mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
VideoBackends: Use the full depth range when inverted depth range is unsupported.
This commit is contained in:
@ -478,10 +478,13 @@ void Renderer::SetViewport()
|
||||
y += height;
|
||||
height = -height;
|
||||
}
|
||||
|
||||
// If an inverted depth range is used, which D3D doesn't support,
|
||||
// we need to calculate the depth range in the vertex shader.
|
||||
if (xfmem.viewport.zRange < 0.0f)
|
||||
{
|
||||
min_depth = 1.0f - min_depth;
|
||||
max_depth = 1.0f - max_depth;
|
||||
min_depth = 0.0f;
|
||||
max_depth = GX_MAX_DEPTH;
|
||||
}
|
||||
|
||||
// In D3D, the viewport rectangle must fit within the render target.
|
||||
@ -490,11 +493,9 @@ void Renderer::SetViewport()
|
||||
width = (x + width <= GetTargetWidth()) ? width : (GetTargetWidth() - x);
|
||||
height = (y + height <= GetTargetHeight()) ? height : (GetTargetHeight() - y);
|
||||
|
||||
// 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. 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.
|
||||
// We use an inverted depth range here to apply the Reverse Z trick.
|
||||
// This trick makes sure we match the precision provided by the 1:0
|
||||
// clipping depth range on the hardware.
|
||||
D3D12_VIEWPORT vp = {x, y, width, height, 1.0f - max_depth, 1.0f - min_depth};
|
||||
D3D::current_command_list->RSSetViewports(1, &vp);
|
||||
}
|
||||
|
Reference in New Issue
Block a user