Runtime effects: Detect passthrough sample calls automatically

As explained, this is *very* conservative. It only works when the child
is sampled from within main, and using a direct reference to the coords
parameter. If that parameter is ever modified (even after being used),
the optimization doesn't happen. For most cases, this is fine.

Bug: skia:11869
Change-Id: Ia06181730a6d07e2a4fe2de4cc8e8c3402f0dc52
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/397320
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/gm/runtimeshader.cpp b/gm/runtimeshader.cpp
index 5ec6cd7..578f28a 100644
--- a/gm/runtimeshader.cpp
+++ b/gm/runtimeshader.cpp
@@ -134,10 +134,10 @@
         }
 
         half4 main(float2 xy) {
-            half4 before = sample(before_map);
-            half4 after = sample(after_map);
+            half4 before = sample(before_map, xy);
+            half4 after = sample(after_map, xy);
 
-            float m = smooth_cutoff(sample(threshold_map).a);
+            float m = smooth_cutoff(sample(threshold_map, xy).a);
             return mix(before, after, m);
         }
     )", kAnimate_RTFlag | kBench_RTFlag) {}
@@ -228,7 +228,7 @@
         uniform float inv_size;
 
         half4 main(float2 xy) {
-            float4 c = unpremul(sample(input));
+            float4 c = unpremul(sample(input, xy));
 
             // Map to cube coords:
             float3 cubeCoords = float3(c.rg * rg_scale + rg_bias, c.b * b_scale);