| 95 | } |
| 96 | |
| 97 | std::string GenerateInstruction(const Operand operand) { |
| 98 | switch (operand) { |
| 99 | case OpMemoryBarrier: |
| 100 | return "OpMemoryBarrier %scope %semantics"; |
| 101 | case OpControlBarrier: |
| 102 | return "OpControlBarrier %uint_2 %scope %semantics"; |
| 103 | case OpAtomicLoad: |
| 104 | return "%result = OpAtomicLoad %uint %var %scope %semantics"; |
| 105 | case OpAtomicStore: |
| 106 | return "OpAtomicStore %var %scope %semantics %uint_1"; |
| 107 | case OpAtomicExchange: |
| 108 | return "%result = OpAtomicExchange %uint %var %scope %semantics %uint_1"; |
| 109 | case OpAtomicCompareExchangeEqual: |
| 110 | return "%result = OpAtomicCompareExchange %uint %var %scope %semantics " |
| 111 | "%semantics_min %uint_1 %uint_0"; |
| 112 | case OpAtomicCompareExchangeUnequal: |
| 113 | return "%result = OpAtomicCompareExchange %uint %var %scope " |
| 114 | "%semantics_max %semantics %uint_1 %uint_0"; |
| 115 | case OpAtomicIIncrement: |
| 116 | return "%result = OpAtomicIIncrement %uint %var %scope %semantics"; |
| 117 | case OpAtomicIDecrement: |
| 118 | return "%result = OpAtomicIDecrement %uint %var %scope %semantics"; |
| 119 | case OpAtomicIAdd: |
| 120 | return "%result = OpAtomicIAdd %uint %var %scope %semantics %uint_1"; |
| 121 | case OpAtomicISub: |
| 122 | return "%result = OpAtomicISub %uint %var %scope %semantics %uint_1"; |
| 123 | case OpAtomicSMin: |
| 124 | return "%result = OpAtomicSMin %uint %var %scope %semantics %uint_1"; |
| 125 | case OpAtomicUMin: |
| 126 | return "%result = OpAtomicUMin %uint %var %scope %semantics %uint_1"; |
| 127 | case OpAtomicSMax: |
| 128 | return "%result = OpAtomicSMax %uint %var %scope %semantics %uint_1"; |
| 129 | case OpAtomicUMax: |
| 130 | return "%result = OpAtomicUMax %uint %var %scope %semantics %uint_1"; |
| 131 | case OpAtomicAnd: |
| 132 | return "%result = OpAtomicAnd %uint %var %scope %semantics %uint_1"; |
| 133 | case OpAtomicOr: |
| 134 | return "%result = OpAtomicOr %uint %var %scope %semantics %uint_1"; |
| 135 | case OpAtomicXor: |
| 136 | return "%result = OpAtomicXor %uint %var %scope %semantics %uint_1"; |
| 137 | default: |
| 138 | return ""; |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | std::string GenerateVulkanCode(const std::string instruction, |
| 143 | const uint32_t semantics, |