From ab00591297e60c6e03a54669c8b07ea08bdc5afb Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Wed, 31 May 2023 15:57:34 +0200 Subject: [PATCH] [dxvk] Introduce dxvk.tearFree option And replace the old frontend-specific options. --- dxvk.conf | 3 +-- src/d3d11/d3d11_options.cpp | 1 - src/d3d11/d3d11_options.h | 4 ---- src/d3d9/d3d9_options.cpp | 1 - src/d3d9/d3d9_options.h | 4 ---- src/dxvk/dxvk_options.cpp | 1 + src/dxvk/dxvk_options.h | 4 ++++ src/dxvk/dxvk_presenter.cpp | 8 +++++++- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/dxvk.conf b/dxvk.conf index f5ec17eb..4682ccd7 100644 --- a/dxvk.conf +++ b/dxvk.conf @@ -122,8 +122,7 @@ # # Supported values: Auto, True, False -# dxgi.tearFree = Auto -# d3d9.tearFree = Auto +# dxvk.tearFree = Auto # Assume single-use mode for command lists created on deferred contexts. diff --git a/src/d3d11/d3d11_options.cpp b/src/d3d11/d3d11_options.cpp index bcac396b..7c33c88b 100644 --- a/src/d3d11/d3d11_options.cpp +++ b/src/d3d11/d3d11_options.cpp @@ -31,7 +31,6 @@ namespace dxvk { 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); // Clamp LOD bias so that people don't abuse this in unintended ways this->samplerLodBias = dxvk::fclamp(this->samplerLodBias, -2.0f, 1.0f); diff --git a/src/d3d11/d3d11_options.h b/src/d3d11/d3d11_options.h index 99bca076..a0586f6b 100644 --- a/src/d3d11/d3d11_options.h +++ b/src/d3d11/d3d11_options.h @@ -77,10 +77,6 @@ namespace dxvk { /// passed to IDXGISwapChain::Present. int32_t syncInterval; - /// Tear-free mode if vsync is disabled - /// Tearing mode if vsync is enabled - Tristate tearFree; - /// Override maximum frame latency if the app specifies /// a higher value. May help with frame timing issues. int32_t maxFrameLatency; diff --git a/src/d3d9/d3d9_options.cpp b/src/d3d9/d3d9_options.cpp index 87b87828..83a23e55 100644 --- a/src/d3d9/d3d9_options.cpp +++ b/src/d3d9/d3d9_options.cpp @@ -67,7 +67,6 @@ namespace dxvk { this->allowDiscard = config.getOption ("d3d9.allowDiscard", true); this->enumerateByDisplays = config.getOption ("d3d9.enumerateByDisplays", true); this->longMad = config.getOption ("d3d9.longMad", false); - this->tearFree = config.getOption ("d3d9.tearFree", Tristate::Auto); this->apitraceMode = config.getOption ("d3d9.apitraceMode", false); this->deviceLocalConstantBuffers = config.getOption ("d3d9.deviceLocalConstantBuffers", false); this->allowDirectBufferMapping = config.getOption ("d3d9.allowDirectBufferMapping", true); diff --git a/src/d3d9/d3d9_options.h b/src/d3d9/d3d9_options.h index 13458104..923245ed 100644 --- a/src/d3d9/d3d9_options.h +++ b/src/d3d9/d3d9_options.h @@ -127,10 +127,6 @@ namespace dxvk { /// don't match entirely to the regular vertex shader in this way. bool longMad; - /// Tear-free mode if vsync is disabled - /// Tearing mode if vsync is enabled - Tristate tearFree; - /// Apitrace mode: Maps all buffers in cached memory. bool apitraceMode; diff --git a/src/dxvk/dxvk_options.cpp b/src/dxvk/dxvk_options.cpp index 373db325..9c4a8355 100644 --- a/src/dxvk/dxvk_options.cpp +++ b/src/dxvk/dxvk_options.cpp @@ -11,6 +11,7 @@ namespace dxvk { useRawSsbo = config.getOption("dxvk.useRawSsbo", Tristate::Auto); maxChunkSize = config.getOption ("dxvk.maxChunkSize", 0); hud = config.getOption("dxvk.hud", ""); + tearFree = config.getOption("dxvk.tearFree", Tristate::Auto); } } diff --git a/src/dxvk/dxvk_options.h b/src/dxvk/dxvk_options.h index fe4e903d..f367e5c6 100644 --- a/src/dxvk/dxvk_options.h +++ b/src/dxvk/dxvk_options.h @@ -32,6 +32,10 @@ namespace dxvk { /// HUD elements std::string hud; + + /// Forces swap chain into MAILBOX (if true) + /// or FIFO_RELAXED (if false) present mode + Tristate tearFree; }; } diff --git a/src/dxvk/dxvk_presenter.cpp b/src/dxvk/dxvk_presenter.cpp index b6ea8d57..6eca13de 100644 --- a/src/dxvk/dxvk_presenter.cpp +++ b/src/dxvk/dxvk_presenter.cpp @@ -518,9 +518,15 @@ namespace dxvk { std::array desired = { }; uint32_t numDesired = 0; + Tristate tearFree = m_device->config().tearFree; + if (!syncInterval) { - desired[numDesired++] = VK_PRESENT_MODE_IMMEDIATE_KHR; + if (tearFree != Tristate::True) + desired[numDesired++] = VK_PRESENT_MODE_IMMEDIATE_KHR; desired[numDesired++] = VK_PRESENT_MODE_MAILBOX_KHR; + } else { + if (tearFree == Tristate::False) + desired[numDesired++] = VK_PRESENT_MODE_FIFO_RELAXED_KHR; } // Just pick the first desired and supported mode