Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(901)

Side by Side Diff: src/gpu/gl/GrGLUniformManager.cpp

Issue 62163004: Added support for Chrome's gpu command buffer extension BindUniformLocation. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fixed compile error on the bots + feedback. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/gpu/gl/GrGLUniformManager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "gl/GrGLShaderBuilder.h" 8 #include "gl/GrGLShaderBuilder.h"
9 #include "gl/GrGLProgram.h" 9 #include "gl/GrGLProgram.h"
10 #include "gl/GrGLUniformHandle.h" 10 #include "gl/GrGLUniformHandle.h"
11 #include "gl/GrGpuGL.h" 11 #include "gl/GrGpuGL.h"
12 #include "SkMatrix.h" 12 #include "SkMatrix.h"
13 13
14 #define ASSERT_ARRAY_UPLOAD_IN_BOUNDS(UNI, OFFSET, COUNT) \ 14 #define ASSERT_ARRAY_UPLOAD_IN_BOUNDS(UNI, COUNT) \
15 SkASSERT(offset + arrayCount <= uni.fArrayCount || \ 15 SkASSERT(arrayCount <= uni.fArrayCount || \
16 (0 == offset && 1 == arrayCount && GrGLShaderVar::kNonArray == uni.fArrayCount)) 16 (1 == arrayCount && GrGLShaderVar::kNonArray == uni.fArrayCoun t))
17
18 GrGLUniformManager::GrGLUniformManager(GrGpuGL* gpu) : fGpu(gpu) {
19 fUsingBindUniform = fGpu->glInterface()->fBindUniformLocation != NULL;
20 }
17 21
18 GrGLUniformManager::UniformHandle GrGLUniformManager::appendUniform(GrSLType typ e, int arrayCount) { 22 GrGLUniformManager::UniformHandle GrGLUniformManager::appendUniform(GrSLType typ e, int arrayCount) {
19 int idx = fUniforms.count(); 23 int idx = fUniforms.count();
20 Uniform& uni = fUniforms.push_back(); 24 Uniform& uni = fUniforms.push_back();
21 SkASSERT(GrGLShaderVar::kNonArray == arrayCount || arrayCount > 0); 25 SkASSERT(GrGLShaderVar::kNonArray == arrayCount || arrayCount > 0);
22 uni.fArrayCount = arrayCount; 26 uni.fArrayCount = arrayCount;
23 uni.fType = type; 27 uni.fType = type;
24 uni.fVSLocation = kUnusedUniform; 28 uni.fVSLocation = kUnusedUniform;
25 uni.fFSLocation = kUnusedUniform; 29 uni.fFSLocation = kUnusedUniform;
26 return GrGLUniformManager::UniformHandle::CreateFromUniformIndex(idx); 30 return GrGLUniformManager::UniformHandle::CreateFromUniformIndex(idx);
(...skipping 22 matching lines...) Expand all
49 SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat ion); 53 SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat ion);
50 if (kUnusedUniform != uni.fFSLocation) { 54 if (kUnusedUniform != uni.fFSLocation) {
51 GR_GL_CALL(fGpu->glInterface(), Uniform1f(uni.fFSLocation, v0)); 55 GR_GL_CALL(fGpu->glInterface(), Uniform1f(uni.fFSLocation, v0));
52 } 56 }
53 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) { 57 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
54 GR_GL_CALL(fGpu->glInterface(), Uniform1f(uni.fVSLocation, v0)); 58 GR_GL_CALL(fGpu->glInterface(), Uniform1f(uni.fVSLocation, v0));
55 } 59 }
56 } 60 }
57 61
58 void GrGLUniformManager::set1fv(UniformHandle u, 62 void GrGLUniformManager::set1fv(UniformHandle u,
59 int offset,
60 int arrayCount, 63 int arrayCount,
61 const GrGLfloat v[]) const { 64 const GrGLfloat v[]) const {
62 const Uniform& uni = fUniforms[u.toUniformIndex()]; 65 const Uniform& uni = fUniforms[u.toUniformIndex()];
63 SkASSERT(uni.fType == kFloat_GrSLType); 66 SkASSERT(uni.fType == kFloat_GrSLType);
64 SkASSERT(arrayCount > 0); 67 SkASSERT(arrayCount > 0);
65 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, offset, arrayCount); 68 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount);
66 // This assert fires in some instances of the two-pt gradient for its VSPara ms. 69 // This assert fires in some instances of the two-pt gradient for its VSPara ms.
67 // Once the uniform manager is responsible for inserting the duplicate unifo rm 70 // Once the uniform manager is responsible for inserting the duplicate unifo rm
68 // arrays in VS and FS driver bug workaround, this can be enabled. 71 // arrays in VS and FS driver bug workaround, this can be enabled.
69 //SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLoc ation); 72 //SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLoc ation);
70 if (kUnusedUniform != uni.fFSLocation) { 73 if (kUnusedUniform != uni.fFSLocation) {
71 GR_GL_CALL(fGpu->glInterface(), Uniform1fv(uni.fFSLocation + offset, arr ayCount, v)); 74 GR_GL_CALL(fGpu->glInterface(), Uniform1fv(uni.fFSLocation, arrayCount, v));
72 } 75 }
73 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) { 76 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
74 GR_GL_CALL(fGpu->glInterface(), Uniform1fv(uni.fVSLocation + offset, arr ayCount, v)); 77 GR_GL_CALL(fGpu->glInterface(), Uniform1fv(uni.fVSLocation, arrayCount, v));
75 } 78 }
76 } 79 }
77 80
78 void GrGLUniformManager::set2f(UniformHandle u, GrGLfloat v0, GrGLfloat v1) cons t { 81 void GrGLUniformManager::set2f(UniformHandle u, GrGLfloat v0, GrGLfloat v1) cons t {
79 const Uniform& uni = fUniforms[u.toUniformIndex()]; 82 const Uniform& uni = fUniforms[u.toUniformIndex()];
80 SkASSERT(uni.fType == kVec2f_GrSLType); 83 SkASSERT(uni.fType == kVec2f_GrSLType);
81 SkASSERT(GrGLShaderVar::kNonArray == uni.fArrayCount); 84 SkASSERT(GrGLShaderVar::kNonArray == uni.fArrayCount);
82 SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat ion); 85 SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat ion);
83 if (kUnusedUniform != uni.fFSLocation) { 86 if (kUnusedUniform != uni.fFSLocation) {
84 GR_GL_CALL(fGpu->glInterface(), Uniform2f(uni.fFSLocation, v0, v1)); 87 GR_GL_CALL(fGpu->glInterface(), Uniform2f(uni.fFSLocation, v0, v1));
85 } 88 }
86 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) { 89 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
87 GR_GL_CALL(fGpu->glInterface(), Uniform2f(uni.fVSLocation, v0, v1)); 90 GR_GL_CALL(fGpu->glInterface(), Uniform2f(uni.fVSLocation, v0, v1));
88 } 91 }
89 } 92 }
90 93
91 void GrGLUniformManager::set2fv(UniformHandle u, 94 void GrGLUniformManager::set2fv(UniformHandle u,
92 int offset,
93 int arrayCount, 95 int arrayCount,
94 const GrGLfloat v[]) const { 96 const GrGLfloat v[]) const {
95 const Uniform& uni = fUniforms[u.toUniformIndex()]; 97 const Uniform& uni = fUniforms[u.toUniformIndex()];
96 SkASSERT(uni.fType == kVec2f_GrSLType); 98 SkASSERT(uni.fType == kVec2f_GrSLType);
97 SkASSERT(arrayCount > 0); 99 SkASSERT(arrayCount > 0);
98 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, offset, arrayCount); 100 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount);
99 SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat ion); 101 SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat ion);
100 if (kUnusedUniform != uni.fFSLocation) { 102 if (kUnusedUniform != uni.fFSLocation) {
101 GR_GL_CALL(fGpu->glInterface(), Uniform2fv(uni.fFSLocation + offset, arr ayCount, v)); 103 GR_GL_CALL(fGpu->glInterface(), Uniform2fv(uni.fFSLocation, arrayCount, v));
102 } 104 }
103 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) { 105 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
104 GR_GL_CALL(fGpu->glInterface(), Uniform2fv(uni.fVSLocation + offset, arr ayCount, v)); 106 GR_GL_CALL(fGpu->glInterface(), Uniform2fv(uni.fVSLocation, arrayCount, v));
105 } 107 }
106 } 108 }
107 109
108 void GrGLUniformManager::set3f(UniformHandle u, GrGLfloat v0, GrGLfloat v1, GrGL float v2) const { 110 void GrGLUniformManager::set3f(UniformHandle u, GrGLfloat v0, GrGLfloat v1, GrGL float v2) const {
109 const Uniform& uni = fUniforms[u.toUniformIndex()]; 111 const Uniform& uni = fUniforms[u.toUniformIndex()];
110 SkASSERT(uni.fType == kVec3f_GrSLType); 112 SkASSERT(uni.fType == kVec3f_GrSLType);
111 SkASSERT(GrGLShaderVar::kNonArray == uni.fArrayCount); 113 SkASSERT(GrGLShaderVar::kNonArray == uni.fArrayCount);
112 SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat ion); 114 SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat ion);
113 if (kUnusedUniform != uni.fFSLocation) { 115 if (kUnusedUniform != uni.fFSLocation) {
114 GR_GL_CALL(fGpu->glInterface(), Uniform3f(uni.fFSLocation, v0, v1, v2)); 116 GR_GL_CALL(fGpu->glInterface(), Uniform3f(uni.fFSLocation, v0, v1, v2));
115 } 117 }
116 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) { 118 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
117 GR_GL_CALL(fGpu->glInterface(), Uniform3f(uni.fVSLocation, v0, v1, v2)); 119 GR_GL_CALL(fGpu->glInterface(), Uniform3f(uni.fVSLocation, v0, v1, v2));
118 } 120 }
119 } 121 }
120 122
121 void GrGLUniformManager::set3fv(UniformHandle u, 123 void GrGLUniformManager::set3fv(UniformHandle u,
122 int offset,
123 int arrayCount, 124 int arrayCount,
124 const GrGLfloat v[]) const { 125 const GrGLfloat v[]) const {
125 const Uniform& uni = fUniforms[u.toUniformIndex()]; 126 const Uniform& uni = fUniforms[u.toUniformIndex()];
126 SkASSERT(uni.fType == kVec3f_GrSLType); 127 SkASSERT(uni.fType == kVec3f_GrSLType);
127 SkASSERT(arrayCount > 0); 128 SkASSERT(arrayCount > 0);
128 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, offset, arrayCount); 129 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount);
129 SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat ion); 130 SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat ion);
130 if (kUnusedUniform != uni.fFSLocation) { 131 if (kUnusedUniform != uni.fFSLocation) {
131 GR_GL_CALL(fGpu->glInterface(), Uniform3fv(uni.fFSLocation + offset, arr ayCount, v)); 132 GR_GL_CALL(fGpu->glInterface(), Uniform3fv(uni.fFSLocation, arrayCount, v));
132 } 133 }
133 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) { 134 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
134 GR_GL_CALL(fGpu->glInterface(), Uniform3fv(uni.fVSLocation + offset, arr ayCount, v)); 135 GR_GL_CALL(fGpu->glInterface(), Uniform3fv(uni.fVSLocation, arrayCount, v));
135 } 136 }
136 } 137 }
137 138
138 void GrGLUniformManager::set4f(UniformHandle u, 139 void GrGLUniformManager::set4f(UniformHandle u,
139 GrGLfloat v0, 140 GrGLfloat v0,
140 GrGLfloat v1, 141 GrGLfloat v1,
141 GrGLfloat v2, 142 GrGLfloat v2,
142 GrGLfloat v3) const { 143 GrGLfloat v3) const {
143 const Uniform& uni = fUniforms[u.toUniformIndex()]; 144 const Uniform& uni = fUniforms[u.toUniformIndex()];
144 SkASSERT(uni.fType == kVec4f_GrSLType); 145 SkASSERT(uni.fType == kVec4f_GrSLType);
145 SkASSERT(GrGLShaderVar::kNonArray == uni.fArrayCount); 146 SkASSERT(GrGLShaderVar::kNonArray == uni.fArrayCount);
146 SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat ion); 147 SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat ion);
147 if (kUnusedUniform != uni.fFSLocation) { 148 if (kUnusedUniform != uni.fFSLocation) {
148 GR_GL_CALL(fGpu->glInterface(), Uniform4f(uni.fFSLocation, v0, v1, v2, v 3)); 149 GR_GL_CALL(fGpu->glInterface(), Uniform4f(uni.fFSLocation, v0, v1, v2, v 3));
149 } 150 }
150 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) { 151 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
151 GR_GL_CALL(fGpu->glInterface(), Uniform4f(uni.fVSLocation, v0, v1, v2, v 3)); 152 GR_GL_CALL(fGpu->glInterface(), Uniform4f(uni.fVSLocation, v0, v1, v2, v 3));
152 } 153 }
153 } 154 }
154 155
155 void GrGLUniformManager::set4fv(UniformHandle u, 156 void GrGLUniformManager::set4fv(UniformHandle u,
156 int offset,
157 int arrayCount, 157 int arrayCount,
158 const GrGLfloat v[]) const { 158 const GrGLfloat v[]) const {
159 const Uniform& uni = fUniforms[u.toUniformIndex()]; 159 const Uniform& uni = fUniforms[u.toUniformIndex()];
160 SkASSERT(uni.fType == kVec4f_GrSLType); 160 SkASSERT(uni.fType == kVec4f_GrSLType);
161 SkASSERT(arrayCount > 0); 161 SkASSERT(arrayCount > 0);
162 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount);
162 SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat ion); 163 SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat ion);
163 if (kUnusedUniform != uni.fFSLocation) { 164 if (kUnusedUniform != uni.fFSLocation) {
164 GR_GL_CALL(fGpu->glInterface(), Uniform4fv(uni.fFSLocation + offset, arr ayCount, v)); 165 GR_GL_CALL(fGpu->glInterface(), Uniform4fv(uni.fFSLocation, arrayCount, v));
165 } 166 }
166 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) { 167 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
167 GR_GL_CALL(fGpu->glInterface(), Uniform4fv(uni.fVSLocation + offset, arr ayCount, v)); 168 GR_GL_CALL(fGpu->glInterface(), Uniform4fv(uni.fVSLocation, arrayCount, v));
168 } 169 }
169 } 170 }
170 171
171 void GrGLUniformManager::setMatrix3f(UniformHandle u, const GrGLfloat matrix[]) const { 172 void GrGLUniformManager::setMatrix3f(UniformHandle u, const GrGLfloat matrix[]) const {
172 const Uniform& uni = fUniforms[u.toUniformIndex()]; 173 const Uniform& uni = fUniforms[u.toUniformIndex()];
173 SkASSERT(uni.fType == kMat33f_GrSLType); 174 SkASSERT(uni.fType == kMat33f_GrSLType);
174 SkASSERT(GrGLShaderVar::kNonArray == uni.fArrayCount); 175 SkASSERT(GrGLShaderVar::kNonArray == uni.fArrayCount);
175 // TODO: Re-enable this assert once texture matrices aren't forced on all ef fects 176 // TODO: Re-enable this assert once texture matrices aren't forced on all ef fects
176 // SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLo cation); 177 // SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLo cation);
177 if (kUnusedUniform != uni.fFSLocation) { 178 if (kUnusedUniform != uni.fFSLocation) {
(...skipping 11 matching lines...) Expand all
189 SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat ion); 190 SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat ion);
190 if (kUnusedUniform != uni.fFSLocation) { 191 if (kUnusedUniform != uni.fFSLocation) {
191 GR_GL_CALL(fGpu->glInterface(), UniformMatrix4fv(uni.fFSLocation, 1, fal se, matrix)); 192 GR_GL_CALL(fGpu->glInterface(), UniformMatrix4fv(uni.fFSLocation, 1, fal se, matrix));
192 } 193 }
193 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) { 194 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
194 GR_GL_CALL(fGpu->glInterface(), UniformMatrix4fv(uni.fVSLocation, 1, fal se, matrix)); 195 GR_GL_CALL(fGpu->glInterface(), UniformMatrix4fv(uni.fVSLocation, 1, fal se, matrix));
195 } 196 }
196 } 197 }
197 198
198 void GrGLUniformManager::setMatrix3fv(UniformHandle u, 199 void GrGLUniformManager::setMatrix3fv(UniformHandle u,
199 int offset,
200 int arrayCount, 200 int arrayCount,
201 const GrGLfloat matrices[]) const { 201 const GrGLfloat matrices[]) const {
202 const Uniform& uni = fUniforms[u.toUniformIndex()]; 202 const Uniform& uni = fUniforms[u.toUniformIndex()];
203 SkASSERT(uni.fType == kMat33f_GrSLType); 203 SkASSERT(uni.fType == kMat33f_GrSLType);
204 SkASSERT(arrayCount > 0); 204 SkASSERT(arrayCount > 0);
205 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, offset, arrayCount); 205 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount);
206 SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat ion); 206 SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat ion);
207 if (kUnusedUniform != uni.fFSLocation) { 207 if (kUnusedUniform != uni.fFSLocation) {
208 GR_GL_CALL(fGpu->glInterface(), 208 GR_GL_CALL(fGpu->glInterface(),
209 UniformMatrix3fv(uni.fFSLocation + offset, arrayCount, false, matrices)); 209 UniformMatrix3fv(uni.fFSLocation, arrayCount, false, matrices ));
210 } 210 }
211 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) { 211 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
212 GR_GL_CALL(fGpu->glInterface(), 212 GR_GL_CALL(fGpu->glInterface(),
213 UniformMatrix3fv(uni.fVSLocation + offset, arrayCount, false, matrices)); 213 UniformMatrix3fv(uni.fVSLocation, arrayCount, false, matrices ));
214 } 214 }
215 } 215 }
216 216
217 void GrGLUniformManager::setMatrix4fv(UniformHandle u, 217 void GrGLUniformManager::setMatrix4fv(UniformHandle u,
218 int offset,
219 int arrayCount, 218 int arrayCount,
220 const GrGLfloat matrices[]) const { 219 const GrGLfloat matrices[]) const {
221 const Uniform& uni = fUniforms[u.toUniformIndex()]; 220 const Uniform& uni = fUniforms[u.toUniformIndex()];
222 SkASSERT(uni.fType == kMat44f_GrSLType); 221 SkASSERT(uni.fType == kMat44f_GrSLType);
223 SkASSERT(arrayCount > 0); 222 SkASSERT(arrayCount > 0);
224 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, offset, arrayCount); 223 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, arrayCount);
225 SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat ion); 224 SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat ion);
226 if (kUnusedUniform != uni.fFSLocation) { 225 if (kUnusedUniform != uni.fFSLocation) {
227 GR_GL_CALL(fGpu->glInterface(), 226 GR_GL_CALL(fGpu->glInterface(),
228 UniformMatrix4fv(uni.fFSLocation + offset, arrayCount, false, matrices)); 227 UniformMatrix4fv(uni.fFSLocation, arrayCount, false, matrices ));
229 } 228 }
230 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) { 229 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) {
231 GR_GL_CALL(fGpu->glInterface(), 230 GR_GL_CALL(fGpu->glInterface(),
232 UniformMatrix4fv(uni.fVSLocation + offset, arrayCount, false, matrices)); 231 UniformMatrix4fv(uni.fVSLocation, arrayCount, false, matrices ));
233 } 232 }
234 } 233 }
235 234
236 void GrGLUniformManager::setSkMatrix(UniformHandle u, const SkMatrix& matrix) co nst { 235 void GrGLUniformManager::setSkMatrix(UniformHandle u, const SkMatrix& matrix) co nst {
237 // GR_STATIC_ASSERT(SK_SCALAR_IS_FLOAT); 236 // GR_STATIC_ASSERT(SK_SCALAR_IS_FLOAT);
238 GrGLfloat mt[] = { 237 GrGLfloat mt[] = {
239 matrix.get(SkMatrix::kMScaleX), 238 matrix.get(SkMatrix::kMScaleX),
240 matrix.get(SkMatrix::kMSkewY), 239 matrix.get(SkMatrix::kMSkewY),
241 matrix.get(SkMatrix::kMPersp0), 240 matrix.get(SkMatrix::kMPersp0),
242 matrix.get(SkMatrix::kMSkewX), 241 matrix.get(SkMatrix::kMSkewX),
243 matrix.get(SkMatrix::kMScaleY), 242 matrix.get(SkMatrix::kMScaleY),
244 matrix.get(SkMatrix::kMPersp1), 243 matrix.get(SkMatrix::kMPersp1),
245 matrix.get(SkMatrix::kMTransX), 244 matrix.get(SkMatrix::kMTransX),
246 matrix.get(SkMatrix::kMTransY), 245 matrix.get(SkMatrix::kMTransY),
247 matrix.get(SkMatrix::kMPersp2), 246 matrix.get(SkMatrix::kMPersp2),
248 }; 247 };
249 this->setMatrix3f(u, mt); 248 this->setMatrix3f(u, mt);
250 } 249 }
251 250
252 251
253 void GrGLUniformManager::getUniformLocations(GrGLuint programID, const BuilderUn iformArray& uniforms) { 252 void GrGLUniformManager::getUniformLocations(GrGLuint programID, const BuilderUn iformArray& uniforms) {
254 SkASSERT(uniforms.count() == fUniforms.count()); 253 SkASSERT(uniforms.count() == fUniforms.count());
255 int count = fUniforms.count(); 254 int count = fUniforms.count();
256 for (int i = 0; i < count; ++i) { 255 for (int i = 0; i < count; ++i) {
257 SkASSERT(uniforms[i].fVariable.getType() == fUniforms[i].fType); 256 SkASSERT(uniforms[i].fVariable.getType() == fUniforms[i].fType);
258 SkASSERT(uniforms[i].fVariable.getArrayCount() == fUniforms[i].fArrayCou nt); 257 SkASSERT(uniforms[i].fVariable.getArrayCount() == fUniforms[i].fArrayCou nt);
259 GrGLint location; 258 GrGLint location;
260 // TODO: Move the Xoom uniform array in both FS and VS bug workaround he re. 259 // TODO: Move the Xoom uniform array in both FS and VS bug workaround he re.
261 GR_GL_CALL_RET(fGpu->glInterface(), location, 260 if (fUsingBindUniform) {
261 location = i;
262 GR_GL_CALL(fGpu->glInterface(),
263 BindUniformLocation(programID, location, uniforms[i].fVar iable.c_str()));
264 } else {
265 GR_GL_CALL_RET(fGpu->glInterface(), location,
262 GetUniformLocation(programID, uniforms[i].fVariable.c_str ())); 266 GetUniformLocation(programID, uniforms[i].fVariable.c_str ()));
267 }
263 if (GrGLShaderBuilder::kVertex_Visibility & uniforms[i].fVisibility) { 268 if (GrGLShaderBuilder::kVertex_Visibility & uniforms[i].fVisibility) {
264 fUniforms[i].fVSLocation = location; 269 fUniforms[i].fVSLocation = location;
265 } 270 }
266 if (GrGLShaderBuilder::kFragment_Visibility & uniforms[i].fVisibility) { 271 if (GrGLShaderBuilder::kFragment_Visibility & uniforms[i].fVisibility) {
267 fUniforms[i].fFSLocation = location; 272 fUniforms[i].fFSLocation = location;
268 } 273 }
269 } 274 }
270 } 275 }
271 276
272 const GrGLUniformManager::BuilderUniform& 277 const GrGLUniformManager::BuilderUniform&
273 GrGLUniformManager::getBuilderUniform(const BuilderUniformArray& array, UniformH andle handle) const { 278 GrGLUniformManager::getBuilderUniform(const BuilderUniformArray& array, UniformH andle handle) const {
274 return array[handle.toUniformIndex()]; 279 return array[handle.toUniformIndex()];
275 } 280 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLUniformManager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698