diff options
| author | NanoByte011 <nanobyte011@hotmail.com> | 2014-12-25 00:34:22 -0700 |
|---|---|---|
| committer | Scott Mansell <phiren@gmail.com> | 2015-01-23 03:31:54 +1300 |
| commit | 937844b9e339d1f6b819e90eeb9bde65f45e833f (patch) | |
| tree | 4226b4160379d52e030385ef0a811c5c7ce0c331 /Source/Core/VideoCommon/PixelShaderGen.cpp | |
| parent | 4984215971e0c03a16e40b0c1703840bfa2cdab8 (diff) | |
Initial port of zfreeze branch (3.5-1729)
Initial port of original zfreeze branch (3.5-1729) by neobrain into
most recent build of Dolphin.
Makes Rogue Squadron 2 very playable at full speed thanks to recent core
speedups made to Dolphin. Works on DirectX Video plugin only for now.
Enjoy! and Merry Xmas!!
Diffstat (limited to 'Source/Core/VideoCommon/PixelShaderGen.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/PixelShaderGen.cpp | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp index edc67cc83c..7afb21056c 100644 --- a/Source/Core/VideoCommon/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/PixelShaderGen.cpp @@ -228,6 +228,7 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T "\tint4 " I_FOGCOLOR";\n" "\tint4 " I_FOGI";\n" "\tfloat4 " I_FOGF"[2];\n" + "\tfloat4 " I_ZSLOPE";\n" "};\n"); if (g_ActiveConfig.bEnablePixelLighting) @@ -269,7 +270,7 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T out.Write("};\n"); const bool forced_early_z = g_ActiveConfig.backend_info.bSupportsEarlyZ && bpmem.UseEarlyDepthTest() && (g_ActiveConfig.bFastDepthCalc || bpmem.alpha_test.TestResult() == AlphaTest::UNDETERMINED); - const bool per_pixel_depth = (bpmem.ztex2.op != ZTEXTURE_DISABLE && bpmem.UseLateDepthTest()) || (!g_ActiveConfig.bFastDepthCalc && bpmem.zmode.testenable && !forced_early_z); + const bool per_pixel_depth = (bpmem.ztex2.op != ZTEXTURE_DISABLE && bpmem.UseLateDepthTest()) || (!g_ActiveConfig.bFastDepthCalc && bpmem.zmode.testenable && !forced_early_z) || bpmem.genMode.zfreeze; if (forced_early_z) { @@ -538,10 +539,20 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T uid_data->fast_depth_calc = g_ActiveConfig.bFastDepthCalc; uid_data->early_ztest = bpmem.UseEarlyDepthTest(); uid_data->fog_fsel = bpmem.fog.c_proj_fsel.fsel; + uid_data->zfreeze = bpmem.genMode.zfreeze; // Note: z-textures are not written to depth buffer if early depth test is used if (per_pixel_depth && bpmem.UseEarlyDepthTest()) - out.Write("\tdepth = float(zCoord) / float(0xFFFFFF);\n"); + { + if (bpmem.genMode.zfreeze) + { + out.Write("\tdepth = " I_ZSLOPE".z + " I_ZSLOPE".x * (clipPos.x / clipPos.w) + " I_ZSLOPE".y * (clipPos.y / clipPos.w);\n"); + } + else + { + out.Write("\tdepth = float(zCoord) / float(0xFFFFFF);\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 @@ -555,7 +566,16 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T } if (per_pixel_depth && bpmem.UseLateDepthTest()) - out.Write("\tdepth = float(zCoord) / float(0xFFFFFF);\n"); + { + if (bpmem.genMode.zfreeze) + { + out.Write("\tdepth = " I_ZSLOPE".z + " I_ZSLOPE".x * (clipPos.x / clipPos.w) + " I_ZSLOPE".y * (clipPos.y / clipPos.w);\n"); + } + else + { + out.Write("\tdepth = float(zCoord) / float(0xFFFFFF);\n"); + } + } if (dstAlphaMode == DSTALPHA_ALPHA_PASS) { |
