From 9d8d9f32587d61653437d7e8243e6906237b83eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 7 Jun 2023 22:32:47 +0200 Subject: [PATCH] rhi: Add QRhiSwapChainHdrInfo::maxPotentialColorComponentValue Knowing the maximum potential component value can be useful to potentially (sic) opt out of an HDR code path if the maximum color component value will be too low to make the additional processing overhead worth it. Change-Id: Ib1e1b7a745b236e1d137a1e7daf1248f1572e184 Reviewed-by: Laszlo Agocs (cherry picked from commit 183629e3ef9286332fdefa15dbce1b1495ef079d) Reviewed-by: Qt Cherry-pick Bot --- src/gui/rhi/qrhi.cpp | 6 ++++-- src/gui/rhi/qrhi.h | 1 + src/gui/rhi/qrhimetal.mm | 6 +++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp index 58bbc349419..f2e899651bd 100644 --- a/src/gui/rhi/qrhi.cpp +++ b/src/gui/rhi/qrhi.cpp @@ -7256,12 +7256,13 @@ QRhiRenderTarget *QRhiSwapChain::currentFrameRenderTarget(StereoTargetBuffer tar } luminanceInNits; \endcode - Whereas for macOS/iOS, the maximum color component value (e.g. supposedly - something larger than 1.0f) is provided: + Whereas for macOS/iOS, the current maximum and potential maximum color + component values are provided: \code struct { float maxColorComponentValue; + float maxPotentialColorComponentValue; } colorComponentValue; \endcode @@ -7306,6 +7307,7 @@ QDebug operator<<(QDebug dbg, const QRhiSwapChainHdrInfo &info) break; case QRhiSwapChainHdrInfo::ColorComponentValue: dbg.nospace() << " maxColorComponentValue=" << info.limits.colorComponentValue.maxColorComponentValue; + dbg.nospace() << " maxPotentialColorComponentValue=" << info.limits.colorComponentValue.maxPotentialColorComponentValue; break; } dbg.nospace() << ')'; diff --git a/src/gui/rhi/qrhi.h b/src/gui/rhi/qrhi.h index 8ec6630acfe..eb300f5873b 100644 --- a/src/gui/rhi/qrhi.h +++ b/src/gui/rhi/qrhi.h @@ -1485,6 +1485,7 @@ struct QRhiSwapChainHdrInfo } luminanceInNits; struct { float maxColorComponentValue; + float maxPotentialColorComponentValue; } colorComponentValue; } limits; }; diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index 4edf0ac865e..4a4da81b862 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -6338,12 +6338,16 @@ QRhiSwapChainHdrInfo QMetalSwapChain::hdrInfo() // Must use m_window, not window, given this may be called before createOrResize(). #ifdef Q_OS_MACOS NSView *view = reinterpret_cast(m_window->winId()); - info.limits.colorComponentValue.maxColorComponentValue = view.window.screen.maximumExtendedDynamicRangeColorComponentValue; + NSScreen *screen = view.window.screen; + info.limits.colorComponentValue.maxColorComponentValue = screen.maximumExtendedDynamicRangeColorComponentValue; + info.limits.colorComponentValue.maxPotentialColorComponentValue = screen.maximumPotentialExtendedDynamicRangeColorComponentValue; info.isHardCodedDefaults = false; #else if (@available(iOS 16.0, *)) { UIView *view = reinterpret_cast(m_window->winId()); + UIScreen *screen = view.window.windowScene.screen; info.limits.colorComponentValue.maxColorComponentValue = view.window.windowScene.screen.currentEDRHeadroom; + info.limits.colorComponentValue.maxPotentialColorComponentValue = screen.potentialEDRHeadroom; info.isHardCodedDefaults = false; } #endif