summaryrefslogtreecommitdiff
path: root/thirdparty/glslang/SPIRV/SpvPostProcess.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/glslang/SPIRV/SpvPostProcess.cpp')
-rw-r--r--thirdparty/glslang/SPIRV/SpvPostProcess.cpp32
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