diff options
Diffstat (limited to 'src/shader_recompiler/ir_opt')
| -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) { | |||
| 45 | } | 45 | } |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | u32 GetElementSize(IR::Type& used_type, Shader::IR::Opcode opcode) { | ||
| 49 | switch (opcode) { | ||
| 50 | case IR::Opcode::GetCbufU8: | ||
| 51 | case IR::Opcode::GetCbufS8: | ||
| 52 | used_type |= IR::Type::U8; | ||
| 53 | return 1; | ||
| 54 | case IR::Opcode::GetCbufU16: | ||
| 55 | case IR::Opcode::GetCbufS16: | ||
| 56 | used_type |= IR::Type::U16; | ||
| 57 | return 2; | ||
| 58 | case IR::Opcode::GetCbufU32: | ||
| 59 | used_type |= IR::Type::U32; | ||
| 60 | return 4; | ||
| 61 | case IR::Opcode::GetCbufF32: | ||
| 62 | used_type |= IR::Type::F32; | ||
| 63 | return 4; | ||
| 64 | case IR::Opcode::GetCbufU32x2: | ||
| 65 | used_type |= IR::Type::U32x2; | ||
| 66 | return 8; | ||
| 67 | default: | ||
| 68 | throw InvalidArgument("Invalid opcode {}", opcode); | ||
| 69 | } | ||
| 70 | } | ||
| 71 | |||
| 48 | void GetPatch(Info& info, IR::Patch patch) { | 72 | void GetPatch(Info& info, IR::Patch patch) { |
| 49 | if (!IR::IsGeneric(patch)) { | 73 | if (!IR::IsGeneric(patch)) { |
| 50 | throw NotImplementedException("Reading non-generic patch {}", patch); | 74 | throw NotImplementedException("Reading non-generic patch {}", patch); |
| @@ -481,45 +505,16 @@ void VisitUsages(Info& info, IR::Inst& inst) { | |||
| 481 | const IR::Value offset{inst.Arg(1)}; | 505 | const IR::Value offset{inst.Arg(1)}; |
| 482 | if (index.IsImmediate()) { | 506 | if (index.IsImmediate()) { |
| 483 | AddConstantBufferDescriptor(info, index.U32(), 1); | 507 | AddConstantBufferDescriptor(info, index.U32(), 1); |
| 484 | } else { | 508 | u32 element_size = GetElementSize(info.used_constant_buffer_types, inst.GetOpcode()); |
| 485 | AddRegisterIndexedLdc(info); | ||
| 486 | } | ||
| 487 | |||
| 488 | u32 element_size{}; | ||
| 489 | switch (inst.GetOpcode()) { | ||
| 490 | case IR::Opcode::GetCbufU8: | ||
| 491 | case IR::Opcode::GetCbufS8: | ||
| 492 | info.used_constant_buffer_types |= IR::Type::U8; | ||
| 493 | element_size = 1; | ||
| 494 | break; | ||
| 495 | case IR::Opcode::GetCbufU16: | ||
| 496 | case IR::Opcode::GetCbufS16: | ||
| 497 | info.used_constant_buffer_types |= IR::Type::U16; | ||
| 498 | element_size = 2; | ||
| 499 | break; | ||
| 500 | case IR::Opcode::GetCbufU32: | ||
| 501 | info.used_constant_buffer_types |= IR::Type::U32; | ||
| 502 | element_size = 4; | ||
| 503 | break; | ||
| 504 | case IR::Opcode::GetCbufF32: | ||
| 505 | info.used_constant_buffer_types |= IR::Type::F32; | ||
| 506 | element_size = 4; | ||
| 507 | break; | ||
| 508 | case IR::Opcode::GetCbufU32x2: | ||
| 509 | info.used_constant_buffer_types |= IR::Type::U32x2; | ||
| 510 | element_size = 8; | ||
| 511 | break; | ||
| 512 | default: | ||
| 513 | break; | ||
| 514 | } | ||
| 515 | |||
| 516 | if (index.IsImmediate()) { | ||
| 517 | u32& size{info.constant_buffer_used_sizes[index.U32()]}; | 509 | u32& size{info.constant_buffer_used_sizes[index.U32()]}; |
| 518 | if (offset.IsImmediate()) { | 510 | if (offset.IsImmediate()) { |
| 519 | size = Common::AlignUp(std::max(size, offset.U32() + element_size), 16u); | 511 | size = Common::AlignUp(std::max(size, offset.U32() + element_size), 16u); |
| 520 | } else { | 512 | } else { |
| 521 | size = 0x10'000; | 513 | size = 0x10'000; |
| 522 | } | 514 | } |
| 515 | } else { | ||
| 516 | AddRegisterIndexedLdc(info); | ||
| 517 | GetElementSize(info.used_indirect_cbuf_types, inst.GetOpcode()); | ||
| 523 | } | 518 | } |
| 524 | break; | 519 | break; |
| 525 | } | 520 | } |