Skip to content

Commit a684e0a

Browse files
committed
CD3D11VP::SetSuperRes: allows enabling NVIDIA/Intel superres
1 parent e02eecc commit a684e0a

File tree

3 files changed

+110
-0
lines changed

3 files changed

+110
-0
lines changed

Source/D3D11VP.cpp

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,101 @@ void CD3D11VP::GetVPParams(D3D11_VIDEO_PROCESSOR_CAPS& caps, UINT& rateConvIndex
428428
rateConvCaps = m_RateConvCaps;
429429
}
430430

431+
HRESULT CD3D11VP::SetSuperRes(const int iType)
432+
{
433+
// This func calls into both Intel & NV functions, so that we can tell Intel to disable itself if only NV was picked, or vice-versa
434+
435+
// Intel VP SuperRes
436+
HRESULT hr;
437+
{
438+
constexpr GUID GUID_INTEL_VPE_INTERFACE = {
439+
0xedd1d4b9,
440+
0x8659,
441+
0x4cbc,
442+
{0xa4, 0xd6, 0x98, 0x31, 0xa2, 0x16, 0x3a, 0xc3} };
443+
444+
enum : UINT {
445+
kIntelVpeFnVersion = 0x01,
446+
kIntelVpeFnMode = 0x20,
447+
kIntelVpeFnScaling = 0x37,
448+
};
449+
450+
enum : UINT {
451+
kIntelVpeVersion3 = 0x0003,
452+
};
453+
454+
enum : UINT {
455+
kIntelVpeModeNone = 0x0,
456+
kIntelVpeModePreproc = 0x01,
457+
};
458+
459+
enum : UINT {
460+
kIntelVpeScalingDefault = 0x0,
461+
kIntelVpeScalingSuperResolution = 0x2,
462+
};
463+
464+
struct IntelVpeExt {
465+
UINT function;
466+
void* param;
467+
};
468+
469+
IntelVpeExt ext = {};
470+
UINT param = 0;
471+
ext.param = &param;
472+
473+
ext.function = kIntelVpeFnVersion;
474+
param = kIntelVpeVersion3;
475+
hr = m_pVideoContext->VideoProcessorSetOutputExtension(
476+
m_pVideoProcessor, &GUID_INTEL_VPE_INTERFACE, sizeof(ext), &ext);
477+
if (!SUCCEEDED(hr)) {
478+
return hr;
479+
}
480+
481+
ext.function = kIntelVpeFnMode;
482+
param = (iType == SUPERRES_Intel) ? kIntelVpeModePreproc : kIntelVpeModeNone;
483+
hr = m_pVideoContext->VideoProcessorSetOutputExtension(
484+
m_pVideoProcessor, &GUID_INTEL_VPE_INTERFACE, sizeof(ext), &ext);
485+
if (!SUCCEEDED(hr)) {
486+
return hr;
487+
}
488+
489+
ext.function = kIntelVpeFnScaling;
490+
param = (iType == SUPERRES_Intel) ? kIntelVpeScalingSuperResolution : kIntelVpeScalingDefault;
491+
492+
hr = m_pVideoContext->VideoProcessorSetStreamExtension(
493+
m_pVideoProcessor, 0, &GUID_INTEL_VPE_INTERFACE, sizeof(ext), &ext);
494+
if (!SUCCEEDED(hr)) {
495+
return hr;
496+
}
497+
}
498+
499+
// NVIDIA RTX Super Resolution
500+
{
501+
constexpr GUID kNvidiaPPEInterfaceGUID = {
502+
0xd43ce1b3,
503+
0x1f4b,
504+
0x48ac,
505+
{0xba, 0xee, 0xc3, 0xc2, 0x53, 0x75, 0xe6, 0xf7} };
506+
constexpr UINT kStreamExtensionVersionV1 = 0x1;
507+
constexpr UINT kStreamExtensionMethodSuperResolution = 0x2;
508+
509+
struct {
510+
UINT version;
511+
UINT method;
512+
UINT enable;
513+
} stream_extension_info = { kStreamExtensionVersionV1,
514+
kStreamExtensionMethodSuperResolution, iType == SUPERRES_Nvidia ? 1 : 0 };
515+
516+
hr = m_pVideoContext->VideoProcessorSetStreamExtension(m_pVideoProcessor, 0, &kNvidiaPPEInterfaceGUID,
517+
sizeof(stream_extension_info), &stream_extension_info);
518+
if (!SUCCEEDED(hr)) {
519+
return hr;
520+
}
521+
}
522+
523+
return hr;
524+
}
525+
431526
HRESULT CD3D11VP::SetRectangles(const RECT* pSrcRect, const RECT* pDstRect)
432527
{
433528
CheckPointer(m_pVideoContext, E_ABORT);

Source/D3D11VP.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@
2222

2323
#include <d3d11.h>
2424

25+
// TODO: move this somewhere better?
26+
enum :int {
27+
SUPERRES_None = 0,
28+
SUPERRES_Intel = 1,
29+
SUPERRES_Nvidia = 2
30+
};
31+
2532
class VideoTextureBuffer
2633
{
2734
private:
@@ -163,6 +170,7 @@ class CD3D11VP
163170
ID3D11Texture2D* GetNextInputTexture(const D3D11_VIDEO_FRAME_FORMAT vframeFormat);
164171
void ResetFrameOrder();
165172

173+
HRESULT SetSuperRes(const int iType);
166174
HRESULT SetRectangles(const RECT * pSrcRect, const RECT* pDstRect);
167175
HRESULT SetColorSpace(const DXVA2_ExtendedFormat exFmt, const bool bHdrPassthrough);
168176
void SetRotation(D3D11_VIDEO_PROCESSOR_ROTATION rotation);

Source/DX11VideoProcessor.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,6 +1585,13 @@ HRESULT CDX11VideoProcessor::InitializeD3D11VP(const FmtConvParams_t& params, co
15851585
return hr;
15861586
}
15871587

1588+
// TODO: SetSuperRes can enable Intel superres too, but this only calls with SUPERRES_Nvidia atm
1589+
hr = m_D3D11VP.SetSuperRes(SUPERRES_Nvidia);
1590+
if (FAILED(hr)) {
1591+
DLog(L"CDX11VideoProcessor::InitializeD3D11VP() : SetSuperRes() failed with error {}", HR2Str(hr));
1592+
return hr;
1593+
}
1594+
15881595
hr = m_D3D11VP.SetColorSpace(m_srcExFmt, m_bHdrDisplayModeEnabled && SourceIsHDR());
15891596

15901597
hr = m_TexSrcVideo.Create(m_pDevice, dxgiFormat, width, height, Tex2D_DynamicShaderWriteNoSRV);

0 commit comments

Comments
 (0)