Elide sample coords for GrSkSLFP if only used for pass-through sampling

If every use of the coords passed to main was for a call to sample that
was converted to pass-through sampling... We don't actually reference
the sample coords, so we can un-set the flag. This prevents the FP from
requesting an extra set of (unused) coords, which saves a varying
between the vertex and fragment shaders.

Bug: skia:11869
Change-Id: I4e15876031717b8bcf642e742bad8ae26d6bd020
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/411871
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 399d530..e28a2d9 100644
--- a/tests/SkRuntimeEffectTest.cpp
+++ b/tests/SkRuntimeEffectTest.cpp
@@ -586,11 +586,6 @@
     //
     // It also checks that we correctly set the "referencesSampleCoords" bit on the runtime effect
     // FP, depending on how the coords parameter to main is used.
-    //
-    // TODO(skia:11869): Today, any reference to sample coords marks them as being referenced. If
-    // the *only* use is in sample calls that are converted to passthrough by our optimization,
-    // they should not be considered referenced. (This will prevent us from adding an unnecessary
-    // varying to the shaders).
 
     auto test = [&](const char* src, bool expectExplicit, bool expectReferencesSampleCoords) {
         auto [effect, err] =
@@ -607,9 +602,9 @@
 
     // Cases where our optimization is valid, and works:
 
-    // Direct use of passed-in coords
-    // TODO(skia:11869): This is the case where referencesSampleCoords *should* be false
-    test("half4 main(float2 xy) { return sample(child, xy); }", false, true);
+    // Direct use of passed-in coords. Here, the only use of sample coords is for a sample call
+    // converted to passthrough, so referenceSampleCoords is *false*, despite appearing in main.
+    test("half4 main(float2 xy) { return sample(child, xy); }", false, false);
     // Sample with passed-in coords, read (but don't write) sample coords elsewhere
     test("half4 main(float2 xy) { return sample(child, xy) + sin(xy.x); }", false, true);