From 7c9bedba52fcc8a1a1a6db43ac00e9cdbb214954 Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Mon, 20 Apr 2020 15:33:37 +0200 Subject: [PATCH] Add option to enforce relaxed fifo present mode also mirrors tearFree for d3d9 --- dxvk.conf | 12 +++++++++++- src/d3d11/d3d11_options.cpp | 3 ++- src/d3d11/d3d11_options.h | 5 ++++- src/d3d11/d3d11_swapchain.cpp | 6 ++++-- src/d3d9/d3d9_options.cpp | 4 +++- src/d3d9/d3d9_options.h | 8 +++++++- src/d3d9/d3d9_swapchain.cpp | 9 ++++++--- 7 files changed, 37 insertions(+), 10 deletions(-) diff --git a/dxvk.conf b/dxvk.conf index 025848d7db3..ae946842731 100644 --- a/dxvk.conf +++ b/dxvk.conf @@ -77,7 +77,17 @@ # Supported values: True, False # dxgi.tearFree = False +# d3d9.tearFree = False +# Enables the relaxed fifo present mode in case regular Vsync is enabled. +# This should result in tearing but reduce stutter if FPS are too low, +# but may be unsupported on some systems. +# Please do not report issues with this option. +# +# Supported values: True, False + +# dxgi.forceTear = False +# d3d9.forceTear = 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 @@ -324,4 +334,4 @@ # Supported values: # - True/False -# d3d9.longMad = False \ No newline at end of file +# d3d9.longMad = False diff --git a/src/d3d11/d3d11_options.cpp b/src/d3d11/d3d11_options.cpp index 2ae15276114..4ad6281b776 100644 --- a/src/d3d11/d3d11_options.cpp +++ b/src/d3d11/d3d11_options.cpp @@ -20,6 +20,7 @@ namespace dxvk { this->maxFrameLatency = config.getOption("dxgi.maxFrameLatency", 0); this->syncInterval = config.getOption("dxgi.syncInterval", -1); this->tearFree = config.getOption("dxgi.tearFree", false); + this->forceTear = config.getOption("dxgi.forceTear", false); this->constantBufferRangeCheck = config.getOption("d3d11.constantBufferRangeCheck", false) && DxvkGpuVendor(devInfo.core.properties.vendorID) != DxvkGpuVendor::Amd; @@ -37,4 +38,4 @@ namespace dxvk { Logger::warn("D3D11: Apitrace mode enabled, may affect performance!"); } -} \ No newline at end of file +} diff --git a/src/d3d11/d3d11_options.h b/src/d3d11/d3d11_options.h index 13f97b8103d..82bf9ec2619 100644 --- a/src/d3d11/d3d11_options.h +++ b/src/d3d11/d3d11_options.h @@ -75,6 +75,9 @@ namespace dxvk { /// Tear-free mode if vsync is disabled bool tearFree; + /// Tearing if vsync is enabled + bool forceTear; + /// Override maximum frame latency if the app specifies /// a higher value. May help with frame timing issues. int32_t maxFrameLatency; @@ -89,4 +92,4 @@ namespace dxvk { bool apitraceMode; }; -} \ No newline at end of file +} diff --git a/src/d3d11/d3d11_swapchain.cpp b/src/d3d11/d3d11_swapchain.cpp index d12a251c457..6cce33d3331 100644 --- a/src/d3d11/d3d11_swapchain.cpp +++ b/src/d3d11/d3d11_swapchain.cpp @@ -848,12 +848,14 @@ namespace dxvk { uint32_t n = 0; if (Vsync) { + if (m_parent->GetOptions()->forceTear) + pDstModes[n++] = VK_PRESENT_MODE_FIFO_RELAXED_KHR; pDstModes[n++] = VK_PRESENT_MODE_FIFO_KHR; } else { 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; + pDstModes[n++] = VK_PRESENT_MODE_IMMEDIATE_KHR; } return n; @@ -887,4 +889,4 @@ namespace dxvk { return str::format("D3D", apiVersion, " FL", flHi, "_", flLo); } -} \ No newline at end of file +} diff --git a/src/d3d9/d3d9_options.cpp b/src/d3d9/d3d9_options.cpp index 939f4f4b398..6abf90c6148 100644 --- a/src/d3d9/d3d9_options.cpp +++ b/src/d3d9/d3d9_options.cpp @@ -64,6 +64,8 @@ namespace dxvk { this->enableDialogMode = config.getOption ("d3d9.enableDialogMode", false); this->forceSamplerTypeSpecConstants = config.getOption ("d3d9.forceSamplerTypeSpecConstants", false); this->forceSwapchainMSAA = config.getOption ("d3d9.forceSwapchainMSAA", -1); + this->tearFree = config.getOption ("d3d9.tearFree", false); + this->forceTear = config.getOption ("d3d9.forceTear", false); this->forceAspectRatio = config.getOption("d3d9.forceAspectRatio", ""); this->allowDoNotWait = config.getOption ("d3d9.allowDoNotWait", true); @@ -80,4 +82,4 @@ namespace dxvk { applyTristate(this->d3d9FloatEmulation, config.getOption("d3d9.floatEmulation", Tristate::Auto)); } -} \ No newline at end of file +} diff --git a/src/d3d9/d3d9_options.h b/src/d3d9/d3d9_options.h index b5742f9cb46..8044f7644a7 100644 --- a/src/d3d9/d3d9_options.h +++ b/src/d3d9/d3d9_options.h @@ -143,6 +143,12 @@ namespace dxvk { /// This solves some rendering bugs in games that have z-pass shaders which /// don't match entirely to the regular vertex shader in this way. bool longMad; + + /// Tear-free mode if vsync is disabled + bool tearFree; + + /// Tearing if vsync is enabled + bool forceTear; }; -} \ No newline at end of file +} diff --git a/src/d3d9/d3d9_swapchain.cpp b/src/d3d9/d3d9_swapchain.cpp index 5fa24565bc3..bab4ee870ca 100644 --- a/src/d3d9/d3d9_swapchain.cpp +++ b/src/d3d9/d3d9_swapchain.cpp @@ -1362,11 +1362,14 @@ namespace dxvk { uint32_t n = 0; if (Vsync) { + if (m_parent->GetOptions()->forceTear) + pDstModes[n++] = VK_PRESENT_MODE_FIFO_RELAXED_KHR; 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; + pDstModes[n++] = VK_PRESENT_MODE_IMMEDIATE_KHR; } return n; @@ -1555,4 +1558,4 @@ namespace dxvk { return this->GetParent()->IsExtended() ? "D3D9Ex" : "D3D9"; } -} \ No newline at end of file +}