From 4d8940957cb40fbd1be3eb6cc74d1677d3e352d4 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Sun, 12 Apr 2020 20:25:20 +0200 Subject: [PATCH] [d3d11] Add option to enforce mailbox present mode --- dxvk.conf | 10 ++++++++++ src/d3d11/d3d11_options.cpp | 1 + src/d3d11/d3d11_options.h | 3 +++ src/d3d11/d3d11_swapchain.cpp | 3 ++- 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/dxvk.conf b/dxvk.conf index 1b5d8b50..025848d7 100644 --- a/dxvk.conf +++ b/dxvk.conf @@ -69,6 +69,16 @@ # d3d9.presentInterval = -1 +# Enables the mailbox present mode in case regular Vsync is disabled. +# This should avoid tearing, but may be unsupported on some systems +# or require setting dxgi.numBackBuffers to a higher value in order +# to work properly. Please do not report issues with this option. +# +# Supported values: True, False + +# dxgi.tearFree = False + + # Performs range check on dynamically indexed constant buffers in shaders. # This may be needed to work around a certain type of game bug, but may # also introduce incorrect behaviour. diff --git a/src/d3d11/d3d11_options.cpp b/src/d3d11/d3d11_options.cpp index cba4cf32..2ae15276 100644 --- a/src/d3d11/d3d11_options.cpp +++ b/src/d3d11/d3d11_options.cpp @@ -19,6 +19,7 @@ namespace dxvk { this->numBackBuffers = config.getOption("dxgi.numBackBuffers", 0); this->maxFrameLatency = config.getOption("dxgi.maxFrameLatency", 0); this->syncInterval = config.getOption("dxgi.syncInterval", -1); + this->tearFree = config.getOption("dxgi.tearFree", false); this->constantBufferRangeCheck = config.getOption("d3d11.constantBufferRangeCheck", false) && DxvkGpuVendor(devInfo.core.properties.vendorID) != DxvkGpuVendor::Amd; diff --git a/src/d3d11/d3d11_options.h b/src/d3d11/d3d11_options.h index e59b3c47..13f97b81 100644 --- a/src/d3d11/d3d11_options.h +++ b/src/d3d11/d3d11_options.h @@ -72,6 +72,9 @@ namespace dxvk { /// passed to IDXGISwapChain::Present. int32_t syncInterval; + /// Tear-free mode if vsync is disabled + bool 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/d3d11/d3d11_swapchain.cpp b/src/d3d11/d3d11_swapchain.cpp index 686f87d9..d12a251c 100644 --- a/src/d3d11/d3d11_swapchain.cpp +++ b/src/d3d11/d3d11_swapchain.cpp @@ -850,7 +850,8 @@ namespace dxvk { if (Vsync) { pDstModes[n++] = VK_PRESENT_MODE_FIFO_KHR; } else { - pDstModes[n++] = VK_PRESENT_MODE_IMMEDIATE_KHR; + if (!m_parent->GetOptions()->tearFree) + pDstModes[n++] = VK_PRESENT_MODE_IMMEDIATE_KHR; pDstModes[n++] = VK_PRESENT_MODE_MAILBOX_KHR; pDstModes[n++] = VK_PRESENT_MODE_FIFO_RELAXED_KHR; }