summaryrefslogtreecommitdiff
path: root/src/shader_recompiler
diff options
context:
space:
mode:
authorGravatar Liam2023-12-18 22:20:25 -0500
committerGravatar Liam2023-12-18 22:25:14 -0500
commitfcfa8b680b6aedd4b51757d4e33e97ef2cdae048 (patch)
treede1aac013700c0e22d378b8a35f5f20b6e35d161 /src/shader_recompiler
parentshader_recompiler: ignore clip distances beyond driver support level (diff)
downloadyuzu-fcfa8b680b6aedd4b51757d4e33e97ef2cdae048.tar.gz
yuzu-fcfa8b680b6aedd4b51757d4e33e97ef2cdae048.tar.xz
yuzu-fcfa8b680b6aedd4b51757d4e33e97ef2cdae048.zip
shader_recompiler: use minimal clip distance array
Diffstat (limited to 'src/shader_recompiler')
-rw-r--r--src/shader_recompiler/backend/spirv/spirv_emit_context.cpp3
-rw-r--r--src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp6
-rw-r--r--src/shader_recompiler/shader_info.h2
3 files changed, 9 insertions, 2 deletions
diff --git a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp
index 4d24e02de..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(std::min(8U, profile.max_user_clip_distances)))}; 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/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;