From cb0cf5bed9162312621df22bdff972da27c02eb1 Mon Sep 17 00:00:00 2001 From: Sergey Lipskiy Date: Tue, 18 Dec 2018 15:23:57 +0700 Subject: [PATCH] Fix depth_compare shader: always write depth to buffer when otherMode.depthCompare flag is off. Up shader storage version. Fixed 2 players mode in Extreme-G XG2 (U) with N64 depth compare enabled, #1963 --- .../GLSL/glsl_CombinerProgramBuilder.cpp | 32 ++++++++----------- .../OpenGLContext/GLSL/glsl_ShaderStorage.h | 2 +- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/Graphics/OpenGLContext/GLSL/glsl_CombinerProgramBuilder.cpp b/src/Graphics/OpenGLContext/GLSL/glsl_CombinerProgramBuilder.cpp index def82f4a..13d79037 100644 --- a/src/Graphics/OpenGLContext/GLSL/glsl_CombinerProgramBuilder.cpp +++ b/src/Graphics/OpenGLContext/GLSL/glsl_CombinerProgramBuilder.cpp @@ -1957,9 +1957,9 @@ public: ; if (_glinfo.imageTextures) { m_part += - " ivec2 coord = ivec2(gl_FragCoord.xy); \n" - " highp vec4 depthZ = imageLoad(uDepthImageZ,coord); \n" - " highp vec4 depthDeltaZ = imageLoad(uDepthImageDeltaZ,coord);\n" + " ivec2 coord = ivec2(gl_FragCoord.xy); \n" + " highp vec4 depthZ = imageLoad(uDepthImageZ,coord); \n" + " highp vec4 depthDeltaZ = imageLoad(uDepthImageDeltaZ,coord);\n" ; } m_part += @@ -1968,14 +1968,14 @@ public: " if (uDepthSource == 1) { \n" " dzMin = dz = uDeltaZ; \n" " } else { \n" - " dz = 4.0*fwidth(curZ); \n" + " dz = 4.0*fwidth(curZ); \n" " dzMin = min(dz, depthDeltaZ.r); \n" " } \n" " bool bInfront = curZ < bufZ; \n" " bool bFarther = (curZ + dzMin) >= bufZ; \n" " bool bNearer = (curZ - dzMin) <= bufZ; \n" " bool bMax = bufZ == 1.0; \n" - " bool bRes; \n" + " bool bRes = false; \n" " switch (uDepthMode) { \n" " case 1: \n" " bRes = bMax || bNearer; \n" @@ -1987,30 +1987,26 @@ public: " case 3: \n" " bRes = bFarther && bNearer && !bMax; \n" " break; \n" - " default: \n" - " bRes = bInfront; \n" - " break; \n" " } \n" - " if (uEnableDepthUpdate != 0 && bRes) { \n" + " bRes = bRes || (uEnableDepthCompare == 0); \n" + " if (uEnableDepthUpdate != 0 && bRes) { \n" ; if (_glinfo.imageTextures) { m_part += - " highp vec4 depthOutZ = vec4(curZ, 1.0, 1.0, 1.0); \n" - " highp vec4 depthOutDeltaZ = vec4(dz, 1.0, 1.0, 1.0); \n" - " imageStore(uDepthImageZ, coord, depthOutZ); \n" - " imageStore(uDepthImageDeltaZ, coord, depthOutDeltaZ); \n" + " highp vec4 depthOutZ = vec4(curZ, 1.0, 1.0, 1.0); \n" + " highp vec4 depthOutDeltaZ = vec4(dz, 1.0, 1.0, 1.0); \n" + " imageStore(uDepthImageZ, coord, depthOutZ); \n" + " imageStore(uDepthImageDeltaZ, coord, depthOutDeltaZ); \n" ; } else if (_glinfo.ext_fetch) { m_part += - " depthZ.r = curZ; \n" - " depthDeltaZ.r = dz; \n" + " depthZ.r = curZ; \n" + " depthDeltaZ.r = dz; \n" ; } m_part += " } \n" - " if (uEnableDepthCompare != 0) \n" - " return bRes; \n" - " return true; \n" + " return bRes; \n" "} \n" ; } diff --git a/src/Graphics/OpenGLContext/GLSL/glsl_ShaderStorage.h b/src/Graphics/OpenGLContext/GLSL/glsl_ShaderStorage.h index 95028291..5b762284 100644 --- a/src/Graphics/OpenGLContext/GLSL/glsl_ShaderStorage.h +++ b/src/Graphics/OpenGLContext/GLSL/glsl_ShaderStorage.h @@ -20,7 +20,7 @@ namespace glsl { bool _saveCombinerKeys(const graphics::Combiners & _combiners) const; bool _loadFromCombinerKeys(graphics::Combiners & _combiners); - const u32 m_formatVersion = 0x22U; + const u32 m_formatVersion = 0x23U; const u32 m_keysFormatVersion = 0x04; const opengl::GLInfo & m_glinfo; opengl::CachedUseProgram * m_useProgram;