From 76ee76d6da6a3d4ec010aab43f1f6ccaaaf491f1 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Fri, 19 Aug 2022 15:56:25 +0200 Subject: [PATCH] [d3d9,dxso] Use DemoteToHelperInvocation for alpha test May enable additional compiler optimizations. --- src/d3d9/d3d9_fixed_function.cpp | 5 ++++- src/dxso/dxso_compiler.cpp | 8 ++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/d3d9/d3d9_fixed_function.cpp b/src/d3d9/d3d9_fixed_function.cpp index cc6628214..344dc7e89 100644 --- a/src/d3d9/d3d9_fixed_function.cpp +++ b/src/d3d9/d3d9_fixed_function.cpp @@ -323,7 +323,8 @@ namespace dxvk { spvModule.opBranchConditional(atestDiscard, atestDiscardLabel, atestKeepLabel); spvModule.opLabel(atestDiscardLabel); - spvModule.opKill(); + spvModule.opDemoteToHelperInvocation(); + spvModule.opBranch(atestKeepLabel); // end if (do_discard) spvModule.opLabel(atestKeepLabel); @@ -2147,6 +2148,8 @@ namespace dxvk { m_specUbo = SetupSpecUBO(m_module, m_bindings); // PS Caps + m_module.enableExtension("SPV_EXT_demote_to_helper_invocation"); + m_module.enableCapability(spv::CapabilityDemoteToHelperInvocationEXT); m_module.enableCapability(spv::CapabilityDerivativeControl); m_module.setExecutionMode(m_entryPointId, diff --git a/src/dxso/dxso_compiler.cpp b/src/dxso/dxso_compiler.cpp index 29dfef8f1..67066ec4f 100644 --- a/src/dxso/dxso_compiler.cpp +++ b/src/dxso/dxso_compiler.cpp @@ -488,6 +488,8 @@ namespace dxvk { void DxsoCompiler::emitPsInit() { + m_module.enableExtension("SPV_EXT_demote_to_helper_invocation"); + m_module.enableCapability(spv::CapabilityDemoteToHelperInvocationEXT); m_module.enableCapability(spv::CapabilityDerivativeControl); m_module.setExecutionMode(m_entryPointId, @@ -509,12 +511,6 @@ namespace dxvk { m_module.defFunctionType( m_module.defVoidType(), 0, nullptr)); this->emitFunctionLabel(); - - if (m_analysis->usesKill) { - // This extension basically implements D3D-style discard - m_module.enableExtension("SPV_EXT_demote_to_helper_invocation"); - m_module.enableCapability(spv::CapabilityDemoteToHelperInvocationEXT); - } }