[Mesa-dev] [PATCH 3/3] RFC: vulkan/wsi: Rework the way prime support works

Jason Ekstrand jason at jlekstrand.net
Tue Nov 14 18:40:16 UTC 2017


This commit significantly reworks the way prime support works and lets
us pull it even further into radv.  The old mechanism required the
specific WSI layer to be aware of the linear shadow copy that has to be
done in order for prime to work.  In the new paradigm, we better define
what bits of wsi_image go to the client and what bits go off to the
window system.  It's then the job of the driver to allocate two separate
images and stash whatever intermediates it needs in driver_private.
There are a few advantages to this method:

 1) It separates supporting prime from the driver decision as to whether
    it's better to render directly into the window-system-compatible
    image or if it's better to blit.

 2) Because of this separation, it's now possible for a driver to use a
    different scheme for WSI image presentation where it hooks the
    vkCmdPipelineBarrier that transitions the image to
    VK_IMAGE_LAYOUT_PRESENT_SRC_KHR and does the blit there.

 3) It lets us pull more of the details into radv and, in my opinion,
    actually makes the radv code more straightforward.

 4) It means that adding prime support to another window system (most
    likely Wayland) is as simple as detecting the GPU difference and
    passing that information on to the driver.  The individual WSI layer
    doesn't have to worry about creating and tracking shadow images.

This patch is compile-tested only.

Cc: Dave Airlie <airlied at redhat.com>
Cc: Daniel Stone <daniels at collabora.com>
---
 src/amd/vulkan/radv_wsi.c           | 307 +++++++++++++++++++++---------------
 src/intel/vulkan/anv_wsi.c          |   1 -
 src/vulkan/wsi/wsi_common.h         |  16 +-
 src/vulkan/wsi/wsi_common_wayland.c |   3 +-
 src/vulkan/wsi/wsi_common_x11.c     |  51 ++----
 5 files changed, 199 insertions(+), 179 deletions(-)

diff --git a/src/amd/vulkan/radv_wsi.c b/src/amd/vulkan/radv_wsi.c
index f729ffb..7a9064b 100644
--- a/src/amd/vulkan/radv_wsi.c
+++ b/src/amd/vulkan/radv_wsi.c
@@ -139,18 +139,16 @@ VkResult radv_GetPhysicalDeviceSurfacePresentModesKHR(
 }
 
 static VkResult
