xref: /aosp_15_r20/external/skia/resources/sksl/compute/Desaturate.compute (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1*c8dee2aaSAndroid Build Coastguard Workerlayout(local_size_x = 16, local_size_y = 16) in;
2*c8dee2aaSAndroid Build Coastguard Worker
3*c8dee2aaSAndroid Build Coastguard Workerlayout(rgba8, binding=0) readonly texture2D src;
4*c8dee2aaSAndroid Build Coastguard Workerlayout(rgba8, binding=1) writeonly texture2D dest;
5*c8dee2aaSAndroid Build Coastguard Worker
6*c8dee2aaSAndroid Build Coastguard Workerhalf4 desaturate(half4 color) {
7*c8dee2aaSAndroid Build Coastguard Worker    color.rgb = half3(dot(color.rgb, half3(0.22, 0.67, 0.11)));
8*c8dee2aaSAndroid Build Coastguard Worker    return color;
9*c8dee2aaSAndroid Build Coastguard Worker}
10*c8dee2aaSAndroid Build Coastguard Worker
11*c8dee2aaSAndroid Build Coastguard Workervoid main() {
12*c8dee2aaSAndroid Build Coastguard Worker    if (sk_GlobalInvocationID.x < textureWidth(src) && sk_GlobalInvocationID.y < textureHeight(src)) {
13*c8dee2aaSAndroid Build Coastguard Worker        textureWrite(dest, sk_GlobalInvocationID.xy, desaturate(textureRead(src, sk_GlobalInvocationID.xy)));
14*c8dee2aaSAndroid Build Coastguard Worker    }
15*c8dee2aaSAndroid Build Coastguard Worker}
16