blob: 6a34981174d60a4da0b75634d49bccc01ae1be49 [file] [log] [blame]
Mathias Agopian3f844832013-08-07 21:24:32 -07001/*
2 * Copyright 2013 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <GLES2/gl2.h>
18#include <GLES2/gl2ext.h>
19
20#include <utils/String8.h>
21
Mathias Agopian3f844832013-08-07 21:24:32 -070022#include "Description.h"
Chia-I Wub027f802017-11-29 14:00:52 -080023#include "Program.h"
24#include "ProgramCache.h"
Mathias Agopian3f844832013-08-07 21:24:32 -070025
26namespace android {
27// -----------------------------------------------------------------------------------------------
28
Mathias Agopian3f844832013-08-07 21:24:32 -070029/*
30 * A simple formatter class to automatically add the endl and
31 * manage the indentation.
32 */
33
34class Formatter;
35static Formatter& indent(Formatter& f);
36static Formatter& dedent(Formatter& f);
37
38class Formatter {
39 String8 mString;
40 int mIndent;
41 typedef Formatter& (*FormaterManipFunc)(Formatter&);
42 friend Formatter& indent(Formatter& f);
43 friend Formatter& dedent(Formatter& f);
Chia-I Wub027f802017-11-29 14:00:52 -080044
Mathias Agopian3f844832013-08-07 21:24:32 -070045public:
Andy McFadden892f22d2013-08-15 10:05:01 -070046 Formatter() : mIndent(0) {}
47
Chia-I Wub027f802017-11-29 14:00:52 -080048 String8 getString() const { return mString; }
Mathias Agopian3f844832013-08-07 21:24:32 -070049
Chia-I Wub027f802017-11-29 14:00:52 -080050 friend Formatter& operator<<(Formatter& out, const char* in) {
51 for (int i = 0; i < out.mIndent; i++) {
Mathias Agopian3f844832013-08-07 21:24:32 -070052 out.mString.append(" ");
53 }
54 out.mString.append(in);
55 out.mString.append("\n");
56 return out;
57 }
Chia-I Wub027f802017-11-29 14:00:52 -080058 friend inline Formatter& operator<<(Formatter& out, const String8& in) {
59 return operator<<(out, in.string());
Mathias Agopian3f844832013-08-07 21:24:32 -070060 }
61 friend inline Formatter& operator<<(Formatter& to, FormaterManipFunc func) {
62 return (*func)(to);
63 }
64};
65Formatter& indent(Formatter& f) {
66 f.mIndent++;
67 return f;
68}
69Formatter& dedent(Formatter& f) {
70 f.mIndent--;
71 return f;
72}
73
74// -----------------------------------------------------------------------------------------------
75
76ANDROID_SINGLETON_STATIC_INSTANCE(ProgramCache)
77
Mathias Agopian3f844832013-08-07 21:24:32 -070078ProgramCache::ProgramCache() {
Riley Andrewsa51fafc2014-09-29 13:29:40 -070079 // Until surfaceflinger has a dependable blob cache on the filesystem,
80 // generate shaders on initialization so as to avoid jank.
81 primeCache();
Mathias Agopian3f844832013-08-07 21:24:32 -070082}
83
Chia-I Wub027f802017-11-29 14:00:52 -080084ProgramCache::~ProgramCache() {}
Mathias Agopian3f844832013-08-07 21:24:32 -070085
Riley Andrewsa51fafc2014-09-29 13:29:40 -070086void ProgramCache::primeCache() {
87 uint32_t shaderCount = 0;
Chia-I Wub027f802017-11-29 14:00:52 -080088 uint32_t keyMask = Key::BLEND_MASK | Key::OPACITY_MASK | Key::ALPHA_MASK | Key::TEXTURE_MASK;
Riley Andrewsa51fafc2014-09-29 13:29:40 -070089 // Prime the cache for all combinations of the above masks,
90 // leaving off the experimental color matrix mask options.
91
92 nsecs_t timeBefore = systemTime();
93 for (uint32_t keyVal = 0; keyVal <= keyMask; keyVal++) {
94 Key shaderKey;
95 shaderKey.set(keyMask, keyVal);
96 uint32_t tex = shaderKey.getTextureTarget();
Chia-I Wub027f802017-11-29 14:00:52 -080097 if (tex != Key::TEXTURE_OFF && tex != Key::TEXTURE_EXT && tex != Key::TEXTURE_2D) {
Riley Andrewsa51fafc2014-09-29 13:29:40 -070098 continue;
99 }
100 Program* program = mCache.valueFor(shaderKey);
Peiyong Lin566a3b42018-01-09 18:22:43 -0800101 if (program == nullptr) {
Riley Andrewsa51fafc2014-09-29 13:29:40 -0700102 program = generateProgram(shaderKey);
103 mCache.add(shaderKey, program);
104 shaderCount++;
105 }
106 }
107 nsecs_t timeAfter = systemTime();
108 float compileTimeMs = static_cast<float>(timeAfter - timeBefore) / 1.0E6;
109 ALOGD("shader cache generated - %u shaders in %f ms\n", shaderCount, compileTimeMs);
110}
111
Mathias Agopian3f844832013-08-07 21:24:32 -0700112ProgramCache::Key ProgramCache::computeKey(const Description& description) {
113 Key needs;
114 needs.set(Key::TEXTURE_MASK,
Chia-I Wub027f802017-11-29 14:00:52 -0800115 !description.mTextureEnabled
116 ? Key::TEXTURE_OFF
117 : description.mTexture.getTextureTarget() == GL_TEXTURE_EXTERNAL_OES
118 ? Key::TEXTURE_EXT
119 : description.mTexture.getTextureTarget() == GL_TEXTURE_2D
120 ? Key::TEXTURE_2D
121 : Key::TEXTURE_OFF)
122 .set(Key::ALPHA_MASK,
123 (description.mColor.a < 1) ? Key::ALPHA_LT_ONE : Key::ALPHA_EQ_ONE)
124 .set(Key::BLEND_MASK,
125 description.mPremultipliedAlpha ? Key::BLEND_PREMULT : Key::BLEND_NORMAL)
126 .set(Key::OPACITY_MASK,
127 description.mOpaque ? Key::OPACITY_OPAQUE : Key::OPACITY_TRANSLUCENT)
128 .set(Key::COLOR_MATRIX_MASK,
Chia-I Wu7e65bc02018-01-11 14:31:38 -0800129 description.mColorMatrixEnabled ? Key::COLOR_MATRIX_ON : Key::COLOR_MATRIX_OFF);
130
Chia-I Wu131d3762018-01-11 14:35:27 -0800131 needs.set(Key::Y410_BT2020_MASK,
132 description.mY410BT2020 ? Key::Y410_BT2020_ON : Key::Y410_BT2020_OFF);
133
Chia-I Wu7e65bc02018-01-11 14:31:38 -0800134 if (needs.hasColorMatrix()) {
135 switch (description.mInputTransferFunction) {
136 case Description::TransferFunction::LINEAR:
137 default:
138 needs.set(Key::INPUT_TF_MASK, Key::INPUT_TF_LINEAR);
139 break;
140 case Description::TransferFunction::SRGB:
141 needs.set(Key::INPUT_TF_MASK, Key::INPUT_TF_SRGB);
142 break;
Chia-I Wu131d3762018-01-11 14:35:27 -0800143 case Description::TransferFunction::ST2084:
144 needs.set(Key::INPUT_TF_MASK, Key::INPUT_TF_ST2084);
145 break;
Chia-I Wu7e65bc02018-01-11 14:31:38 -0800146 }
147
148 switch (description.mOutputTransferFunction) {
149 case Description::TransferFunction::LINEAR:
150 default:
151 needs.set(Key::OUTPUT_TF_MASK, Key::OUTPUT_TF_LINEAR);
152 break;
153 case Description::TransferFunction::SRGB:
154 needs.set(Key::OUTPUT_TF_MASK, Key::OUTPUT_TF_SRGB);
155 break;
Chia-I Wu131d3762018-01-11 14:35:27 -0800156 case Description::TransferFunction::ST2084:
157 needs.set(Key::OUTPUT_TF_MASK, Key::OUTPUT_TF_ST2084);
158 break;
Chia-I Wu7e65bc02018-01-11 14:31:38 -0800159 }
Chia-I Wu131d3762018-01-11 14:35:27 -0800160
161 needs.set(Key::TONE_MAPPING_MASK,
162 description.mToneMappingEnabled ? Key::TONE_MAPPING_ON : Key::TONE_MAPPING_OFF);
Chia-I Wu7e65bc02018-01-11 14:31:38 -0800163 }
164
Mathias Agopian3f844832013-08-07 21:24:32 -0700165 return needs;
166}
167
168String8 ProgramCache::generateVertexShader(const Key& needs) {
169 Formatter vs;
170 if (needs.isTexturing()) {
Chia-I Wub027f802017-11-29 14:00:52 -0800171 vs << "attribute vec4 texCoords;"
172 << "varying vec2 outTexCoords;";
Mathias Agopian3f844832013-08-07 21:24:32 -0700173 }
174 vs << "attribute vec4 position;"
175 << "uniform mat4 projection;"
176 << "uniform mat4 texture;"
Chia-I Wub027f802017-11-29 14:00:52 -0800177 << "void main(void) {" << indent << "gl_Position = projection * position;";
Mathias Agopian3f844832013-08-07 21:24:32 -0700178 if (needs.isTexturing()) {
179 vs << "outTexCoords = (texture * texCoords).st;";
180 }
181 vs << dedent << "}";
182 return vs.getString();
183}
184
185String8 ProgramCache::generateFragmentShader(const Key& needs) {
186 Formatter fs;
187 if (needs.getTextureTarget() == Key::TEXTURE_EXT) {
188 fs << "#extension GL_OES_EGL_image_external : require";
189 }
Mathias Agopian458197d2013-08-15 14:56:51 -0700190
191 // default precision is required-ish in fragment shaders
192 fs << "precision mediump float;";
193
Mathias Agopian3f844832013-08-07 21:24:32 -0700194 if (needs.getTextureTarget() == Key::TEXTURE_EXT) {
195 fs << "uniform samplerExternalOES sampler;"
196 << "varying vec2 outTexCoords;";
197 } else if (needs.getTextureTarget() == Key::TEXTURE_2D) {
198 fs << "uniform sampler2D sampler;"
199 << "varying vec2 outTexCoords;";
chaviw13fdc492017-06-27 12:40:18 -0700200 }
201
202 if (needs.getTextureTarget() == Key::TEXTURE_OFF || needs.hasAlpha()) {
Mathias Agopian3f844832013-08-07 21:24:32 -0700203 fs << "uniform vec4 color;";
204 }
chaviw13fdc492017-06-27 12:40:18 -0700205
Chia-I Wu131d3762018-01-11 14:35:27 -0800206 if (needs.isY410BT2020()) {
207 fs << R"__SHADER__(
208 vec3 convertY410BT2020(const vec3 color) {
209 const vec3 offset = vec3(0.0625, 0.5, 0.5);
210 const mat3 transform = mat3(
211 vec3(1.1678, 1.1678, 1.1678),
212 vec3( 0.0, -0.1878, 2.1481),
213 vec3(1.6836, -0.6523, 0.0));
214 // Y is in G, U is in R, and V is in B
215 return clamp(transform * (color.grb - offset), 0.0, 1.0);
216 }
217 )__SHADER__";
218 }
219
Mathias Agopianff2ed702013-09-01 21:36:12 -0700220 if (needs.hasColorMatrix()) {
221 fs << "uniform mat4 colorMatrix;";
Romain Guy88d37dd2017-05-26 17:57:05 -0700222
Chia-I Wu7e65bc02018-01-11 14:31:38 -0800223 switch (needs.getInputTF()) {
224 case Key::INPUT_TF_LINEAR:
225 default:
226 fs << R"__SHADER__(
227 vec3 EOTF(const vec3 linear) {
228 return linear;
229 }
230 )__SHADER__";
231 break;
232 case Key::INPUT_TF_SRGB:
233 fs << R"__SHADER__(
234 float EOTF_sRGB(float srgb) {
235 return srgb <= 0.04045 ? srgb / 12.92 : pow((srgb + 0.055) / 1.055, 2.4);
236 }
Romain Guy88d37dd2017-05-26 17:57:05 -0700237
Chia-I Wu7e65bc02018-01-11 14:31:38 -0800238 vec3 EOTF_sRGB(const vec3 srgb) {
239 return vec3(EOTF_sRGB(srgb.r), EOTF_sRGB(srgb.g), EOTF_sRGB(srgb.b));
240 }
Romain Guy88d37dd2017-05-26 17:57:05 -0700241
Chia-I Wu7e65bc02018-01-11 14:31:38 -0800242 vec3 EOTF(const vec3 srgb) {
243 return sign(srgb.rgb) * EOTF_sRGB(abs(srgb.rgb));
244 }
245 )__SHADER__";
246 break;
Chia-I Wu131d3762018-01-11 14:35:27 -0800247 case Key::INPUT_TF_ST2084:
248 fs << R"__SHADER__(
249 vec3 EOTF(const highp vec3 color) {
250 const highp float m1 = (2610.0 / 4096.0) / 4.0;
251 const highp float m2 = (2523.0 / 4096.0) * 128.0;
252 const highp float c1 = (3424.0 / 4096.0);
253 const highp float c2 = (2413.0 / 4096.0) * 32.0;
254 const highp float c3 = (2392.0 / 4096.0) * 32.0;
255
256 highp vec3 tmp = pow(color, 1.0 / vec3(m2));
257 tmp = max(tmp - c1, 0.0) / (c2 - c3 * tmp);
258 return pow(tmp, 1.0 / vec3(m1));
259 }
260 )__SHADER__";
261 break;
Chia-I Wu7e65bc02018-01-11 14:31:38 -0800262 }
Romain Guy88d37dd2017-05-26 17:57:05 -0700263
Chia-I Wu7e65bc02018-01-11 14:31:38 -0800264 switch (needs.getOutputTF()) {
265 case Key::OUTPUT_TF_LINEAR:
266 default:
267 fs << R"__SHADER__(
268 vec3 OETF(const vec3 linear) {
269 return linear;
270 }
271 )__SHADER__";
272 break;
273 case Key::OUTPUT_TF_SRGB:
274 fs << R"__SHADER__(
275 float OETF_sRGB(const float linear) {
276 return linear <= 0.0031308 ?
277 linear * 12.92 : (pow(linear, 1.0 / 2.4) * 1.055) - 0.055;
278 }
Romain Guy88d37dd2017-05-26 17:57:05 -0700279
Chia-I Wu7e65bc02018-01-11 14:31:38 -0800280 vec3 OETF_sRGB(const vec3 linear) {
281 return vec3(OETF_sRGB(linear.r), OETF_sRGB(linear.g), OETF_sRGB(linear.b));
282 }
Romain Guy88d37dd2017-05-26 17:57:05 -0700283
Chia-I Wu7e65bc02018-01-11 14:31:38 -0800284 vec3 OETF(const vec3 linear) {
285 return sign(linear.rgb) * OETF_sRGB(abs(linear.rgb));
286 }
287 )__SHADER__";
288 break;
Chia-I Wu131d3762018-01-11 14:35:27 -0800289 case Key::OUTPUT_TF_ST2084:
290 fs << R"__SHADER__(
291 vec3 OETF(const vec3 linear) {
292 const float m1 = (2610.0 / 4096.0) / 4.0;
293 const float m2 = (2523.0 / 4096.0) * 128.0;
294 const float c1 = (3424.0 / 4096.0);
295 const float c2 = (2413.0 / 4096.0) * 32.0;
296 const float c3 = (2392.0 / 4096.0) * 32.0;
297
298 vec3 tmp = pow(linear, vec3(m1));
299 tmp = (c1 + c2 * tmp) / (1.0 + c3 * tmp);
300 return pow(tmp, vec3(m2));
301 }
302 )__SHADER__";
303 break;
304 }
305
306 if (needs.hasToneMapping()) {
307 fs << R"__SHADER__(
Peiyong Lin7c4d1282018-03-21 19:14:35 -0700308 float CalculateY(const vec3 color) {
309 // BT2020 standard uses the unadjusted KR = 0.2627,
310 // KB = 0.0593 luminance interpretation for RGB conversion.
311 return color.r * 0.262700 + color.g * 0.677998 +
312 color.b * 0.059302;
313 }
314 vec3 ToneMap(const vec3 color) {
Chia-I Wu131d3762018-01-11 14:35:27 -0800315 const float maxLumi = 10000.0;
316 const float maxMasteringLumi = 1000.0;
317 const float maxContentLumi = 1000.0;
318 const float maxInLumi = min(maxMasteringLumi, maxContentLumi);
319 const float maxOutLumi = 500.0;
320
Peiyong Lin7c4d1282018-03-21 19:14:35 -0700321 // Calculate Y value in XYZ color space.
322 float colorY = CalculateY(color);
323
Chia-I Wu131d3762018-01-11 14:35:27 -0800324 // convert to nits first
Peiyong Lin7c4d1282018-03-21 19:14:35 -0700325 float nits = colorY * maxLumi;
Chia-I Wu131d3762018-01-11 14:35:27 -0800326
327 // clamp to max input luminance
328 nits = clamp(nits, 0.0, maxInLumi);
329
330 // scale [0.0, maxInLumi] to [0.0, maxOutLumi]
331 if (maxInLumi <= maxOutLumi) {
332 nits *= maxOutLumi / maxInLumi;
333 } else {
334 // three control points
335 const float x0 = 10.0;
336 const float y0 = 17.0;
337 const float x1 = maxOutLumi * 0.75;
338 const float y1 = x1;
339 const float x2 = x1 + (maxInLumi - x1) / 2.0;
340 const float y2 = y1 + (maxOutLumi - y1) * 0.75;
341
342 // horizontal distances between the last three control points
343 const float h12 = x2 - x1;
344 const float h23 = maxInLumi - x2;
345 // tangents at the last three control points
346 const float m1 = (y2 - y1) / h12;
347 const float m3 = (maxOutLumi - y2) / h23;
348 const float m2 = (m1 + m3) / 2.0;
349
350 if (nits < x0) {
351 // scale [0.0, x0] to [0.0, y0] linearly
352 const float slope = y0 / x0;
353 nits *= slope;
354 } else if (nits < x1) {
355 // scale [x0, x1] to [y0, y1] linearly
356 const float slope = (y1 - y0) / (x1 - x0);
357 nits = y0 + (nits - x0) * slope;
358 } else if (nits < x2) {
359 // scale [x1, x2] to [y1, y2] using Hermite interp
360 float t = (nits - x1) / h12;
361 nits = (y1 * (1.0 + 2.0 * t) + h12 * m1 * t) * (1.0 - t) * (1.0 - t) +
362 (y2 * (3.0 - 2.0 * t) + h12 * m2 * (t - 1.0)) * t * t;
363 } else {
364 // scale [x2, maxInLumi] to [y2, maxOutLumi] using Hermite interp
365 float t = (nits - x2) / h23;
366 nits = (y2 * (1.0 + 2.0 * t) + h23 * m2 * t) * (1.0 - t) * (1.0 - t) +
367 (maxOutLumi * (3.0 - 2.0 * t) + h23 * m3 * (t - 1.0)) * t * t;
368 }
369 }
370
371 // convert back to [0.0, 1.0]
Peiyong Lin7c4d1282018-03-21 19:14:35 -0700372 float targetY = nits / maxOutLumi;
373 return color * (targetY / max(1e-6, colorY));
Chia-I Wu131d3762018-01-11 14:35:27 -0800374 }
375 )__SHADER__";
376 } else {
377 fs << R"__SHADER__(
378 vec3 ToneMap(const vec3 color) {
379 return color;
380 }
381 )__SHADER__";
Romain Guy88d37dd2017-05-26 17:57:05 -0700382 }
383 }
Chia-I Wu7e65bc02018-01-11 14:31:38 -0800384
Mathias Agopian3f844832013-08-07 21:24:32 -0700385 fs << "void main(void) {" << indent;
386 if (needs.isTexturing()) {
387 fs << "gl_FragColor = texture2D(sampler, outTexCoords);";
Chia-I Wu131d3762018-01-11 14:35:27 -0800388 if (needs.isY410BT2020()) {
389 fs << "gl_FragColor.rgb = convertY410BT2020(gl_FragColor.rgb);";
390 }
Mathias Agopian3f844832013-08-07 21:24:32 -0700391 } else {
chaviw13fdc492017-06-27 12:40:18 -0700392 fs << "gl_FragColor.rgb = color.rgb;";
393 fs << "gl_FragColor.a = 1.0;";
Mathias Agopian3f844832013-08-07 21:24:32 -0700394 }
Mathias Agopian2eaefe12013-08-14 16:33:27 -0700395 if (needs.isOpaque()) {
396 fs << "gl_FragColor.a = 1.0;";
397 }
chaviw13fdc492017-06-27 12:40:18 -0700398 if (needs.hasAlpha()) {
399 // modulate the current alpha value with alpha set
Mathias Agopian3f844832013-08-07 21:24:32 -0700400 if (needs.isPremultiplied()) {
401 // ... and the color too if we're premultiplied
chaviw13fdc492017-06-27 12:40:18 -0700402 fs << "gl_FragColor *= color.a;";
Mathias Agopian3f844832013-08-07 21:24:32 -0700403 } else {
chaviw13fdc492017-06-27 12:40:18 -0700404 fs << "gl_FragColor.a *= color.a;";
Mathias Agopian3f844832013-08-07 21:24:32 -0700405 }
406 }
Mathias Agopianff2ed702013-09-01 21:36:12 -0700407
408 if (needs.hasColorMatrix()) {
409 if (!needs.isOpaque() && needs.isPremultiplied()) {
410 // un-premultiply if needed before linearization
Romain Guy88d37dd2017-05-26 17:57:05 -0700411 // avoid divide by 0 by adding 0.5/256 to the alpha channel
412 fs << "gl_FragColor.rgb = gl_FragColor.rgb / (gl_FragColor.a + 0.0019);";
Mathias Agopianff2ed702013-09-01 21:36:12 -0700413 }
Chia-I Wu131d3762018-01-11 14:35:27 -0800414 fs << "vec4 transformed = colorMatrix * vec4(ToneMap(EOTF(gl_FragColor.rgb)), 1);";
415 // the transformation from a wider colorspace to a narrower one can
416 // result in >1.0 or <0.0 pixel values
417 fs << "transformed.rgb = clamp(transformed.rgb, 0.0, 1.0);";
Romain Guy88d37dd2017-05-26 17:57:05 -0700418 // We assume the last row is always {0,0,0,1} and we skip the division by w
Chia-I Wu7e65bc02018-01-11 14:31:38 -0800419 fs << "gl_FragColor.rgb = OETF(transformed.rgb);";
Mathias Agopianff2ed702013-09-01 21:36:12 -0700420 if (!needs.isOpaque() && needs.isPremultiplied()) {
421 // and re-premultiply if needed after gamma correction
Romain Guy88d37dd2017-05-26 17:57:05 -0700422 fs << "gl_FragColor.rgb = gl_FragColor.rgb * (gl_FragColor.a + 0.0019);";
Mathias Agopianff2ed702013-09-01 21:36:12 -0700423 }
424 }
425
Mathias Agopian3f844832013-08-07 21:24:32 -0700426 fs << dedent << "}";
427 return fs.getString();
428}
429
430Program* ProgramCache::generateProgram(const Key& needs) {
431 // vertex shader
432 String8 vs = generateVertexShader(needs);
433
434 // fragment shader
435 String8 fs = generateFragmentShader(needs);
436
437 Program* program = new Program(needs, vs.string(), fs.string());
438 return program;
439}
440
441void ProgramCache::useProgram(const Description& description) {
Mathias Agopian3f844832013-08-07 21:24:32 -0700442 // generate the key for the shader based on the description
443 Key needs(computeKey(description));
444
Chia-I Wub027f802017-11-29 14:00:52 -0800445 // look-up the program in the cache
Mathias Agopian3f844832013-08-07 21:24:32 -0700446 Program* program = mCache.valueFor(needs);
Peiyong Lin566a3b42018-01-09 18:22:43 -0800447 if (program == nullptr) {
Mathias Agopian3f844832013-08-07 21:24:32 -0700448 // we didn't find our program, so generate one...
449 nsecs_t time = -systemTime();
450 program = generateProgram(needs);
451 mCache.add(needs, program);
452 time += systemTime();
453
Chia-I Wub027f802017-11-29 14:00:52 -0800454 // ALOGD(">>> generated new program: needs=%08X, time=%u ms (%d programs)",
Mathias Agopian3f844832013-08-07 21:24:32 -0700455 // needs.mNeeds, uint32_t(ns2ms(time)), mCache.size());
456 }
457
458 // here we have a suitable program for this description
459 if (program->isValid()) {
460 program->use();
461 program->setUniforms(description);
462 }
463}
464
Mathias Agopian3f844832013-08-07 21:24:32 -0700465} /* namespace android */