diff options
Diffstat (limited to 'src/shader_recompiler')
5 files changed, 16 insertions, 2 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp index e5a78a914..feca5105f 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp | |||
| @@ -74,6 +74,11 @@ std::optional<OutAttr> OutputAttrPointer(EmitContext& ctx, IR::Attribute attr) { | |||
| 74 | case IR::Attribute::ClipDistance7: { | 74 | case IR::Attribute::ClipDistance7: { |
| 75 | const u32 base{static_cast<u32>(IR::Attribute::ClipDistance0)}; | 75 | const u32 base{static_cast<u32>(IR::Attribute::ClipDistance0)}; |
| 76 | const u32 index{static_cast<u32>(attr) - base}; | 76 | const u32 index{static_cast<u32>(attr) - base}; |
| 77 | if (index >= ctx.profile.max_user_clip_distances) { | ||
| 78 | LOG_WARNING(Shader, "Ignoring clip distance store {} >= {} supported", index, | ||
| 79 | ctx.profile.max_user_clip_distances); | ||
| 80 | return std::nullopt; | ||
| 81 | } | ||
| 77 | const Id clip_num{ctx.Const(index)}; | 82 | const Id clip_num{ctx.Const(index)}; |
| 78 | return OutputAccessChain(ctx, ctx.output_f32, ctx.clip_distances, clip_num); | 83 | return OutputAccessChain(ctx, ctx.output_f32, ctx.clip_distances, clip_num); |
| 79 | } | 84 | } |
diff --git a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp index 3350f1f85..2abc21a17 100644 --- a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp +++ b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp | |||
| @@ -1528,7 +1528,8 @@ void EmitContext::DefineOutputs(const IR::Program& program) { | |||
| 1528 | if (stage == Stage::Fragment) { | 1528 | if (stage == Stage::Fragment) { |
| 1529 | throw NotImplementedException("Storing ClipDistance in fragment stage"); | 1529 | throw NotImplementedException("Storing ClipDistance in fragment stage"); |
| 1530 | } | 1530 | } |
| 1531 | const Id type{TypeArray(F32[1], Const(8U))}; | 1531 | const Id type{TypeArray( |
| 1532 | F32[1], Const(std::min(info.used_clip_distances, profile.max_user_clip_distances)))}; | ||
| 1532 | clip_distances = DefineOutput(*this, type, invocations, spv::BuiltIn::ClipDistance); | 1533 | clip_distances = DefineOutput(*this, type, invocations, spv::BuiltIn::ClipDistance); |
| 1533 | } | 1534 | } |
| 1534 | if (info.stores[IR::Attribute::Layer] && | 1535 | if (info.stores[IR::Attribute::Layer] && |
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 70292686f..cb82a326c 100644 --- a/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp +++ b/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp | |||
| @@ -913,7 +913,11 @@ void GatherInfoFromHeader(Environment& env, Info& info) { | |||
| 913 | } | 913 | } |
| 914 | for (size_t index = 0; index < 8; ++index) { | 914 | for (size_t index = 0; index < 8; ++index) { |
| 915 | const u16 mask{header.vtg.omap_systemc.clip_distances}; | 915 | const u16 mask{header.vtg.omap_systemc.clip_distances}; |
| 916 | info.stores.Set(IR::Attribute::ClipDistance0 + index, ((mask >> index) & 1) != 0); | 916 | const bool used{((mask >> index) & 1) != 0}; |
| 917 | info.stores.Set(IR::Attribute::ClipDistance0 + index, used); | ||
| 918 | if (used) { | ||
| 919 | info.used_clip_distances = static_cast<u32>(index) + 1; | ||
| 920 | } | ||
| 917 | } | 921 | } |
| 918 | info.stores.Set(IR::Attribute::PrimitiveId, | 922 | info.stores.Set(IR::Attribute::PrimitiveId, |
| 919 | header.vtg.omap_systemb.primitive_array_id != 0); | 923 | header.vtg.omap_systemb.primitive_array_id != 0); |
diff --git a/src/shader_recompiler/profile.h b/src/shader_recompiler/profile.h index 66901a965..7578d41cc 100644 --- a/src/shader_recompiler/profile.h +++ b/src/shader_recompiler/profile.h | |||
| @@ -87,6 +87,8 @@ struct Profile { | |||
| 87 | bool has_broken_robust{}; | 87 | bool has_broken_robust{}; |
| 88 | 88 | ||
| 89 | u64 min_ssbo_alignment{}; | 89 | u64 min_ssbo_alignment{}; |
| 90 | |||
| 91 | u32 max_user_clip_distances{}; | ||
| 90 | }; | 92 | }; |
| 91 | 93 | ||
| 92 | } // namespace Shader | 94 | } // namespace Shader |
diff --git a/src/shader_recompiler/shader_info.h b/src/shader_recompiler/shader_info.h index b4b4afd37..1419b8fe7 100644 --- a/src/shader_recompiler/shader_info.h +++ b/src/shader_recompiler/shader_info.h | |||
| @@ -227,6 +227,8 @@ struct Info { | |||
| 227 | bool requires_layer_emulation{}; | 227 | bool requires_layer_emulation{}; |
| 228 | IR::Attribute emulated_layer{}; | 228 | IR::Attribute emulated_layer{}; |
| 229 | 229 | ||
| 230 | u32 used_clip_distances{}; | ||
| 231 | |||
| 230 | boost::container::static_vector<ConstantBufferDescriptor, MAX_CBUFS> | 232 | boost::container::static_vector<ConstantBufferDescriptor, MAX_CBUFS> |
| 231 | constant_buffer_descriptors; | 233 | constant_buffer_descriptors; |
| 232 | boost::container::static_vector<StorageBufferDescriptor, MAX_SSBOS> storage_buffers_descriptors; | 234 | boost::container::static_vector<StorageBufferDescriptor, MAX_SSBOS> storage_buffers_descriptors; |