Skip to content

Commit

Permalink
Fix edge-case that was leaving tearing enabled while DLSS3 Frame Gene…
Browse files Browse the repository at this point in the history
…ration is active on a VRR display
  • Loading branch information
Kaldaien committed Sep 18, 2024
1 parent ed4991a commit d47e407
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/render/dxgi/dxgi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2373,6 +2373,12 @@ SK_DXGI_PresentBase ( IDXGISwapChain *This,
SK_RenderBackend& rb =
SK_GetCurrentRenderBackend ();

const auto& display =
rb.displays [rb.active_display];

const bool bDLSS3OnVRRDisplay =
(__SK_IsDLSSGActive && display.nvapi.vrr_enabled);

auto _Present = [&](UINT _SyncInterval,
UINT _Flags) ->
HRESULT
Expand All @@ -2381,7 +2387,7 @@ SK_DXGI_PresentBase ( IDXGISwapChain *This,
config.render.framerate.target_fps_bg < rb.getActiveRefreshRate () / 2.0f &&
(! SK_IsGameWindowActive ()) )
{
if ( SK_GetFramesDrawn () > 30 && rb.displays [rb.active_display].nvapi.vrr_enabled &&
if ( SK_GetFramesDrawn () > 30 && display.nvapi.vrr_enabled &&
( config.window.background_render ||
config.window.always_on_top == SmartAlwaysOnTop ) )
{
Expand Down Expand Up @@ -2448,7 +2454,7 @@ SK_DXGI_PresentBase ( IDXGISwapChain *This,
}

// Turn tearing off when using frame generation
if (__SK_IsDLSSGActive && rb.displays [rb.active_display].nvapi.vrr_enabled)
if (bDLSS3OnVRRDisplay)
{
_Flags &= ~DXGI_PRESENT_ALLOW_TEARING;
_SyncInterval = 0;
Expand Down Expand Up @@ -2476,7 +2482,7 @@ SK_DXGI_PresentBase ( IDXGISwapChain *This,
_d3d12_rbk->release (This);
}

if ( ret != S_OK && (! rb.active_traits.bOriginallyFlip) && SK_GetCurrentRenderBackend ().api != SK_RenderAPI::D3D12 )
if ( ret != S_OK && (! rb.active_traits.bOriginallyFlip) && rb.api != SK_RenderAPI::D3D12 )
{
// This would recurse infinitely without the ghetto lock
//
Expand Down Expand Up @@ -2588,8 +2594,8 @@ SK_DXGI_PresentBase ( IDXGISwapChain *This,
);
};

if (! config.render.dxgi.allow_tearing)
{
if ((! config.render.dxgi.allow_tearing) || bDLSS3OnVRRDisplay)
{ // Turn tearing off when using frame generation
if (Flags & DXGI_PRESENT_ALLOW_TEARING)
{
SK_RunOnce (
Expand All @@ -2598,6 +2604,11 @@ SK_DXGI_PresentBase ( IDXGISwapChain *This,

Flags &= ~DXGI_PRESENT_ALLOW_TEARING;
}

if (bDLSS3OnVRRDisplay)
{
SyncInterval = 0;
}
}

//
Expand Down

0 comments on commit d47e407

Please sign in to comment.