From 4a4a86390ba8c8bae8b9febf7750c0fbc05ef2ab Mon Sep 17 00:00:00 2001 From: Danylo Piliaiev Date: Fri, 6 Mar 2026 14:57:56 +0100 Subject: [PATCH] tu: Don't read .patch_input_gmem of unused attachment There was duplicated code to set unscaled_input_fragcoord and a read from VK_ATTACHMENT_UNUSED attachment, which incorrectly updated builder->unscaled_input_fragcoord. ubsan: tu_pipeline.cc:4734:44: runtime error: load of value 127, which is not a valid value for type 'bool' Seen in: dEQP-VK.renderpasses.renderpass1.custom_resolve.monolithic.stencil_only_s8 Fixes: 97da0a77341 ("tu: Rewrite to use common Vulkan dynamic state") Signed-off-by: Danylo Piliaiev (cherry picked from commit 81a76be861c3281d0fc227824c2b17401484c2c7) Part-of: --- .pick_status.json | 2 +- src/freedreno/vulkan/tu_pipeline.cc | 11 ++--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 3f903a45656..f8b0c8c1975 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1774,7 +1774,7 @@ "description": "tu: Don't read .patch_input_gmem of unused attachment", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "97da0a7734188f4b666bc38833bfadc8b4c53f84", "notes": null diff --git a/src/freedreno/vulkan/tu_pipeline.cc b/src/freedreno/vulkan/tu_pipeline.cc index c3e1cba82ad..68b412da50a 100644 --- a/src/freedreno/vulkan/tu_pipeline.cc +++ b/src/freedreno/vulkan/tu_pipeline.cc @@ -4678,14 +4678,6 @@ tu_pipeline_builder_init_graphics( tu_fill_render_pass_state(&rp_state, pass, subpass); - for (unsigned i = 0; i < subpass->input_count; i++) { - /* Input attachments stored in GMEM must be loaded with unscaled - * FragCoord. - */ - if (subpass->input_attachments[i].patch_input_gmem) - builder->unscaled_input_fragcoord |= 1u << i; - } - if (subpass->feedback_loop_color) { rp_flags |= VK_PIPELINE_CREATE_2_COLOR_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT; @@ -4716,7 +4708,8 @@ tu_pipeline_builder_init_graphics( /* Input attachments stored in GMEM must be loaded with unscaled * FragCoord. */ - if (subpass->input_attachments[i].patch_input_gmem) + if (subpass->input_attachments[i].attachment != VK_ATTACHMENT_UNUSED && + subpass->input_attachments[i].patch_input_gmem) builder->unscaled_input_fragcoord |= 1u << i; }