diff options
author | Liam <byteslice@airmail.cc> | 2023-12-19 04:15:44 +0100 |
---|---|---|
committer | Liam <byteslice@airmail.cc> | 2023-12-19 04:25:14 +0100 |
commit | 94244437de48561cc299c5afc4ee70c9dcd086ce (patch) | |
tree | 6e8a917e55419a670728e4f76487f1d5b7ecc658 /src/shader_recompiler | |
parent | Merge pull request #12349 from Kelebek1/return_system_channels_active (diff) | |
download | yuzu-94244437de48561cc299c5afc4ee70c9dcd086ce.tar yuzu-94244437de48561cc299c5afc4ee70c9dcd086ce.tar.gz yuzu-94244437de48561cc299c5afc4ee70c9dcd086ce.tar.bz2 yuzu-94244437de48561cc299c5afc4ee70c9dcd086ce.tar.lz yuzu-94244437de48561cc299c5afc4ee70c9dcd086ce.tar.xz yuzu-94244437de48561cc299c5afc4ee70c9dcd086ce.tar.zst yuzu-94244437de48561cc299c5afc4ee70c9dcd086ce.zip |
Diffstat (limited to 'src/shader_recompiler')
-rw-r--r-- | src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp | 5 | ||||
-rw-r--r-- | src/shader_recompiler/backend/spirv/spirv_emit_context.cpp | 2 | ||||
-rw-r--r-- | src/shader_recompiler/profile.h | 2 |
3 files changed, 8 insertions, 1 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) { case IR::Attribute::ClipDistance7: { const u32 base{static_cast<u32>(IR::Attribute::ClipDistance0)}; const u32 index{static_cast<u32>(attr) - base}; + if (index >= ctx.profile.max_user_clip_distances) { + LOG_WARNING(Shader, "Ignoring clip distance store {} >= {} supported", index, + ctx.profile.max_user_clip_distances); + return std::nullopt; + } const Id clip_num{ctx.Const(index)}; return OutputAccessChain(ctx, ctx.output_f32, ctx.clip_distances, clip_num); } diff --git a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp index 3350f1f85..4d24e02de 100644 --- a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp +++ b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp @@ -1528,7 +1528,7 @@ void EmitContext::DefineOutputs(const IR::Program& program) { if (stage == Stage::Fragment) { throw NotImplementedException("Storing ClipDistance in fragment stage"); } - const Id type{TypeArray(F32[1], Const(8U))}; + const Id type{TypeArray(F32[1], Const(std::min(8U, profile.max_user_clip_distances)))}; clip_distances = DefineOutput(*this, type, invocations, spv::BuiltIn::ClipDistance); } if (info.stores[IR::Attribute::Layer] && 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 { bool has_broken_robust{}; u64 min_ssbo_alignment{}; + + u32 max_user_clip_distances{}; }; } // namespace Shader |