-radv_wsi_image_create(VkDevice device_h,
-		      const VkSwapchainCreateInfoKHR *pCreateInfo,
-		      const VkAllocationCallbacks* pAllocator,
-		      bool needs_linear_copy,
-		      bool linear,
-		      struct wsi_image *wsi_image)
+radv_wsi_image_create_common(VkDevice device_h,
+			     const VkSwapchainCreateInfoKHR *pCreateInfo,
+			     const VkAllocationCallbacks* pAllocator,
+			     bool linear,
+			     VkImage *image_p,
+			     VkDeviceMemory *memory_p)
 {
 	VkResult result = VK_SUCCESS;
-	struct radeon_surf *surface;
 	VkImage image_h;
 	struct radv_image *image;
-	int fd;
 	RADV_FROM_HANDLE(radv_device, device, device_h);
 
 	result = radv_image_create(device_h,
@@ -214,148 +212,212 @@ radv_wsi_image_create(VkDevice device_h,
 				     NULL /* XXX: pAllocator */,
 				     RADV_MEM_IMPLICIT_SYNC,
 				     &memory_h);
-	if (result != VK_SUCCESS)
-		goto fail_create_image;
+	if (result != VK_SUCCESS) {
+		radv_DestroyImage(device_h, image_h, pAllocator);
+		return result;
+	}
 
 	radv_BindImageMemory(device_h, image_h, memory_h, 0);
 
-	/*
-	 * return the fd for the image in the no copy mode,
-	 * or the fd for the linear image if a copy is required.
-	 */
-	if (!needs_linear_copy || (needs_linear_copy && linear)) {
-		RADV_FROM_HANDLE(radv_device_memory, memory, memory_h);
-		if (!radv_get_memory_fd(device, memory, &fd))
-			goto fail_alloc_memory;
-		wsi_image->fd = fd;
+	*image_p = image_h;
+	*memory_p = memory_h;
+
+	return VK_SUCCESS;
+}
+
+static VkResult
+radv_wsi_create_blit_cmd_buffer(VkDevice device_h,
+				VkImage client_image_h,
+				VkImage wsi_image_h,
+				uint32_t queue_family_index,
+				VkCommandPool *cmd_pool_p,
+				VkCommandBuffer *cmd_buffer_p,
+				const VkAllocationCallbacks* pAllocator)
+{
+	VkResult result = VK_SUCCESS;
+	VkCommandPool cmd_pool_h;
+	VkCommandBuffer cmd_buffer_h;
+
+	VkCommandPoolCreateInfo pool_create_info;
+	pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
+	pool_create_info.pNext = NULL;
+	pool_create_info.flags = 0;
+	pool_create_info.queueFamilyIndex = queue_family_index;
+
+	result = radv_CreateCommandPool(device_h,
+					&pool_create_info,
+					pAllocator,
+					&cmd_pool_h);
+	if (result != VK_SUCCESS)
+		return result;
+
+	VkCommandBufferAllocateInfo cmd_buffer_info;
+	cmd_buffer_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
+	cmd_buffer_info.pNext = NULL;
+	cmd_buffer_info.commandPool = cmd_pool_h;
+	cmd_buffer_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
+	cmd_buffer_info.commandBufferCount = 1;
+
+	result = radv_AllocateCommandBuffers(device_h,
+					     &cmd_buffer_info,
+					     &cmd_buffer_h);
+	if (result != VK_SUCCESS) {
+		radv_DestroyCommandPool(device_h, cmd_pool_h, pAllocator);
+		return result;
 	}
 
-	surface = &image->surface;
+	VkCommandBufferBeginInfo begin_info = {0};
+	begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
 
-	wsi_image->image = image_h;
-	wsi_image->driver_private = memory_h;
-	wsi_image->size = image->size;
-	wsi_image->offset = image->offset;
-	if (device->physical_device->rad_info.chip_class >= GFX9)
-		wsi_image->row_pitch =
-			surface->u.gfx9.surf_pitch * surface->bpe;
-	else
-		wsi_image->row_pitch =
-			surface->u.legacy.level[0].nblk_x * surface->bpe;
+	radv_BeginCommandBuffer(cmd_buffer_h, &begin_info);
 
-	return VK_SUCCESS;
- fail_alloc_memory:
-	radv_FreeMemory(device_h, memory_h, pAllocator);
+	radv_blit_to_prime_linear(radv_cmd_buffer_from_handle(cmd_buffer_h),
+				  radv_image_from_handle(client_image_h),
+				  radv_image_from_handle(wsi_image_h));
 
-fail_create_image:
-	radv_DestroyImage(device_h, image_h, pAllocator);
+	radv_EndCommandBuffer(cmd_buffer_h);
 
-	return result;
+	*cmd_pool_p = cmd_pool_h;
+	*cmd_buffer_p = cmd_buffer_h;
+
+	return VK_SUCCESS;
 }
 
-static void
-radv_wsi_image_free(VkDevice device,
-		    const VkAllocationCallbacks* pAllocator,
-		    struct wsi_image *wsi_image)
-{
-	radv_DestroyImage(device, wsi_image->image, pAllocator);
+struct radv_wsi_image_private {
+	VkDeviceMemory client_memory_h;
 
-	radv_FreeMemory(device, wsi_image->driver_private, pAllocator);
-}
+	/* If non-NULL, this is the linear image passed off to the window
+	 * system and its memory
+	 */
+	VkImage wsi_image_h;
+	VkDeviceMemory wsi_memory_h;
 
-static const struct wsi_image_fns radv_wsi_image_fns = {
-   .create_wsi_image = radv_wsi_image_create,
-   .free_wsi_image = radv_wsi_image_free,
+	VkCommandPool blit_cmd_pools[RADV_MAX_QUEUE_FAMILIES];
+	VkCommandBuffer blit_cmd_buffers[RADV_MAX_QUEUE_FAMILIES];
 };
 
-#define NUM_PRIME_POOLS RADV_QUEUE_TRANSFER
 static void
-radv_wsi_free_prime_command_buffers(struct radv_device *device,
-				    struct wsi_swapchain *swapchain)
+radv_wsi_image_private_free(VkDevice device_h,
+			    struct radv_wsi_image_private *private,
+			    const VkAllocationCallbacks* pAllocator)
 {
-	const int num_pools = NUM_PRIME_POOLS;
-	const int num_images = swapchain->image_count;
-	int i;
-	for (i = 0; i < num_pools; i++) {
-		radv_FreeCommandBuffers(radv_device_to_handle(device),
-				     swapchain->cmd_pools[i],
-				     swapchain->image_count,
-				     &swapchain->cmd_buffers[i * num_images]);
-
-		radv_DestroyCommandPool(radv_device_to_handle(device),
-				     swapchain->cmd_pools[i],
-				     &swapchain->alloc);
+	RADV_FROM_HANDLE(radv_device, device, device_h);
+
+	radv_FreeMemory(device_h, private->client_memory_h, pAllocator);
+	radv_DestroyImage(device_h, private->wsi_image_h, pAllocator);
+	radv_FreeMemory(device_h, private->wsi_memory_h, pAllocator);
+
+	/* This will automatically free the command buffer */
+	for (uint32_t q = 0; q < RADV_MAX_QUEUE_FAMILIES; q++) {
+		radv_DestroyCommandPool(device_h, private->blit_cmd_pools[q],
+					pAllocator);
 	}
+
+	vk_free2(&device->alloc, pAllocator, private);
 }
 
+
 static VkResult
-radv_wsi_create_prime_command_buffers(struct radv_device *device,
-				      const VkAllocationCallbacks *alloc,
-				      struct wsi_swapchain *swapchain)
+radv_wsi_image_create(VkDevice device_h,
+		      const VkSwapchainCreateInfoKHR *pCreateInfo,
+		      const VkAllocationCallbacks* pAllocator,
+		      bool different_gpu,
+		      struct wsi_image *wsi_image)
 {
-	const int num_pools = NUM_PRIME_POOLS;
-	const int num_images = swapchain->image_count;
-	int num_cmd_buffers = num_images * num_pools; //TODO bump to MAX_QUEUE_FAMILIES
-	VkResult result;
-	int i, j;
+	VkResult result = VK_SUCCESS;
+	VkImage client_image_h = VK_NULL_HANDLE;
+	struct radeon_surf *surface;
+	struct radv_image *image;
+	struct radv_device_memory *memory;
+	int fd;
+	RADV_FROM_HANDLE(radv_device, device, device_h);
 
-	swapchain->cmd_buffers = vk_alloc(alloc, (sizeof(VkCommandBuffer) * num_cmd_buffers), 8,
-					  VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
-	if (!swapchain->cmd_buffers)
+	struct radv_wsi_image_private *private =
+		vk_zalloc2(&device->alloc, pAllocator,
+			   sizeof(struct radv_wsi_image_private), 8,
+			   VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
+	if (!private)
 		return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
 
-	memset(swapchain->cmd_buffers, 0, sizeof(VkCommandBuffer) * num_cmd_buffers);
-	memset(swapchain->cmd_pools, 0, sizeof(VkCommandPool) * num_pools);
-	for (i = 0; i < num_pools; i++) {
-		VkCommandPoolCreateInfo pool_create_info;
-
-		pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
-		pool_create_info.pNext = NULL;
-		pool_create_info.flags = 0;
-		pool_create_info.queueFamilyIndex = i;
-
-		result = radv_CreateCommandPool(radv_device_to_handle(device),
-						&pool_create_info, alloc,
-						&swapchain->cmd_pools[i]);
-		if (result != VK_SUCCESS)
-			goto fail;
-
-		VkCommandBufferAllocateInfo cmd_buffer_info;
-		cmd_buffer_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
-		cmd_buffer_info.pNext = NULL;
-		cmd_buffer_info.commandPool = swapchain->cmd_pools[i];
-		cmd_buffer_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
-		cmd_buffer_info.commandBufferCount = num_images;
-
-		result = radv_AllocateCommandBuffers(radv_device_to_handle(device),
-						     &cmd_buffer_info,
-						     &swapchain->cmd_buffers[i * num_images]);
+	result = radv_wsi_image_create_common(device_h,
+					      pCreateInfo,
+					      pAllocator,
+					      false,
+					      &client_image_h,
+					      &private->client_memory_h);
+	if (result != VK_SUCCESS)
+		goto fail;
+	image = radv_image_from_handle(client_image_h);
+	memory = radv_device_memory_from_handle(private->client_memory_h);
+
+	if (different_gpu) {
+		result = radv_wsi_image_create_common(device_h,
+						      pCreateInfo,
+						      pAllocator,
+						      true,
+						      &private->wsi_image_h,
+						      &private->wsi_memory_h);
 		if (result != VK_SUCCESS)
 			goto fail;
-		for (j = 0; j < num_images; j++) {
-			VkImage image, linear_image;
-			int idx = (i * num_images) + j;
-
-			swapchain->get_image_and_linear(swapchain, j, &image, &linear_image);
-			VkCommandBufferBeginInfo begin_info = {0};
+		image = radv_image_from_handle(private->wsi_image_h);
+		memory = radv_device_memory_from_handle(private->wsi_memory_h);
+
+		for (uint32_t q = 0; q < RADV_MAX_QUEUE_FAMILIES; q++) {
+			result = radv_wsi_create_blit_cmd_buffer(device_h,
+								 client_image_h,
+								 private->wsi_image_h,
+								 q,
+								 &private->blit_cmd_pools[q],
+								 &private->blit_cmd_buffers[q],
+								 pAllocator);
+			if (result != VK_SUCCESS)
+				goto fail;
+		}
+	}
 
-			begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
+	if (!radv_get_memory_fd(device, memory, &fd)) {
+		result = vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
+		goto fail;
+	}
 
-			radv_BeginCommandBuffer(swapchain->cmd_buffers[idx], &begin_info);
+	surface = &image->surface;
 
-			radv_blit_to_prime_linear(radv_cmd_buffer_from_handle(swapchain->cmd_buffers[idx]),
-						  radv_image_from_handle(image),
-						  radv_image_from_handle(linear_image));
+	wsi_image->driver_private = private;
+	wsi_image->image = client_image_h;
+	wsi_image->size = image->size;
+	wsi_image->offset = image->offset;
+	if (device->physical_device->rad_info.chip_class >= GFX9)
+		wsi_image->row_pitch =
+			surface->u.gfx9.surf_pitch * surface->bpe;
+	else
+		wsi_image->row_pitch =
+			surface->u.legacy.level[0].nblk_x * surface->bpe;
+	wsi_image->fd = fd;
 
-			radv_EndCommandBuffer(swapchain->cmd_buffers[idx]);
-		}
-	}
 	return VK_SUCCESS;
+
 fail:
-	radv_wsi_free_prime_command_buffers(device, swapchain);
+	radv_DestroyImage(device_h, client_image_h, pAllocator);
+	radv_wsi_image_private_free(device_h, private, pAllocator);
+
 	return result;
 }
 
+static void
+radv_wsi_image_free(VkDevice device_h,
+		    const VkAllocationCallbacks* pAllocator,
+		    struct wsi_image *wsi_image)
+{
+	radv_DestroyImage(device_h, wsi_image->image, pAllocator);
+	radv_wsi_image_private_free(device_h, wsi_image->driver_private,
+				    pAllocator);
+}
+
+static const struct wsi_image_fns radv_wsi_image_fns = {
+   .create_wsi_image = radv_wsi_image_create,
+   .free_wsi_image = radv_wsi_image_free,
+};
+
 VkResult radv_CreateSwapchainKHR(
 	VkDevice                                     _device,
 	const VkSwapchainCreateInfoKHR*              pCreateInfo,
@@ -389,13 +451,6 @@ VkResult radv_CreateSwapchainKHR(
 	for (unsigned i = 0; i < ARRAY_SIZE(swapchain->fences); i++)
 		swapchain->fences[i] = VK_NULL_HANDLE;
 
-	if (swapchain->needs_linear_copy) {
-		result = radv_wsi_create_prime_command_buffers(device, alloc,
-							       swapchain);
-		if (result != VK_SUCCESS)
-			return result;
-	}
-
 	*pSwapchain = wsi_swapchain_to_handle(swapchain);
 
 	return VK_SUCCESS;
@@ -423,9 +478,6 @@ void radv_DestroySwapchainKHR(
 			radv_DestroyFence(_device, swapchain->fences[i], pAllocator);
 	}
 
-	if (swapchain->needs_linear_copy)
-		radv_wsi_free_prime_command_buffers(device, swapchain);
-
 	swapchain->destroy(swapchain, alloc);
 }
 
@@ -510,9 +562,10 @@ VkResult radv_QueuePresentKHR(
 					 1, &swapchain->fences[0]);
 		}
 
-		if (swapchain->needs_linear_copy) {
-			int idx = (queue->queue_family_index * swapchain->image_count) + pPresentInfo->pImageIndices[i];
-			cs = radv_cmd_buffer_from_handle(swapchain->cmd_buffers[idx])->cs;
+		if (swapchain->different_gpu) {
+			struct wsi_image *wsi_image = swapchain->get_wsi_image(swapchain, pPresentInfo->pImageIndices[i]);
+			struct radv_wsi_image_private *private = wsi_image->driver_private;
+			cs = radv_cmd_buffer_from_handle(private->blit_cmd_buffers[queue->queue_family_index])->cs;
 		} else
 			cs = queue->device->empty_cs[queue->queue_family_index];
 		RADV_FROM_HANDLE(radv_fence, fence, swapchain->fences[0]);
diff --git a/src/intel/vulkan/anv_wsi.c b/src/intel/vulkan/anv_wsi.c
index 154263f..363f70f 100644
--- a/src/intel/vulkan/anv_wsi.c
+++ b/src/intel/vulkan/anv_wsi.c
@@ -173,7 +173,6 @@ anv_wsi_image_create(VkDevice device_h,
                      const VkSwapchainCreateInfoKHR *pCreateInfo,
                      const VkAllocationCallbacks* pAllocator,
                      bool different_gpu,
-                     bool linear,
                      struct wsi_image *wsi_image)
 {
    struct anv_device *device = anv_device_from_handle(device_h);
diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h
index a6414ef..3fa2631 100644
--- a/src/vulkan/wsi/wsi_common.h
+++ b/src/vulkan/wsi/wsi_common.h
@@ -34,7 +34,10 @@ struct wsi_image {
    /* Private storage for the driver */
    void *driver_private;
 
+   /* Image to hand off to the client */
    VkImage image;
+
+   /* Image to hand off to window system */
    uint32_t size;
    uint32_t offset;
    uint32_t row_pitch;
@@ -46,8 +49,7 @@ struct wsi_image_fns {
    VkResult (*create_wsi_image)(VkDevice device_h,
                                 const VkSwapchainCreateInfoKHR *pCreateInfo,
                                 const VkAllocationCallbacks *pAllocator,
-                                bool needs_linear_copy,
-                                bool linear,
+                                bool different_gpu,
                                 struct wsi_image *image_p);
    void (*free_wsi_image)(VkDevice device,
                           const VkAllocationCallbacks *pAllocator,
@@ -60,11 +62,9 @@ struct wsi_swapchain {
    VkAllocationCallbacks alloc;
    const struct wsi_image_fns *image_fns;
    VkFence fences[3];
-   VkCommandBuffer *cmd_buffers;
-   VkCommandPool cmd_pools[3];
    VkPresentModeKHR present_mode;
    uint32_t image_count;
-   bool needs_linear_copy;
+   bool different_gpu;
 
    VkResult (*destroy)(struct wsi_swapchain *swapchain,
                        const VkAllocationCallbacks *pAllocator);
@@ -76,10 +76,8 @@ struct wsi_swapchain {
    VkResult (*queue_present)(struct wsi_swapchain *swap_chain,
                              uint32_t image_index,
                              const VkPresentRegionKHR *damage);
-   void (*get_image_and_linear)(struct wsi_swapchain *swapchain,
-                                int imageIndex,
-                                VkImage *image,
-                                VkImage *linear_image);
+   struct wsi_image * (*get_wsi_image)(struct wsi_swapchain *swapchain,
+                                       uint32_t imageIndex);
 };
 
 struct wsi_interface {
diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c
index 5e65855..60e72fb 100644
--- a/src/vulkan/wsi/wsi_common_wayland.c
+++ b/src/vulkan/wsi/wsi_common_wayland.c
@@ -731,7 +731,6 @@ wsi_wl_image_init(struct wsi_wl_swapchain *chain,
                                                     pCreateInfo,
                                                     pAllocator,
                                                     false,
-                                                    false,
                                                     &image->base);
    if (result != VK_SUCCESS)
       return result;
@@ -834,7 +833,7 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
    chain->base.image_fns = image_fns;
    chain->base.present_mode = pCreateInfo->presentMode;
    chain->base.image_count = num_images;
-   chain->base.needs_linear_copy = false;
+   chain->base.different_gpu = false;
    chain->extent = pCreateInfo->imageExtent;
    chain->vk_format = pCreateInfo->imageFormat;
    chain->drm_format = wl_drm_format_for_vk_format(chain->vk_format, alpha);
diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c
index 22b894e..bc69c8c 100644
--- a/src/vulkan/wsi/wsi_common_x11.c
+++ b/src/vulkan/wsi/wsi_common_x11.c
@@ -616,7 +616,6 @@ VkResult wsi_create_xlib_surface(const VkAllocationCallbacks *pAllocator,
 
 struct x11_image {
    struct wsi_image                          base;
-   struct wsi_image                          linear_base;
    xcb_pixmap_t                              pixmap;
    bool                                      busy;
    struct xshmfence *                        shm_fence;
@@ -673,13 +672,11 @@ x11_get_images(struct wsi_swapchain *anv_chain,
    return result;
 }
 
-static void
-x11_get_image_and_linear(struct wsi_swapchain *drv_chain,
-                         int imageIndex, VkImage *image, VkImage *linear_image)
+static struct wsi_image *
+x11_get_wsi_image(struct wsi_swapchain *drv_chain, uint32_t imageIndex)
 {
    struct x11_swapchain *chain = (struct x11_swapchain *)drv_chain;
-   *image = chain->images[imageIndex].base.image;
-   *linear_image = chain->images[imageIndex].linear_base.image;
+   return &chain->images[imageIndex].base;
 }
 
 static VkResult
@@ -963,43 +960,25 @@ x11_image_init(VkDevice device_h, struct x11_swapchain *chain,
    result = chain->base.image_fns->create_wsi_image(device_h,
                                                     pCreateInfo,
                                                     pAllocator,
-                                                    chain->base.needs_linear_copy,
-                                                    false,
+                                                    chain->base.different_gpu,
                                                     &image->base);
    if (result != VK_SUCCESS)
       return result;
 
-   if (chain->base.needs_linear_copy) {
-      result = chain->base.image_fns->create_wsi_image(device_h,
-                                                       pCreateInfo,
-                                                       pAllocator,
-                                                       chain->base.needs_linear_copy,
-                                                       true,
-                                                       &image->linear_base);
-
-      if (result != VK_SUCCESS) {
-         chain->base.image_fns->free_wsi_image(device_h, pAllocator,
-                                               &image->base);
-         return result;
-      }
-   }
-
    image->pixmap = xcb_generate_id(chain->conn);
 
-   struct wsi_image *image_ws =
-      chain->base.needs_linear_copy ? &image->linear_base : &image->base;
    cookie =
       xcb_dri3_pixmap_from_buffer_checked(chain->conn,
                                           image->pixmap,
                                           chain->window,
-                                          image_ws->size,
+                                          image->base.size,
                                           pCreateInfo->imageExtent.width,
                                           pCreateInfo->imageExtent.height,
-                                          image_ws->row_pitch,
+                                          image->base.row_pitch,
                                           chain->depth, bpp,
-                                          image_ws->fd);
+                                          image->base.fd);
    xcb_discard_reply(chain->conn, cookie.sequence);
-   image_ws->fd = -1; /* XCB has now taken ownership of the FD */
+   image->base.fd = -1; /* XCB has now taken ownership of the FD */
 
    int fence_fd = xshmfence_alloc_shm();
    if (fence_fd < 0)
@@ -1028,10 +1007,6 @@ fail_pixmap:
    cookie = xcb_free_pixmap(chain->conn, image->pixmap);
    xcb_discard_reply(chain->conn, cookie.sequence);
 
-   if (chain->base.needs_linear_copy) {
-      chain->base.image_fns->free_wsi_image(device_h, pAllocator,
-                                            &image->linear_base);
-   }
    chain->base.image_fns->free_wsi_image(device_h, pAllocator, &image->base);
 
    return result;
@@ -1051,10 +1026,6 @@ x11_image_finish(struct x11_swapchain *chain,
    cookie = xcb_free_pixmap(chain->conn, image->pixmap);
    xcb_discard_reply(chain->conn, cookie.sequence);
 
-   if (chain->base.needs_linear_copy) {
-      chain->base.image_fns->free_wsi_image(chain->base.device, pAllocator,
-                                            &image->linear_base);
-   }
    chain->base.image_fns->free_wsi_image(chain->base.device, pAllocator,
                                          &image->base);
 }
@@ -1124,7 +1095,7 @@ x11_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
    chain->base.device = device;
    chain->base.destroy = x11_swapchain_destroy;
    chain->base.get_images = x11_get_images;
-   chain->base.get_image_and_linear = x11_get_image_and_linear;
+   chain->base.get_wsi_image = x11_get_wsi_image;
    chain->base.acquire_next_image = x11_acquire_next_image;
    chain->base.queue_present = x11_queue_present;
    chain->base.image_fns = image_fns;
@@ -1141,9 +1112,9 @@ x11_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
 
    free(geometry);
 
-   chain->base.needs_linear_copy = false;
+   chain->base.different_gpu = false;
    if (!wsi_x11_check_dri3_compatible(conn, local_fd))
-       chain->base.needs_linear_copy = true;
+       chain->base.different_gpu = true;
 
    chain->event_id = xcb_generate_id(chain->conn);
    xcb_present_select_input(chain->conn, chain->event_id, chain->window,
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list