Skip to content

Commit

Permalink
Vulkan: Declare gl_Position as invariant. See #11583
Browse files Browse the repository at this point in the history
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...
  • Loading branch information
hrydgard committed Sep 9, 2022
1 parent 42b2b0a commit e56e594
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions GPU/Common/VertexShaderGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit e56e594

Please sign in to comment.