Remove GrGLSLSampler type and subclasses
authorBrian Salomon <bsalomon@google.com>
Fri, 18 Nov 2016 16:58:54 +0000 (11:58 -0500)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Mon, 21 Nov 2016 18:01:43 +0000 (18:01 +0000)
GrGLSLUniformManager and GrGLSLProgramDataManager subclasses handle sampler variation across GPU backends.

BUG=skia:

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=5002

Change-Id: I968b006bab978c2fa209d1f7eda710c298d1212f
Reviewed-on: https://skia-review.googlesource.com/5002
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>

27 files changed:
gn/gpu.gni
src/effects/SkBlurMaskFilter.cpp
src/effects/SkShadowMaskFilter.cpp
src/gpu/effects/GrTextureDomain.cpp
src/gpu/effects/GrTextureDomain.h
src/gpu/gl/GrGLProgram.cpp
src/gpu/gl/GrGLProgram.h
src/gpu/gl/GrGLProgramDataManager.cpp
src/gpu/gl/GrGLProgramDataManager.h
src/gpu/gl/GrGLSampler.h [deleted file]
src/gpu/gl/GrGLUniformHandler.cpp
src/gpu/gl/GrGLUniformHandler.h
src/gpu/gl/builders/GrGLProgramBuilder.cpp
src/gpu/glsl/GrGLSLFragmentProcessor.h
src/gpu/glsl/GrGLSLPrimitiveProcessor.h
src/gpu/glsl/GrGLSLProgramBuilder.cpp
src/gpu/glsl/GrGLSLProgramBuilder.h
src/gpu/glsl/GrGLSLSampler.h [deleted file]
src/gpu/glsl/GrGLSLShaderBuilder.cpp
src/gpu/glsl/GrGLSLShaderBuilder.h
src/gpu/glsl/GrGLSLUniformHandler.h
src/gpu/glsl/GrGLSLXferProcessor.h
src/gpu/vk/GrVkDescriptorSetManager.cpp
src/gpu/vk/GrVkGLSLSampler.h [deleted file]
src/gpu/vk/GrVkResourceProvider.cpp
src/gpu/vk/GrVkUniformHandler.cpp
src/gpu/vk/GrVkUniformHandler.h

