SkSL: Salt inline identifiers in PipelineStage and FragmentProcessor passes
Fixes a bug with name conflicts in the final SkSL.
Bug: skia:10526
Change-Id: Ic238f89dd778c186e775ecbaabfbaed9e426274f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/305563
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
diff --git a/tests/SkRuntimeEffectTest.cpp b/tests/SkRuntimeEffectTest.cpp
index 9ec8234..e39c16c 100644
--- a/tests/SkRuntimeEffectTest.cpp
+++ b/tests/SkRuntimeEffectTest.cpp
@@ -196,6 +196,10 @@
effect.test(0xFF000000, 0xFF00007F, 0xFF007F00, 0xFF007F7F,
[](SkCanvas* canvas, SkPaint*) { canvas->rotate(45.0f); });
+ //
+ // Sampling children
+ //
+
// Sampling a null child should return the paint color
effect.build("in shader child;",
"color = sample(child);");
@@ -222,6 +226,16 @@
"color = sample(child, float3x3(0, 1, 0, 1, 0, 0, 0, 0, 1));");
effect.child("child") = rgbwShader;
effect.test(0xFF0000FF, 0xFFFF0000, 0xFF00FF00, 0xFFFFFFFF);
+
+ //
+ // Helper functions
+ //
+
+ // Test case for inlining in the pipeline-stage and fragment-shader passes (skbug.com/10526):
+ effect.build("float2 helper(float2 x) { return x + 1; }",
+ "float2 v = helper(p);"
+ "color = half4(half2(v), 0, 1);");
+ effect.test(0xFF00FFFF);
}
DEF_TEST(SkRuntimeEffectSimple, r) {
diff --git a/tests/SkSLFPTest.cpp b/tests/SkSLFPTest.cpp
index e8516dc..4f46f28 100644
--- a/tests/SkSLFPTest.cpp
+++ b/tests/SkSLFPTest.cpp
@@ -830,12 +830,12 @@
"R\"SkSL(return c.wzyx;\n"
")SkSL\", &flip_name);",
"fragBuilder->codeAppendf(\n"
- "R\"SkSL(half4 inlineResult0;\n"
- "half4 inlineArg1_0 = %s;\n"
+ "R\"SkSL(half4 inlineResult_fp_0;\n"
+ "half4 inlineArg_fp_1_0 = %s;\n"
"{\n"
- " inlineResult0 = inlineArg1_0.wzyx;\n"
+ " inlineResult_fp_0 = inlineArg_fp_1_0.wzyx;\n"
"}\n"
- "%s = inlineResult0;\n"
+ "%s = inlineResult_fp_0;\n"
"\n"
")SkSL\"\n"
", args.fInputColor, args.fOutputColor);"