From 9a023b36159fafff401b36cafd841ce1fa1d137a Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Mon, 18 Aug 2025 11:24:43 -0400 Subject: [PATCH] vulkan/wsi: Make get_blit_queue return a struct vk_queue * Reviewed-by: Lars-Ivar Hesselberg Simonsen Reviewed-by: Adam Jackson Reviewed-by: Lionel Landwerlin Part-of: --- src/amd/vulkan/radv_wsi.c | 8 ++++---- src/microsoft/vulkan/dzn_wsi.c | 4 ++-- src/vulkan/wsi/wsi_common.c | 26 ++++++++++++-------------- src/vulkan/wsi/wsi_common.h | 2 +- src/vulkan/wsi/wsi_common_private.h | 2 +- 5 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/amd/vulkan/radv_wsi.c b/src/amd/vulkan/radv_wsi.c index 47829dff236..49f21b388b7 100644 --- a/src/amd/vulkan/radv_wsi.c +++ b/src/amd/vulkan/radv_wsi.c @@ -34,7 +34,7 @@ radv_wsi_set_memory_ownership(VkDevice _device, VkDeviceMemory _mem, VkBool32 ow } } -static VkQueue +static struct vk_queue * radv_wsi_get_prime_blit_queue(VkDevice _device) { VK_FROM_HANDLE(radv_device, device, _device); @@ -42,7 +42,7 @@ radv_wsi_get_prime_blit_queue(VkDevice _device) const struct radv_instance *instance = radv_physical_device_instance(pdev); if (device->private_sdma_queue != VK_NULL_HANDLE) - return vk_queue_to_handle(&device->private_sdma_queue->vk); + return &device->private_sdma_queue->vk; if (pdev->info.gfx_level >= GFX9 && !(instance->debug_flags & RADV_DEBUG_NO_DMA_BLIT)) { @@ -58,13 +58,13 @@ radv_wsi_get_prime_blit_queue(VkDevice _device) VkResult result = radv_queue_init(device, device->private_sdma_queue, 0, &queue_create, NULL); if (result == VK_SUCCESS) { - return vk_queue_to_handle(&device->private_sdma_queue->vk); + return &device->private_sdma_queue->vk; } else { vk_free(&device->vk.alloc, device->private_sdma_queue); device->private_sdma_queue = VK_NULL_HANDLE; } } - return VK_NULL_HANDLE; + return NULL; } VkResult diff --git a/src/microsoft/vulkan/dzn_wsi.c b/src/microsoft/vulkan/dzn_wsi.c index e077532d199..6a834975498 100644 --- a/src/microsoft/vulkan/dzn_wsi.c +++ b/src/microsoft/vulkan/dzn_wsi.c @@ -39,12 +39,12 @@ dzn_wsi_get_d3d12_command_queue(VkDevice dev) return device->swapchain_queue->cmdqueue; } -static VkQueue +static struct vk_queue * dzn_wsi_get_blit_queue(VkDevice dev) { VK_FROM_HANDLE(dzn_device, device, dev); - return dzn_queue_to_handle(device->swapchain_queue); + return &device->swapchain_queue->vk; } static bool diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c index 5dde335acc7..7ac4a4eeb29 100644 --- a/src/vulkan/wsi/wsi_common.c +++ b/src/vulkan/wsi/wsi_common.c @@ -451,13 +451,13 @@ wsi_swapchain_init(const struct wsi_device *wsi, chain->alloc = *pAllocator; chain->blit.type = get_blit_type(wsi, image_params, _device); - chain->blit.queue = VK_NULL_HANDLE; + chain->blit.queue = NULL; if (chain->blit.type != WSI_SWAPCHAIN_NO_BLIT) { if (wsi->get_blit_queue) { chain->blit.queue = wsi->get_blit_queue(_device); } - int cmd_pools_count = chain->blit.queue != VK_NULL_HANDLE ? 1 : wsi->queue_family_count; + int cmd_pools_count = chain->blit.queue != NULL ? 1 : wsi->queue_family_count; chain->cmd_pools = vk_zalloc(pAllocator, sizeof(VkCommandPool) * cmd_pools_count, 8, @@ -471,9 +471,8 @@ wsi_swapchain_init(const struct wsi_device *wsi, for (uint32_t i = 0; i < cmd_pools_count; i++) { int queue_family_index = i; - if (chain->blit.queue != VK_NULL_HANDLE) { - VK_FROM_HANDLE(vk_queue, queue, chain->blit.queue); - queue_family_index = queue->queue_family_index; + if (chain->blit.queue != NULL) { + queue_family_index = chain->blit.queue->queue_family_index; } else { /* Queues returned by get_blit_queue() might not be listed in * GetPhysicalDeviceQueueFamilyProperties, so this check is skipped for those queues. @@ -589,7 +588,7 @@ wsi_swapchain_finish(struct wsi_swapchain *chain) &chain->alloc); if (chain->blit.type != WSI_SWAPCHAIN_NO_BLIT) { - int cmd_pools_count = chain->blit.queue != VK_NULL_HANDLE ? + int cmd_pools_count = chain->blit.queue != NULL ? 1 : chain->wsi->queue_family_count; for (uint32_t i = 0; i < cmd_pools_count; i++) { if (!chain->cmd_pools[i]) @@ -811,7 +810,7 @@ wsi_destroy_image(const struct wsi_swapchain *chain, if (image->blit.cmd_buffers) { int cmd_buffer_count = - chain->blit.queue != VK_NULL_HANDLE ? 1 : wsi->queue_family_count; + chain->blit.queue != NULL ? 1 : wsi->queue_family_count; for (uint32_t i = 0; i < cmd_buffer_count; i++) { if (!chain->cmd_pools[i]) @@ -1065,7 +1064,7 @@ wsi_CreateSwapchainKHR(VkDevice _device, } } - if (swapchain->blit.queue != VK_NULL_HANDLE) { + if (swapchain->blit.queue != NULL) { swapchain->blit.semaphores = vk_zalloc(alloc, sizeof (*swapchain->blit.semaphores) * swapchain->image_count, sizeof (*swapchain->blit.semaphores), @@ -1417,7 +1416,7 @@ wsi_common_queue_present(const struct wsi_device *wsi, goto fail_present; if (swapchain->blit.type != WSI_SWAPCHAIN_NO_BLIT && - swapchain->blit.queue != VK_NULL_HANDLE) { + swapchain->blit.queue != NULL) { const VkSemaphoreCreateInfo sem_info = { .sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO, .pNext = NULL, @@ -1462,7 +1461,7 @@ wsi_common_queue_present(const struct wsi_device *wsi, VkSemaphoreSubmitInfo blit_semaphore_info; VkCommandBufferSubmitInfo blit_command_buffer_info; if (swapchain->blit.type != WSI_SWAPCHAIN_NO_BLIT) { - if (swapchain->blit.queue == VK_NULL_HANDLE) { + if (swapchain->blit.queue == NULL) { blit_command_buffer_info = (VkCommandBufferSubmitInfo) { .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_SUBMIT_INFO, .commandBuffer = @@ -1497,7 +1496,7 @@ wsi_common_queue_present(const struct wsi_device *wsi, /* Now prepare the blit submit. It needs to then wait on the * semaphore we signaled above. */ - submit_queue = vk_queue_from_handle(swapchain->blit.queue); + submit_queue = swapchain->blit.queue; submit_info.waitSemaphoreInfoCount = 1; submit_info.pWaitSemaphoreInfos = &blit_semaphore_info; @@ -2099,7 +2098,7 @@ wsi_finish_create_blit_context(const struct wsi_swapchain *chain, VkResult result; int cmd_buffer_count = - chain->blit.queue != VK_NULL_HANDLE ? 1 : wsi->queue_family_count; + chain->blit.queue != NULL ? 1 : wsi->queue_family_count; image->blit.cmd_buffers = vk_zalloc(&chain->alloc, sizeof(VkCommandBuffer) * cmd_buffer_count, 8, @@ -2135,10 +2134,9 @@ wsi_finish_create_blit_context(const struct wsi_swapchain *chain, switch (chain->blit.type) { case WSI_SWAPCHAIN_BUFFER_BLIT: { - VK_FROM_HANDLE(vk_queue, blit_queue, chain->blit.queue); wsi_cmd_blit_image_to_buffer( cmd_buffer, wsi, info, image, - blit_queue ? blit_queue->queue_family_index : i); + chain->blit.queue ? chain->blit.queue->queue_family_index : i); break; } case WSI_SWAPCHAIN_IMAGE_BLIT: diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h index dd779c25bf9..55df390ea86 100644 --- a/src/vulkan/wsi/wsi_common.h +++ b/src/vulkan/wsi/wsi_common.h @@ -223,7 +223,7 @@ struct wsi_device { * A driver can implement this callback to return a special queue to execute * buffer blits. */ - VkQueue (*get_blit_queue)(VkDevice device); + struct vk_queue *(*get_blit_queue)(VkDevice device); #define WSI_CB(cb) PFN_vk##cb cb WSI_CB(AllocateMemory); diff --git a/src/vulkan/wsi/wsi_common_private.h b/src/vulkan/wsi/wsi_common_private.h index 634e3687764..4a45bea1639 100644 --- a/src/vulkan/wsi/wsi_common_private.h +++ b/src/vulkan/wsi/wsi_common_private.h @@ -233,7 +233,7 @@ struct wsi_swapchain { * The created queue will be stored here and will be used to execute the * buffer blit instead of using the present queue. */ - VkQueue queue; + struct vk_queue *queue; } blit; bool capture_key_pressed;