summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon
diff options
context:
space:
mode:
authorPierre Bourdon <delroth@gmail.com>2016-03-03 02:03:03 +0100
committerPierre Bourdon <delroth@gmail.com>2016-03-03 02:03:03 +0100
commit265c6408d6f2d3684d84d6a4c8d8a7fbd0adadf6 (patch)
treec5635299c45c6e9fc7180be508543a96179f8494 /Source/Core/VideoCommon
parentf752c6e7044c9b391bb2c88a6114bd46ca43d09c (diff)
parent6d1628eda4b78bfee7eefec1b632953f52a785f5 (diff)
Merge pull request #3686 from Armada651/revert-3578
Revert "Merge pull request #3578 from Armada651/forced-slow-depth"
Diffstat (limited to 'Source/Core/VideoCommon')
-rw-r--r--Source/Core/VideoCommon/PixelShaderGen.cpp24
-rw-r--r--Source/Core/VideoCommon/PixelShaderGen.h2
-rw-r--r--Source/Core/VideoCommon/VertexShaderGen.cpp2
-rw-r--r--Source/Core/VideoCommon/VideoConfig.cpp6
-rw-r--r--Source/Core/VideoCommon/VideoConfig.h2
5 files changed, 15 insertions, 21 deletions
diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp
index 09f8c6a871..f9781c5217 100644
--- a/Source/Core/VideoCommon/PixelShaderGen.cpp
+++ b/Source/Core/VideoCommon/PixelShaderGen.cpp
@@ -285,14 +285,13 @@ static T GeneratePixelShader(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType)
GenerateVSOutputMembers<T>(out, ApiType);
out.Write("};\n");
- const bool forced_slow_depth = g_ActiveConfig.bForcedSlowDepth || !g_ActiveConfig.backend_info.bSupportsClipControl;
const bool forced_early_z = g_ActiveConfig.backend_info.bSupportsEarlyZ && bpmem.UseEarlyDepthTest()
- && (!forced_slow_depth || bpmem.alpha_test.TestResult() == AlphaTest::UNDETERMINED)
+ && (g_ActiveConfig.bFastDepthCalc || bpmem.alpha_test.TestResult() == AlphaTest::UNDETERMINED)
// We can't allow early_ztest for zfreeze because depth is overridden per-pixel.
// This means it's impossible for zcomploc to be emulated on a zfrozen polygon.
&& !(bpmem.zmode.testenable && bpmem.genMode.zfreeze);
const bool per_pixel_depth = (bpmem.ztex2.op != ZTEXTURE_DISABLE && bpmem.UseLateDepthTest())
- || (forced_slow_depth && bpmem.zmode.testenable && !forced_early_z)
+ || (!g_ActiveConfig.bFastDepthCalc && bpmem.zmode.testenable && !forced_early_z)
|| (bpmem.zmode.testenable && bpmem.genMode.zfreeze);
if (forced_early_z)
@@ -325,7 +324,7 @@ static T GeneratePixelShader(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType)
// D3D11 also has a way to force the driver to enable early-z, so we're fine here.
if(ApiType == API_OPENGL)
{
- // This is a #define which signals whatever early-z method the driver supports.
+ // This is a #define which signals whatever early-z method the driver supports.
out.Write("FORCE_EARLY_Z; \n");
}
else
@@ -333,7 +332,7 @@ static T GeneratePixelShader(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType)
out.Write("[earlydepthstencil]\n");
}
}
- else if (bpmem.UseEarlyDepthTest() && (!forced_slow_depth || bpmem.alpha_test.TestResult() == AlphaTest::UNDETERMINED))
+ else if (bpmem.UseEarlyDepthTest() && (g_ActiveConfig.bFastDepthCalc || bpmem.alpha_test.TestResult() == AlphaTest::UNDETERMINED))
{
static bool warn_once = true;
if (warn_once)
@@ -562,13 +561,11 @@ static T GeneratePixelShader(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType)
out.Write("\tint zCoord = int(" I_ZSLOPE".z + " I_ZSLOPE".x * screenpos.x + " I_ZSLOPE".y * screenpos.y);\n");
}
- else if (forced_slow_depth)
+ else if (!g_ActiveConfig.bFastDepthCalc)
{
- // Due to floating point round-trip issues some depth equations are not as accurate as required.
- // Depth equations used in D3D and OGL with GL_ARB_clip_control are accurate, but older cards
- // that do not support GL_ARB_clip_control are not accurate enough under OGL. So on these older
- // cards we just calculate the depth value again.
-
+ // FastDepth means to trust the depth generated in perspective division.
+ // It should be correct, but it seems not to be as accurate as required. TODO: Find out why!
+ // For disabled FastDepth we just calculate the depth value again.
// The performance impact of this additional calculation doesn't matter, but it prevents
// the host GPU driver from performing any early depth test optimizations.
out.SetConstantsUsed(C_ZBIAS+1, C_ZBIAS+1);
@@ -577,7 +574,6 @@ static T GeneratePixelShader(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType)
}
else
{
- // Our D3D backend uses inverse depth values, so we invert them to the expected value here.
if (ApiType == API_D3D)
out.Write("\tint zCoord = int((1.0 - rawpos.z) * 16777216.0);\n");
else
@@ -591,7 +587,7 @@ static T GeneratePixelShader(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType)
uid_data->ztex_op = bpmem.ztex2.op;
uid_data->per_pixel_depth = per_pixel_depth;
uid_data->forced_early_z = forced_early_z;
- uid_data->forced_slow_depth = forced_slow_depth;
+ 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;
@@ -599,7 +595,6 @@ static T GeneratePixelShader(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType)
// Note: z-textures are not written to depth buffer if early depth test is used
if (per_pixel_depth && bpmem.UseEarlyDepthTest())
{
- // Our D3D backend uses inverse depth values, so we invert them back to the depth buffer value here.
if (ApiType == API_D3D)
out.Write("\tdepth = 1.0 - float(zCoord) / 16777216.0;\n");
else
@@ -619,7 +614,6 @@ static T GeneratePixelShader(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType)
if (per_pixel_depth && bpmem.UseLateDepthTest())
{
- // Our D3D backend uses inverse depth values, so we invert them back to the depth buffer value here.
if (ApiType == API_D3D)
out.Write("\tdepth = 1.0 - float(zCoord) / 16777216.0;\n");
else
diff --git a/Source/Core/VideoCommon/PixelShaderGen.h b/Source/Core/VideoCommon/PixelShaderGen.h
index 66611d82b1..3cc8071ce9 100644
--- a/Source/Core/VideoCommon/PixelShaderGen.h
+++ b/Source/Core/VideoCommon/PixelShaderGen.h
@@ -42,7 +42,7 @@ struct pixel_shader_uid_data
u32 fog_fsel : 3;
u32 fog_RangeBaseEnabled : 1;
u32 ztex_op : 2;
- u32 forced_slow_depth : 1;
+ u32 fast_depth_calc : 1;
u32 per_pixel_depth : 1;
u32 forced_early_z : 1;
u32 early_ztest : 1;
diff --git a/Source/Core/VideoCommon/VertexShaderGen.cpp b/Source/Core/VideoCommon/VertexShaderGen.cpp
index feb94bfa5d..9a9a23b5b9 100644
--- a/Source/Core/VideoCommon/VertexShaderGen.cpp
+++ b/Source/Core/VideoCommon/VertexShaderGen.cpp
@@ -333,7 +333,7 @@ static T GenerateVertexShader(API_TYPE api_type)
else // OGL
{
// this results in a scale from -1..0 to -1..1 after perspective
- // divide, but introduces a floating point round-trip error.
+ // divide
out.Write("o.pos.z = o.pos.z * -2.0 - o.pos.w;\n");
// the next steps of the OGL pipeline are:
diff --git a/Source/Core/VideoCommon/VideoConfig.cpp b/Source/Core/VideoCommon/VideoConfig.cpp
index 4a4f9a3f53..257cc61fc6 100644
--- a/Source/Core/VideoCommon/VideoConfig.cpp
+++ b/Source/Core/VideoCommon/VideoConfig.cpp
@@ -71,7 +71,7 @@ void VideoConfig::Load(const std::string& ini_file)
settings->Get("FreeLook", &bFreeLook, 0);
settings->Get("UseFFV1", &bUseFFV1, 0);
settings->Get("EnablePixelLighting", &bEnablePixelLighting, 0);
- settings->Get("ForcedSlowDepth", &bForcedSlowDepth, false);
+ settings->Get("FastDepthCalc", &bFastDepthCalc, true);
settings->Get("MSAA", &iMultisamples, 1);
settings->Get("SSAA", &bSSAA, false);
settings->Get("EFBScale", &iEFBScale, (int)SCALE_1X); // native
@@ -165,7 +165,7 @@ void VideoConfig::GameIniLoad()
CHECK_SETTING("Video_Settings", "ConvertHiresTextures", bConvertHiresTextures);
CHECK_SETTING("Video_Settings", "CacheHiresTextures", bCacheHiresTextures);
CHECK_SETTING("Video_Settings", "EnablePixelLighting", bEnablePixelLighting);
- CHECK_SETTING("Video_Settings", "ForcedSlowDepth", bForcedSlowDepth);
+ CHECK_SETTING("Video_Settings", "FastDepthCalc", bFastDepthCalc);
CHECK_SETTING("Video_Settings", "MSAA", iMultisamples);
CHECK_SETTING("Video_Settings", "SSAA", bSSAA);
@@ -282,7 +282,7 @@ void VideoConfig::Save(const std::string& ini_file)
settings->Set("FreeLook", bFreeLook);
settings->Set("UseFFV1", bUseFFV1);
settings->Set("EnablePixelLighting", bEnablePixelLighting);
- settings->Set("ForcedSlowDepth", bForcedSlowDepth);
+ settings->Set("FastDepthCalc", bFastDepthCalc);
settings->Set("MSAA", iMultisamples);
settings->Set("SSAA", bSSAA);
settings->Set("EFBScale", iEFBScale);
diff --git a/Source/Core/VideoCommon/VideoConfig.h b/Source/Core/VideoCommon/VideoConfig.h
index adfa20f65b..bc0250ab2f 100644
--- a/Source/Core/VideoCommon/VideoConfig.h
+++ b/Source/Core/VideoCommon/VideoConfig.h
@@ -117,7 +117,7 @@ struct VideoConfig final
std::string sPhackvalue[2];
float fAspectRatioHackW, fAspectRatioHackH;
bool bEnablePixelLighting;
- bool bForcedSlowDepth;
+ bool bFastDepthCalc;
int iLog; // CONF_ bits
int iSaveTargetId; // TODO: Should be dropped