Re: [Mesa-dev] [PATCH v2 17/32] radv/wsi: Move the guts of QueuePresent to wsi common

2017-12-01 Thread Chad Versace
On Tue 28 Nov 2017, Jason Ekstrand wrote:
> From: Dave Airlie 
> 
> v2 (Jason Ekstrand):
>  - Better comit message
>  - Rebase
>  - Re-indent to follow wsi_common style
>  - Drop the unneeded _swapchain from the newly added helper
>  - Make the clone more true to the original (as per the rebase)
> ---
>  src/amd/vulkan/radv_wsi.c   | 92 
> +++--
>  src/vulkan/wsi/wsi_common.c | 78 ++
>  src/vulkan/wsi/wsi_common.h | 10 +
>  3 files changed, 93 insertions(+), 87 deletions(-)

> +VkResult
> +wsi_common_queue_present(const struct wsi_device *wsi,
> + VkDevice device,
> + VkQueue queue,
> + int queue_family_index,
> + const VkPresentInfoKHR *pPresentInfo)
> +{
> +   VkResult result = VK_SUCCESS;
> +
> +   const VkPresentRegionsKHR *regions =
> +  vk_find_struct_const(pPresentInfo->pNext, PRESENT_REGIONS_KHR);
> +
> +   for (uint32_t i = 0; i < pPresentInfo->swapchainCount; i++) {
> +  WSI_FROM_HANDLE(wsi_swapchain, swapchain, 
> pPresentInfo->pSwapchains[i]);
> +  VkResult item_result;
> +
> +  if (swapchain->fences[0] == VK_NULL_HANDLE) {
> + const VkFenceCreateInfo fence_info = {
> +.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
> +.pNext = NULL,
> +.flags = 0,
> + };
> + item_result = wsi->CreateFence(device, _info,
> +>alloc,
> +>fences[0]);

As part of moving fence creation to the common code, the fence
destruction should also be moved from (anv|radv)_DestroySwapchainKHR to
wsi_swapchain_finish(). But, since that migration doesn't affect the
correctness of the patch, this patch 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 17/32] radv/wsi: Move the guts of QueuePresent to wsi common

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

v2 (Jason Ekstrand):
 - Better comit message
 - Rebase
 - Re-indent to follow wsi_common style
 - Drop the unneeded _swapchain from the newly added helper
 - Make the clone more true to the original (as per the rebase)
---
 src/amd/vulkan/radv_wsi.c   | 92 +++--
 src/vulkan/wsi/wsi_common.c | 78 ++
 src/vulkan/wsi/wsi_common.h | 10 +
 3 files changed, 93 insertions(+), 87 deletions(-)

diff --git a/src/amd/vulkan/radv_wsi.c b/src/amd/vulkan/radv_wsi.c
index b576514..0d1b479 100644
--- a/src/amd/vulkan/radv_wsi.c
+++ b/src/amd/vulkan/radv_wsi.c
@@ -258,91 +258,9 @@ VkResult radv_QueuePresentKHR(
const VkPresentInfoKHR*  pPresentInfo)
 {
RADV_FROM_HANDLE(radv_queue, queue, _queue);
-   VkResult result = VK_SUCCESS;
-   const VkPresentRegionsKHR *regions =
-vk_find_struct_const(pPresentInfo->pNext, PRESENT_REGIONS_KHR);
-
-   for (uint32_t i = 0; i < pPresentInfo->swapchainCount; i++) {
-   RADV_FROM_HANDLE(wsi_swapchain, swapchain, 
pPresentInfo->pSwapchains[i]);
-   struct radeon_winsys_cs *cs;
-   const VkPresentRegionKHR *region = NULL;
-   VkResult item_result;
-   struct radv_winsys_sem_info sem_info;
-
-   item_result = radv_alloc_sem_info(_info,
- 
pPresentInfo->waitSemaphoreCount,
- pPresentInfo->pWaitSemaphores,
- 0,
- NULL);
-   if (pPresentInfo->pResults != NULL)
-   pPresentInfo->pResults[i] = item_result;
-   result = result == VK_SUCCESS ? item_result : result;
-   if (item_result != VK_SUCCESS) {
-   radv_free_sem_info(_info);
-   continue;
-   }
-
-   assert(radv_device_from_handle(swapchain->device) == 
queue->device);
-   if (swapchain->fences[0] == VK_NULL_HANDLE) {
-   item_result = 
radv_CreateFence(radv_device_to_handle(queue->device),
- &(VkFenceCreateInfo) {
- .sType = 
VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
- .flags = 0,
- }, 
>alloc, >fences[0]);
-   if (pPresentInfo->pResults != NULL)
-   pPresentInfo->pResults[i] = item_result;
-   result = result == VK_SUCCESS ? item_result : result;
-   if (item_result != VK_SUCCESS) {
-   radv_free_sem_info(_info);
-   continue;
-   }
-   } else {
-   radv_ResetFences(radv_device_to_handle(queue->device),
-1, >fences[0]);
-   }
-
-   cs = queue->device->empty_cs[queue->queue_family_index];
-   RADV_FROM_HANDLE(radv_fence, fence, swapchain->fences[0]);
-   struct radeon_winsys_fence *base_fence = fence->fence;
-   struct radeon_winsys_ctx *ctx = queue->hw_ctx;
-
-   queue->device->ws->cs_submit(ctx, queue->queue_idx,
-,
-1, NULL, NULL,
-_info,
-false, base_fence);
-   fence->submitted = true;
-
-   if (regions && regions->pRegions)
-   region = >pRegions[i];
-
-   item_result = swapchain->queue_present(swapchain,
- _queue,
- 
pPresentInfo->waitSemaphoreCount,
- pPresentInfo->pWaitSemaphores,
- 
pPresentInfo->pImageIndices[i],
- region);
-   /* TODO: What if one of them returns OUT_OF_DATE? */
-   if (pPresentInfo->pResults != NULL)
-   pPresentInfo->pResults[i] = item_result;
-   result = result == VK_SUCCESS ? item_result : result;
-   if (item_result != VK_SUCCESS) {
-   radv_free_sem_info(_info);
-   continue;
-   }
-
-   VkFence last = swapchain->fences[2];
-   swapchain->fences[2] = swapchain->fences[1];
-   swapchain->fences[1] = swapchain->fences[0];
-   swapchain->fences[0] = last;
-
-