Skip to content

Commit

Permalink
[d3d9] Saturate viewport depth range
Browse files Browse the repository at this point in the history
Viewport depth range in D3D9 is clamped at 0-1, same as OpenGL.

Drivers like RADV, etc support VK_EXT_depth_range_unrestricted,
which makes the regular UB of this actually work -- which isn't what
we want.

We also don't enable VK_EXT_depth_range_unrestricted, so we shouldn't
be setting depth ranges outside of the 0-1 bounds anyway.

Closes: #2960
  • Loading branch information
misyltoad committed Sep 27, 2022
1 parent 5085753 commit 49854db
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/d3d9/d3d9_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5636,7 +5636,8 @@ namespace dxvk {
viewport = VkViewport{
float(vp.X) + cf, float(vp.Height + vp.Y) + cf,
float(vp.Width), -float(vp.Height),
vp.MinZ, std::max(vp.MaxZ, vp.MinZ + zBias),
std::clamp(vp.MinZ, 0.0f, 1.0f),
std::clamp(std::max(vp.MaxZ, vp.MinZ + zBias), 0.0f, 1.0f),
};

// Scissor rectangles. Vulkan does not provide an easy way
Expand Down

0 comments on commit 49854db

Please sign in to comment.