blob: 4d5d711de48715bf8d8b184711f81d1cdfb9d0c1 [file] [log] [blame]
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +00001/*
2 * Copyright 2012 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
bsalomon@google.comd8b5fac2012-11-01 17:02:46 +00008#include "SkMatrix.h"
joshualitte7afc2d2015-09-11 10:44:13 -07009#include "gl/GrGLProgramDataManager.h"
10#include "gl/GrGLGpu.h"
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +000011
commit-bot@chromium.orgd3baf202013-11-07 22:06:08 +000012#define ASSERT_ARRAY_UPLOAD_IN_BOUNDS(UNI, COUNT) \
13 SkASSERT(arrayCount <= uni.fArrayCount || \
14 (1 == arrayCount && GrGLShaderVar::kNonArray == uni.fArrayCount))
15
joshualittd8dd47b2015-09-11 11:45:01 -070016GrGLProgramDataManager::GrGLProgramDataManager(GrGLGpu* gpu, GrGLuint programID,
17 const UniformInfoArray& uniforms,
18 const SeparableVaryingInfoArray& separableVaryings)
19 : fGpu(gpu)
20 , fProgramID(programID) {
joshualitt47bb3822014-10-07 16:43:25 -070021 int count = uniforms.count();
kkinnunendddc18a2014-08-03 23:19:46 -070022 fUniforms.push_back_n(count);
23 for (int i = 0; i < count; i++) {
24 Uniform& uniform = fUniforms[i];
joshualitt47bb3822014-10-07 16:43:25 -070025 const UniformInfo& builderUniform = uniforms[i];
kkinnunendddc18a2014-08-03 23:19:46 -070026 SkASSERT(GrGLShaderVar::kNonArray == builderUniform.fVariable.getArrayCount() ||
27 builderUniform.fVariable.getArrayCount() > 0);
28 SkDEBUGCODE(
29 uniform.fArrayCount = builderUniform.fVariable.getArrayCount();
30 uniform.fType = builderUniform.fVariable.getType();
31 );
32 // TODO: Move the Xoom uniform array in both FS and VS bug workaround here.
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +000033
joshualitt30ba4362014-08-21 20:18:45 -070034 if (GrGLProgramBuilder::kVertex_Visibility & builderUniform.fVisibility) {
kkinnunendddc18a2014-08-03 23:19:46 -070035 uniform.fVSLocation = builderUniform.fLocation;
36 } else {
37 uniform.fVSLocation = kUnusedUniform;
joshualitt47bb3822014-10-07 16:43:25 -070038 }
joshualitt30ba4362014-08-21 20:18:45 -070039 if (GrGLProgramBuilder::kFragment_Visibility & builderUniform.fVisibility) {
kkinnunendddc18a2014-08-03 23:19:46 -070040 uniform.fFSLocation = builderUniform.fLocation;
41 } else {
42 uniform.fFSLocation = kUnusedUniform;
43 }
44 }
joshualittd8dd47b2015-09-11 11:45:01 -070045
46 // NVPR programs have separable varyings
47 count = separableVaryings.count();
48 fSeparableVaryings.push_back_n(count);
49 for (int i = 0; i < count; i++) {
50 SkASSERT(fGpu->glCaps().shaderCaps()->pathRenderingSupport());
51 SeparableVarying& separableVarying = fSeparableVaryings[i];
52 const SeparableVaryingInfo& builderSeparableVarying = separableVaryings[i];
53 SkASSERT(GrGLShaderVar::kNonArray == builderSeparableVarying.fVariable.getArrayCount() ||
54 builderSeparableVarying.fVariable.getArrayCount() > 0);
55 SkDEBUGCODE(
56 separableVarying.fArrayCount = builderSeparableVarying.fVariable.getArrayCount();
57 separableVarying.fType = builderSeparableVarying.fVariable.getType();
58 );
59 separableVarying.fLocation = builderSeparableVarying.fLocation;
60 }
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +000061}
62
kkinnunen7510b222014-07-30 00:04:16 -070063void GrGLProgramDataManager::setSampler(UniformHandle u, GrGLint texUnit) const {
joshualitte7afc2d2015-09-11 10:44:13 -070064 const Uniform& uni = fUniforms[u.toIndex()];
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +000065 SkASSERT(uni.fType == kSampler2D_GrSLType);
66 SkASSERT(GrGLShaderVar::kNonArray == uni.fArrayCount);
bsalomon@google.com0982d352012-07-31 15:33:25 +000067 // FIXME: We still insert a single sampler uniform for every stage. If the shader does not
68 // reference the sampler then the compiler may have optimized it out. Uncomment this assert
69 // once stages insert their own samplers.
joshualittaf2d56d2015-05-11 06:21:34 -070070 // this->printUnused(uni);
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +000071 if (kUnusedUniform != uni.fFSLocation) {
commit-bot@chromium.org9188a152013-09-05 18:28:24 +000072 GR_GL_CALL(fGpu->glInterface(), Uniform1i(uni.fFSLocation, texUnit));
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +000073 }
74 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
commit-bot@chromium.org9188a152013-09-05 18:28:24 +000075 GR_GL_CALL(fGpu->glInterface(), Uniform1i(uni.fVSLocation, texUnit));
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +000076 }
77}
78
kkinnunen7510b222014-07-30 00:04:16 -070079void GrGLProgramDataManager::set1f(UniformHandle u, GrGLfloat v0) const {
joshualitte7afc2d2015-09-11 10:44:13 -070080 const Uniform& uni = fUniforms[u.toIndex()];
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +000081 SkASSERT(uni.fType == kFloat_GrSLType);
82 SkASSERT(GrGLShaderVar::kNonArray == uni.fArrayCount);
joshualitt7d022d62015-05-12 12:03:50 -070083 SkDEBUGCODE(this->printUnused(uni);)
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +000084 if (kUnusedUniform != uni.fFSLocation) {
commit-bot@chromium.org9188a152013-09-05 18:28:24 +000085 GR_GL_CALL(fGpu->glInterface(), Uniform1f(uni.fFSLocation, v0));
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +000086 }
87 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
commit-bot@chromium.org9188a152013-09-05 18:28:24 +000088 GR_GL_CALL(fGpu->glInterface(), Uniform1f(uni.fVSLocation, v0));
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +000089 }
90}
91
kkinnunen7510b222014-07-30 00:04:16 -070092void GrGLProgramDataManager::set1fv(UniformHandle u,
93 int arrayCount,
94 const GrGLfloat v[]) const {
joshualitte7afc2d2015-09-11 10:44:13 -070095 const Uniform& uni = fUniforms[u.toIndex()];
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +000096 SkASSERT(uni.fType == kFloat_GrSLType);
97 SkASSERT(arrayCount > 0);
commit-bot@chromium.orgd3baf202013-11-07 22:06:08 +000098 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount);
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +000099 // This assert fires in some instances of the two-pt gradient for its VSParams.
100 // Once the uniform manager is responsible for inserting the duplicate uniform
101 // arrays in VS and FS driver bug workaround, this can be enabled.
joshualittaf2d56d2015-05-11 06:21:34 -0700102 // this->printUni(uni);
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +0000103 if (kUnusedUniform != uni.fFSLocation) {
commit-bot@chromium.orgd3baf202013-11-07 22:06:08 +0000104 GR_GL_CALL(fGpu->glInterface(), Uniform1fv(uni.fFSLocation, arrayCount, v));
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +0000105 }
106 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
commit-bot@chromium.orgd3baf202013-11-07 22:06:08 +0000107 GR_GL_CALL(fGpu->glInterface(), Uniform1fv(uni.fVSLocation, arrayCount, v));
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +0000108 }
109}
110
kkinnunen7510b222014-07-30 00:04:16 -0700111void GrGLProgramDataManager::set2f(UniformHandle u, GrGLfloat v0, GrGLfloat v1) const {
joshualitte7afc2d2015-09-11 10:44:13 -0700112 const Uniform& uni = fUniforms[u.toIndex()];
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000113 SkASSERT(uni.fType == kVec2f_GrSLType);
114 SkASSERT(GrGLShaderVar::kNonArray == uni.fArrayCount);
joshualitt7d022d62015-05-12 12:03:50 -0700115 SkDEBUGCODE(this->printUnused(uni);)
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +0000116 if (kUnusedUniform != uni.fFSLocation) {
commit-bot@chromium.org9188a152013-09-05 18:28:24 +0000117 GR_GL_CALL(fGpu->glInterface(), Uniform2f(uni.fFSLocation, v0, v1));
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +0000118 }
119 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
commit-bot@chromium.org9188a152013-09-05 18:28:24 +0000120 GR_GL_CALL(fGpu->glInterface(), Uniform2f(uni.fVSLocation, v0, v1));
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +0000121 }
122}
123
kkinnunen7510b222014-07-30 00:04:16 -0700124void GrGLProgramDataManager::set2fv(UniformHandle u,
125 int arrayCount,
126 const GrGLfloat v[]) const {
joshualitte7afc2d2015-09-11 10:44:13 -0700127 const Uniform& uni = fUniforms[u.toIndex()];
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000128 SkASSERT(uni.fType == kVec2f_GrSLType);
129 SkASSERT(arrayCount > 0);
commit-bot@chromium.orgd3baf202013-11-07 22:06:08 +0000130 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount);
joshualitt7d022d62015-05-12 12:03:50 -0700131 SkDEBUGCODE(this->printUnused(uni);)
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +0000132 if (kUnusedUniform != uni.fFSLocation) {
commit-bot@chromium.orgd3baf202013-11-07 22:06:08 +0000133 GR_GL_CALL(fGpu->glInterface(), Uniform2fv(uni.fFSLocation, arrayCount, v));
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +0000134 }
135 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
commit-bot@chromium.orgd3baf202013-11-07 22:06:08 +0000136 GR_GL_CALL(fGpu->glInterface(), Uniform2fv(uni.fVSLocation, arrayCount, v));
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +0000137 }
138}
139
kkinnunen7510b222014-07-30 00:04:16 -0700140void GrGLProgramDataManager::set3f(UniformHandle u, GrGLfloat v0, GrGLfloat v1, GrGLfloat v2) const {
joshualitte7afc2d2015-09-11 10:44:13 -0700141 const Uniform& uni = fUniforms[u.toIndex()];
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000142 SkASSERT(uni.fType == kVec3f_GrSLType);
143 SkASSERT(GrGLShaderVar::kNonArray == uni.fArrayCount);
joshualitt7d022d62015-05-12 12:03:50 -0700144 SkDEBUGCODE(this->printUnused(uni);)
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +0000145 if (kUnusedUniform != uni.fFSLocation) {
commit-bot@chromium.org9188a152013-09-05 18:28:24 +0000146 GR_GL_CALL(fGpu->glInterface(), Uniform3f(uni.fFSLocation, v0, v1, v2));
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +0000147 }
148 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
commit-bot@chromium.org9188a152013-09-05 18:28:24 +0000149 GR_GL_CALL(fGpu->glInterface(), Uniform3f(uni.fVSLocation, v0, v1, v2));
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +0000150 }
151}
152
kkinnunen7510b222014-07-30 00:04:16 -0700153void GrGLProgramDataManager::set3fv(UniformHandle u,
154 int arrayCount,
155 const GrGLfloat v[]) const {
joshualitte7afc2d2015-09-11 10:44:13 -0700156 const Uniform& uni = fUniforms[u.toIndex()];
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000157 SkASSERT(uni.fType == kVec3f_GrSLType);
158 SkASSERT(arrayCount > 0);
commit-bot@chromium.orgd3baf202013-11-07 22:06:08 +0000159 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount);
joshualitt7d022d62015-05-12 12:03:50 -0700160 SkDEBUGCODE(this->printUnused(uni);)
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +0000161 if (kUnusedUniform != uni.fFSLocation) {
commit-bot@chromium.orgd3baf202013-11-07 22:06:08 +0000162 GR_GL_CALL(fGpu->glInterface(), Uniform3fv(uni.fFSLocation, arrayCount, v));
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +0000163 }
164 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
commit-bot@chromium.orgd3baf202013-11-07 22:06:08 +0000165 GR_GL_CALL(fGpu->glInterface(), Uniform3fv(uni.fVSLocation, arrayCount, v));
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +0000166 }
167}
168
kkinnunen7510b222014-07-30 00:04:16 -0700169void GrGLProgramDataManager::set4f(UniformHandle u,
170 GrGLfloat v0,
171 GrGLfloat v1,
172 GrGLfloat v2,
173 GrGLfloat v3) const {
joshualitte7afc2d2015-09-11 10:44:13 -0700174 const Uniform& uni = fUniforms[u.toIndex()];
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000175 SkASSERT(uni.fType == kVec4f_GrSLType);
176 SkASSERT(GrGLShaderVar::kNonArray == uni.fArrayCount);
joshualitt7d022d62015-05-12 12:03:50 -0700177 SkDEBUGCODE(this->printUnused(uni);)
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +0000178 if (kUnusedUniform != uni.fFSLocation) {
commit-bot@chromium.org9188a152013-09-05 18:28:24 +0000179 GR_GL_CALL(fGpu->glInterface(), Uniform4f(uni.fFSLocation, v0, v1, v2, v3));
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +0000180 }
181 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
commit-bot@chromium.org9188a152013-09-05 18:28:24 +0000182 GR_GL_CALL(fGpu->glInterface(), Uniform4f(uni.fVSLocation, v0, v1, v2, v3));
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +0000183 }
184}
185
kkinnunen7510b222014-07-30 00:04:16 -0700186void GrGLProgramDataManager::set4fv(UniformHandle u,
187 int arrayCount,
188 const GrGLfloat v[]) const {
joshualitte7afc2d2015-09-11 10:44:13 -0700189 const Uniform& uni = fUniforms[u.toIndex()];
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000190 SkASSERT(uni.fType == kVec4f_GrSLType);
191 SkASSERT(arrayCount > 0);
commit-bot@chromium.orgd3baf202013-11-07 22:06:08 +0000192 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount);
joshualitt7d022d62015-05-12 12:03:50 -0700193 SkDEBUGCODE(this->printUnused(uni);)
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +0000194 if (kUnusedUniform != uni.fFSLocation) {
commit-bot@chromium.orgd3baf202013-11-07 22:06:08 +0000195 GR_GL_CALL(fGpu->glInterface(), Uniform4fv(uni.fFSLocation, arrayCount, v));
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +0000196 }
197 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
commit-bot@chromium.orgd3baf202013-11-07 22:06:08 +0000198 GR_GL_CALL(fGpu->glInterface(), Uniform4fv(uni.fVSLocation, arrayCount, v));
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +0000199 }
200}
201
kkinnunen7510b222014-07-30 00:04:16 -0700202void GrGLProgramDataManager::setMatrix3f(UniformHandle u, const GrGLfloat matrix[]) const {
joshualitte7afc2d2015-09-11 10:44:13 -0700203 const Uniform& uni = fUniforms[u.toIndex()];
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000204 SkASSERT(uni.fType == kMat33f_GrSLType);
205 SkASSERT(GrGLShaderVar::kNonArray == uni.fArrayCount);
joshualitt7d022d62015-05-12 12:03:50 -0700206 SkDEBUGCODE(this->printUnused(uni);)
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +0000207 if (kUnusedUniform != uni.fFSLocation) {
commit-bot@chromium.org9188a152013-09-05 18:28:24 +0000208 GR_GL_CALL(fGpu->glInterface(), UniformMatrix3fv(uni.fFSLocation, 1, false, matrix));
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +0000209 }
210 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
commit-bot@chromium.org9188a152013-09-05 18:28:24 +0000211 GR_GL_CALL(fGpu->glInterface(), UniformMatrix3fv(uni.fVSLocation, 1, false, matrix));
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +0000212 }
213}
214
kkinnunen7510b222014-07-30 00:04:16 -0700215void GrGLProgramDataManager::setMatrix4f(UniformHandle u, const GrGLfloat matrix[]) const {
joshualitte7afc2d2015-09-11 10:44:13 -0700216 const Uniform& uni = fUniforms[u.toIndex()];
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000217 SkASSERT(uni.fType == kMat44f_GrSLType);
218 SkASSERT(GrGLShaderVar::kNonArray == uni.fArrayCount);
joshualitt7d022d62015-05-12 12:03:50 -0700219 SkDEBUGCODE(this->printUnused(uni);)
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +0000220 if (kUnusedUniform != uni.fFSLocation) {
commit-bot@chromium.org9188a152013-09-05 18:28:24 +0000221 GR_GL_CALL(fGpu->glInterface(), UniformMatrix4fv(uni.fFSLocation, 1, false, matrix));
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +0000222 }
223 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
commit-bot@chromium.org9188a152013-09-05 18:28:24 +0000224 GR_GL_CALL(fGpu->glInterface(), UniformMatrix4fv(uni.fVSLocation, 1, false, matrix));
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +0000225 }
226}
227
kkinnunen7510b222014-07-30 00:04:16 -0700228void GrGLProgramDataManager::setMatrix3fv(UniformHandle u,
229 int arrayCount,
230 const GrGLfloat matrices[]) const {
joshualitte7afc2d2015-09-11 10:44:13 -0700231 const Uniform& uni = fUniforms[u.toIndex()];
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000232 SkASSERT(uni.fType == kMat33f_GrSLType);
233 SkASSERT(arrayCount > 0);
commit-bot@chromium.orgd3baf202013-11-07 22:06:08 +0000234 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount);
joshualitt7d022d62015-05-12 12:03:50 -0700235 SkDEBUGCODE(this->printUnused(uni);)
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +0000236 if (kUnusedUniform != uni.fFSLocation) {
commit-bot@chromium.org9188a152013-09-05 18:28:24 +0000237 GR_GL_CALL(fGpu->glInterface(),
commit-bot@chromium.orgd3baf202013-11-07 22:06:08 +0000238 UniformMatrix3fv(uni.fFSLocation, arrayCount, false, matrices));
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +0000239 }
240 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
commit-bot@chromium.org9188a152013-09-05 18:28:24 +0000241 GR_GL_CALL(fGpu->glInterface(),
commit-bot@chromium.orgd3baf202013-11-07 22:06:08 +0000242 UniformMatrix3fv(uni.fVSLocation, arrayCount, false, matrices));
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +0000243 }
244}
245
kkinnunen7510b222014-07-30 00:04:16 -0700246void GrGLProgramDataManager::setMatrix4fv(UniformHandle u,
247 int arrayCount,
248 const GrGLfloat matrices[]) const {
joshualitte7afc2d2015-09-11 10:44:13 -0700249 const Uniform& uni = fUniforms[u.toIndex()];
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000250 SkASSERT(uni.fType == kMat44f_GrSLType);
251 SkASSERT(arrayCount > 0);
commit-bot@chromium.orgd3baf202013-11-07 22:06:08 +0000252 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount);
joshualitt7d022d62015-05-12 12:03:50 -0700253 SkDEBUGCODE(this->printUnused(uni);)
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +0000254 if (kUnusedUniform != uni.fFSLocation) {
commit-bot@chromium.org9188a152013-09-05 18:28:24 +0000255 GR_GL_CALL(fGpu->glInterface(),
commit-bot@chromium.orgd3baf202013-11-07 22:06:08 +0000256 UniformMatrix4fv(uni.fFSLocation, arrayCount, false, matrices));
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +0000257 }
258 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
commit-bot@chromium.org9188a152013-09-05 18:28:24 +0000259 GR_GL_CALL(fGpu->glInterface(),
commit-bot@chromium.orgd3baf202013-11-07 22:06:08 +0000260 UniformMatrix4fv(uni.fVSLocation, arrayCount, false, matrices));
bsalomon@google.comdbbc4e22012-07-25 17:48:39 +0000261 }
262}
263
kkinnunen7510b222014-07-30 00:04:16 -0700264void GrGLProgramDataManager::setSkMatrix(UniformHandle u, const SkMatrix& matrix) const {
bsalomon@google.comd8b5fac2012-11-01 17:02:46 +0000265 GrGLfloat mt[] = {
266 matrix.get(SkMatrix::kMScaleX),
267 matrix.get(SkMatrix::kMSkewY),
268 matrix.get(SkMatrix::kMPersp0),
269 matrix.get(SkMatrix::kMSkewX),
270 matrix.get(SkMatrix::kMScaleY),
271 matrix.get(SkMatrix::kMPersp1),
272 matrix.get(SkMatrix::kMTransX),
273 matrix.get(SkMatrix::kMTransY),
274 matrix.get(SkMatrix::kMPersp2),
275 };
276 this->setMatrix3f(u, mt);
277}
joshualittaf2d56d2015-05-11 06:21:34 -0700278
joshualittd8dd47b2015-09-11 11:45:01 -0700279void GrGLProgramDataManager::setPathFragmentInputTransform(SeparableVaryingHandle u,
280 int components,
281 const SkMatrix& matrix) const {
282 SkASSERT(fGpu->glCaps().shaderCaps()->pathRenderingSupport());
283 const SeparableVarying& fragmentInput = fSeparableVaryings[u.toIndex()];
284
285 SkASSERT((components == 2 && fragmentInput.fType == kVec2f_GrSLType) ||
286 (components == 3 && fragmentInput.fType == kVec3f_GrSLType));
287
288 fGpu->glPathRendering()->setProgramPathFragmentInputTransform(fProgramID,
289 fragmentInput.fLocation,
290 GR_GL_OBJECT_LINEAR,
291 components,
292 matrix);
293}
294
joshualittaf2d56d2015-05-11 06:21:34 -0700295#ifdef SK_DEBUG
296void GrGLProgramDataManager::printUnused(const Uniform& uni) const {
297 if (kUnusedUniform == uni.fFSLocation && kUnusedUniform == uni.fVSLocation) {
bsalomon682c2692015-05-22 14:01:46 -0700298 GrCapsDebugf(fGpu->caps(), "Unused uniform in shader\n");
joshualittaf2d56d2015-05-11 06:21:34 -0700299 }
300}
301#endif