diff options
author | Liam <byteslice@airmail.cc> | 2022-03-17 19:45:38 +0100 |
---|---|---|
committer | Liam <byteslice@airmail.cc> | 2022-03-17 19:48:18 +0100 |
commit | 3009d0bd7d30b341a8697d85d9d42a9ee4910d19 (patch) | |
tree | c00cb183d00f673185e69fa0d4094b34bcabbe12 /src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp | |
parent | shader_recompiler: Use functions for indirect const buffer accesses (diff) | |
download | yuzu-3009d0bd7d30b341a8697d85d9d42a9ee4910d19.tar yuzu-3009d0bd7d30b341a8697d85d9d42a9ee4910d19.tar.gz yuzu-3009d0bd7d30b341a8697d85d9d42a9ee4910d19.tar.bz2 yuzu-3009d0bd7d30b341a8697d85d9d42a9ee4910d19.tar.lz yuzu-3009d0bd7d30b341a8697d85d9d42a9ee4910d19.tar.xz yuzu-3009d0bd7d30b341a8697d85d9d42a9ee4910d19.tar.zst yuzu-3009d0bd7d30b341a8697d85d9d42a9ee4910d19.zip |
Diffstat (limited to '')
-rw-r--r-- | src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp | 61 |
1 files changed, 28 insertions, 33 deletions
diff --git a/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp b/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp index b54894a9b..0b2c60842 100644 --- a/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp +++ b/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp @@ -45,6 +45,30 @@ void AddRegisterIndexedLdc(Info& info) { } } +u32 GetElementSize(IR::Type& used_type, Shader::IR::Opcode opcode) { + switch (opcode) { + case IR::Opcode::GetCbufU8: + case IR::Opcode::GetCbufS8: + used_type |= IR::Type::U8; + return 1; + case IR::Opcode::GetCbufU16: + case IR::Opcode::GetCbufS16: + used_type |= IR::Type::U16; + return 2; + case IR::Opcode::GetCbufU32: + used_type |= IR::Type::U32; + return 4; + case IR::Opcode::GetCbufF32: + used_type |= IR::Type::F32; + return 4; + case IR::Opcode::GetCbufU32x2: + used_type |= IR::Type::U32x2; + return 8; + default: + throw InvalidArgument("Invalid opcode {}", opcode); + } +} + void GetPatch(Info& info, IR::Patch patch) { if (!IR::IsGeneric(patch)) { throw NotImplementedException("Reading non-generic patch {}", patch); @@ -481,45 +505,16 @@ void VisitUsages(Info& info, IR::Inst& inst) { const IR::Value offset{inst.Arg(1)}; if (index.IsImmediate()) { AddConstantBufferDescriptor(info, index.U32(), 1); - } else { - AddRegisterIndexedLdc(info); - } - - u32 element_size{}; - switch (inst.GetOpcode()) { - case IR::Opcode::GetCbufU8: - case IR::Opcode::GetCbufS8: - info.used_constant_buffer_types |= IR::Type::U8; - element_size = 1; - break; - case IR::Opcode::GetCbufU16: - case IR::Opcode::GetCbufS16: - info.used_constant_buffer_types |= IR::Type::U16; - element_size = 2; - break; - case IR::Opcode::GetCbufU32: - info.used_constant_buffer_types |= IR::Type::U32; - element_size = 4; - break; - case IR::Opcode::GetCbufF32: - info.used_constant_buffer_types |= IR::Type::F32; - element_size = 4; - break; - case IR::Opcode::GetCbufU32x2: - info.used_constant_buffer_types |= IR::Type::U32x2; - element_size = 8; - break; - default: - break; - } - - if (index.IsImmediate()) { + u32 element_size = GetElementSize(info.used_constant_buffer_types, inst.GetOpcode()); u32& size{info.constant_buffer_used_sizes[index.U32()]}; if (offset.IsImmediate()) { size = Common::AlignUp(std::max(size, offset.U32() + element_size), 16u); } else { size = 0x10'000; } + } else { + AddRegisterIndexedLdc(info); + GetElementSize(info.used_indirect_cbuf_types, inst.GetOpcode()); } break; } |