From 006923e871e496a7c6c0fe9ba76da4ee939ce14e Mon Sep 17 00:00:00 2001 From: skidau Date: Thu, 22 Mar 2012 20:36:41 +1100 Subject: [PATCH 1/3] Disabled zcomploc while update_enable has been set in zmode. Fixes zcomploc in F-Zero GX. --- Source/Core/VideoCommon/Src/PixelShaderGen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp index e4944c842c..ec4eb2c70b 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp @@ -1147,7 +1147,7 @@ static bool WriteAlphaTest(char *&p, API_TYPE ApiType,DSTALPHA_MODE dstAlphaMode WRITE(p, "ocol1 = 0;\n"); if (DepthTextureEnable) WRITE(p, "depth = 1.f;\n"); - if (!bpmem.zcontrol.zcomploc) + if (!(bpmem.zcontrol.zcomploc && bpmem.zmode.updateenable)) { WRITE(p, "discard;\n"); if (ApiType != API_D3D11) From 339ee98e6258024622ef509aafe25ff46ad19341 Mon Sep 17 00:00:00 2001 From: Pierre Bourdon Date: Thu, 22 Mar 2012 22:10:23 +0100 Subject: [PATCH 2/3] Add a comment before the zcomploc test explaining the implementation/hack --- Source/Core/VideoCommon/Src/PixelShaderGen.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp index 46ac264889..79afc45974 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp @@ -1198,6 +1198,16 @@ static bool WriteAlphaTest(char *&p, API_TYPE ApiType,DSTALPHA_MODE dstAlphaMode WRITE(p, "ocol1 = 0;\n"); if (DepthTextureEnable) WRITE(p, "depth = 1.f;\n"); + + // HAXX: zcomploc is a way to control whether depth test is done before + // or after texturing and alpha test. PC GPU have no way to support this + // feature properly as of 2012: depth buffer and depth test are not + // programmable and the depth test is always done after texturing. + // + // We implement "depth test before texturing" by discarding the fragment + // when the alpha test fail. This is not a correct implementation because + // even if the depth test fails the fragment could be alpha blended, but + // we don't have a choice. if (!(bpmem.zcontrol.zcomploc && bpmem.zmode.updateenable)) { WRITE(p, "discard;\n"); From c662b8ee2f55f28a14c51dfe44309a6dcf3710d8 Mon Sep 17 00:00:00 2001 From: Pierre Bourdon Date: Sat, 24 Mar 2012 20:46:40 +0100 Subject: [PATCH 3/3] Bump the shader cache version --- Source/Core/Common/Src/LinearDiskCache.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Common/Src/LinearDiskCache.h b/Source/Core/Common/Src/LinearDiskCache.h index 582eebbd22..eae60885b7 100644 --- a/Source/Core/Common/Src/LinearDiskCache.h +++ b/Source/Core/Common/Src/LinearDiskCache.h @@ -24,7 +24,7 @@ // Increment this every time you change shader generation code. enum { - LINEAR_DISKCACHE_VER = 6973 + LINEAR_DISKCACHE_VER = 6974 }; // On disk format: