From f95b7c58779f01d9077996da67953d8d9acd058c Mon Sep 17 00:00:00 2001 From: gdkchan Date: Sat, 29 Jul 2023 18:47:03 -0300 Subject: Fix incorrect fragment origin when YNegate is enabled (#4673) * Fix incorrect fragment origin when YNegate is enabled * Shader cache version bump * Do not update support buffer if shader does not read gl_FragCoord * Pass unscaled viewport size to the support buffer --- src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs | 15 ++++++++++++--- .../CodeGen/Spirv/SpirvGenerator.cs | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'src/Ryujinx.Graphics.Shader/CodeGen') diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs index 2370b49f..2a45e23d 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs @@ -188,10 +188,19 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl context.AppendLine(); } - if (context.Config.Stage == ShaderStage.Fragment && context.Config.GpuAccessor.QueryEarlyZForce()) + if (context.Config.Stage == ShaderStage.Fragment) { - context.AppendLine("layout(early_fragment_tests) in;"); - context.AppendLine(); + if (context.Config.GpuAccessor.QueryEarlyZForce()) + { + context.AppendLine("layout (early_fragment_tests) in;"); + context.AppendLine(); + } + + if (context.Config.Properties.OriginUpperLeft) + { + context.AppendLine("layout (origin_upper_left) in vec4 gl_FragCoord;"); + context.AppendLine(); + } } if ((info.HelperFunctionsMask & HelperFunctionsMask.MultiplyHighS32) != 0) diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/SpirvGenerator.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/SpirvGenerator.cs index c8fcd75a..21797975 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/SpirvGenerator.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/SpirvGenerator.cs @@ -251,7 +251,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv } else if (context.Config.Stage == ShaderStage.Fragment) { - context.AddExecutionMode(spvFunc, context.Config.Options.TargetApi == TargetApi.Vulkan + context.AddExecutionMode(spvFunc, context.Config.Properties.OriginUpperLeft ? ExecutionMode.OriginUpperLeft : ExecutionMode.OriginLowerLeft); -- cgit v1.2.3