| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 SkASSERT(GrGLSLShaderVar::kNonArray == builderSeparableVarying.fVariable
.getArrayCount() || | 53 SkASSERT(GrGLSLShaderVar::kNonArray == builderSeparableVarying.fVariable
.getArrayCount() || |
| 54 builderSeparableVarying.fVariable.getArrayCount() > 0); | 54 builderSeparableVarying.fVariable.getArrayCount() > 0); |
| 55 SkDEBUGCODE( | 55 SkDEBUGCODE( |
| 56 separableVarying.fArrayCount = builderSeparableVarying.fVariable.get
ArrayCount(); | 56 separableVarying.fArrayCount = builderSeparableVarying.fVariable.get
ArrayCount(); |
| 57 separableVarying.fType = builderSeparableVarying.fVariable.getType()
; | 57 separableVarying.fType = builderSeparableVarying.fVariable.getType()
; |
| 58 ); | 58 ); |
| 59 separableVarying.fLocation = builderSeparableVarying.fLocation; | 59 separableVarying.fLocation = builderSeparableVarying.fLocation; |
| 60 } | 60 } |
| 61 } | 61 } |
| 62 | 62 |
| 63 void GrGLProgramDataManager::setSampler(UniformHandle u, GrGLint texUnit) const
{ | 63 void GrGLProgramDataManager::setSampler(UniformHandle u, int texUnit) const { |
| 64 const Uniform& uni = fUniforms[u.toIndex()]; | 64 const Uniform& uni = fUniforms[u.toIndex()]; |
| 65 SkASSERT(uni.fType == kSampler2D_GrSLType); | 65 SkASSERT(uni.fType == kSampler2D_GrSLType); |
| 66 SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount); | 66 SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount); |
| 67 // FIXME: We still insert a single sampler uniform for every stage. If the s
hader does not | 67 // FIXME: We still insert a single sampler uniform for every stage. If the s
hader does not |
| 68 // reference the sampler then the compiler may have optimized it out. Uncomm
ent this assert | 68 // reference the sampler then the compiler may have optimized it out. Uncomm
ent this assert |
| 69 // once stages insert their own samplers. | 69 // once stages insert their own samplers. |
| 70 // this->printUnused(uni); | 70 // this->printUnused(uni); |
| 71 if (kUnusedUniform != uni.fFSLocation) { | 71 if (kUnusedUniform != uni.fFSLocation) { |
| 72 GR_GL_CALL(fGpu->glInterface(), Uniform1i(uni.fFSLocation, texUnit)); | 72 GR_GL_CALL(fGpu->glInterface(), Uniform1i(uni.fFSLocation, texUnit)); |
| 73 } | 73 } |
| 74 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ | 74 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ |
| 75 GR_GL_CALL(fGpu->glInterface(), Uniform1i(uni.fVSLocation, texUnit)); | 75 GR_GL_CALL(fGpu->glInterface(), Uniform1i(uni.fVSLocation, texUnit)); |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 | 78 |
| 79 void GrGLProgramDataManager::set1f(UniformHandle u, GrGLfloat v0) const { | 79 void GrGLProgramDataManager::set1f(UniformHandle u, float v0) const { |
| 80 const Uniform& uni = fUniforms[u.toIndex()]; | 80 const Uniform& uni = fUniforms[u.toIndex()]; |
| 81 SkASSERT(uni.fType == kFloat_GrSLType); | 81 SkASSERT(uni.fType == kFloat_GrSLType); |
| 82 SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount); | 82 SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount); |
| 83 SkDEBUGCODE(this->printUnused(uni);) | 83 SkDEBUGCODE(this->printUnused(uni);) |
| 84 if (kUnusedUniform != uni.fFSLocation) { | 84 if (kUnusedUniform != uni.fFSLocation) { |
| 85 GR_GL_CALL(fGpu->glInterface(), Uniform1f(uni.fFSLocation, v0)); | 85 GR_GL_CALL(fGpu->glInterface(), Uniform1f(uni.fFSLocation, v0)); |
| 86 } | 86 } |
| 87 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ | 87 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ |
| 88 GR_GL_CALL(fGpu->glInterface(), Uniform1f(uni.fVSLocation, v0)); | 88 GR_GL_CALL(fGpu->glInterface(), Uniform1f(uni.fVSLocation, v0)); |
| 89 } | 89 } |
| 90 } | 90 } |
| 91 | 91 |
| 92 void GrGLProgramDataManager::set1fv(UniformHandle u, | 92 void GrGLProgramDataManager::set1fv(UniformHandle u, |
| 93 int arrayCount, | 93 int arrayCount, |
| 94 const GrGLfloat v[]) const { | 94 const float v[]) const { |
| 95 const Uniform& uni = fUniforms[u.toIndex()]; | 95 const Uniform& uni = fUniforms[u.toIndex()]; |
| 96 SkASSERT(uni.fType == kFloat_GrSLType); | 96 SkASSERT(uni.fType == kFloat_GrSLType); |
| 97 SkASSERT(arrayCount > 0); | 97 SkASSERT(arrayCount > 0); |
| 98 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount); | 98 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount); |
| 99 // This assert fires in some instances of the two-pt gradient for its VSPara
ms. | 99 // This assert fires in some instances of the two-pt gradient for its VSPara
ms. |
| 100 // Once the uniform manager is responsible for inserting the duplicate unifo
rm | 100 // Once the uniform manager is responsible for inserting the duplicate unifo
rm |
| 101 // arrays in VS and FS driver bug workaround, this can be enabled. | 101 // arrays in VS and FS driver bug workaround, this can be enabled. |
| 102 // this->printUni(uni); | 102 // this->printUni(uni); |
| 103 if (kUnusedUniform != uni.fFSLocation) { | 103 if (kUnusedUniform != uni.fFSLocation) { |
| 104 GR_GL_CALL(fGpu->glInterface(), Uniform1fv(uni.fFSLocation, arrayCount,
v)); | 104 GR_GL_CALL(fGpu->glInterface(), Uniform1fv(uni.fFSLocation, arrayCount,
v)); |
| 105 } | 105 } |
| 106 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ | 106 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ |
| 107 GR_GL_CALL(fGpu->glInterface(), Uniform1fv(uni.fVSLocation, arrayCount,
v)); | 107 GR_GL_CALL(fGpu->glInterface(), Uniform1fv(uni.fVSLocation, arrayCount,
v)); |
| 108 } | 108 } |
| 109 } | 109 } |
| 110 | 110 |
| 111 void GrGLProgramDataManager::set2f(UniformHandle u, GrGLfloat v0, GrGLfloat v1)
const { | 111 void GrGLProgramDataManager::set2f(UniformHandle u, float v0, float v1) const { |
| 112 const Uniform& uni = fUniforms[u.toIndex()]; | 112 const Uniform& uni = fUniforms[u.toIndex()]; |
| 113 SkASSERT(uni.fType == kVec2f_GrSLType); | 113 SkASSERT(uni.fType == kVec2f_GrSLType); |
| 114 SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount); | 114 SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount); |
| 115 SkDEBUGCODE(this->printUnused(uni);) | 115 SkDEBUGCODE(this->printUnused(uni);) |
| 116 if (kUnusedUniform != uni.fFSLocation) { | 116 if (kUnusedUniform != uni.fFSLocation) { |
| 117 GR_GL_CALL(fGpu->glInterface(), Uniform2f(uni.fFSLocation, v0, v1)); | 117 GR_GL_CALL(fGpu->glInterface(), Uniform2f(uni.fFSLocation, v0, v1)); |
| 118 } | 118 } |
| 119 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ | 119 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ |
| 120 GR_GL_CALL(fGpu->glInterface(), Uniform2f(uni.fVSLocation, v0, v1)); | 120 GR_GL_CALL(fGpu->glInterface(), Uniform2f(uni.fVSLocation, v0, v1)); |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 | 123 |
| 124 void GrGLProgramDataManager::set2fv(UniformHandle u, | 124 void GrGLProgramDataManager::set2fv(UniformHandle u, |
| 125 int arrayCount, | 125 int arrayCount, |
| 126 const GrGLfloat v[]) const { | 126 const float v[]) const { |
| 127 const Uniform& uni = fUniforms[u.toIndex()]; | 127 const Uniform& uni = fUniforms[u.toIndex()]; |
| 128 SkASSERT(uni.fType == kVec2f_GrSLType); | 128 SkASSERT(uni.fType == kVec2f_GrSLType); |
| 129 SkASSERT(arrayCount > 0); | 129 SkASSERT(arrayCount > 0); |
| 130 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount); | 130 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount); |
| 131 SkDEBUGCODE(this->printUnused(uni);) | 131 SkDEBUGCODE(this->printUnused(uni);) |
| 132 if (kUnusedUniform != uni.fFSLocation) { | 132 if (kUnusedUniform != uni.fFSLocation) { |
| 133 GR_GL_CALL(fGpu->glInterface(), Uniform2fv(uni.fFSLocation, arrayCount,
v)); | 133 GR_GL_CALL(fGpu->glInterface(), Uniform2fv(uni.fFSLocation, arrayCount,
v)); |
| 134 } | 134 } |
| 135 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ | 135 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ |
| 136 GR_GL_CALL(fGpu->glInterface(), Uniform2fv(uni.fVSLocation, arrayCount,
v)); | 136 GR_GL_CALL(fGpu->glInterface(), Uniform2fv(uni.fVSLocation, arrayCount,
v)); |
| 137 } | 137 } |
| 138 } | 138 } |
| 139 | 139 |
| 140 void GrGLProgramDataManager::set3f(UniformHandle u, GrGLfloat v0, GrGLfloat v1,
GrGLfloat v2) const { | 140 void GrGLProgramDataManager::set3f(UniformHandle u, float v0, float v1, float v2
) const { |
| 141 const Uniform& uni = fUniforms[u.toIndex()]; | 141 const Uniform& uni = fUniforms[u.toIndex()]; |
| 142 SkASSERT(uni.fType == kVec3f_GrSLType); | 142 SkASSERT(uni.fType == kVec3f_GrSLType); |
| 143 SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount); | 143 SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount); |
| 144 SkDEBUGCODE(this->printUnused(uni);) | 144 SkDEBUGCODE(this->printUnused(uni);) |
| 145 if (kUnusedUniform != uni.fFSLocation) { | 145 if (kUnusedUniform != uni.fFSLocation) { |
| 146 GR_GL_CALL(fGpu->glInterface(), Uniform3f(uni.fFSLocation, v0, v1, v2)); | 146 GR_GL_CALL(fGpu->glInterface(), Uniform3f(uni.fFSLocation, v0, v1, v2)); |
| 147 } | 147 } |
| 148 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ | 148 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ |
| 149 GR_GL_CALL(fGpu->glInterface(), Uniform3f(uni.fVSLocation, v0, v1, v2)); | 149 GR_GL_CALL(fGpu->glInterface(), Uniform3f(uni.fVSLocation, v0, v1, v2)); |
| 150 } | 150 } |
| 151 } | 151 } |
| 152 | 152 |
| 153 void GrGLProgramDataManager::set3fv(UniformHandle u, | 153 void GrGLProgramDataManager::set3fv(UniformHandle u, |
| 154 int arrayCount, | 154 int arrayCount, |
| 155 const GrGLfloat v[]) const { | 155 const float v[]) const { |
| 156 const Uniform& uni = fUniforms[u.toIndex()]; | 156 const Uniform& uni = fUniforms[u.toIndex()]; |
| 157 SkASSERT(uni.fType == kVec3f_GrSLType); | 157 SkASSERT(uni.fType == kVec3f_GrSLType); |
| 158 SkASSERT(arrayCount > 0); | 158 SkASSERT(arrayCount > 0); |
| 159 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount); | 159 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount); |
| 160 SkDEBUGCODE(this->printUnused(uni);) | 160 SkDEBUGCODE(this->printUnused(uni);) |
| 161 if (kUnusedUniform != uni.fFSLocation) { | 161 if (kUnusedUniform != uni.fFSLocation) { |
| 162 GR_GL_CALL(fGpu->glInterface(), Uniform3fv(uni.fFSLocation, arrayCount,
v)); | 162 GR_GL_CALL(fGpu->glInterface(), Uniform3fv(uni.fFSLocation, arrayCount,
v)); |
| 163 } | 163 } |
| 164 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ | 164 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ |
| 165 GR_GL_CALL(fGpu->glInterface(), Uniform3fv(uni.fVSLocation, arrayCount,
v)); | 165 GR_GL_CALL(fGpu->glInterface(), Uniform3fv(uni.fVSLocation, arrayCount,
v)); |
| 166 } | 166 } |
| 167 } | 167 } |
| 168 | 168 |
| 169 void GrGLProgramDataManager::set4f(UniformHandle u, | 169 void GrGLProgramDataManager::set4f(UniformHandle u, |
| 170 GrGLfloat v0, | 170 float v0, |
| 171 GrGLfloat v1, | 171 float v1, |
| 172 GrGLfloat v2, | 172 float v2, |
| 173 GrGLfloat v3) const { | 173 float v3) const { |
| 174 const Uniform& uni = fUniforms[u.toIndex()]; | 174 const Uniform& uni = fUniforms[u.toIndex()]; |
| 175 SkASSERT(uni.fType == kVec4f_GrSLType); | 175 SkASSERT(uni.fType == kVec4f_GrSLType); |
| 176 SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount); | 176 SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount); |
| 177 SkDEBUGCODE(this->printUnused(uni);) | 177 SkDEBUGCODE(this->printUnused(uni);) |
| 178 if (kUnusedUniform != uni.fFSLocation) { | 178 if (kUnusedUniform != uni.fFSLocation) { |
| 179 GR_GL_CALL(fGpu->glInterface(), Uniform4f(uni.fFSLocation, v0, v1, v2, v
3)); | 179 GR_GL_CALL(fGpu->glInterface(), Uniform4f(uni.fFSLocation, v0, v1, v2, v
3)); |
| 180 } | 180 } |
| 181 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ | 181 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ |
| 182 GR_GL_CALL(fGpu->glInterface(), Uniform4f(uni.fVSLocation, v0, v1, v2, v
3)); | 182 GR_GL_CALL(fGpu->glInterface(), Uniform4f(uni.fVSLocation, v0, v1, v2, v
3)); |
| 183 } | 183 } |
| 184 } | 184 } |
| 185 | 185 |
| 186 void GrGLProgramDataManager::set4fv(UniformHandle u, | 186 void GrGLProgramDataManager::set4fv(UniformHandle u, |
| 187 int arrayCount, | 187 int arrayCount, |
| 188 const GrGLfloat v[]) const { | 188 const float v[]) const { |
| 189 const Uniform& uni = fUniforms[u.toIndex()]; | 189 const Uniform& uni = fUniforms[u.toIndex()]; |
| 190 SkASSERT(uni.fType == kVec4f_GrSLType); | 190 SkASSERT(uni.fType == kVec4f_GrSLType); |
| 191 SkASSERT(arrayCount > 0); | 191 SkASSERT(arrayCount > 0); |
| 192 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount); | 192 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount); |
| 193 SkDEBUGCODE(this->printUnused(uni);) | 193 SkDEBUGCODE(this->printUnused(uni);) |
| 194 if (kUnusedUniform != uni.fFSLocation) { | 194 if (kUnusedUniform != uni.fFSLocation) { |
| 195 GR_GL_CALL(fGpu->glInterface(), Uniform4fv(uni.fFSLocation, arrayCount,
v)); | 195 GR_GL_CALL(fGpu->glInterface(), Uniform4fv(uni.fFSLocation, arrayCount,
v)); |
| 196 } | 196 } |
| 197 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ | 197 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ |
| 198 GR_GL_CALL(fGpu->glInterface(), Uniform4fv(uni.fVSLocation, arrayCount,
v)); | 198 GR_GL_CALL(fGpu->glInterface(), Uniform4fv(uni.fVSLocation, arrayCount,
v)); |
| 199 } | 199 } |
| 200 } | 200 } |
| 201 | 201 |
| 202 void GrGLProgramDataManager::setMatrix3f(UniformHandle u, const GrGLfloat matrix
[]) const { | 202 void GrGLProgramDataManager::setMatrix3f(UniformHandle u, const float matrix[])
const { |
| 203 const Uniform& uni = fUniforms[u.toIndex()]; | 203 const Uniform& uni = fUniforms[u.toIndex()]; |
| 204 SkASSERT(uni.fType == kMat33f_GrSLType); | 204 SkASSERT(uni.fType == kMat33f_GrSLType); |
| 205 SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount); | 205 SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount); |
| 206 SkDEBUGCODE(this->printUnused(uni);) | 206 SkDEBUGCODE(this->printUnused(uni);) |
| 207 if (kUnusedUniform != uni.fFSLocation) { | 207 if (kUnusedUniform != uni.fFSLocation) { |
| 208 GR_GL_CALL(fGpu->glInterface(), UniformMatrix3fv(uni.fFSLocation, 1, fal
se, matrix)); | 208 GR_GL_CALL(fGpu->glInterface(), UniformMatrix3fv(uni.fFSLocation, 1, fal
se, matrix)); |
| 209 } | 209 } |
| 210 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ | 210 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ |
| 211 GR_GL_CALL(fGpu->glInterface(), UniformMatrix3fv(uni.fVSLocation, 1, fal
se, matrix)); | 211 GR_GL_CALL(fGpu->glInterface(), UniformMatrix3fv(uni.fVSLocation, 1, fal
se, matrix)); |
| 212 } | 212 } |
| 213 } | 213 } |
| 214 | 214 |
| 215 void GrGLProgramDataManager::setMatrix4f(UniformHandle u, const GrGLfloat matrix
[]) const { | 215 void GrGLProgramDataManager::setMatrix4f(UniformHandle u, const float matrix[])
const { |
| 216 const Uniform& uni = fUniforms[u.toIndex()]; | 216 const Uniform& uni = fUniforms[u.toIndex()]; |
| 217 SkASSERT(uni.fType == kMat44f_GrSLType); | 217 SkASSERT(uni.fType == kMat44f_GrSLType); |
| 218 SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount); | 218 SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount); |
| 219 SkDEBUGCODE(this->printUnused(uni);) | 219 SkDEBUGCODE(this->printUnused(uni);) |
| 220 if (kUnusedUniform != uni.fFSLocation) { | 220 if (kUnusedUniform != uni.fFSLocation) { |
| 221 GR_GL_CALL(fGpu->glInterface(), UniformMatrix4fv(uni.fFSLocation, 1, fal
se, matrix)); | 221 GR_GL_CALL(fGpu->glInterface(), UniformMatrix4fv(uni.fFSLocation, 1, fal
se, matrix)); |
| 222 } | 222 } |
| 223 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ | 223 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ |
| 224 GR_GL_CALL(fGpu->glInterface(), UniformMatrix4fv(uni.fVSLocation, 1, fal
se, matrix)); | 224 GR_GL_CALL(fGpu->glInterface(), UniformMatrix4fv(uni.fVSLocation, 1, fal
se, matrix)); |
| 225 } | 225 } |
| 226 } | 226 } |
| 227 | 227 |
| 228 void GrGLProgramDataManager::setMatrix3fv(UniformHandle u, | 228 void GrGLProgramDataManager::setMatrix3fv(UniformHandle u, |
| 229 int arrayCount, | 229 int arrayCount, |
| 230 const GrGLfloat matrices[]) const { | 230 const float matrices[]) const { |
| 231 const Uniform& uni = fUniforms[u.toIndex()]; | 231 const Uniform& uni = fUniforms[u.toIndex()]; |
| 232 SkASSERT(uni.fType == kMat33f_GrSLType); | 232 SkASSERT(uni.fType == kMat33f_GrSLType); |
| 233 SkASSERT(arrayCount > 0); | 233 SkASSERT(arrayCount > 0); |
| 234 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount); | 234 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount); |
| 235 SkDEBUGCODE(this->printUnused(uni);) | 235 SkDEBUGCODE(this->printUnused(uni);) |
| 236 if (kUnusedUniform != uni.fFSLocation) { | 236 if (kUnusedUniform != uni.fFSLocation) { |
| 237 GR_GL_CALL(fGpu->glInterface(), | 237 GR_GL_CALL(fGpu->glInterface(), |
| 238 UniformMatrix3fv(uni.fFSLocation, arrayCount, false, matrices
)); | 238 UniformMatrix3fv(uni.fFSLocation, arrayCount, false, matrices
)); |
| 239 } | 239 } |
| 240 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ | 240 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ |
| 241 GR_GL_CALL(fGpu->glInterface(), | 241 GR_GL_CALL(fGpu->glInterface(), |
| 242 UniformMatrix3fv(uni.fVSLocation, arrayCount, false, matrices
)); | 242 UniformMatrix3fv(uni.fVSLocation, arrayCount, false, matrices
)); |
| 243 } | 243 } |
| 244 } | 244 } |
| 245 | 245 |
| 246 void GrGLProgramDataManager::setMatrix4fv(UniformHandle u, | 246 void GrGLProgramDataManager::setMatrix4fv(UniformHandle u, |
| 247 int arrayCount, | 247 int arrayCount, |
| 248 const GrGLfloat matrices[]) const { | 248 const float matrices[]) const { |
| 249 const Uniform& uni = fUniforms[u.toIndex()]; | 249 const Uniform& uni = fUniforms[u.toIndex()]; |
| 250 SkASSERT(uni.fType == kMat44f_GrSLType); | 250 SkASSERT(uni.fType == kMat44f_GrSLType); |
| 251 SkASSERT(arrayCount > 0); | 251 SkASSERT(arrayCount > 0); |
| 252 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount); | 252 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount); |
| 253 SkDEBUGCODE(this->printUnused(uni);) | 253 SkDEBUGCODE(this->printUnused(uni);) |
| 254 if (kUnusedUniform != uni.fFSLocation) { | 254 if (kUnusedUniform != uni.fFSLocation) { |
| 255 GR_GL_CALL(fGpu->glInterface(), | 255 GR_GL_CALL(fGpu->glInterface(), |
| 256 UniformMatrix4fv(uni.fFSLocation, arrayCount, false, matrices
)); | 256 UniformMatrix4fv(uni.fFSLocation, arrayCount, false, matrices
)); |
| 257 } | 257 } |
| 258 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ | 258 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ |
| 259 GR_GL_CALL(fGpu->glInterface(), | 259 GR_GL_CALL(fGpu->glInterface(), |
| 260 UniformMatrix4fv(uni.fVSLocation, arrayCount, false, matrices
)); | 260 UniformMatrix4fv(uni.fVSLocation, arrayCount, false, matrices
)); |
| 261 } | 261 } |
| 262 } | 262 } |
| 263 | 263 |
| 264 void GrGLProgramDataManager::setSkMatrix(UniformHandle u, const SkMatrix& matrix
) const { | 264 void GrGLProgramDataManager::setSkMatrix(UniformHandle u, const SkMatrix& matrix
) const { |
| 265 GrGLfloat mt[] = { | 265 float mt[] = { |
| 266 matrix.get(SkMatrix::kMScaleX), | 266 matrix.get(SkMatrix::kMScaleX), |
| 267 matrix.get(SkMatrix::kMSkewY), | 267 matrix.get(SkMatrix::kMSkewY), |
| 268 matrix.get(SkMatrix::kMPersp0), | 268 matrix.get(SkMatrix::kMPersp0), |
| 269 matrix.get(SkMatrix::kMSkewX), | 269 matrix.get(SkMatrix::kMSkewX), |
| 270 matrix.get(SkMatrix::kMScaleY), | 270 matrix.get(SkMatrix::kMScaleY), |
| 271 matrix.get(SkMatrix::kMPersp1), | 271 matrix.get(SkMatrix::kMPersp1), |
| 272 matrix.get(SkMatrix::kMTransX), | 272 matrix.get(SkMatrix::kMTransX), |
| 273 matrix.get(SkMatrix::kMTransY), | 273 matrix.get(SkMatrix::kMTransY), |
| 274 matrix.get(SkMatrix::kMPersp2), | 274 matrix.get(SkMatrix::kMPersp2), |
| 275 }; | 275 }; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 292 matrix); | 292 matrix); |
| 293 } | 293 } |
| 294 | 294 |
| 295 #ifdef SK_DEBUG | 295 #ifdef SK_DEBUG |
| 296 void GrGLProgramDataManager::printUnused(const Uniform& uni) const { | 296 void GrGLProgramDataManager::printUnused(const Uniform& uni) const { |
| 297 if (kUnusedUniform == uni.fFSLocation && kUnusedUniform == uni.fVSLocation)
{ | 297 if (kUnusedUniform == uni.fFSLocation && kUnusedUniform == uni.fVSLocation)
{ |
| 298 GrCapsDebugf(fGpu->caps(), "Unused uniform in shader\n"); | 298 GrCapsDebugf(fGpu->caps(), "Unused uniform in shader\n"); |
| 299 } | 299 } |
| 300 } | 300 } |
| 301 #endif | 301 #endif |
| OLD | NEW |