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 <laszlo.agocs@qt.io>
(cherry picked from commit 183629e3ef9286332fdefa15dbce1b1495ef079d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Tor Arne Vestbø 2023-06-07 22:32:47 +02:00 committed by Qt Cherry-pick Bot
parent 8133a6e2af
commit 9d8d9f3258
3 changed files with 10 additions and 3 deletions

View File

@ -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() << ')';

View File

@ -1485,6 +1485,7 @@ struct QRhiSwapChainHdrInfo
} luminanceInNits;
struct {
float maxColorComponentValue;
float maxPotentialColorComponentValue;
} colorComponentValue;
} limits;
};

View File

@ -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<NSView *>(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<UIView *>(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