xref: /aosp_15_r20/external/skia/resources/sksl/wgsl/OutParams.sksl (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1/*#pragma settings NoInline*/
2uniform half uFloat;
3
4// Reference a pipeline I/O parameter and a global uniform. This tests that all parameter variations
5// are injected correctly.
6void various_parameter_types(half a, out half b, inout half c) {
7    sk_FragColor = half4(a, b, c, uFloat);  // `b` has an undefined value but should compile OK.
8    b = a;
9    c = uFloat;
10}
11
12void one_out_param(out half h) {
13    h = 2;
14}
15
16void one_out_param_indirect(out half h) {
17    one_out_param(h);
18}
19
20struct S {
21    half4 v;
22};
23
24void main() {
25    // local float
26    half x = 1;
27    one_out_param(x);
28    one_out_param_indirect(x);
29    various_parameter_types(x + 1, x, x);
30
31    // local vector
32    half4 v;
33    various_parameter_types(x + 1, v.x, v.x);
34    various_parameter_types(x + 1, v.y, v.y);
35    various_parameter_types(x + 1, v.x, v.y);
36
37    // local struct
38    S s;
39    various_parameter_types(x + 1, s.v.x, x);
40    various_parameter_types(x + 1, s.v.y, x);
41}
42
43// TODO(skia:13092): test the case in which a pipeline IO parameter is passed as out-param,
44//                   directly and indirectly
45// TODO(skia:13092): module-private out-param
46// TODO(skia:13092): access an IO parameter while also passing it as an out-param
47// TODO(skia:13092): mixing out params with in and inout
48// TODO(skia:13092): swizzle assignment when that's supported
49