From 517e94499f353368b4a0fcb7c92031cd12317e1d 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 955703268ff..d3bcba118ea 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -4594,7 +4594,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 f0e9cc7b0f9..edfbda3c630 100644 --- a/src/freedreno/vulkan/tu_cmd_buffer.cc +++ b/src/freedreno/vulkan/tu_cmd_buffer.cc @@ -4094,12 +4094,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;