mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-31 05:52:11 +01:00
[d3d11] Sync frame latency after presentation
This commit is contained in:
parent
0fe8f2e40c
commit
f98a45b305
@ -178,9 +178,8 @@ namespace dxvk {
|
|||||||
return DXGI_ERROR_INVALID_CALL;
|
return DXGI_ERROR_INVALID_CALL;
|
||||||
|
|
||||||
m_frameLatency = MaxLatency;
|
m_frameLatency = MaxLatency;
|
||||||
m_frameLatencySignal->wait(m_frameId - GetActualFrameLatency());
|
|
||||||
|
|
||||||
SignalFrameLatencyEvent();
|
SyncFrameLatency();
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,10 +241,6 @@ namespace dxvk {
|
|||||||
auto immediateContext = static_cast<D3D11ImmediateContext*>(deviceContext.ptr());
|
auto immediateContext = static_cast<D3D11ImmediateContext*>(deviceContext.ptr());
|
||||||
immediateContext->Flush();
|
immediateContext->Flush();
|
||||||
|
|
||||||
// Wait for the sync event so that we respect the maximum frame latency
|
|
||||||
uint64_t frameId = ++m_frameId;
|
|
||||||
m_frameLatencySignal->wait(frameId - GetActualFrameLatency());
|
|
||||||
|
|
||||||
for (uint32_t i = 0; i < SyncInterval || i < 1; i++) {
|
for (uint32_t i = 0; i < SyncInterval || i < 1; i++) {
|
||||||
SynchronizePresent();
|
SynchronizePresent();
|
||||||
|
|
||||||
@ -283,12 +278,15 @@ namespace dxvk {
|
|||||||
m_hud->render(m_context, info.format, info.imageExtent);
|
m_hud->render(m_context, info.format, info.imageExtent);
|
||||||
|
|
||||||
if (i + 1 >= SyncInterval)
|
if (i + 1 >= SyncInterval)
|
||||||
m_context->signal(m_frameLatencySignal, frameId);
|
m_context->signal(m_frameLatencySignal, m_frameId);
|
||||||
|
|
||||||
SubmitPresent(immediateContext, sync, i);
|
SubmitPresent(immediateContext, sync, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
SignalFrameLatencyEvent();
|
// Bump our frame id.
|
||||||
|
++m_frameId;
|
||||||
|
|
||||||
|
SyncFrameLatency();
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -536,7 +534,10 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void D3D11SwapChain::SignalFrameLatencyEvent() {
|
void D3D11SwapChain::SyncFrameLatency() {
|
||||||
|
// Wait for the sync event so that we respect the maximum frame latency
|
||||||
|
m_frameLatencySignal->wait(m_frameId - GetActualFrameLatency());
|
||||||
|
|
||||||
if (m_frameLatencyEvent) {
|
if (m_frameLatencyEvent) {
|
||||||
// Signal event with the same value that we'd wait for during the next present.
|
// Signal event with the same value that we'd wait for during the next present.
|
||||||
m_frameLatencySignal->setEvent(m_frameLatencyEvent, m_frameId - GetActualFrameLatency() + 1);
|
m_frameLatencySignal->setEvent(m_frameLatencyEvent, m_frameId - GetActualFrameLatency() + 1);
|
||||||
|
@ -134,7 +134,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
void DestroyFrameLatencyEvent();
|
void DestroyFrameLatencyEvent();
|
||||||
|
|
||||||
void SignalFrameLatencyEvent();
|
void SyncFrameLatency();
|
||||||
|
|
||||||
uint32_t GetActualFrameLatency();
|
uint32_t GetActualFrameLatency();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user