skia2/resources/sksl/dslfp/GrDSLFPTest_SwitchStatement.fp

29 lines
688 B
Plaintext
Raw Normal View History

layout(key) in int ten; // always equals 10
Reland "Reland "Implement statements and expressions in DSL C++ code generator."" This is a reland of c412688798e572ac8ca6414a19a48d007500f751 This CL lands the code changes but not the dm test, which is causing link errors. Tests will be relanded as a separate CL, at http://review.skia.org/400097 Original change's description: > Reland "Implement statements and expressions in DSL C++ code generator." > > This is a reland of 16cbfb41dff107ca3388bacf34201311d3c5f14d > > Tests now rely on `shaderDerivativeSupport` and `integerSupport` as > proxies to indicate ES3 support. The SwitchStatement test has been > adjusted to hopefully confuse fewer compilers. > > Original change's description: > > 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> > > Bug: skia:11854, skia:11891 > Change-Id: I91363e31f34611d15ae350b52d6fc459feeace9c > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/399076 > Auto-Submit: John Stiles <johnstiles@google.com> > Commit-Queue: Ethan Nicholas <ethannicholas@google.com> > Reviewed-by: Ethan Nicholas <ethannicholas@google.com> Bug: skia:11854 Bug: skia:11891 Change-Id: Ib1f08256c84d1da2130e0b61356f72435dc0a5a8 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/399740 Reviewed-by: Ethan Nicholas <ethannicholas@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com> Commit-Queue: John Stiles <johnstiles@google.com> Auto-Submit: John Stiles <johnstiles@google.com>
2021-04-22 19:05:20 +00:00
half4 main() {
int4 color = int4(0);
switch (color.r) { // will take case 0
case 0: ++color.g; // fallthrough
case 1: break;
case 2: return half4(0);
case 3: // fallthrough
case 4: ++color.r; // fallthrough
case 5: { ++color.b; } break;
default: { --color.g; break; }
}
switch (color.g) { // will take case 1
case 1: break;
case 0: { color.r = 1; color.b = 1; }
}
@switch (ten) {
Reland "Reland "Implement statements and expressions in DSL C++ code generator."" This is a reland of c412688798e572ac8ca6414a19a48d007500f751 This CL lands the code changes but not the dm test, which is causing link errors. Tests will be relanded as a separate CL, at http://review.skia.org/400097 Original change's description: > Reland "Implement statements and expressions in DSL C++ code generator." > > This is a reland of 16cbfb41dff107ca3388bacf34201311d3c5f14d > > Tests now rely on `shaderDerivativeSupport` and `integerSupport` as > proxies to indicate ES3 support. The SwitchStatement test has been > adjusted to hopefully confuse fewer compilers. > > Original change's description: > > 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> > > Bug: skia:11854, skia:11891 > Change-Id: I91363e31f34611d15ae350b52d6fc459feeace9c > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/399076 > Auto-Submit: John Stiles <johnstiles@google.com> > Commit-Queue: Ethan Nicholas <ethannicholas@google.com> > Reviewed-by: Ethan Nicholas <ethannicholas@google.com> Bug: skia:11854 Bug: skia:11891 Change-Id: Ib1f08256c84d1da2130e0b61356f72435dc0a5a8 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/399740 Reviewed-by: Ethan Nicholas <ethannicholas@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com> Commit-Queue: John Stiles <johnstiles@google.com> Auto-Submit: John Stiles <johnstiles@google.com>
2021-04-22 19:05:20 +00:00
case 0: color.r = color.g; break;
case 20: color.b = color.g; break;
case 10: color.a = color.g; break;
}
return half4(color);
}