diff options
Diffstat (limited to 'src/shader_recompiler')
| -rw-r--r-- | src/shader_recompiler/backend/spirv/spirv_emit_context.cpp | 21 | ||||
| -rw-r--r-- | src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp | 9 | ||||
| -rw-r--r-- | src/shader_recompiler/shader_info.h | 1 |
3 files changed, 14 insertions, 17 deletions
diff --git a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp index 28f6a6184..9c83cd2e4 100644 --- a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp +++ b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp | |||
| @@ -1043,15 +1043,15 @@ void EmitContext::DefineConstantBufferIndirectFunctions(const Info& info) { | |||
| 1043 | const Id merge_label{OpLabel()}; | 1043 | const Id merge_label{OpLabel()}; |
| 1044 | const Id uniform_type{uniform_types.*member_ptr}; | 1044 | const Id uniform_type{uniform_types.*member_ptr}; |
| 1045 | 1045 | ||
| 1046 | std::array<Id, Info::MAX_CBUFS> buf_labels; | 1046 | std::array<Id, Info::MAX_INDIRECT_CBUFS> buf_labels; |
| 1047 | std::array<Sirit::Literal, Info::MAX_CBUFS> buf_literals; | 1047 | std::array<Sirit::Literal, Info::MAX_INDIRECT_CBUFS> buf_literals; |
| 1048 | for (u32 i = 0; i < Info::MAX_CBUFS; i++) { | 1048 | for (u32 i = 0; i < Info::MAX_INDIRECT_CBUFS; i++) { |
| 1049 | buf_labels[i] = OpLabel(); | 1049 | buf_labels[i] = OpLabel(); |
| 1050 | buf_literals[i] = Sirit::Literal{i}; | 1050 | buf_literals[i] = Sirit::Literal{i}; |
| 1051 | } | 1051 | } |
| 1052 | OpSelectionMerge(merge_label, spv::SelectionControlMask::MaskNone); | 1052 | OpSelectionMerge(merge_label, spv::SelectionControlMask::MaskNone); |
| 1053 | OpSwitch(binding, buf_labels[0], buf_literals, buf_labels); | 1053 | OpSwitch(binding, buf_labels[0], buf_literals, buf_labels); |
| 1054 | for (u32 i = 0; i < Info::MAX_CBUFS; i++) { | 1054 | for (u32 i = 0; i < Info::MAX_INDIRECT_CBUFS; i++) { |
| 1055 | AddLabel(buf_labels[i]); | 1055 | AddLabel(buf_labels[i]); |
| 1056 | const Id cbuf{cbufs[i].*member_ptr}; | 1056 | const Id cbuf{cbufs[i].*member_ptr}; |
| 1057 | const Id access_chain{OpAccessChain(uniform_type, cbuf, u32_zero_value, offset)}; | 1057 | const Id access_chain{OpAccessChain(uniform_type, cbuf, u32_zero_value, offset)}; |
| @@ -1064,22 +1064,23 @@ void EmitContext::DefineConstantBufferIndirectFunctions(const Info& info) { | |||
| 1064 | return func; | 1064 | return func; |
| 1065 | }}; | 1065 | }}; |
| 1066 | IR::Type types{info.used_indirect_cbuf_types}; | 1066 | IR::Type types{info.used_indirect_cbuf_types}; |
| 1067 | if (True(types & IR::Type::U8)) { | 1067 | bool supports_aliasing = profile.support_descriptor_aliasing; |
| 1068 | if (supports_aliasing && True(types & IR::Type::U8)) { | ||
| 1068 | load_const_func_u8 = make_accessor(U8, &UniformDefinitions::U8); | 1069 | load_const_func_u8 = make_accessor(U8, &UniformDefinitions::U8); |
| 1069 | } | 1070 | } |
| 1070 | if (True(types & IR::Type::U16)) { | 1071 | if (supports_aliasing && True(types & IR::Type::U16)) { |
| 1071 | load_const_func_u16 = make_accessor(U16, &UniformDefinitions::U16); | 1072 | load_const_func_u16 = make_accessor(U16, &UniformDefinitions::U16); |
| 1072 | } | 1073 | } |
| 1073 | if (True(types & IR::Type::F32)) { | 1074 | if (supports_aliasing && True(types & IR::Type::F32)) { |
| 1074 | load_const_func_f32 = make_accessor(F32[1], &UniformDefinitions::F32); | 1075 | load_const_func_f32 = make_accessor(F32[1], &UniformDefinitions::F32); |
| 1075 | } | 1076 | } |
| 1076 | if (True(types & IR::Type::U32)) { | 1077 | if (supports_aliasing && True(types & IR::Type::U32)) { |
| 1077 | load_const_func_u32 = make_accessor(U32[1], &UniformDefinitions::U32); | 1078 | load_const_func_u32 = make_accessor(U32[1], &UniformDefinitions::U32); |
| 1078 | } | 1079 | } |
| 1079 | if (True(types & IR::Type::U32x2)) { | 1080 | if (supports_aliasing && True(types & IR::Type::U32x2)) { |
| 1080 | load_const_func_u32x2 = make_accessor(U32[2], &UniformDefinitions::U32x2); | 1081 | load_const_func_u32x2 = make_accessor(U32[2], &UniformDefinitions::U32x2); |
| 1081 | } | 1082 | } |
| 1082 | if (True(types & IR::Type::U32x4)) { | 1083 | if (!supports_aliasing || True(types & IR::Type::U32x4)) { |
| 1083 | load_const_func_u32x4 = make_accessor(U32[4], &UniformDefinitions::U32x4); | 1084 | load_const_func_u32x4 = make_accessor(U32[4], &UniformDefinitions::U32x4); |
| 1084 | } | 1085 | } |
| 1085 | } | 1086 | } |
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 0b2c60842..16278faab 100644 --- a/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp +++ b/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp | |||
| @@ -32,13 +32,8 @@ void AddConstantBufferDescriptor(Info& info, u32 index, u32 count) { | |||
| 32 | void AddRegisterIndexedLdc(Info& info) { | 32 | void AddRegisterIndexedLdc(Info& info) { |
| 33 | info.uses_cbuf_indirect = true; | 33 | info.uses_cbuf_indirect = true; |
| 34 | 34 | ||
| 35 | // The shader can use any possible constant buffer | 35 | for (u32 i = 0; i < Info::MAX_INDIRECT_CBUFS; i++) { |
| 36 | info.constant_buffer_mask = (1 << Info::MAX_CBUFS) - 1; | 36 | AddConstantBufferDescriptor(info, i, 1); |
| 37 | |||
| 38 | auto& cbufs{info.constant_buffer_descriptors}; | ||
| 39 | cbufs.clear(); | ||
| 40 | for (u32 i = 0; i < Info::MAX_CBUFS; i++) { | ||
| 41 | cbufs.push_back(ConstantBufferDescriptor{.index = i, .count = 1}); | ||
| 42 | 37 | ||
| 43 | // The shader can use any possible access size | 38 | // The shader can use any possible access size |
| 44 | info.constant_buffer_used_sizes[i] = 0x10'000; | 39 | info.constant_buffer_used_sizes[i] = 0x10'000; |
diff --git a/src/shader_recompiler/shader_info.h b/src/shader_recompiler/shader_info.h index 9d36bd9eb..c14856dd0 100644 --- a/src/shader_recompiler/shader_info.h +++ b/src/shader_recompiler/shader_info.h | |||
| @@ -105,6 +105,7 @@ struct ImageDescriptor { | |||
| 105 | using ImageDescriptors = boost::container::small_vector<ImageDescriptor, 4>; | 105 | using ImageDescriptors = boost::container::small_vector<ImageDescriptor, 4>; |
| 106 | 106 | ||
| 107 | struct Info { | 107 | struct Info { |
| 108 | static constexpr size_t MAX_INDIRECT_CBUFS{16}; | ||
| 108 | static constexpr size_t MAX_CBUFS{18}; | 109 | static constexpr size_t MAX_CBUFS{18}; |
| 109 | static constexpr size_t MAX_SSBOS{32}; | 110 | static constexpr size_t MAX_SSBOS{32}; |
| 110 | 111 | ||