skia2/resources/sksl/dslfp/GrDSLFPTest_Ternary.fp
John Stiles 16cbfb41df Implement statements and expressions in DSL C++ code generator.
This CL removes the bulk of the existing C++ code generator, especially
all the complex format-string assembly code. It has been replaced with
actual DSL code generation. Simple IR can now be successfully translated
to a working DSL fragment processor.

This CL also adds a simple test harness which is patterned after the
existing SkSLTest; it renders a pixel, reads it back, and fails the test
if the result isn't solid green (RGBA=0101).

This CL doesn't implement every feature. Some obvious gaps include:
- Sampling from children
- Uniforms/inputs of any kind
- Function calls of any kind

Change-Id: Ib80c23fe1ba4453f7c3cb43b65f93c5ea0deb709
Bug: skia:11854
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/396757
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-04-20 19:28:36 +00:00

12 lines
453 B
GLSL

half4 main() {
half4 green = half4(0, 1, 0, 1);
half4 red = half4(1, 0, 0, 1);
bool t = true;
bool f = false;
return half4(t ? green.r : red.r, // true -> green.r
f ? red.g : green.g, // false -> green.g
(green.g == red.r) ? green.b : red.r, // true -> green.b
(green.a != red.a) ? red.g : green.a); // false -> green.a
}