mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-01-07 15:48:15 +01:00
don't stringify shader source & move vertex buffer bindings by 1
This commit is contained in:
parent
67a64c9fe9
commit
c05b2d0b48
@ -21,13 +21,13 @@ struct MetalPixelFormatSupport
|
||||
};
|
||||
|
||||
#define MAX_MTL_BUFFERS 31
|
||||
// Buffer index 30 is reserved for the support buffer, buffer indices 27-29 are reserved for the helper shaders
|
||||
#define GET_MTL_VERTEX_BUFFER_INDEX(index) (MAX_MTL_BUFFERS - index - 5)
|
||||
// Buffer indices 28-30 are reserved for the helper shaders
|
||||
#define GET_MTL_VERTEX_BUFFER_INDEX(index) (MAX_MTL_BUFFERS - index - 4)
|
||||
|
||||
#define MAX_MTL_TEXTURES 31
|
||||
#define MAX_MTL_SAMPLERS 16
|
||||
|
||||
#define GET_HELPER_BUFFER_BINDING(index) (27 + index)
|
||||
#define GET_HELPER_BUFFER_BINDING(index) (28 + index)
|
||||
#define GET_HELPER_TEXTURE_BINDING(index) (29 + index)
|
||||
#define GET_HELPER_SAMPLER_BINDING(index) (14 + index)
|
||||
|
||||
|
@ -17,11 +17,8 @@
|
||||
#include "Cafe/HW/Latte/Core/LatteShader.h"
|
||||
#include "Cafe/HW/Latte/Core/LatteIndices.h"
|
||||
#include "Cemu/Logging/CemuDebugLogging.h"
|
||||
#include "Common/precompiled.h"
|
||||
#include "HW/Latte/Core/LatteConst.h"
|
||||
#include "HW/Latte/Renderer/Metal/MetalCommon.h"
|
||||
#include "Metal/MTLDevice.hpp"
|
||||
#include "Metal/MTLRenderCommandEncoder.hpp"
|
||||
#include "gui/guiWrapper.h"
|
||||
|
||||
#define COMMIT_TRESHOLD 256
|
||||
@ -98,15 +95,9 @@ MetalRenderer::MetalRenderer()
|
||||
|
||||
// Utility shader library
|
||||
|
||||
// Process the source first
|
||||
std::string processedUtilityShaderSource = utilityShaderSource;
|
||||
processedUtilityShaderSource.pop_back();
|
||||
processedUtilityShaderSource.erase(processedUtilityShaderSource.begin());
|
||||
processedUtilityShaderSource = "#include <metal_stdlib>\nusing namespace metal;\n#define GET_BUFFER_BINDING(index) (27 + index)\n#define GET_TEXTURE_BINDING(index) (29 + index)\n#define GET_SAMPLER_BINDING(index) (14 + index)\n" + processedUtilityShaderSource;
|
||||
|
||||
// Create the library
|
||||
NS::Error* error = nullptr;
|
||||
MTL::Library* utilityLibrary = m_device->newLibrary(ToNSString(processedUtilityShaderSource.c_str()), nullptr, &error);
|
||||
MTL::Library* utilityLibrary = m_device->newLibrary(ToNSString(utilityShaderSource), nullptr, &error);
|
||||
if (error)
|
||||
{
|
||||
debug_printf("failed to create utility library (error: %s)\n", error->localizedDescription()->utf8String());
|
||||
|
@ -3,7 +3,14 @@
|
||||
#define __STRINGIFY(x) #x
|
||||
#define _STRINGIFY(x) __STRINGIFY(x)
|
||||
|
||||
constexpr const char* utilityShaderSource = _STRINGIFY((
|
||||
constexpr const char* utilityShaderSource = R"V0G0N(
|
||||
#include <metal_stdlib>
|
||||
using namespace metal;
|
||||
|
||||
#define GET_BUFFER_BINDING(index) (28 + index)
|
||||
#define GET_TEXTURE_BINDING(index) (29 + index)
|
||||
#define GET_SAMPLER_BINDING(index) (14 + index)\n
|
||||
|
||||
constant float2 positions[] = {float2(-1.0, -3.0), float2(-1.0, 1.0), float2(3.0, 1.0)};
|
||||
|
||||
struct VertexOut {
|
||||
@ -48,4 +55,4 @@ vertex void vertexRestrideBuffer(uint vid [[vertex_id]], device uint8_t* src [[b
|
||||
dst[vid * params.newStride + i] = src[vid * params.oldStride + i];
|
||||
}
|
||||
}
|
||||
));
|
||||
)V0G0N";
|
||||
|
Loading…
Reference in New Issue
Block a user