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.

Pick-to: 6.6
Change-Id: Ib1e1b7a745b236e1d137a1e7daf1248f1572e184
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
Tor Arne Vestbø 2023-06-07 22:32:47 +02:00
parent 74319d05b1
commit 183629e3ef
3 changed files with 10 additions and 3 deletions

View File

@ -7256,12 +7256,13 @@ QRhiRenderTarget *QRhiSwapChain::currentFrameRenderTarget(StereoTargetBuffer tar
} luminanceInNits; } luminanceInNits;
\endcode \endcode
Whereas for macOS/iOS, the maximum color component value (e.g. supposedly Whereas for macOS/iOS, the current maximum and potential maximum color
something larger than 1.0f) is provided: component values are provided:
\code \code
struct { struct {
float maxColorComponentValue; float maxColorComponentValue;
float maxPotentialColorComponentValue;
} colorComponentValue; } colorComponentValue;
\endcode \endcode
@ -7306,6 +7307,7 @@ QDebug operator<<(QDebug dbg, const QRhiSwapChainHdrInfo &info)
break; break;
case QRhiSwapChainHdrInfo::ColorComponentValue: case QRhiSwapChainHdrInfo::ColorComponentValue:
dbg.nospace() << " maxColorComponentValue=" << info.limits.colorComponentValue.maxColorComponentValue; dbg.nospace() << " maxColorComponentValue=" << info.limits.colorComponentValue.maxColorComponentValue;
dbg.nospace() << " maxPotentialColorComponentValue=" << info.limits.colorComponentValue.maxPotentialColorComponentValue;
break; break;
} }
dbg.nospace() << ')'; dbg.nospace() << ')';

View File

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

View File

@ -6338,12 +6338,16 @@ QRhiSwapChainHdrInfo QMetalSwapChain::hdrInfo()
// Must use m_window, not window, given this may be called before createOrResize(). // Must use m_window, not window, given this may be called before createOrResize().
#ifdef Q_OS_MACOS #ifdef Q_OS_MACOS
NSView *view = reinterpret_cast<NSView *>(m_window->winId()); 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; info.isHardCodedDefaults = false;
#else #else
if (@available(iOS 16.0, *)) { if (@available(iOS 16.0, *)) {
UIView *view = reinterpret_cast<UIView *>(m_window->winId()); 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.maxColorComponentValue = view.window.windowScene.screen.currentEDRHeadroom;
info.limits.colorComponentValue.maxPotentialColorComponentValue = screen.potentialEDRHeadroom;
info.isHardCodedDefaults = false; info.isHardCodedDefaults = false;
} }
#endif #endif