1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-04 16:24:29 +01:00

[d3d11] Use new presenter signal mechanism for frame latency event

This commit is contained in:
Philip Rebohle 2023-06-15 17:09:08 +02:00
parent 08363edb05
commit e99bc591df
2 changed files with 14 additions and 12 deletions

View File

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

View File

@ -130,7 +130,7 @@ namespace dxvk {
void SubmitPresent( void SubmitPresent(
D3D11ImmediateContext* pContext, D3D11ImmediateContext* pContext,
const PresenterSync& Sync, const PresenterSync& Sync,
uint32_t FrameId); uint32_t Repeat);
void SynchronizePresent(); void SynchronizePresent();