aboutsummaryrefslogtreecommitdiff
path: root/xbmc/rendering/dx/DeviceResources.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'xbmc/rendering/dx/DeviceResources.cpp')
-rw-r--r--xbmc/rendering/dx/DeviceResources.cpp47
1 files changed, 45 insertions, 2 deletions
diff --git a/xbmc/rendering/dx/DeviceResources.cpp b/xbmc/rendering/dx/DeviceResources.cpp
index 103809d591..ff1cea0cca 100644
--- a/xbmc/rendering/dx/DeviceResources.cpp
+++ b/xbmc/rendering/dx/DeviceResources.cpp
@@ -131,6 +131,28 @@ void DX::DeviceResources::GetOutput(IDXGIOutput** ppOutput) const
*ppOutput = pOutput.Detach();
}
+void DX::DeviceResources::GetCachedOutputAndDesc(IDXGIOutput** ppOutput,
+ DXGI_OUTPUT_DESC* outputDesc) const
+{
+ ComPtr<IDXGIOutput> pOutput;
+ if (m_output)
+ {
+ m_output.As(&pOutput);
+ *outputDesc = m_outputDesc;
+ }
+ else if (m_swapChain && SUCCEEDED(m_swapChain->GetContainingOutput(pOutput.GetAddressOf())) &&
+ pOutput)
+ {
+ pOutput->GetDesc(outputDesc);
+ }
+
+ if (!pOutput)
+ CLog::LogF(LOGWARNING, "unable to retrieve current output");
+
+ *ppOutput = pOutput.Detach();
+ return;
+}
+
DXGI_ADAPTER_DESC DX::DeviceResources::GetAdapterDesc() const
{
DXGI_ADAPTER_DESC desc{};
@@ -1045,6 +1067,7 @@ void DX::DeviceResources::HandleOutputChange(const std::function<bool(DXGI_OUTPU
if (cmpFunc(outputDesc))
{
output.As(&m_output);
+ m_outputDesc = outputDesc;
// check if adapter is changed
if (currentDesc.AdapterLuid.HighPart != foundDesc.AdapterLuid.HighPart
|| currentDesc.AdapterLuid.LowPart != foundDesc.AdapterLuid.LowPart)
@@ -1331,6 +1354,11 @@ HDR_STATUS DX::DeviceResources::ToggleHDR()
DXGI_MODE_DESC md = {};
GetDisplayMode(&md);
+ // Xbox uses only full screen windowed mode and not needs recreate swapchain.
+ // Recreate swapchain causes native 4K resolution is lost and quality obtained
+ // is equivalent to 1080p upscaled to 4K (TO DO: investigate root cause).
+ const bool isXbox = (CSysInfo::GetWindowsDeviceFamily() == CSysInfo::Xbox);
+
DX::Windowing()->SetTogglingHDR(true);
DX::Windowing()->SetAlteringWindow(true);
@@ -1338,7 +1366,7 @@ HDR_STATUS DX::DeviceResources::ToggleHDR()
HDR_STATUS hdrStatus = CWIN32Util::ToggleWindowsHDR(md);
// Kill swapchain
- if (m_swapChain && hdrStatus != HDR_STATUS::HDR_TOGGLE_FAILED)
+ if (!isXbox && m_swapChain && hdrStatus != HDR_STATUS::HDR_TOGGLE_FAILED)
{
CLog::LogF(LOGDEBUG, "Re-create swapchain due HDR <-> SDR switch");
DestroySwapChain();
@@ -1347,13 +1375,28 @@ HDR_STATUS DX::DeviceResources::ToggleHDR()
DX::Windowing()->SetAlteringWindow(false);
// Re-create swapchain
- if (hdrStatus != HDR_STATUS::HDR_TOGGLE_FAILED)
+ if (!isXbox && hdrStatus != HDR_STATUS::HDR_TOGGLE_FAILED)
{
CreateWindowSizeDependentResources();
DX::Windowing()->NotifyAppFocusChange(true);
}
+ // On Xbox set new color space in same swapchain
+ if (isXbox && hdrStatus != HDR_STATUS::HDR_TOGGLE_FAILED)
+ {
+ if (hdrStatus == HDR_STATUS::HDR_ON)
+ {
+ SetHdrColorSpace(DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020);
+ m_IsHDROutput = true;
+ }
+ else
+ {
+ SetHdrColorSpace(DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709);
+ m_IsHDROutput = false;
+ }
+ }
+
return hdrStatus;
}