From 4ea5d165f5c98d99040ea5dd7c42ae16d2d5311e Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 18 Apr 2020 22:34:33 -0700 Subject: [PATCH] D3D11: Always use accurate depth. The Direct3D APIs use a "min" and "max" value, and it's required that min must be less than or equal to max. If this requirement is not met, the viewport parameters are not updated. We forced accurate depth on for NVIDIA and AMD, but this just meant Intel was still broken and less people were reporting bugs about it. Although the PSP GE has depth viewport transform, this is not used for clipping and is not actually the depth range. The minz and maxz GE registers are the depth range, and minz must be less than or equal to maxz for drawing to occur. --- GPU/D3D11/GPU_D3D11.cpp | 10 ++++------ GPU/Directx9/GPU_DX9.cpp | 10 +++++----- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/GPU/D3D11/GPU_D3D11.cpp b/GPU/D3D11/GPU_D3D11.cpp index 4af81be893..207cc52f5d 100644 --- a/GPU/D3D11/GPU_D3D11.cpp +++ b/GPU/D3D11/GPU_D3D11.cpp @@ -132,12 +132,10 @@ void GPU_D3D11::CheckGPUFeatures() { features |= GPU_SUPPORTS_BLEND_MINMAX; features |= GPU_PREFER_CPU_DOWNLOAD; - // Accurate depth is required on AMD/nVidia (for reverse Z) so we ignore the compat flag to disable it on those. See #9545 - auto vendor = draw_->GetDeviceCaps().vendor; - - if (!PSP_CoreParameter().compat.flags().DisableAccurateDepth || vendor == Draw::GPUVendor::VENDOR_AMD || vendor == Draw::GPUVendor::VENDOR_NVIDIA) { - features |= GPU_SUPPORTS_ACCURATE_DEPTH; // Breaks text in PaRappa for some reason. - } + // Accurate depth is required because the Direct3D API does not support inverse Z. + // So we cannot incorrectly use the viewport transform as the depth range on Direct3D. + // TODO: Breaks text in PaRappa for some reason? + features |= GPU_SUPPORTS_ACCURATE_DEPTH; #ifndef _M_ARM // TODO: Do proper feature detection diff --git a/GPU/Directx9/GPU_DX9.cpp b/GPU/Directx9/GPU_DX9.cpp index e25afe304b..162e7ed71e 100644 --- a/GPU/Directx9/GPU_DX9.cpp +++ b/GPU/Directx9/GPU_DX9.cpp @@ -167,12 +167,12 @@ void GPU_DX9::CheckGPUFeatures() { features |= GPU_SUPPORTS_TEXTURE_LOD_CONTROL; features |= GPU_PREFER_CPU_DOWNLOAD; - auto vendor = draw_->GetDeviceCaps().vendor; - // Accurate depth is required on AMD/nVidia (for reverse Z) so we ignore the compat flag to disable it on those. See #9545 - if (!PSP_CoreParameter().compat.flags().DisableAccurateDepth || vendor == Draw::GPUVendor::VENDOR_AMD || vendor == Draw::GPUVendor::VENDOR_NVIDIA) { - features |= GPU_SUPPORTS_ACCURATE_DEPTH; - } + // Accurate depth is required because the Direct3D API does not support inverse Z. + // So we cannot incorrectly use the viewport transform as the depth range on Direct3D. + // TODO: Breaks text in PaRappa for some reason? + features |= GPU_SUPPORTS_ACCURATE_DEPTH; + auto vendor = draw_->GetDeviceCaps().vendor; if (!PSP_CoreParameter().compat.flags().DepthRangeHack) { // VS range culling (killing triangles in the vertex shader using NaN) causes problems on Intel. // Also causes problems on old NVIDIA.