vulkan,anv,hasvk: Drop vk_queue_wait_before_present()

This helper existed to ensure that drivers waited for semaphores to
materialize before processing a QueuePresent().  However, most drivers
never called this and they were kind-of fine.  Now that we have explicit
and dma-buf sync built into WSI, this wait happens as part
GetSemaphoreFd when we fetch the sync file from the semaphore.

It's also less racy to just rely on GetSemaphoreFd() because, even
though we were stalling the submit thread prior to present, the present
itself does one or more submits and those may go to the thread and
potentially race with the window system.  The GetSemaphoreFd(), however,
happens at the right time to ensure we actually stall before handing
off to the window system.

Reviewed-by: Lars-Ivar Hesselberg Simonsen <lars-ivar.simonsen@arm.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36827>
This commit is contained in:
Faith Ekstrand
2025-08-18 10:51:16 -04:00
committed by Marge Bot
parent c9d361ca80
commit 81325cf887
4 changed files with 0 additions and 76 deletions
-4
View File
@@ -108,10 +108,6 @@ VkResult anv_QueuePresentKHR(
if (u_trace_should_process(&device->ds.trace_context))
anv_queue_trace(queue, NULL, true /* frame */, false /* begin */);
result = vk_queue_wait_before_present(&queue->vk, pPresentInfo);
if (result != VK_SUCCESS)
return result;
result = wsi_common_queue_present(&device->physical->wsi_device,
anv_device_to_handle(queue->device),
_queue, 0,
-4
View File
@@ -105,10 +105,6 @@ VkResult anv_QueuePresentKHR(
#endif
}
result = vk_queue_wait_before_present(&queue->vk, pPresentInfo);
if (result != VK_SUCCESS)
return result;
result = wsi_common_queue_present(&device->physical->wsi_device,
anv_device_to_handle(queue->device),
_queue, 0,
-65
View File
@@ -1125,71 +1125,6 @@ vk_queue_merge_submit(struct vk_queue *queue,
return result;
}
VkResult
vk_queue_wait_before_present(struct vk_queue *queue,
const VkPresentInfoKHR *pPresentInfo)
{
if (vk_device_is_lost(queue->base.device))
return VK_ERROR_DEVICE_LOST;
/* From the Vulkan 1.2.194 spec:
*
* VUID-vkQueuePresentKHR-pWaitSemaphores-03268
*
* "All elements of the pWaitSemaphores member of pPresentInfo must
* reference a semaphore signal operation that has been submitted for
* execution and any semaphore signal operations on which it depends (if
* any) must have also been submitted for execution."
*
* As with vkQueueSubmit above, we need to ensure that any binary
* semaphores we use in this present actually exist. If we don't have
* timeline semaphores, this is a non-issue. If they're emulated, then
* this is ensured for us by the vk_device_flush() at the end of every
* vkQueueSubmit() and every vkSignalSemaphore(). For real timeline
* semaphores, however, we need to do a wait. Thanks to the above bit of
* spec text, that wait should never block for long.
*/
if (!vk_device_supports_threaded_submit(queue->base.device))
return VK_SUCCESS;
const uint32_t wait_count = pPresentInfo->waitSemaphoreCount;
if (wait_count == 0)
return VK_SUCCESS;
STACK_ARRAY(struct vk_sync_wait, waits, wait_count);
for (uint32_t i = 0; i < wait_count; i++) {
VK_FROM_HANDLE(vk_semaphore, semaphore,
pPresentInfo->pWaitSemaphores[i]);
/* From the Vulkan 1.2.194 spec:
*
* VUID-vkQueuePresentKHR-pWaitSemaphores-03267
*
* "All elements of the pWaitSemaphores member of pPresentInfo must
* be created with a VkSemaphoreType of VK_SEMAPHORE_TYPE_BINARY."
*/
assert(semaphore->type == VK_SEMAPHORE_TYPE_BINARY);
waits[i] = (struct vk_sync_wait) {
.sync = vk_semaphore_get_active_sync(semaphore),
.stage_mask = ~(VkPipelineStageFlags2)0,
};
}
VkResult result = vk_sync_wait_many(queue->base.device, wait_count, waits,
VK_SYNC_WAIT_PENDING, UINT64_MAX);
STACK_ARRAY_FINISH(waits);
/* Check again, just in case */
if (vk_device_is_lost(queue->base.device))
return VK_ERROR_DEVICE_LOST;
return result;
}
static VkResult
vk_queue_signal_sync(struct vk_queue *queue,
struct vk_sync *sync,
-3
View File
@@ -192,9 +192,6 @@ VkResult vk_queue_enable_submit_thread(struct vk_queue *queue);
VkResult vk_queue_flush(struct vk_queue *queue, uint32_t *submit_count_out);
VkResult vk_queue_wait_before_present(struct vk_queue *queue,
const VkPresentInfoKHR *pPresentInfo);
VkResult PRINTFLIKE(4, 5)
_vk_queue_set_lost(struct vk_queue *queue,
const char *file, int line,