aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCrystalP <crystalp@kodi.tv>2023-05-07 10:39:19 -0400
committerCrystalP <crystalp@kodi.tv>2023-05-11 14:21:25 -0400
commit98545e68a26dcc9cc55784d2ba0e4b7814a17579 (patch)
tree6d5d0d4ce778abd43da2c12c48df29f051745551
parent0abb4db261846571054f3f17aba12c0d8cecdb97 (diff)
downloadxbmc-98545e68a26dcc9cc55784d2ba0e4b7814a17579.tar.xz
[Windows] fix playback of HDR material when Windows is already in HDR mode for AMD
backport of PR 23241
-rw-r--r--xbmc/rendering/dx/DeviceResources.cpp15
-rw-r--r--xbmc/rendering/dx/DeviceResources.h1
2 files changed, 16 insertions, 0 deletions
diff --git a/xbmc/rendering/dx/DeviceResources.cpp b/xbmc/rendering/dx/DeviceResources.cpp
index b3ae890f83..502f253d8d 100644
--- a/xbmc/rendering/dx/DeviceResources.cpp
+++ b/xbmc/rendering/dx/DeviceResources.cpp
@@ -708,6 +708,7 @@ void DX::DeviceResources::ResizeBuffers()
ComPtr<IDXGIDevice1> dxgiDevice;
hr = m_d3dDevice.As(&dxgiDevice); CHECK_ERR();
dxgiDevice->SetMaximumFrameLatency(1);
+ m_usedSwapChain = false;
}
CLog::LogF(LOGDEBUG, "end resize buffers.");
@@ -935,6 +936,7 @@ void DX::DeviceResources::HandleDeviceLost(bool removed)
bool DX::DeviceResources::Begin()
{
HRESULT hr = m_swapChain->Present(0, DXGI_PRESENT_TEST);
+ m_usedSwapChain = true;
// If the device was removed either by a disconnection or a driver upgrade, we
// must recreate all device resources.
@@ -966,6 +968,7 @@ void DX::DeviceResources::Present()
// frames that will never be displayed to the screen.
DXGI_PRESENT_PARAMETERS parameters = {};
HRESULT hr = m_swapChain->Present1(1, 0, &parameters);
+ m_usedSwapChain = true;
// If the device was removed either by a disconnection or a driver upgrade, we
// must recreate all device resources.
@@ -1270,6 +1273,18 @@ void DX::DeviceResources::SetHdrColorSpace(const DXGI_COLOR_SPACE_TYPE colorSpac
if (SUCCEEDED(m_swapChain.As(&swapChain3)))
{
+ // Set the color space on a new swap chain - not mandated by MS documentation but needed
+ // at least for some AMD, at least up to Adrenalin 23.4.3 / Windows driver 31.0.14043.7000
+ if (m_usedSwapChain &&
+ m_IsTransferPQ != (colorSpace == DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020))
+ {
+ // Temporary release, can't hold references during swap chain re-creation
+ swapChain3 = nullptr;
+ DestroySwapChain();
+ CreateWindowSizeDependentResources();
+ m_swapChain.As(&swapChain3);
+ }
+
if (SUCCEEDED(swapChain3->SetColorSpace1(colorSpace)))
{
m_IsTransferPQ = (colorSpace == DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020);
diff --git a/xbmc/rendering/dx/DeviceResources.h b/xbmc/rendering/dx/DeviceResources.h
index d45890264f..2527720cd7 100644
--- a/xbmc/rendering/dx/DeviceResources.h
+++ b/xbmc/rendering/dx/DeviceResources.h
@@ -183,5 +183,6 @@ namespace DX
bool m_IsTransferPQ;
bool m_NV12SharedTexturesSupport{false};
bool m_DXVA2SharedDecoderSurfaces{false};
+ bool m_usedSwapChain{false};
};
}