xref: /aosp_15_r20/external/skia/resources/sksl/compute/DesaturateReadWrite.compute (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1layout(local_size_x = 16, local_size_y = 16) in;
2
3layout(binding=0, rgba32f) readonly texture2D texIn;
4layout(binding=1, rgba32f) writeonly texture2D texOut;
5
6half4 desaturate(half4 color) {
7    color.rgb = half3(dot(color.rgb, half3(0.22, 0.67, 0.11)));
8    return color;
9}
10
11void main() {
12    if (sk_GlobalInvocationID.x < textureWidth(texIn) &&
13        sk_GlobalInvocationID.y < textureHeight(texIn)) {
14        half4 gray = desaturate(textureRead(texIn, sk_GlobalInvocationID.xy));
15        textureWrite(texOut, sk_GlobalInvocationID.xy, gray);
16    }
17}
18