| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkMatrix.h" | 8 #include "SkMatrix.h" |
| 9 #include "gl/GrGLProgramDataManager.h" | 9 #include "gl/GrGLProgramDataManager.h" |
| 10 #include "gl/GrGLGpu.h" | 10 #include "gl/GrGLGpu.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 SkASSERT(GrGLSLShaderVar::kNonArray == builderPathProcVarying.fVariable.
getArrayCount() || | 54 SkASSERT(GrGLSLShaderVar::kNonArray == builderPathProcVarying.fVariable.
getArrayCount() || |
| 55 builderPathProcVarying.fVariable.getArrayCount() > 0); | 55 builderPathProcVarying.fVariable.getArrayCount() > 0); |
| 56 SkDEBUGCODE( | 56 SkDEBUGCODE( |
| 57 pathProcVarying.fArrayCount = builderPathProcVarying.fVariable.getAr
rayCount(); | 57 pathProcVarying.fArrayCount = builderPathProcVarying.fVariable.getAr
rayCount(); |
| 58 pathProcVarying.fType = builderPathProcVarying.fVariable.getType(); | 58 pathProcVarying.fType = builderPathProcVarying.fVariable.getType(); |
| 59 ); | 59 ); |
| 60 pathProcVarying.fLocation = builderPathProcVarying.fLocation; | 60 pathProcVarying.fLocation = builderPathProcVarying.fLocation; |
| 61 } | 61 } |
| 62 } | 62 } |
| 63 | 63 |
| 64 void GrGLProgramDataManager::setSampler(UniformHandle u, int texUnit) const { | 64 void GrGLProgramDataManager::setSamplers(const SkTArray<GrGLSampler>& samplers)
const { |
| 65 const Uniform& uni = fUniforms[u.toIndex()]; | 65 for (int i = 0; i < samplers.count(); ++i) { |
| 66 SkASSERT(GrSLTypeIsSamplerType(uni.fType)); | 66 GrGLint vsLocation; |
| 67 SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount); | 67 GrGLint fsLocation; |
| 68 // FIXME: We still insert a single sampler uniform for every stage. If the s
hader does not | 68 const GrGLSampler& sampler = samplers[i]; |
| 69 // reference the sampler then the compiler may have optimized it out. Uncomm
ent this assert | 69 if (kVertex_GrShaderFlag & sampler.visibility()) { |
| 70 // once stages insert their own samplers. | 70 vsLocation = sampler.location(); |
| 71 // this->printUnused(uni); | 71 } else { |
| 72 if (kUnusedUniform != uni.fFSLocation) { | 72 vsLocation = kUnusedUniform; |
| 73 GR_GL_CALL(fGpu->glInterface(), Uniform1i(uni.fFSLocation, texUnit)); | 73 } |
| 74 } | 74 if (kFragment_GrShaderFlag & sampler.visibility()) { |
| 75 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ | 75 fsLocation = sampler.location(); |
| 76 GR_GL_CALL(fGpu->glInterface(), Uniform1i(uni.fVSLocation, texUnit)); | 76 } else { |
| 77 fsLocation = kUnusedUniform; |
| 78 } |
| 79 // FIXME: We still insert a single sampler uniform for every stage. If t
he shader does not |
| 80 // reference the sampler then the compiler may have optimized it out. Un
comment this assert |
| 81 // once stages insert their own samplers. |
| 82 // this->printUnused(uni); |
| 83 if (kUnusedUniform != fsLocation) { |
| 84 GR_GL_CALL(fGpu->glInterface(), Uniform1i(fsLocation, i)); |
| 85 } |
| 86 if (kUnusedUniform != vsLocation && vsLocation != fsLocation) { |
| 87 GR_GL_CALL(fGpu->glInterface(), Uniform1i(vsLocation, i)); |
| 88 } |
| 77 } | 89 } |
| 78 } | 90 } |
| 79 | 91 |
| 80 void GrGLProgramDataManager::set1f(UniformHandle u, float v0) const { | 92 void GrGLProgramDataManager::set1f(UniformHandle u, float v0) const { |
| 81 const Uniform& uni = fUniforms[u.toIndex()]; | 93 const Uniform& uni = fUniforms[u.toIndex()]; |
| 82 SkASSERT(uni.fType == kFloat_GrSLType); | 94 SkASSERT(uni.fType == kFloat_GrSLType); |
| 83 SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount); | 95 SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount); |
| 84 SkDEBUGCODE(this->printUnused(uni);) | 96 SkDEBUGCODE(this->printUnused(uni);) |
| 85 if (kUnusedUniform != uni.fFSLocation) { | 97 if (kUnusedUniform != uni.fFSLocation) { |
| 86 GR_GL_CALL(fGpu->glInterface(), Uniform1f(uni.fFSLocation, v0)); | 98 GR_GL_CALL(fGpu->glInterface(), Uniform1f(uni.fFSLocation, v0)); |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 matrix); | 288 matrix); |
| 277 } | 289 } |
| 278 | 290 |
| 279 #ifdef SK_DEBUG | 291 #ifdef SK_DEBUG |
| 280 void GrGLProgramDataManager::printUnused(const Uniform& uni) const { | 292 void GrGLProgramDataManager::printUnused(const Uniform& uni) const { |
| 281 if (kUnusedUniform == uni.fFSLocation && kUnusedUniform == uni.fVSLocation)
{ | 293 if (kUnusedUniform == uni.fFSLocation && kUnusedUniform == uni.fVSLocation)
{ |
| 282 GrCapsDebugf(fGpu->caps(), "Unused uniform in shader\n"); | 294 GrCapsDebugf(fGpu->caps(), "Unused uniform in shader\n"); |
| 283 } | 295 } |
| 284 } | 296 } |
| 285 #endif | 297 #endif |
| OLD | NEW |