From 779f8b39cdef136bd1dc177c5f93034b5a7c9f6d Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Wed, 20 Jul 2022 22:38:03 +0200 Subject: [PATCH] [spirv] Track currently active block ID --- src/spirv/spirv_module.cpp | 10 ++++++++++ src/spirv/spirv_module.h | 7 ++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/spirv/spirv_module.cpp b/src/spirv/spirv_module.cpp index c253c6a3d..7e9efe71f 100644 --- a/src/spirv/spirv_module.cpp +++ b/src/spirv/spirv_module.cpp @@ -2986,6 +2986,8 @@ namespace dxvk { void SpirvModule::opLabel(uint32_t labelId) { m_code.putIns (spv::OpLabel, 2); m_code.putWord(labelId); + + m_blockId = labelId; } @@ -3533,6 +3535,8 @@ namespace dxvk { uint32_t label) { m_code.putIns (spv::OpBranch, 2); m_code.putWord(label); + + m_blockId = 0; } @@ -3544,6 +3548,8 @@ namespace dxvk { m_code.putWord(condition); m_code.putWord(trueLabel); m_code.putWord(falseLabel); + + m_blockId = 0; } @@ -3560,6 +3566,8 @@ namespace dxvk { m_code.putWord(caseLabels[i].literal); m_code.putWord(caseLabels[i].labelId); } + + m_blockId = 0; } @@ -3584,11 +3592,13 @@ namespace dxvk { void SpirvModule::opReturn() { m_code.putIns (spv::OpReturn, 1); + m_blockId = 0; } void SpirvModule::opKill() { m_code.putIns (spv::OpKill, 1); + m_blockId = 0; } diff --git a/src/spirv/spirv_module.h b/src/spirv/spirv_module.h index e9be24d6f..f1ef6947e 100644 --- a/src/spirv/spirv_module.h +++ b/src/spirv/spirv_module.h @@ -50,7 +50,7 @@ namespace dxvk { ~SpirvModule(); SpirvCodeBuffer compile() const; - + size_t getInsertionPtr() { return m_code.getInsertionPtr(); } @@ -63,6 +63,10 @@ namespace dxvk { m_code.endInsertion(); } + uint32_t getBlockId() const { + return m_blockId; + } + uint32_t allocateId(); bool hasCapability( @@ -1239,6 +1243,7 @@ namespace dxvk { uint32_t m_version; uint32_t m_id = 1; uint32_t m_instExtGlsl450 = 0; + uint32_t m_blockId = 0; SpirvCodeBuffer m_capabilities; SpirvCodeBuffer m_extensions;