radv: fix optional pSizes parameter when binding streamout buffers
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 18 Mar 2020 17:49:23 +0000 (18:49 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 20 Mar 2020 08:25:14 +0000 (09:25 +0100)
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 <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4232>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4232>

src/amd/vulkan/radv_cmd_buffer.c

index b58b3541c803bb94bf09c056b9f5aa16871553a0..81b705893f79309a7d8464ff330836c96122d8a3 100644 (file)
@@ -6026,7 +6026,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);