From e56e5947d5d4cadad7e69f2f3c3dbfea5d95a15b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 10 Sep 2022 00:26:23 +0200 Subject: [PATCH] Vulkan: Declare gl_Position as invariant. See #11583 The code that computes shader outputs declared as invariant gets certain optimizations disabled that could change the value - it makes it more likely that different ways to do the same calculations end up with the same value. This can help some types of Z fighting problems and similar. Generally not a big deal for performance, plus, we're rarely vshader-bottlenecked... --- GPU/Common/VertexShaderGenerator.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/GPU/Common/VertexShaderGenerator.cpp b/GPU/Common/VertexShaderGenerator.cpp index 071f1f4f5b04..ccda9af86b12 100644 --- a/GPU/Common/VertexShaderGenerator.cpp +++ b/GPU/Common/VertexShaderGenerator.cpp @@ -276,6 +276,9 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag // See the fragment shader generator WRITE(p, "layout (location = 3) out highp float v_fogdepth;\n"); } + + WRITE(p, "invariant gl_Position;\n"); + } else if (compat.shaderLanguage == HLSL_D3D11 || compat.shaderLanguage == HLSL_D3D9) { // Note: These two share some code after this hellishly large if/else. if (compat.shaderLanguage == HLSL_D3D11) {