Re: [Mesa-dev] [PATCH v2 25/32] vulkan/wsi: move swapchain create/destroy to common code

2017-12-02 Thread Chad Versace
On Tue 28 Nov 2017, Jason Ekstrand wrote:
> From: Dave Airlie 
> 
> v2 (Jason Ekstrand):
>  - Rebase
>  - Alter the names of the helpers to better match the vulkan entrypoints
>  - Use the helpers in anv
> ---
>  src/amd/vulkan/radv_wsi.c   | 42 --
>  src/intel/vulkan/anv_wsi.c  | 35 +--
>  src/vulkan/wsi/wsi_common.c | 38 ++
>  src/vulkan/wsi/wsi_common.h | 12 
>  4 files changed, 63 insertions(+), 64 deletions(-)

> @@ -115,6 +115,9 @@ fail:
>  void
>  wsi_swapchain_finish(struct wsi_swapchain *chain)
>  {
> +   for (unsigned i = 0; i < ARRAY_SIZE(chain->fences); i++)
> +  chain->wsi->DestroyFence(chain->device, chain->fences[i], 
> >alloc);
> +

Yes. I've been waiting to see DestroyFence here since patch 17.

> for (uint32_t i = 0; i < chain->wsi->queue_family_count; i++) {
>chain->wsi->DestroyCommandPool(chain->device, chain->cmd_pools[i],
>   >alloc);
> @@ -485,6 +488,41 @@ wsi_destroy_image(const struct wsi_swapchain *chain,

Patch 25 is
Reviewed-by: Chad Versace 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2 25/32] vulkan/wsi: move swapchain create/destroy to common code

2017-11-28 Thread Jason Ekstrand
From: Dave Airlie 

v2 (Jason Ekstrand):
 - Rebase
 - Alter the names of the helpers to better match the vulkan entrypoints
 - Use the helpers in anv
---
 src/amd/vulkan/radv_wsi.c   | 42 --
 src/intel/vulkan/anv_wsi.c  | 35 +--
 src/vulkan/wsi/wsi_common.c | 38 ++
 src/vulkan/wsi/wsi_common.h | 12 
 4 files changed, 63 insertions(+), 64 deletions(-)

diff --git a/src/amd/vulkan/radv_wsi.c b/src/amd/vulkan/radv_wsi.c
index ed964c5..7791162 100644
--- a/src/amd/vulkan/radv_wsi.c
+++ b/src/amd/vulkan/radv_wsi.c
@@ -164,60 +164,34 @@ VkResult radv_CreateSwapchainKHR(
VkSwapchainKHR*  pSwapchain)
 {
RADV_FROM_HANDLE(radv_device, device, _device);
-   ICD_FROM_HANDLE(VkIcdSurfaceBase, surface, pCreateInfo->surface);
-   struct wsi_interface *iface =
-   device->physical_device->wsi_device.wsi[surface->platform];
-   struct wsi_swapchain *swapchain;
const VkAllocationCallbacks *alloc;
if (pAllocator)
alloc = pAllocator;
else
alloc = >alloc;
-   VkResult result = iface->create_swapchain(surface, _device,
- 
>physical_device->wsi_device,
- 
device->physical_device->local_fd,
- pCreateInfo,
- alloc,
- );
-   if (result != VK_SUCCESS)
-   return result;
-
-   if (pAllocator)
-   swapchain->alloc = *pAllocator;
-   else
-   swapchain->alloc = device->alloc;
-
-   for (unsigned i = 0; i < ARRAY_SIZE(swapchain->fences); i++)
-   swapchain->fences[i] = VK_NULL_HANDLE;
-
-   *pSwapchain = wsi_swapchain_to_handle(swapchain);
 
-   return VK_SUCCESS;
+   return wsi_common_create_swapchain(>physical_device->wsi_device,
+  radv_device_to_handle(device),
+  device->physical_device->local_fd,
+  pCreateInfo,
+  alloc,
+  pSwapchain);
 }
 
 void radv_DestroySwapchainKHR(
VkDevice _device,
-   VkSwapchainKHR   _swapchain,
+   VkSwapchainKHR   swapchain,
const VkAllocationCallbacks* pAllocator)
 {
RADV_FROM_HANDLE(radv_device, device, _device);
-   RADV_FROM_HANDLE(wsi_swapchain, swapchain, _swapchain);
const VkAllocationCallbacks *alloc;
 
-   if (!_swapchain)
-   return;
-
if (pAllocator)
alloc = pAllocator;
else
alloc = >alloc;
 
-   for (unsigned i = 0; i < ARRAY_SIZE(swapchain->fences); i++) {
-   if (swapchain->fences[i] != VK_NULL_HANDLE)
-   radv_DestroyFence(_device, swapchain->fences[i], 
pAllocator);
-   }
-
-   swapchain->destroy(swapchain, alloc);
+   wsi_common_destroy_swapchain(_device, swapchain, alloc);
 }
 
 VkResult radv_GetSwapchainImagesKHR(
diff --git a/src/intel/vulkan/anv_wsi.c b/src/intel/vulkan/anv_wsi.c
index eed378c..62368a1 100644
--- a/src/intel/vulkan/anv_wsi.c
+++ b/src/intel/vulkan/anv_wsi.c
@@ -193,57 +193,32 @@ VkResult anv_CreateSwapchainKHR(
 VkSwapchainKHR*  pSwapchain)
 {
ANV_FROM_HANDLE(anv_device, device, _device);
-   ICD_FROM_HANDLE(VkIcdSurfaceBase, surface, pCreateInfo->surface);
-   struct wsi_interface *iface =
-  device->instance->physicalDevice.wsi_device.wsi[surface->platform];
-   struct wsi_swapchain *swapchain;
+   struct wsi_device *wsi_device = 
>instance->physicalDevice.wsi_device;
const VkAllocationCallbacks *alloc;
 
if (pAllocator)
  alloc = pAllocator;
else
  alloc = >alloc;
-   VkResult result = iface->create_swapchain(surface, _device,
- 
>instance->physicalDevice.wsi_device,
- 
device->instance->physicalDevice.local_fd,
- pCreateInfo,
- alloc,
- );
-   if (result != VK_SUCCESS)
-  return result;
-
-   swapchain->alloc = *alloc;
 
-   for (unsigned i = 0; i < ARRAY_SIZE(swapchain->fences); i++)
-  swapchain->fences[i] = VK_NULL_HANDLE;
-
-   *pSwapchain = wsi_swapchain_to_handle(swapchain);
-
-   return VK_SUCCESS;
+   return wsi_common_create_swapchain(wsi_device, _device, device->fd,
+  pCreateInfo, alloc, pSwapchain);