diff options
author | Rémi Verschelde <remi@verschelde.fr> | 2021-09-22 13:47:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-22 13:47:52 +0200 |
commit | b7ad29d574543d8da5a4476069a1ae12019cfc8e (patch) | |
tree | d66064c6feb18fd86f02e5d10b1f1df1dc0fd3ff /thirdparty/glslang/SPIRV/SpvPostProcess.cpp | |
parent | f25aaa98d626ddbf4d19ee0b1f3cc8e3483b2fdb (diff) | |
parent | fd641ac85c6170c34845db5e345d3bf9cedce8d7 (diff) |
Merge pull request #52933 from akien-mga/vulkan-1.2.190
Diffstat (limited to 'thirdparty/glslang/SPIRV/SpvPostProcess.cpp')
-rw-r--r-- | thirdparty/glslang/SPIRV/SpvPostProcess.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/thirdparty/glslang/SPIRV/SpvPostProcess.cpp b/thirdparty/glslang/SPIRV/SpvPostProcess.cpp index d40174d172..23d7b5a461 100644 --- a/thirdparty/glslang/SPIRV/SpvPostProcess.cpp +++ b/thirdparty/glslang/SPIRV/SpvPostProcess.cpp @@ -436,6 +436,38 @@ void Builder::postProcessFeatures() { } } } + + // If any Vulkan memory model-specific functionality is used, update the + // OpMemoryModel to match. + if (capabilities.find(spv::CapabilityVulkanMemoryModelKHR) != capabilities.end()) { + memoryModel = spv::MemoryModelVulkanKHR; + addIncorporatedExtension(spv::E_SPV_KHR_vulkan_memory_model, spv::Spv_1_5); + } + + // Add Aliased decoration if there's more than one Workgroup Block variable. + if (capabilities.find(spv::CapabilityWorkgroupMemoryExplicitLayoutKHR) != capabilities.end()) { + assert(entryPoints.size() == 1); + auto &ep = entryPoints[0]; + + std::vector<Id> workgroup_variables; + for (int i = 0; i < (int)ep->getNumOperands(); i++) { + if (!ep->isIdOperand(i)) + continue; + + const Id id = ep->getIdOperand(i); + const Instruction *instr = module.getInstruction(id); + if (instr->getOpCode() != spv::OpVariable) + continue; + + if (instr->getImmediateOperand(0) == spv::StorageClassWorkgroup) + workgroup_variables.push_back(id); + } + + if (workgroup_variables.size() > 1) { + for (size_t i = 0; i < workgroup_variables.size(); i++) + addDecoration(workgroup_variables[i], spv::DecorationAliased); + } + } } #endif |