From 8b67ef724e5bd7b59dbfd497b84794a9fe33dcca Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Wed, 9 Jun 2021 03:46:12 +0200 Subject: [PATCH] [d3d11] Add frame rate limiter and dxgi.maxFrameRate option --- dxvk.conf | 1 + src/d3d11/d3d11_options.cpp | 1 + src/d3d11/d3d11_options.h | 3 +++ src/d3d11/d3d11_swapchain.cpp | 3 +++ src/d3d11/d3d11_swapchain.h | 2 ++ 5 files changed, 10 insertions(+) diff --git a/dxvk.conf b/dxvk.conf index 349dc944..332c88c4 100644 --- a/dxvk.conf +++ b/dxvk.conf @@ -24,6 +24,7 @@ # # Supported values : Any non-negative integer +# dxgi.maxFrameRate = 0 # d3d9.maxFrameRate = 0 diff --git a/src/d3d11/d3d11_options.cpp b/src/d3d11/d3d11_options.cpp index b807a2d1..558829d6 100644 --- a/src/d3d11/d3d11_options.cpp +++ b/src/d3d11/d3d11_options.cpp @@ -19,6 +19,7 @@ namespace dxvk { this->deferSurfaceCreation = config.getOption("dxgi.deferSurfaceCreation", false); this->numBackBuffers = config.getOption("dxgi.numBackBuffers", 0); this->maxFrameLatency = config.getOption("dxgi.maxFrameLatency", 0); + this->maxFrameRate = config.getOption("dxgi.maxFrameRate", 0); this->syncInterval = config.getOption("dxgi.syncInterval", -1); this->tearFree = config.getOption("dxgi.tearFree", Tristate::Auto); diff --git a/src/d3d11/d3d11_options.h b/src/d3d11/d3d11_options.h index 2949ca3d..a948aa0a 100644 --- a/src/d3d11/d3d11_options.h +++ b/src/d3d11/d3d11_options.h @@ -83,6 +83,9 @@ namespace dxvk { /// a higher value. May help with frame timing issues. int32_t maxFrameLatency; + /// Limit frame rate + int32_t maxFrameRate; + /// Defer surface creation until first present call. This /// fixes issues with games that create multiple swap chains /// for a single window that may interfere with each other. diff --git a/src/d3d11/d3d11_swapchain.cpp b/src/d3d11/d3d11_swapchain.cpp index de302a8a..a78515df 100644 --- a/src/d3d11/d3d11_swapchain.cpp +++ b/src/d3d11/d3d11_swapchain.cpp @@ -380,6 +380,9 @@ namespace dxvk { presenterDevice, presenterDesc); + m_presenter->setFrameRateLimit(m_parent->GetOptions()->maxFrameRate); + m_presenter->setFrameRateLimiterRefreshRate(m_displayRefreshRate); + CreateRenderTargetViews(); } diff --git a/src/d3d11/d3d11_swapchain.h b/src/d3d11/d3d11_swapchain.h index 944ab696..65e1f5f9 100644 --- a/src/d3d11/d3d11_swapchain.h +++ b/src/d3d11/d3d11_swapchain.h @@ -108,6 +108,8 @@ namespace dxvk { bool m_dirty = true; bool m_vsync = true; + double m_displayRefreshRate = 0.0; + HRESULT PresentImage(UINT SyncInterval); void SubmitPresent(