From d710eda0c5332293afc44d6fd50b95978c29e60c Mon Sep 17 00:00:00 2001 From: Pierre Bourdon Date: Sun, 4 Sep 2011 04:44:50 +0200 Subject: [PATCH 1/3] Clean up a bit the shader code generation for alpha test fails --- Source/Core/VideoCommon/Src/PixelShaderGen.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp index 530ecd54bb..9146f4cb09 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp @@ -1139,7 +1139,18 @@ 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%sdiscard;%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"); + WRITE(p, "discard;\n"); + if (ApiType != API_D3D11) + WRITE(p, "return;\n"); + + WRITE(p, "}\n"); return true; } From 0bdf8646f09c2f7cf2324ddf6cacf6cc1b31da07 Mon Sep 17 00:00:00 2001 From: Pierre Bourdon Date: Sun, 4 Sep 2011 05:08:09 +0200 Subject: [PATCH 2/3] Proof of concept zcomploc implementation Fixes a few depth related graphics bugs. Example in Baten Kaitos (GKBEAF): Before: http://i.imgur.com/EDdVA.png After: http://i.imgur.com/h6GuY.png Still a few bugs in this implementation: zcomploc switching is not yet implemented, and the color is wrong with this test: http://codepad.org/7GpxklOi (red on Dolphin, gray on Wii). --- Source/Core/VideoCommon/Src/PixelShaderGen.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp index 9146f4cb09..50de52df51 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp @@ -1146,9 +1146,12 @@ static bool WriteAlphaTest(char *&p, API_TYPE ApiType,DSTALPHA_MODE dstAlphaMode WRITE(p, "ocol1 = 0;\n"); if (DepthTextureEnable) WRITE(p, "depth = 1.f;\n"); - WRITE(p, "discard;\n"); - if (ApiType != API_D3D11) - WRITE(p, "return;\n"); + if (!bpmem.zcontrol.zcomploc) + { + WRITE(p, "discard;\n"); + if (ApiType != API_D3D11) + WRITE(p, "return;\n"); + } WRITE(p, "}\n"); return true; From d3ecf9821335fde15d429ffc1bd58dc0b4f6c665 Mon Sep 17 00:00:00 2001 From: Pierre Bourdon Date: Sun, 4 Sep 2011 05:38:32 +0200 Subject: [PATCH 3/3] Include the zcomploc bit in the shader UID Fixes issues with switching zcomploc on/off during execution. --- Source/Core/VideoCommon/Src/PixelShaderGen.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp index 50de52df51..e4944c842c 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp @@ -62,7 +62,8 @@ void GetPixelShaderId(PIXELSHADERUID *uid, DSTALPHA_MODE dstAlphaMode) uid->values[2] = (u32)bpmem.fog.c_proj_fsel.fsel | ((u32)bpmem.fog.c_proj_fsel.proj << 3) | - ((u32)enableZTexture << 4) | ((u32)bpmem.fogRange.Base.Enabled << 5); + ((u32)enableZTexture << 4) | ((u32)bpmem.fogRange.Base.Enabled << 5) | + ((u32)bpmem.zcontrol.zcomploc << 6); if(g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting) { @@ -1148,7 +1149,7 @@ static bool WriteAlphaTest(char *&p, API_TYPE ApiType,DSTALPHA_MODE dstAlphaMode WRITE(p, "depth = 1.f;\n"); if (!bpmem.zcontrol.zcomploc) { - WRITE(p, "discard;\n"); + WRITE(p, "discard;\n"); if (ApiType != API_D3D11) WRITE(p, "return;\n"); }