Skip to content

Commit d10e68f

Browse files
committed
rtx-hdr: force RTX HDR to activate
1 parent 35ff723 commit d10e68f

File tree

3 files changed

+53
-2
lines changed

3 files changed

+53
-2
lines changed

Source/D3D11VP.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ HRESULT CD3D11VP::InitVideoProcessor(
377377
// other
378378
m_pVideoContext->VideoProcessorSetOutputTargetRect(m_pVideoProcessor, FALSE, nullptr);
379379
m_pVideoContext->VideoProcessorSetStreamRotation(m_pVideoProcessor, 0, m_Rotation ? TRUE : FALSE, m_Rotation);
380+
SetRtxHdrNvidia(true);
380381

381382
m_srcFormat = inputFmt;
382383
m_srcWidth = width;
@@ -696,6 +697,55 @@ HRESULT CD3D11VP::SetSuperResNvidia(const bool enable)
696697
return hr;
697698
}
698699

700+
HRESULT CD3D11VP::SetRtxHdrNvidia(const bool enable)
701+
{
702+
constexpr GUID kNvidiaTrueHDRInterfaceGUID = {
703+
0xfdd62bb4,
704+
0x620b,
705+
0x4fd7,
706+
{0x9a, 0xb3, 0x1e, 0x59, 0xd0, 0xd5, 0x44, 0xb3}
707+
};
708+
constexpr UINT kStreamExtensionVersionV4 = 0x4;
709+
constexpr UINT kStreamExtensionMethodTrueHDR = 0x3;
710+
711+
struct {
712+
UINT version;
713+
UINT method;
714+
UINT enable : 1;
715+
UINT reserved : 31;
716+
}
717+
stream_extension_info = {
718+
kStreamExtensionVersionV4,
719+
kStreamExtensionMethodTrueHDR,
720+
enable ? 1u : 0u,
721+
0u
722+
};
723+
724+
HRESULT hr;
725+
726+
UINT driver_supports_true_hdr = 0;
727+
hr = m_pVideoContext->VideoProcessorGetStreamExtension(
728+
m_pVideoProcessor, 0, &kNvidiaTrueHDRInterfaceGUID,
729+
sizeof(driver_supports_true_hdr), &driver_supports_true_hdr);
730+
731+
if (FAILED(hr)) {
732+
return S_FALSE;
733+
}
734+
if (driver_supports_true_hdr != 1) {
735+
return S_FALSE;
736+
}
737+
738+
hr = m_pVideoContext->VideoProcessorSetStreamExtension(
739+
m_pVideoProcessor, 0, &kNvidiaTrueHDRInterfaceGUID,
740+
sizeof(stream_extension_info), &stream_extension_info);
741+
742+
if (hr == S_OK && !enable) {
743+
return S_FALSE;
744+
}
745+
746+
return hr;
747+
}
748+
699749
HRESULT CD3D11VP::SetSuperResIntel(const bool enable)
700750
{
701751
constexpr GUID GUID_INTEL_VPE_INTERFACE = {

Source/D3D11VP.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ class CD3D11VP
184184
HRESULT SetSuperResIntel(const bool enable);
185185
public:
186186
HRESULT SetSuperRes(const int iSuperRes);
187+
HRESULT SetRtxHdrNvidia(const bool enable);
187188

188189
HRESULT Process(ID3D11Texture2D* pRenderTarget, const D3D11_VIDEO_FRAME_FORMAT sampleFormat, const bool second);
189190
};

Source/DX11VideoProcessor.cpp

Lines changed: 2 additions & 2 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 && SourceIsHDR();
1313+
const auto bHdrOutput = m_bHdrPassthroughSupport && m_bHdrPassthrough;
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 bHdrPassthrough = m_bHdrDisplayModeEnabled && SourceIsPQorHLG();
1744+
const bool bHdrPassthrough = m_bHdrDisplayModeEnabled;
17451745
m_D3D11OutputFmt = m_InternalTexFmt;
17461746
HRESULT hr = m_D3D11VP.InitVideoProcessor(dxgiFormat, width, height, m_srcExFmt, m_bInterlaced, bHdrPassthrough, m_D3D11OutputFmt);
17471747
if (FAILED(hr)) {

0 commit comments

Comments
 (0)