From f1a9d72d3834c5f5c846dc5d2b26dc5b4bf63636 Mon Sep 17 00:00:00 2001 From: Joshua Ashton Date: Sun, 6 Jun 2021 16:46:50 +0100 Subject: [PATCH] [d3d9] Don't scale z to [0, 1] for POSITIONT 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 --- src/d3d9/d3d9_device.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index cdf6b485..13b0f486 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -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;