From 77eb71a612b47ad55d8dde2b0dbc0f935ad5bea6 Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Sun, 22 Oct 2023 21:50:35 +0200 Subject: [PATCH] radv: fix buffers in vkGetDescriptorEXT with size not aligned to 4 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 Reviewed-by: Georg Lehmann Reviewed-by: Samuel Pitoiset Part-of: (cherry picked from commit 1c619b668d69c66521d1da8edd97e518d6d61857) --- .pick_status.json | 2 +- src/amd/vulkan/radv_descriptor_set.c | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index a7a21845bdc..e129ea3e151 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -694,7 +694,7 @@ "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 diff --git a/src/amd/vulkan/radv_descriptor_set.c b/src/amd/vulkan/radv_descriptor_set.c index 979ea00ab69..a0aa0673fe5 100644 --- a/src/amd/vulkan/radv_descriptor_set.c +++ b/src/amd/vulkan/radv_descriptor_set.c @@ -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); -- 2.34.1