From c3af42356f3e86b8b48f0e7fd136e31aca66287f Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Fri, 15 Jul 2022 15:06:23 +0200 Subject: [PATCH] [dxbc] Enable SPIR-V 1.6 --- src/dxbc/dxbc_compiler.cpp | 22 +++++++--------------- src/dxbc/dxbc_compiler.h | 20 -------------------- src/spirv/spirv_module.cpp | 2 +- 3 files changed, 8 insertions(+), 36 deletions(-) diff --git a/src/dxbc/dxbc_compiler.cpp b/src/dxbc/dxbc_compiler.cpp index bb4701b8..8ea7c9a7 100644 --- a/src/dxbc/dxbc_compiler.cpp +++ b/src/dxbc/dxbc_compiler.cpp @@ -19,7 +19,7 @@ namespace dxvk { const DxbcAnalysisInfo& analysis) : m_moduleInfo (moduleInfo), m_programInfo(programInfo), - m_module (spvVersion(1, 3)), + m_module (spvVersion(1, 6)), m_isgn (isgn), m_osgn (osgn), m_psgn (psgn), @@ -1483,7 +1483,9 @@ namespace dxvk { m_immConstBuf = m_module.newVarInit( pointerTypeId, spv::StorageClassPrivate, arrayId); + m_module.setDebugName(m_immConstBuf, "icb"); + m_module.decorate(m_immConstBuf, spv::DecorationNonWritable); } @@ -6262,7 +6264,7 @@ namespace dxvk { case DxbcSystemValue::RenderTargetId: { if (m_programInfo.type() != DxbcProgramType::GeometryShader) - enableShaderViewportIndexLayer(); + m_module.enableCapability(spv::CapabilityShaderLayer); if (m_gs.builtinLayer == 0) { m_module.enableCapability(spv::CapabilityGeometry); @@ -6285,7 +6287,7 @@ namespace dxvk { case DxbcSystemValue::ViewportId: { if (m_programInfo.type() != DxbcProgramType::GeometryShader) - enableShaderViewportIndexLayer(); + m_module.enableCapability(spv::CapabilityShaderViewportIndex); if (m_gs.builtinViewportId == 0) { m_module.enableCapability(spv::CapabilityMultiViewport); @@ -6801,8 +6803,7 @@ namespace dxvk { if (m_analysis->usesKill && m_moduleInfo.options.useDemoteToHelperInvocation) { // This extension basically implements D3D-style discard - m_module.enableExtension("SPV_EXT_demote_to_helper_invocation"); - m_module.enableCapability(spv::CapabilityDemoteToHelperInvocationEXT); + m_module.enableCapability(spv::CapabilityDemoteToHelperInvocation); } else if (m_analysis->usesKill && m_analysis->usesDerivatives) { // We may have to defer kill operations to the end of // the shader in order to keep derivatives correct. @@ -7409,6 +7410,7 @@ namespace dxvk { spv::StorageClassPrivate, samplePosArray); m_module.setDebugName(varId, "g_sample_pos"); + m_module.decorate(varId, spv::DecorationNonWritable); return varId; } @@ -7515,16 +7517,6 @@ namespace dxvk { } - void DxbcCompiler::enableShaderViewportIndexLayer() { - if (!m_extensions.shaderViewportIndexLayer) { - m_extensions.shaderViewportIndexLayer = true; - - m_module.enableExtension("SPV_EXT_shader_viewport_index_layer"); - m_module.enableCapability(spv::CapabilityShaderViewportIndexLayerEXT); - } - } - - DxbcCfgBlock* DxbcCompiler::cfgFindBlock( const std::initializer_list& types) { for (auto cur = m_controlFlowBlocks.rbegin(); diff --git a/src/dxbc/dxbc_compiler.h b/src/dxbc/dxbc_compiler.h index 65c331f1..a3ac717a 100644 --- a/src/dxbc/dxbc_compiler.h +++ b/src/dxbc/dxbc_compiler.h @@ -353,18 +353,6 @@ namespace dxvk { }; - /** - * \brief SPIR-V extension set - * - * Keeps track of which optional SPIR-V extensions - * are enabled so that any required setup code is - * only run once. - */ - struct DxbcSpirvExtensions { - bool shaderViewportIndexLayer = false; - }; - - /** * \brief DXBC to SPIR-V shader compiler * @@ -534,10 +522,6 @@ namespace dxvk { DxbcCompilerPsPart m_ps; DxbcCompilerCsPart m_cs; - ///////////////////////////// - // Enabled SPIR-V extensions - DxbcSpirvExtensions m_extensions; - ////////////////////// // Global state stuff bool m_precise = true; @@ -1198,10 +1182,6 @@ namespace dxvk { uint32_t emitPushConstants(); - //////////////////////////////// - // Extension enablement methods - void enableShaderViewportIndexLayer(); - //////////////// // Misc methods DxbcCfgBlock* cfgFindBlock( diff --git a/src/spirv/spirv_module.cpp b/src/spirv/spirv_module.cpp index f107f7f2..c253c6a3 100644 --- a/src/spirv/spirv_module.cpp +++ b/src/spirv/spirv_module.cpp @@ -3593,7 +3593,7 @@ namespace dxvk { void SpirvModule::opDemoteToHelperInvocation() { - m_code.putIns (spv::OpDemoteToHelperInvocationEXT, 1); + m_code.putIns (spv::OpDemoteToHelperInvocation, 1); }