summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorScott Mansell <phiren@gmail.com>2016-08-24 02:28:53 +1200
committerGitHub <noreply@github.com>2016-08-24 02:28:53 +1200
commit0fbf72cbf1e616703e75a6f202b018954ae4372b (patch)
tree152a4199b061ddfb2ef0c0344050e01c6340d20d /Source/Core
parent817009236474cce63e783cf5168d173d790ca79a (diff)
parent65472260d8cd81ecbfdb9856424aa584f0b1ce2a (diff)
Merge pull request #4140 from Armada651/ww-depth
D3D: Correctly invert the viewport depth range.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/VideoBackends/D3D/Render.cpp6
-rw-r--r--Source/Core/VideoBackends/D3D12/Render.cpp6
2 files changed, 8 insertions, 4 deletions
diff --git a/Source/Core/VideoBackends/D3D/Render.cpp b/Source/Core/VideoBackends/D3D/Render.cpp
index a6301e53a2..57e481cde4 100644
--- a/Source/Core/VideoBackends/D3D/Render.cpp
+++ b/Source/Core/VideoBackends/D3D/Render.cpp
@@ -580,8 +580,10 @@ void Renderer::SetViewport()
// We do depth clipping and depth range in the vertex shader instead of relying
// on the graphics API. However we still need to ensure depth values don't exceed
- // the maximum value supported by the console GPU.
- D3D11_VIEWPORT vp = CD3D11_VIEWPORT(X, Y, Wd, Ht, D3D11_MIN_DEPTH, GX_MAX_DEPTH);
+ // the maximum value supported by the console GPU. We also need to account for the
+ // fact that the entire depth buffer is inverted on D3D, so we set GX_MAX_DEPTH as
+ // an inverted near value.
+ D3D11_VIEWPORT vp = CD3D11_VIEWPORT(X, Y, Wd, Ht, 1.0f - GX_MAX_DEPTH, D3D11_MAX_DEPTH);
D3D::context->RSSetViewports(1, &vp);
}
diff --git a/Source/Core/VideoBackends/D3D12/Render.cpp b/Source/Core/VideoBackends/D3D12/Render.cpp
index 912cd4908d..49b87e686f 100644
--- a/Source/Core/VideoBackends/D3D12/Render.cpp
+++ b/Source/Core/VideoBackends/D3D12/Render.cpp
@@ -484,8 +484,10 @@ void Renderer::SetViewport()
// We do depth clipping and depth range in the vertex shader instead of relying
// on the graphics API. However we still need to ensure depth values don't exceed
- // the maximum value supported by the console GPU.
- D3D12_VIEWPORT vp = {x, y, width, height, D3D12_MIN_DEPTH, GX_MAX_DEPTH};
+ // the maximum value supported by the console GPU. We also need to account for the
+ // fact that the entire depth buffer is inverted on D3D, so we set GX_MAX_DEPTH as
+ // an inverted near value.
+ D3D12_VIEWPORT vp = {x, y, width, height, 1.0f - GX_MAX_DEPTH, D3D12_MAX_DEPTH};
D3D::current_command_list->RSSetViewports(1, &vp);
}