Commit 58c8fc8b2108e5865c5ec1a010d73f227e924054

Christopher Cameron 2023-09-06T23:54:20

CopySubTexture: Handle sRGB source in Metal backend CopySubTexture should ignore the color encoding of both the source and destination. The implementation currently ignores the color encoding of the destination (and CopyTextureVariationsTest tests this). The implementation does not always ignore the color encoding of the source. As an example of the consequences of this, an RGBA pixel value of 0xFF/80/00/FF, when copied from a GL_SRGB8_ALPHA8 texture to a GL_RGBA8 texture may result in a value of 0xFF/37/00/FF, if the copy was executed using a shader (in which case the sRGB-to-linear function was applied 0x80, resulting in the 0x37). Update the Metal shaders that do this blit, adding an option to apply a linear-to-sRGB transformation to undo the transformation applied by the sampler. The linear-to-sRGB transformation must be applied on unpremultiplied values. Ensure that the sequence of operations in all shaders is first unpremultiply, then linear-to-sRGB, then premultiply. Also remove optimizations to have the unpremultiply and premultiply cancel each other out, if there is also a linear-to-sRGB being applied. Bug: angleproject:7907 Change-Id: I7237bde1c61251a2f83968755e98a139ba949b59 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4848327 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>