[util] Rework tearFree as a Tristate

PR #1606.
This commit is contained in:
DadSchoorse 2020-05-02 10:18:13 +02:00 committed by GitHub
parent c9dde91760
commit 9b602ef850
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 26 additions and 10 deletions

View File

@ -69,14 +69,21 @@
# d3d9.presentInterval = -1
# Enables the mailbox present mode in case regular Vsync is disabled.
# True 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.
# to work properly.
#
# Supported values: True, False
# 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: Auto, True, False
# dxgi.tearFree = False
# dxgi.tearFree = Auto
# d3d9.tearFree = Auto
# Performs range check on dynamically indexed constant buffers in shaders.

View File

@ -19,7 +19,7 @@ namespace dxvk {
this->numBackBuffers = config.getOption<int32_t>("dxgi.numBackBuffers", 0);
this->maxFrameLatency = config.getOption<int32_t>("dxgi.maxFrameLatency", 0);
this->syncInterval = config.getOption<int32_t>("dxgi.syncInterval", -1);
this->tearFree = config.getOption<bool>("dxgi.tearFree", false);
this->tearFree = config.getOption<Tristate>("dxgi.tearFree", Tristate::Auto);
this->constantBufferRangeCheck = config.getOption<bool>("d3d11.constantBufferRangeCheck", false)
&& DxvkGpuVendor(devInfo.core.properties.vendorID) != DxvkGpuVendor::Amd;

View File

@ -73,7 +73,8 @@ namespace dxvk {
int32_t syncInterval;
/// Tear-free mode if vsync is disabled
bool tearFree;
/// 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.

View File

@ -850,12 +850,13 @@ namespace dxvk {
uint32_t n = 0;
if (Vsync) {
if (m_parent->GetOptions()->tearFree == Tristate::False)
pDstModes[n++] = VK_PRESENT_MODE_FIFO_RELAXED_KHR;
pDstModes[n++] = VK_PRESENT_MODE_FIFO_KHR;
} else {
if (!m_parent->GetOptions()->tearFree)
if (m_parent->GetOptions()->tearFree != Tristate::True)
pDstModes[n++] = VK_PRESENT_MODE_IMMEDIATE_KHR;
pDstModes[n++] = VK_PRESENT_MODE_MAILBOX_KHR;
pDstModes[n++] = VK_PRESENT_MODE_FIFO_RELAXED_KHR;
}
return n;

View File

@ -70,6 +70,7 @@ namespace dxvk {
this->allowDiscard = config.getOption<bool> ("d3d9.allowDiscard", true);
this->enumerateByDisplays = config.getOption<bool> ("d3d9.enumerateByDisplays", true);
this->longMad = config.getOption<bool> ("d3d9.longMad", false);
this->tearFree = config.getOption<Tristate> ("d3d9.tearFree", Tristate::Auto);
// If we are not Nvidia, enable general hazards.
this->generalHazards = adapter == nullptr || !adapter->matchesDriver(DxvkGpuVendor::Nvidia, VK_DRIVER_ID_NVIDIA_PROPRIETARY_KHR, 0, 0);

View File

@ -143,6 +143,10 @@ 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
/// Tearing mode if vsync is enabled
Tristate tearFree;
};
}

View File

@ -1362,11 +1362,13 @@ namespace dxvk {
uint32_t n = 0;
if (Vsync) {
if (m_parent->GetOptions()->tearFree == Tristate::False)
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 != Tristate::True)
pDstModes[n++] = VK_PRESENT_MODE_IMMEDIATE_KHR;
pDstModes[n++] = VK_PRESENT_MODE_MAILBOX_KHR;
pDstModes[n++] = VK_PRESENT_MODE_FIFO_RELAXED_KHR;
}
return n;