radv: fix buffers in vkGetDescriptorEXT with size not aligned to 4
authorKarol Herbst <kherbst@redhat.com>
Sun, 22 Oct 2023 19:50:35 +0000 (21:50 +0200)
committerEric Engestrom <eric@engestrom.ch>
Mon, 30 Oct 2023 15:48:27 +0000 (15:48 +0000)
The range alignment didn't happen through GetDescriptorEXT as it called
write_buffer_descriptor directly. So simply move the align
from write_buffer_descriptor_impl into write_buffer_descriptor.

Fixes: 46e0c77582d ("radv: implement VK_EXT_descriptor_buffer")
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25837>
(cherry picked from commit 1c619b668d69c66521d1da8edd97e518d6d61857)

.pick_status.json
src/amd/vulkan/radv_descriptor_set.c

index a7a21845bdc90ca482aa50131946d6effce2e099..e129ea3e151668373da4155d7bac15440ec29f82 100644 (file)
         "description": "radv: fix buffers in vkGetDescriptorEXT with size not aligned to 4",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "46e0c77582dd2cfbe77e78cf33399eb761ccb7b6",
         "notes": null
index 979ea00ab69dd3a45d403a8514701a16f2f06b1d..a0aa0673fe57149888c6fbf9d7e8e95fde47456b 100644 (file)
@@ -1095,7 +1095,11 @@ write_buffer_descriptor(struct radv_device *device, unsigned *dst, uint64_t va,
 
    dst[0] = va;
    dst[1] = S_008F04_BASE_ADDRESS_HI(va >> 32);
-   dst[2] = range;
+   /* robustBufferAccess is relaxed enough to allow this (in combination with the alignment/size
+    * we return from vkGetBufferMemoryRequirements) and this allows the shader compiler to create
+    * more efficient 8/16-bit buffer accesses.
+    */
+   dst[2] = align(range, 4);
    dst[3] = rsrc_word3;
 }
 
@@ -1111,12 +1115,6 @@ write_buffer_descriptor_impl(struct radv_device *device, struct radv_cmd_buffer
 
       range = vk_buffer_range(&buffer->vk, buffer_info->offset, buffer_info->range);
       assert(buffer->vk.size > 0 && range > 0);
-
-      /* robustBufferAccess is relaxed enough to allow this (in combination with the alignment/size
-       * we return from vkGetBufferMemoryRequirements) and this allows the shader compiler to create
-       * more efficient 8/16-bit buffer accesses.
-       */
-      range = align(range, 4);
    }
 
    write_buffer_descriptor(device, dst, va, range);