[Mesa-dev] [PATCH 03/14] vulkan/wsi: Rename needs_linear_copy to should_export

Daniel Stone daniels at collabora.com
Fri Jul 21 13:42:06 UTC 2017


The only use for this boolean was to decide whether or not it should
export a dmabuf FD. Simplify things a bit by giving that directly.

Signed-off-by: Daniel Stone <daniels at collabora.com>
---
 src/amd/vulkan/radv_wsi.c           |  6 ++++--
 src/intel/vulkan/anv_wsi.c          | 19 ++++++++++++-------
 src/vulkan/wsi/wsi_common.h         |  2 +-
 src/vulkan/wsi/wsi_common_wayland.c |  2 +-
 src/vulkan/wsi/wsi_common_x11.c     |  4 ++--
 5 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/src/amd/vulkan/radv_wsi.c b/src/amd/vulkan/radv_wsi.c
index 293cccbe04..a29318f1ea 100644
--- a/src/amd/vulkan/radv_wsi.c
+++ b/src/amd/vulkan/radv_wsi.c
@@ -141,7 +141,7 @@ static VkResult
 radv_wsi_image_create(VkDevice device_h,
 		      const VkSwapchainCreateInfoKHR *pCreateInfo,
 		      const VkAllocationCallbacks* pAllocator,
-		      bool needs_linear_copy,
+		      bool should_export,
 		      bool linear,
 		      struct wsi_image_base *wsi_image)
 {
@@ -206,12 +206,14 @@ radv_wsi_image_create(VkDevice device_h,
 	 * 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)) {
+	if (should_export) {
 		RADV_FROM_HANDLE(radv_device, device, device_h);
 		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;
+	} else {
+		wsi_image->fd = -1;
 	}
 
 	surface = &image->surface;
diff --git a/src/intel/vulkan/anv_wsi.c b/src/intel/vulkan/anv_wsi.c
index d2c6307376..9df9c61c5a 100644
--- a/src/intel/vulkan/anv_wsi.c
+++ b/src/intel/vulkan/anv_wsi.c
@@ -172,7 +172,7 @@ static VkResult
 anv_wsi_image_create(VkDevice device_h,
                      const VkSwapchainCreateInfoKHR *pCreateInfo,
                      const VkAllocationCallbacks* pAllocator,
-                     bool different_gpu,
+                     bool should_export,
                      bool linear,
                      struct wsi_image_base *wsi_image)
 {
@@ -248,12 +248,17 @@ anv_wsi_image_create(VkDevice device_h,
       goto fail_alloc_memory;
    }
 
-   int fd = anv_gem_handle_to_fd(device, memory->bo->gem_handle);
-   if (fd == -1) {
-      /* FINISHME: Choose a better error. */
-      result = vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY,
-                         "handle_to_fd failed: %m");
-      goto fail_alloc_memory;
+   int fd;
+   if (should_export) {
+      fd = anv_gem_handle_to_fd(device, memory->bo->gem_handle);
+      if (fd == -1) {
+         /* FINISHME: Choose a better error. */
+         result = vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY,
+                            "handle_to_fd failed: %m");
+         goto fail_alloc_memory;
+      }
+   } else {
+      fd = -1;
    }
 
    wsi_image->image = image_h;
diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h
index 2a9092479d..1103703b0e 100644
--- a/src/vulkan/wsi/wsi_common.h
+++ b/src/vulkan/wsi/wsi_common.h
@@ -44,7 +44,7 @@ struct wsi_image_fns {
    VkResult (*create_wsi_image)(VkDevice device_h,
                                 const VkSwapchainCreateInfoKHR *pCreateInfo,
                                 const VkAllocationCallbacks *pAllocator,
-                                bool needs_linear_copy,
+                                bool should_export,
                                 bool linear,
                                 struct wsi_image_base *image_p);
    void (*free_wsi_image)(VkDevice device,
diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c
index 3e94034077..8ff57522bb 100644
--- a/src/vulkan/wsi/wsi_common_wayland.c
+++ b/src/vulkan/wsi/wsi_common_wayland.c
@@ -697,7 +697,7 @@ wsi_wl_image_init(struct wsi_wl_swapchain *chain,
    result = chain->base.image_fns->create_wsi_image(vk_device,
                                                     pCreateInfo,
                                                     pAllocator,
-                                                    false,
+                                                    true,
                                                     false,
                                                     &image->base);
    if (result != VK_SUCCESS)
diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c
index 580a200d73..997255913c 100644
--- a/src/vulkan/wsi/wsi_common_x11.c
+++ b/src/vulkan/wsi/wsi_common_x11.c
@@ -962,7 +962,7 @@ 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,
+                                                    !chain->base.needs_linear_copy,
                                                     false,
                                                     &image->base);
    if (result != VK_SUCCESS)
@@ -972,7 +972,7 @@ 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,
+                                                       true,
                                                        true,
                                                        &image->linear_base);
 
-- 
2.13.2



More information about the mesa-dev mailing list