[Mesa-dev] [RFC v5 10/19] vulkan/wsi: Rename needs_linear_copy to should_export
Louis-Francis Ratté-Boulianne
lfrb at collabora.com
Mon Nov 6 22:02:40 UTC 2017
From: Daniel Stone <daniels at collabora.com>
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 | 21 +++++++++++++--------
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, 21 insertions(+), 14 deletions(-)
diff --git a/src/amd/vulkan/radv_wsi.c b/src/amd/vulkan/radv_wsi.c
index 2562d38e23..b24cf28d42 100644
--- a/src/amd/vulkan/radv_wsi.c
+++ b/src/amd/vulkan/radv_wsi.c
@@ -142,7 +142,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)
{
@@ -209,11 +209,13 @@ 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_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 d520d8e3f4..916c62cad9 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)
{
@@ -250,13 +250,18 @@ 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(device->instance, device,
- 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(device->instance, device,
+ 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 495e7068b4..36cc4d0821 100644
--- a/src/vulkan/wsi/wsi_common_wayland.c
+++ b/src/vulkan/wsi/wsi_common_wayland.c
@@ -730,7 +730,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 94578b438b..78fd406aa1 100644
--- a/src/vulkan/wsi/wsi_common_x11.c
+++ b/src/vulkan/wsi/wsi_common_x11.c
@@ -963,7 +963,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)
@@ -973,7 +973,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.0
More information about the mesa-dev
mailing list