Index: src/gpu/gl/GrGLProgramDataManager.cpp |
diff --git a/src/gpu/gl/GrGLProgramDataManager.cpp b/src/gpu/gl/GrGLProgramDataManager.cpp |
index 6b2e1118cb2ea05f98912142172219322471d62c..9513a3fd57b086c60b95b8f1b4df61bcac9a7e5a 100644 |
--- a/src/gpu/gl/GrGLProgramDataManager.cpp |
+++ b/src/gpu/gl/GrGLProgramDataManager.cpp |
@@ -61,19 +61,31 @@ GrGLProgramDataManager::GrGLProgramDataManager(GrGLGpu* gpu, GrGLuint programID, |
} |
} |
-void GrGLProgramDataManager::setSampler(UniformHandle u, int texUnit) const { |
- const Uniform& uni = fUniforms[u.toIndex()]; |
- SkASSERT(GrSLTypeIsSamplerType(uni.fType)); |
- SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount); |
- // 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 != uni.fFSLocation) { |
- GR_GL_CALL(fGpu->glInterface(), Uniform1i(uni.fFSLocation, texUnit)); |
- } |
- if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) { |
- GR_GL_CALL(fGpu->glInterface(), Uniform1i(uni.fVSLocation, texUnit)); |
+void GrGLProgramDataManager::setSamplers(const SkTArray<GrGLSampler>& 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(); |
+ } 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)); |
+ } |
} |
} |