index 21206f6..84b3624 100644 (file)
@@ -372,7 +372,6 @@ skia_gpu_sources = [
   "$_src/gpu/gl/GrGLProgramDataManager.h",
   "$_src/gpu/gl/GrGLRenderTarget.cpp",
   "$_src/gpu/gl/GrGLRenderTarget.h",
-  "$_src/gpu/gl/GrGLSampler.h",
   "$_src/gpu/gl/GrGLStencilAttachment.cpp",
   "$_src/gpu/gl/GrGLStencilAttachment.h",
   "$_src/gpu/gl/GrGLTestInterface.cpp",
@@ -420,7 +419,6 @@ skia_gpu_sources = [
   "$_src/gpu/glsl/GrGLSLProgramBuilder.h",
   "$_src/gpu/glsl/GrGLSLProgramDataManager.cpp",
   "$_src/gpu/glsl/GrGLSLProgramDataManager.h",
-  "$_src/gpu/glsl/GrGLSLSampler.h",
   "$_src/gpu/glsl/GrGLSLShaderBuilder.cpp",
   "$_src/gpu/glsl/GrGLSLShaderBuilder.h",
   "$_src/gpu/glsl/GrGLSLShaderVar.h",
@@ -477,7 +475,6 @@ skia_vk_sources = [
   "$_src/gpu/vk/GrVkExtensions.h",
   "$_src/gpu/vk/GrVkFramebuffer.cpp",
   "$_src/gpu/vk/GrVkFramebuffer.h",
-  "$_src/gpu/vk/GrVkGLSLSampler.h",
   "$_src/gpu/vk/GrVkGpu.cpp",
   "$_src/gpu/vk/GrVkGpu.h",
   "$_src/gpu/vk/GrVkGpuCommandBuffer.cpp",
index e5d521a..92911bc 100644 (file)
@@ -27,7 +27,6 @@
 #include "glsl/GrGLSLFragmentProcessor.h"
 #include "glsl/GrGLSLFragmentShaderBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
-#include "glsl/GrGLSLSampler.h"
 #include "glsl/GrGLSLUniformHandler.h"
 #endif
 
index 25feaf6..3894d74 100755 (executable)
@@ -20,7 +20,6 @@
 #include "glsl/GrGLSLFragmentProcessor.h"
 #include "glsl/GrGLSLFragmentShaderBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
-#include "glsl/GrGLSLSampler.h"
 #include "glsl/GrGLSLUniformHandler.h"
 #include "SkStrokeRec.h"
 #endif
index 51f3051..e3129fd 100644 (file)
@@ -12,7 +12,6 @@
 #include "glsl/GrGLSLFragmentProcessor.h"
 #include "glsl/GrGLSLFragmentShaderBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
-#include "glsl/GrGLSLSampler.h"
 #include "glsl/GrGLSLShaderBuilder.h"
 #include "glsl/GrGLSLUniformHandler.h"
 
index 4c3cf22..3ba6ee8 100644 (file)
@@ -15,7 +15,6 @@
 class GrGLProgramBuilder;
 class GrGLSLShaderBuilder;
 class GrInvariantOutput;
-class GrGLSLSampler;
 class GrGLSLUniformHandler;
 struct SkRect;
 
index 27361e7..1f2e1c8 100644 (file)
@@ -31,7 +31,7 @@ GrGLProgram::GrGLProgram(GrGLGpu* gpu,
                          const BuiltinUniformHandles& builtinUniforms,
                          GrGLuint programID,
                          const UniformInfoArray& uniforms,
-                         const SkTArray<GrGLSampler>& samplers,
+                         const UniformInfoArray& samplers,
                          const VaryingInfoArray& pathProcVaryings,
                          GrGLSLPrimitiveProcessor* geometryProcessor,
                          GrGLSLXferProcessor* xferProcessor,
index 157f404..3b0940e 100644 (file)
@@ -111,8 +111,8 @@ protected:
                 const GrProgramDesc&,
                 const BuiltinUniformHandles&,
                 GrGLuint programID,
-                const UniformInfoArray&,
-                const SkTArray<GrGLSampler>&,
+                const UniformInfoArray& uniforms,
+                const UniformInfoArray& samplers,
                 const VaryingInfoArray&, // used for NVPR only currently
                 GrGLSLPrimitiveProcessor* geometryProcessor,
                 GrGLSLXferProcessor* xferProcessor,
index 9fe7d3b..68d0166 100644 (file)
@@ -30,18 +30,7 @@ GrGLProgramDataManager::GrGLProgramDataManager(GrGLGpu* gpu, GrGLuint programID,
             uniform.fArrayCount = builderUniform.fVariable.getArrayCount();
             uniform.fType = builderUniform.fVariable.getType();
         );
-        // TODO: Move the Xoom uniform array in both FS and VS bug workaround here.
-
-        if (kVertex_GrShaderFlag & builderUniform.fVisibility) {
-            uniform.fVSLocation = builderUniform.fLocation;
-        } else {
-            uniform.fVSLocation = kUnusedUniform;
-        }
-        if (kFragment_GrShaderFlag & builderUniform.fVisibility) {
-            uniform.fFSLocation = builderUniform.fLocation;
-        } else {
-            uniform.fFSLocation = kUnusedUniform;
-        }
+        uniform.fLocation = builderUniform.fLocation;
     }
 
     // NVPR programs have separable varyings
@@ -61,30 +50,17 @@ GrGLProgramDataManager::GrGLProgramDataManager(GrGLGpu* gpu, GrGLuint programID,
     }
 }
 
-void GrGLProgramDataManager::setSamplers(const SkTArray<GrGLSampler>& samplers) const {
+void GrGLProgramDataManager::setSamplers(const UniformInfoArray& samplers) const {
     for (int i = 0; i < samplers.count(); ++i) {
-        GrGLint vsLocation;
-        GrGLint fsLocation;
-        const GrGLSampler& sampler = samplers[i];
-        if (kVertex_GrShaderFlag & sampler.visibility()) {
-            vsLocation = sampler.location();
+        const UniformInfo& sampler = samplers[i];
+        SkASSERT(sampler.fVisibility);
+        if (kUnusedUniform != sampler.fLocation) {
+            GR_GL_CALL(fGpu->glInterface(), Uniform1i(sampler.fLocation, i));
         } else {
-            vsLocation = kUnusedUniform;
-        }
-        if (kFragment_GrShaderFlag & sampler.visibility()) {
-            fsLocation = sampler.location();
-        } else {
-            fsLocation = kUnusedUniform;
-        }
-        // FIXME: We still insert a single sampler uniform for every stage. If the shader does not
-        // reference the sampler then the compiler may have optimized it out. Uncomment this assert
-        // once stages insert their own samplers.
-        // this->printUnused(uni);
-        if (kUnusedUniform != fsLocation) {
-            GR_GL_CALL(fGpu->glInterface(), Uniform1i(fsLocation, i));
-        }
-        if (kUnusedUniform != vsLocation && vsLocation != fsLocation) {
-            GR_GL_CALL(fGpu->glInterface(), Uniform1i(vsLocation, i));
+            // FIXME: We still insert a single sampler uniform for every stage. If the shader does
+            // not reference the sampler then the compiler may have optimized it out. Uncomment this
+            // assert once stages insert their own samplers.
+            // this->printUnused(uni);
         }
     }
 }
@@ -94,11 +70,8 @@ void GrGLProgramDataManager::set1i(UniformHandle u, int32_t i) const {
     SkASSERT(uni.fType == kInt_GrSLType);
     SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
     SkDEBUGCODE(this->printUnused(uni));
-    if (kUnusedUniform != uni.fFSLocation) {
-        GR_GL_CALL(fGpu->glInterface(), Uniform1i(uni.fFSLocation, i));
-    }
-    if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
-        GR_GL_CALL(fGpu->glInterface(), Uniform1i(uni.fVSLocation, i));
+    if (kUnusedUniform != uni.fLocation) {
+        GR_GL_CALL(fGpu->glInterface(), Uniform1i(uni.fLocation, i));
     }
 }
 
@@ -109,11 +82,8 @@ void GrGLProgramDataManager::set1iv(UniformHandle u,
     SkASSERT(uni.fType == kInt_GrSLType);
     SkASSERT(arrayCount > 0);
     ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount);
-    if (kUnusedUniform != uni.fFSLocation) {
-        GR_GL_CALL(fGpu->glInterface(), Uniform1iv(uni.fFSLocation, arrayCount, v));
-    }
-    if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
-        GR_GL_CALL(fGpu->glInterface(), Uniform1iv(uni.fVSLocation, arrayCount, v));
+    if (kUnusedUniform != uni.fLocation) {
+        GR_GL_CALL(fGpu->glInterface(), Uniform1iv(uni.fLocation, arrayCount, v));
     }
 }
 
@@ -122,11 +92,8 @@ void GrGLProgramDataManager::set1f(UniformHandle u, float v0) const {
     SkASSERT(uni.fType == kFloat_GrSLType);
     SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
     SkDEBUGCODE(this->printUnused(uni);)
-    if (kUnusedUniform != uni.fFSLocation) {
-        GR_GL_CALL(fGpu->glInterface(), Uniform1f(uni.fFSLocation, v0));
-    }
-    if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
-        GR_GL_CALL(fGpu->glInterface(), Uniform1f(uni.fVSLocation, v0));
+    if (kUnusedUniform != uni.fLocation) {
+        GR_GL_CALL(fGpu->glInterface(), Uniform1f(uni.fLocation, v0));
     }
 }
 
@@ -141,11 +108,8 @@ void GrGLProgramDataManager::set1fv(UniformHandle u,
     // Once the uniform manager is responsible for inserting the duplicate uniform
     // arrays in VS and FS driver bug workaround, this can be enabled.
     // this->printUni(uni);
-    if (kUnusedUniform != uni.fFSLocation) {
-        GR_GL_CALL(fGpu->glInterface(), Uniform1fv(uni.fFSLocation, arrayCount, v));
-    }
-    if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
-        GR_GL_CALL(fGpu->glInterface(), Uniform1fv(uni.fVSLocation, arrayCount, v));
+    if (kUnusedUniform != uni.fLocation) {
+        GR_GL_CALL(fGpu->glInterface(), Uniform1fv(uni.fLocation, arrayCount, v));
     }
 }
 
@@ -154,11 +118,8 @@ void GrGLProgramDataManager::set2f(UniformHandle u, float v0, float v1) const {
     SkASSERT(uni.fType == kVec2f_GrSLType);
     SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
     SkDEBUGCODE(this->printUnused(uni);)
-    if (kUnusedUniform != uni.fFSLocation) {
-        GR_GL_CALL(fGpu->glInterface(), Uniform2f(uni.fFSLocation, v0, v1));
-    }
-    if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
-        GR_GL_CALL(fGpu->glInterface(), Uniform2f(uni.fVSLocation, v0, v1));
+    if (kUnusedUniform != uni.fLocation) {
+        GR_GL_CALL(fGpu->glInterface(), Uniform2f(uni.fLocation, v0, v1));
     }
 }
 
@@ -170,11 +131,8 @@ void GrGLProgramDataManager::set2fv(UniformHandle u,
     SkASSERT(arrayCount > 0);
     ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount);
     SkDEBUGCODE(this->printUnused(uni);)
-    if (kUnusedUniform != uni.fFSLocation) {
-        GR_GL_CALL(fGpu->glInterface(), Uniform2fv(uni.fFSLocation, arrayCount, v));
-    }
-    if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
-        GR_GL_CALL(fGpu->glInterface(), Uniform2fv(uni.fVSLocation, arrayCount, v));
+    if (kUnusedUniform != uni.fLocation) {
+        GR_GL_CALL(fGpu->glInterface(), Uniform2fv(uni.fLocation, arrayCount, v));
     }
 }
 
@@ -183,11 +141,8 @@ void GrGLProgramDataManager::set3f(UniformHandle u, float v0, float v1, float v2
     SkASSERT(uni.fType == kVec3f_GrSLType);
     SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
     SkDEBUGCODE(this->printUnused(uni);)
-    if (kUnusedUniform != uni.fFSLocation) {
-        GR_GL_CALL(fGpu->glInterface(), Uniform3f(uni.fFSLocation, v0, v1, v2));
-    }
-    if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
-        GR_GL_CALL(fGpu->glInterface(), Uniform3f(uni.fVSLocation, v0, v1, v2));
+    if (kUnusedUniform != uni.fLocation) {
+        GR_GL_CALL(fGpu->glInterface(), Uniform3f(uni.fLocation, v0, v1, v2));
     }
 }
 
@@ -199,11 +154,8 @@ void GrGLProgramDataManager::set3fv(UniformHandle u,
     SkASSERT(arrayCount > 0);
     ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount);
     SkDEBUGCODE(this->printUnused(uni);)
-    if (kUnusedUniform != uni.fFSLocation) {
-        GR_GL_CALL(fGpu->glInterface(), Uniform3fv(uni.fFSLocation, arrayCount, v));
-    }
-    if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
-        GR_GL_CALL(fGpu->glInterface(), Uniform3fv(uni.fVSLocation, arrayCount, v));
+    if (kUnusedUniform != uni.fLocation) {
+        GR_GL_CALL(fGpu->glInterface(), Uniform3fv(uni.fLocation, arrayCount, v));
     }
 }
 
@@ -216,11 +168,8 @@ void GrGLProgramDataManager::set4f(UniformHandle u,
     SkASSERT(uni.fType == kVec4f_GrSLType);
     SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
     SkDEBUGCODE(this->printUnused(uni);)
-    if (kUnusedUniform != uni.fFSLocation) {
-        GR_GL_CALL(fGpu->glInterface(), Uniform4f(uni.fFSLocation, v0, v1, v2, v3));
-    }
-    if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
-        GR_GL_CALL(fGpu->glInterface(), Uniform4f(uni.fVSLocation, v0, v1, v2, v3));
+    if (kUnusedUniform != uni.fLocation) {
+        GR_GL_CALL(fGpu->glInterface(), Uniform4f(uni.fLocation, v0, v1, v2, v3));
     }
 }
 
@@ -232,11 +181,8 @@ void GrGLProgramDataManager::set4fv(UniformHandle u,
     SkASSERT(arrayCount > 0);
     ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount);
     SkDEBUGCODE(this->printUnused(uni);)
-    if (kUnusedUniform != uni.fFSLocation) {
-        GR_GL_CALL(fGpu->glInterface(), Uniform4fv(uni.fFSLocation, arrayCount, v));
-    }
-    if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
-        GR_GL_CALL(fGpu->glInterface(), Uniform4fv(uni.fVSLocation, arrayCount, v));
+    if (kUnusedUniform != uni.fLocation) {
+        GR_GL_CALL(fGpu->glInterface(), Uniform4fv(uni.fLocation, arrayCount, v));
     }
 }
 
