06b84efcb3
We now insert helper functions which defer the assignment of out- parameters back into their original variables to the end of the function call. This allows us to match the semantics listed the GLSL spec in section 6.1.1: "All arguments are evaluated at call time, exactly once, in order, from left to right. [...] Evaluation of an out parameter results in an l-value that is used to copy out a value when the function returns. Evaluation of an inout parameter results in both a value and an l-value; the value is copied to the formal parameter at call time and the lvalue is used to copy out a value when the function returns." This technique also allows us to support swizzled out-parameters in Metal, by reading the swizzle into a temp variable, calling the original function, and then re-assigning the result back into the original swizzle expression. At present, we don't deduplicate these helper functions, so in theory there could be a fair amount of redundant code generated if a function with out parameters is called many times in a row. The cost of properly deduplicating them is probably larger than the benefit in the 99% case. Change-Id: Iefc922ac9e2b24ef2ff1e9dacb17a735a75ec8ea Bug: skia:10855, skia:11052 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/341162 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Brian Osman <brianosman@google.com> Auto-Submit: John Stiles <johnstiles@google.com>
21 lines
438 B
Plaintext
21 lines
438 B
Plaintext
/*#pragma settings NoInline*/
|
|
|
|
half2 glob = half2(1);
|
|
|
|
half4 fn(half a, out half2 b, inout half2 c, inout half3 d) {
|
|
a = sk_FragColor.r + a;
|
|
b = sk_FragColor.gb - glob.y;
|
|
c *= a;
|
|
d = sk_FragColor.aaa / d;
|
|
return half4(a, b.x, c.y, d.x);
|
|
}
|
|
|
|
void main() {
|
|
half2 a = half2(1);
|
|
half3 b = half3(2);
|
|
half4x4 c = half4x4(3);
|
|
half3x3 d = half3x3(4);
|
|
|
|
sk_FragColor = fn(a.x, b.yz, glob.yx, d[1].zyx);
|
|
}
|