vulkan/overlay: Fix violation of VUID-VkMappedMemoryRange-size-01389
authorPavel Asyutchenko <sventeam@yandex.ru>
Sun, 25 Jul 2021 17:11:16 +0000 (20:11 +0300)
committerMarge Bot <eric+marge@anholt.net>
Fri, 30 Jul 2021 11:38:40 +0000 (11:38 +0000)
Mapping lentgh must be a multiple of 'nonCoherentAtomSize' bytes
when using VK_WHOLE_SIZE in vkFlushMappedMemoryRanges.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12131>

src/vulkan/overlay-layer/overlay.cpp

index fb0f529..270dd9b 100644 (file)
@@ -41,6 +41,7 @@
 #include "util/os_time.h"
 #include "util/os_socket.h"
 #include "util/simple_mtx.h"
+#include "util/u_math.h"
 
 #include "vk_enum_to_str.h"
 #include "vk_dispatch_table.h"
@@ -1217,8 +1218,8 @@ static struct overlay_draw *render_swapchain_display(struct swapchain_data *data
                                           VK_SUBPASS_CONTENTS_INLINE);
 
    /* Create/Resize vertex & index buffers */
-   size_t vertex_size = draw_data->TotalVtxCount * sizeof(ImDrawVert);
-   size_t index_size = draw_data->TotalIdxCount * sizeof(ImDrawIdx);
+   size_t vertex_size = ALIGN(draw_data->TotalVtxCount * sizeof(ImDrawVert), device_data->properties.limits.nonCoherentAtomSize);
+   size_t index_size = ALIGN(draw_data->TotalIdxCount * sizeof(ImDrawIdx), device_data->properties.limits.nonCoherentAtomSize);
    if (draw->vertex_buffer_size < vertex_size) {
       CreateOrResizeBuffer(device_data,
                            &draw->vertex_buffer,