skia2/tests/sksl/shared/DeadStripFunctions.sksl
John Stiles ade695ea4a Add unit test for function dead-stripping.
This test verifies that dead-stripping works on both built-in and user
functions, if their function call is optimized away.

Change-Id: I3125a34640c69de43c383343cd00d97e5a32ac60
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/338836
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-11-30 15:16:44 +00:00

28 lines
658 B
Plaintext

/*#pragma settings NoInline*/
half4 dead_fn(half4 a, half4 b) {
return a * b;
}
half4 live_fn(half4 a, half4 b) {
return a + b;
}
void main() {
@switch (999) {
// Dead stripping a user function.
case 0: sk_FragColor = dead_fn(half4(0.5), half4(2)); break;
// A live user function.
case 999: sk_FragColor = live_fn(half4(3), half4(-3)); break;
}
@switch (777) {
// Dead stripping a built-in function.
case 0: sk_FragColor = blend_modulate(half4(1), half4(-1)); break;
// A live built-in function.
case 777: sk_FragColor = blend_dst(half4(7), half4(-7)); break;
}
}