vulkan/wsi: Add multiple planes to wsi_image
authorDaniel Stone <daniels@collabora.com>
Fri, 9 Feb 2018 23:43:25 +0000 (15:43 -0800)
committerDaniel Stone <daniels@collabora.com>
Wed, 21 Feb 2018 22:37:10 +0000 (22:37 +0000)
Not currently used.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/vulkan/wsi/wsi_common.c
src/vulkan/wsi/wsi_common_private.h
src/vulkan/wsi/wsi_common_wayland.c
src/vulkan/wsi/wsi_common_x11.c

index 90ed07b7857a8dd331a0e95899ad572190eaeeda..f257eb08755c1d68ee09ba8b8aac998fde08b942 100644 (file)
@@ -201,6 +201,8 @@ wsi_create_native_image(const struct wsi_swapchain *chain,
    VkResult result;
 
    memset(image, 0, sizeof(*image));
+   for (int i = 0; i < ARRAY_SIZE(image->fds); i++)
+      image->fds[i] = -1;
 
    const struct wsi_image_create_info image_wsi_info = {
       .sType = VK_STRUCTURE_TYPE_WSI_IMAGE_CREATE_INFO_MESA,
@@ -289,10 +291,11 @@ wsi_create_native_image(const struct wsi_swapchain *chain,
    if (result != VK_SUCCESS)
       goto fail;
 
-   image->size = reqs.size;
-   image->row_pitch = image_layout.rowPitch;
-   image->offset = 0;
-   image->fd = fd;
+   image->num_planes = 1;
+   image->sizes[0] = reqs.size;
+   image->row_pitches[0] = image_layout.rowPitch;
+   image->offsets[0] = 0;
+   image->fds[0] = fd;
 
    return VK_SUCCESS;
 
@@ -491,10 +494,11 @@ wsi_create_prime_image(const struct wsi_swapchain *chain,
    if (result != VK_SUCCESS)
       goto fail;
 
-   image->size = linear_size;
-   image->row_pitch = linear_stride;
-   image->offset = 0;
-   image->fd = fd;
+   image->num_planes = 1;
+   image->sizes[0] = linear_size;
+   image->row_pitches[0] = linear_stride;
+   image->offsets[0] = 0;
+   image->fds[0] = fd;
 
    return VK_SUCCESS;
 
index 503b2a015dc696517991f4467b2233fb20ebde33..c5002ec8ecaab6d4b5ed6d77fa4e48db9e84b1b4 100644 (file)
@@ -35,10 +35,11 @@ struct wsi_image {
       VkCommandBuffer *blit_cmd_buffers;
    } prime;
 
-   uint32_t size;
-   uint32_t offset;
-   uint32_t row_pitch;
-   int fd;
+   int num_planes;
+   uint32_t sizes[4];
+   uint32_t offsets[4];
+   uint32_t row_pitches[4];
+   int fds[4];
 };
 
 struct wsi_swapchain {
index be7635bbf843c5f8b1819a40676efa602e7fd0cf..8290170c9ec38b232559b81125aea769f936864f 100644 (file)
@@ -712,15 +712,18 @@ wsi_wl_image_init(struct wsi_wl_swapchain *chain,
    if (result != VK_SUCCESS)
       return result;
 
+   /* Without passing modifiers, we can't have multi-plane RGB images. */
+   assert(image->base.num_planes == 1);
+
    image->buffer = wl_drm_create_prime_buffer(chain->drm_wrapper,
-                                              image->base.fd, /* name */
+                                              image->base.fds[0], /* name */
                                               chain->extent.width,
                                               chain->extent.height,
                                               chain->drm_format,
-                                              image->base.offset,
-                                              image->base.row_pitch,
+                                              image->base.offsets[0],
+                                              image->base.row_pitches[0],
                                               0, 0, 0, 0 /* unused */);
-   close(image->base.fd);
+   close(image->base.fds[0]);
 
    if (!image->buffer)
       goto fail_image;
index c29e0a2d30d2efc80529f744e9edd9f9c16cecdf..b42b8234064c1aff81999c0d66dc530dd26428a4 100644 (file)
@@ -936,18 +936,21 @@ x11_image_init(VkDevice device_h, struct x11_swapchain *chain,
 
    image->pixmap = xcb_generate_id(chain->conn);
 
+   /* Without passing modifiers, we can't have multi-plane RGB images. */
+   assert(image->base.num_planes == 1);
+
    cookie =
       xcb_dri3_pixmap_from_buffer_checked(chain->conn,
                                           image->pixmap,
                                           chain->window,
-                                          image->base.size,
+                                          image->base.sizes[0],
                                           pCreateInfo->imageExtent.width,
                                           pCreateInfo->imageExtent.height,
-                                          image->base.row_pitch,
+                                          image->base.row_pitches[0],
                                           chain->depth, bpp,
-                                          image->base.fd);
+                                          image->base.fds[0]);
    xcb_discard_reply(chain->conn, cookie.sequence);
-   image->base.fd = -1; /* XCB has now taken ownership of the FD */
+   image->base.fds[0] = -1; /* XCB has now taken ownership of the FD */
 
    int fence_fd = xshmfence_alloc_shm();
    if (fence_fd < 0)