1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-04 10:03:36 +00:00

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
This commit is contained in:
Sergey Lipskiy 2018-12-18 15:23:57 +07:00
parent a5fc0689ac
commit cb0cf5bed9
2 changed files with 15 additions and 19 deletions

View File

@ -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"
;
}

View File

@ -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;