MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / UpgradeMemoryScope

Method UpgradeMemoryScope

source/opt/upgrade_memory_model.cpp:732–753  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

730}
731
732void UpgradeMemoryModel::UpgradeMemoryScope() {
733 get_module()->ForEachInst([this](Instruction* inst) {
734 // Don't need to handle all the operations that take a scope.
735 // * Group operations can only be subgroup
736 // * Non-uniform can only be workgroup or subgroup
737 // * Named barriers are not supported by Vulkan
738 // * Workgroup ops (e.g. async_copy) have at most workgroup scope.
739 if (spvOpcodeIsAtomicOp(inst->opcode())) {
740 if (IsDeviceScope(inst->GetSingleWordInOperand(1))) {
741 inst->SetInOperand(1, {GetScopeConstant(spv::Scope::QueueFamilyKHR)});
742 }
743 } else if (inst->opcode() == spv::Op::OpControlBarrier) {
744 if (IsDeviceScope(inst->GetSingleWordInOperand(1))) {
745 inst->SetInOperand(1, {GetScopeConstant(spv::Scope::QueueFamilyKHR)});
746 }
747 } else if (inst->opcode() == spv::Op::OpMemoryBarrier) {
748 if (IsDeviceScope(inst->GetSingleWordInOperand(0))) {
749 inst->SetInOperand(0, {GetScopeConstant(spv::Scope::QueueFamilyKHR)});
750 }
751 }
752 });
753}
754
755bool UpgradeMemoryModel::IsDeviceScope(uint32_t scope_id) {
756 const analysis::Constant* constant =

Callers

nothing calls this directly

Calls 5

spvOpcodeIsAtomicOpFunction · 0.85
SetInOperandMethod · 0.80
ForEachInstMethod · 0.45
opcodeMethod · 0.45

Tested by

no test coverage detected