rhi: metal: support HDR10

Change-Id: I6a50657e96f6e41ef2907abdac937b5e491380f8
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
Wang Bin 2023-10-16 15:55:50 +08:00
parent 4f7e0f4519
commit 004a765d1f

View File

@ -6348,6 +6348,11 @@ bool QMetalSwapChain::isFormatSupported(Format f)
return hdrInfo().limits.colorComponentValue.maxPotentialColorComponentValue > 1.0f;
else
return false;
} else if (f == HDR10) {
if (@available(iOS 16.0, *))
return hdrInfo().limits.colorComponentValue.maxPotentialColorComponentValue > 1.0f;
else
return false;
} else if (f == HDRExtendedDisplayP3Linear) {
return hdrInfo().limits.colorComponentValue.maxPotentialColorComponentValue > 1.0f;
}
@ -6392,6 +6397,11 @@ void QMetalSwapChain::chooseFormats()
d->rhiColorFormat = QRhiTexture::RGBA16F;
return;
}
if (m_format == HDR10) {
d->colorFormat = MTLPixelFormatRGB10A2Unorm;
d->rhiColorFormat = QRhiTexture::RGB10A2;
return;
}
d->colorFormat = m_flags.testFlag(sRGB) ? MTLPixelFormatBGRA8Unorm_sRGB : MTLPixelFormatBGRA8Unorm;
d->rhiColorFormat = QRhiTexture::BGRA8;
}
@ -6440,6 +6450,11 @@ bool QMetalSwapChain::createOrResize()
d->layer.colorspace = CGColorSpaceCreateWithName(kCGColorSpaceExtendedLinearSRGB);
d->layer.wantsExtendedDynamicRangeContent = YES;
}
} else if (m_format == HDR10) {
if (@available(iOS 16.0, *)) {
d->layer.colorspace = CGColorSpaceCreateWithName(kCGColorSpaceITUR_2100_PQ);
d->layer.wantsExtendedDynamicRangeContent = YES;
}
} else if (m_format == HDRExtendedDisplayP3Linear) {
if (@available(iOS 16.0, *)) {
d->layer.colorspace = CGColorSpaceCreateWithName(kCGColorSpaceExtendedLinearDisplayP3);