Display HDR content with CAMetalLayer on iOS

Hi,

We're trying to render HDR video frames with CAMetalLayer in our iOS app, using BGR10_XR format.

The WWDC2020 presentation Optimize the Core Image pipeline for your video app
gives a really nice example of how to do this at 7:01.

The CAMetalLayer documentations describe the same at Using Color Spaces to Display HDR Content and at wantsExtendedDynamicRangeContent clearly stating the CAMetalLayer won't clamp extended range values only if wantsExtendedDynamicRangeContent is set to true.

An example of how this would work:
Code Block swift
let metalLayer = CAMetalLayer()
metalLayer.wantsExtendedDynamicRangeContent = true
metalLayer.pixelFormat = .bgr10_xr
let name = CGColorSpace.itur_2020_HLG
metalLayer.colorspace = CGColorSpace(name: name)

What we get now in our iOS app is exactly what the documentation describes: the rendered content is clamped to 1.0 on the screen, resulting in an overexposed video.

It looks like iOS apps with a pipeline like the one in Optimize the Core Image pipeline for your video app will be able to render HDR videos only when wantsExtendedDynamicRangeContent becomes available on iOS as well.

Is there any plan to add this CAMetalLayer property on iOS too? And if there's any when do you think it's gonna be available?

Replies

Yes, please add this for iOS and tvOS.

I am writing a Metal-based video player and this is a limitation.