Pass in actual sampled texture and sample params to gpu uniform builders.

To support external textures vulkan needs to know the actual sampler it
will use at pipeline creation time. Thus we need access to the actual
vkimage and sampler state to know how to make these samplers early.

Bug: skia:
Change-Id: I8492bb283932d6800dbfcc8bc86b3bba947397fe
Reviewed-on: https://skia-review.googlesource.com/c/166281
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/vk/GrVkGpuCommandBuffer.cpp b/src/gpu/vk/GrVkGpuCommandBuffer.cpp
index 9ffd8f8..1d6d585 100644
--- a/src/gpu/vk/GrVkGpuCommandBuffer.cpp
+++ b/src/gpu/vk/GrVkGpuCommandBuffer.cpp
@@ -580,7 +580,6 @@
         currCmdBuf->bindInputBuffer(fGpu, binding++,
                                     static_cast<const GrVkVertexBuffer*>(instanceBuffer));
     }
-
     if (indexBuffer) {
         SkASSERT(indexBuffer);
         SkASSERT(!indexBuffer->isMapped());
@@ -601,9 +600,19 @@
 
     VkRenderPass compatibleRenderPass = cbInfo.fRenderPass->vkRenderPass();
 
+    const GrTextureProxy* const* primProcProxies = nullptr;
+    if (dynamicStateArrays && dynamicStateArrays->fPrimitiveProcessorTextures) {
+        primProcProxies = dynamicStateArrays->fPrimitiveProcessorTextures;
+    } else if (fixedDynamicState) {
+        primProcProxies = fixedDynamicState->fPrimitiveProcessorTextures;
+    }
+
+    SkASSERT(SkToBool(primProcProxies) == SkToBool(primProc.numTextureSamplers()));
+
     GrVkPipelineState* pipelineState =
         fGpu->resourceProvider().findOrCreateCompatiblePipelineState(pipeline,
                                                                      primProc,
+                                                                     primProcProxies,
                                                                      primitiveType,
                                                                      compatibleRenderPass);
     if (!pipelineState) {
@@ -624,10 +633,6 @@
     // Check whether we need to bind textures between each GrMesh. If not we can bind them all now.
     bool setTextures = !(dynamicStateArrays && dynamicStateArrays->fPrimitiveProcessorTextures);
     if (setTextures) {
-        const GrTextureProxy* const* primProcProxies = nullptr;
-        if (fixedDynamicState) {
-            primProcProxies = fixedDynamicState->fPrimitiveProcessorTextures;
-        }
         pipelineState->setAndBindTextures(fGpu, primProc, pipeline, primProcProxies,
                                           cbInfo.currentCmdBuf());
     }