diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUSwapChainVulkan.cpp b/Source/Engine/GraphicsDevice/Vulkan/GPUSwapChainVulkan.cpp index b259ed688..3bc38a765 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/GPUSwapChainVulkan.cpp +++ b/Source/Engine/GraphicsDevice/Vulkan/GPUSwapChainVulkan.cpp @@ -135,6 +135,7 @@ GPUTextureView* GPUSwapChainVulkan::GetBackBufferView() PROFILE_CPU(); auto context = _device->MainContext; auto cmdBufferManager = context->GetCmdBufferManager(); + // Keep commands recorded before acquire independent from the image-acquired semaphore wait below. if (cmdBufferManager->HasPendingActiveCmdBuffer()) context->Flush(); @@ -152,7 +153,6 @@ GPUTextureView* GPUSwapChainVulkan::GetBackBufferView() acquiredBackBuffer.WaitForSubmit(); const auto backBuffer = &_backBuffers[_acquiredImageIndex].Handle; - auto cmdBuffer = cmdBufferManager->GetCmdBuffer(); // Transition to render target (typical usage in most cases when calling backbuffer getter) @@ -171,6 +171,17 @@ GPUTextureView* GPUSwapChainVulkan::GetBackBufferView() void GPUSwapChainVulkan::Begin(RenderTask* task) { GPUSwapChain::Begin(task); + + // Wait for the backbuffer to be available + if (_currentImageIndex != -1) + { + auto& backBuffer = _backBuffers[_currentImageIndex]; + if (backBuffer.SubmitCmdBuffer) + { + backBuffer.SubmitCmdBuffer->Wait(); + backBuffer.SubmitCmdBuffer = nullptr; + } + } } bool GPUSwapChainVulkan::Resize(int32 width, int32 height)