DSL var values are now specified at construction time rather than in
Declare
This solves several issues caused by the lack of ordering guarantees in
C++; it was possible for the SkSL backend to look for the value of a
variable before its Declare() call gets processed. Moving the initial
value out of Declare should fix this whole class of problems.
Change-Id: I428fe230f1c312a0128c1f00c2a36cb95f4590a6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/380358
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/gm/dsl_processor_test.cpp b/gm/dsl_processor_test.cpp
index fff5577..5d5caa3 100644
--- a/gm/dsl_processor_test.cpp
+++ b/gm/dsl_processor_test.cpp
@@ -36,14 +36,14 @@
StartFragmentProcessor(this, &args);
// Test for skbug.com/11384
- Var x(kInt);
- Declare(x, 1);
+ Var x(kInt, 1);
+ Declare(x);
SkASSERT(DSLWriter::Var(x).initialValue()->description() == "1");
Var blueAlpha(kUniform_Modifier, kHalf2);
fBlueAlphaUniform = VarUniformHandle(blueAlpha);
- Var coords(kFloat4);
- Declare(coords, sk_FragCoord());
+ Var coords(kFloat4, sk_FragCoord());
+ Declare(coords);
Return(Half4(Swizzle(coords, X, Y) / 100, blueAlpha));
EndFragmentProcessor();
}