Skip to content

Commit

Permalink
rtx-hdr: reinit with autohdr disabled if SetRtxHdrNvidia failed
Browse files Browse the repository at this point in the history
  • Loading branch information
emoose committed Jan 27, 2024
1 parent da9debb commit 0194d76
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
19 changes: 15 additions & 4 deletions Source/DX11VideoProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1310,7 +1310,7 @@ HRESULT CDX11VideoProcessor::InitSwapChain()
}
}

const auto bHdrOutput = m_bHdrPassthroughSupport && m_bHdrPassthrough;
const auto bHdrOutput = m_bHdrPassthroughSupport && m_bHdrPassthrough && (SourceIsHDR() || m_bVPUseAutoHDR);
const auto b10BitOutput = bHdrOutput || Preferred10BitOutput();
m_SwapChainFmt = b10BitOutput ? DXGI_FORMAT_R10G10B10A2_UNORM : DXGI_FORMAT_B8G8R8A8_UNORM;

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

m_TexSrcVideo.Release();

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

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

if (!SourceIsHDR()) {
// Only enable RTX HDR if it's HDR display & we're playing an 8-bit format
m_D3D11VP.SetRtxHdrNvidia(true);
if (m_bVPUseAutoHDR) {
hr = m_D3D11VP.SetRtxHdrNvidia(true);
if (hr != S_OK) {
m_bVPUseAutoHDR = false;

// reinit swapchain & VP with autohdr now disabled
ReleaseSwapChain();
Init(m_hWnd);

return InitializeD3D11VP(params, width, height);
}
}

m_bVPUseSuperRes = (m_D3D11VP.SetSuperRes(m_bVPScaling ? m_iVPSuperRes : 0) == S_OK);
}

Expand Down
1 change: 1 addition & 0 deletions Source/DX11VideoProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class CDX11VideoProcessor

int m_iVPSuperRes = 0;
bool m_bVPUseSuperRes = false; // but it is not exactly
bool m_bVPUseAutoHDR = true;

bool m_bHdrPassthroughSupport = false;
bool m_bHdrDisplaySwitching = false; // switching HDR display in progress
Expand Down

0 comments on commit 0194d76

Please sign in to comment.