From f3766dada2de15dd5be2b56405fa34f5cdf00e91 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Wed, 18 Mar 2020 18:49:23 +0100 Subject: [PATCH] radv: fix optional pSizes parameter when binding streamout buffers The Vulkan spec 1.2.135 says: "pSizes is an optional array of buffer sizes, specifying the maximum number of bytes to capture to the corresponding transform feedback buffer. If pSizes is NULL, or the value of the pSizes array element is VK_WHOLE_SIZE, then the maximum bytes captured will be the size of the corresponding buffer minus the buffer offset." Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/2650 Fixes: b4eb029062a ("radv: implement VK_EXT_transform_feedback") Signed-off-by: Samuel Pitoiset Reviewed-by: Bas Nieuwenhuizen Tested-by: Marge Bot Part-of: (cherry picked from commit 2d3223ca90ae946231c1bfbfd1b450e5e96106a3) --- .pick_status.json | 2 +- src/amd/vulkan/radv_cmd_buffer.c | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index de4b3c2d87a..2b86367b3b3 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -121,7 +121,7 @@ "description": "radv: fix optional pSizes parameter when binding streamout buffers", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "master_sha": null, "because_sha": "b4eb029062a944c428d6214447a852318e36016e" }, diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c index 549b7e8843d..c0d5c44dadf 100644 --- a/src/amd/vulkan/radv_cmd_buffer.c +++ b/src/amd/vulkan/radv_cmd_buffer.c @@ -5905,7 +5905,12 @@ void radv_CmdBindTransformFeedbackBuffersEXT( sb[idx].buffer = radv_buffer_from_handle(pBuffers[i]); sb[idx].offset = pOffsets[i]; - sb[idx].size = pSizes[i]; + + if (!pSizes || pSizes[i] == VK_WHOLE_SIZE) { + sb[idx].size = sb[idx].buffer->size - sb[idx].offset; + } else { + sb[idx].size = pSizes[i]; + } radv_cs_add_buffer(cmd_buffer->device->ws, cmd_buffer->cs, sb[idx].buffer->bo);