From 38c6eeed269afb75791187f9ba353a9211716e70 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Tue, 19 Feb 2019 14:27:21 +0100 Subject: [PATCH] [dxbc] Only emit depth clamp in fragment shader if necessary We don't need this if the depth clip extension is supported by the driver. --- src/dxbc/dxbc_compiler.cpp | 5 ++++- src/dxbc/dxbc_options.cpp | 2 ++ src/dxbc/dxbc_options.h | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/dxbc/dxbc_compiler.cpp b/src/dxbc/dxbc_compiler.cpp index 638e720b..11569842 100644 --- a/src/dxbc/dxbc_compiler.cpp +++ b/src/dxbc/dxbc_compiler.cpp @@ -6601,7 +6601,10 @@ namespace dxvk { this->emitOutputSetup(); this->emitOutputMapping(); - this->emitOutputDepthClamp(); + + if (m_moduleInfo.options.useDepthClipWorkaround) + this->emitOutputDepthClamp(); + this->emitFunctionEnd(); } diff --git a/src/dxbc/dxbc_options.cpp b/src/dxbc/dxbc_options.cpp index 940119d4..3ec58c05 100644 --- a/src/dxbc/dxbc_options.cpp +++ b/src/dxbc/dxbc_options.cpp @@ -15,6 +15,8 @@ namespace dxvk { const DxvkDeviceFeatures& devFeatures = device->features(); const DxvkDeviceInfo& devInfo = adapter->devicePropertiesExt(); + useDepthClipWorkaround + = !devFeatures.extDepthClipEnable.depthClipEnable; useStorageImageReadWithoutFormat = devFeatures.core.features.shaderStorageImageReadWithoutFormat; useSubgroupOpsForEarlyDiscard diff --git a/src/dxbc/dxbc_options.h b/src/dxbc/dxbc_options.h index b569398f..ef332c16 100644 --- a/src/dxbc/dxbc_options.h +++ b/src/dxbc/dxbc_options.h @@ -10,6 +10,10 @@ namespace dxvk { DxbcOptions(); DxbcOptions(const Rc& device, const D3D11Options& options); + // Clamp oDepth in fragment shaders if the depth + // clip device feature is not supported + bool useDepthClipWorkaround = false; + /// Use the ShaderImageReadWithoutFormat capability. bool useStorageImageReadWithoutFormat = false;