remove old present pipelines

This commit is contained in:
Samuliak 2024-09-30 19:59:30 +02:00
parent 5d01c77efc
commit a3bfde80b0
3 changed files with 31 additions and 33 deletions

View File

@ -120,6 +120,7 @@ MetalRenderer::MetalRenderer()
} }
// Present pipeline // Present pipeline
/*
MTL::Function* fullscreenVertexFunction = utilityLibrary->newFunction(ToNSString("vertexFullscreen")); MTL::Function* fullscreenVertexFunction = utilityLibrary->newFunction(ToNSString("vertexFullscreen"));
MTL::Function* presentFragmentFunction = utilityLibrary->newFunction(ToNSString("fragmentPresent")); MTL::Function* presentFragmentFunction = utilityLibrary->newFunction(ToNSString("fragmentPresent"));
@ -153,6 +154,7 @@ MetalRenderer::MetalRenderer()
debug_printf("failed to create sRGB present pipeline (error: %s)\n", error->localizedDescription()->utf8String()); debug_printf("failed to create sRGB present pipeline (error: %s)\n", error->localizedDescription()->utf8String());
error->release(); error->release();
} }
*/
// Copy texture pipelines // Copy texture pipelines
auto copyTextureToColorPipelineDescriptor = MTL::RenderPipelineDescriptor::alloc()->init(); auto copyTextureToColorPipelineDescriptor = MTL::RenderPipelineDescriptor::alloc()->init();
@ -174,8 +176,8 @@ MetalRenderer::~MetalRenderer()
//delete m_copyTextureToTexturePipeline; //delete m_copyTextureToTexturePipeline;
delete m_restrideBufferPipeline; delete m_restrideBufferPipeline;
m_presentPipelineLinear->release(); //m_presentPipelineLinear->release();
m_presentPipelineSRGB->release(); //m_presentPipelineSRGB->release();
delete m_outputShaderCache; delete m_outputShaderCache;
delete m_pipelineCache; delete m_pipelineCache;

View File

@ -467,8 +467,8 @@ private:
class MetalSamplerCache* m_samplerCache; class MetalSamplerCache* m_samplerCache;
// Pipelines // Pipelines
MTL::RenderPipelineState* m_presentPipelineLinear; //MTL::RenderPipelineState* m_presentPipelineLinear;
MTL::RenderPipelineState* m_presentPipelineSRGB; //MTL::RenderPipelineState* m_presentPipelineSRGB;
// Hybrid pipelines // Hybrid pipelines
class MetalVoidVertexPipeline* m_copyBufferToBufferPipeline; class MetalVoidVertexPipeline* m_copyBufferToBufferPipeline;

View File

@ -3,54 +3,50 @@
#define __STRINGIFY(x) #x #define __STRINGIFY(x) #x
#define _STRINGIFY(x) __STRINGIFY(x) #define _STRINGIFY(x) __STRINGIFY(x)
constexpr const char* utilityShaderSource = R"V0G0N( constexpr const char* utilityShaderSource = R"(#include <metal_stdlib>
#include <metal_stdlib>
using namespace metal; using namespace metal;
#define GET_BUFFER_BINDING(index) (28 + index) #define GET_BUFFER_BINDING(index) (28 + index)
#define GET_TEXTURE_BINDING(index) (29 + index) #define GET_TEXTURE_BINDING(index) (29 + index)
#define GET_SAMPLER_BINDING(index) (14 + index)\n #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)}; //constant float2 positions[] = {float2(-1.0, -3.0), float2(-1.0, 1.0), float2(3.0, 1.0)};
//
struct VertexOut { //struct VertexOut {
float4 position [[position]]; // float4 position [[position]];
float2 texCoord; // float2 texCoord;
}; //};
//
vertex VertexOut vertexFullscreen(ushort vid [[vertex_id]]) { //vertex VertexOut vertexFullscreen(ushort vid [[vertex_id]]) {
VertexOut out; // VertexOut out;
out.position = float4(positions[vid], 0.0, 1.0); // out.position = float4(positions[vid], 0.0, 1.0);
out.texCoord = positions[vid] * 0.5 + 0.5; // out.texCoord = positions[vid] * 0.5 + 0.5;
out.texCoord.y = 1.0 - out.texCoord.y; // out.texCoord.y = 1.0 - out.texCoord.y;
//
return out; // return out;
} //}
//
fragment float4 fragmentPresent(VertexOut in [[stage_in]], texture2d<float> tex [[texture(0)]], sampler samplr [[sampler(0)]]) { //fragment float4 fragmentPresent(VertexOut in [[stage_in]], texture2d<float> tex [[texture(0)]], //sampler samplr [[sampler(0)]]) {
return tex.sample(samplr, in.texCoord); // return tex.sample(samplr, in.texCoord);
} //}
vertex void vertexCopyBufferToBuffer(uint vid [[vertex_id]], device uint8_t* src [[buffer(GET_BUFFER_BINDING(0))]], device uint8_t* dst [[buffer(GET_BUFFER_BINDING(1))]]) { vertex void vertexCopyBufferToBuffer(uint vid [[vertex_id]], device uint8_t* src [[buffer(GET_BUFFER_BINDING(0))]], device uint8_t* dst [[buffer(GET_BUFFER_BINDING(1))]]) {
dst[vid] = src[vid]; dst[vid] = src[vid];
} }
/* //vertex void vertexCopyTextureToTexture(uint vid [[vertex_id]], texture2d<float, access::read> src [[texture(GET_TEXTURE_BINDING(0))]], texture2d<float, access::write> dst [[texture(GET_TEXTURE_BINDING(1))]], constant uint32_t& width [[buffer(GET_BUFFER_BINDING(0))]]) {
vertex void vertexCopyTextureToTexture(uint vid [[vertex_id]], texture2d<float, access::read> src [[texture(GET_TEXTURE_BINDING(0))]], texture2d<float, access::write> dst [[texture(GET_TEXTURE_BINDING(1))]], constant uint32_t& width [[buffer(GET_BUFFER_BINDING(0))]]) { // uint2 coord = uint2(vid % width, vid / width);
uint2 coord = uint2(vid % width, vid / width); // return dst.write(float4(src.read(coord).r, 0.0, 0.0, 0.0), coord);
return dst.write(float4(src.read(coord).r, 0.0, 0.0, 0.0), coord); //}
}
*/
struct RestrideParams { struct RestrideParams {
uint oldStride; uint oldStride;
uint newStride; uint newStride;
}; };
// TODO: use uint32? Since that would require less iterations
vertex void vertexRestrideBuffer(uint vid [[vertex_id]], device uint8_t* src [[buffer(GET_BUFFER_BINDING(0))]], device uint8_t* dst [[buffer(GET_BUFFER_BINDING(1))]], constant RestrideParams& params [[buffer(GET_BUFFER_BINDING(2))]]) { vertex void vertexRestrideBuffer(uint vid [[vertex_id]], device uint8_t* src [[buffer(GET_BUFFER_BINDING(0))]], device uint8_t* dst [[buffer(GET_BUFFER_BINDING(1))]], constant RestrideParams& params [[buffer(GET_BUFFER_BINDING(2))]]) {
for (uint32_t i = 0; i < params.oldStride; i++) { for (uint32_t i = 0; i < params.oldStride; i++) {
dst[vid * params.newStride + i] = src[vid * params.oldStride + i]; dst[vid * params.newStride + i] = src[vid * params.oldStride + i];
} }
} }
)V0G0N"; )";