diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index 4a4da81b862..537f63418da 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 true; + return hdrInfoForScreen().limits.colorComponentValue.maxPotentialColorComponentValue > 1.0f; else return false; } @@ -6328,13 +6328,25 @@ 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; info.limits.colorComponentValue.maxColorComponentValue = 1; info.isHardCodedDefaults = true; - if (m_format != SDR && m_window) { + if (m_window) { // Must use m_window, not window, given this may be called before createOrResize(). #ifdef Q_OS_MACOS NSView *view = reinterpret_cast(m_window->winId()); diff --git a/src/gui/rhi/qrhimetal_p.h b/src/gui/rhi/qrhimetal_p.h index 8fb2ce84b0c..3cc8f89ca7d 100644 --- a/src/gui/rhi/qrhimetal_p.h +++ b/src/gui/rhi/qrhimetal_p.h @@ -318,6 +318,9 @@ struct QMetalSwapChain : public QRhiSwapChain QMetalCommandBuffer cbWrapper; QMetalRenderBuffer *ds = nullptr; QMetalSwapChainData *d = nullptr; + +private: + QRhiSwapChainHdrInfo hdrInfoForScreen(); }; struct QRhiMetalData;