From 5650b3b5f6c4d915827768b6bb1f4f4c49982b21 Mon Sep 17 00:00:00 2001 From: rodolfoosvaldobogado Date: Tue, 3 Apr 2012 15:08:58 -0300 Subject: [PATCH] more fixes. take in account when depth textures are used and alpha test fails :)( i really forgot that). --- Source/Core/Common/Src/LinearDiskCache.h | 2 +- .../Core/VideoCommon/Src/PixelShaderGen.cpp | 28 +++++++++++-------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/Source/Core/Common/Src/LinearDiskCache.h b/Source/Core/Common/Src/LinearDiskCache.h index f75e80cd4b..9755c996bd 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 = 6978 + LINEAR_DISKCACHE_VER = 6979 }; // On disk format: diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp index 75718f1abe..28904cbf2f 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp @@ -769,11 +769,6 @@ const char *GeneratePixelShaderCode(PSGRENDER_MODE PSGRenderMode, API_TYPE ApiTy // emulation of unsigned 8 overflow when casting WRITE(p, "prev = frac(4.0f + prev * (255.0f/256.0f)) * (256.0f/255.0f);\n"); - if(Pretest == ALPHAPT_UNDEFINED) - { - WriteAlphaTest(p, ApiType, PSGRenderMode); - } - if (MustWriteToDepth) { // use the texture input of the last texture stage (textemp), hopefully this has been read and is in correct format... @@ -790,7 +785,7 @@ const char *GeneratePixelShaderCode(PSGRENDER_MODE PSGRenderMode, API_TYPE ApiTy WRITE(p, "zCoord = zCoord * (16777216.0f/16777215.0f);\n"); } WRITE(p, "depth = zCoord;\n"); - } + } if (PSGRenderMode == PSGRENDER_DSTALPHA_ALPHA_PASS) WRITE(p, " ocol0 = float4(prev.rgb, "I_ALPHA"[0].a);\n"); @@ -809,6 +804,21 @@ const char *GeneratePixelShaderCode(PSGRENDER_MODE PSGRenderMode, API_TYPE ApiTy // ...and the alpha from ocol0 will be written to the framebuffer. WRITE(p, " ocol0.a = "I_ALPHA"[0].a;\n"); } + + // Alpha test could fail here if depth texture is enabled + if (Pretest == ALPHAPT_ALWAYSFAIL) + { + if(!FastZcomploc) + { + WRITE(p, "discard;\n"); + if(ApiType != API_D3D11) + WRITE(p, "return;\n"); + } + } + else if(Pretest == ALPHAPT_UNDEFINED) + { + WriteAlphaTest(p, ApiType, PSGRenderMode); + } WRITE(p, "}\n"); if (text[sizeof(text) - 1] != 0x7C) @@ -1205,12 +1215,6 @@ static void WriteAlphaTest(char *&p, API_TYPE ApiType,PSGRENDER_MODE PSGRenderMo WRITE(p, tevAlphaFuncsTable[compindex],alphaRef[1]);//lookup the second component from the alpha function table WRITE(p, ")) {\n"); - WRITE(p, "ocol0 = 0;\n"); - if (PSGRenderMode == PSGRENDER_DSTALPHA_DUAL_SOURCE_BLEND) - WRITE(p, "ocol1 = 0;\n"); - if (MustWriteToDepth) - WRITE(p, "depth = zCoord;\n"); - // HAXX: zcomploc is a way to control whether depth test is done before // or after texturing and alpha test. PC GPU does depth test before texturing ONLY if depth value is // not updated during shader execution.