From a3bfde80b08d489e2291563598d41217d3c321a2 Mon Sep 17 00:00:00 2001 From: Samuliak Date: Mon, 30 Sep 2024 19:59:30 +0200 Subject: [PATCH] remove old present pipelines --- .../HW/Latte/Renderer/Metal/MetalRenderer.cpp | 6 ++- .../HW/Latte/Renderer/Metal/MetalRenderer.h | 4 +- .../Renderer/Metal/UtilityShaderSource.h | 54 +++++++++---------- 3 files changed, 31 insertions(+), 33 deletions(-) diff --git a/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp index 0587b268..f33f8af2 100644 --- a/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp @@ -120,6 +120,7 @@ MetalRenderer::MetalRenderer() } // Present pipeline + /* MTL::Function* fullscreenVertexFunction = utilityLibrary->newFunction(ToNSString("vertexFullscreen")); 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()); error->release(); } + */ // Copy texture pipelines auto copyTextureToColorPipelineDescriptor = MTL::RenderPipelineDescriptor::alloc()->init(); @@ -174,8 +176,8 @@ MetalRenderer::~MetalRenderer() //delete m_copyTextureToTexturePipeline; delete m_restrideBufferPipeline; - m_presentPipelineLinear->release(); - m_presentPipelineSRGB->release(); + //m_presentPipelineLinear->release(); + //m_presentPipelineSRGB->release(); delete m_outputShaderCache; delete m_pipelineCache; diff --git a/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.h b/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.h index 327104a1..2c9b150f 100644 --- a/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.h +++ b/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.h @@ -467,8 +467,8 @@ private: class MetalSamplerCache* m_samplerCache; // Pipelines - MTL::RenderPipelineState* m_presentPipelineLinear; - MTL::RenderPipelineState* m_presentPipelineSRGB; + //MTL::RenderPipelineState* m_presentPipelineLinear; + //MTL::RenderPipelineState* m_presentPipelineSRGB; // Hybrid pipelines class MetalVoidVertexPipeline* m_copyBufferToBufferPipeline; diff --git a/src/Cafe/HW/Latte/Renderer/Metal/UtilityShaderSource.h b/src/Cafe/HW/Latte/Renderer/Metal/UtilityShaderSource.h index 95606df7..9fba1946 100644 --- a/src/Cafe/HW/Latte/Renderer/Metal/UtilityShaderSource.h +++ b/src/Cafe/HW/Latte/Renderer/Metal/UtilityShaderSource.h @@ -3,54 +3,50 @@ #define __STRINGIFY(x) #x #define _STRINGIFY(x) __STRINGIFY(x) -constexpr const char* utilityShaderSource = R"V0G0N( -#include +constexpr const char* utilityShaderSource = R"(#include 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 { - float4 position [[position]]; - float2 texCoord; -}; - -vertex VertexOut vertexFullscreen(ushort vid [[vertex_id]]) { - VertexOut out; - out.position = float4(positions[vid], 0.0, 1.0); - out.texCoord = positions[vid] * 0.5 + 0.5; - out.texCoord.y = 1.0 - out.texCoord.y; - - return out; -} - -fragment float4 fragmentPresent(VertexOut in [[stage_in]], texture2d tex [[texture(0)]], sampler samplr [[sampler(0)]]) { - return tex.sample(samplr, in.texCoord); -} +//constant float2 positions[] = {float2(-1.0, -3.0), float2(-1.0, 1.0), float2(3.0, 1.0)}; +// +//struct VertexOut { +// float4 position [[position]]; +// float2 texCoord; +//}; +// +//vertex VertexOut vertexFullscreen(ushort vid [[vertex_id]]) { +// VertexOut out; +// out.position = float4(positions[vid], 0.0, 1.0); +// out.texCoord = positions[vid] * 0.5 + 0.5; +// out.texCoord.y = 1.0 - out.texCoord.y; +// +// return out; +//} +// +//fragment float4 fragmentPresent(VertexOut in [[stage_in]], texture2d tex [[texture(0)]], //sampler samplr [[sampler(0)]]) { +// 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))]]) { dst[vid] = src[vid]; } -/* -vertex void vertexCopyTextureToTexture(uint vid [[vertex_id]], texture2d src [[texture(GET_TEXTURE_BINDING(0))]], texture2d dst [[texture(GET_TEXTURE_BINDING(1))]], constant uint32_t& width [[buffer(GET_BUFFER_BINDING(0))]]) { - uint2 coord = uint2(vid % width, vid / width); - return dst.write(float4(src.read(coord).r, 0.0, 0.0, 0.0), coord); -} -*/ +//vertex void vertexCopyTextureToTexture(uint vid [[vertex_id]], texture2d src [[texture(GET_TEXTURE_BINDING(0))]], texture2d dst [[texture(GET_TEXTURE_BINDING(1))]], constant uint32_t& width [[buffer(GET_BUFFER_BINDING(0))]]) { +// uint2 coord = uint2(vid % width, vid / width); +// return dst.write(float4(src.read(coord).r, 0.0, 0.0, 0.0), coord); +//} struct RestrideParams { uint oldStride; 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))]]) { for (uint32_t i = 0; i < params.oldStride; i++) { dst[vid * params.newStride + i] = src[vid * params.oldStride + i]; } } -)V0G0N"; +)";