From 8ff1ce68c31c82cdde19909622e3b249c56741b3 Mon Sep 17 00:00:00 2001 From: Samuliak Date: Wed, 10 Apr 2024 19:55:56 +0200 Subject: [PATCH] metal: flip y texture coordinate --- .../renderer_metal/mtl_pipeline_cache.cpp | 13 +++++++------ src/video_core/renderer_metal/renderer_metal.cpp | 13 +++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/video_core/renderer_metal/mtl_pipeline_cache.cpp b/src/video_core/renderer_metal/mtl_pipeline_cache.cpp index e80b3eb3e0..d142ccbf89 100644 --- a/src/video_core/renderer_metal/mtl_pipeline_cache.cpp +++ b/src/video_core/renderer_metal/mtl_pipeline_cache.cpp @@ -279,10 +279,10 @@ std::unique_ptr PipelineCache::CreateGraphicsPipeline( #include using namespace metal; - constant float2 texCoords[] = { - float2(0.0, -1.0), - float2(0.0, 1.0), - float2(2.0, 1.0), + constant float2 positions[] = { + float2(-1.0, -3.0), + float2(-1.0, 1.0), + float2( 3.0, 1.0), }; struct VertexOut { @@ -292,8 +292,9 @@ std::unique_ptr PipelineCache::CreateGraphicsPipeline( vertex VertexOut vertexMain(uint vid [[vertex_id]]) { VertexOut out; - out.position = float4(texCoords[vid] * 2.0 - 1.0, 0.0, 1.0); - out.texCoord = texCoords[vid]; + 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; } diff --git a/src/video_core/renderer_metal/renderer_metal.cpp b/src/video_core/renderer_metal/renderer_metal.cpp index e0a0031d08..efb83743c6 100644 --- a/src/video_core/renderer_metal/renderer_metal.cpp +++ b/src/video_core/renderer_metal/renderer_metal.cpp @@ -80,10 +80,10 @@ void RendererMetal::CreateBlitPipelineState() { #include using namespace metal; - constant float2 texCoords[] = { - float2(0.0, -1.0), - float2(0.0, 1.0), - float2(2.0, 1.0), + constant float2 positions[] = { + float2(-1.0, -3.0), + float2(-1.0, 1.0), + float2( 3.0, 1.0), }; struct VertexOut { @@ -93,8 +93,9 @@ void RendererMetal::CreateBlitPipelineState() { vertex VertexOut vertexMain(uint vid [[vertex_id]]) { VertexOut out; - out.position = float4(texCoords[vid] * 2.0 - 1.0, 0.0, 1.0); - out.texCoord = texCoords[vid]; + 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; }