| 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" |
| 11 #include "glsl/GrGLSLUniformHandler.h" |
| 11 | 12 |
| 12 #define ASSERT_ARRAY_UPLOAD_IN_BOUNDS(UNI, COUNT) \ | 13 #define ASSERT_ARRAY_UPLOAD_IN_BOUNDS(UNI, COUNT) \ |
| 13 SkASSERT(arrayCount <= uni.fArrayCount || \ | 14 SkASSERT(arrayCount <= uni.fArrayCount || \ |
| 14 (1 == arrayCount && GrGLSLShaderVar::kNonArray == uni.fArrayCo
unt)) | 15 (1 == arrayCount && GrGLSLShaderVar::kNonArray == uni.fArrayCo
unt)) |
| 15 | 16 |
| 16 GrGLProgramDataManager::GrGLProgramDataManager(GrGLGpu* gpu, GrGLuint programID, | 17 GrGLProgramDataManager::GrGLProgramDataManager(GrGLGpu* gpu, GrGLuint programID, |
| 17 const UniformInfoArray& uniforms, | 18 const UniformInfoArray& uniforms, |
| 18 const VaryingInfoArray& pathProcV
aryings) | 19 const VaryingInfoArray& pathProcV
aryings) |
| 19 : fGpu(gpu) | 20 : fGpu(gpu) |
| 20 , fProgramID(programID) { | 21 , fProgramID(programID) { |
| 21 int count = uniforms.count(); | 22 int count = uniforms.count(); |
| 22 fUniforms.push_back_n(count); | 23 fUniforms.push_back_n(count); |
| 23 for (int i = 0; i < count; i++) { | 24 for (int i = 0; i < count; i++) { |
| 24 Uniform& uniform = fUniforms[i]; | 25 Uniform& uniform = fUniforms[i]; |
| 25 const UniformInfo& builderUniform = uniforms[i]; | 26 const UniformInfo& builderUniform = uniforms[i]; |
| 26 SkASSERT(GrGLSLShaderVar::kNonArray == builderUniform.fVariable.getArray
Count() || | 27 SkASSERT(GrGLSLShaderVar::kNonArray == builderUniform.fVariable.getArray
Count() || |
| 27 builderUniform.fVariable.getArrayCount() > 0); | 28 builderUniform.fVariable.getArrayCount() > 0); |
| 28 SkDEBUGCODE( | 29 SkDEBUGCODE( |
| 29 uniform.fArrayCount = builderUniform.fVariable.getArrayCount(); | 30 uniform.fArrayCount = builderUniform.fVariable.getArrayCount(); |
| 30 uniform.fType = builderUniform.fVariable.getType(); | 31 uniform.fType = builderUniform.fVariable.getType(); |
| 31 ); | 32 ); |
| 32 // TODO: Move the Xoom uniform array in both FS and VS bug workaround he
re. | 33 // TODO: Move the Xoom uniform array in both FS and VS bug workaround he
re. |
| 33 | 34 |
| 34 if (GrGLProgramBuilder::kVertex_Visibility & builderUniform.fVisibility)
{ | 35 if (GrGLSLUniformHandler::kVertex_Visibility & builderUniform.fVisibilit
y) { |
| 35 uniform.fVSLocation = builderUniform.fLocation; | 36 uniform.fVSLocation = builderUniform.fLocation; |
| 36 } else { | 37 } else { |
| 37 uniform.fVSLocation = kUnusedUniform; | 38 uniform.fVSLocation = kUnusedUniform; |
| 38 } | 39 } |
| 39 if (GrGLProgramBuilder::kFragment_Visibility & builderUniform.fVisibilit
y) { | 40 if (GrGLSLUniformHandler::kFragment_Visibility & builderUniform.fVisibil
ity) { |
| 40 uniform.fFSLocation = builderUniform.fLocation; | 41 uniform.fFSLocation = builderUniform.fLocation; |
| 41 } else { | 42 } else { |
| 42 uniform.fFSLocation = kUnusedUniform; | 43 uniform.fFSLocation = kUnusedUniform; |
| 43 } | 44 } |
| 44 } | 45 } |
| 45 | 46 |
| 46 // NVPR programs have separable varyings | 47 // NVPR programs have separable varyings |
| 47 count = pathProcVaryings.count(); | 48 count = pathProcVaryings.count(); |
| 48 fPathProcVaryings.push_back_n(count); | 49 fPathProcVaryings.push_back_n(count); |
| 49 for (int i = 0; i < count; i++) { | 50 for (int i = 0; i < count; i++) { |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 matrix); | 293 matrix); |
| 293 } | 294 } |
| 294 | 295 |
| 295 #ifdef SK_DEBUG | 296 #ifdef SK_DEBUG |
| 296 void GrGLProgramDataManager::printUnused(const Uniform& uni) const { | 297 void GrGLProgramDataManager::printUnused(const Uniform& uni) const { |
| 297 if (kUnusedUniform == uni.fFSLocation && kUnusedUniform == uni.fVSLocation)
{ | 298 if (kUnusedUniform == uni.fFSLocation && kUnusedUniform == uni.fVSLocation)
{ |
| 298 GrCapsDebugf(fGpu->caps(), "Unused uniform in shader\n"); | 299 GrCapsDebugf(fGpu->caps(), "Unused uniform in shader\n"); |
| 299 } | 300 } |
| 300 } | 301 } |
| 301 #endif | 302 #endif |
| OLD | NEW |