mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-11-22 09:09:18 +01:00
Vulkan: Remove unecessary present fence (#1166)
This commit is contained in:
parent
391533dbe5
commit
84cad8b280
@ -875,11 +875,6 @@ void LatteRenderTarget_getScreenImageArea(sint32* x, sint32* y, sint32* width, s
|
||||
|
||||
void LatteRenderTarget_copyToBackbuffer(LatteTextureView* textureView, bool isPadView)
|
||||
{
|
||||
if (g_renderer->GetType() == RendererAPI::Vulkan)
|
||||
{
|
||||
((VulkanRenderer*)g_renderer.get())->PreparePresentationFrame(!isPadView);
|
||||
}
|
||||
|
||||
// make sure texture is updated to latest data in cache
|
||||
LatteTexture_UpdateDataToLatest(textureView->baseTexture);
|
||||
// mark source texture as still in use
|
||||
|
@ -146,13 +146,6 @@ void SwapchainInfoVk::Create()
|
||||
UnrecoverableError("Failed to create semaphore for swapchain acquire");
|
||||
}
|
||||
|
||||
VkFenceCreateInfo fenceInfo = {};
|
||||
fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
|
||||
fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT;
|
||||
result = vkCreateFence(m_logicalDevice, &fenceInfo, nullptr, &m_imageAvailableFence);
|
||||
if (result != VK_SUCCESS)
|
||||
UnrecoverableError("Failed to create fence for swapchain");
|
||||
|
||||
m_acquireIndex = 0;
|
||||
hasDefinedSwapchainImage = false;
|
||||
}
|
||||
@ -184,12 +177,6 @@ void SwapchainInfoVk::Cleanup()
|
||||
m_swapchainFramebuffers.clear();
|
||||
|
||||
|
||||
if (m_imageAvailableFence)
|
||||
{
|
||||
WaitAvailableFence();
|
||||
vkDestroyFence(m_logicalDevice, m_imageAvailableFence, nullptr);
|
||||
m_imageAvailableFence = nullptr;
|
||||
}
|
||||
if (m_swapchain)
|
||||
{
|
||||
vkDestroySwapchainKHR(m_logicalDevice, m_swapchain, nullptr);
|
||||
@ -202,18 +189,6 @@ bool SwapchainInfoVk::IsValid() const
|
||||
return m_swapchain && !m_acquireSemaphores.empty();
|
||||
}
|
||||
|
||||
void SwapchainInfoVk::WaitAvailableFence()
|
||||
{
|
||||
if(m_awaitableFence != VK_NULL_HANDLE)
|
||||
vkWaitForFences(m_logicalDevice, 1, &m_awaitableFence, VK_TRUE, UINT64_MAX);
|
||||
m_awaitableFence = VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
void SwapchainInfoVk::ResetAvailableFence() const
|
||||
{
|
||||
vkResetFences(m_logicalDevice, 1, &m_imageAvailableFence);
|
||||
}
|
||||
|
||||
VkSemaphore SwapchainInfoVk::ConsumeAcquireSemaphore()
|
||||
{
|
||||
VkSemaphore ret = m_currentSemaphore;
|
||||
@ -221,15 +196,18 @@ VkSemaphore SwapchainInfoVk::ConsumeAcquireSemaphore()
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool SwapchainInfoVk::AcquireImage(uint64 timeout)
|
||||
bool SwapchainInfoVk::AcquireImage()
|
||||
{
|
||||
WaitAvailableFence();
|
||||
ResetAvailableFence();
|
||||
|
||||
VkSemaphore acquireSemaphore = m_acquireSemaphores[m_acquireIndex];
|
||||
VkResult result = vkAcquireNextImageKHR(m_logicalDevice, m_swapchain, timeout, acquireSemaphore, m_imageAvailableFence, &swapchainImageIndex);
|
||||
VkResult result = vkAcquireNextImageKHR(m_logicalDevice, m_swapchain, 1'000'000'000, acquireSemaphore, nullptr, &swapchainImageIndex);
|
||||
if (result == VK_ERROR_OUT_OF_DATE_KHR || result == VK_SUBOPTIMAL_KHR)
|
||||
m_shouldRecreate = true;
|
||||
if (result == VK_TIMEOUT)
|
||||
{
|
||||
swapchainImageIndex = -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (result < 0)
|
||||
{
|
||||
swapchainImageIndex = -1;
|
||||
@ -238,7 +216,6 @@ bool SwapchainInfoVk::AcquireImage(uint64 timeout)
|
||||
return false;
|
||||
}
|
||||
m_currentSemaphore = acquireSemaphore;
|
||||
m_awaitableFence = m_imageAvailableFence;
|
||||
m_acquireIndex = (m_acquireIndex + 1) % m_swapchainImages.size();
|
||||
|
||||
return true;
|
||||
|
@ -26,10 +26,7 @@ struct SwapchainInfoVk
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
void WaitAvailableFence();
|
||||
void ResetAvailableFence() const;
|
||||
|
||||
bool AcquireImage(uint64 timeout);
|
||||
bool AcquireImage();
|
||||
// retrieve semaphore of last acquire for submitting a wait operation
|
||||
// only one wait operation must be submitted per acquire (which submits a single signal operation)
|
||||
// therefore subsequent calls will return a NULL handle
|
||||
@ -84,9 +81,7 @@ struct SwapchainInfoVk
|
||||
private:
|
||||
uint32 m_acquireIndex = 0;
|
||||
std::vector<VkSemaphore> m_acquireSemaphores; // indexed by m_acquireIndex
|
||||
VkFence m_imageAvailableFence{};
|
||||
VkSemaphore m_currentSemaphore = VK_NULL_HANDLE;
|
||||
VkFence m_awaitableFence = VK_NULL_HANDLE;
|
||||
|
||||
std::array<uint32, 2> m_swapchainQueueFamilyIndices;
|
||||
VkExtent2D m_actualExtent{};
|
||||
|
@ -1824,11 +1824,6 @@ void VulkanRenderer::DrawEmptyFrame(bool mainWindow)
|
||||
SwapBuffers(mainWindow, !mainWindow);
|
||||
}
|
||||
|
||||
void VulkanRenderer::PreparePresentationFrame(bool mainWindow)
|
||||
{
|
||||
AcquireNextSwapchainImage(mainWindow);
|
||||
}
|
||||
|
||||
void VulkanRenderer::InitFirstCommandBuffer()
|
||||
{
|
||||
cemu_assert_debug(m_state.currentCommandBuffer == nullptr);
|
||||
@ -2599,7 +2594,7 @@ bool VulkanRenderer::AcquireNextSwapchainImage(bool mainWindow)
|
||||
if (!UpdateSwapchainProperties(mainWindow))
|
||||
return false;
|
||||
|
||||
bool result = chainInfo.AcquireImage(UINT64_MAX);
|
||||
bool result = chainInfo.AcquireImage();
|
||||
if (!result)
|
||||
return false;
|
||||
|
||||
@ -2612,8 +2607,6 @@ void VulkanRenderer::RecreateSwapchain(bool mainWindow, bool skipCreate)
|
||||
SubmitCommandBuffer();
|
||||
WaitDeviceIdle();
|
||||
auto& chainInfo = GetChainInfo(mainWindow);
|
||||
// make sure fence has no signal operation submitted
|
||||
chainInfo.WaitAvailableFence();
|
||||
|
||||
Vector2i size;
|
||||
if (mainWindow)
|
||||
|
@ -228,7 +228,6 @@ public:
|
||||
uint64 GenUniqueId(); // return unique id (uses incrementing counter)
|
||||
|
||||
void DrawEmptyFrame(bool mainWindow) override;
|
||||
void PreparePresentationFrame(bool mainWindow);
|
||||
|
||||
void InitFirstCommandBuffer();
|
||||
void ProcessFinishedCommandBuffers();
|
||||
|
Loading…
Reference in New Issue
Block a user