Skip to content

Commit 0194d76

Browse files
committed
rtx-hdr: reinit with autohdr disabled if SetRtxHdrNvidia failed
1 parent da9debb commit 0194d76

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

Source/DX11VideoProcessor.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,7 +1310,7 @@ HRESULT CDX11VideoProcessor::InitSwapChain()
13101310
}
13111311
}
13121312

1313-
const auto bHdrOutput = m_bHdrPassthroughSupport && m_bHdrPassthrough;
1313+
const auto bHdrOutput = m_bHdrPassthroughSupport && m_bHdrPassthrough && (SourceIsHDR() || m_bVPUseAutoHDR);
13141314
const auto b10BitOutput = bHdrOutput || Preferred10BitOutput();
13151315
m_SwapChainFmt = b10BitOutput ? DXGI_FORMAT_R10G10B10A2_UNORM : DXGI_FORMAT_B8G8R8A8_UNORM;
13161316

@@ -1741,7 +1741,7 @@ HRESULT CDX11VideoProcessor::InitializeD3D11VP(const FmtConvParams_t& params, co
17411741

17421742
m_TexSrcVideo.Release();
17431743

1744-
const bool bHdrWillAutoHDRUpconvert = m_bHdrDisplayModeEnabled && params.CDepth <= 8; // TODO: add check if autoHDR is available here...
1744+
const bool bHdrWillAutoHDRUpconvert = m_bHdrDisplayModeEnabled && m_bVPUseAutoHDR && params.CDepth <= 8;
17451745

17461746
const bool bHdrPassthrough = m_bHdrDisplayModeEnabled && (SourceIsPQorHLG() || bHdrWillAutoHDRUpconvert);
17471747
m_D3D11OutputFmt = m_InternalTexFmt;
@@ -1758,8 +1758,19 @@ HRESULT CDX11VideoProcessor::InitializeD3D11VP(const FmtConvParams_t& params, co
17581758
}
17591759

17601760
if (!SourceIsHDR()) {
1761-
// Only enable RTX HDR if it's HDR display & we're playing an 8-bit format
1762-
m_D3D11VP.SetRtxHdrNvidia(true);
1761+
if (m_bVPUseAutoHDR) {
1762+
hr = m_D3D11VP.SetRtxHdrNvidia(true);
1763+
if (hr != S_OK) {
1764+
m_bVPUseAutoHDR = false;
1765+
1766+
// reinit swapchain & VP with autohdr now disabled
1767+
ReleaseSwapChain();
1768+
Init(m_hWnd);
1769+
1770+
return InitializeD3D11VP(params, width, height);
1771+
}
1772+
}
1773+
17631774
m_bVPUseSuperRes = (m_D3D11VP.SetSuperRes(m_bVPScaling ? m_iVPSuperRes : 0) == S_OK);
17641775
}
17651776

Source/DX11VideoProcessor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ class CDX11VideoProcessor
151151

152152
int m_iVPSuperRes = 0;
153153
bool m_bVPUseSuperRes = false; // but it is not exactly
154+
bool m_bVPUseAutoHDR = true;
154155

155156
bool m_bHdrPassthroughSupport = false;
156157
bool m_bHdrDisplaySwitching = false; // switching HDR display in progress

0 commit comments

Comments
 (0)