Mesa (main): vulkan/wsi: unbreak win32-support

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon May 16 19:25:56 UTC 2022


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

Author: Erik Faye-Lund <erik.faye-lund at collabora.com>
Date:   Mon May 16 09:50:26 2022 +0200

vulkan/wsi: unbreak win32-support

There's no unistd.h on Windows, let's not include it unconditionally.

But we also don't want to deal with DRM modifiers or DMABUFs on Windows,
so let's also ifdef out the rest of that stuff.

Fixes: a8b009aed6b ("vulkan/wsi: fix missing unistd include")
Fixes: c72ff19a9ef ("vulkan/wsi: Close file descriptors in wsi_destroy_image")

Reviewed-By: Yonggang Luo <luoyonggang at gmail.com>
Acked-by: Boris Brezillon <boris.brezillon at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16373>

---

 src/vulkan/wsi/wsi_common.c         | 8 ++++++++
 src/vulkan/wsi/wsi_common_private.h | 4 ++++
 2 files changed, 12 insertions(+)

diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c
index dd193d83601..0b48f16a0b2 100644
--- a/src/vulkan/wsi/wsi_common.c
+++ b/src/vulkan/wsi/wsi_common.c
@@ -38,7 +38,10 @@
 #include <time.h>
 #include <stdlib.h>
 #include <stdio.h>
+
+#ifndef _WIN32
 #include <unistd.h>
+#endif
 
 VkResult
 wsi_device_init(struct wsi_device *wsi,
@@ -477,7 +480,10 @@ wsi_create_image(const struct wsi_swapchain *chain,
    VkResult result;
 
    memset(image, 0, sizeof(*image));
+
+#ifndef _WIN32
    image->dma_buf_fd = -1;
+#endif
 
    result = wsi->CreateImage(chain->device, &info->create,
                              &chain->alloc, &image->image);
@@ -512,8 +518,10 @@ wsi_destroy_image(const struct wsi_swapchain *chain,
 {
    const struct wsi_device *wsi = chain->wsi;
 
+#ifndef _WIN32
    if (image->dma_buf_fd >= 0)
       close(image->dma_buf_fd);
+#endif
 
    if (image->buffer.blit_cmd_buffers) {
       for (uint32_t i = 0; i < wsi->queue_family_count; i++) {
diff --git a/src/vulkan/wsi/wsi_common_private.h b/src/vulkan/wsi/wsi_common_private.h
index ae0b196b3aa..b5198d45b0b 100644
--- a/src/vulkan/wsi/wsi_common_private.h
+++ b/src/vulkan/wsi/wsi_common_private.h
@@ -74,12 +74,16 @@ struct wsi_image {
       VkCommandBuffer *blit_cmd_buffers;
    } buffer;
 
+#ifndef _WIN32
    uint64_t drm_modifier;
+#endif
    int num_planes;
    uint32_t sizes[4];
    uint32_t offsets[4];
    uint32_t row_pitches[4];
+#ifndef _WIN32
    int dma_buf_fd;
+#endif
 };
 
 struct wsi_swapchain {



More information about the mesa-commit mailing list