From df3a0e127f46f9d2d40eebf7c65689007ae16b1d Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Mon, 11 May 2026 14:55:25 +0200 Subject: [PATCH] radv: fix amount of sample shading with required sample shaded inputs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Vulkan spec says: If a fragment shader entry point statically uses an input variable decorated with a BuiltIn of SampleId or SamplePosition, sample shading is enabled and a value of 1.0 is used instead of minSampleShading. If a fragment shader entry point statically uses an input variable decorated with Sample, sample shading may be enabled and a value of 1.0 will be used instead of minSampleShading if it is. This means we have to overwrite the command buffer state entirely. Cc: mesa-stable Reviewed-by: Samuel Pitoiset Reviewed-by: Marek Olšák (cherry picked from commit e7a035df653f1135cfffbbe152f0ae69beeec3b4) Part-of: --- .pick_status.json | 2 +- src/amd/vulkan/radv_cmd_buffer.c | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 1131a80a87e..abcd7751cc4 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -794,7 +794,7 @@ "description": "radv: fix amount of sample shading with required sample shaded inputs", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c index 2f280f495b8..b4a7a640188 100644 --- a/src/amd/vulkan/radv_cmd_buffer.c +++ b/src/amd/vulkan/radv_cmd_buffer.c @@ -1969,13 +1969,19 @@ radv_is_sample_shading_enabled(struct radv_cmd_buffer *cmd_buffer, float *min_sa if (min_sample_shading) *min_sample_shading = 1.0f; + /* If the PS requires sample shading for inputs, + * min_sample_shading is overwritten to 1.0. + */ + if (ps && ps->info.ps.uses_sample_shading) + return true; + if (cmd_buffer->state.ms.sample_shading_enable) { if (min_sample_shading) *min_sample_shading = cmd_buffer->state.ms.min_sample_shading; return true; } - return ps ? ps->info.ps.uses_sample_shading : false; + return false; } static ALWAYS_INLINE unsigned