mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-22 17:50:12 +01:00
wsi/common: Implement swapchain present fence.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no> Reviewed-by: Joshua Ashton <joshua@froggi.es> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20235>
This commit is contained in:
parent
be0dcbdfa2
commit
ae920c8420
1 changed files with 12 additions and 5 deletions
|
|
@ -1186,9 +1186,10 @@ wsi_AcquireNextImage2KHR(VkDevice _device,
|
||||||
}
|
}
|
||||||
|
|
||||||
static VkResult wsi_signal_present_id_timeline(struct wsi_swapchain *swapchain,
|
static VkResult wsi_signal_present_id_timeline(struct wsi_swapchain *swapchain,
|
||||||
VkQueue queue, uint64_t present_id)
|
VkQueue queue, uint64_t present_id,
|
||||||
|
VkFence present_fence)
|
||||||
{
|
{
|
||||||
assert(swapchain->present_id_timeline);
|
assert(swapchain->present_id_timeline || present_fence);
|
||||||
|
|
||||||
const VkTimelineSemaphoreSubmitInfo timeline_info = {
|
const VkTimelineSemaphoreSubmitInfo timeline_info = {
|
||||||
.sType = VK_STRUCTURE_TYPE_TIMELINE_SEMAPHORE_SUBMIT_INFO,
|
.sType = VK_STRUCTURE_TYPE_TIMELINE_SEMAPHORE_SUBMIT_INFO,
|
||||||
|
|
@ -1203,7 +1204,8 @@ static VkResult wsi_signal_present_id_timeline(struct wsi_swapchain *swapchain,
|
||||||
.pSignalSemaphores = &swapchain->present_id_timeline,
|
.pSignalSemaphores = &swapchain->present_id_timeline,
|
||||||
};
|
};
|
||||||
|
|
||||||
return swapchain->wsi->QueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE);
|
uint32_t submit_count = present_id ? 1 : 0;
|
||||||
|
return swapchain->wsi->QueueSubmit(queue, submit_count, &submit_info, present_fence);
|
||||||
}
|
}
|
||||||
|
|
||||||
VkResult
|
VkResult
|
||||||
|
|
@ -1224,6 +1226,8 @@ wsi_common_queue_present(const struct wsi_device *wsi,
|
||||||
vk_find_struct_const(pPresentInfo->pNext, PRESENT_REGIONS_KHR);
|
vk_find_struct_const(pPresentInfo->pNext, PRESENT_REGIONS_KHR);
|
||||||
const VkPresentIdKHR *present_ids =
|
const VkPresentIdKHR *present_ids =
|
||||||
vk_find_struct_const(pPresentInfo->pNext, PRESENT_ID_KHR);
|
vk_find_struct_const(pPresentInfo->pNext, PRESENT_ID_KHR);
|
||||||
|
const VkSwapchainPresentFenceInfoEXT *present_fence_info =
|
||||||
|
vk_find_struct_const(pPresentInfo->pNext, SWAPCHAIN_PRESENT_FENCE_INFO_EXT);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < pPresentInfo->swapchainCount; i++) {
|
for (uint32_t i = 0; i < pPresentInfo->swapchainCount; i++) {
|
||||||
VK_FROM_HANDLE(wsi_swapchain, swapchain, pPresentInfo->pSwapchains[i]);
|
VK_FROM_HANDLE(wsi_swapchain, swapchain, pPresentInfo->pSwapchains[i]);
|
||||||
|
|
@ -1375,9 +1379,12 @@ wsi_common_queue_present(const struct wsi_device *wsi,
|
||||||
uint64_t present_id = 0;
|
uint64_t present_id = 0;
|
||||||
if (present_ids && present_ids->pPresentIds)
|
if (present_ids && present_ids->pPresentIds)
|
||||||
present_id = present_ids->pPresentIds[i];
|
present_id = present_ids->pPresentIds[i];
|
||||||
|
VkFence present_fence = VK_NULL_HANDLE;
|
||||||
|
if (present_fence_info && present_fence_info->pFences)
|
||||||
|
present_fence = present_fence_info->pFences[i];
|
||||||
|
|
||||||
if (present_id) {
|
if (present_id || present_fence) {
|
||||||
result = wsi_signal_present_id_timeline(swapchain, queue, present_id);
|
result = wsi_signal_present_id_timeline(swapchain, queue, present_id, present_fence);
|
||||||
if (result != VK_SUCCESS)
|
if (result != VK_SUCCESS)
|
||||||
goto fail_present;
|
goto fail_present;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue