Skip to content

Commit

Permalink
[dxvk] Introduce dxvk.tearFree option
Browse files Browse the repository at this point in the history
And replace the old frontend-specific options.
  • Loading branch information
doitsujin committed Jun 1, 2023
1 parent 85d52cc commit ab00591
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 13 deletions.
3 changes: 1 addition & 2 deletions dxvk.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion src/d3d11/d3d11_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ namespace dxvk {
this->maxFrameLatency = config.getOption<int32_t>("dxgi.maxFrameLatency", 0);
this->maxFrameRate = config.getOption<int32_t>("dxgi.maxFrameRate", 0);
this->syncInterval = config.getOption<int32_t>("dxgi.syncInterval", -1);
this->tearFree = config.getOption<Tristate>("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);
Expand Down
4 changes: 0 additions & 4 deletions src/d3d11/d3d11_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/d3d9/d3d9_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ 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);
this->apitraceMode = config.getOption<bool> ("d3d9.apitraceMode", false);
this->deviceLocalConstantBuffers = config.getOption<bool> ("d3d9.deviceLocalConstantBuffers", false);
this->allowDirectBufferMapping = config.getOption<bool> ("d3d9.allowDirectBufferMapping", true);
Expand Down
4 changes: 0 additions & 4 deletions src/d3d9/d3d9_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions src/dxvk/dxvk_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace dxvk {
useRawSsbo = config.getOption<Tristate>("dxvk.useRawSsbo", Tristate::Auto);
maxChunkSize = config.getOption<int32_t> ("dxvk.maxChunkSize", 0);
hud = config.getOption<std::string>("dxvk.hud", "");
tearFree = config.getOption<Tristate>("dxvk.tearFree", Tristate::Auto);
}

}
4 changes: 4 additions & 0 deletions src/dxvk/dxvk_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

}
8 changes: 7 additions & 1 deletion src/dxvk/dxvk_presenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,9 +518,15 @@ namespace dxvk {
std::array<VkPresentModeKHR, 2> 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
Expand Down

0 comments on commit ab00591

Please sign in to comment.