Don't rely on primProc textures when adding samplers

Change-Id: Idee88e061004c308665ad5e7c56528398c8e7201
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/274842
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
diff --git a/src/gpu/GrOpsRenderPass.cpp b/src/gpu/GrOpsRenderPass.cpp
index 9ce11a0..6de07f3 100644
--- a/src/gpu/GrOpsRenderPass.cpp
+++ b/src/gpu/GrOpsRenderPass.cpp
@@ -115,11 +115,19 @@
 
 void GrOpsRenderPass::bindTextures(const GrPrimitiveProcessor& primProc, const GrPipeline& pipeline,
                                    const GrSurfaceProxy* const primProcTextures[]) {
+#ifdef SK_DEBUG
+    SkASSERT((primProc.numTextureSamplers() > 0) == SkToBool(primProcTextures));
+    for (int i = 0; i < primProc.numTextureSamplers(); ++i) {
+        SkASSERT(primProcTextures[i]->backendFormat() ==
+                 primProc.textureSampler(i).backendFormat());
+    }
+#endif
+
     if (DrawPipelineStatus::kOk != fDrawPipelineStatus) {
         SkASSERT(DrawPipelineStatus::kNotConfigured != fDrawPipelineStatus);
         return;
     }
-    SkASSERT((primProc.numTextureSamplers() > 0) == SkToBool(primProcTextures));
+
     // Don't assert on fTextureBindingStatus. onBindTextures() just turns into a no-op when there
     // aren't any textures, and it's hard to tell from the GrPipeline whether there are any. For
     // many clients it is easier to just always call this method.
@@ -127,6 +135,7 @@
         fDrawPipelineStatus = DrawPipelineStatus::kFailedToBind;
         return;
     }
+
     SkDEBUGCODE(fTextureBindingStatus = DynamicStateStatus::kConfigured);
 }