From ec58e20d7e8ef8c61907381db8c7bfdaa9539f5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 9 Jun 2023 14:38:39 +0200 Subject: [PATCH] rhi: Don't check m_format in QRhiSwapChain::hdrInfo() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The HDR info is independent of the current format anyways. Removing the format check allows code to use hdrInfo() as a signal for whether to set a HDR format, instead of having to set the format, then query hdrInfo(), and then setting SDR again if needed. Change-Id: I99b57335003d06af227f2a7078560c2a483b049b Reviewed-by: Laszlo Agocs (cherry picked from commit 5ea0256b07495977a1f2740f6b2d99984cf927dc) Reviewed-by: Tor Arne Vestbø --- src/gui/rhi/qrhid3d11.cpp | 2 +- src/gui/rhi/qrhid3d12.cpp | 2 +- src/gui/rhi/qrhimetal.mm | 14 +------------- src/gui/rhi/qrhimetal_p.h | 3 --- 4 files changed, 3 insertions(+), 18 deletions(-) diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index f20c1f4072e..e1f422ce02e 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -4915,7 +4915,7 @@ bool QD3D11SwapChain::isFormatSupported(Format f) QRhiSwapChainHdrInfo QD3D11SwapChain::hdrInfo() { QRhiSwapChainHdrInfo info = QRhiSwapChain::hdrInfo(); - if (m_format != QRhiSwapChain::SDR && m_window) { + if (m_window) { QRHI_RES_RHI(QRhiD3D11); DXGI_OUTPUT_DESC1 hdrOutputDesc; if (outputDesc1ForWindow(m_window, rhiD->activeAdapter, &hdrOutputDesc)) { diff --git a/src/gui/rhi/qrhid3d12.cpp b/src/gui/rhi/qrhid3d12.cpp index 19843ed82bc..e954d16d1a1 100644 --- a/src/gui/rhi/qrhid3d12.cpp +++ b/src/gui/rhi/qrhid3d12.cpp @@ -5801,7 +5801,7 @@ bool QD3D12SwapChain::isFormatSupported(Format f) QRhiSwapChainHdrInfo QD3D12SwapChain::hdrInfo() { QRhiSwapChainHdrInfo info = QRhiSwapChain::hdrInfo(); - if (m_format != QRhiSwapChain::SDR && m_window) { + if (m_window) { QRHI_RES_RHI(QRhiD3D12); DXGI_OUTPUT_DESC1 hdrOutputDesc; if (outputDesc1ForWindow(m_window, rhiD->activeAdapter, &hdrOutputDesc)) { diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index 537f63418da..bbdd48318fb 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -6107,7 +6107,7 @@ bool QMetalSwapChain::isFormatSupported(Format f) { if (f == HDRExtendedSrgbLinear) { if (@available(macOS 10.11, iOS 16.0, *)) - return hdrInfoForScreen().limits.colorComponentValue.maxPotentialColorComponentValue > 1.0f; + return hdrInfo().limits.colorComponentValue.maxPotentialColorComponentValue > 1.0f; else return false; } @@ -6328,18 +6328,6 @@ bool QMetalSwapChain::createOrResize() } QRhiSwapChainHdrInfo QMetalSwapChain::hdrInfo() -{ - if (m_format == SDR) { - QRhiSwapChainHdrInfo info; - info.limitsType = QRhiSwapChainHdrInfo::ColorComponentValue; - info.limits.colorComponentValue.maxColorComponentValue = 1; - info.isHardCodedDefaults = true; - } else { - return hdrInfoForScreen(); - } -} - -QRhiSwapChainHdrInfo QMetalSwapChain::hdrInfoForScreen() { QRhiSwapChainHdrInfo info; info.limitsType = QRhiSwapChainHdrInfo::ColorComponentValue; diff --git a/src/gui/rhi/qrhimetal_p.h b/src/gui/rhi/qrhimetal_p.h index 3cc8f89ca7d..8fb2ce84b0c 100644 --- a/src/gui/rhi/qrhimetal_p.h +++ b/src/gui/rhi/qrhimetal_p.h @@ -318,9 +318,6 @@ struct QMetalSwapChain : public QRhiSwapChain QMetalCommandBuffer cbWrapper; QMetalRenderBuffer *ds = nullptr; QMetalSwapChainData *d = nullptr; - -private: - QRhiSwapChainHdrInfo hdrInfoForScreen(); }; struct QRhiMetalData;