I have a MTKView and I want to display a CIImage in it using wide color. I'm deriving the CIImage from a PNG image tagged with the Display P3 color space. I have set the MTKView's colorPixelFormat property to either MTLPixelFormatBGR10_XR or MTLPixelFormatBGR10_XR_sRGB, and I've set my CIContext's workingColorSpace to Display P3 and workingColorFormat to kCIFormatRGBAh.
In my MTKView delegate's drawRect method I am drawing the CIImage like this:
[ciContext render:image toMTLTexture:currentDrawable.texture commandBuffer:commandBuffer bounds:drawableBounds colorSpace:deviceColorSpace]
where deviceColorSpace is created using one of the following:
CGColorSpaceCreateDeviceRGB()
CGColorSpaceCreateWithName(kCGColorSpaceExtendedSRGB)
CGColorSpaceCreateWithName(kCGColorSpaceDisplayP3)
CGColorSpaceCreateWithName(kCGColorSpaceSRGB)
However, no matter which combination of colorSpace and colorPixelFormat I use, the image does not render correclty, with the image's colors being either compressed or cropped into a smaller gamut.
If I render the CIImage to a CGImage using the Display P3 color space and view the result either in a UIImageView or in the debugger, it appears correctly, so I know that neither the CIImage nor the CIContext are incorrect.
Has anyone gotten wide color with Core Image and MTKView to work properly, and if so, what color space and pixel format did you use?