@@ -274,11 +220,8 @@ template<int N> inline void GrGLProgramDataManager::setMatrices(UniformHandle u,
     SkASSERT(arrayCount > 0);
     ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount);
     SkDEBUGCODE(this->printUnused(uni);)
-    if (kUnusedUniform != uni.fFSLocation) {
-        set_uniform_matrix<N>::set(fGpu->glInterface(), uni.fFSLocation, arrayCount, matrices);
-    }
-    if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
-        set_uniform_matrix<N>::set(fGpu->glInterface(), uni.fVSLocation, arrayCount, matrices);
+    if (kUnusedUniform != uni.fLocation) {
+        set_uniform_matrix<N>::set(fGpu->glInterface(), uni.fLocation, arrayCount, matrices);
     }
 }
 
@@ -318,7 +261,7 @@ void GrGLProgramDataManager::setPathFragmentInputTransform(VaryingHandle u,
 
 #ifdef SK_DEBUG
 void GrGLProgramDataManager::printUnused(const Uniform& uni) const {
-    if (kUnusedUniform == uni.fFSLocation && kUnusedUniform == uni.fVSLocation) {
+    if (kUnusedUniform == uni.fLocation) {
         GrCapsDebugf(fGpu->caps(), "Unused uniform in shader\n");
     }
 }
index 30c4a63..fa1456d 100644 (file)
@@ -11,7 +11,6 @@
 #include "glsl/GrGLSLProgramDataManager.h"
 
 #include "GrAllocator.h"
-#include "gl/GrGLSampler.h"
 #include "gl/GrGLTypes.h"
 #include "glsl/GrGLSLShaderVar.h"
 
@@ -38,6 +37,7 @@ public:
         GrGLint         fLocation;
     };
 
+
     // This uses an allocator rather than array so that the GrGLSLShaderVars don't move in memory
     // after they are inserted. Users of GrGLShaderBuilder get refs to the vars and ptrs to their
     // name strings. Otherwise, we'd have to hand out copies.
@@ -48,7 +48,7 @@ public:
                            const VaryingInfoArray&);
 
 
