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