summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2014-12-03 14:49:30 -0500
committerLioncash <mathew1800@gmail.com>2014-12-03 14:49:30 -0500
commit88cd27bbcaaa46b8bbd3cf29ee71327c629be0c2 (patch)
tree7f8799a92409bbd9fd9efe8327b305a3724adbdd /Source/Core/VideoCommon
parentb9b3277fb52cc14065082482b0c654217b39841c (diff)
parent36b886cb802c44eb02482b17ce483ba76ccb25ee (diff)
Merge pull request #1392 from kayru/d3d_viewport_depth
D3D: Replaced shader-based depth range remap with viewport
Diffstat (limited to 'Source/Core/VideoCommon')
-rw-r--r--Source/Core/VideoCommon/ConstantManager.h2
-rw-r--r--Source/Core/VideoCommon/ShaderGenCommon.h4
-rw-r--r--Source/Core/VideoCommon/VertexShaderGen.cpp4
-rw-r--r--Source/Core/VideoCommon/VertexShaderManager.cpp6
4 files changed, 7 insertions, 9 deletions
diff --git a/Source/Core/VideoCommon/ConstantManager.h b/Source/Core/VideoCommon/ConstantManager.h
index 116088d76e..93c228bc98 100644
--- a/Source/Core/VideoCommon/ConstantManager.h
+++ b/Source/Core/VideoCommon/ConstantManager.h
@@ -42,7 +42,7 @@ struct VertexShaderConstants
float4 transformmatrices[64];
float4 normalmatrices[32];
float4 posttransformmatrices[64];
- float4 depthparams;
+ float4 pixelcentercorrection;
float4 stereoparams;
};
diff --git a/Source/Core/VideoCommon/ShaderGenCommon.h b/Source/Core/VideoCommon/ShaderGenCommon.h
index 330b9f8ced..4d22048ee6 100644
--- a/Source/Core/VideoCommon/ShaderGenCommon.h
+++ b/Source/Core/VideoCommon/ShaderGenCommon.h
@@ -238,7 +238,7 @@ private:
#define I_TRANSFORMMATRICES "ctrmtx"
#define I_NORMALMATRICES "cnmtx"
#define I_POSTTRANSFORMMATRICES "cpostmtx"
-#define I_DEPTHPARAMS "cDepth" // farZ, zRange
+#define I_PIXELCENTERCORRECTION "cpixelcenter"
#define I_STEREOPARAMS "cstereo"
static const char s_shader_uniforms[] =
@@ -250,5 +250,5 @@ static const char s_shader_uniforms[] =
"\tfloat4 " I_TRANSFORMMATRICES"[64];\n"
"\tfloat4 " I_NORMALMATRICES"[32];\n"
"\tfloat4 " I_POSTTRANSFORMMATRICES"[64];\n"
- "\tfloat4 " I_DEPTHPARAMS";\n"
+ "\tfloat4 " I_PIXELCENTERCORRECTION";\n"
"\tfloat4 " I_STEREOPARAMS";\n";
diff --git a/Source/Core/VideoCommon/VertexShaderGen.cpp b/Source/Core/VideoCommon/VertexShaderGen.cpp
index 24c6f39f46..26d6942372 100644
--- a/Source/Core/VideoCommon/VertexShaderGen.cpp
+++ b/Source/Core/VideoCommon/VertexShaderGen.cpp
@@ -405,7 +405,7 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ
//if not early z culling will improve speed
if (api_type == API_D3D)
{
- out.Write("o.pos.z = " I_DEPTHPARAMS".x * o.pos.w + o.pos.z * " I_DEPTHPARAMS".y;\n");
+ out.Write("o.pos.z = o.pos.w + o.pos.z;\n");
}
else // OGL
{
@@ -430,7 +430,7 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ
// which in turn can be critical if it happens for clear quads.
// Hence, we compensate for this pixel center difference so that primitives
// get rasterized correctly.
- out.Write("o.pos.xy = o.pos.xy - " I_DEPTHPARAMS".zw;\n");
+ out.Write("o.pos.xy = o.pos.xy - " I_PIXELCENTERCORRECTION".xy;\n");
if (api_type == API_OPENGL)
{
diff --git a/Source/Core/VideoCommon/VertexShaderManager.cpp b/Source/Core/VideoCommon/VertexShaderManager.cpp
index 8de50c5436..2d496cb50c 100644
--- a/Source/Core/VideoCommon/VertexShaderManager.cpp
+++ b/Source/Core/VideoCommon/VertexShaderManager.cpp
@@ -359,8 +359,6 @@ void VertexShaderManager::SetConstants()
if (bViewportChanged)
{
bViewportChanged = false;
- constants.depthparams[0] = xfmem.viewport.farZ / 16777216.0f;
- constants.depthparams[1] = xfmem.viewport.zRange / 16777216.0f;
// The console GPU places the pixel center at 7/12 unless antialiasing
// is enabled, while D3D and OpenGL place it at 0.5. See the comment
@@ -370,8 +368,8 @@ void VertexShaderManager::SetConstants()
const float pixel_center_correction = 7.0f / 12.0f - 0.5f;
const float pixel_size_x = 2.f / Renderer::EFBToScaledXf(2.f * xfmem.viewport.wd);
const float pixel_size_y = 2.f / Renderer::EFBToScaledXf(2.f * xfmem.viewport.ht);
- constants.depthparams[2] = pixel_center_correction * pixel_size_x;
- constants.depthparams[3] = pixel_center_correction * pixel_size_y;
+ constants.pixelcentercorrection[0] = pixel_center_correction * pixel_size_x;
+ constants.pixelcentercorrection[1] = pixel_center_correction * pixel_size_y;
dirty = true;
// This is so implementation-dependent that we can't have it here.
g_renderer->SetViewport();