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 "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 "SkMatrix.h" | 11 #include "SkMatrix.h" |
12 | 12 |
13 #define ASSERT_ARRAY_UPLOAD_IN_BOUNDS(UNI, OFFSET, COUNT) \ | 13 #define ASSERT_ARRAY_UPLOAD_IN_BOUNDS(UNI, OFFSET, COUNT) \ |
14 GrAssert(offset + arrayCount <= uni.fArrayCount || \ | 14 GrAssert(offset + arrayCount <= uni.fArrayCount || \ |
15 (0 == offset && 1 == arrayCount && GrGLShaderVar::kNonArray ==
uni.fArrayCount)) | 15 (0 == offset && 1 == arrayCount && GrGLShaderVar::kNonArray ==
uni.fArrayCount)) |
16 | 16 |
17 GrGLUniformManager::UniformHandle GrGLUniformManager::appendUniform(GrSLType typ
e, int arrayCount) { | 17 GrGLUniformManager::UniformHandle GrGLUniformManager::appendUniform(GrSLType typ
e, int arrayCount) { |
18 int idx = fUniforms.count(); | 18 int idx = fUniforms.count(); |
19 Uniform& uni = fUniforms.push_back(); | 19 Uniform& uni = fUniforms.push_back(); |
20 GrAssert(GrGLShaderVar::kNonArray == arrayCount || arrayCount > 0); | 20 GrAssert(GrGLShaderVar::kNonArray == arrayCount || arrayCount > 0); |
21 uni.fArrayCount = arrayCount; | 21 uni.fArrayCount = arrayCount; |
22 uni.fType = type; | 22 uni.fType = type; |
23 uni.fVSLocation = kUnusedUniform; | 23 uni.fVSLocation = kUnusedUniform; |
24 uni.fFSLocation = kUnusedUniform; | 24 uni.fFSLocation = kUnusedUniform; |
25 return index_to_handle(idx); | 25 return GrGLUniformManager::UniformHandle::CreateFromUniformIndex(idx); |
26 } | 26 } |
27 | 27 |
28 void GrGLUniformManager::setSampler(UniformHandle u, GrGLint texUnit) const { | 28 void GrGLUniformManager::setSampler(UniformHandle u, GrGLint texUnit) const { |
29 const Uniform& uni = fUniforms[handle_to_index(u)]; | 29 const Uniform& uni = fUniforms[u.toUniformIndex()]; |
30 GrAssert(uni.fType == kSampler2D_GrSLType); | 30 GrAssert(uni.fType == kSampler2D_GrSLType); |
31 GrAssert(GrGLShaderVar::kNonArray == uni.fArrayCount); | 31 GrAssert(GrGLShaderVar::kNonArray == uni.fArrayCount); |
32 // FIXME: We still insert a single sampler uniform for every stage. If the s
hader does not | 32 // FIXME: We still insert a single sampler uniform for every stage. If the s
hader does not |
33 // reference the sampler then the compiler may have optimized it out. Uncomm
ent this assert | 33 // reference the sampler then the compiler may have optimized it out. Uncomm
ent this assert |
34 // once stages insert their own samplers. | 34 // once stages insert their own samplers. |
35 // GrAssert(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLo
cation); | 35 // GrAssert(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLo
cation); |
36 if (kUnusedUniform != uni.fFSLocation) { | 36 if (kUnusedUniform != uni.fFSLocation) { |
37 GR_GL_CALL(fContext.interface(), Uniform1i(uni.fFSLocation, texUnit)); | 37 GR_GL_CALL(fContext.interface(), Uniform1i(uni.fFSLocation, texUnit)); |
38 } | 38 } |
39 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ | 39 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ |
40 GR_GL_CALL(fContext.interface(), Uniform1i(uni.fVSLocation, texUnit)); | 40 GR_GL_CALL(fContext.interface(), Uniform1i(uni.fVSLocation, texUnit)); |
41 } | 41 } |
42 } | 42 } |
43 | 43 |
44 void GrGLUniformManager::set1f(UniformHandle u, GrGLfloat v0) const { | 44 void GrGLUniformManager::set1f(UniformHandle u, GrGLfloat v0) const { |
45 const Uniform& uni = fUniforms[handle_to_index(u)]; | 45 const Uniform& uni = fUniforms[u.toUniformIndex()]; |
46 GrAssert(uni.fType == kFloat_GrSLType); | 46 GrAssert(uni.fType == kFloat_GrSLType); |
47 GrAssert(GrGLShaderVar::kNonArray == uni.fArrayCount); | 47 GrAssert(GrGLShaderVar::kNonArray == uni.fArrayCount); |
48 GrAssert(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat
ion); | 48 GrAssert(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat
ion); |
49 if (kUnusedUniform != uni.fFSLocation) { | 49 if (kUnusedUniform != uni.fFSLocation) { |
50 GR_GL_CALL(fContext.interface(), Uniform1f(uni.fFSLocation, v0)); | 50 GR_GL_CALL(fContext.interface(), Uniform1f(uni.fFSLocation, v0)); |
51 } | 51 } |
52 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ | 52 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ |
53 GR_GL_CALL(fContext.interface(), Uniform1f(uni.fVSLocation, v0)); | 53 GR_GL_CALL(fContext.interface(), Uniform1f(uni.fVSLocation, v0)); |
54 } | 54 } |
55 } | 55 } |
56 | 56 |
57 void GrGLUniformManager::set1fv(UniformHandle u, | 57 void GrGLUniformManager::set1fv(UniformHandle u, |
58 int offset, | 58 int offset, |
59 int arrayCount, | 59 int arrayCount, |
60 const GrGLfloat v[]) const { | 60 const GrGLfloat v[]) const { |
61 const Uniform& uni = fUniforms[handle_to_index(u)]; | 61 const Uniform& uni = fUniforms[u.toUniformIndex()]; |
62 GrAssert(uni.fType == kFloat_GrSLType); | 62 GrAssert(uni.fType == kFloat_GrSLType); |
63 GrAssert(arrayCount > 0); | 63 GrAssert(arrayCount > 0); |
64 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, offset, arrayCount); | 64 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, offset, arrayCount); |
65 // This assert fires in some instances of the two-pt gradient for its VSPara
ms. | 65 // This assert fires in some instances of the two-pt gradient for its VSPara
ms. |
66 // Once the uniform manager is responsible for inserting the duplicate unifo
rm | 66 // Once the uniform manager is responsible for inserting the duplicate unifo
rm |
67 // arrays in VS and FS driver bug workaround, this can be enabled. | 67 // arrays in VS and FS driver bug workaround, this can be enabled. |
68 //GrAssert(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLoc
ation); | 68 //GrAssert(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLoc
ation); |
69 if (kUnusedUniform != uni.fFSLocation) { | 69 if (kUnusedUniform != uni.fFSLocation) { |
70 GR_GL_CALL(fContext.interface(), Uniform1fv(uni.fFSLocation + offset, ar
rayCount, v)); | 70 GR_GL_CALL(fContext.interface(), Uniform1fv(uni.fFSLocation + offset, ar
rayCount, v)); |
71 } | 71 } |
72 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ | 72 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ |
73 GR_GL_CALL(fContext.interface(), Uniform1fv(uni.fVSLocation + offset, ar
rayCount, v)); | 73 GR_GL_CALL(fContext.interface(), Uniform1fv(uni.fVSLocation + offset, ar
rayCount, v)); |
74 } | 74 } |
75 } | 75 } |
76 | 76 |
77 void GrGLUniformManager::set2f(UniformHandle u, GrGLfloat v0, GrGLfloat v1) cons
t { | 77 void GrGLUniformManager::set2f(UniformHandle u, GrGLfloat v0, GrGLfloat v1) cons
t { |
78 const Uniform& uni = fUniforms[handle_to_index(u)]; | 78 const Uniform& uni = fUniforms[u.toUniformIndex()]; |
79 GrAssert(uni.fType == kVec2f_GrSLType); | 79 GrAssert(uni.fType == kVec2f_GrSLType); |
80 GrAssert(GrGLShaderVar::kNonArray == uni.fArrayCount); | 80 GrAssert(GrGLShaderVar::kNonArray == uni.fArrayCount); |
81 GrAssert(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat
ion); | 81 GrAssert(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat
ion); |
82 if (kUnusedUniform != uni.fFSLocation) { | 82 if (kUnusedUniform != uni.fFSLocation) { |
83 GR_GL_CALL(fContext.interface(), Uniform2f(uni.fFSLocation, v0, v1)); | 83 GR_GL_CALL(fContext.interface(), Uniform2f(uni.fFSLocation, v0, v1)); |
84 } | 84 } |
85 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ | 85 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ |
86 GR_GL_CALL(fContext.interface(), Uniform2f(uni.fVSLocation, v0, v1)); | 86 GR_GL_CALL(fContext.interface(), Uniform2f(uni.fVSLocation, v0, v1)); |
87 } | 87 } |
88 } | 88 } |
89 | 89 |
90 void GrGLUniformManager::set2fv(UniformHandle u, | 90 void GrGLUniformManager::set2fv(UniformHandle u, |
91 int offset, | 91 int offset, |
92 int arrayCount, | 92 int arrayCount, |
93 const GrGLfloat v[]) const { | 93 const GrGLfloat v[]) const { |
94 const Uniform& uni = fUniforms[handle_to_index(u)]; | 94 const Uniform& uni = fUniforms[u.toUniformIndex()]; |
95 GrAssert(uni.fType == kVec2f_GrSLType); | 95 GrAssert(uni.fType == kVec2f_GrSLType); |
96 GrAssert(arrayCount > 0); | 96 GrAssert(arrayCount > 0); |
97 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, offset, arrayCount); | 97 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, offset, arrayCount); |
98 GrAssert(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat
ion); | 98 GrAssert(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat
ion); |
99 if (kUnusedUniform != uni.fFSLocation) { | 99 if (kUnusedUniform != uni.fFSLocation) { |
100 GR_GL_CALL(fContext.interface(), Uniform2fv(uni.fFSLocation + offset, ar
rayCount, v)); | 100 GR_GL_CALL(fContext.interface(), Uniform2fv(uni.fFSLocation + offset, ar
rayCount, v)); |
101 } | 101 } |
102 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ | 102 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ |
103 GR_GL_CALL(fContext.interface(), Uniform2fv(uni.fVSLocation + offset, ar
rayCount, v)); | 103 GR_GL_CALL(fContext.interface(), Uniform2fv(uni.fVSLocation + offset, ar
rayCount, v)); |
104 } | 104 } |
105 } | 105 } |
106 | 106 |
107 void GrGLUniformManager::set3f(UniformHandle u, GrGLfloat v0, GrGLfloat v1, GrGL
float v2) const { | 107 void GrGLUniformManager::set3f(UniformHandle u, GrGLfloat v0, GrGLfloat v1, GrGL
float v2) const { |
108 const Uniform& uni = fUniforms[handle_to_index(u)]; | 108 const Uniform& uni = fUniforms[u.toUniformIndex()]; |
109 GrAssert(uni.fType == kVec3f_GrSLType); | 109 GrAssert(uni.fType == kVec3f_GrSLType); |
110 GrAssert(GrGLShaderVar::kNonArray == uni.fArrayCount); | 110 GrAssert(GrGLShaderVar::kNonArray == uni.fArrayCount); |
111 GrAssert(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat
ion); | 111 GrAssert(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat
ion); |
112 if (kUnusedUniform != uni.fFSLocation) { | 112 if (kUnusedUniform != uni.fFSLocation) { |
113 GR_GL_CALL(fContext.interface(), Uniform3f(uni.fFSLocation, v0, v1, v2))
; | 113 GR_GL_CALL(fContext.interface(), Uniform3f(uni.fFSLocation, v0, v1, v2))
; |
114 } | 114 } |
115 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ | 115 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ |
116 GR_GL_CALL(fContext.interface(), Uniform3f(uni.fVSLocation, v0, v1, v2))
; | 116 GR_GL_CALL(fContext.interface(), Uniform3f(uni.fVSLocation, v0, v1, v2))
; |
117 } | 117 } |
118 } | 118 } |
119 | 119 |
120 void GrGLUniformManager::set3fv(UniformHandle u, | 120 void GrGLUniformManager::set3fv(UniformHandle u, |
121 int offset, | 121 int offset, |
122 int arrayCount, | 122 int arrayCount, |
123 const GrGLfloat v[]) const { | 123 const GrGLfloat v[]) const { |
124 const Uniform& uni = fUniforms[handle_to_index(u)]; | 124 const Uniform& uni = fUniforms[u.toUniformIndex()]; |
125 GrAssert(uni.fType == kVec3f_GrSLType); | 125 GrAssert(uni.fType == kVec3f_GrSLType); |
126 GrAssert(arrayCount > 0); | 126 GrAssert(arrayCount > 0); |
127 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, offset, arrayCount); | 127 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, offset, arrayCount); |
128 GrAssert(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat
ion); | 128 GrAssert(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat
ion); |
129 if (kUnusedUniform != uni.fFSLocation) { | 129 if (kUnusedUniform != uni.fFSLocation) { |
130 GR_GL_CALL(fContext.interface(), Uniform3fv(uni.fFSLocation + offset, ar
rayCount, v)); | 130 GR_GL_CALL(fContext.interface(), Uniform3fv(uni.fFSLocation + offset, ar
rayCount, v)); |
131 } | 131 } |
132 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ | 132 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ |
133 GR_GL_CALL(fContext.interface(), Uniform3fv(uni.fVSLocation + offset, ar
rayCount, v)); | 133 GR_GL_CALL(fContext.interface(), Uniform3fv(uni.fVSLocation + offset, ar
rayCount, v)); |
134 } | 134 } |
135 } | 135 } |
136 | 136 |
137 void GrGLUniformManager::set4f(UniformHandle u, | 137 void GrGLUniformManager::set4f(UniformHandle u, |
138 GrGLfloat v0, | 138 GrGLfloat v0, |
139 GrGLfloat v1, | 139 GrGLfloat v1, |
140 GrGLfloat v2, | 140 GrGLfloat v2, |
141 GrGLfloat v3) const { | 141 GrGLfloat v3) const { |
142 const Uniform& uni = fUniforms[handle_to_index(u)]; | 142 const Uniform& uni = fUniforms[u.toUniformIndex()]; |
143 GrAssert(uni.fType == kVec4f_GrSLType); | 143 GrAssert(uni.fType == kVec4f_GrSLType); |
144 GrAssert(GrGLShaderVar::kNonArray == uni.fArrayCount); | 144 GrAssert(GrGLShaderVar::kNonArray == uni.fArrayCount); |
145 GrAssert(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat
ion); | 145 GrAssert(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat
ion); |
146 if (kUnusedUniform != uni.fFSLocation) { | 146 if (kUnusedUniform != uni.fFSLocation) { |
147 GR_GL_CALL(fContext.interface(), Uniform4f(uni.fFSLocation, v0, v1, v2,
v3)); | 147 GR_GL_CALL(fContext.interface(), Uniform4f(uni.fFSLocation, v0, v1, v2,
v3)); |
148 } | 148 } |
149 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ | 149 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ |
150 GR_GL_CALL(fContext.interface(), Uniform4f(uni.fVSLocation, v0, v1, v2,
v3)); | 150 GR_GL_CALL(fContext.interface(), Uniform4f(uni.fVSLocation, v0, v1, v2,
v3)); |
151 } | 151 } |
152 } | 152 } |
153 | 153 |
154 void GrGLUniformManager::set4fv(UniformHandle u, | 154 void GrGLUniformManager::set4fv(UniformHandle u, |
155 int offset, | 155 int offset, |
156 int arrayCount, | 156 int arrayCount, |
157 const GrGLfloat v[]) const { | 157 const GrGLfloat v[]) const { |
158 const Uniform& uni = fUniforms[handle_to_index(u)]; | 158 const Uniform& uni = fUniforms[u.toUniformIndex()]; |
159 GrAssert(uni.fType == kVec4f_GrSLType); | 159 GrAssert(uni.fType == kVec4f_GrSLType); |
160 GrAssert(arrayCount > 0); | 160 GrAssert(arrayCount > 0); |
161 GrAssert(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat
ion); | 161 GrAssert(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat
ion); |
162 if (kUnusedUniform != uni.fFSLocation) { | 162 if (kUnusedUniform != uni.fFSLocation) { |
163 GR_GL_CALL(fContext.interface(), Uniform4fv(uni.fFSLocation + offset, ar
rayCount, v)); | 163 GR_GL_CALL(fContext.interface(), Uniform4fv(uni.fFSLocation + offset, ar
rayCount, v)); |
164 } | 164 } |
165 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ | 165 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ |
166 GR_GL_CALL(fContext.interface(), Uniform4fv(uni.fVSLocation + offset, ar
rayCount, v)); | 166 GR_GL_CALL(fContext.interface(), Uniform4fv(uni.fVSLocation + offset, ar
rayCount, v)); |
167 } | 167 } |
168 } | 168 } |
169 | 169 |
170 void GrGLUniformManager::setMatrix3f(UniformHandle u, const GrGLfloat matrix[])
const { | 170 void GrGLUniformManager::setMatrix3f(UniformHandle u, const GrGLfloat matrix[])
const { |
171 const Uniform& uni = fUniforms[handle_to_index(u)]; | 171 const Uniform& uni = fUniforms[u.toUniformIndex()]; |
172 GrAssert(uni.fType == kMat33f_GrSLType); | 172 GrAssert(uni.fType == kMat33f_GrSLType); |
173 GrAssert(GrGLShaderVar::kNonArray == uni.fArrayCount); | 173 GrAssert(GrGLShaderVar::kNonArray == uni.fArrayCount); |
174 // TODO: Re-enable this assert once texture matrices aren't forced on all ef
fects | 174 // TODO: Re-enable this assert once texture matrices aren't forced on all ef
fects |
175 // GrAssert(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLo
cation); | 175 // GrAssert(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLo
cation); |
176 if (kUnusedUniform != uni.fFSLocation) { | 176 if (kUnusedUniform != uni.fFSLocation) { |
177 GR_GL_CALL(fContext.interface(), UniformMatrix3fv(uni.fFSLocation, 1, fa
lse, matrix)); | 177 GR_GL_CALL(fContext.interface(), UniformMatrix3fv(uni.fFSLocation, 1, fa
lse, matrix)); |
178 } | 178 } |
179 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ | 179 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ |
180 GR_GL_CALL(fContext.interface(), UniformMatrix3fv(uni.fVSLocation, 1, fa
lse, matrix)); | 180 GR_GL_CALL(fContext.interface(), UniformMatrix3fv(uni.fVSLocation, 1, fa
lse, matrix)); |
181 } | 181 } |
182 } | 182 } |
183 | 183 |
184 void GrGLUniformManager::setMatrix4f(UniformHandle u, const GrGLfloat matrix[])
const { | 184 void GrGLUniformManager::setMatrix4f(UniformHandle u, const GrGLfloat matrix[])
const { |
185 const Uniform& uni = fUniforms[handle_to_index(u)]; | 185 const Uniform& uni = fUniforms[u.toUniformIndex()]; |
186 GrAssert(uni.fType == kMat44f_GrSLType); | 186 GrAssert(uni.fType == kMat44f_GrSLType); |
187 GrAssert(GrGLShaderVar::kNonArray == uni.fArrayCount); | 187 GrAssert(GrGLShaderVar::kNonArray == uni.fArrayCount); |
188 GrAssert(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat
ion); | 188 GrAssert(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat
ion); |
189 if (kUnusedUniform != uni.fFSLocation) { | 189 if (kUnusedUniform != uni.fFSLocation) { |
190 GR_GL_CALL(fContext.interface(), UniformMatrix4fv(uni.fFSLocation, 1, fa
lse, matrix)); | 190 GR_GL_CALL(fContext.interface(), UniformMatrix4fv(uni.fFSLocation, 1, fa
lse, matrix)); |
191 } | 191 } |
192 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ | 192 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ |
193 GR_GL_CALL(fContext.interface(), UniformMatrix4fv(uni.fVSLocation, 1, fa
lse, matrix)); | 193 GR_GL_CALL(fContext.interface(), UniformMatrix4fv(uni.fVSLocation, 1, fa
lse, matrix)); |
194 } | 194 } |
195 } | 195 } |
196 | 196 |
197 void GrGLUniformManager::setMatrix3fv(UniformHandle u, | 197 void GrGLUniformManager::setMatrix3fv(UniformHandle u, |
198 int offset, | 198 int offset, |
199 int arrayCount, | 199 int arrayCount, |
200 const GrGLfloat matrices[]) const { | 200 const GrGLfloat matrices[]) const { |
201 const Uniform& uni = fUniforms[handle_to_index(u)]; | 201 const Uniform& uni = fUniforms[u.toUniformIndex()]; |
202 GrAssert(uni.fType == kMat33f_GrSLType); | 202 GrAssert(uni.fType == kMat33f_GrSLType); |
203 GrAssert(arrayCount > 0); | 203 GrAssert(arrayCount > 0); |
204 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, offset, arrayCount); | 204 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, offset, arrayCount); |
205 GrAssert(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat
ion); | 205 GrAssert(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat
ion); |
206 if (kUnusedUniform != uni.fFSLocation) { | 206 if (kUnusedUniform != uni.fFSLocation) { |
207 GR_GL_CALL(fContext.interface(), | 207 GR_GL_CALL(fContext.interface(), |
208 UniformMatrix3fv(uni.fFSLocation + offset, arrayCount, false,
matrices)); | 208 UniformMatrix3fv(uni.fFSLocation + offset, arrayCount, false,
matrices)); |
209 } | 209 } |
210 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ | 210 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ |
211 GR_GL_CALL(fContext.interface(), | 211 GR_GL_CALL(fContext.interface(), |
212 UniformMatrix3fv(uni.fVSLocation + offset, arrayCount, false,
matrices)); | 212 UniformMatrix3fv(uni.fVSLocation + offset, arrayCount, false,
matrices)); |
213 } | 213 } |
214 } | 214 } |
215 | 215 |
216 void GrGLUniformManager::setMatrix4fv(UniformHandle u, | 216 void GrGLUniformManager::setMatrix4fv(UniformHandle u, |
217 int offset, | 217 int offset, |
218 int arrayCount, | 218 int arrayCount, |
219 const GrGLfloat matrices[]) const { | 219 const GrGLfloat matrices[]) const { |
220 const Uniform& uni = fUniforms[handle_to_index(u)]; | 220 const Uniform& uni = fUniforms[u.toUniformIndex()]; |
221 GrAssert(uni.fType == kMat44f_GrSLType); | 221 GrAssert(uni.fType == kMat44f_GrSLType); |
222 GrAssert(arrayCount > 0); | 222 GrAssert(arrayCount > 0); |
223 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, offset, arrayCount); | 223 ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, offset, arrayCount); |
224 GrAssert(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat
ion); | 224 GrAssert(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocat
ion); |
225 if (kUnusedUniform != uni.fFSLocation) { | 225 if (kUnusedUniform != uni.fFSLocation) { |
226 GR_GL_CALL(fContext.interface(), | 226 GR_GL_CALL(fContext.interface(), |
227 UniformMatrix4fv(uni.fFSLocation + offset, arrayCount, false,
matrices)); | 227 UniformMatrix4fv(uni.fFSLocation + offset, arrayCount, false,
matrices)); |
228 } | 228 } |
229 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ | 229 if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation)
{ |
230 GR_GL_CALL(fContext.interface(), | 230 GR_GL_CALL(fContext.interface(), |
(...skipping 29 matching lines...) Expand all Loading... |
260 GR_GL_CALL_RET(fContext.interface(), location, | 260 GR_GL_CALL_RET(fContext.interface(), location, |
261 GetUniformLocation(programID, uniforms[i].fVariable.c_str
())); | 261 GetUniformLocation(programID, uniforms[i].fVariable.c_str
())); |
262 if (GrGLShaderBuilder::kVertex_ShaderType & uniforms[i].fVisibility) { | 262 if (GrGLShaderBuilder::kVertex_ShaderType & uniforms[i].fVisibility) { |
263 fUniforms[i].fVSLocation = location; | 263 fUniforms[i].fVSLocation = location; |
264 } | 264 } |
265 if (GrGLShaderBuilder::kFragment_ShaderType & uniforms[i].fVisibility) { | 265 if (GrGLShaderBuilder::kFragment_ShaderType & uniforms[i].fVisibility) { |
266 fUniforms[i].fFSLocation = location; | 266 fUniforms[i].fFSLocation = location; |
267 } | 267 } |
268 } | 268 } |
269 } | 269 } |
| 270 |
| 271 const GrGLUniformManager::BuilderUniform& |
| 272 GrGLUniformManager::getBuilderUniform(const BuilderUniformArray& array, UniformH
andle handle) const { |
| 273 return array[handle.toUniformIndex()]; |
| 274 } |
OLD | NEW |