• Christopher Cameron's avatar
    HDR/macOS Tonemapping: Change from Metal blit to shader · 52d096fb
    Christopher Cameron authored
    There exists code that copies an IOSurface to a CAMetalLayer,
    because simply setting a CALayer's contents to an IOSurface that
    has an HDR color space is not sufficient to guarantee that the
    content will be displayed as HDR (it did in early versions of
    10.16, but now does not).
    
    Separately, there is now desire to have tonemapping on lower
    end HDR devices. This is fairly easy to wrangle into the
    pipeline in the place where we do the copy.
    
    In this patch, replace the blit with a shader that does
    the blit. Also, change the CAMetalLayer from matching the
    IOSurface to being float16. Patches will follow will include
    - Change the CAMetalLayer to be in extended-linear-sRGB
      color space, by adding limited color conversion to the
      shader.
    - Add tonemapping in the extended-linear-sRGB color space.
    - Set the tonemapping parameters based on the NSScreen
      properties.
    
    Bug: 1101041
    Change-Id: If1aaa6081730212611cb4cf58d8f90d5957dddf7
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2352027
    Commit-Queue: ccameron <ccameron@chromium.org>
    Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#798466}
    52d096fb
hdr_copier_layer.mm 9.89 KB