From e52e9094ca5afb60bfbb67768302e3d9c8c30a85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 12 Jul 2022 00:12:57 +0200 Subject: [PATCH] Vulkan fragment shaders: Don't opportunistically emit "layout (early_fragment_tests)" The purpose of this is not really for optimization, it's to get a specific behavior that we really don't care about. Drivers are pretty good at getting this potential performance improvement automatically if it's possible without changing the output. git blame says I added it, heh. Don't think it'll make much difference one way or another, though, but trying to reduce complexity. --- GPU/Common/FragmentShaderGenerator.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/GPU/Common/FragmentShaderGenerator.cpp b/GPU/Common/FragmentShaderGenerator.cpp index cb965bf782..2571690e4b 100644 --- a/GPU/Common/FragmentShaderGenerator.cpp +++ b/GPU/Common/FragmentShaderGenerator.cpp @@ -111,7 +111,6 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu if (compat.glslES30 || compat.shaderLanguage == ShaderLanguage::GLSL_VULKAN) shading = doFlatShading ? "flat" : ""; - bool earlyFragmentTests = ((!enableAlphaTest && !enableColorTest) || testForceToZero) && !gstate_c.Supports(GPU_ROUND_FRAGMENT_DEPTH_TO_16BIT); bool useAdrenoBugWorkaround = id.Bit(FS_BIT_NO_DEPTH_CANNOT_DISCARD_STENCIL); bool readFramebuffer = replaceBlend == REPLACE_BLEND_COPY_FBO || colorWriteMask; @@ -131,9 +130,7 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu } if (compat.shaderLanguage == ShaderLanguage::GLSL_VULKAN) { - if (earlyFragmentTests) { - WRITE(p, "layout (early_fragment_tests) in;\n"); - } else if (useAdrenoBugWorkaround && !gstate_c.Supports(GPU_ROUND_FRAGMENT_DEPTH_TO_16BIT)) { + if (useAdrenoBugWorkaround && !gstate_c.Supports(GPU_ROUND_FRAGMENT_DEPTH_TO_16BIT)) { WRITE(p, "layout (depth_unchanged) out float gl_FragDepth;\n"); } @@ -1052,7 +1049,7 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu WRITE(p, " z = (1.0/65535.0) * floor(z * 65535.0);\n"); } WRITE(p, " gl_FragDepth = z;\n"); - } else if (!earlyFragmentTests && useAdrenoBugWorkaround) { + } else if (useAdrenoBugWorkaround) { // Adreno (and possibly MESA/others) apply early frag tests even with discard in the shader. // Writing depth prevents the bug, even with depth_unchanged specified. WRITE(p, " gl_FragDepth = gl_FragCoord.z;\n");