summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp b/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp
index 1d11a00d8..70449eeca 100644
--- a/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp
+++ b/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp
@@ -253,12 +253,12 @@ struct LowAddrInfo {
253/// Tries to track the first 32-bits of a global memory instruction 253/// Tries to track the first 32-bits of a global memory instruction
254std::optional<LowAddrInfo> TrackLowAddress(IR::Inst* inst) { 254std::optional<LowAddrInfo> TrackLowAddress(IR::Inst* inst) {
255 // The first argument is the low level GPU pointer to the global memory instruction 255 // The first argument is the low level GPU pointer to the global memory instruction
256 const IR::U64 addr{inst->Arg(0)}; 256 const IR::Value addr{inst->Arg(0)};
257 if (addr.IsImmediate()) { 257 if (addr.IsImmediate()) {
258 // Not much we can do if it's an immediate 258 // Not much we can do if it's an immediate
259 return std::nullopt; 259 return std::nullopt;
260 } 260 }
261 // This address is expected to either be a PackUint2x32 or a IAdd64 261 // This address is expected to either be a PackUint2x32, a IAdd64, or a CompositeConstructU32x2
262 IR::Inst* addr_inst{addr.InstRecursive()}; 262 IR::Inst* addr_inst{addr.InstRecursive()};
263 s32 imm_offset{0}; 263 s32 imm_offset{0};
264 if (addr_inst->GetOpcode() == IR::Opcode::IAdd64) { 264 if (addr_inst->GetOpcode() == IR::Opcode::IAdd64) {
@@ -274,25 +274,24 @@ std::optional<LowAddrInfo> TrackLowAddress(IR::Inst* inst) {
274 if (iadd_addr.IsImmediate()) { 274 if (iadd_addr.IsImmediate()) {
275 return std::nullopt; 275 return std::nullopt;
276 } 276 }
277 addr_inst = iadd_addr.Inst(); 277 addr_inst = iadd_addr.InstRecursive();
278 } 278 }
279 // With IAdd64 handled, now PackUint2x32 is expected without exceptions 279 // With IAdd64 handled, now PackUint2x32 is expected
280 if (addr_inst->GetOpcode() != IR::Opcode::PackUint2x32) { 280 if (addr_inst->GetOpcode() == IR::Opcode::PackUint2x32) {
281 return std::nullopt; 281 // PackUint2x32 is expected to be generated from a vector
282 } 282 const IR::Value vector{addr_inst->Arg(0)};
283 // PackUint2x32 is expected to be generated from a vector 283 if (vector.IsImmediate()) {
284 const IR::Value vector{addr_inst->Arg(0)}; 284 return std::nullopt;
285 if (vector.IsImmediate()) { 285 }
286 return std::nullopt; 286 addr_inst = vector.InstRecursive();
287 } 287 }
288 // This vector is expected to be a CompositeConstructU32x2 288 // The vector is expected to be a CompositeConstructU32x2
289 IR::Inst* const vector_inst{vector.InstRecursive()}; 289 if (addr_inst->GetOpcode() != IR::Opcode::CompositeConstructU32x2) {
290 if (vector_inst->GetOpcode() != IR::Opcode::CompositeConstructU32x2) {
291 return std::nullopt; 290 return std::nullopt;
292 } 291 }
293 // Grab the first argument from the CompositeConstructU32x2, this is the low address. 292 // Grab the first argument from the CompositeConstructU32x2, this is the low address.
294 return LowAddrInfo{ 293 return LowAddrInfo{
295 .value{IR::U32{vector_inst->Arg(0)}}, 294 .value{IR::U32{addr_inst->Arg(0)}},
296 .imm_offset = imm_offset, 295 .imm_offset = imm_offset,
297 }; 296 };
298} 297}