From 2d670ec3db0c1502c84f844e5f9c79f6a5d23c65 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Fri, 29 Jan 2021 16:29:39 +0100 Subject: [PATCH] [dxbc] Enable capabilities for float control modes Fixes some validation errors (but seriously, why does everything have to be a capability in SPIR-V?) --- src/dxbc/dxbc_compiler.cpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/dxbc/dxbc_compiler.cpp b/src/dxbc/dxbc_compiler.cpp index 94da778a3..ba3e48f2d 100644 --- a/src/dxbc/dxbc_compiler.cpp +++ b/src/dxbc/dxbc_compiler.cpp @@ -7481,17 +7481,27 @@ namespace dxvk { m_module.enableExtension("SPV_KHR_float_controls"); - if (flags.test(DxbcFloatControlFlag::DenormFlushToZero32)) + if (flags.test(DxbcFloatControlFlag::DenormFlushToZero32)) { + m_module.enableCapability(spv::CapabilityDenormFlushToZero); m_module.setExecutionMode(m_entryPointId, spv::ExecutionModeDenormFlushToZero, 1, &width32); + } - if (flags.test(DxbcFloatControlFlag::DenormPreserve64)) - m_module.setExecutionMode(m_entryPointId, spv::ExecutionModeDenormPreserve, 1, &width64); - - if (flags.test(DxbcFloatControlFlag::PreserveNan32)) + if (flags.test(DxbcFloatControlFlag::PreserveNan32)) { + m_module.enableCapability(spv::CapabilitySignedZeroInfNanPreserve); m_module.setExecutionMode(m_entryPointId, spv::ExecutionModeSignedZeroInfNanPreserve, 1, &width32); + } - if (flags.test(DxbcFloatControlFlag::PreserveNan64)) - m_module.setExecutionMode(m_entryPointId, spv::ExecutionModeSignedZeroInfNanPreserve, 1, &width64); + if (m_module.hasCapability(spv::CapabilityFloat64)) { + if (flags.test(DxbcFloatControlFlag::DenormPreserve64)) { + m_module.enableCapability(spv::CapabilityDenormPreserve); + m_module.setExecutionMode(m_entryPointId, spv::ExecutionModeDenormPreserve, 1, &width64); + } + + if (flags.test(DxbcFloatControlFlag::PreserveNan64)) { + m_module.enableCapability(spv::CapabilitySignedZeroInfNanPreserve); + m_module.setExecutionMode(m_entryPointId, spv::ExecutionModeSignedZeroInfNanPreserve, 1, &width64); + } + } }