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: diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp index 662c9c59a8..89032c67ea 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp @@ -1181,10 +1181,31 @@ static bool WriteAlphaTest(char *&p, API_TYPE ApiType,DSTALPHA_MODE dstAlphaMode compindex = bpmem.alphaFunc.comp1 % 8; WRITE(p, tevAlphaFuncsTable[compindex],alphaRef[1]);//lookup the second component from the alpha function table - WRITE(p, ")){ocol0 = 0;%s%s discard;%s}\n", - dstAlphaMode == DSTALPHA_DUAL_SOURCE_BLEND ? "ocol1 = 0;" : "", - DepthTextureEnable ? "depth = 1.f;" : "", - (ApiType != API_D3D11) ? "return;" : ""); + WRITE(p, ")) {\n"); + + WRITE(p, "ocol0 = 0;\n"); + if (dstAlphaMode == DSTALPHA_DUAL_SOURCE_BLEND) + 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"); + if (ApiType != API_D3D11) + WRITE(p, "return;\n"); + } + + WRITE(p, "}\n"); return true; } @@ -1242,4 +1263,4 @@ static void WriteFog(char *&p) WRITE(p, " prev.rgb = lerp(prev.rgb,"I_FOG"[0].rgb,fog);\n"); -} \ No newline at end of file +}