skia2/resources/sksl/shared/CommaSideEffects.sksl
John Stiles 94e72b90b8 Add test to verify side effects from the comma operator.
SkVMCodeGenerator was lacking support for the comma operator entirely;
this has now been implemented.

Change-Id: I9350f54e6ee52764c620116e6dbfe4ca3e9cd47e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/363096
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-02-01 16:16:58 +00:00

26 lines
549 B
Plaintext

/*#pragma settings NoInline*/
uniform half4 colorRed, colorGreen, colorWhite, colorBlack;
void setToColorBlack(out half4 x) {
x = colorBlack;
}
half4 main() {
half4 a, b, c, d;
(b = colorRed), (c = colorGreen);
a = (setToColorBlack(d), colorWhite);
// These uniforms only contain 1s and 0s so these multiplies should be no-ops.
a *= a;
b *= b;
c *= c;
d *= d;
return (a == colorWhite &&
b == colorRed &&
c == colorGreen &&
d == colorBlack) ? colorGreen : colorRed;
}