Skip to content

Commit

Permalink
[d3d9] Don't scale z to [0, 1] for POSITIONT
Browse files Browse the repository at this point in the history
I originally thought the depth clipping region was always [0, 1] when I first implemented this nearly 2 years ago.

The depth clipping region is already in the viewport's depth range, so just don't do anything here if we are z-testing.

( We still need to keep the flattening around for when ztest is disabled though :( )

Fixes: #2056
  • Loading branch information
misyltoad committed Jun 6, 2021
1 parent fe00919 commit 659262e
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/d3d9/d3d9_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6357,22 +6357,15 @@ namespace dxvk {

m_ffZTest = IsZTestEnabled();

float zMin = m_ffZTest ? vp.MinZ : 0.0f;
float zMax = m_ffZTest ? vp.MaxZ : 0.0f;
float zExtent = zMax - zMin;
zExtent = zExtent != 0.0f
? 1.0f / zExtent
: 0.0f;

m_viewportInfo.inverseExtent = Vector4(
2.0f / float(vp.Width),
-2.0f / float(vp.Height),
zExtent,
m_ffZTest ? 1.0f : 0.0f,
1.0f);

m_viewportInfo.inverseOffset = Vector4(
-float(vp.X), -float(vp.Y),
-zMin, 0.0f);
0.0f, 0.0f);

m_viewportInfo.inverseOffset = m_viewportInfo.inverseOffset * m_viewportInfo.inverseExtent;

Expand Down

0 comments on commit 659262e

Please sign in to comment.