1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-31 14:52:11 +01:00

[dxvk] Create timeline semaphores in submission queue

This commit is contained in:
Philip Rebohle 2024-10-18 21:32:07 +02:00 committed by Philip Rebohle
parent 4c0cbbef6a
commit 1ee60048c0
2 changed files with 39 additions and 0 deletions

View File

@ -7,7 +7,20 @@ namespace dxvk {
: m_device(device), m_callback(callback),
m_submitThread([this] () { submitCmdLists(); }),
m_finishThread([this] () { finishCmdLists(); }) {
auto vk = m_device->vkd();
VkSemaphoreTypeCreateInfo semaphoreType = { VK_STRUCTURE_TYPE_SEMAPHORE_TYPE_CREATE_INFO };
semaphoreType.semaphoreType = VK_SEMAPHORE_TYPE_TIMELINE;
VkSemaphoreCreateInfo semaphoreInfo = { VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO, &semaphoreType };
VkResult vrGraphics = vk->vkCreateSemaphore(vk->device(), &semaphoreInfo, nullptr, &m_semaphores.graphics);
VkResult vrTransfer = vk->vkCreateSemaphore(vk->device(), &semaphoreInfo, nullptr, &m_semaphores.transfer);
if (vrGraphics || vrTransfer) {
throw DxvkError(str::format("Failed to create timeline semaphores: ",
vrGraphics > vrTransfer ? vrGraphics : vrTransfer));
}
}
@ -23,6 +36,9 @@ namespace dxvk {
m_submitThread.join();
m_finishThread.join();
vk->vkDestroySemaphore(vk->device(), m_semaphores.graphics, nullptr);
vk->vkDestroySemaphore(vk->device(), m_semaphores.transfer, nullptr);
}

View File

@ -59,6 +59,26 @@ namespace dxvk {
};
/**
* \brief Timeline semaphore pair
*
* One semaphore for each queue.
*/
struct DxvkTimelineSemaphores {
VkSemaphore graphics = VK_NULL_HANDLE;
VkSemaphore transfer = VK_NULL_HANDLE;
};
/**
* \brief Timeline semaphore values
*/
struct DxvkTimelineSemaphoreValues {
uint64_t graphics = 0u;
uint64_t transfer = 0u;
};
/**
* \brief Submission queue
*/
@ -179,6 +199,9 @@ namespace dxvk {
DxvkDevice* m_device;
DxvkQueueCallback m_callback;
DxvkTimelineSemaphores m_semaphores;
DxvkTimelineSemaphoreValues m_timelines;
std::atomic<VkResult> m_lastError = { VK_SUCCESS };
std::atomic<bool> m_stopped = { false };