-    void setSamplers(const SkTArray<GrGLSampler>& samplers) const;
+    void setSamplers(const UniformInfoArray& samplers) const;
 
     /** Functions for uploading uniform values. The varities ending in v can be used to upload to an
     *  array of uniforms. arrayCount must be <= the array count of the uniform.
@@ -82,12 +82,11 @@ private:
     };
 
     struct Uniform {
-        GrGLint     fVSLocation;
-        GrGLint     fFSLocation;
-        SkDEBUGCODE(
-            GrSLType    fType;
-            int         fArrayCount;
-        );
+        GrGLint     fLocation;
+#ifdef SK_DEBUG
+        GrSLType    fType;
+        int         fArrayCount;
+#endif
     };
 
     enum {
diff --git a/src/gpu/gl/GrGLSampler.h b/src/gpu/gl/GrGLSampler.h
deleted file mode 100644 (file)
index 1f67ac9..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-* Copyright 2016 Google Inc.
-*
-* Use of this source code is governed by a BSD-style license that can be
-* found in the LICENSE file.
-*/
-
-#ifndef GrGLSampler_DEFINED
-#define GrGLSampler_DEFINED
-
-#include "glsl/GrGLSLSampler.h"
-
-#include "gl/GrGLTypes.h"
-#include "glsl/GrGLSLShaderVar.h"
-
-class GrGLSampler : public GrGLSLSampler {
-public:
-    GrGLSampler(uint32_t visibility,
-                GrPixelConfig config,
-                GrSLType type,
-                GrSLPrecision precision,
-                const char* name) : INHERITED(visibility, config) {
-        SkASSERT(GrSLTypeIsCombinedSamplerType(type));
-        fShaderVar.setType(type);
-        fShaderVar.setTypeModifier(GrGLSLShaderVar::kUniform_TypeModifier);
-        fShaderVar.setPrecision(precision);
-        fShaderVar.accessName()->set(name);
-    }
-
-    GrGLint location() const { return fLocation; }
-    GrSLType type() const override { return fShaderVar.getType(); }
-
-    const char* onGetSamplerNameForTexture2D() const override { return fShaderVar.c_str(); }
-    const char* getSamplerNameForTexelFetch() const override { return fShaderVar.c_str(); }
-
-private:
-    GrGLSLShaderVar fShaderVar;
-    GrGLint         fLocation;
-
-    friend class GrGLUniformHandler;
-
-    typedef GrGLSLSampler INHERITED;
-};
-
-#endif
index c388e46..37f2418 100644 (file)
@@ -45,6 +45,7 @@ GrGLSLUniformHandler::UniformHandle GrGLUniformHandler::internalAddUniformArray(
     uni.fVariable.setArrayCount(arrayCount);
     uni.fVisibility = visibility;
     uni.fVariable.setPrecision(precision);
+    uni.fLocation = -1;
 
     if (outName) {
         *outName = uni.fVariable.c_str();
@@ -52,19 +53,30 @@ GrGLSLUniformHandler::UniformHandle GrGLUniformHandler::internalAddUniformArray(
     return GrGLSLUniformHandler::UniformHandle(fUniforms.count() - 1);
 }
 
-GrGLSLUniformHandler::SamplerHandle GrGLUniformHandler::internalAddSampler(uint32_t visibility,
-                                                                           GrPixelConfig config,
-                                                                           GrSLType type,
-                                                                           GrSLPrecision precision,
-                                                                           const char* name) {
+GrGLSLUniformHandler::SamplerHandle GrGLUniformHandler::addSampler(uint32_t visibility,
+                                                                   GrSwizzle swizzle,
+                                                                   GrSLType type,
+                                                                   GrSLPrecision precision,
+                                                                   const char* name) {
     SkASSERT(name && strlen(name));
     SkDEBUGCODE(static const uint32_t kVisMask = kVertex_GrShaderFlag | kFragment_GrShaderFlag);
     SkASSERT(0 == (~kVisMask & visibility));
     SkASSERT(0 != visibility);
+
     SkString mangleName;
     char prefix = 'u';
     fProgramBuilder->nameVariable(&mangleName, prefix, name, true);
-    fSamplers.emplace_back(visibility, config, type, precision, mangleName.c_str());
+
+    UniformInfo& sampler = fSamplers.push_back();
+    SkASSERT(GrSLTypeIsCombinedSamplerType(type));
+    sampler.fVariable.setType(type);
+    sampler.fVariable.setTypeModifier(GrGLSLShaderVar::kUniform_TypeModifier);
+    sampler.fVariable.setPrecision(precision);
+    sampler.fVariable.setName(mangleName);
+    sampler.fLocation = -1;
+    sampler.fVisibility = visibility;
+    fSamplerSwizzles.push_back(swizzle);
+    SkASSERT(fSamplers.count() == fSamplerSwizzles.count());
     return GrGLSLUniformHandler::SamplerHandle(fSamplers.count() - 1);
 }
 
@@ -76,8 +88,8 @@ void GrGLUniformHandler::appendUniformDecls(GrShaderFlags visibility, SkString*
         }
     }
     for (int i = 0; i < fSamplers.count(); ++i) {
-        if (fSamplers[i].visibility() & visibility) {
-            fSamplers[i].fShaderVar.appendDecl(fProgramBuilder->glslCaps(), out);
+        if (fSamplers[i].fVisibility & visibility) {
+            fSamplers[i].fVariable.appendDecl(fProgramBuilder->glslCaps(), out);
             out->append(";\n");
         }
     }
@@ -92,7 +104,7 @@ void GrGLUniformHandler::bindUniformLocations(GrGLuint programID, const GrGLCaps
         }
         for (int i = 0; i < fSamplers.count(); ++i) {
             GrGLint location = i + uniformCnt;
-            GL_CALL(BindUniformLocation(programID, location, fSamplers[i].fShaderVar.c_str()));
+            GL_CALL(BindUniformLocation(programID, location, fSamplers[i].fVariable.c_str()));
             fSamplers[i].fLocation = location;
         }
     }
@@ -108,7 +120,7 @@ void GrGLUniformHandler::getUniformLocations(GrGLuint programID, const GrGLCaps&
         }
         for (int i = 0; i < fSamplers.count(); ++i) {
             GrGLint location;
-            GL_CALL_RET(location, GetUniformLocation(programID, fSamplers[i].fShaderVar.c_str()));
+            GL_CALL_RET(location, GetUniformLocation(programID, fSamplers[i].fVariable.c_str()));
             fSamplers[i].fLocation = location;
         }
     }
index 3656d3a..da5b96d 100644 (file)
@@ -11,7 +11,6 @@
 #include "glsl/GrGLSLUniformHandler.h"
 
 #include "gl/GrGLProgramDataManager.h"
-#include "gl/GrGLSampler.h"
 
 class GrGLCaps;
 
@@ -29,7 +28,8 @@ public:
 private:
     explicit GrGLUniformHandler(GrGLSLProgramBuilder* program)
         : INHERITED(program)
-        , fUniforms(kUniformsPerBlock) {}
+        , fUniforms(kUniformsPerBlock)
+        , fSamplers(kUniformsPerBlock) {}
 
     UniformHandle internalAddUniformArray(uint32_t visibility,
                                           GrSLType type,
@@ -39,15 +39,15 @@ private:
                                           int arrayCount,
                                           const char** outName) override;
 
-    SamplerHandle internalAddSampler(uint32_t visibility,
-                                     GrPixelConfig config,
-                                     GrSLType type,
-                                     GrSLPrecision precision,
-                                     const char* name) override;
+    SamplerHandle addSampler(uint32_t visibility, GrSwizzle, GrSLType, GrSLPrecision,
+                             const char* name) override;
 
-    int numSamplers() const override { return fSamplers.count(); }
-    const GrGLSLSampler& getSampler(SamplerHandle handle) const override {
-        return fSamplers[handle.toIndex()];
+    const GrGLSLShaderVar& samplerVariable(SamplerHandle handle) const override {
+        return fSamplers[handle.toIndex()].fVariable;
+    }
+
+    GrSwizzle samplerSwizzle(SamplerHandle handle) const override {
+        return fSamplerSwizzles[handle.toIndex()];
     }
 
     void appendUniformDecls(GrShaderFlags visibility, SkString*) const override;
@@ -63,9 +63,9 @@ private:
     typedef GrGLProgramDataManager::UniformInfo UniformInfo;
     typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray;
 
-    UniformInfoArray fUniforms;
-
-    SkTArray<GrGLSampler> fSamplers;
+    UniformInfoArray    fUniforms;
+    UniformInfoArray    fSamplers;
+    SkTArray<GrSwizzle> fSamplerSwizzles;
 
     friend class GrGLProgramBuilder;
 
index 370cee6..e951c6b 100644 (file)
@@ -22,7 +22,6 @@
 #include "glsl/GrGLSLFragmentProcessor.h"
 #include "glsl/GrGLSLGeometryProcessor.h"
 #include "glsl/GrGLSLProgramDataManager.h"
-#include "glsl/GrGLSLSampler.h"
 #include "glsl/GrGLSLXferProcessor.h"
 
 #define GL_CALL(X) GR_GL_CALL(this->gpu()->glInterface(), X)
index 2189250..aba68b7 100644 (file)
@@ -11,7 +11,6 @@
 #include "GrFragmentProcessor.h"
 #include "GrShaderVar.h"
 #include "glsl/GrGLSLProgramDataManager.h"
-#include "glsl/GrGLSLSampler.h"
 
 class GrProcessor;
 class GrProcessorKeyBuilder;
index d270fa1..fd77bdd 100644 (file)
@@ -11,7 +11,6 @@
 #include "GrFragmentProcessor.h"
 #include "GrPrimitiveProcessor.h"
 #include "glsl/GrGLSLProgramDataManager.h"
-#include "glsl/GrGLSLSampler.h"
 
 class GrBatchTracker;
 class GrPrimitiveProcessor;
index 1e78788..7dea0be 100644 (file)
@@ -295,8 +295,9 @@ void GrGLSLProgramBuilder::emitSampler(GrSLType samplerType,
         ++fNumFragmentSamplers;
     }
     GrSLPrecision precision = this->glslCaps()->samplerPrecision(config, visibility);
+    GrSwizzle swizzle = this->glslCaps()->configTextureSwizzle(config);
     SamplerHandle handle = this->uniformHandler()->addSampler(visibility,
-                                                              config,
+                                                              swizzle,
                                                               samplerType,
                                                               precision,
                                                               name);
@@ -390,9 +391,6 @@ void GrGLSLProgramBuilder::appendUniformDecls(GrShaderFlags visibility, SkString
     this->uniformHandler()->appendUniformDecls(visibility, out);
 }
 
-const GrGLSLSampler& GrGLSLProgramBuilder::getSampler(SamplerHandle handle) const {
-    return this->uniformHandler()->getSampler(handle);
-}
 
 void GrGLSLProgramBuilder::addRTAdjustmentUniform(GrSLPrecision precision,
                                                   const char* name,
index 8a8cff5..7276144 100644 (file)
@@ -16,7 +16,6 @@
 #include "glsl/GrGLSLPrimitiveProcessor.h"
 #include "glsl/GrGLSLProgramDataManager.h"
 #include "glsl/GrGLSLUniformHandler.h"
-#include "glsl/GrGLSLSampler.h"
 #include "glsl/GrGLSLVertexShaderBuilder.h"
 #include "glsl/GrGLSLXferProcessor.h"
 
@@ -44,7 +43,13 @@ public:
 
     typedef GrGLSLUniformHandler::SamplerHandle SamplerHandle;
 
-    const GrGLSLSampler& getSampler(SamplerHandle handle) const;
+    const GrGLSLShaderVar& samplerVariable(SamplerHandle handle) const {
+        return this->uniformHandler()->samplerVariable(handle);
+    }
+
+    GrSwizzle samplerSwizzle(SamplerHandle handle) const {
+        return this->uniformHandler()->samplerSwizzle(handle);
+    }
 
     // Handles for program uniforms (other than per-effect uniforms)
     struct BuiltinUniformHandles {
diff --git a/src/gpu/glsl/GrGLSLSampler.h b/src/gpu/glsl/GrGLSLSampler.h
deleted file mode 100644 (file)
index bc90769..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2016 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrGLSLSampler_DEFINED
-#define GrGLSLSampler_DEFINED
-
-#include "GrTypes.h"
-#include "GrTypesPriv.h"
-#include "SkString.h"
-
-class GrGLSLSampler {
-public:
-    virtual ~GrGLSLSampler() {}
-
-    explicit GrGLSLSampler(uint32_t visibility, GrPixelConfig config)
-        : fVisibility(visibility)
-        , fConfig(config) {
-        SkASSERT(kUnknown_GrPixelConfig != fConfig);
-    }
-
-    uint32_t visibility() const { return fVisibility; }
-    GrPixelConfig config() const { return fConfig; }
-    virtual GrSLType type() const = 0;
-
-    // Returns the string to be used for the sampler in glsl 2D texture functions (texture,
-    // texture2D, etc.)
-    const char* getSamplerNameForTexture2D() const {
-        SkASSERT(GrSLTypeIs2DCombinedSamplerType(this->type()));
-        return this->onGetSamplerNameForTexture2D();
-    }
-
-    // Returns the string to be used for the sampler in glsl texelFetch.
-    virtual const char* getSamplerNameForTexelFetch() const = 0;
-
-private:
-    virtual const char* onGetSamplerNameForTexture2D() const = 0;
-    uint32_t      fVisibility;
-    GrPixelConfig fConfig;
-};
-
-#endif
index 6d77bdb..2e79779 100644 (file)
@@ -10,7 +10,6 @@
 #include "glsl/GrGLSLCaps.h"
 #include "glsl/GrGLSLColorSpaceXformHelper.h"
 #include "glsl/GrGLSLShaderVar.h"
-#include "glsl/GrGLSLSampler.h"
 #include "glsl/GrGLSLProgramBuilder.h"
 
 GrGLSLShaderBuilder::GrGLSLShaderBuilder(GrGLSLProgramBuilder* program)
@@ -63,38 +62,37 @@ void GrGLSLShaderBuilder::emitFunction(GrSLType returnType,
     this->functions().append("}\n\n");
 }
 
+static inline void append_texture_swizzle(SkString* out, GrSwizzle swizzle) {
+    if (swizzle != GrSwizzle::RGBA()) {
+        out->appendf(".%s", swizzle.c_str());
+    }
+}
+
 void GrGLSLShaderBuilder::appendTextureLookup(SkString* out,
                                               SamplerHandle samplerHandle,
                                               const char* coordName,
                                               GrSLType varyingType) const {
     const GrGLSLCaps* glslCaps = fProgramBuilder->glslCaps();
-    const GrGLSLSampler& sampler = fProgramBuilder->getSampler(samplerHandle);
-    GrSLType samplerType = sampler.type();
+    const GrGLSLShaderVar& sampler = fProgramBuilder->samplerVariable(samplerHandle);
+    GrSLType samplerType = sampler.getType();
     if (samplerType == kTexture2DRectSampler_GrSLType) {
         if (varyingType == kVec2f_GrSLType) {
             out->appendf("%s(%s, textureSize(%s) * %s)",
                          GrGLSLTexture2DFunctionName(varyingType, samplerType,
                                                      glslCaps->generation()),
-                         sampler.getSamplerNameForTexture2D(),
-                         sampler.getSamplerNameForTexture2D(),
-                         coordName);
+                         sampler.c_str(), sampler.c_str(), coordName);
         } else {
             out->appendf("%s(%s, vec3(textureSize(%s) * %s.xy, %s.z))",
                          GrGLSLTexture2DFunctionName(varyingType, samplerType,
                                                      glslCaps->generation()),
-                         sampler.getSamplerNameForTexture2D(),
-                         sampler.getSamplerNameForTexture2D(),
-                         coordName,
-                         coordName);
+                         sampler.c_str(), sampler.c_str(), coordName, coordName);
         }
     } else {
         out->appendf("%s(%s, %s)",
                      GrGLSLTexture2DFunctionName(varyingType, samplerType, glslCaps->generation()),
-                     sampler.getSamplerNameForTexture2D(),
-                     coordName);
+                     sampler.c_str(), coordName);
     }
-
-    this->appendTextureSwizzle(out, sampler.config());
+    append_texture_swizzle(out, fProgramBuilder->samplerSwizzle(samplerHandle));
 }
 
 void GrGLSLShaderBuilder::appendTextureLookup(SamplerHandle samplerHandle,
@@ -164,27 +162,19 @@ void GrGLSLShaderBuilder::appendColorGamutXform(const char* srcColor,
 void GrGLSLShaderBuilder::appendTexelFetch(SkString* out,
                                            SamplerHandle samplerHandle,
                                            const char* coordExpr) const {
-    const GrGLSLSampler& sampler = fProgramBuilder->getSampler(samplerHandle);
+    const GrGLSLShaderVar& sampler = fProgramBuilder->samplerVariable(samplerHandle);
     SkASSERT(fProgramBuilder->glslCaps()->texelFetchSupport());
-    SkASSERT(GrSLTypeIsCombinedSamplerType(sampler.type()));
+    SkASSERT(GrSLTypeIsCombinedSamplerType(sampler.getType()));
 
-    out->appendf("texelFetch(%s, %s)", sampler.getSamplerNameForTexelFetch(), coordExpr);
+    out->appendf("texelFetch(%s, %s)", sampler.c_str(), coordExpr);
 
-    this->appendTextureSwizzle(out, sampler.config());
+    append_texture_swizzle(out, fProgramBuilder->samplerSwizzle(samplerHandle));
 }
 
 void GrGLSLShaderBuilder::appendTexelFetch(SamplerHandle samplerHandle, const char* coordExpr) {
     this->appendTexelFetch(&this->code(), samplerHandle, coordExpr);
 }
 
-void GrGLSLShaderBuilder::appendTextureSwizzle(SkString* out, GrPixelConfig config) const {
-    const GrSwizzle& configSwizzle = fProgramBuilder->glslCaps()->configTextureSwizzle(config);
-
-    if (configSwizzle != GrSwizzle::RGBA()) {
-        out->appendf(".%s", configSwizzle.c_str());
-    }
-}
-
 bool GrGLSLShaderBuilder::addFeature(uint32_t featureBit, const char* extensionName) {
     if (featureBit & fFeaturesAddedMask) {
         return false;
index 378f523..2ab0eec 100644 (file)
@@ -29,8 +29,8 @@ public:
 
     /** Appends a 2D texture sample with projection if necessary. coordType must either be Vec2f or
         Vec3f. The latter is interpreted as projective texture coords. The vec length and swizzle
-        order of the result depends on the GrProcessor::TextureSampelr associated with the
-        GrGLSLSampler.
+        order of the result depends on the GrProcessor::TextureSampler associated with the
+        SamplerHandle.
         */
     void appendTextureLookup(SkString* out,
                              SamplerHandle,
@@ -45,7 +45,7 @@ public:
 
 
     /** Does the work of appendTextureLookup and modulates the result by modulation. The result is
-        always a vec4. modulation and the swizzle specified by GrGLSLSampler must both be
+        always a vec4. modulation and the swizzle specified by SamplerHandle must both be
         vec4 or float. If modulation is "" or nullptr it this function acts as though
         appendTextureLookup were called. */
     void appendTextureLookupAndModulate(const char* modulation,
@@ -203,12 +203,6 @@ protected:
 
     void compileAndAppendLayoutQualifiers();
 
-    /* Appends any swizzling we may need to get from some backend internal format to the format used
-     * in GrPixelConfig. If this is implemented by the GrGpu object, then swizzle will be rgba. For
-     * shader prettiness we omit the swizzle rather than appending ".rgba".
-     */
-    void appendTextureSwizzle(SkString* out, GrPixelConfig) const;
-
     void nextStage() {
         fShaderStrings.push_back();
         fCompilerStrings.push_back(this->code().c_str());
index d7b2138..657be6a 100644 (file)
@@ -12,7 +12,6 @@
 #include "GrGLSLShaderVar.h"
 
 class GrGLSLProgramBuilder;
-class GrGLSLSampler;
 
 class GrGLSLUniformHandler {
 public:
@@ -61,22 +60,11 @@ protected:
     GrGLSLProgramBuilder* fProgramBuilder;
 
 private:
-    virtual int numSamplers() const = 0;
-    virtual const GrGLSLSampler& getSampler(SamplerHandle handle) const = 0;
+    virtual const GrGLSLShaderVar& samplerVariable(SamplerHandle) const = 0;
+    virtual GrSwizzle samplerSwizzle(SamplerHandle) const = 0;
 
-    SamplerHandle addSampler(uint32_t visibility,
-                             GrPixelConfig config,
-                             GrSLType type,
-                             GrSLPrecision precision,
-                             const char* name) {
-        return this->internalAddSampler(visibility, config, type, precision, name);
-    }
-
-    virtual SamplerHandle internalAddSampler(uint32_t visibility,
-                                             GrPixelConfig config,
-                                             GrSLType type,
-                                             GrSLPrecision precision,
-                                             const char* name) = 0;
+    virtual SamplerHandle addSampler(uint32_t visibility, GrSwizzle, GrSLType, GrSLPrecision,
+                                     const char* name) = 0;
 
     virtual UniformHandle internalAddUniformArray(uint32_t visibility,
                                                   GrSLType type,
index f4a8ebd..bf6ee64 100644 (file)
@@ -9,7 +9,6 @@
 #define GrGLSLXferProcessor_DEFINED
 
 #include "glsl/GrGLSLProgramDataManager.h"
-#include "glsl/GrGLSLSampler.h"
 
 class GrXferProcessor;
 class GrGLSLCaps;
index d05a11c..f523cee 100644 (file)
@@ -11,7 +11,6 @@
 #include "GrVkDescriptorSet.h"
 #include "GrVkGpu.h"
 #include "GrVkUniformHandler.h"
-#include "glsl/GrGLSLSampler.h"
 
 GrVkDescriptorSetManager::GrVkDescriptorSetManager(GrVkGpu* gpu,
                                                    VkDescriptorType type,
@@ -20,7 +19,7 @@ GrVkDescriptorSetManager::GrVkDescriptorSetManager(GrVkGpu* gpu,
     if (type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) {
         SkASSERT(uniformHandler);
         for (int i = 0; i < uniformHandler->numSamplers(); ++i) {
-            fBindingVisibilities.push_back(uniformHandler->getSampler(i).visibility());
+            fBindingVisibilities.push_back(uniformHandler->samplerVisibility(i));
         }
     } else {
         SkASSERT(type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
@@ -103,7 +102,7 @@ bool GrVkDescriptorSetManager::isCompatible(VkDescriptorType type,
             return false;
         }
         for (int i = 0; i < uniHandler->numSamplers(); ++i) {
-            if (uniHandler->getSampler(i).visibility() != fBindingVisibilities[i]) {
+            if (uniHandler->samplerVisibility(i) != fBindingVisibilities[i]) {
                 return false;
             }
         }
@@ -185,10 +184,7 @@ void GrVkDescriptorSetManager::DescriptorPoolManager::init(GrVkGpu* gpu,
         for (uint32_t i = 0; i < numSamplers; ++i) {
             uint32_t visibility;
             if (uniformHandler) {
-                const GrVkGLSLSampler& sampler =
-                    static_cast<const GrVkGLSLSampler&>(uniformHandler->getSampler(i));
-                SkASSERT(sampler.binding() == i);
-                visibility = sampler.visibility();
+                visibility = uniformHandler->samplerVisibility(i);
             } else {
                 visibility = (*visibilities)[i];
             }
diff --git a/src/gpu/vk/GrVkGLSLSampler.h b/src/gpu/vk/GrVkGLSLSampler.h
deleted file mode 100644 (file)
index f0ba7fa..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
-* Copyright 2016 Google Inc.
-*
-* Use of this source code is governed by a BSD-style license that can be
-* found in the LICENSE file.
-*/
-
-#ifndef GrVkGLSLSampler_DEFINED
-#define GrVkGLSLSampler_DEFINED
-
-#include "glsl/GrGLSLSampler.h"
-
-#include "glsl/GrGLSLShaderVar.h"
-
-class GrVkGLSLSampler : public GrGLSLSampler {
-public:
-    GrVkGLSLSampler(uint32_t visibility,
-                    GrPixelConfig config,
-                    GrSLType type,
-                    GrSLPrecision precision,
-                    const char* name,
-                    uint32_t binding,
-                    uint32_t set) : INHERITED(visibility, config), fBinding(binding) {
-        SkASSERT(GrSLTypeIsCombinedSamplerType(type));
-        fShaderVar.setType(type);
-        fShaderVar.setTypeModifier(GrGLSLShaderVar::kUniform_TypeModifier);
-        fShaderVar.setPrecision(precision);
-        fShaderVar.accessName()->set(name);
-        SkString layoutQualifier;
-        layoutQualifier.appendf("set=%d, binding=%d", set, binding);
-        fShaderVar.setLayoutQualifier(layoutQualifier.c_str());
-    }
-
-    GrSLType type() const override { return fShaderVar.getType(); }
-    uint32_t binding() const { return fBinding; }
-
-    const char* onGetSamplerNameForTexture2D() const override { return fShaderVar.c_str(); }
-    const char* getSamplerNameForTexelFetch() const override { return fShaderVar.c_str(); }
-
-private:
-    GrGLSLShaderVar fShaderVar;
-    uint32_t        fBinding;
-
-    friend class GrVkUniformHandler;
-
-    typedef GrGLSLSampler INHERITED;
-};
-
-#endif
index 81e1738..487633d 100644 (file)
@@ -10,7 +10,6 @@
 #include "GrSamplerParams.h"
 #include "GrVkCommandBuffer.h"
 #include "GrVkCopyPipeline.h"
-#include "GrVkGLSLSampler.h"
 #include "GrVkPipeline.h"
 #include "GrVkRenderTarget.h"
 #include "GrVkSampler.h"
index 212095a..1da4119 100644 (file)
@@ -168,11 +168,11 @@ GrGLSLUniformHandler::UniformHandle GrVkUniformHandler::internalAddUniformArray(
     return GrGLSLUniformHandler::UniformHandle(fUniforms.count() - 1);
 }
 
-GrGLSLUniformHandler::SamplerHandle GrVkUniformHandler::internalAddSampler(uint32_t visibility,
-                                                                           GrPixelConfig config,
-                                                                           GrSLType type,
-                                                                           GrSLPrecision precision,
-                                                                           const char* name) {
+GrGLSLUniformHandler::SamplerHandle GrVkUniformHandler::addSampler(uint32_t visibility,
+                                                                   GrSwizzle swizzle,
+                                                                   GrSLType type,
+                                                                   GrSLPrecision precision,
+                                                                   const char* name) {
     SkASSERT(name && strlen(name));
     SkDEBUGCODE(static const uint32_t kVisMask = kVertex_GrShaderFlag | kFragment_GrShaderFlag);
     SkASSERT(0 == (~kVisMask & visibility));
@@ -180,8 +180,20 @@ GrGLSLUniformHandler::SamplerHandle GrVkUniformHandler::internalAddSampler(uint3
     SkString mangleName;
     char prefix = 'u';
     fProgramBuilder->nameVariable(&mangleName, prefix, name, true);
-    fSamplers.emplace_back(visibility, config, type, precision, mangleName.c_str(),
-                           (uint32_t)fSamplers.count(), kSamplerDescSet);
+
+    UniformInfo& info = fSamplers.push_back();
+    SkASSERT(GrSLTypeIsCombinedSamplerType(type));
+    info.fVariable.setType(type);
+    info.fVariable.setTypeModifier(GrGLSLShaderVar::kUniform_TypeModifier);
+    info.fVariable.setPrecision(precision);
+    info.fVariable.setName(mangleName);
+    SkString layoutQualifier;
+    layoutQualifier.appendf("set=%d, binding=%d", kSamplerDescSet, fSamplers.count() - 1);
+    info.fVariable.setLayoutQualifier(layoutQualifier.c_str());
+    info.fVisibility = visibility;
+    info.fUBOffset = 0;
+    fSamplerSwizzles.push_back(swizzle);
+    SkASSERT(fSamplerSwizzles.count() == fSamplers.count());
     return GrGLSLUniformHandler::SamplerHandle(fSamplers.count() - 1);
 }
 
@@ -189,10 +201,10 @@ void GrVkUniformHandler::appendUniformDecls(GrShaderFlags visibility, SkString*
     SkASSERT(kVertex_GrShaderFlag == visibility || kFragment_GrShaderFlag == visibility);
 
     for (int i = 0; i < fSamplers.count(); ++i) {
-        const GrVkGLSLSampler& sampler = fSamplers[i];
-        SkASSERT(sampler.type() == kTexture2DSampler_GrSLType);
-        if (visibility == sampler.visibility()) {
-            sampler.fShaderVar.appendDecl(fProgramBuilder->glslCaps(), out);
+        const UniformInfo& sampler = fSamplers[i];
+        SkASSERT(sampler.fVariable.getType() == kTexture2DSampler_GrSLType);
+        if (visibility == sampler.fVisibility) {
+            sampler.fVariable.appendDecl(fProgramBuilder->glslCaps(), out);
             out->append(";\n");
         }
     }
index a6ea936..89dc410 100644 (file)
@@ -11,7 +11,6 @@
 #include "glsl/GrGLSLUniformHandler.h"
 
 #include "GrAllocator.h"
-#include "GrVkGLSLSampler.h"
 #include "glsl/GrGLSLShaderVar.h"
 
 class GrVkUniformHandler : public GrGLSLUniformHandler {
@@ -47,6 +46,7 @@ private:
     explicit GrVkUniformHandler(GrGLSLProgramBuilder* program)
         : INHERITED(program)
         , fUniforms(kUniformsPerBlock)
+        , fSamplers(kUniformsPerBlock)
         , fCurrentVertexUBOOffset(0)
         , fCurrentFragmentUBOOffset(0)
         , fCurrentSamplerBinding(0) {
@@ -60,15 +60,21 @@ private:
                                           int arrayCount,
                                           const char** outName) override;
 
-    SamplerHandle internalAddSampler(uint32_t visibility,
-                                     GrPixelConfig config,
-                                     GrSLType type,
-                                     GrSLPrecision precision,
-                                     const char* name) override;
+    SamplerHandle addSampler(uint32_t visibility,
+                             GrSwizzle swizzle,
+                             GrSLType type,
+                             GrSLPrecision precision,
+                             const char* name) override;
 
-    int numSamplers() const override { return fSamplers.count(); }
-    const GrGLSLSampler& getSampler(SamplerHandle handle) const override {
-        return fSamplers[handle.toIndex()];
+    int numSamplers() const { return fSamplers.count(); }
+    const GrGLSLShaderVar& samplerVariable(SamplerHandle handle) const override {
+        return fSamplers[handle.toIndex()].fVariable;
+    }
+    GrSwizzle samplerSwizzle(SamplerHandle handle) const override {
+        return fSamplerSwizzles[handle.toIndex()];
+    }
+    uint32_t samplerVisibility(SamplerHandle handle) const {
+        return fSamplers[handle.toIndex()].fVisibility;
     }
 
     void appendUniformDecls(GrShaderFlags, SkString*) const override;
@@ -82,12 +88,13 @@ private:
     }
 
 
-    UniformInfoArray fUniforms;
-    SkTArray<GrVkGLSLSampler> fSamplers;
+    UniformInfoArray    fUniforms;
+    UniformInfoArray    fSamplers;
+    SkTArray<GrSwizzle> fSamplerSwizzles;
 
-    uint32_t         fCurrentVertexUBOOffset;
-    uint32_t         fCurrentFragmentUBOOffset;
-    uint32_t         fCurrentSamplerBinding;
+    uint32_t            fCurrentVertexUBOOffset;
+    uint32_t            fCurrentFragmentUBOOffset;
+    uint32_t            fCurrentSamplerBinding;
 
     friend class GrVkPipelineStateBuilder;
     friend class GrVkDescriptorSetManager;