mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-30 20:52:11 +01:00
[vulkan] Remove getSyncSemaphores from presenter
Instead, return the semaphores in acquireNextImage.
This commit is contained in:
parent
253884a8c7
commit
0b88d0deab
@ -254,11 +254,11 @@ namespace dxvk {
|
|||||||
|
|
||||||
// Presentation semaphores and WSI swap chain image
|
// Presentation semaphores and WSI swap chain image
|
||||||
vk::PresenterInfo info = m_presenter->info();
|
vk::PresenterInfo info = m_presenter->info();
|
||||||
vk::PresenterSync sync = m_presenter->getSyncSemaphores();
|
vk::PresenterSync sync;
|
||||||
|
|
||||||
uint32_t imageIndex = 0;
|
uint32_t imageIndex = 0;
|
||||||
|
|
||||||
VkResult status = m_presenter->acquireNextImage(sync.acquire, imageIndex);
|
VkResult status = m_presenter->acquireNextImage(sync, imageIndex);
|
||||||
|
|
||||||
while (status != VK_SUCCESS && status != VK_SUBOPTIMAL_KHR) {
|
while (status != VK_SUCCESS && status != VK_SUBOPTIMAL_KHR) {
|
||||||
RecreateSwapChain(m_vsync);
|
RecreateSwapChain(m_vsync);
|
||||||
@ -267,9 +267,7 @@ namespace dxvk {
|
|||||||
return DXGI_STATUS_OCCLUDED;
|
return DXGI_STATUS_OCCLUDED;
|
||||||
|
|
||||||
info = m_presenter->info();
|
info = m_presenter->info();
|
||||||
sync = m_presenter->getSyncSemaphores();
|
status = m_presenter->acquireNextImage(sync, imageIndex);
|
||||||
|
|
||||||
status = m_presenter->acquireNextImage(sync.acquire, imageIndex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resolve back buffer if it is multisampled. We
|
// Resolve back buffer if it is multisampled. We
|
||||||
@ -317,8 +315,7 @@ namespace dxvk {
|
|||||||
if (cHud != nullptr && !cFrameId)
|
if (cHud != nullptr && !cFrameId)
|
||||||
cHud->update();
|
cHud->update();
|
||||||
|
|
||||||
m_device->presentImage(m_presenter,
|
m_device->presentImage(m_presenter, &m_presentStatus);
|
||||||
cSync.present, &m_presentStatus);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
pContext->FlushCsChunk();
|
pContext->FlushCsChunk();
|
||||||
|
@ -787,19 +787,17 @@ namespace dxvk {
|
|||||||
|
|
||||||
// Presentation semaphores and WSI swap chain image
|
// Presentation semaphores and WSI swap chain image
|
||||||
vk::PresenterInfo info = m_presenter->info();
|
vk::PresenterInfo info = m_presenter->info();
|
||||||
vk::PresenterSync sync = m_presenter->getSyncSemaphores();
|
vk::PresenterSync sync;
|
||||||
|
|
||||||
uint32_t imageIndex = 0;
|
uint32_t imageIndex = 0;
|
||||||
|
|
||||||
VkResult status = m_presenter->acquireNextImage(sync.acquire, imageIndex);
|
VkResult status = m_presenter->acquireNextImage(sync, imageIndex);
|
||||||
|
|
||||||
while (status != VK_SUCCESS && status != VK_SUBOPTIMAL_KHR) {
|
while (status != VK_SUCCESS && status != VK_SUBOPTIMAL_KHR) {
|
||||||
RecreateSwapChain(m_vsync);
|
RecreateSwapChain(m_vsync);
|
||||||
|
|
||||||
info = m_presenter->info();
|
info = m_presenter->info();
|
||||||
sync = m_presenter->getSyncSemaphores();
|
status = m_presenter->acquireNextImage(sync, imageIndex);
|
||||||
|
|
||||||
status = m_presenter->acquireNextImage(sync.acquire, imageIndex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_context->beginRecording(
|
m_context->beginRecording(
|
||||||
@ -852,8 +850,7 @@ namespace dxvk {
|
|||||||
if (cHud != nullptr && !cFrameId)
|
if (cHud != nullptr && !cFrameId)
|
||||||
cHud->update();
|
cHud->update();
|
||||||
|
|
||||||
m_device->presentImage(m_presenter,
|
m_device->presentImage(m_presenter, &m_presentStatus);
|
||||||
cSync.present, &m_presentStatus);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
m_parent->FlushCsChunk();
|
m_parent->FlushCsChunk();
|
||||||
|
@ -211,13 +211,11 @@ namespace dxvk {
|
|||||||
|
|
||||||
void DxvkDevice::presentImage(
|
void DxvkDevice::presentImage(
|
||||||
const Rc<vk::Presenter>& presenter,
|
const Rc<vk::Presenter>& presenter,
|
||||||
VkSemaphore semaphore,
|
|
||||||
DxvkSubmitStatus* status) {
|
DxvkSubmitStatus* status) {
|
||||||
status->result = VK_NOT_READY;
|
status->result = VK_NOT_READY;
|
||||||
|
|
||||||
DxvkPresentInfo presentInfo;
|
DxvkPresentInfo presentInfo;
|
||||||
presentInfo.presenter = presenter;
|
presentInfo.presenter = presenter;
|
||||||
presentInfo.waitSync = semaphore;
|
|
||||||
m_submissionQueue.present(presentInfo, status);
|
m_submissionQueue.present(presentInfo, status);
|
||||||
|
|
||||||
std::lock_guard<sync::Spinlock> statLock(m_statLock);
|
std::lock_guard<sync::Spinlock> statLock(m_statLock);
|
||||||
|
@ -399,12 +399,10 @@ namespace dxvk {
|
|||||||
* the submission thread. The status of this operation
|
* the submission thread. The status of this operation
|
||||||
* can be retrieved with \ref waitForSubmission.
|
* can be retrieved with \ref waitForSubmission.
|
||||||
* \param [in] presenter The presenter
|
* \param [in] presenter The presenter
|
||||||
* \param [in] semaphore Sync semaphore
|
|
||||||
* \param [out] status Present status
|
* \param [out] status Present status
|
||||||
*/
|
*/
|
||||||
void presentImage(
|
void presentImage(
|
||||||
const Rc<vk::Presenter>& presenter,
|
const Rc<vk::Presenter>& presenter,
|
||||||
VkSemaphore semaphore,
|
|
||||||
DxvkSubmitStatus* status);
|
DxvkSubmitStatus* status);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -108,8 +108,7 @@ namespace dxvk {
|
|||||||
entry.submit.waitSync,
|
entry.submit.waitSync,
|
||||||
entry.submit.wakeSync);
|
entry.submit.wakeSync);
|
||||||
} else if (entry.present.presenter != nullptr) {
|
} else if (entry.present.presenter != nullptr) {
|
||||||
status = entry.present.presenter->presentImage(
|
status = entry.present.presenter->presentImage();
|
||||||
entry.present.waitSync);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Don't submit anything after device loss
|
// Don't submit anything after device loss
|
||||||
|
@ -46,7 +46,6 @@ namespace dxvk {
|
|||||||
*/
|
*/
|
||||||
struct DxvkPresentInfo {
|
struct DxvkPresentInfo {
|
||||||
Rc<vk::Presenter> presenter;
|
Rc<vk::Presenter> presenter;
|
||||||
VkSemaphore waitSync;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,49 +38,44 @@ namespace dxvk::vk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PresenterSync Presenter::getSyncSemaphores() const {
|
|
||||||
return m_semaphores.at(m_frameIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PresenterImage Presenter::getImage(uint32_t index) const {
|
PresenterImage Presenter::getImage(uint32_t index) const {
|
||||||
return m_images.at(index);
|
return m_images.at(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VkResult Presenter::acquireNextImage(
|
VkResult Presenter::acquireNextImage(PresenterSync& sync, uint32_t& index) {
|
||||||
VkSemaphore signal,
|
sync = m_semaphores.at(m_frameIndex);
|
||||||
uint32_t& index) {
|
|
||||||
VkResult status;
|
|
||||||
|
|
||||||
status = m_vkd->vkAcquireNextImageKHR(
|
VkResult status = m_vkd->vkAcquireNextImageKHR(
|
||||||
m_vkd->device(), m_swapchain,
|
m_vkd->device(), m_swapchain,
|
||||||
std::numeric_limits<uint64_t>::max(),
|
std::numeric_limits<uint64_t>::max(),
|
||||||
signal, VK_NULL_HANDLE, &m_imageIndex);
|
sync.acquire, VK_NULL_HANDLE, &m_imageIndex);
|
||||||
|
|
||||||
if (status != VK_SUCCESS
|
if (status != VK_SUCCESS
|
||||||
&& status != VK_SUBOPTIMAL_KHR)
|
&& status != VK_SUBOPTIMAL_KHR)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
m_frameIndex += 1;
|
|
||||||
m_frameIndex %= m_semaphores.size();
|
|
||||||
|
|
||||||
index = m_imageIndex;
|
index = m_imageIndex;
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VkResult Presenter::presentImage(VkSemaphore wait) {
|
VkResult Presenter::presentImage() {
|
||||||
|
PresenterSync sync = m_semaphores.at(m_frameIndex);
|
||||||
|
|
||||||
VkPresentInfoKHR info;
|
VkPresentInfoKHR info;
|
||||||
info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
|
info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
|
||||||
info.pNext = nullptr;
|
info.pNext = nullptr;
|
||||||
info.waitSemaphoreCount = 1;
|
info.waitSemaphoreCount = 1;
|
||||||
info.pWaitSemaphores = &wait;
|
info.pWaitSemaphores = &sync.present;
|
||||||
info.swapchainCount = 1;
|
info.swapchainCount = 1;
|
||||||
info.pSwapchains = &m_swapchain;
|
info.pSwapchains = &m_swapchain;
|
||||||
info.pImageIndices = &m_imageIndex;
|
info.pImageIndices = &m_imageIndex;
|
||||||
info.pResults = nullptr;
|
info.pResults = nullptr;
|
||||||
|
|
||||||
|
m_frameIndex += 1;
|
||||||
|
m_frameIndex %= m_semaphores.size();
|
||||||
|
|
||||||
return m_vkd->vkQueuePresentKHR(m_device.queue, &info);
|
return m_vkd->vkQueuePresentKHR(m_device.queue, &info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,15 +106,6 @@ namespace dxvk::vk {
|
|||||||
*/
|
*/
|
||||||
PresenterInfo info() const;
|
PresenterInfo info() const;
|
||||||
|
|
||||||
/**
|
|
||||||
* \breif Retrieves a pair of semaphores
|
|
||||||
*
|
|
||||||
* These semaphores are meant to be used
|
|
||||||
* for acquire and present operations.
|
|
||||||
* \returns Pair of semaphores
|
|
||||||
*/
|
|
||||||
PresenterSync getSyncSemaphores() const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Retrieves image by index
|
* \brief Retrieves image by index
|
||||||
*
|
*
|
||||||
@ -132,12 +123,12 @@ namespace dxvk::vk {
|
|||||||
* If this returns an error, the swap chain
|
* If this returns an error, the swap chain
|
||||||
* must be recreated and a new image must
|
* must be recreated and a new image must
|
||||||
* be acquired before proceeding.
|
* be acquired before proceeding.
|
||||||
* \param [in] signal Semaphore to signal
|
* \param [out] sync Synchronization semaphores
|
||||||
* \param [out] index Acquired image index
|
* \param [out] index Acquired image index
|
||||||
* \returns Status of the operation
|
* \returns Status of the operation
|
||||||
*/
|
*/
|
||||||
VkResult acquireNextImage(
|
VkResult acquireNextImage(
|
||||||
VkSemaphore signal,
|
PresenterSync& sync,
|
||||||
uint32_t& index);
|
uint32_t& index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -146,11 +137,9 @@ namespace dxvk::vk {
|
|||||||
* Presents the current image. If this returns
|
* Presents the current image. If this returns
|
||||||
* an error, the swap chain must be recreated,
|
* an error, the swap chain must be recreated,
|
||||||
* but do not present before acquiring an image.
|
* but do not present before acquiring an image.
|
||||||
* \param [in] wait Semaphore to wait on
|
|
||||||
* \returns Status of the operation
|
* \returns Status of the operation
|
||||||
*/
|
*/
|
||||||
VkResult presentImage(
|
VkResult presentImage();
|
||||||
VkSemaphore wait);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Changes presenter properties
|
* \brief Changes presenter properties
|
||||||
|
Loading…
x
Reference in New Issue
Block a user