EDR doesn't work on iOS?

Trying to modify Unreal Engine for the recent EDR support on iOS, and I can't get it working properly.

  • Extended colors are getting clipped. wantsExtendedDynamicRangeContent is enabled on the layer. I tried both MTLPixelFormatBGR10A2Unorm/kCGColorSpaceITUR_2100_PQ and MTLPixelFormatBGRA16Float/kCGColorSpaceExtendedLinearSRGB with the appropriate color transformations in shader code, and the SDR-range colors look fine, but the extended colors do not. Metal frame debugger shows the pixel values are what I want them to be. I'm testing this with iPad Pro 5 in Reference Mode. I don't set edrMetadata because I don't want the device to do any tonemapping. Is there something else I need to set?
  • IPad Pro 5 and iPhone XR report 16/2 for potentialHDRHeadroom (good), but currentHDRHeadroom is always 1 (bad) unless I put the iPad Pro 5 in Reference Mode, where it becomes 10 as expected.
  • I played an HDR video recording of our PC build on the device, so I know the device is capable of rendering HDR correctly...

Can I get some help please? Is there an iOS EDR sample published that I can use for reference maybe? :D

Replies

To enable EDR rendering, all we do is to set the colorPixelFormat to MTLPixelFormatRGBA16Float (note: RGBA, not BGRA) and wantsExtendedDynamicRangeContent to YES. We don't change the colorSpace since it is already set to extended linear sRGB when setting the other properties.

As soon as we render pixel values outside [0...1], the screen switches to EDR mode and the potential and current HDR headroom adjust accordingly.

  • Yeah, typo. I was using RGBA16F, not BGRA16F. I tried not setting colorspace, Xcode shows the values all look good: wantsExtended is true, pixelFormat is RGBA16F, colorspace is sRGB linear extended, and colors are clipped. Ignoring current headroom seems like a violation of the contract, and shouldn't be necessary? It's moot since reference mode returns 10, and I'm still clipping. I watched the iOS EDR and even the Mac EDR WWDC videos, but I'm not sure what I could be doing wrong.

Add a Comment

I think I resolved my issue. Unreal has a viewport resize callback where it normally refreshes Metal layer properties, but apparently that's too late to set up EDR on iOS. If I set the properties where the layer is originally initialized, then EDR seems to work. This suggests that EDR can't be toggled on the fly, which doesn't seem ideal.