summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/VertexShaderManager.cpp
diff options
context:
space:
mode:
authorPierre Bourdon <delroth@gmail.com>2014-04-25 09:32:36 +0200
committerPierre Bourdon <delroth@gmail.com>2014-04-25 09:32:36 +0200
commit25f5598e31d5ce5dca8d1b03888a9205b616280e (patch)
tree8c7450570343948543a276dd5be742a48fdc9a35 /Source/Core/VideoCommon/VertexShaderManager.cpp
parent28db73971733319adfbf25b47e833cbc9510a3a2 (diff)
parentc47c32d4a808218866a9e0a744b0cfa37d6ec9cb (diff)
Merge pull request #306 from neobrain/pixel_center_correction
VertexShaderGen: Correct vertex shader output to consider shifted pixel centers.
Diffstat (limited to 'Source/Core/VideoCommon/VertexShaderManager.cpp')
-rw-r--r--Source/Core/VideoCommon/VertexShaderManager.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/Source/Core/VideoCommon/VertexShaderManager.cpp b/Source/Core/VideoCommon/VertexShaderManager.cpp
index f0e4be9040..b26ee5ccf9 100644
--- a/Source/Core/VideoCommon/VertexShaderManager.cpp
+++ b/Source/Core/VideoCommon/VertexShaderManager.cpp
@@ -360,6 +360,17 @@ void VertexShaderManager::SetConstants()
bViewportChanged = false;
constants.depthparams[0] = xfregs.viewport.farZ / 16777216.0f;
constants.depthparams[1] = xfregs.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
+ // in VertexShaderGen.cpp for details.
+ // NOTE: If we ever emulate antialiasing, the sample locations set by
+ // BP registers 0x01-0x04 need to be considered here.
+ const float pixel_center_correction = 7.0f / 12.0f - 0.5f;
+ const float pixel_size_x = 2.f / Renderer::EFBToScaledXf(2.f * xfregs.viewport.wd);
+ const float pixel_size_y = 2.f / Renderer::EFBToScaledXf(2.f * xfregs.viewport.ht);
+ constants.depthparams[2] = pixel_center_correction * pixel_size_x;
+ constants.depthparams[3] = pixel_center_correction * pixel_size_y;
dirty = true;
// This is so implementation-dependent that we can't have it here.
g_renderer->SetViewport();