Mesa (main): vulkan: do not map zero-sized region of memory

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jul 14 07:27:34 UTC 2021


Module: Mesa
Branch: main
Commit: d0c7a2106bbea28dbdcc22437340589a17ae3ff7
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=d0c7a2106bbea28dbdcc22437340589a17ae3ff7

Author: Erik Faye-Lund <erik.faye-lund at collabora.com>
Date:   Tue Jul 13 15:38:16 2021 +0200

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 <jason at jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11848>

---

 src/vulkan/wsi/wsi_common_win32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/vulkan/wsi/wsi_common_win32.c b/src/vulkan/wsi/wsi_common_win32.c
index 4368ad80a1b..1b21914acf2 100644
--- a/src/vulkan/wsi/wsi_common_win32.c
+++ b/src/vulkan/wsi/wsi_common_win32.c
@@ -538,7 +538,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);



More information about the mesa-commit mailing list