Skip to content

Commit

Permalink
rtx-hdr: force RTX HDR to activate
Browse files Browse the repository at this point in the history
  • Loading branch information
emoose committed Jan 26, 2024
1 parent 35ff723 commit d10e68f
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
50 changes: 50 additions & 0 deletions Source/D3D11VP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ HRESULT CD3D11VP::InitVideoProcessor(
// other
m_pVideoContext->VideoProcessorSetOutputTargetRect(m_pVideoProcessor, FALSE, nullptr);
m_pVideoContext->VideoProcessorSetStreamRotation(m_pVideoProcessor, 0, m_Rotation ? TRUE : FALSE, m_Rotation);
SetRtxHdrNvidia(true);

m_srcFormat = inputFmt;
m_srcWidth = width;
Expand Down Expand Up @@ -696,6 +697,55 @@ HRESULT CD3D11VP::SetSuperResNvidia(const bool enable)
return hr;
}

HRESULT CD3D11VP::SetRtxHdrNvidia(const bool enable)
{
constexpr GUID kNvidiaTrueHDRInterfaceGUID = {
0xfdd62bb4,
0x620b,
0x4fd7,
{0x9a, 0xb3, 0x1e, 0x59, 0xd0, 0xd5, 0x44, 0xb3}
};
constexpr UINT kStreamExtensionVersionV4 = 0x4;
constexpr UINT kStreamExtensionMethodTrueHDR = 0x3;

struct {
UINT version;
UINT method;
UINT enable : 1;
UINT reserved : 31;
}
stream_extension_info = {
kStreamExtensionVersionV4,
kStreamExtensionMethodTrueHDR,
enable ? 1u : 0u,
0u
};

HRESULT hr;

UINT driver_supports_true_hdr = 0;
hr = m_pVideoContext->VideoProcessorGetStreamExtension(
m_pVideoProcessor, 0, &kNvidiaTrueHDRInterfaceGUID,
sizeof(driver_supports_true_hdr), &driver_supports_true_hdr);

if (FAILED(hr)) {
return S_FALSE;
}
if (driver_supports_true_hdr != 1) {
return S_FALSE;
}

hr = m_pVideoContext->VideoProcessorSetStreamExtension(
m_pVideoProcessor, 0, &kNvidiaTrueHDRInterfaceGUID,
sizeof(stream_extension_info), &stream_extension_info);

if (hr == S_OK && !enable) {
return S_FALSE;
}

return hr;
}

HRESULT CD3D11VP::SetSuperResIntel(const bool enable)
{
constexpr GUID GUID_INTEL_VPE_INTERFACE = {
Expand Down
1 change: 1 addition & 0 deletions Source/D3D11VP.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ class CD3D11VP
HRESULT SetSuperResIntel(const bool enable);
public:
HRESULT SetSuperRes(const int iSuperRes);
HRESULT SetRtxHdrNvidia(const bool enable);

HRESULT Process(ID3D11Texture2D* pRenderTarget, const D3D11_VIDEO_FRAME_FORMAT sampleFormat, const bool second);
};
4 changes: 2 additions & 2 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 && SourceIsHDR();
const auto bHdrOutput = m_bHdrPassthroughSupport && m_bHdrPassthrough;
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 bHdrPassthrough = m_bHdrDisplayModeEnabled && SourceIsPQorHLG();
const bool bHdrPassthrough = m_bHdrDisplayModeEnabled;
m_D3D11OutputFmt = m_InternalTexFmt;
HRESULT hr = m_D3D11VP.InitVideoProcessor(dxgiFormat, width, height, m_srcExFmt, m_bInterlaced, bHdrPassthrough, m_D3D11OutputFmt);
if (FAILED(hr)) {
Expand Down

0 comments on commit d10e68f

Please sign in to comment.