From c6638a7154bfee0958e6d4048fa8f0de73e0a8fa Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 14 Jan 2020 17:12:55 -0800 Subject: [PATCH] Add support for 10-bit output in full-screen with DXVA2 --- .../video/ffmpeg-renderers/dxva2.cpp | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/app/streaming/video/ffmpeg-renderers/dxva2.cpp b/app/streaming/video/ffmpeg-renderers/dxva2.cpp index edc42431..10eff187 100644 --- a/app/streaming/video/ffmpeg-renderers/dxva2.cpp +++ b/app/streaming/video/ffmpeg-renderers/dxva2.cpp @@ -546,14 +546,33 @@ bool DXVA2Renderer::initializeDevice(SDL_Window* window, bool enableVsync) d3dpp.hDeviceWindow = info.info.win.window; d3dpp.Flags = D3DPRESENTFLAG_VIDEO; + if (m_VideoFormat == VIDEO_FORMAT_H265_MAIN10) { + // Verify 10-bit A2R10G10B10 color support. This is only available + // as a display format in full-screen exclusive mode on DX9. + hr = d3d9ex->CheckDeviceType(adapterIndex, + D3DDEVTYPE_HAL, + D3DFMT_A2R10G10B10, + D3DFMT_A2R10G10B10, + FALSE); + if (FAILED(hr)) { + SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, + "GPU/driver doesn't support A2R10G10B10"); + return false; + } + } + if ((windowFlags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN) { d3dpp.Windowed = false; d3dpp.BackBufferWidth = currentMode.Width; d3dpp.BackBufferHeight = currentMode.Height; d3dpp.FullScreen_RefreshRateInHz = currentMode.RefreshRate; - // TODO: Need to select 10-bit color format for HDR - d3dpp.BackBufferFormat = currentMode.Format; + if (m_VideoFormat == VIDEO_FORMAT_H265_MAIN10) { + d3dpp.BackBufferFormat = currentMode.Format = D3DFMT_A2R10G10B10; + } + else { + d3dpp.BackBufferFormat = currentMode.Format; + } } else { d3dpp.Windowed = true;