diff --git a/src/d3d11/d3d11_swapchain.cpp b/src/d3d11/d3d11_swapchain.cpp index ba51400d..92af2fd3 100644 --- a/src/d3d11/d3d11_swapchain.cpp +++ b/src/d3d11/d3d11_swapchain.cpp @@ -336,9 +336,6 @@ namespace dxvk { immediateContext->EndFrame(); immediateContext->Flush(); - // Bump our frame id. - ++m_frameId; - for (uint32_t i = 0; i < SyncInterval || i < 1; i++) { SynchronizePresent(); @@ -380,9 +377,6 @@ namespace dxvk { if (m_hud != nullptr) m_hud->render(m_context, info.format, info.imageExtent); - if (i + 1 >= SyncInterval) - m_context->signal(m_frameLatencySignal, m_frameId); - SubmitPresent(immediateContext, sync, i); } @@ -394,27 +388,35 @@ namespace dxvk { void D3D11SwapChain::SubmitPresent( D3D11ImmediateContext* pContext, const PresenterSync& Sync, - uint32_t FrameId) { + uint32_t Repeat) { auto lock = pContext->LockContext(); + // Bump frame ID as necessary + if (!Repeat) + m_frameId += 1; + // Present from CS thread so that we don't // have to synchronize with it first. m_presentStatus.result = VK_NOT_READY; pContext->EmitCs([this, - cFrameId = FrameId, + cRepeat = Repeat, cSync = Sync, cHud = m_hud, cPresentMode = m_presenter->info().presentMode, + cFrameId = m_frameId, cCommandList = m_context->endRecording() ] (DxvkContext* ctx) { cCommandList->setWsiSemaphores(cSync); m_device->submitCommandList(cCommandList, nullptr); - if (cHud != nullptr && !cFrameId) + if (cHud != nullptr && !cRepeat) cHud->update(); - m_device->presentImage(m_presenter, cPresentMode, 0, &m_presentStatus); + uint64_t frameId = cRepeat ? 0 : cFrameId; + + m_device->presentImage(m_presenter, + cPresentMode, frameId, &m_presentStatus); }); pContext->FlushCsChunk(); @@ -479,7 +481,7 @@ namespace dxvk { presenterDesc.numFormats = PickFormats(m_desc.Format, presenterDesc.formats); presenterDesc.fullScreenExclusive = PickFullscreenMode(); - m_presenter = new Presenter(m_device, nullptr, presenterDesc); + m_presenter = new Presenter(m_device, m_frameLatencySignal, presenterDesc); m_presenter->setFrameRateLimit(m_parent->GetOptions()->maxFrameRate); } diff --git a/src/d3d11/d3d11_swapchain.h b/src/d3d11/d3d11_swapchain.h index 1e0ba4a0..4ff3cde2 100644 --- a/src/d3d11/d3d11_swapchain.h +++ b/src/d3d11/d3d11_swapchain.h @@ -130,7 +130,7 @@ namespace dxvk { void SubmitPresent( D3D11ImmediateContext* pContext, const PresenterSync& Sync, - uint32_t FrameId); + uint32_t Repeat); void SynchronizePresent();