diff options
| author | 2023-12-18 22:15:44 -0500 | |
|---|---|---|
| committer | 2023-12-18 22:25:14 -0500 | |
| commit | 94244437de48561cc299c5afc4ee70c9dcd086ce (patch) | |
| tree | 6e8a917e55419a670728e4f76487f1d5b7ecc658 | |
| parent | Merge pull request #12349 from Kelebek1/return_system_channels_active (diff) | |
| download | yuzu-94244437de48561cc299c5afc4ee70c9dcd086ce.tar.gz yuzu-94244437de48561cc299c5afc4ee70c9dcd086ce.tar.xz yuzu-94244437de48561cc299c5afc4ee70c9dcd086ce.zip | |
shader_recompiler: ignore clip distances beyond driver support level
Diffstat (limited to '')
6 files changed, 14 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) { | |||
| 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..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) { | |||
| 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(F32[1], Const(std::min(8U, profile.max_user_clip_distances)))}; |
| 1532 | clip_distances = DefineOutput(*this, type, invocations, spv::BuiltIn::ClipDistance); | 1532 | clip_distances = DefineOutput(*this, type, invocations, spv::BuiltIn::ClipDistance); |
| 1533 | } | 1533 | } |
| 1534 | if (info.stores[IR::Attribute::Layer] && | 1534 | 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 { | |||
| 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/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp index 26f2d0ea7..b5999362a 100644 --- a/src/video_core/renderer_opengl/gl_shader_cache.cpp +++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp | |||
| @@ -233,6 +233,7 @@ ShaderCache::ShaderCache(RasterizerOpenGL& rasterizer_, Core::Frontend::EmuWindo | |||
| 233 | .ignore_nan_fp_comparisons = true, | 233 | .ignore_nan_fp_comparisons = true, |
| 234 | .gl_max_compute_smem_size = device.GetMaxComputeSharedMemorySize(), | 234 | .gl_max_compute_smem_size = device.GetMaxComputeSharedMemorySize(), |
| 235 | .min_ssbo_alignment = device.GetShaderStorageBufferAlignment(), | 235 | .min_ssbo_alignment = device.GetShaderStorageBufferAlignment(), |
| 236 | .max_user_clip_distances = 8, | ||
| 236 | }, | 237 | }, |
| 237 | host_info{ | 238 | host_info{ |
| 238 | .support_float64 = true, | 239 | .support_float64 = true, |
diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp index 2a13b2a72..fa63d6228 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp | |||
| @@ -374,6 +374,7 @@ PipelineCache::PipelineCache(RasterizerVulkan& rasterizer_, const Device& device | |||
| 374 | .has_broken_robust = | 374 | .has_broken_robust = |
| 375 | device.IsNvidia() && device.GetNvidiaArch() <= NvidiaArchitecture::Arch_Pascal, | 375 | device.IsNvidia() && device.GetNvidiaArch() <= NvidiaArchitecture::Arch_Pascal, |
| 376 | .min_ssbo_alignment = device.GetStorageBufferAlignment(), | 376 | .min_ssbo_alignment = device.GetStorageBufferAlignment(), |
| 377 | .max_user_clip_distances = device.GetMaxUserClipDistances(), | ||
| 377 | }; | 378 | }; |
| 378 | 379 | ||
| 379 | host_info = Shader::HostTranslateInfo{ | 380 | host_info = Shader::HostTranslateInfo{ |
diff --git a/src/video_core/vulkan_common/vulkan_device.h b/src/video_core/vulkan_common/vulkan_device.h index 4f3846345..701817086 100644 --- a/src/video_core/vulkan_common/vulkan_device.h +++ b/src/video_core/vulkan_common/vulkan_device.h | |||
| @@ -665,6 +665,10 @@ public: | |||
| 665 | return properties.properties.limits.maxViewports; | 665 | return properties.properties.limits.maxViewports; |
| 666 | } | 666 | } |
| 667 | 667 | ||
| 668 | u32 GetMaxUserClipDistances() const { | ||
| 669 | return properties.properties.limits.maxClipDistances; | ||
| 670 | } | ||
| 671 | |||
| 668 | bool SupportsConditionalBarriers() const { | 672 | bool SupportsConditionalBarriers() const { |
| 669 | return supports_conditional_barriers; | 673 | return supports_conditional_barriers; |
| 670 | } | 674 | } |