From eb153cfdedf4ec3563576aca5deb9ef33338ac7d Mon Sep 17 00:00:00 2001 From: NeoBrainX Date: Sat, 29 Jun 2013 23:14:08 +0200 Subject: [PATCH] PixelShaderGen: Fix a small early-ztest related bug. --- Source/Core/VideoCommon/Src/PixelShaderGen.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp index ad8cc4d7c5..1c10459160 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp @@ -592,6 +592,8 @@ static void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_TYPE Api if (per_pixel_depth && bpmem.zcontrol.early_ztest) out.Write("depth = zCoord;\n"); + // Note: depth texture output is only written to depth buffer if late depth test is used + // theoretical final depth value is used for fog calculation, though, so we have to emulate ztextures anyway if (bpmem.ztex2.op != ZTEXTURE_DISABLE && !skip_ztexture) { // use the texture input of the last texture stage (textemp), hopefully this has been read and is in correct format... @@ -603,13 +605,9 @@ static void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_TYPE Api out.Write("zCoord = zCoord * (16777215.0f/16777216.0f);\n"); out.Write("zCoord = frac(zCoord);\n"); out.Write("zCoord = zCoord * (16777216.0f/16777215.0f);\n"); - - // Note: depth texture output is only written to depth buffer if late depth test is used - // final depth value is used for fog calculation, though - if (per_pixel_depth) - out.Write("depth = zCoord;\n"); } - else if (per_pixel_depth && !bpmem.zcontrol.early_ztest) + + if (per_pixel_depth && !bpmem.zcontrol.early_ztest) out.Write("depth = zCoord;\n"); if (dstAlphaMode == DSTALPHA_ALPHA_PASS)