From 211ffe02a21c470db52ac14b706edda46bdff4ab Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Tue, 13 Jul 2021 15:38:16 +0200 Subject: [PATCH] vulkan: do not map zero-sized region of memory The Vulkan 1.2 specification, section 11.2.12 ("Host Access to Device Memory Objects") say the following: > If size is not equal to VK_WHOLE_SIZE, size must be greater than 0 So, mapping a zero-sized range is illegal. Let's instead map the reported size of the image, which we already know. Fixes: 8af568e4ae7 ("vulkan: implement wsi_win32 backend") Reviewed-by: Jason Ekstrand Part-of: (cherry picked from commit d0c7a2106bbea28dbdcc22437340589a17ae3ff7) --- .pick_status.json | 2 +- src/vulkan/wsi/wsi_common_win32.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 93b8854b278..8d4c1b5ef28 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -265,7 +265,7 @@ "description": "vulkan: do not map zero-sized region of memory", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "8af568e4ae77332e1cc09031301e559996b81fe9" }, diff --git a/src/vulkan/wsi/wsi_common_win32.c b/src/vulkan/wsi/wsi_common_win32.c index fa6f898e590..824cd6b4253 100644 --- a/src/vulkan/wsi/wsi_common_win32.c +++ b/src/vulkan/wsi/wsi_common_win32.c @@ -534,7 +534,7 @@ wsi_win32_queue_present(struct wsi_swapchain *drv_chain, char *dptr = image->ppvBits; result = chain->base.wsi->MapMemory(chain->base.device, image->base.memory, - 0, 0, 0, (void**)&ptr); + 0, image->base.sizes[0], 0, (void**)&ptr); for (unsigned h = 0; h < chain->extent.height; h++) { memcpy(dptr, ptr, chain->extent.width * 4);