| 730 | } |
| 731 | |
| 732 | void 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 | |
| 755 | bool UpgradeMemoryModel::IsDeviceScope(uint32_t scope_id) { |
| 756 | const analysis::Constant* constant = |
nothing calls this directly
no test coverage detected