From f4e56b61da2d823c77145f2510be068f5e36ea2d Mon Sep 17 00:00:00 2001 From: Aitor Camacho Date: Thu, 8 Jan 2026 08:24:23 +0900 Subject: [PATCH] hk: Handle unbound sets that contain dynamic buffers The offset for the dynamic buffers needs to be computed with the currently bound pipeline layout. This change fixes incorrectly selecting the offset for a dynamic buffer if a descriptor with a lower index than the currently being bound contains a dynamic buffer but said descriptor hasn't being bound yet. It also prevents the binding to override the dynamic buffers in order to preserve the already bound dynamic descriptors. Signed-off-by: Aitor Camacho Reviewed-by: Mel Henning Acked-by: Alyssa Rosenzweig (cherry picked from commit aaf4405507deb685ac7d57b1400e999465b54227) Part-of: --- .pick_status.json | 2 +- src/asahi/vulkan/hk_cmd_buffer.c | 18 ++++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index af22d13c219..41b3231e55c 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -4204,7 +4204,7 @@ "description": "hk: Handle unbound sets that contain dynamic buffers", "nominated": false, "nomination_type": 0, - "resolution": 4, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/asahi/vulkan/hk_cmd_buffer.c b/src/asahi/vulkan/hk_cmd_buffer.c index 5321662a0ea..42a952209b6 100644 --- a/src/asahi/vulkan/hk_cmd_buffer.c +++ b/src/asahi/vulkan/hk_cmd_buffer.c @@ -376,13 +376,15 @@ hk_bind_descriptor_sets(UNUSED struct hk_cmd_buffer *cmd, * * This means that, if some earlier set gets bound in such a way that * it changes set_dynamic_buffer_start[s], this binding is implicitly - * invalidated. Therefore, we can always look at the current value - * of set_dynamic_buffer_start[s] as the base of our dynamic buffer - * range and it's only our responsibility to adjust all - * set_dynamic_buffer_start[p] for p > s as needed. + * invalidated. */ - uint8_t dyn_buffer_start = - desc->root.set_dynamic_buffer_start[info->firstSet]; + uint8_t dyn_buffer_start = 0u; + for (uint32_t i = 0u; i < info->firstSet; ++i) { + const struct hk_descriptor_set_layout *set_layout = + vk_to_hk_descriptor_set_layout(pipeline_layout->set_layouts[i]); + if (set_layout) + dyn_buffer_start += set_layout->dynamic_buffer_count; + } uint32_t next_dyn_offset = 0; for (uint32_t i = 0; i < info->descriptorSetCount; ++i) { @@ -427,10 +429,6 @@ hk_bind_descriptor_sets(UNUSED struct hk_cmd_buffer *cmd, assert(dyn_buffer_start <= HK_MAX_DYNAMIC_BUFFERS); assert(next_dyn_offset <= info->dynamicOffsetCount); - for (uint32_t s = info->firstSet + info->descriptorSetCount; s < HK_MAX_SETS; - s++) - desc->root.set_dynamic_buffer_start[s] = dyn_buffer_start; - desc->root_dirty = true; }