forked from ShuriZma/suyu
1
0
Fork 0

metal: flip y texture coordinate

This commit is contained in:
Samuliak 2024-04-10 19:55:56 +02:00
parent e3ab4c6349
commit 8ff1ce68c3
No known key found for this signature in database
2 changed files with 14 additions and 12 deletions

View File

@ -279,10 +279,10 @@ std::unique_ptr<GraphicsPipeline> PipelineCache::CreateGraphicsPipeline(
#include <metal_stdlib>
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<GraphicsPipeline> 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;
}

View File

@ -80,10 +80,10 @@ void RendererMetal::CreateBlitPipelineState() {
#include <metal_stdlib>
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;
}