rhi: Only report HDR as supported if maxPotentialColorComponentValue > 1

Pick-to: 6.6
Change-Id: I4c951e8c651b2bee41aba8ff69f481a08d6a3561
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
Tor Arne Vestbø 2023-06-09 12:44:39 +02:00
parent 183629e3ef
commit 5302fb64af
2 changed files with 17 additions and 2 deletions

View File

@ -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<NSView *>(m_window->winId());

View File

@ -318,6 +318,9 @@ struct QMetalSwapChain : public QRhiSwapChain
QMetalCommandBuffer cbWrapper;
QMetalRenderBuffer *ds = nullptr;
QMetalSwapChainData *d = nullptr;
private:
QRhiSwapChainHdrInfo hdrInfoForScreen();
};
struct QRhiMetalData;