Skip to content

Commit

Permalink
Fix config & clean-up debug menu
Browse files Browse the repository at this point in the history
debug menu got a slight overhaul with better alignment and cleaner text.
Fixed 'superres only if upscaling' not saving properly.
  • Loading branch information
JTGaming committed Feb 11, 2024
1 parent 8d0833d commit 8fb7d0b
Show file tree
Hide file tree
Showing 9 changed files with 176 additions and 146 deletions.
34 changes: 17 additions & 17 deletions Source/D3D11VP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ HRESULT CD3D11VP::InitVideoProcessor(
if (FAILED(hr)) {
// Windows 8/8.1
DLog(L"CD3D11VP::InitVideoProcessor() : ID3D11VideoProcessorEnumerator1 unavailable");
if (exFmt.value && exFmt.VideoTransferMatrix > DXVA2_VideoTransferMatrix_BT601) {
if (exFmt.value && exFmt.VideoTransferMatrix > MFVideoTransferMatrix_BT601) {
// Win8/8.1 D3D11 VP only supports RGB, BT.601, BT.709
return E_ABORT;
}
Expand Down Expand Up @@ -515,14 +515,14 @@ HRESULT CD3D11VP::CheckColorSpaceNew(
m_bConvSupportedG2084 = FALSE;
HRESULT hr = S_OK;

const bool fullrange = (exFmt.NominalRange == DXVA2_NominalRange_0_255);
const bool fullrange = (exFmt.NominalRange == MFNominalRange_0_255);
bool isG2084 = false;

cstype_input = DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709;
cstype_output = DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709;

if (bHdrPassthrough) {
cstype_input = (exFmt.VideoChromaSubsampling == DXVA2_VideoChromaSubsampling_Cosited)
cstype_input = (exFmt.VideoChromaSubsampling == MFVideoChromaSubsampling_Cosited)
? DXGI_COLOR_SPACE_YCBCR_STUDIO_G2084_TOPLEFT_P2020
: DXGI_COLOR_SPACE_YCBCR_STUDIO_G2084_LEFT_P2020;
cstype_output = DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020;
Expand All @@ -536,7 +536,7 @@ HRESULT CD3D11VP::CheckColorSpaceNew(
else if (exFmt.value) {
/*
if (exFmt.VideoTransferMatrix == VIDEOTRANSFERMATRIX_BT2020_10 || exFmt.VideoTransferMatrix == VIDEOTRANSFERMATRIX_BT2020_12) {
const bool topleft = (exFmt.VideoChromaSubsampling == DXVA2_VideoChromaSubsampling_Cosited);
const bool topleft = (exFmt.VideoChromaSubsampling == MFVideoChromaSubsampling_Cosited);
if (exFmt.VideoTransferFunction == MFVideoTransFunc_2084) {
cstype_stream = topleft
Expand All @@ -548,20 +548,20 @@ HRESULT CD3D11VP::CheckColorSpaceNew(
? DXGI_COLOR_SPACE_YCBCR_FULL_GHLG_TOPLEFT_P2020
: DXGI_COLOR_SPACE_YCBCR_STUDIO_GHLG_TOPLEFT_P2020;
}
else if (exFmt.VideoTransferFunction == DXVA2_VideoTransFunc_sRGB) {
else if (exFmt.VideoTransferFunction == MFVideoTransFunc_sRGB) {
cstype_stream = topleft
? DXGI_COLOR_SPACE_YCBCR_STUDIO_G24_TOPLEFT_P2020
: DXGI_COLOR_SPACE_YCBCR_STUDIO_G24_LEFT_P2020;
}
else { // DXVA2_VideoTransFunc_22 and other
else { // MFVideoTransFunc_22 and other
cstype_stream = topleft
? DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_TOPLEFT_P2020
: fullrange ? DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P2020 : DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P2020;
}
}
*/
if (exFmt.VideoTransferFunction == MFVideoTransFunc_2084 && (exFmt.VideoTransferMatrix == MFVideoTransferMatrix_BT2020_10 || exFmt.VideoTransferMatrix == MFVideoTransferMatrix_BT2020_12)) {
const bool topleft = (exFmt.VideoChromaSubsampling == DXVA2_VideoChromaSubsampling_Cosited);
const bool topleft = (exFmt.VideoChromaSubsampling == MFVideoChromaSubsampling_Cosited);
cstype_input = topleft
? DXGI_COLOR_SPACE_YCBCR_STUDIO_G2084_TOPLEFT_P2020
: DXGI_COLOR_SPACE_YCBCR_STUDIO_G2084_LEFT_P2020;
Expand All @@ -573,16 +573,16 @@ HRESULT CD3D11VP::CheckColorSpaceNew(
outputFormat, cstype_output,
&m_bConvSupportedG2084);
}
else if (exFmt.VideoTransferMatrix == DXVA2_VideoTransferMatrix_BT601) {
else if (exFmt.VideoTransferMatrix == MFVideoTransferMatrix_BT601) {
cstype_input = fullrange
? DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P601
: DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601;
}
else { // DXVA2_VideoTransferMatrix_BT709 and other
if (exFmt.VideoTransferFunction == DXVA2_VideoTransFunc_sRGB) {
else { // MFVideoTransferMatrix_BT709 and other
if (exFmt.VideoTransferFunction == MFVideoTransFunc_sRGB) {
cstype_input = DXGI_COLOR_SPACE_YCBCR_STUDIO_G24_LEFT_P709;
}
else { // DXVA2_VideoTransFunc_22 and other
else { // MFVideoTransFunc_22 and other
cstype_input = fullrange
? DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P709
: DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709;
Expand All @@ -591,16 +591,16 @@ HRESULT CD3D11VP::CheckColorSpaceNew(
}

if (isG2084 && (FAILED(hr) || !m_bConvSupportedG2084)) {
if (exFmt.VideoTransferMatrix == DXVA2_VideoTransferMatrix_BT601) {
if (exFmt.VideoTransferMatrix == MFVideoTransferMatrix_BT601) {
cstype_input = fullrange
? DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P601
: DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601;
}
else { // DXVA2_VideoTransferMatrix_BT709 and other
if (exFmt.VideoTransferFunction == DXVA2_VideoTransFunc_sRGB) {
else { // MFVideoTransferMatrix_BT709 and other
if (exFmt.VideoTransferFunction == MFVideoTransFunc_sRGB) {
cstype_input = DXGI_COLOR_SPACE_YCBCR_STUDIO_G24_LEFT_P709;
}
else { // DXVA2_VideoTransFunc_22 and other
else { // MFVideoTransFunc_22 and other
cstype_input = fullrange
? DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P709
: DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709;
Expand Down Expand Up @@ -652,10 +652,10 @@ void CD3D11VP::SetColorSpaceOld(const DXVA2_ExtendedFormat exFmt)
D3D11_VIDEO_PROCESSOR_COLOR_SPACE colorSpace = {};
if (exFmt.value) {
colorSpace.RGB_Range = 0; // output RGB always full range (0-255)
colorSpace.YCbCr_Matrix = (exFmt.VideoTransferMatrix == DXVA2_VideoTransferMatrix_BT601)
colorSpace.YCbCr_Matrix = (exFmt.VideoTransferMatrix == MFVideoTransferMatrix_BT601)
? 0 // ITU-R BT.601
: 1; // ITU-R BT.709
colorSpace.Nominal_Range = (exFmt.NominalRange == DXVA2_NominalRange_0_255)
colorSpace.Nominal_Range = (exFmt.NominalRange == MFNominalRange_0_255)
? D3D11_VIDEO_PROCESSOR_NOMINAL_RANGE_0_255
: D3D11_VIDEO_PROCESSOR_NOMINAL_RANGE_16_235;
}
Expand Down
58 changes: 29 additions & 29 deletions Source/DX11VideoProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@ void CDX11VideoProcessor::SetGraphSize()
CalcStatsFont();
if (S_OK == m_Font3D.CreateFontBitmap(L"Consolas", m_StatsFontH, 0)) {
SIZE charSize = m_Font3D.GetMaxCharMetric();
m_StatsRect.right = m_StatsRect.left + 61 * charSize.cx + 5 + 3;
m_StatsRect.right = m_StatsRect.left + 64 * charSize.cx + 5 + 3;
m_StatsRect.bottom = m_StatsRect.top + 19 * charSize.cy + 5 + 3;
}
m_StatsBackground.Set(m_StatsRect, rtSize, D3DCOLOR_ARGB(80, 0, 0, 0));
Expand Down Expand Up @@ -1810,9 +1810,9 @@ BOOL CDX11VideoProcessor::InitMediaType(const CMediaType* pmt)
hr = InitializeD3D11VP(FmtParams, origW, origH);
if (SUCCEEDED(hr)) {
UINT resId = 0;
bool bTransFunc22 = m_srcExFmt.VideoTransferFunction == DXVA2_VideoTransFunc_22
|| m_srcExFmt.VideoTransferFunction == DXVA2_VideoTransFunc_709
|| m_srcExFmt.VideoTransferFunction == DXVA2_VideoTransFunc_240M;
bool bTransFunc22 = m_srcExFmt.VideoTransferFunction == MFVideoTransFunc_22
|| m_srcExFmt.VideoTransferFunction == MFVideoTransFunc_709
|| m_srcExFmt.VideoTransferFunction == MFVideoTransFunc_240M;

if (m_srcExFmt.VideoTransferFunction == MFVideoTransFunc_2084 && !(m_bHdrPassthroughSupport && m_bHdrPassthrough) && m_bConvertToSdr) {
resId = m_D3D11VP.IsPqSupported() ? IDF_PS_11_CONVERT_PQ_TO_SDR : IDF_PS_11_FIXCONVERT_PQ_TO_SDR;
Expand Down Expand Up @@ -3872,9 +3872,9 @@ void CDX11VideoProcessor::UpdateStatsPresent()
{
DXGI_SWAP_CHAIN_DESC1 swapchain_desc;
if (m_pDXGISwapChain1 && S_OK == m_pDXGISwapChain1->GetDesc1(&swapchain_desc)) {
m_strStatsPresent.assign(L"\nPresentation : ");
m_strStatsPresent.assign(L"\nPresentation : ");
if (m_bVBlankBeforePresent && m_pDXGIOutput) {
m_strStatsPresent.append(L"wait VBlank, ");
m_strStatsPresent.append(L"wait for VBlank, ");
}
switch (swapchain_desc.SwapEffect) {
case DXGI_SWAP_EFFECT_DISCARD:
Expand All @@ -3884,10 +3884,10 @@ void CDX11VideoProcessor::UpdateStatsPresent()
m_strStatsPresent.append(L"Sequential");
break;
case DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL:
m_strStatsPresent.append(L"Flip sequential");
m_strStatsPresent.append(L"Flip Sequential");
break;
case DXGI_SWAP_EFFECT_FLIP_DISCARD:
m_strStatsPresent.append(L"Flip discard");
m_strStatsPresent.append(L"Flip Discard");
break;
}
m_strStatsPresent.append(L", ");
Expand All @@ -3902,16 +3902,16 @@ void CDX11VideoProcessor::UpdateStatsStatic()

UpdateStatsInputFmt();

m_strStatsVProc.assign(L"\nVideoProcessor: ");
m_strStatsVProc.assign(L"\nVideo Processor : ");
if (m_D3D11VP.IsReady()) {
m_strStatsVProc += std::format(L"D3D11 VP, output to {}", DXGIFormatToString(m_D3D11OutputFmt));
m_strStatsVProc += std::format(L"D3D11 VP, Output to {}", DXGIFormatToString(m_D3D11OutputFmt));
} else {
m_strStatsVProc.append(L"Shaders");
if (m_srcParams.Subsampling == 420 || m_srcParams.Subsampling == 422) {
m_strStatsVProc.append(L", Chroma scaling: ");
m_strStatsVProc.append(L", Chroma Scaling: ");
switch (m_iChromaScaling) {
case CHROMA_Nearest:
m_strStatsVProc.append(L"Nearest-neighbor");
m_strStatsVProc.append(L"Nearest-Neighbor");
break;
case CHROMA_Bilinear:
m_strStatsVProc.append(L"Bilinear");
Expand All @@ -3922,17 +3922,17 @@ void CDX11VideoProcessor::UpdateStatsStatic()
}
}
}
m_strStatsVProc += std::format(L"\nInternalFormat: {}", DXGIFormatToString(m_InternalTexFmt));
m_strStatsVProc += std::format(L"\nInternal Format : {}", DXGIFormatToString(m_InternalTexFmt));

//add debug output so users know when RTX Video HDR is enabled
//might want to rename this feature to 'Auto HDR' or something else in the future,
// but considering nvidia is the only one to currently support this,
// RTX Video HDR seems to be more recognizable for users.
bool sourceHDR = SourceIsHDR();
if (sourceHDR || m_bVPUseRTXVideoHDR) {
m_strStatsHDR.assign(L"\nHDR processing: ");
m_strStatsHDR.assign(L"\nHDR Processing : ");
if (m_bVPUseRTXVideoHDR && !sourceHDR)
m_strStatsHDR.append(L"RTX Video HDR*");
m_strStatsHDR.append(L"RTX Video HDR");
else if (m_bHdrPassthroughSupport && m_bHdrPassthrough) {
m_strStatsHDR.append(L"Passthrough");
if (m_lastHdr10.bValid) {
Expand All @@ -3941,7 +3941,7 @@ void CDX11VideoProcessor::UpdateStatsStatic()
} else if (m_bConvertToSdr) {
m_strStatsHDR.append(L"Convert to SDR");
} else {
m_strStatsHDR.append(L"Not used");
m_strStatsHDR.append(L"Not Used");
}
} else {
m_strStatsHDR.clear();
Expand Down Expand Up @@ -3991,19 +3991,19 @@ HRESULT CDX11VideoProcessor::DrawStats(ID3D11Texture2D* pRenderTarget)
str.reserve(700);
str.assign(m_strStatsHeader);
str.append(m_strStatsDispInfo);
str += std::format(L"\nGraph. Adapter: {}", m_strAdapterDescription);
str += std::format(L"\nGraphics Adapter: {}", m_strAdapterDescription);

wchar_t frametype = (m_SampleFormat != D3D11_VIDEO_FRAME_FORMAT_PROGRESSIVE) ? 'i' : 'p';
str += std::format(
L"\nFrame rate : {:7.3f}{},{:7.3f}",
L"\nFrame Rate : {:7.3f}{},{:7.3f}p",
m_pFilter->m_FrameStats.GetAverageFps(),
frametype,
m_pFilter->m_DrawStats.GetAverageFps()
);

str.append(m_strStatsInputFmt);
if (m_Dovi.bValid) {
str.append(L", MetaData: DolbyVision");
str.append(L", Metadata: Dolby Vision");
if (m_Dovi.bHasMMR) {
str.append(L"(MMR)");
}
Expand All @@ -4013,9 +4013,9 @@ HRESULT CDX11VideoProcessor::DrawStats(ID3D11Texture2D* pRenderTarget)
const int dstW = m_videoRect.Width();
const int dstH = m_videoRect.Height();
if (m_iRotation) {
str += std::format(L"\nScaling : {}x{} r{}\u00B0> {}x{}", m_srcRectWidth, m_srcRectHeight, m_iRotation, dstW, dstH);
str += std::format(L"\nScaling : {}x{} r{}\u00B0> {}x{}", m_srcRectWidth, m_srcRectHeight, m_iRotation, dstW, dstH);
} else {
str += std::format(L"\nScaling : {}x{} -> {}x{}", m_srcRectWidth, m_srcRectHeight, dstW, dstH);
str += std::format(L"\nScaling : {}x{} -> {}x{}", m_srcRectWidth, m_srcRectHeight, dstW, dstH);
}
if (m_srcRectWidth != dstW || m_srcRectHeight != dstH) {
//D3D scaling is manually forced on if SuperRes is enabled
Expand All @@ -4036,39 +4036,39 @@ HRESULT CDX11VideoProcessor::DrawStats(ID3D11Texture2D* pRenderTarget)
}

if (m_bVPUseSuperRes) {
str.append(L" SuperResolution*");
str.append(L" Super Resolution");
}

if (m_strCorrection || m_pPostScaleShaders.size() || m_bDitherUsed) {
str.append(L"\nPostProcessing:");
str.append(L"\nPost-Processing :");
if (m_strCorrection) {
str += std::format(L" {},", m_strCorrection);
}
if (m_pPostScaleShaders.size()) {
str += std::format(L" shaders[{}],", m_pPostScaleShaders.size());
str += std::format(L" Shaders[{}],", m_pPostScaleShaders.size());
}
if (m_bDitherUsed) {
str.append(L" dither");
str.append(L" Dither");
}
str_trim_end(str, ',');
}
str.append(m_strStatsHDR);
str.append(m_strStatsPresent);

str += std::format(L"\nFrames: {:5}, skipped: {}/{}, failed: {}",
str += std::format(L"\nFrames : {}, skipped: {}/{}, failed: {}",
m_pFilter->m_FrameStats.GetFrames(), m_pFilter->m_DrawStats.m_dropped, m_RenderStats.dropped2, m_RenderStats.failed);
str += std::format(L"\nTimes(ms): Copy{:3}, Paint{:3}, Present{:3}",
str += std::format(L"\nTimes : copy:{:3} ms, paint:{:3} ms, present:{:3} ms",
m_RenderStats.copyticks * 1000 / GetPreciseTicksPerSecondI(),
m_RenderStats.paintticks * 1000 / GetPreciseTicksPerSecondI(),
m_RenderStats.presentticks * 1000 / GetPreciseTicksPerSecondI());

str += std::format(L"\nSync offset : {:+3} ms", (m_RenderStats.syncoffset + 5000) / 10000);
str += std::format(L"\nSync offset : {:+3} ms", (m_RenderStats.syncoffset + 5000) / 10000);

#if SYNC_OFFSET_EX
{
const auto [so_min, so_max] = m_Syncs.MinMax();
const auto [sod_min, sod_max] = m_SyncDevs.MinMax();
str += std::format(L", range[{:+3.0f};{:+3.0f}], max change{:+3.0f}/{:+3.0f}",
str += std::format(L", range [{:+3.0f};{:+3.0f}], max change {:+3.0f}/{:+3.0f}",
so_min / 10000.0f,
so_max / 10000.0f,
sod_min / 10000.0f,
Expand Down
Loading

0 comments on commit 8fb7d0b

Please sign in to comment.