1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-31 14:52:11 +01:00

[d3d9] Limit frame rate to display refresh as necessary

This commit is contained in:
Philip Rebohle 2024-06-06 10:44:20 +02:00 committed by Philip Rebohle
parent 1c198dcd48
commit 5674abe483
2 changed files with 14 additions and 1 deletions

View File

@ -191,6 +191,7 @@ namespace dxvk {
if (!m_wctx->presenter->hasSwapChain())
return D3D_OK;
UpdateTargetFrameRate(presentInterval);
PresentImage(presentInterval);
return D3D_OK;
} catch (const DxvkError& e) {
@ -927,7 +928,6 @@ namespace dxvk {
presenterDesc.fullScreenExclusive = PickFullscreenMode();
m_wctx->presenter = new Presenter(m_device, m_wctx->frameLatencySignal, presenterDesc);
m_wctx->presenter->setFrameRateLimit(m_parent->GetOptions()->maxFrameRate);
}
@ -1107,6 +1107,17 @@ namespace dxvk {
}
void D3D9SwapChainEx::UpdateTargetFrameRate(uint32_t SyncInterval) {
double frameRateOption = double(m_parent->GetOptions()->maxFrameRate);
double frameRate = std::max(frameRateOption, 0.0);
if (SyncInterval && frameRateOption == 0.0)
frameRate = -m_displayRefreshRate / double(SyncInterval);
m_wctx->presenter->setFrameRateLimit(frameRate);
}
void D3D9SwapChainEx::SyncFrameLatency() {
// Wait for the sync event so that we respect the maximum frame latency
m_wctx->frameLatencySignal->wait(m_wctx->frameId - GetActualFrameLatency());

View File

@ -213,6 +213,8 @@ namespace dxvk {
void InitRamp();
void UpdateTargetFrameRate(uint32_t SyncInterval);
uint32_t GetActualFrameLatency();
uint32_t PickFormats(