From 1ce7aca953f5cee5871c544000f95efd2f6c3cc9 Mon Sep 17 00:00:00 2001 From: Connor Abbott Date: Fri, 22 Aug 2025 12:04:27 -0400 Subject: [PATCH] tu: Fix CmdBindTransformFeedbackBuffersEXT size handling According to the spec and as implemented by other drivers, this should use the size of the buffer instead of the size of the VkDeviceMemory it's bound to when VK_WHOLE_SIZE is specified or pSizes is NULL. The current behavior doesn't make sense at all for sparse buffers which are not bound to a single VkDeviceMemory. Just use the common helper that already does the right thing, copied from anv. Cc: mesa-stable Part-of: (cherry picked from commit 460ed359164105f7ea9d50e7909500d786f7ca27) --- .pick_status.json | 2 +- src/freedreno/vulkan/tu_cmd_buffer.cc | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index eb2f3525388..213e87a9e18 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -974,7 +974,7 @@ "description": "tu: Fix CmdBindTransformFeedbackBuffersEXT size handling", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/freedreno/vulkan/tu_cmd_buffer.cc b/src/freedreno/vulkan/tu_cmd_buffer.cc index 03dde570036..d6b72cc3a76 100644 --- a/src/freedreno/vulkan/tu_cmd_buffer.cc +++ b/src/freedreno/vulkan/tu_cmd_buffer.cc @@ -3892,12 +3892,10 @@ tu_CmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer, for (uint32_t i = 0; i < bindingCount; i++) { VK_FROM_HANDLE(tu_buffer, buf, pBuffers[i]); uint64_t iova = vk_buffer_address(&buf->vk, pOffsets[i]); - uint32_t size = buf->bo->size - (iova - buf->bo->iova); + uint32_t size = vk_buffer_range(&buf->vk, pOffsets[i], + pSizes ? pSizes[i] : VK_WHOLE_SIZE); uint32_t idx = i + firstBinding; - if (pSizes && pSizes[i] != VK_WHOLE_SIZE) - size = pSizes[i]; - /* BUFFER_BASE is 32-byte aligned, add remaining offset to BUFFER_OFFSET */ uint32_t offset = iova & 0x1f; iova &= ~(uint64_t) 0x1f;