skia2/resources/sksl/shared/OutParamsTricky.sksl
John Stiles ec24154521 Fix SPIR-V bug with swizzled out parameters.
The CL at http://review.skia.org/366399 introduced a bug with
LValue::getPointer. Specifically, getPointer used to return zero when
no pointer is available. (This happens when the LValue is a swizzle.)
That CL changed the error code to -1. However, it did not fix up all
the call sites that checked the return value of getPointer().

This CL fixes up those call sites to use -1 consistently, and adds
TODOs in spots which do not check the result from getPointer() at all
(instead assuming it cannot fail). This will allow swizzled out-
parameters to work in SPIR-V as they did before. (Except in intrinsics,
where they seem to have been broken all along, but those are now marked
with a TODO at least.)

Note that we still do not fully emulate GLSL semantics for out
parameters, as out-parameters should only be copied back to the original
variable at the end of the function call to be fully GLSL compliant.

(This CL also replaces a tuple with a named struct for readability.)

Change-Id: I708dc7a69296a4244ba9ceb85c3e68d1f331bbc9
Bug: skia:11052
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/368618
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-02-12 15:21:27 +00:00

20 lines
412 B
Plaintext

/*#pragma settings NoInline*/
uniform half4 colorGreen, colorRed;
half2 tricky(half x, half y, inout half2 color, half z) {
color.xy = color.yx;
return half2(x + y, z);
}
void func(inout half4 color) {
half2 t = tricky(1, 2, color.rb, 5);
color.ga = t;
}
half4 main() {
half4 result = half4(0, 1, 2, 3);
func(result);
return result == half4(2, 3, 0, 5) ? colorGreen : colorRed;
}