1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES Utilities
3 * ------------------------------------------------
5 * Copyright 2014 The Android Open Source Project
7 * Licensed under the Apache License, Version 2.0 (the 'License');
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an 'AS IS' BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 goog.provide('functional.gles3.es3fShaderStructTests');
23 goog.require('framework.common.tcuTestCase');
24 goog.require('framework.common.tcuTexture');
25 goog.require('framework.common.tcuTextureUtil');
26 goog.require('framework.delibs.debase.deMath');
27 // goog.require('framework.opengl.gluShaderUtil');
28 goog.require('framework.opengl.gluTexture');
29 goog.require('modules.shared.glsShaderRenderCase');
30 goog.require('framework.common.tcuStringTemplate');
32 goog.scope(function() {
33 var es3fShaderStructTests = functional.gles3.es3fShaderStructTests;
34 var tcuTestCase = framework.common.tcuTestCase;
35 var tcuTexture = framework.common.tcuTexture;
36 var tcuTextureUtil = framework.common.tcuTextureUtil;
37 var deMath = framework.delibs.debase.deMath;
38 // var gluShaderUtil = framework.opengl.gluShaderUtil;
39 var glsShaderRenderCase = modules.shared.glsShaderRenderCase;
40 var gluTexture = framework.opengl.gluTexture;
41 var tcuStringTemplate = framework.common.tcuStringTemplate;
43 /** @typedef {function(WebGLProgram, Array<number>)} */
44 es3fShaderStructTests.SetupUniformsFunc;
46 /** @const {number} */ es3fShaderStructTests.TEXTURE_BRICK = 0;
51 * @extends {glsShaderRenderCase.ShaderRenderCase}
52 * @param {string} name
53 * @param {string} description
54 * @param {boolean} isVertexCase
55 * @param {boolean} usesTextures
56 * @param {glsShaderRenderCase.ShaderEvalFunc} evalFunc
57 * @param {?es3fShaderStructTests.SetupUniformsFunc} setupUniformsFunc
58 * @param {string} vertShaderSource
59 * @param {string} fragShaderSource
61 es3fShaderStructTests.ShaderStructCase = function(name, description, isVertexCase, usesTextures, evalFunc, setupUniformsFunc, vertShaderSource, fragShaderSource) {
62 glsShaderRenderCase.ShaderRenderCase.call(this, name, description, isVertexCase, evalFunc);
63 /** @type {?es3fShaderStructTests.SetupUniformsFunc} */ this.m_setupUniforms = setupUniformsFunc;
64 /** @type {boolean} */ this.m_usesTexture = usesTextures;
65 /** @type {gluTexture.Texture2D} */ this.m_brickTexture = null;
66 /** @type {string} */ this.m_vertShaderSource = vertShaderSource;
67 /** @type {string} */ this.m_fragShaderSource = fragShaderSource;
70 es3fShaderStructTests.ShaderStructCase.prototype = Object.create(glsShaderRenderCase.ShaderRenderCase.prototype);
71 es3fShaderStructTests.ShaderStructCase.prototype.constructor = es3fShaderStructTests.ShaderStructCase;
73 es3fShaderStructTests.ShaderStructCase.prototype.init = function() {
74 if (this.m_usesTexture) {
75 this.m_brickTexture = gluTexture.texture2DFromInternalFormat(gl, gl.RGBA8, 256, 256);
76 var ref = this.m_brickTexture.getRefTexture();
77 for (var i = 0 ; i < ref.getNumLevels(); i++) {
79 tcuTextureUtil.fillWithGrid(ref.getLevel(i), 8, [0.2, 0.7, 0.1, 1.0], [0.7, 0.1, 0.5, 0.8]);
81 this.m_brickTexture.upload();
83 this.m_textures.push(new glsShaderRenderCase.TextureBinding(
85 new tcuTexture.Sampler(
86 tcuTexture.WrapMode.CLAMP_TO_EDGE,
87 tcuTexture.WrapMode.CLAMP_TO_EDGE,
88 tcuTexture.WrapMode.CLAMP_TO_EDGE,
89 tcuTexture.FilterMode.LINEAR,
90 tcuTexture.FilterMode.LINEAR)));
92 assertMsgOptions(this.m_textures.length === 1, 'Only one texture required', false, true);
97 es3fShaderStructTests.ShaderStructCase.prototype.deinit = function() {
98 glsShaderRenderCase.ShaderRenderCase.prototype.deinit.call(this);
99 this.m_brickTexture = null;
103 * @param {WebGLProgram} programID
104 * @param {Array<number>} constCoords
106 es3fShaderStructTests.ShaderStructCase.prototype.setupUniforms = function(programID, constCoords) {
107 glsShaderRenderCase.ShaderRenderCase.prototype.setupUniforms.call(this, programID, constCoords);
108 if (this.m_setupUniforms)
109 this.m_setupUniforms(programID, constCoords);
113 * @param {string} name
114 * @param {string} description
115 * @param {boolean} isVertexCase
116 * @param {boolean} usesTextures
117 * @param {glsShaderRenderCase.ShaderEvalFunc} evalFunc
118 * @param {?es3fShaderStructTests.SetupUniformsFunc} setupUniforms
119 * @param {string} shaderSrc
121 es3fShaderStructTests.ShaderStructCase.createStructCase = function(name, description, isVertexCase, usesTextures, evalFunc, setupUniforms, shaderSrc) {
122 /** @type {string} */ var defaultVertSrc =
123 '#version 300 es\n' +
124 'in highp vec4 a_position;\n' +
125 'in highp vec4 a_coords;\n' +
126 'out mediump vec4 v_coords;\n\n' +
127 'void main (void)\n' +
129 ' v_coords = a_coords;\n' +
130 ' gl_Position = a_position;\n' +
132 /** @type {string} */ var defaultFragSrc =
133 '#version 300 es\n' +
134 'in mediump vec4 v_color;\n' +
135 'layout(location = 0) out mediump vec4 o_color;\n\n' +
136 'void main (void)\n' +
138 ' o_color = v_color;\n' +
141 // Fill in specialization parameters.
145 "#version 300 es\n" +
146 "in highp vec4 a_position;\n" +
147 "in highp vec4 a_coords;\n" +
148 "out mediump vec4 v_color;";
149 spParams["COORDS"] = "a_coords";
150 spParams["DST"] = "v_color";
151 spParams["ASSIGN_POS"] = "gl_Position = a_position;";
155 "#version 300 es\n" +
156 "in mediump vec4 v_coords;\n" +
157 "layout(location = 0) out mediump vec4 o_color;";
158 spParams["COORDS"] = "v_coords";
159 spParams["DST"] = "o_color";
160 spParams["ASSIGN_POS"] = "";
164 return new es3fShaderStructTests.ShaderStructCase(name, description, isVertexCase, usesTextures, evalFunc, setupUniforms, tcuStringTemplate.specialize(shaderSrc, spParams), defaultFragSrc);
166 return new es3fShaderStructTests.ShaderStructCase(name, description, isVertexCase, usesTextures, evalFunc, setupUniforms, defaultVertSrc, tcuStringTemplate.specialize(shaderSrc, spParams));
171 * @extends {tcuTestCase.DeqpTest}
173 es3fShaderStructTests.LocalStructTests = function() {
174 tcuTestCase.DeqpTest.call(this, 'local', 'Local structs');
175 this.makeExecutable();
178 es3fShaderStructTests.LocalStructTests.prototype = Object.create(tcuTestCase.DeqpTest.prototype);
179 es3fShaderStructTests.LocalStructTests.prototype.constructor = es3fShaderStructTests.LocalStructTests;
181 es3fShaderStructTests.LocalStructTests.prototype.init = function() {
182 var currentCtx = this;
183 function LocalStructCase(name, description, shaderSource, evalFunction) {
184 currentCtx.addChild(es3fShaderStructTests.ShaderStructCase.createStructCase(name + "_vertex", description, true, false, evalFunction, null, shaderSource));
185 currentCtx.addChild(es3fShaderStructTests.ShaderStructCase.createStructCase(name + "_fragment", description, false, false, evalFunction, null, shaderSource));
188 LocalStructCase('basic', 'Basic struct usage',
190 'uniform int ui_one;\n' +
193 ' mediump float a;\n' +
194 ' mediump vec3 b;\n' +
198 'void main (void)\n' +
200 ' S s = S(${COORDS}.x, vec3(0.0), ui_one);\n' +
201 ' s.b = ${COORDS}.yzw;\n' +
202 ' ${DST} = vec4(s.a, s.b.x, s.b.y, s.c);\n' +
206 c.color[0] = c.coords[0];
207 c.color[1] = c.coords[1];
208 c.color[2] = c.coords[2];
211 LocalStructCase('nested', "Nested struct",
213 "uniform int ui_zero;\n" +
214 "uniform int ui_one;\n" +
218 " mediump vec2 b;\n" +
221 ' mediump float a;\n' +
226 'void main (void)\n' +
228 ' S s = S(${COORDS}.x, T(0, vec2(0.0)), ui_one);\n' +
229 ' s.b = T(ui_zero, ${COORDS}.yz);\n' +
230 ' ${DST} = vec4(s.a, s.b.b, s.b.a + s.c);\n' +
234 c.color[0] = c.coords[0];
235 c.color[1] = c.coords[1];
236 c.color[2] = c.coords[2];
239 LocalStructCase('array_member', "Struct with array member",
241 'uniform int ui_one;\n' +
244 ' mediump float a;\n' +
245 ' mediump float b[3];\n' +
249 'void main (void)\n' +
252 ' s.a = ${COORDS}.w;\n' +
254 ' s.b[0] = ${COORDS}.z;\n' +
255 ' s.b[1] = ${COORDS}.y;\n' +
256 ' s.b[2] = ${COORDS}.x;\n' +
257 ' ${DST} = vec4(s.a, s.b[0], s.b[1], s.c);\n' +
261 c.color[0] = c.coords[3];
262 c.color[1] = c.coords[2];
263 c.color[2] = c.coords[1];
266 LocalStructCase('array_member_dynamic_index', "Struct with array member, dynamic indexing",
268 'uniform int ui_zero;\n' +
269 'uniform int ui_one;\n' +
270 'uniform int ui_two;\n' +
273 ' mediump float a;\n' +
274 ' mediump float b[3];\n' +
278 'void main (void)\n' +
281 ' s.a = ${COORDS}.w;\n' +
283 ' s.b[0] = ${COORDS}.z;\n' +
284 ' s.b[1] = ${COORDS}.y;\n' +
285 ' s.b[2] = ${COORDS}.x;\n' +
286 ' ${DST} = vec4(s.b[ui_one], s.b[ui_zero], s.b[ui_two], s.c);\n' +
290 c.color[0] = c.coords[1];
291 c.color[1] = c.coords[2];
292 c.color[2] = c.coords[0];
295 LocalStructCase('struct_array', "Struct array",
297 'uniform int ui_zero;\n' +
298 'uniform int ui_one;\n' +
299 'uniform int ui_two;\n' +
302 ' mediump float a;\n' +
303 ' mediump int b;\n' +
306 'void main (void)\n' +
309 ' s[0] = S(${COORDS}.x, ui_zero);\n' +
310 ' s[1].a = ${COORDS}.y;\n' +
311 ' s[1].b = ui_one;\n' +
312 ' s[2] = S(${COORDS}.z, ui_two);\n' +
313 ' ${DST} = vec4(s[2].a, s[1].a, s[0].a, s[2].b - s[1].b + s[0].b);\n' +
317 c.color[0] = c.coords[2];
318 c.color[1] = c.coords[1];
319 c.color[2] = c.coords[0];
322 LocalStructCase('struct_array_dynamic_index', "Struct array with dynamic indexing",
324 'uniform int ui_zero;\n' +
325 'uniform int ui_one;\n' +
326 'uniform int ui_two;\n' +
329 ' mediump float a;\n' +
330 ' mediump int b;\n' +
333 'void main (void)\n' +
336 ' s[0] = S(${COORDS}.x, ui_zero);\n' +
337 ' s[1].a = ${COORDS}.y;\n' +
338 ' s[1].b = ui_one;\n' +
339 ' s[2] = S(${COORDS}.z, ui_two);\n' +
340 ' ${DST} = vec4(s[ui_two].a, s[ui_one].a, s[ui_zero].a, s[ui_two].b - s[ui_one].b + s[ui_zero].b);\n' +
344 c.color[0] = c.coords[2];
345 c.color[1] = c.coords[1];
346 c.color[2] = c.coords[0];
349 LocalStructCase('nested_struct_array', "Nested struct array",
351 'uniform int ui_zero;\n' +
352 'uniform int ui_one;\n' +
353 'uniform int ui_two;\n' +
354 'uniform mediump float uf_two;\n' +
355 'uniform mediump float uf_three;\n' +
356 'uniform mediump float uf_four;\n' +
357 'uniform mediump float uf_half;\n' +
358 'uniform mediump float uf_third;\n' +
359 'uniform mediump float uf_fourth;\n' +
362 ' mediump float a;\n' +
363 ' mediump vec2 b[2];\n' +
366 ' mediump float a;\n' +
371 'void main (void)\n' +
376 ' s[0].a = ${COORDS}.x;\n' +
377 ' s[0].b[0].a = uf_half;\n' +
378 ' s[0].b[0].b[0] = ${COORDS}.xy;\n' +
379 ' s[0].b[0].b[1] = ${COORDS}.zw;\n' +
380 ' s[0].b[1].a = uf_third;\n' +
381 ' s[0].b[1].b[0] = ${COORDS}.zw;\n' +
382 ' s[0].b[1].b[1] = ${COORDS}.xy;\n' +
383 ' s[0].b[2].a = uf_fourth;\n' +
384 ' s[0].b[2].b[0] = ${COORDS}.xz;\n' +
385 ' s[0].b[2].b[1] = ${COORDS}.yw;\n' +
386 ' s[0].c = ui_zero;\n' +
389 ' s[1].a = ${COORDS}.w;\n' +
390 ' s[1].b[0].a = uf_two;\n' +
391 ' s[1].b[0].b[0] = ${COORDS}.xx;\n' +
392 ' s[1].b[0].b[1] = ${COORDS}.yy;\n' +
393 ' s[1].b[1].a = uf_three;\n' +
394 ' s[1].b[1].b[0] = ${COORDS}.zz;\n' +
395 ' s[1].b[1].b[1] = ${COORDS}.ww;\n' +
396 ' s[1].b[2].a = uf_four;\n' +
397 ' s[1].b[2].b[0] = ${COORDS}.yx;\n' +
398 ' s[1].b[2].b[1] = ${COORDS}.wz;\n' +
399 ' s[1].c = ui_one;\n' +
401 ' mediump float r = (s[0].b[1].b[0].x + s[1].b[2].b[1].y) * s[0].b[0].a; // (z + z) * 0.5\n' +
402 ' mediump float g = s[1].b[0].b[0].y * s[0].b[2].a * s[1].b[2].a; // x * 0.25 * 4\n' +
403 ' mediump float b = (s[0].b[2].b[1].y + s[0].b[1].b[0].y + s[1].a) * s[0].b[1].a; // (w + w + w) * 0.333\n' +
404 ' mediump float a = float(s[0].c) + s[1].b[2].a - s[1].b[1].a; // 0 + 4.0 - 3.0\n' +
405 ' ${DST} = vec4(r, g, b, a);\n' +
409 c.color[0] = c.coords[2];
410 c.color[1] = c.coords[0];
411 c.color[2] = c.coords[3];
414 LocalStructCase('nested_struct_array_dynamic_index', "Nested struct array with dynamic indexing",
416 'uniform int ui_zero;\n' +
417 'uniform int ui_one;\n' +
418 'uniform int ui_two;\n' +
419 'uniform mediump float uf_two;\n' +
420 'uniform mediump float uf_three;\n' +
421 'uniform mediump float uf_four;\n' +
422 'uniform mediump float uf_half;\n' +
423 'uniform mediump float uf_third;\n' +
424 'uniform mediump float uf_fourth;\n' +
427 ' mediump float a;\n' +
428 ' mediump vec2 b[2];\n' +
431 ' mediump float a;\n' +
436 'void main (void)\n' +
441 ' s[0].a = ${COORDS}.x;\n' +
442 ' s[0].b[0].a = uf_half;\n' +
443 ' s[0].b[0].b[0] = ${COORDS}.xy;\n' +
444 ' s[0].b[0].b[1] = ${COORDS}.zw;\n' +
445 ' s[0].b[1].a = uf_third;\n' +
446 ' s[0].b[1].b[0] = ${COORDS}.zw;\n' +
447 ' s[0].b[1].b[1] = ${COORDS}.xy;\n' +
448 ' s[0].b[2].a = uf_fourth;\n' +
449 ' s[0].b[2].b[0] = ${COORDS}.xz;\n' +
450 ' s[0].b[2].b[1] = ${COORDS}.yw;\n' +
451 ' s[0].c = ui_zero;\n' +
454 ' s[1].a = ${COORDS}.w;\n' +
455 ' s[1].b[0].a = uf_two;\n' +
456 ' s[1].b[0].b[0] = ${COORDS}.xx;\n' +
457 ' s[1].b[0].b[1] = ${COORDS}.yy;\n' +
458 ' s[1].b[1].a = uf_three;\n' +
459 ' s[1].b[1].b[0] = ${COORDS}.zz;\n' +
460 ' s[1].b[1].b[1] = ${COORDS}.ww;\n' +
461 ' s[1].b[2].a = uf_four;\n' +
462 ' s[1].b[2].b[0] = ${COORDS}.yx;\n' +
463 ' s[1].b[2].b[1] = ${COORDS}.wz;\n' +
464 ' s[1].c = ui_one;\n' +
466 ' mediump float r = (s[0].b[ui_one].b[ui_one-1].x + s[ui_one].b[ui_two].b[ui_zero+1].y) * s[0].b[0].a; // (z + z) * 0.5\n' +
467 ' mediump float g = s[ui_two-1].b[ui_two-2].b[ui_zero].y * s[0].b[ui_two].a * s[ui_one].b[2].a; // x * 0.25 * 4\n' +
468 ' mediump float b = (s[ui_zero].b[ui_one+1].b[1].y + s[0].b[ui_one*ui_one].b[0].y + s[ui_one].a) * s[0].b[ui_two-ui_one].a; // (w + w + w) * 0.333\n' +
469 ' mediump float a = float(s[ui_zero].c) + s[ui_one-ui_zero].b[ui_two].a - s[ui_zero+ui_one].b[ui_two-ui_one].a; // 0 + 4.0 - 3.0\n' +
470 ' ${DST} = vec4(r, g, b, a);\n' +
474 c.color[0] = c.coords[2];
475 c.color[1] = c.coords[0];
476 c.color[2] = c.coords[3];
479 LocalStructCase('parameter', "Struct as a function parameter",
481 'uniform int ui_one;\n' +
484 ' mediump float a;\n' +
485 ' mediump vec3 b;\n' +
489 'mediump vec4 myFunc (S s)\n' +
491 ' return vec4(s.a, s.b.x, s.b.y, s.c);\n' +
494 'void main (void)\n' +
496 ' S s = S(${COORDS}.x, vec3(0.0), ui_one);\n' +
497 ' s.b = ${COORDS}.yzw;\n' +
498 ' ${DST} = myFunc(s);\n' +
502 c.color[0] = c.coords[0];
503 c.color[1] = c.coords[1];
504 c.color[2] = c.coords[2];
507 LocalStructCase('parameter_nested', "Nested struct as a function parameter",
509 'uniform int ui_zero;\n' +
510 'uniform int ui_one;\n' +
514 ' mediump vec2 b;\n' +
517 ' mediump float a;\n' +
522 'mediump vec4 myFunc (S s)\n' +
524 ' return vec4(s.a, s.b.b, s.b.a + s.c);\n' +
527 'void main (void)\n' +
529 ' S s = S(${COORDS}.x, T(0, vec2(0.0)), ui_one);\n' +
530 ' s.b = T(ui_zero, ${COORDS}.yz);\n' +
531 ' ${DST} = myFunc(s);\n' +
535 c.color[0] = c.coords[0];
536 c.color[1] = c.coords[1];
537 c.color[2] = c.coords[2];
540 LocalStructCase('return', "Struct as a return value",
542 'uniform int ui_one;\n' +
545 ' mediump float a;\n' +
546 ' mediump vec3 b;\n' +
550 'S myFunc (void)\n' +
552 ' S s = S(${COORDS}.x, vec3(0.0), ui_one);\n' +
553 ' s.b = ${COORDS}.yzw;\n' +
557 'void main (void)\n' +
559 ' S s = myFunc();\n' +
560 ' ${DST} = vec4(s.a, s.b.x, s.b.y, s.c);\n' +
564 c.color[0] = c.coords[0];
565 c.color[1] = c.coords[1];
566 c.color[2] = c.coords[2];
569 LocalStructCase('return_nested', "Nested struct",
571 'uniform int ui_zero;\n' +
572 'uniform int ui_one;\n' +
576 ' mediump vec2 b;\n' +
579 ' mediump float a;\n' +
584 'S myFunc (void)\n' +
586 ' S s = S(${COORDS}.x, T(0, vec2(0.0)), ui_one);\n' +
587 ' s.b = T(ui_zero, ${COORDS}.yz);\n' +
591 'void main (void)\n' +
593 ' S s = myFunc();\n' +
594 ' ${DST} = vec4(s.a, s.b.b, s.b.a + s.c);\n' +
598 c.color[0] = c.coords[0];
599 c.color[1] = c.coords[1];
600 c.color[2] = c.coords[2];
603 LocalStructCase('conditional_assignment', "Conditional struct assignment",
605 'uniform int ui_zero;\n' +
606 'uniform int ui_one;\n' +
607 'uniform mediump float uf_one;\n' +
610 ' mediump float a;\n' +
611 ' mediump vec3 b;\n' +
615 'void main (void)\n' +
617 ' S s = S(${COORDS}.x, ${COORDS}.yzw, ui_zero);\n' +
618 ' if (uf_one > 0.0)\n' +
619 ' s = S(${COORDS}.w, ${COORDS}.zyx, ui_one);\n' +
620 ' ${DST} = vec4(s.a, s.b.xy, s.c);\n' +
624 c.color[0] = c.coords[3];
625 c.color[1] = c.coords[2];
626 c.color[2] = c.coords[1];
629 LocalStructCase('loop_assignment', "Struct assignment in loop",
631 'uniform int ui_zero;\n' +
632 'uniform int ui_one;\n' +
635 ' mediump float a;\n' +
636 ' mediump vec3 b;\n' +
640 'void main (void)\n' +
642 ' S s = S(${COORDS}.x, ${COORDS}.yzw, ui_zero);\n' +
643 ' for (int i = 0; i < 3; i++)\n' +
646 ' s = S(${COORDS}.w, ${COORDS}.zyx, ui_one);\n' +
648 ' ${DST} = vec4(s.a, s.b.xy, s.c);\n' +
652 c.color[0] = c.coords[3];
653 c.color[1] = c.coords[2];
654 c.color[2] = c.coords[1];
657 LocalStructCase('dynamic_loop_assignment', "Struct assignment in loop",
659 'uniform int ui_zero;\n' +
660 'uniform int ui_one;\n' +
661 'uniform int ui_three;\n' +
664 ' mediump float a;\n' +
665 ' mediump vec3 b;\n' +
669 'void main (void)\n' +
671 ' S s = S(${COORDS}.x, ${COORDS}.yzw, ui_zero);\n' +
672 ' for (int i = 0; i < ui_three; i++)\n' +
674 ' if (i == ui_one)\n' +
675 ' s = S(${COORDS}.w, ${COORDS}.zyx, ui_one);\n' +
677 ' ${DST} = vec4(s.a, s.b.xy, s.c);\n' +
681 c.color[0] = c.coords[3];
682 c.color[1] = c.coords[2];
683 c.color[2] = c.coords[1];
686 LocalStructCase('nested_conditional_assignment', "Conditional assignment of nested struct",
688 'uniform int ui_zero;\n' +
689 'uniform int ui_one;\n' +
690 'uniform mediump float uf_one;\n' +
694 ' mediump vec2 b;\n' +
697 ' mediump float a;\n' +
702 'void main (void)\n' +
704 ' S s = S(${COORDS}.x, T(ui_one, ${COORDS}.yz), ui_one);\n' +
705 ' if (uf_one > 0.0)\n' +
706 ' s.b = T(ui_zero, ${COORDS}.zw);\n' +
707 ' ${DST} = vec4(s.a, s.b.b, s.c - s.b.a);\n' +
711 c.color[0] = c.coords[0];
712 c.color[1] = c.coords[2];
713 c.color[2] = c.coords[3];
716 LocalStructCase('nested_loop_assignment', "Nested struct assignment in loop",
718 'uniform int ui_zero;\n' +
719 'uniform int ui_one;\n' +
720 'uniform mediump float uf_one;\n' +
724 ' mediump vec2 b;\n' +
727 ' mediump float a;\n' +
732 'void main (void)\n' +
734 ' S s = S(${COORDS}.x, T(ui_one, ${COORDS}.yz), ui_one);\n' +
735 ' for (int i = 0; i < 3; i++)\n' +
738 ' s.b = T(ui_zero, ${COORDS}.zw);\n' +
740 ' ${DST} = vec4(s.a, s.b.b, s.c - s.b.a);\n' +
744 c.color[0] = c.coords[0];
745 c.color[1] = c.coords[2];
746 c.color[2] = c.coords[3];
749 LocalStructCase('nested_dynamic_loop_assignment', "Nested struct assignment in dynamic loop",
751 'uniform int ui_zero;\n' +
752 'uniform int ui_one;\n' +
753 'uniform int ui_three;\n' +
754 'uniform mediump float uf_one;\n' +
758 ' mediump vec2 b;\n' +
761 ' mediump float a;\n' +
766 'void main (void)\n' +
768 ' S s = S(${COORDS}.x, T(ui_one, ${COORDS}.yz), ui_one);\n' +
769 ' for (int i = 0; i < ui_three; i++)\n' +
771 ' if (i == ui_one)\n' +
772 ' s.b = T(ui_zero, ${COORDS}.zw);\n' +
774 ' ${DST} = vec4(s.a, s.b.b, s.c - s.b.a);\n' +
778 c.color[0] = c.coords[0];
779 c.color[1] = c.coords[2];
780 c.color[2] = c.coords[3];
783 LocalStructCase('loop_struct_array', "Struct array usage in loop",
785 'uniform int ui_zero;\n' +
786 'uniform int ui_one;\n' +
787 'uniform int ui_two;\n' +
790 ' mediump float a;\n' +
791 ' mediump int b;\n' +
794 'void main (void)\n' +
797 ' s[0] = S(${COORDS}.x, ui_zero);\n' +
798 ' s[1].a = ${COORDS}.y;\n' +
799 ' s[1].b = -ui_one;\n' +
800 ' s[2] = S(${COORDS}.z, ui_two);\n' +
802 ' mediump float rgb[3];\n' +
803 ' int alpha = 0;\n' +
804 ' for (int i = 0; i < 3; i++)\n' +
806 ' rgb[i] = s[2-i].a;\n' +
807 ' alpha += s[i].b;\n' +
809 ' ${DST} = vec4(rgb[0], rgb[1], rgb[2], alpha);\n' +
813 c.color[0] = c.coords[2];
814 c.color[1] = c.coords[1];
815 c.color[2] = c.coords[0];
818 LocalStructCase('loop_nested_struct_array', "Nested struct array usage in loop",
820 'uniform int ui_zero;\n' +
821 'uniform int ui_one;\n' +
822 'uniform int ui_two;\n' +
823 'uniform mediump float uf_two;\n' +
824 'uniform mediump float uf_three;\n' +
825 'uniform mediump float uf_four;\n' +
826 'uniform mediump float uf_half;\n' +
827 'uniform mediump float uf_third;\n' +
828 'uniform mediump float uf_fourth;\n' +
829 'uniform mediump float uf_sixth;\n' +
832 ' mediump float a;\n' +
833 ' mediump vec2 b[2];\n' +
836 ' mediump float a;\n' +
841 'void main (void)\n' +
846 ' s[0].a = ${COORDS}.x;\n' +
847 ' s[0].b[0].a = uf_half;\n' +
848 ' s[0].b[0].b[0] = ${COORDS}.yx;\n' +
849 ' s[0].b[0].b[1] = ${COORDS}.zx;\n' +
850 ' s[0].b[1].a = uf_third;\n' +
851 ' s[0].b[1].b[0] = ${COORDS}.yy;\n' +
852 ' s[0].b[1].b[1] = ${COORDS}.wy;\n' +
853 ' s[0].b[2].a = uf_fourth;\n' +
854 ' s[0].b[2].b[0] = ${COORDS}.zx;\n' +
855 ' s[0].b[2].b[1] = ${COORDS}.zy;\n' +
856 ' s[0].c = ui_zero;\n' +
859 ' s[1].a = ${COORDS}.w;\n' +
860 ' s[1].b[0].a = uf_two;\n' +
861 ' s[1].b[0].b[0] = ${COORDS}.zx;\n' +
862 ' s[1].b[0].b[1] = ${COORDS}.zy;\n' +
863 ' s[1].b[1].a = uf_three;\n' +
864 ' s[1].b[1].b[0] = ${COORDS}.zz;\n' +
865 ' s[1].b[1].b[1] = ${COORDS}.ww;\n' +
866 ' s[1].b[2].a = uf_four;\n' +
867 ' s[1].b[2].b[0] = ${COORDS}.yx;\n' +
868 ' s[1].b[2].b[1] = ${COORDS}.wz;\n' +
869 ' s[1].c = ui_one;\n' +
871 ' mediump float r = 0.0; // (x*3 + y*3) / 6.0\n' +
872 ' mediump float g = 0.0; // (y*3 + z*3) / 6.0\n' +
873 ' mediump float b = 0.0; // (z*3 + w*3) / 6.0\n' +
874 ' mediump float a = 1.0;\n' +
875 ' for (int i = 0; i < 2; i++)\n' +
877 ' for (int j = 0; j < 3; j++)\n' +
879 ' r += s[0].b[j].b[i].y;\n' +
880 ' g += s[i].b[j].b[0].x;\n' +
881 ' b += s[i].b[j].b[1].x;\n' +
882 ' a *= s[i].b[j].a;\n' +
885 ' ${DST} = vec4(r*uf_sixth, g*uf_sixth, b*uf_sixth, a);\n' +
889 c.color[0] = (c.coords[0] + c.coords[1]) * 0.5;
890 c.color[1] = (c.coords[1] + c.coords[2]) * 0.5;
891 c.color[2] = (c.coords[2] + c.coords[3]) * 0.5;
894 LocalStructCase('dynamic_loop_struct_array', "Struct array usage in dynamic loop",
896 'uniform int ui_zero;\n' +
897 'uniform int ui_one;\n' +
898 'uniform int ui_two;\n' +
899 'uniform int ui_three;\n' +
902 ' mediump float a;\n' +
903 ' mediump int b;\n' +
906 'void main (void)\n' +
909 ' s[0] = S(${COORDS}.x, ui_zero);\n' +
910 ' s[1].a = ${COORDS}.y;\n' +
911 ' s[1].b = -ui_one;\n' +
912 ' s[2] = S(${COORDS}.z, ui_two);\n' +
914 ' mediump float rgb[3];\n' +
915 ' int alpha = 0;\n' +
916 ' for (int i = 0; i < ui_three; i++)\n' +
918 ' rgb[i] = s[2-i].a;\n' +
919 ' alpha += s[i].b;\n' +
921 ' ${DST} = vec4(rgb[0], rgb[1], rgb[2], alpha);\n' +
925 c.color[0] = c.coords[2];
926 c.color[1] = c.coords[1];
927 c.color[2] = c.coords[0];
930 LocalStructCase('dynamic_loop_nested_struct_array', "Nested struct array usage in dynamic loop",
932 'uniform int ui_zero;\n' +
933 'uniform int ui_one;\n' +
934 'uniform int ui_two;\n' +
935 'uniform int ui_three;\n' +
936 'uniform mediump float uf_two;\n' +
937 'uniform mediump float uf_three;\n' +
938 'uniform mediump float uf_four;\n' +
939 'uniform mediump float uf_half;\n' +
940 'uniform mediump float uf_third;\n' +
941 'uniform mediump float uf_fourth;\n' +
942 'uniform mediump float uf_sixth;\n' +
945 ' mediump float a;\n' +
946 ' mediump vec2 b[2];\n' +
949 ' mediump float a;\n' +
954 'void main (void)\n' +
959 ' s[0].a = ${COORDS}.x;\n' +
960 ' s[0].b[0].a = uf_half;\n' +
961 ' s[0].b[0].b[0] = ${COORDS}.yx;\n' +
962 ' s[0].b[0].b[1] = ${COORDS}.zx;\n' +
963 ' s[0].b[1].a = uf_third;\n' +
964 ' s[0].b[1].b[0] = ${COORDS}.yy;\n' +
965 ' s[0].b[1].b[1] = ${COORDS}.wy;\n' +
966 ' s[0].b[2].a = uf_fourth;\n' +
967 ' s[0].b[2].b[0] = ${COORDS}.zx;\n' +
968 ' s[0].b[2].b[1] = ${COORDS}.zy;\n' +
969 ' s[0].c = ui_zero;\n' +
972 ' s[1].a = ${COORDS}.w;\n' +
973 ' s[1].b[0].a = uf_two;\n' +
974 ' s[1].b[0].b[0] = ${COORDS}.zx;\n' +
975 ' s[1].b[0].b[1] = ${COORDS}.zy;\n' +
976 ' s[1].b[1].a = uf_three;\n' +
977 ' s[1].b[1].b[0] = ${COORDS}.zz;\n' +
978 ' s[1].b[1].b[1] = ${COORDS}.ww;\n' +
979 ' s[1].b[2].a = uf_four;\n' +
980 ' s[1].b[2].b[0] = ${COORDS}.yx;\n' +
981 ' s[1].b[2].b[1] = ${COORDS}.wz;\n' +
982 ' s[1].c = ui_one;\n' +
984 ' mediump float r = 0.0; // (x*3 + y*3) / 6.0\n' +
985 ' mediump float g = 0.0; // (y*3 + z*3) / 6.0\n' +
986 ' mediump float b = 0.0; // (z*3 + w*3) / 6.0\n' +
987 ' mediump float a = 1.0;\n' +
988 ' for (int i = 0; i < ui_two; i++)\n' +
990 ' for (int j = 0; j < ui_three; j++)\n' +
992 ' r += s[0].b[j].b[i].y;\n' +
993 ' g += s[i].b[j].b[0].x;\n' +
994 ' b += s[i].b[j].b[1].x;\n' +
995 ' a *= s[i].b[j].a;\n' +
998 ' ${DST} = vec4(r*uf_sixth, g*uf_sixth, b*uf_sixth, a);\n' +
1002 c.color[0] = (c.coords[0] + c.coords[1]) * 0.5;
1003 c.color[1] = (c.coords[1] + c.coords[2]) * 0.5;
1004 c.color[2] = (c.coords[2] + c.coords[3]) * 0.5;
1007 LocalStructCase('basic_equal', "Basic struct equality",
1009 'uniform int ui_one;\n' +
1010 'uniform int ui_two;\n' +
1013 ' mediump float a;\n' +
1014 ' mediump vec3 b;\n' +
1018 'void main (void)\n' +
1020 ' S a = S(floor(${COORDS}.x), vec3(0.0, floor(${COORDS}.y), 2.3), ui_one);\n' +
1021 ' S b = S(floor(${COORDS}.x+0.5), vec3(0.0, floor(${COORDS}.y), 2.3), ui_one);\n' +
1022 ' S c = S(floor(${COORDS}.x), vec3(0.0, floor(${COORDS}.y+0.5), 2.3), ui_one);\n' +
1023 ' S d = S(floor(${COORDS}.x), vec3(0.0, floor(${COORDS}.y), 2.3), ui_two);\n' +
1024 ' ${DST} = vec4(0.0, 0.0, 0.0, 1.0);\n' +
1025 ' if (a == b) ${DST}.x = 1.0;\n' +
1026 ' if (a == c) ${DST}.y = 1.0;\n' +
1027 ' if (a == d) ${DST}.z = 1.0;\n' +
1028 ' ${ASSIGN_POS}\n' +
1031 if (Math.floor(c.coords[0]) === Math.floor(c.coords[0] + 0.5))
1033 if (Math.floor(c.coords[1]) === Math.floor(c.coords[1] + 0.5))
1037 LocalStructCase('basic_not_equal', "Basic struct equality",
1039 'uniform int ui_one;\n' +
1040 'uniform int ui_two;\n' +
1043 ' mediump float a;\n' +
1044 ' mediump vec3 b;\n' +
1048 'void main (void)\n' +
1050 ' S a = S(floor(${COORDS}.x), vec3(0.0, floor(${COORDS}.y), 2.3), ui_one);\n' +
1051 ' S b = S(floor(${COORDS}.x+0.5), vec3(0.0, floor(${COORDS}.y), 2.3), ui_one);\n' +
1052 ' S c = S(floor(${COORDS}.x), vec3(0.0, floor(${COORDS}.y+0.5), 2.3), ui_one);\n' +
1053 ' S d = S(floor(${COORDS}.x), vec3(0.0, floor(${COORDS}.y), 2.3), ui_two);\n' +
1054 ' ${DST} = vec4(0.0, 0.0, 0.0, 1.0);\n' +
1055 ' if (a != b) ${DST}.x = 1.0;\n' +
1056 ' if (a != c) ${DST}.y = 1.0;\n' +
1057 ' if (a != d) ${DST}.z = 1.0;\n' +
1058 ' ${ASSIGN_POS}\n' +
1061 if (Math.floor(c.coords[0]) != Math.floor(c.coords[0] + 0.5))
1063 if (Math.floor(c.coords[1]) != Math.floor(c.coords[1] + 0.5))
1068 LocalStructCase('nested_equal', "Nested struct struct equality",
1070 'uniform int ui_one;\n' +
1071 'uniform int ui_two;\n' +
1074 ' mediump vec3 a;\n' +
1078 ' mediump float a;\n' +
1083 'void main (void)\n' +
1085 ' S a = S(floor(${COORDS}.x), T(vec3(0.0, floor(${COORDS}.y), 2.3), ui_one), 1);\n' +
1086 ' S b = S(floor(${COORDS}.x+0.5), T(vec3(0.0, floor(${COORDS}.y), 2.3), ui_one), 1);\n' +
1087 ' S c = S(floor(${COORDS}.x), T(vec3(0.0, floor(${COORDS}.y+0.5), 2.3), ui_one), 1);\n' +
1088 ' S d = S(floor(${COORDS}.x), T(vec3(0.0, floor(${COORDS}.y), 2.3), ui_two), 1);\n' +
1089 ' ${DST} = vec4(0.0, 0.0, 0.0, 1.0);\n' +
1090 ' if (a == b) ${DST}.x = 1.0;\n' +
1091 ' if (a == c) ${DST}.y = 1.0;\n' +
1092 ' if (a == d) ${DST}.z = 1.0;\n' +
1093 ' ${ASSIGN_POS}\n' +
1096 if (Math.floor(c.coords[0]) == Math.floor(c.coords[0] + 0.5))
1098 if (Math.floor(c.coords[1]) == Math.floor(c.coords[1] + 0.5))
1102 LocalStructCase('nested_not_equal', "Nested struct struct equality",
1104 'uniform int ui_one;\n' +
1105 'uniform int ui_two;\n' +
1108 ' mediump vec3 a;\n' +
1112 ' mediump float a;\n' +
1117 'void main (void)\n' +
1119 ' S a = S(floor(${COORDS}.x), T(vec3(0.0, floor(${COORDS}.y), 2.3), ui_one), 1);\n' +
1120 ' S b = S(floor(${COORDS}.x+0.5), T(vec3(0.0, floor(${COORDS}.y), 2.3), ui_one), 1);\n' +
1121 ' S c = S(floor(${COORDS}.x), T(vec3(0.0, floor(${COORDS}.y+0.5), 2.3), ui_one), 1);\n' +
1122 ' S d = S(floor(${COORDS}.x), T(vec3(0.0, floor(${COORDS}.y), 2.3), ui_two), 1);\n' +
1123 ' ${DST} = vec4(0.0, 0.0, 0.0, 1.0);\n' +
1124 ' if (a != b) ${DST}.x = 1.0;\n' +
1125 ' if (a != c) ${DST}.y = 1.0;\n' +
1126 ' if (a != d) ${DST}.z = 1.0;\n' +
1127 ' ${ASSIGN_POS}\n' +
1130 if (Math.floor(c.coords[0]) != Math.floor(c.coords[0] + 0.5))
1132 if (Math.floor(c.coords[1]) != Math.floor(c.coords[1] + 0.5))
1140 * @extends {tcuTestCase.DeqpTest}
1142 es3fShaderStructTests.UniformStructTests = function() {
1143 tcuTestCase.DeqpTest.call(this, 'uniform', 'Uniform structs');
1144 this.makeExecutable();
1147 es3fShaderStructTests.UniformStructTests.prototype = Object.create(tcuTestCase.DeqpTest.prototype);
1148 es3fShaderStructTests.UniformStructTests.prototype.constructor = es3fShaderStructTests.UniformStructTests;
1151 * @param {WebGLProgram} programID
1152 * @param {string} name
1153 * @param {Array<number>} vec
1155 es3fShaderStructTests.setUniform2fv = function(programID, name, vec) {
1156 /** @type {WebGLUniformLocation} */ var loc = gl.getUniformLocation(programID, name);
1157 gl.uniform2fv(loc, vec);
1161 * @param {WebGLProgram} programID
1162 * @param {string} name
1163 * @param {Array<number>} vec
1165 es3fShaderStructTests.setUniform3fv = function(programID, name, vec) {
1166 /** @type {WebGLUniformLocation} */ var loc = gl.getUniformLocation(programID, name);
1167 gl.uniform3fv(loc, vec);
1171 * @param {WebGLProgram} programID
1172 * @param {string} name
1173 * @param {number} value
1175 es3fShaderStructTests.setUniform1i = function(programID, name, value) {
1176 /** @type {WebGLUniformLocation} */ var loc = gl.getUniformLocation(programID, name);
1177 gl.uniform1i(loc, value);
1181 * @param {WebGLProgram} programID
1182 * @param {string} name
1183 * @param {number} value
1185 es3fShaderStructTests.setUniform1f = function(programID, name, value) {
1186 /** @type {WebGLUniformLocation} */ var loc = gl.getUniformLocation(programID, name);
1187 gl.uniform1f(loc, value);
1191 * @param {WebGLProgram} programID
1192 * @param {string} name
1193 * @param {Array<number>} vec
1195 es3fShaderStructTests.setUniform1fv = function(programID, name, vec) {
1196 /** @type {WebGLUniformLocation} */ var loc = gl.getUniformLocation(programID, name);
1197 gl.uniform1fv(loc, vec);
1200 es3fShaderStructTests.UniformStructTests.prototype.init = function() {
1201 var currentCtx = this;
1202 function UniformStructCase(name, description, textures, shaderSrc, setUniformsFunc, evalFunc) {
1203 currentCtx.addChild(es3fShaderStructTests.ShaderStructCase.createStructCase(name + "_vertex", description, true, textures, evalFunc, setUniformsFunc, shaderSrc));
1204 currentCtx.addChild(es3fShaderStructTests.ShaderStructCase.createStructCase(name + "_fragment", description, false, textures, evalFunc, setUniformsFunc, shaderSrc));
1207 UniformStructCase('basic', "Basic struct usage", false,
1209 'uniform int ui_one;\n' +
1212 ' mediump float a;\n' +
1213 ' mediump vec3 b;\n' +
1218 'void main (void)\n' +
1220 ' ${DST} = vec4(s.a, s.b.x, s.b.y, s.c);\n' +
1221 ' ${ASSIGN_POS}\n' +
1223 function(programID, constCoords) {
1224 es3fShaderStructTests.setUniform1f(programID, "s.a", constCoords[0]);
1225 es3fShaderStructTests.setUniform3fv(programID, "s.b", deMath.swizzle(constCoords, [1, 2, 3]));
1226 es3fShaderStructTests.setUniform1i(programID, "s.c", 1);
1229 c.color[0] = c.constCoords[0];
1230 c.color[1] = c.constCoords[1];
1231 c.color[2] = c.constCoords[2];
1234 UniformStructCase('nested', "Nested struct", false,
1236 'uniform int ui_zero;\n' +
1237 'uniform int ui_one;\n' +
1241 ' mediump vec2 b;\n' +
1244 ' mediump float a;\n' +
1250 'void main (void)\n' +
1252 ' ${DST} = vec4(s.a, s.b.b, s.b.a + s.c);\n' +
1253 ' ${ASSIGN_POS}\n' +
1255 function(programID, constCoords) {
1256 es3fShaderStructTests.setUniform1f(programID, "s.a", constCoords[0]);
1257 es3fShaderStructTests.setUniform1i(programID, "s.b.a", 0);
1258 es3fShaderStructTests.setUniform2fv(programID, "s.b.b", deMath.swizzle(constCoords, [1,2]));
1259 es3fShaderStructTests.setUniform1i(programID, "s.c", 1);
1262 c.color[0] = c.constCoords[0];
1263 c.color[1] = c.constCoords[1];
1264 c.color[2] = c.constCoords[2];
1267 UniformStructCase('array_member', "Struct with array member", false,
1269 'uniform int ui_one;\n' +
1272 ' mediump float a;\n' +
1273 ' mediump float b[3];\n' +
1278 'void main (void)\n' +
1280 ' ${DST} = vec4(s.a, s.b[0], s.b[1], s.c);\n' +
1281 ' ${ASSIGN_POS}\n' +
1283 function(programID, constCoords){
1284 es3fShaderStructTests.setUniform1f(programID, "s.a", constCoords[3]);
1285 es3fShaderStructTests.setUniform1i(programID, "s.c", 1);
1287 /** @type {Array<number>} */ var b = [];
1288 b[0] = constCoords[2];
1289 b[1] = constCoords[1];
1290 b[2] = constCoords[0];
1291 es3fShaderStructTests.setUniform1fv(programID, "s.b", b);
1294 c.color[0] = c.constCoords[3];
1295 c.color[1] = c.constCoords[2];
1296 c.color[2] = c.constCoords[1];
1299 UniformStructCase('array_member_dynamic_index', "Struct with array member, dynamic indexing", false,
1301 'uniform int ui_zero;\n' +
1302 'uniform int ui_one;\n' +
1303 'uniform int ui_two;\n' +
1306 ' mediump float a;\n' +
1307 ' mediump float b[3];\n' +
1312 'void main (void)\n' +
1314 ' ${DST} = vec4(s.b[ui_one], s.b[ui_zero], s.b[ui_two], s.c);\n' +
1315 ' ${ASSIGN_POS}\n' +
1317 function(programID, constCoords) {
1318 es3fShaderStructTests.setUniform1f(programID, "s.a", constCoords[3]);
1319 es3fShaderStructTests.setUniform1i(programID, "s.c", 1);
1321 /** @type {Array<number>} */ var b = [];
1322 b[0] = constCoords[2];
1323 b[1] = constCoords[1];
1324 b[2] = constCoords[0];
1325 es3fShaderStructTests.setUniform1fv(programID, "s.b", b);
1328 c.color[0] = c.constCoords[1];
1329 c.color[1] = c.constCoords[2];
1330 c.color[2] = c.constCoords[0];
1333 UniformStructCase('struct_array', "Struct array", false,
1335 'uniform int ui_zero;\n' +
1336 'uniform int ui_one;\n' +
1337 'uniform int ui_two;\n' +
1340 ' mediump float a;\n' +
1341 ' mediump int b;\n' +
1343 'uniform S s[3];\n' +
1345 'void main (void)\n' +
1347 ' ${DST} = vec4(s[2].a, s[1].a, s[0].a, s[2].b - s[1].b + s[0].b);\n' +
1348 ' ${ASSIGN_POS}\n' +
1350 function(programID, constCoords) {
1351 es3fShaderStructTests.setUniform1f(programID, "s[0].a", constCoords[0]);
1352 es3fShaderStructTests.setUniform1i(programID, "s[0].b", 0);
1353 es3fShaderStructTests.setUniform1f(programID, "s[1].a", constCoords[1]);
1354 es3fShaderStructTests.setUniform1i(programID, "s[1].b", 1);
1355 es3fShaderStructTests.setUniform1f(programID, "s[2].a", constCoords[2]);
1356 es3fShaderStructTests.setUniform1i(programID, "s[2].b", 2);
1359 c.color[0] = c.constCoords[2];
1360 c.color[1] = c.constCoords[1];
1361 c.color[2] = c.constCoords[0];
1364 UniformStructCase('struct_array_dynamic_index', "Struct array with dynamic indexing", false,
1366 'uniform int ui_zero;\n' +
1367 'uniform int ui_one;\n' +
1368 'uniform int ui_two;\n' +
1371 ' mediump float a;\n' +
1372 ' mediump int b;\n' +
1374 'uniform S s[3];\n' +
1376 'void main (void)\n' +
1378 ' ${DST} = vec4(s[ui_two].a, s[ui_one].a, s[ui_zero].a, s[ui_two].b - s[ui_one].b + s[ui_zero].b);\n' +
1379 ' ${ASSIGN_POS}\n' +
1381 function(programID, constCoords) {
1382 es3fShaderStructTests.setUniform1f(programID, "s[0].a", constCoords[0]);
1383 es3fShaderStructTests.setUniform1i(programID, "s[0].b", 0);
1384 es3fShaderStructTests.setUniform1f(programID, "s[1].a", constCoords[1]);
1385 es3fShaderStructTests.setUniform1i(programID, "s[1].b", 1);
1386 es3fShaderStructTests.setUniform1f(programID, "s[2].a", constCoords[2]);
1387 es3fShaderStructTests.setUniform1i(programID, "s[2].b", 2);
1390 c.color[0] = c.constCoords[2];
1391 c.color[1] = c.constCoords[1];
1392 c.color[2] = c.constCoords[0];
1395 UniformStructCase('nested_struct_array', "Nested struct array", false,
1398 ' mediump float a;\n' +
1399 ' mediump vec2 b[2];\n' +
1402 ' mediump float a;\n' +
1406 'uniform S s[2];\n' +
1408 'void main (void)\n' +
1410 ' mediump float r = (s[0].b[1].b[0].x + s[1].b[2].b[1].y) * s[0].b[0].a; // (z + z) * 0.5\n' +
1411 ' mediump float g = s[1].b[0].b[0].y * s[0].b[2].a * s[1].b[2].a; // x * 0.25 * 4\n' +
1412 ' mediump float b = (s[0].b[2].b[1].y + s[0].b[1].b[0].y + s[1].a) * s[0].b[1].a; // (w + w + w) * 0.333\n' +
1413 ' mediump float a = float(s[0].c) + s[1].b[2].a - s[1].b[1].a; // 0 + 4.0 - 3.0\n' +
1414 ' ${DST} = vec4(r, g, b, a);\n' +
1415 ' ${ASSIGN_POS}\n' +
1417 function(programID, constCoords) {
1418 /** @type {Array<number>} */ var arr = [];
1420 es3fShaderStructTests.setUniform1f(programID, "s[0].a", constCoords[0]);
1421 arr = deMath.swizzle(constCoords, [0,1,2,3]);
1422 es3fShaderStructTests.setUniform1f(programID, "s[0].b[0].a", 0.5);
1423 es3fShaderStructTests.setUniform2fv(programID, "s[0].b[0].b", arr);
1424 arr = deMath.swizzle(constCoords, [2,3,0,1]);
1425 es3fShaderStructTests.setUniform1f(programID, "s[0].b[1].a", 1.0/3.0);
1426 es3fShaderStructTests.setUniform2fv(programID, "s[0].b[1].b", arr);
1427 arr = deMath.swizzle(constCoords, [0,2,1,3]);
1428 es3fShaderStructTests.setUniform1f(programID, "s[0].b[2].a", 1.0/4.0);
1429 es3fShaderStructTests.setUniform2fv(programID, "s[0].b[2].b", arr);
1430 es3fShaderStructTests.setUniform1i(programID, "s[0].c", 0);
1432 es3fShaderStructTests.setUniform1f(programID, "s[1].a", constCoords[3]);
1433 arr = deMath.swizzle(constCoords, [0,0,1,1]);
1434 es3fShaderStructTests.setUniform1f(programID, "s[1].b[0].a", 2.0);
1435 es3fShaderStructTests.setUniform2fv(programID, "s[1].b[0].b", arr);
1436 arr = deMath.swizzle(constCoords, [2,2,3,3]);
1437 es3fShaderStructTests.setUniform1f(programID, "s[1].b[1].a", 3.0);
1438 es3fShaderStructTests.setUniform2fv(programID, "s[1].b[1].b", arr);
1439 arr = deMath.swizzle(constCoords, [1,0,3,2]);
1440 es3fShaderStructTests.setUniform1f(programID, "s[1].b[2].a", 4.0);
1441 es3fShaderStructTests.setUniform2fv(programID, "s[1].b[2].b", arr);
1442 es3fShaderStructTests.setUniform1i(programID, "s[1].c", 1);
1445 c.color[0] = c.constCoords[2];
1446 c.color[1] = c.constCoords[0];
1447 c.color[2] = c.constCoords[3];
1450 UniformStructCase('nested_struct_array_dynamic_index', "Nested struct array with dynamic indexing", false,
1452 'uniform int ui_zero;\n' +
1453 'uniform int ui_one;\n' +
1454 'uniform int ui_two;\n' +
1457 ' mediump float a;\n' +
1458 ' mediump vec2 b[2];\n' +
1461 ' mediump float a;\n' +
1465 'uniform S s[2];\n' +
1467 'void main (void)\n' +
1469 ' mediump float r = (s[0].b[ui_one].b[ui_one-1].x + s[ui_one].b[ui_two].b[ui_zero+1].y) * s[0].b[0].a; // (z + z) * 0.5\n' +
1470 ' mediump float g = s[ui_two-1].b[ui_two-2].b[ui_zero].y * s[0].b[ui_two].a * s[ui_one].b[2].a; // x * 0.25 * 4\n' +
1471 ' mediump float b = (s[ui_zero].b[ui_one+1].b[1].y + s[0].b[ui_one*ui_one].b[0].y + s[ui_one].a) * s[0].b[ui_two-ui_one].a; // (w + w + w) * 0.333\n' +
1472 ' mediump float a = float(s[ui_zero].c) + s[ui_one-ui_zero].b[ui_two].a - s[ui_zero+ui_one].b[ui_two-ui_one].a; // 0 + 4.0 - 3.0\n' +
1473 ' ${DST} = vec4(r, g, b, a);\n' +
1474 ' ${ASSIGN_POS}\n' +
1476 function(programID, constCoords){
1477 /** @type {Array<number>} */ var arr = [];
1479 es3fShaderStructTests.setUniform1f(programID, "s[0].a", constCoords[0]);
1481 es3fShaderStructTests.setUniform1f(programID, "s[0].b[0].a", 0.5);
1482 es3fShaderStructTests.setUniform2fv(programID, "s[0].b[0].b", arr);
1483 arr = deMath.swizzle(constCoords, [2,3,0,1]);
1484 es3fShaderStructTests.setUniform1f(programID, "s[0].b[1].a", 1.0/3.0);
1485 es3fShaderStructTests.setUniform2fv(programID, "s[0].b[1].b", arr);
1486 arr = deMath.swizzle(constCoords, [0,2,1,3]);
1487 es3fShaderStructTests.setUniform1f(programID, "s[0].b[2].a", 1.0/4.0);
1488 es3fShaderStructTests.setUniform2fv(programID, "s[0].b[2].b", arr);
1489 es3fShaderStructTests.setUniform1i(programID, "s[0].c", 0);
1491 es3fShaderStructTests.setUniform1f(programID, "s[1].a", constCoords[3]);
1492 arr = deMath.swizzle(constCoords, [0,0,1,1]);
1493 es3fShaderStructTests.setUniform1f(programID, "s[1].b[0].a", 2.0);
1494 es3fShaderStructTests.setUniform2fv(programID, "s[1].b[0].b", arr);
1495 arr = deMath.swizzle(constCoords, [2,2,3,3]);
1496 es3fShaderStructTests.setUniform1f(programID, "s[1].b[1].a", 3.0);
1497 es3fShaderStructTests.setUniform2fv(programID, "s[1].b[1].b", arr);
1498 arr = deMath.swizzle(constCoords, [1,0,3,2]);
1499 es3fShaderStructTests.setUniform1f(programID, "s[1].b[2].a", 4.0);
1500 es3fShaderStructTests.setUniform2fv(programID, "s[1].b[2].b", arr);
1501 es3fShaderStructTests.setUniform1i(programID, "s[1].c", 1);
1504 c.color[0] = c.constCoords[2];
1505 c.color[1] = c.constCoords[0];
1506 c.color[2] = c.constCoords[3];
1509 UniformStructCase('loop_struct_array', "Struct array usage in loop", false,
1511 'uniform int ui_zero;\n' +
1512 'uniform int ui_one;\n' +
1513 'uniform int ui_two;\n' +
1516 ' mediump float a;\n' +
1517 ' mediump int b;\n' +
1519 'uniform S s[3];\n' +
1521 'void main (void)\n' +
1523 ' mediump float rgb[3];\n' +
1524 ' int alpha = 0;\n' +
1525 ' for (int i = 0; i < 3; i++)\n' +
1527 ' rgb[i] = s[2-i].a;\n' +
1528 ' alpha += s[i].b;\n' +
1530 ' ${DST} = vec4(rgb[0], rgb[1], rgb[2], alpha);\n' +
1531 ' ${ASSIGN_POS}\n' +
1533 function(programID, constCoords) {
1534 es3fShaderStructTests.setUniform1f(programID, "s[0].a", constCoords[0]);
1535 es3fShaderStructTests.setUniform1i(programID, "s[0].b", 0);
1536 es3fShaderStructTests.setUniform1f(programID, "s[1].a", constCoords[1]);
1537 es3fShaderStructTests.setUniform1i(programID, "s[1].b", -1);
1538 es3fShaderStructTests.setUniform1f(programID, "s[2].a", constCoords[2]);
1539 es3fShaderStructTests.setUniform1i(programID, "s[2].b", 2);
1542 c.color[0] = c.constCoords[2];
1543 c.color[1] = c.constCoords[1];
1544 c.color[2] = c.constCoords[0];
1547 UniformStructCase('loop_nested_struct_array', "Nested struct array usage in loop", false,
1549 'uniform int ui_zero;\n' +
1550 'uniform int ui_one;\n' +
1551 'uniform int ui_two;\n' +
1552 'uniform mediump float uf_two;\n' +
1553 'uniform mediump float uf_three;\n' +
1554 'uniform mediump float uf_four;\n' +
1555 'uniform mediump float uf_half;\n' +
1556 'uniform mediump float uf_third;\n' +
1557 'uniform mediump float uf_fourth;\n' +
1558 'uniform mediump float uf_sixth;\n' +
1561 ' mediump float a;\n' +
1562 ' mediump vec2 b[2];\n' +
1565 ' mediump float a;\n' +
1569 'uniform S s[2];\n' +
1571 'void main (void)\n' +
1573 ' mediump float r = 0.0; // (x*3 + y*3) / 6.0\n' +
1574 ' mediump float g = 0.0; // (y*3 + z*3) / 6.0\n' +
1575 ' mediump float b = 0.0; // (z*3 + w*3) / 6.0\n' +
1576 ' mediump float a = 1.0;\n' +
1577 ' for (int i = 0; i < 2; i++)\n' +
1579 ' for (int j = 0; j < 3; j++)\n' +
1581 ' r += s[0].b[j].b[i].y;\n' +
1582 ' g += s[i].b[j].b[0].x;\n' +
1583 ' b += s[i].b[j].b[1].x;\n' +
1584 ' a *= s[i].b[j].a;\n' +
1587 ' ${DST} = vec4(r*uf_sixth, g*uf_sixth, b*uf_sixth, a);\n' +
1588 ' ${ASSIGN_POS}\n' +
1590 function(programID, constCoords) {
1591 /** @type {Array<number>} */ var arr = [];
1593 es3fShaderStructTests.setUniform1f(programID, "s[0].a", constCoords[0]);
1594 arr = deMath.swizzle(constCoords, [1,0,2,0]);
1595 es3fShaderStructTests.setUniform1f(programID, "s[0].b[0].a", 0.5);
1596 es3fShaderStructTests.setUniform2fv(programID, "s[0].b[0].b", arr);
1597 arr = deMath.swizzle(constCoords, [1,1,3,1]);
1598 es3fShaderStructTests.setUniform1f(programID, "s[0].b[1].a", 1.0/3.0);
1599 es3fShaderStructTests.setUniform2fv(programID, "s[0].b[1].b", arr);
1600 arr = deMath.swizzle(constCoords, [2,1,2,1]);
1601 es3fShaderStructTests.setUniform1f(programID, "s[0].b[2].a", 1.0/4.0);
1602 es3fShaderStructTests.setUniform2fv(programID, "s[0].b[2].b", arr);
1603 es3fShaderStructTests.setUniform1i(programID, "s[0].c", 0);
1605 es3fShaderStructTests.setUniform1f(programID, "s[1].a", constCoords[3]);
1606 arr = deMath.swizzle(constCoords, [2,0,2,1]);
1607 es3fShaderStructTests.setUniform1f(programID, "s[1].b[0].a", 2.0);
1608 es3fShaderStructTests.setUniform2fv(programID, "s[1].b[0].b", arr);
1609 arr = deMath.swizzle(constCoords, [2,2,3,3]);
1610 es3fShaderStructTests.setUniform1f(programID, "s[1].b[1].a", 3.0);
1611 es3fShaderStructTests.setUniform2fv(programID, "s[1].b[1].b", arr);
1612 arr = deMath.swizzle(constCoords, [1,0,3,2]);
1613 es3fShaderStructTests.setUniform1f(programID, "s[1].b[2].a", 4.0);
1614 es3fShaderStructTests.setUniform2fv(programID, "s[1].b[2].b", arr);
1615 es3fShaderStructTests.setUniform1i(programID, "s[1].c", 1);
1618 c.color[0] = (c.constCoords[0] + c.constCoords[1]) * 0.5;
1619 c.color[1] = (c.constCoords[1] + c.constCoords[2]) * 0.5;
1620 c.color[2] = (c.constCoords[2] + c.constCoords[3]) * 0.5;
1623 UniformStructCase('dynamic_loop_struct_array', "Struct array usage in dynamic loop", false,
1625 'uniform int ui_zero;\n' +
1626 'uniform int ui_one;\n' +
1627 'uniform int ui_two;\n' +
1628 'uniform int ui_three;\n' +
1631 ' mediump float a;\n' +
1632 ' mediump int b;\n' +
1634 'uniform S s[3];\n' +
1636 'void main (void)\n' +
1638 ' mediump float rgb[3];\n' +
1639 ' int alpha = 0;\n' +
1640 ' for (int i = 0; i < ui_three; i++)\n' +
1642 ' rgb[i] = s[2-i].a;\n' +
1643 ' alpha += s[i].b;\n' +
1645 ' ${DST} = vec4(rgb[0], rgb[1], rgb[2], alpha);\n' +
1646 ' ${ASSIGN_POS}\n' +
1648 function(programID, constCoords) {
1649 es3fShaderStructTests.setUniform1f(programID, "s[0].a", constCoords[0]);
1650 es3fShaderStructTests.setUniform1i(programID, "s[0].b", 0);
1651 es3fShaderStructTests.setUniform1f(programID, "s[1].a", constCoords[1]);
1652 es3fShaderStructTests.setUniform1i(programID, "s[1].b", -1);
1653 es3fShaderStructTests.setUniform1f(programID, "s[2].a", constCoords[2]);
1654 es3fShaderStructTests.setUniform1i(programID, "s[2].b", 2);
1657 c.color[0] = c.constCoords[2];
1658 c.color[1] = c.constCoords[1];
1659 c.color[2] = c.constCoords[0];
1662 UniformStructCase('dynamic_loop_nested_struct_array', "Nested struct array usage in dynamic loop", false,
1664 'uniform int ui_zero;\n' +
1665 'uniform int ui_one;\n' +
1666 'uniform int ui_two;\n' +
1667 'uniform int ui_three;\n' +
1668 'uniform mediump float uf_two;\n' +
1669 'uniform mediump float uf_three;\n' +
1670 'uniform mediump float uf_four;\n' +
1671 'uniform mediump float uf_half;\n' +
1672 'uniform mediump float uf_third;\n' +
1673 'uniform mediump float uf_fourth;\n' +
1674 'uniform mediump float uf_sixth;\n' +
1677 ' mediump float a;\n' +
1678 ' mediump vec2 b[2];\n' +
1681 ' mediump float a;\n' +
1685 'uniform S s[2];\n' +
1687 'void main (void)\n' +
1689 ' mediump float r = 0.0; // (x*3 + y*3) / 6.0\n' +
1690 ' mediump float g = 0.0; // (y*3 + z*3) / 6.0\n' +
1691 ' mediump float b = 0.0; // (z*3 + w*3) / 6.0\n' +
1692 ' mediump float a = 1.0;\n' +
1693 ' for (int i = 0; i < ui_two; i++)\n' +
1695 ' for (int j = 0; j < ui_three; j++)\n' +
1697 ' r += s[0].b[j].b[i].y;\n' +
1698 ' g += s[i].b[j].b[0].x;\n' +
1699 ' b += s[i].b[j].b[1].x;\n' +
1700 ' a *= s[i].b[j].a;\n' +
1703 ' ${DST} = vec4(r*uf_sixth, g*uf_sixth, b*uf_sixth, a);\n' +
1704 ' ${ASSIGN_POS}\n' +
1706 function(programID, constCoords) {
1707 /** @type {Array<number>} */ var arr = [];
1709 es3fShaderStructTests.setUniform1f(programID, "s[0].a", constCoords[0]);
1710 arr = deMath.swizzle(constCoords, [1,0,2,0]);
1711 es3fShaderStructTests.setUniform1f(programID, "s[0].b[0].a", 0.5);
1712 es3fShaderStructTests.setUniform2fv(programID, "s[0].b[0].b", arr);
1713 arr = deMath.swizzle(constCoords, [1,1,3,1]);
1714 es3fShaderStructTests.setUniform1f(programID, "s[0].b[1].a", 1.0/3.0);
1715 es3fShaderStructTests.setUniform2fv(programID, "s[0].b[1].b", arr);
1716 arr = deMath.swizzle(constCoords, [2,1,2,1]);
1717 es3fShaderStructTests.setUniform1f(programID, "s[0].b[2].a", 1.0/4.0);
1718 es3fShaderStructTests.setUniform2fv(programID, "s[0].b[2].b", arr);
1719 es3fShaderStructTests.setUniform1i(programID, "s[0].c", 0);
1721 es3fShaderStructTests.setUniform1f(programID, "s[1].a", constCoords[3]);
1722 arr = deMath.swizzle(constCoords, [2,0,2,1]);
1723 es3fShaderStructTests.setUniform1f(programID, "s[1].b[0].a", 2.0);
1724 es3fShaderStructTests.setUniform2fv(programID, "s[1].b[0].b", arr);
1725 arr = deMath.swizzle(constCoords, [2,2,3,3]);
1726 es3fShaderStructTests.setUniform1f(programID, "s[1].b[1].a", 3.0);
1727 es3fShaderStructTests.setUniform2fv(programID, "s[1].b[1].b", arr);
1728 arr = deMath.swizzle(constCoords, [1,0,3,2]);
1729 es3fShaderStructTests.setUniform1f(programID, "s[1].b[2].a", 4.0);
1730 es3fShaderStructTests.setUniform2fv(programID, "s[1].b[2].b", arr);
1731 es3fShaderStructTests.setUniform1i(programID, "s[1].c", 1);
1734 c.color[0] = (c.constCoords[0] + c.constCoords[1]) * 0.5;
1735 c.color[1] = (c.constCoords[1] + c.constCoords[2]) * 0.5;
1736 c.color[2] = (c.constCoords[2] + c.constCoords[3]) * 0.5;
1739 UniformStructCase('sampler', "Sampler in struct", true,
1741 'uniform int ui_one;\n' +
1744 ' mediump float a;\n' +
1745 ' mediump vec3 b;\n' +
1750 'void main (void)\n' +
1752 ' ${DST} = vec4(texture(s.c, ${COORDS}.xy * s.b.xy + s.b.z).rgb, s.a);\n' +
1753 ' ${ASSIGN_POS}\n' +
1755 function(programID, constCoords) {
1756 es3fShaderStructTests.setUniform1f(programID, "s.a", 1.0);
1757 es3fShaderStructTests.setUniform3fv(programID, "s.b", [0.25, 0.25, 0.5]);
1758 es3fShaderStructTests.setUniform1i(programID, "s.c", 0);
1761 var tex2d = c.texture2D(es3fShaderStructTests.TEXTURE_BRICK, deMath.addScalar(deMath.scale(deMath.swizzle(c.coords, [0,1]), 0.25), 0.5))
1763 c.color[0] = tex2d[0];
1764 c.color[1] = tex2d[1];
1765 c.color[2] = tex2d[2];
1768 UniformStructCase('sampler_nested', "Sampler in nested struct", true,
1770 'uniform int ui_zero;\n' +
1771 'uniform int ui_one;\n' +
1775 ' mediump vec2 b;\n' +
1778 ' mediump float a;\n' +
1784 'void main (void)\n' +
1786 ' ${DST} = vec4(texture(s.b.a, ${COORDS}.xy * s.b.b + s.a).rgb, s.c);\n' +
1787 ' ${ASSIGN_POS}\n' +
1789 function(programID, constCoords) {
1790 es3fShaderStructTests.setUniform1f(programID, "s.a", 0.5);
1791 es3fShaderStructTests.setUniform1i(programID, "s.b.a", 0);
1792 es3fShaderStructTests.setUniform2fv(programID, "s.b.b", [0.25, 0.25]);
1793 es3fShaderStructTests.setUniform1i(programID, "s.c", 1);
1796 var tex2d = c.texture2D(es3fShaderStructTests.TEXTURE_BRICK, deMath.addScalar(deMath.scale(deMath.swizzle(c.coords, [0,1]), 0.25), 0.5));
1797 c.color[0] = tex2d[0];
1798 c.color[1] = tex2d[1];
1799 c.color[2] = tex2d[2];
1802 UniformStructCase('sampler_array', "Sampler in struct array", true,
1804 'uniform int ui_one;\n' +
1807 ' mediump float a;\n' +
1808 ' mediump vec3 b;\n' +
1811 'uniform S s[2];\n' +
1813 'void main (void)\n' +
1815 ' ${DST} = vec4(texture(s[1].c, ${COORDS}.xy * s[0].b.xy + s[1].b.z).rgb, s[0].a);\n' +
1816 ' ${ASSIGN_POS}\n' +
1818 function(programID, constCoords) {
1819 es3fShaderStructTests.setUniform1f(programID, "s[0].a", 1.0);
1820 es3fShaderStructTests.setUniform3fv(programID, "s[0].b", [0.25, 0.25, 0.25]);
1821 es3fShaderStructTests.setUniform1i(programID, "s[0].c", 1);
1822 es3fShaderStructTests.setUniform1f(programID, "s[1].a", 0.0);
1823 es3fShaderStructTests.setUniform3fv(programID, "s[1].b", [0.5, 0.5, 0.5]);
1824 es3fShaderStructTests.setUniform1i(programID, "s[1].c", 0);
1827 var tex2d = c.texture2D(es3fShaderStructTests.TEXTURE_BRICK, deMath.addScalar(deMath.scale(deMath.swizzle(c.coords, [0,1]), 0.25), 0.5));
1828 c.color[0] = tex2d[0];
1829 c.color[1] = tex2d[1];
1830 c.color[2] = tex2d[2];
1833 UniformStructCase('equal', "Struct equality", false,
1835 'uniform mediump float uf_one;\n' +
1836 'uniform int ui_two;\n' +
1839 ' mediump float a;\n' +
1840 ' mediump vec3 b;\n' +
1847 'void main (void)\n' +
1849 ' S d = S(uf_one, vec3(0.0, floor(${COORDS}.y+1.0), 2.0), ui_two);\n' +
1850 ' ${DST} = vec4(0.0, 0.0, 0.0, 1.0);\n' +
1851 ' if (a == b) ${DST}.x = 1.0;\n' +
1852 ' if (a == c) ${DST}.y = 1.0;\n' +
1853 ' if (a == d) ${DST}.z = 1.0;\n' +
1854 ' ${ASSIGN_POS}\n' +
1856 function(programID, constCoords) {
1857 es3fShaderStructTests.setUniform1f(programID, "a.a", 1.0);
1858 es3fShaderStructTests.setUniform3fv(programID, "a.b", [0.0, 1.0, 2.0]);
1859 es3fShaderStructTests.setUniform1i(programID, "a.c", 2);
1860 es3fShaderStructTests.setUniform1f(programID, "b.a", 1.0);
1861 es3fShaderStructTests.setUniform3fv(programID, "b.b", [0.0, 1.0, 2.0]);
1862 es3fShaderStructTests.setUniform1i(programID, "b.c", 2);
1863 es3fShaderStructTests.setUniform1f(programID, "c.a", 1.0);
1864 es3fShaderStructTests.setUniform3fv(programID, "c.b", [0.0, 1.1, 2.0]);
1865 es3fShaderStructTests.setUniform1i(programID, "c.c", 2);
1870 if (Math.floor(c.coords[1] + 1.0) == Math.floor(1.1))
1874 UniformStructCase('not_equal', "Struct equality", false,
1876 'uniform mediump float uf_one;\n' +
1877 'uniform int ui_two;\n' +
1880 ' mediump float a;\n' +
1881 ' mediump vec3 b;\n' +
1888 'void main (void)\n' +
1890 ' S d = S(uf_one, vec3(0.0, floor(${COORDS}.y+1.0), 2.0), ui_two);\n' +
1891 ' ${DST} = vec4(0.0, 0.0, 0.0, 1.0);\n' +
1892 ' if (a != b) ${DST}.x = 1.0;\n' +
1893 ' if (a != c) ${DST}.y = 1.0;\n' +
1894 ' if (a != d) ${DST}.z = 1.0;\n' +
1895 ' ${ASSIGN_POS}\n' +
1897 function(programID, constCoords) {
1898 es3fShaderStructTests.setUniform1f(programID, "a.a", 1.0);
1899 es3fShaderStructTests.setUniform3fv(programID, "a.b", [0.0, 1.0, 2.0]);
1900 es3fShaderStructTests.setUniform1i(programID, "a.c", 2);
1901 es3fShaderStructTests.setUniform1f(programID, "b.a", 1.0);
1902 es3fShaderStructTests.setUniform3fv(programID, "b.b", [0.0, 1.0, 2.0]);
1903 es3fShaderStructTests.setUniform1i(programID, "b.c", 2);
1904 es3fShaderStructTests.setUniform1f(programID, "c.a", 1.0);
1905 es3fShaderStructTests.setUniform3fv(programID, "c.b", [0.0, 1.1, 2.0]);
1906 es3fShaderStructTests.setUniform1i(programID, "c.c", 2);
1911 if (Math.floor(c.coords[1] + 1.0) != Math.floor(1.1))
1919 * @extends {tcuTestCase.DeqpTest}
1921 es3fShaderStructTests.ShaderStructTests = function() {
1922 tcuTestCase.DeqpTest.call(this, 'struct', 'Struct Tests');
1925 es3fShaderStructTests.ShaderStructTests.prototype = Object.create(tcuTestCase.DeqpTest.prototype);
1926 es3fShaderStructTests.ShaderStructTests.prototype.constructor = es3fShaderStructTests.ShaderStructTests;
1928 es3fShaderStructTests.ShaderStructTests.prototype.init = function() {
1929 this.addChild(new es3fShaderStructTests.LocalStructTests());
1930 this.addChild(new es3fShaderStructTests.UniformStructTests());
1935 * @param {WebGL2RenderingContext} context
1937 es3fShaderStructTests.run = function(context) {
1939 //Set up Test Root parameters
1940 var state = tcuTestCase.runner;
1941 state.setRoot(new es3fShaderStructTests.ShaderStructTests());
1943 //Set up name and description of this test series.
1944 setCurrentTestName(state.testCases.fullName());
1945 description(state.testCases.getDescription());
1948 tcuTestCase.runTestCases();
1951 testFailedOptions('Failed to es3fShaderStructTests.run tests', false);
1952 tcuTestCase.runner.terminate();