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.es3fShaderStateQueryTests');
23 goog.require('framework.common.tcuMatrix');
24 goog.require('framework.common.tcuTestCase');
25 goog.require('framework.delibs.debase.deRandom');
26 goog.require('functional.gles3.es3fApiCase');
27 goog.require('modules.shared.glsStateQuery');
29 goog.scope(function() {
30 var es3fShaderStateQueryTests = functional.gles3.es3fShaderStateQueryTests;
31 var tcuTestCase = framework.common.tcuTestCase;
32 var glsStateQuery = modules.shared.glsStateQuery;
33 var es3fApiCase = functional.gles3.es3fApiCase;
34 var deRandom = framework.delibs.debase.deRandom;
35 var tcuMatrix = framework.common.tcuMatrix;
37 var setParentClass = function(child, parent) {
38 child.prototype = Object.create(parent.prototype);
39 child.prototype.constructor = child;
42 var commonTestVertSource = '#version 300 es\n' +
43 'void main (void)\n' +
45 ' gl_Position = vec4(0.0);\n' +
47 var commonTestFragSource = '#version 300 es\n' +
48 'layout(location = 0) out mediump vec4 fragColor;\n' +
49 'void main (void)\n' +
51 ' fragColor = vec4(0.0);\n' +
54 var brokenShader = '#version 300 es\n' +
55 'broken, this should not compile!\n' +
60 * @extends {es3fApiCase.ApiCase}
61 * @param {string} name
62 * @param {string} description
64 es3fShaderStateQueryTests.ShaderTypeCase = function(name, description) {
65 es3fApiCase.ApiCase.call(this, name, description, gl);
68 setParentClass(es3fShaderStateQueryTests.ShaderTypeCase, es3fApiCase.ApiCase);
70 es3fShaderStateQueryTests.ShaderTypeCase.prototype.test = function() {
71 var shaderTypes = [gl.VERTEX_SHADER, gl.FRAGMENT_SHADER];
72 for (var ndx = 0; ndx < shaderTypes.length; ++ndx) {
73 var shader = gl.createShader(shaderTypes[ndx]);
74 var result = glsStateQuery.verifyShader(shader, gl.SHADER_TYPE, shaderTypes[ndx]);
75 this.check(result, 'Incorrect shader type');
76 gl.deleteShader(shader);
82 * @extends {es3fApiCase.ApiCase}
83 * @param {string} name
84 * @param {string} description
86 es3fShaderStateQueryTests.ShaderCompileStatusCase = function(name, description) {
87 es3fApiCase.ApiCase.call(this, name, description, gl);
90 setParentClass(es3fShaderStateQueryTests.ShaderCompileStatusCase, es3fApiCase.ApiCase);
92 es3fShaderStateQueryTests.ShaderCompileStatusCase.prototype.test = function() {
94 var shaderVert = gl.createShader(gl.VERTEX_SHADER);
95 var shaderFrag = gl.createShader(gl.FRAGMENT_SHADER);
97 result = glsStateQuery.verifyShader(shaderVert, gl.COMPILE_STATUS, false);
98 this.check(result, 'Vertex shader compilation status should be false');
99 result = glsStateQuery.verifyShader(shaderFrag, gl.COMPILE_STATUS, false);
100 this.check(result, 'Fragment shader compilation status should be false');
102 gl.shaderSource(shaderVert, commonTestVertSource);
103 gl.shaderSource(shaderFrag, commonTestFragSource);
105 gl.compileShader(shaderVert);
106 gl.compileShader(shaderFrag);
108 result = glsStateQuery.verifyShader(shaderVert, gl.COMPILE_STATUS, true);
109 this.check(result, 'Vertex shader compilation status should be true');
110 result = glsStateQuery.verifyShader(shaderFrag, gl.COMPILE_STATUS, true);
111 this.check(result, 'Fragment shader compilation status should be true');
113 gl.deleteShader(shaderVert);
114 gl.deleteShader(shaderFrag);
119 * @extends {es3fApiCase.ApiCase}
120 * @param {string} name
121 * @param {string} description
123 es3fShaderStateQueryTests.ShaderInfoLogCase = function(name, description) {
124 es3fApiCase.ApiCase.call(this, name, description, gl);
127 setParentClass(es3fShaderStateQueryTests.ShaderInfoLogCase, es3fApiCase.ApiCase);
129 es3fShaderStateQueryTests.ShaderInfoLogCase.prototype.test = function() {
130 var shader = gl.createShader(gl.VERTEX_SHADER);
131 var log = gl.getShaderInfoLog(shader);
132 this.check(log === '');
134 gl.shaderSource(shader, brokenShader);
135 gl.compileShader(shader);
137 log = gl.getShaderInfoLog(shader);
138 this.check(log === null || typeof log === 'string');
140 gl.deleteShader(shader);
145 * @extends {es3fApiCase.ApiCase}
146 * @param {string} name
147 * @param {string} description
149 es3fShaderStateQueryTests.ShaderSourceCase = function(name, description) {
150 es3fApiCase.ApiCase.call(this, name, description, gl);
153 setParentClass(es3fShaderStateQueryTests.ShaderSourceCase, es3fApiCase.ApiCase);
155 es3fShaderStateQueryTests.ShaderSourceCase.prototype.test = function() {
156 var shader = gl.createShader(gl.VERTEX_SHADER);
157 this.check(gl.getShaderSource(shader) === '');
159 gl.shaderSource(shader, brokenShader);
160 this.check(gl.getShaderSource(shader) === brokenShader);
162 gl.deleteShader(shader);
167 * @extends {es3fApiCase.ApiCase}
168 * @param {string} name
169 * @param {string} description
171 es3fShaderStateQueryTests.DeleteStatusCase = function(name, description) {
172 es3fApiCase.ApiCase.call(this, name, description, gl);
175 setParentClass(es3fShaderStateQueryTests.DeleteStatusCase, es3fApiCase.ApiCase);
177 es3fShaderStateQueryTests.DeleteStatusCase.prototype.test = function() {
178 var shaderVert = gl.createShader(gl.VERTEX_SHADER);
179 var shaderFrag = gl.createShader(gl.FRAGMENT_SHADER);
181 gl.shaderSource(shaderVert, commonTestVertSource);
182 gl.shaderSource(shaderFrag, commonTestFragSource);
184 gl.compileShader(shaderVert);
185 gl.compileShader(shaderFrag);
187 this.check(glsStateQuery.verifyShader(shaderVert, gl.COMPILE_STATUS, true));
188 this.check(glsStateQuery.verifyShader(shaderFrag, gl.COMPILE_STATUS, true));
190 var shaderProg = gl.createProgram();
191 gl.attachShader(shaderProg, shaderVert);
192 gl.attachShader(shaderProg, shaderFrag);
193 gl.linkProgram(shaderProg);
195 this.check(glsStateQuery.verifyProgram(shaderProg, gl.LINK_STATUS, true));
197 this.check(glsStateQuery.verifyShader(shaderVert, gl.DELETE_STATUS, false));
198 this.check(glsStateQuery.verifyShader(shaderFrag, gl.DELETE_STATUS, false));
199 this.check(glsStateQuery.verifyProgram(shaderProg, gl.DELETE_STATUS, false));
201 gl.useProgram(shaderProg);
203 gl.deleteShader(shaderVert);
204 gl.deleteShader(shaderFrag);
205 gl.deleteProgram(shaderProg);
207 this.check(glsStateQuery.verifyShader(shaderVert, gl.DELETE_STATUS, true));
208 this.check(glsStateQuery.verifyShader(shaderFrag, gl.DELETE_STATUS, true));
209 this.check(glsStateQuery.verifyProgram(shaderProg, gl.DELETE_STATUS, true));
216 * @extends {es3fApiCase.ApiCase}
217 * @param {string} name
218 * @param {string} description
220 es3fShaderStateQueryTests.CurrentVertexAttribInitialCase = function(name, description) {
221 es3fApiCase.ApiCase.call(this, name, description, gl);
224 setParentClass(es3fShaderStateQueryTests.CurrentVertexAttribInitialCase, es3fApiCase.ApiCase);
226 es3fShaderStateQueryTests.CurrentVertexAttribInitialCase.prototype.test = function() {
227 var attribute_count = /** @type {number} */ (gl.getParameter(gl.MAX_VERTEX_ATTRIBS));
228 var initial = new Float32Array([0, 0, 0, 1]);
231 for (var index = 0; index < attribute_count; ++index) {
232 var attrib = gl.getVertexAttrib(index, gl.CURRENT_VERTEX_ATTRIB);
233 this.check(glsStateQuery.compare(attrib, initial), 'Initial attrib value should be [0, 0, 0, 1]');
239 * @extends {es3fApiCase.ApiCase}
240 * @param {string} name
241 * @param {string} description
243 es3fShaderStateQueryTests.CurrentVertexAttribFloatCase = function(name, description) {
244 es3fApiCase.ApiCase.call(this, name, description, gl);
247 setParentClass(es3fShaderStateQueryTests.CurrentVertexAttribFloatCase, es3fApiCase.ApiCase);
249 es3fShaderStateQueryTests.CurrentVertexAttribFloatCase.prototype.test = function() {
250 var rnd = new deRandom.Random(0xabcdef);
252 var attribute_count = /** @type {number} */ (gl.getParameter(gl.MAX_VERTEX_ATTRIBS));
254 // test write float/read float
256 for (var index = 0; index < attribute_count; ++index) {
257 var x = rnd.getFloat(-64000, 64000);
258 var y = rnd.getFloat(-64000, 64000);
259 var z = rnd.getFloat(-64000, 64000);
260 var w = rnd.getFloat(-64000, 64000);
262 gl.vertexAttrib4f(index, x, y, z, w);
263 this.check(glsStateQuery.verifyCurrentVertexAttrib(index, new Float32Array([x, y, z, w])));
265 for (var index = 0; index < attribute_count; ++index) {
266 var x = rnd.getFloat(-64000, 64000);
267 var y = rnd.getFloat(-64000, 64000);
268 var z = rnd.getFloat(-64000, 64000);
271 gl.vertexAttrib3f(index, x, y, z);
272 this.check(glsStateQuery.verifyCurrentVertexAttrib(index, new Float32Array([x, y, z, w])));
274 for (var index = 0; index < attribute_count; ++index) {
275 var x = rnd.getFloat(-64000, 64000);
276 var y = rnd.getFloat(-64000, 64000);
280 gl.vertexAttrib2f(index, x, y);
281 this.check(glsStateQuery.verifyCurrentVertexAttrib(index, new Float32Array([x, y, z, w])));
283 for (var index = 0; index < attribute_count; ++index) {
284 var x = rnd.getFloat(-64000, 64000);
289 gl.vertexAttrib1f(index, x);
290 this.check(glsStateQuery.verifyCurrentVertexAttrib(index, new Float32Array([x, y, z, w])));
296 * @extends {es3fApiCase.ApiCase}
297 * @param {string} name
298 * @param {string} description
300 es3fShaderStateQueryTests.CurrentVertexAttribIntCase = function(name, description) {
301 es3fApiCase.ApiCase.call(this, name, description, gl);
304 setParentClass(es3fShaderStateQueryTests.CurrentVertexAttribIntCase, es3fApiCase.ApiCase);
306 es3fShaderStateQueryTests.CurrentVertexAttribIntCase.prototype.test = function() {
307 var rnd = new deRandom.Random(0xabcdef);
309 var attribute_count = /** @type {number} */ (gl.getParameter(gl.MAX_VERTEX_ATTRIBS));
311 // test write float/read float
313 for (var index = 0; index < attribute_count; ++index) {
314 var x = rnd.getInt(-64000, 64000);
315 var y = rnd.getInt(-64000, 64000);
316 var z = rnd.getInt(-64000, 64000);
317 var w = rnd.getInt(-64000, 64000);
319 gl.vertexAttribI4i(index, x, y, z, w);
320 this.check(glsStateQuery.verifyCurrentVertexAttrib(index, new Int32Array([x, y, z, w])));
326 * @extends {es3fApiCase.ApiCase}
327 * @param {string} name
328 * @param {string} description
330 es3fShaderStateQueryTests.CurrentVertexAttribUintCase = function(name, description) {
331 es3fApiCase.ApiCase.call(this, name, description, gl);
334 setParentClass(es3fShaderStateQueryTests.CurrentVertexAttribUintCase, es3fApiCase.ApiCase);
336 es3fShaderStateQueryTests.CurrentVertexAttribUintCase.prototype.test = function() {
337 var rnd = new deRandom.Random(0xabcdef);
339 var attribute_count = /** @type {number} */ (gl.getParameter(gl.MAX_VERTEX_ATTRIBS));
341 // test write float/read float
343 for (var index = 0; index < attribute_count; ++index) {
344 var x = rnd.getInt(0, 64000);
345 var y = rnd.getInt(0, 64000);
346 var z = rnd.getInt(0, 64000);
347 var w = rnd.getInt(0, 64000);
349 gl.vertexAttribI4ui(index, x, y, z, w);
350 this.check(glsStateQuery.verifyCurrentVertexAttrib(index, new Uint32Array([x, y, z, w])));
356 * @extends {es3fApiCase.ApiCase}
357 * @param {string} name
358 * @param {string} description
360 es3fShaderStateQueryTests.ProgramInfoLogCase = function(name, description) {
361 es3fApiCase.ApiCase.call(this, name, description, gl);
364 setParentClass(es3fShaderStateQueryTests.ProgramInfoLogCase, es3fApiCase.ApiCase);
366 es3fShaderStateQueryTests.ProgramInfoLogCase.prototype.test = function() {
367 var shaderVert = gl.createShader(gl.VERTEX_SHADER);
368 var shaderFrag = gl.createShader(gl.FRAGMENT_SHADER);
370 gl.shaderSource(shaderVert, brokenShader);
371 gl.compileShader(shaderVert);
372 gl.shaderSource(shaderFrag, brokenShader);
373 gl.compileShader(shaderFrag);
375 var program = gl.createProgram();
376 gl.attachShader(program, shaderVert);
377 gl.attachShader(program, shaderFrag);
378 gl.linkProgram(program);
380 var log = gl.getProgramInfoLog(program);
381 this.check(log === null || typeof log === 'string');
383 gl.deleteShader(shaderVert);
384 gl.deleteShader(shaderFrag);
385 gl.deleteProgram(program);
390 * @extends {es3fApiCase.ApiCase}
391 * @param {string} name
392 * @param {string} description
394 es3fShaderStateQueryTests.ProgramValidateStatusCase = function(name, description) {
395 es3fApiCase.ApiCase.call(this, name, description, gl);
398 setParentClass(es3fShaderStateQueryTests.ProgramValidateStatusCase, es3fApiCase.ApiCase);
400 es3fShaderStateQueryTests.ProgramValidateStatusCase.prototype.test = function() {
402 var shaderVert = gl.createShader(gl.VERTEX_SHADER);
403 var shaderFrag = gl.createShader(gl.FRAGMENT_SHADER);
405 gl.shaderSource(shaderVert, commonTestVertSource);
406 gl.shaderSource(shaderFrag, commonTestFragSource);
408 gl.compileShader(shaderVert);
409 gl.compileShader(shaderFrag);
411 var program = gl.createProgram();
412 gl.attachShader(program, shaderVert);
413 gl.attachShader(program, shaderFrag);
414 gl.linkProgram(program);
416 this.check(glsStateQuery.verifyShader(shaderVert, gl.COMPILE_STATUS, true));
417 this.check(glsStateQuery.verifyShader(shaderFrag, gl.COMPILE_STATUS, true));
418 this.check(glsStateQuery.verifyProgram(program, gl.LINK_STATUS, true));
420 gl.validateProgram(program);
421 this.check(glsStateQuery.verifyProgram(program, gl.VALIDATE_STATUS, true));
423 gl.deleteShader(shaderVert);
424 gl.deleteShader(shaderFrag);
425 gl.deleteProgram(program);
427 // test with broken shader
428 shaderVert = gl.createShader(gl.VERTEX_SHADER);
429 shaderFrag = gl.createShader(gl.FRAGMENT_SHADER);
431 gl.shaderSource(shaderVert, commonTestVertSource);
432 gl.shaderSource(shaderFrag, brokenShader);
434 gl.compileShader(shaderVert);
435 gl.compileShader(shaderFrag);
437 program = gl.createProgram();
438 gl.attachShader(program, shaderVert);
439 gl.attachShader(program, shaderFrag);
440 gl.linkProgram(program);
442 this.check(glsStateQuery.verifyShader(shaderVert, gl.COMPILE_STATUS, true));
443 this.check(glsStateQuery.verifyShader(shaderFrag, gl.COMPILE_STATUS, false));
444 this.check(glsStateQuery.verifyProgram(program, gl.LINK_STATUS, false));
446 gl.validateProgram(program);
447 this.check(glsStateQuery.verifyProgram(program, gl.VALIDATE_STATUS, false));
449 gl.deleteShader(shaderVert);
450 gl.deleteShader(shaderFrag);
451 gl.deleteProgram(program);
456 * @extends {es3fApiCase.ApiCase}
457 * @param {string} name
458 * @param {string} description
460 es3fShaderStateQueryTests.ProgramAttachedShadersCase = function(name, description) {
461 es3fApiCase.ApiCase.call(this, name, description, gl);
464 setParentClass(es3fShaderStateQueryTests.ProgramAttachedShadersCase, es3fApiCase.ApiCase);
466 es3fShaderStateQueryTests.ProgramAttachedShadersCase.prototype.test = function() {
467 var shaderVert = gl.createShader(gl.VERTEX_SHADER);
468 var shaderFrag = gl.createShader(gl.FRAGMENT_SHADER);
470 gl.shaderSource(shaderVert, commonTestVertSource);
471 gl.shaderSource(shaderFrag, commonTestFragSource);
473 gl.compileShader(shaderVert);
474 gl.compileShader(shaderFrag);
476 // check ATTACHED_SHADERS
478 var program = gl.createProgram();
479 this.check(glsStateQuery.verifyProgram(program, gl.ATTACHED_SHADERS, 0));
481 gl.attachShader(program, shaderVert);
482 this.check(glsStateQuery.verifyProgram(program, gl.ATTACHED_SHADERS, 1));
484 gl.attachShader(program, shaderFrag);
485 this.check(glsStateQuery.verifyProgram(program, gl.ATTACHED_SHADERS, 2));
487 // check GetAttachedShaders
488 var shaders = gl.getAttachedShaders(program);
489 this.check(glsStateQuery.compare(shaders, [shaderVert, shaderFrag]));
491 gl.deleteShader(shaderVert);
492 gl.deleteShader(shaderFrag);
493 gl.deleteProgram(program);
498 * @extends {es3fApiCase.ApiCase}
499 * @param {string} name
500 * @param {string} description
502 es3fShaderStateQueryTests.ProgramActiveUniformNameCase = function(name, description) {
503 es3fApiCase.ApiCase.call(this, name, description, gl);
506 setParentClass(es3fShaderStateQueryTests.ProgramActiveUniformNameCase, es3fApiCase.ApiCase);
508 es3fShaderStateQueryTests.ProgramActiveUniformNameCase.prototype.test = function() {
510 '#version 300 es\n' +
511 'uniform highp float uniformNameWithLength23;\n' +
512 'uniform highp vec2 uniformVec2;\n' +
513 'uniform highp mat4 uniformMat4;\n' +
514 'void main (void)\n' +
516 ' gl_Position = vec4(0.0) + vec4(uniformNameWithLength23) + vec4(uniformVec2.x) + vec4(uniformMat4[2][3]);\n' +
519 '#version 300 es\n' +
520 'layout(location = 0) out mediump vec4 fragColor;' +
521 'void main (void)\n' +
523 ' fragColor = vec4(0.0);\n' +
526 var shaderVert = gl.createShader(gl.VERTEX_SHADER);
527 var shaderFrag = gl.createShader(gl.FRAGMENT_SHADER);
529 gl.shaderSource(shaderVert, testVertSource);
530 gl.shaderSource(shaderFrag, testFragSource);
532 gl.compileShader(shaderVert);
533 gl.compileShader(shaderFrag);
535 var program = gl.createProgram();
536 gl.attachShader(program, shaderVert);
537 gl.attachShader(program, shaderFrag);
538 gl.linkProgram(program);
540 this.check(glsStateQuery.verifyProgram(program, gl.ACTIVE_UNIFORMS, 3));
543 'uniformNameWithLength23',
548 var indices = gl.getUniformIndices(program, uniformNames);
551 for (var ndx = 0; ndx < uniformNames.length; ++ndx) {
552 var index = indices[ndx];
553 var uniform = gl.getActiveUniform(program, index);
555 this.check(glsStateQuery.compare(uniform.name, uniformNames[ndx]));
558 gl.deleteShader(shaderVert);
559 gl.deleteShader(shaderFrag);
560 gl.deleteProgram(program);
566 * @extends {es3fApiCase.ApiCase}
567 * @param {string} name
568 * @param {string} description
570 es3fShaderStateQueryTests.ProgramUniformCase = function(name, description) {
571 es3fApiCase.ApiCase.call(this, name, description, gl);
574 setParentClass(es3fShaderStateQueryTests.ProgramUniformCase, es3fApiCase.ApiCase);
576 es3fShaderStateQueryTests.ProgramUniformCase.prototype.test = function() {
578 ['float', '', 'highp', '', 'uniformValue', gl.FLOAT, 1, false],
579 ['float[2]', '', 'highp', '', 'uniformValue[1]', gl.FLOAT, 2, false],
580 ['vec2', '', 'highp', '', 'uniformValue.x', gl.FLOAT_VEC2, 1, false],
581 ['vec3', '', 'highp', '', 'uniformValue.x', gl.FLOAT_VEC3, 1, false],
582 ['vec4', '', 'highp', '', 'uniformValue.x', gl.FLOAT_VEC4, 1, false],
583 ['int', '', 'highp', '', 'float(uniformValue)', gl.INT, 1, false],
584 ['ivec2', '', 'highp', '', 'float(uniformValue.x)', gl.INT_VEC2, 1, false],
585 ['ivec3', '', 'highp', '', 'float(uniformValue.x)', gl.INT_VEC3, 1, false],
586 ['ivec4', '', 'highp', '', 'float(uniformValue.x)', gl.INT_VEC4, 1, false],
587 ['uint', '', 'highp', '', 'float(uniformValue)', gl.UNSIGNED_INT, 1, false],
588 ['uvec2', '', 'highp', '', 'float(uniformValue.x)', gl.UNSIGNED_INT_VEC2, 1, false],
589 ['uvec3', '', 'highp', '', 'float(uniformValue.x)', gl.UNSIGNED_INT_VEC3, 1, false],
590 ['uvec4', '', 'highp', '', 'float(uniformValue.x)', gl.UNSIGNED_INT_VEC4, 1, false],
591 ['bool', '', '', '', 'float(uniformValue)', gl.BOOL, 1, false],
592 ['bvec2', '', '', '', 'float(uniformValue.x)', gl.BOOL_VEC2, 1, false],
593 ['bvec3', '', '', '', 'float(uniformValue.x)', gl.BOOL_VEC3, 1, false],
594 ['bvec4', '', '', '', 'float(uniformValue.x)', gl.BOOL_VEC4, 1, false],
595 ['mat2', '', 'highp', '', 'float(uniformValue[0][0])', gl.FLOAT_MAT2, 1, false],
596 ['mat3', '', 'highp', '', 'float(uniformValue[0][0])', gl.FLOAT_MAT3, 1, false],
597 ['mat4', '', 'highp', '', 'float(uniformValue[0][0])', gl.FLOAT_MAT4, 1, false],
598 ['mat2x3', '', 'highp', '', 'float(uniformValue[0][0])', gl.FLOAT_MAT2x3, 1, false],
599 ['mat2x4', '', 'highp', '', 'float(uniformValue[0][0])', gl.FLOAT_MAT2x4, 1, false],
600 ['mat3x2', '', 'highp', '', 'float(uniformValue[0][0])', gl.FLOAT_MAT3x2, 1, false],
601 ['mat3x4', '', 'highp', '', 'float(uniformValue[0][0])', gl.FLOAT_MAT3x4, 1, false],
602 ['mat4x2', '', 'highp', '', 'float(uniformValue[0][0])', gl.FLOAT_MAT4x2, 1, false],
603 ['mat4x3', '', 'highp', '', 'float(uniformValue[0][0])', gl.FLOAT_MAT4x3, 1, false],
604 ['sampler2D', '', 'highp', '', 'float(textureSize(uniformValue,0).r)', gl.SAMPLER_2D, 1, false],
605 ['sampler3D', '', 'highp', '', 'float(textureSize(uniformValue,0).r)', gl.SAMPLER_3D, 1, false],
606 ['samplerCube', '', 'highp', '', 'float(textureSize(uniformValue,0).r)', gl.SAMPLER_CUBE, 1, false],
607 ['sampler2DShadow', '', 'highp', '', 'float(textureSize(uniformValue,0).r)', gl.SAMPLER_2D_SHADOW, 1, false],
608 ['sampler2DArray', '', 'highp', '', 'float(textureSize(uniformValue,0).r)', gl.SAMPLER_2D_ARRAY, 1, false],
609 ['sampler2DArrayShadow', '', 'highp', '', 'float(textureSize(uniformValue,0).r)', gl.SAMPLER_2D_ARRAY_SHADOW, 1, false],
610 ['samplerCubeShadow', '', 'highp', '', 'float(textureSize(uniformValue,0).r)', gl.SAMPLER_CUBE_SHADOW, 1, false],
611 ['isampler2D', '', 'highp', '', 'float(textureSize(uniformValue,0).r)', gl.INT_SAMPLER_2D, 1, false],
612 ['isampler3D', '', 'highp', '', 'float(textureSize(uniformValue,0).r)', gl.INT_SAMPLER_3D, 1, false],
613 ['isamplerCube', '', 'highp', '', 'float(textureSize(uniformValue,0).r)', gl.INT_SAMPLER_CUBE, 1, false],
614 ['isampler2DArray', '', 'highp', '', 'float(textureSize(uniformValue,0).r)', gl.INT_SAMPLER_2D_ARRAY, 1, false],
615 ['usampler2D', '', 'highp', '', 'float(textureSize(uniformValue,0).r)', gl.UNSIGNED_INT_SAMPLER_2D, 1, false],
616 ['usampler3D', '', 'highp', '', 'float(textureSize(uniformValue,0).r)', gl.UNSIGNED_INT_SAMPLER_3D, 1, false],
617 ['usamplerCube', '', 'highp', '', 'float(textureSize(uniformValue,0).r)', gl.UNSIGNED_INT_SAMPLER_CUBE, 1, false],
618 ['usampler2DArray', '', 'highp', '', 'float(textureSize(uniformValue,0).r)', gl.UNSIGNED_INT_SAMPLER_2D_ARRAY, 1, false]
622 '#version 300 es\n' +
623 'void main (void)\n' +
625 ' gl_Position = vec4(0.0);\n' +
628 var shaderVert = gl.createShader(gl.VERTEX_SHADER);
629 var shaderFrag = gl.createShader(gl.FRAGMENT_SHADER);
630 var program = gl.createProgram();
632 gl.attachShader(program, shaderVert);
633 gl.attachShader(program, shaderFrag);
635 gl.shaderSource(shaderVert, vertSource);
636 gl.compileShader(shaderVert);
638 for (var ndx = 0; ndx < uniformTypes.length; ++ndx) {
639 var declaration = uniformTypes[ndx][0];
640 var postDeclaration = uniformTypes[ndx][1];
641 var precision = uniformTypes[ndx][2];
642 var layout = uniformTypes[ndx][3];
643 var getter = uniformTypes[ndx][4];
644 var type = uniformTypes[ndx][5];
645 var size = uniformTypes[ndx][6];
646 var isRowMajor = uniformTypes[ndx][7];
647 bufferedLogToConsole('Verify type of ' + declaration + ' variable' + postDeclaration);
649 // gen fragment shader
652 frag += '#version 300 es\n';
653 frag += layout + 'uniform ' + precision + ' ' + declaration + ' uniformValue' + postDeclaration + ';\n';
654 frag += 'layout(location = 0) out mediump vec4 fragColor;\n';
655 frag += 'void main (void)\n';
657 frag += ' fragColor = vec4(' + getter + ');\n';
660 gl.shaderSource(shaderFrag, frag);
664 gl.compileShader(shaderFrag);
665 gl.linkProgram(program);
668 if (this.check(glsStateQuery.verifyProgram(program, gl.LINK_STATUS, true), 'Program link fail' + gl.getProgramInfoLog(program))) {
669 var indices = gl.getUniformIndices(program, ['uniformValue']);
670 var info_type = gl.getActiveUniforms(program, indices, gl.UNIFORM_TYPE)[0];
671 var info_size = gl.getActiveUniforms(program, indices, gl.UNIFORM_SIZE)[0];
672 var info_is_row_major = gl.getActiveUniforms(program, indices, gl.UNIFORM_IS_ROW_MAJOR)[0];
673 this.check(glsStateQuery.compare(info_size, size));
674 this.check(glsStateQuery.compare(info_type, type));
675 this.check(glsStateQuery.compare(info_is_row_major, isRowMajor));
679 gl.deleteShader(shaderVert);
680 gl.deleteShader(shaderFrag);
681 gl.deleteProgram(program);
686 * @extends {es3fApiCase.ApiCase}
687 * @param {string} name
688 * @param {string} description
690 es3fShaderStateQueryTests.ProgramActiveUniformBlocksCase = function(name, description) {
691 es3fApiCase.ApiCase.call(this, name, description, gl);
694 setParentClass(es3fShaderStateQueryTests.ProgramActiveUniformBlocksCase, es3fApiCase.ApiCase);
696 es3fShaderStateQueryTests.ProgramActiveUniformBlocksCase.prototype.test = function() {
698 '#version 300 es\n' +
699 'uniform longlongUniformBlockName {highp vec2 vector2;} longlongUniformInstanceName;\n' +
700 'uniform shortUniformBlockName {highp vec2 vector2;highp vec4 vector4;} shortUniformInstanceName;\n' +
701 'void main (void)\n' +
703 ' gl_Position = shortUniformInstanceName.vector4 + vec4(longlongUniformInstanceName.vector2.x) + vec4(shortUniformInstanceName.vector2.x);\n' +
706 '#version 300 es\n' +
707 'uniform longlongUniformBlockName {highp vec2 vector2;} longlongUniformInstanceName;\n' +
708 'layout(location = 0) out mediump vec4 fragColor;' +
709 'void main (void)\n' +
711 ' fragColor = vec4(longlongUniformInstanceName.vector2.y);\n' +
714 var shaderVert = gl.createShader(gl.VERTEX_SHADER);
715 var shaderFrag = gl.createShader(gl.FRAGMENT_SHADER);
717 gl.shaderSource(shaderVert, testVertSource);
718 gl.shaderSource(shaderFrag, testFragSource);
720 gl.compileShader(shaderVert);
721 gl.compileShader(shaderFrag);
723 var program = gl.createProgram();
724 gl.attachShader(program, shaderVert);
725 gl.attachShader(program, shaderFrag);
726 gl.linkProgram(program);
728 this.check(glsStateQuery.verifyShader(shaderVert, gl.COMPILE_STATUS, true));
729 this.check(glsStateQuery.verifyShader(shaderFrag, gl.COMPILE_STATUS, true));
730 this.check(glsStateQuery.verifyProgram(program, gl.LINK_STATUS, true));
732 this.check(glsStateQuery.verifyProgram(program, gl.ACTIVE_UNIFORM_BLOCKS, 2));
734 var longlongUniformBlockIndex = gl.getUniformBlockIndex(program, 'longlongUniformBlockName');
735 var shortUniformBlockIndex = gl.getUniformBlockIndex(program, 'shortUniformBlockName');
738 'longlongUniformBlockName.vector2',
739 'shortUniformBlockName.vector2',
740 'shortUniformBlockName.vector4'
743 // test UNIFORM_BLOCK_INDEX
745 var uniformIndices = gl.getUniformIndices(program, uniformNames);
747 var uniformsBlockIndices = gl.getActiveUniforms(program, uniformIndices, gl.UNIFORM_BLOCK_INDEX);
748 this.check(uniformsBlockIndices[0] == longlongUniformBlockIndex &&
749 uniformsBlockIndices[1] == shortUniformBlockIndex &&
750 uniformsBlockIndices[2] == shortUniformBlockIndex,
751 'Expected [' + longlongUniformBlockIndex + ", " + shortUniformBlockIndex + ", " + shortUniformBlockIndex + ']; got ' +
752 uniformsBlockIndices[0] + ", " + uniformsBlockIndices[1] + ", " + uniformsBlockIndices[2] + "]");
754 // test UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER & UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER
756 this.check(glsStateQuery.verifyActiveUniformBlock(program, longlongUniformBlockIndex, gl.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER, true));
757 this.check(glsStateQuery.verifyActiveUniformBlock(program, longlongUniformBlockIndex, gl.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER, true));
758 this.check(glsStateQuery.verifyActiveUniformBlock(program, shortUniformBlockIndex, gl.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER, true));
759 this.check(glsStateQuery.verifyActiveUniformBlock(program, shortUniformBlockIndex, gl.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER, false));
761 // test UNIFORM_BLOCK_ACTIVE_UNIFORMS
763 this.check(glsStateQuery.verifyActiveUniformBlock(program, longlongUniformBlockIndex, gl.UNIFORM_BLOCK_ACTIVE_UNIFORMS, 1));
764 this.check(glsStateQuery.verifyActiveUniformBlock(program, shortUniformBlockIndex, gl.UNIFORM_BLOCK_ACTIVE_UNIFORMS, 2));
766 // test UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES
768 var shortUniformBlockIndices = gl.getActiveUniformBlockParameter(program, shortUniformBlockIndex, gl.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES);
769 this.check(shortUniformBlockIndices.length == 2, 'Expected 2 indices; got ' + shortUniformBlockIndices.length);
771 this.check(glsStateQuery.compare(shortUniformBlockIndices, new Uint32Array([uniformIndices[1], uniformIndices[2]])) ||
772 glsStateQuery.compare(shortUniformBlockIndices, new Uint32Array([uniformIndices[2], uniformIndices[1]])),
773 'Expected { ' + uniformIndices[1] +', ' + uniformIndices[2] +
774 '}; got {' + shortUniformBlockIndices[0] + ', ' + shortUniformBlockIndices[1] + '}');
778 var name = gl.getActiveUniformBlockName(program, longlongUniformBlockIndex);
779 this.check(name == "longlongUniformBlockName", 'Wrong uniform block name, expected longlongUniformBlockName; got ' + name);
780 name = gl.getActiveUniformBlockName(program, shortUniformBlockIndex)
781 this.check(name == "shortUniformBlockName", 'Wrong uniform block name, expected shortUniformBlockName; got ' + name);
783 gl.deleteShader(shaderVert);
784 gl.deleteShader(shaderFrag);
785 gl.deleteProgram(program);
790 * @extends {es3fApiCase.ApiCase}
791 * @param {string} name
792 * @param {string} description
794 es3fShaderStateQueryTests.TransformFeedbackCase = function(name, description) {
795 es3fApiCase.ApiCase.call(this, name, description, gl);
798 setParentClass(es3fShaderStateQueryTests.TransformFeedbackCase, es3fApiCase.ApiCase);
800 es3fShaderStateQueryTests.TransformFeedbackCase.prototype.test = function() {
801 var transformFeedbackTestVertSource =
802 '#version 300 es\n' +
803 'out highp vec4 tfOutput2withLongName;\n' +
804 'void main (void)\n' +
806 ' gl_Position = vec4(0.0);\n' +
807 ' tfOutput2withLongName = vec4(0.0);\n' +
809 var transformFeedbackTestFragSource =
810 '#version 300 es\n' +
811 'layout(location = 0) out highp vec4 fragColor;\n' +
812 'void main (void)\n' +
814 ' fragColor = vec4(0.0);\n' +
817 var shaderVert = gl.createShader(gl.VERTEX_SHADER);
818 var shaderFrag = gl.createShader(gl.FRAGMENT_SHADER);
819 var shaderProg = gl.createProgram();
821 this.check(glsStateQuery.verifyProgram(shaderProg, gl.TRANSFORM_FEEDBACK_BUFFER_MODE, gl.INTERLEAVED_ATTRIBS));
823 gl.shaderSource(shaderVert, transformFeedbackTestVertSource);
824 gl.shaderSource(shaderFrag, transformFeedbackTestFragSource);
826 gl.compileShader(shaderVert);
827 gl.compileShader(shaderFrag);
829 this.check(glsStateQuery.verifyShader(shaderVert, gl.COMPILE_STATUS, true));
830 this.check(glsStateQuery.verifyShader(shaderFrag, gl.COMPILE_STATUS, true));
832 gl.attachShader(shaderProg, shaderVert);
833 gl.attachShader(shaderProg, shaderFrag);
835 // check TRANSFORM_FEEDBACK_BUFFER_MODE
837 var transform_feedback_outputs = ['gl_Position', 'tfOutput2withLongName'];
838 var bufferModes = [gl.SEPARATE_ATTRIBS, gl.INTERLEAVED_ATTRIBS];
840 for (var ndx = 0; ndx < bufferModes.length; ++ndx) {
841 gl.transformFeedbackVaryings(shaderProg, transform_feedback_outputs, bufferModes[ndx]);
842 gl.linkProgram(shaderProg);
844 this.check(glsStateQuery.verifyProgram(shaderProg, gl.LINK_STATUS, true));
845 this.check(glsStateQuery.verifyProgram(shaderProg, gl.TRANSFORM_FEEDBACK_BUFFER_MODE, bufferModes[ndx]));
849 var varyings = /** @type {number} */ (gl.getProgramParameter(shaderProg, gl.TRANSFORM_FEEDBACK_VARYINGS));
850 this.check(varyings === 2);
852 for (var index = 0; index < varyings; ++index) {
853 var info = gl.getTransformFeedbackVarying(shaderProg, index);
854 this.check(glsStateQuery.compare(info.type, gl.FLOAT_VEC4));
855 this.check(glsStateQuery.compare(info.size, 1));
856 this.check(glsStateQuery.compare(info.name, transform_feedback_outputs[index]));
859 gl.deleteShader(shaderVert);
860 gl.deleteShader(shaderFrag);
861 gl.deleteProgram(shaderProg);
863 // TODO(kbr): this test is failing and leaving an error in the GL
864 // state, causing later tests to fail. Clear the error state for
866 while (gl.getError() != gl.NO_ERROR) {}
871 * @extends {es3fApiCase.ApiCase}
872 * @param {string} name
873 * @param {string} description
875 es3fShaderStateQueryTests.ActiveAttributesCase = function(name, description) {
876 es3fApiCase.ApiCase.call(this, name, description, gl);
879 setParentClass(es3fShaderStateQueryTests.ActiveAttributesCase, es3fApiCase.ApiCase);
881 es3fShaderStateQueryTests.ActiveAttributesCase.prototype.test = function() {
883 '#version 300 es\n' +
884 'in highp vec2 longInputAttributeName;\n' +
885 'in highp vec2 shortName;\n' +
886 'void main (void)\n' +
888 ' gl_Position = longInputAttributeName.yxxy + shortName.xyxy;\n' +
891 '#version 300 es\n' +
892 'layout(location = 0) out mediump vec4 fragColor;' +
893 'void main (void)\n' +
895 ' fragColor = vec4(0.0);\n' +
898 var shaderVert = gl.createShader(gl.VERTEX_SHADER);
899 var shaderFrag = gl.createShader(gl.FRAGMENT_SHADER);
901 gl.shaderSource(shaderVert, testVertSource);
902 gl.shaderSource(shaderFrag, testFragSource);
904 gl.compileShader(shaderVert);
905 gl.compileShader(shaderFrag);
907 var program = gl.createProgram();
908 gl.attachShader(program, shaderVert);
909 gl.attachShader(program, shaderFrag);
910 gl.linkProgram(program);
912 this.check(glsStateQuery.verifyProgram(program, gl.ACTIVE_ATTRIBUTES, 2));
915 'longInputAttributeName',
919 for (var attributeNdx = 0; attributeNdx < 2; ++attributeNdx) {
920 var info = gl.getActiveAttrib(program, attributeNdx);
921 this.check(glsStateQuery.compare(info.name, attribNames[0]) || glsStateQuery.compare(info.name, attribNames[1]));
924 gl.deleteShader(shaderVert);
925 gl.deleteShader(shaderFrag);
926 gl.deleteProgram(program);
931 * @extends {es3fApiCase.ApiCase}
932 * @param {string} name
933 * @param {string} description
935 es3fShaderStateQueryTests.VertexAttributeSizeCase = function(name, description) {
936 es3fApiCase.ApiCase.call(this, name, description, gl);
939 setParentClass(es3fShaderStateQueryTests.VertexAttributeSizeCase, es3fApiCase.ApiCase);
941 es3fShaderStateQueryTests.VertexAttributeSizeCase.prototype.test = function() {
944 [4, gl.FLOAT, 0, false, 0],
945 [3, gl.FLOAT, 0, false, 0],
946 [2, gl.FLOAT, 0, false, 0],
947 [1, gl.FLOAT, 0, false, 0],
948 [4, gl.INT, 0, false, 0],
949 [3, gl.INT, 0, false, 0],
950 [2, gl.INT, 0, false, 0],
951 [1, gl.INT, 0, false, 0]
954 var buf = gl.createBuffer();
955 gl.bindBuffer(gl.ARRAY_BUFFER, buf);
957 // Test with default VAO
959 for (var ndx = 0; ndx < pointers.length; ++ndx) {
960 gl.vertexAttribPointer(0, pointers[ndx][0], pointers[ndx][1], pointers[ndx][3], pointers[ndx][2], pointers[ndx][4]);
961 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_SIZE, pointers[ndx][0]));
964 // Test with multiple VAOs
965 var vao0 = gl.createVertexArray();
966 var vao1 = gl.createVertexArray();
969 gl.bindVertexArray(vao0);
970 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_SIZE, 4));
972 // set vao 0 to some value
973 gl.vertexAttribPointer(0, pointers[0][0], pointers[0][1], pointers[0][3], pointers[0][2], 0);
975 // set vao 1 to some other value
976 gl.bindVertexArray(vao1);
977 gl.vertexAttribPointer(0, pointers[1][0], pointers[1][1], pointers[1][3], pointers[1][2], 0);
979 // verify vao 1 state
980 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_SIZE, pointers[1][0]));
982 // verify vao 0 state
983 gl.bindVertexArray(vao0);
984 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_SIZE, pointers[0][0]));
986 gl.deleteVertexArray(vao0);
987 gl.deleteVertexArray(vao1);
988 gl.deleteBuffer(buf);
993 * @extends {es3fApiCase.ApiCase}
994 * @param {string} name
995 * @param {string} description
997 es3fShaderStateQueryTests.VertexAttributeTypeCase = function(name, description) {
998 es3fApiCase.ApiCase.call(this, name, description, gl);
1001 setParentClass(es3fShaderStateQueryTests.VertexAttributeTypeCase, es3fApiCase.ApiCase);
1003 es3fShaderStateQueryTests.VertexAttributeTypeCase.prototype.test = function() {
1006 [1, gl.BYTE, 0, false, 0],
1007 [1, gl.SHORT, 0, false, 0],
1008 [1, gl.INT, 0, false, 0],
1009 [1, gl.FLOAT, 0, false, 0],
1010 [1, gl.HALF_FLOAT, 0, false, 0],
1011 [1, gl.UNSIGNED_BYTE, 0, false, 0],
1012 [1, gl.UNSIGNED_SHORT, 0, false, 0],
1013 [1, gl.UNSIGNED_INT, 0, false, 0],
1014 [4, gl.INT_2_10_10_10_REV, 0, false, 0],
1015 [4, gl.UNSIGNED_INT_2_10_10_10_REV, 0, false, 0]
1018 var buf = gl.createBuffer();
1019 gl.bindBuffer(gl.ARRAY_BUFFER, buf);
1021 // Test with default VAO
1023 for (var ndx = 0; ndx < pointers.length; ++ndx) {
1024 gl.vertexAttribPointer(0, pointers[ndx][0], pointers[ndx][1], pointers[ndx][3], pointers[ndx][2], pointers[ndx][4]);
1025 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_TYPE, pointers[ndx][1]));
1029 [1, gl.BYTE, 0, false, 0],
1030 [1, gl.SHORT, 0, false, 0],
1031 [1, gl.INT, 0, false, 0],
1032 [1, gl.UNSIGNED_BYTE, 0, false, 0],
1033 [1, gl.UNSIGNED_SHORT, 0, false, 0],
1034 [1, gl.UNSIGNED_INT, 0, false, 0]
1037 for (var ndx = 0; ndx < pointersI.length; ++ndx) {
1038 gl.vertexAttribIPointer(0, pointersI[ndx][0], pointersI[ndx][1], pointersI[ndx][2], pointersI[ndx][4]);
1039 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_TYPE, pointersI[ndx][1]));
1042 // Test with multiple VAOs
1043 var vao0 = gl.createVertexArray();
1044 var vao1 = gl.createVertexArray();
1047 gl.bindVertexArray(vao0);
1048 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_TYPE, gl.FLOAT));
1050 // set vao 0 to some value
1051 gl.vertexAttribPointer(0, 1, gl.FLOAT, false, 0, 0);
1053 // set vao 1 to some other value
1054 gl.bindVertexArray(vao1);
1055 gl.vertexAttribPointer(0, 1, gl.SHORT, false, 0, 0);
1057 // verify vao 1 state
1058 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_TYPE, gl.SHORT));
1060 // verify vao 0 state
1061 gl.bindVertexArray(vao0);
1062 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_TYPE, gl.FLOAT));
1064 gl.deleteVertexArray(vao0);
1065 gl.deleteVertexArray(vao1);
1066 gl.deleteBuffer(buf);
1071 * @extends {es3fApiCase.ApiCase}
1072 * @param {string} name
1073 * @param {string} description
1075 es3fShaderStateQueryTests.VertexAttributeStrideCase = function(name, description) {
1076 es3fApiCase.ApiCase.call(this, name, description, gl);
1079 setParentClass(es3fShaderStateQueryTests.VertexAttributeStrideCase, es3fApiCase.ApiCase);
1081 es3fShaderStateQueryTests.VertexAttributeStrideCase.prototype.test = function() {
1083 [1, gl.FLOAT, 0, 0, gl.NO_ERROR],
1084 [1, gl.FLOAT, 1, 0, gl.INVALID_OPERATION],
1085 [1, gl.FLOAT, 4, 0, gl.NO_ERROR],
1086 [1, gl.HALF_FLOAT, 0, 0, gl.NO_ERROR],
1087 [1, gl.HALF_FLOAT, 1, 0, gl.INVALID_OPERATION],
1088 [1, gl.HALF_FLOAT, 4, 0, gl.NO_ERROR]
1091 var buf = gl.createBuffer();
1092 gl.bindBuffer(gl.ARRAY_BUFFER, buf);
1094 // Test with default VAO
1096 for (var ndx = 0; ndx < pointers.length; ++ndx) {
1097 gl.vertexAttribPointer(0, pointers[ndx][0], pointers[ndx][1], false, pointers[ndx][2], pointers[ndx][3]);
1098 this.expectError(pointers[ndx][4]);
1099 if (pointers[ndx][4] == gl.NO_ERROR) {
1100 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_STRIDE, pointers[ndx][2]));
1105 [1, gl.INT, 0, 0, gl.NO_ERROR],
1106 [1, gl.INT, 1, 0, gl.INVALID_OPERATION],
1107 [1, gl.INT, 4, 0, gl.NO_ERROR],
1108 [4, gl.UNSIGNED_BYTE, 0, 0, gl.NO_ERROR],
1109 [4, gl.UNSIGNED_BYTE, 1, 0, gl.NO_ERROR],
1110 [4, gl.UNSIGNED_BYTE, 4, 0, gl.NO_ERROR],
1111 [2, gl.SHORT, 0, 0, gl.NO_ERROR],
1112 [2, gl.SHORT, 1, 0, gl.INVALID_OPERATION],
1113 [2, gl.SHORT, 4, 0, gl.NO_ERROR]
1116 for (var ndx = 0; ndx < pointersI.length; ++ndx) {
1117 gl.vertexAttribIPointer(0, pointersI[ndx][0], pointersI[ndx][1], pointersI[ndx][2], pointersI[ndx][3]);
1118 this.expectError(pointersI[ndx][4]);
1119 if (pointersI[ndx][4] == gl.NO_ERROR) {
1120 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_STRIDE, pointersI[ndx][2]));
1124 // Test with multiple VAOs
1125 var vao0 = gl.createVertexArray();
1126 var vao1 = gl.createVertexArray();
1129 gl.bindVertexArray(vao0);
1130 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_STRIDE, 0));
1132 // set vao 0 to some value
1133 gl.vertexAttribPointer(0, 1, gl.FLOAT, false, 4, 0);
1135 // set vao 1 to some other value
1136 gl.bindVertexArray(vao1);
1137 gl.vertexAttribPointer(0, 1, gl.SHORT, false, 8, 0);
1139 // verify vao 1 state
1140 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_STRIDE, 8));
1142 // verify vao 0 state
1143 gl.bindVertexArray(vao0);
1144 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_STRIDE, 4));
1146 gl.deleteVertexArray(vao0);
1147 gl.deleteVertexArray(vao1);
1148 gl.deleteBuffer(buf);
1153 * @extends {es3fApiCase.ApiCase}
1154 * @param {string} name
1155 * @param {string} description
1157 es3fShaderStateQueryTests.VertexAttributeNormalizedCase = function(name, description) {
1158 es3fApiCase.ApiCase.call(this, name, description, gl);
1161 setParentClass(es3fShaderStateQueryTests.VertexAttributeNormalizedCase, es3fApiCase.ApiCase);
1163 es3fShaderStateQueryTests.VertexAttributeNormalizedCase.prototype.test = function() {
1166 [1, gl.BYTE, 0, false, 0],
1167 [1, gl.SHORT, 0, false, 0],
1168 [1, gl.INT, 0, false, 0],
1169 [1, gl.FLOAT, 0, false, 0],
1170 [1, gl.HALF_FLOAT, 0, false, 0],
1171 [1, gl.UNSIGNED_BYTE, 0, false, 0],
1172 [1, gl.UNSIGNED_SHORT, 0, false, 0],
1173 [1, gl.UNSIGNED_INT, 0, false, 0],
1174 [4, gl.INT_2_10_10_10_REV, 0, false, 0],
1175 [4, gl.UNSIGNED_INT_2_10_10_10_REV, 0, false, 0],
1176 [1, gl.BYTE, 0, true, 0],
1177 [1, gl.SHORT, 0, true, 0],
1178 [1, gl.INT, 0, true, 0],
1179 [1, gl.FLOAT, 0, true, 0],
1180 [1, gl.HALF_FLOAT, 0, true, 0],
1181 [1, gl.UNSIGNED_BYTE, 0, true, 0],
1182 [1, gl.UNSIGNED_SHORT, 0, true, 0],
1183 [1, gl.UNSIGNED_INT, 0, true, 0],
1184 [4, gl.INT_2_10_10_10_REV, 0, true, 0],
1185 [4, gl.UNSIGNED_INT_2_10_10_10_REV, 0, true, 0]
1188 var buf = gl.createBuffer();
1189 gl.bindBuffer(gl.ARRAY_BUFFER, buf);
1191 // Test with default VAO
1193 for (var ndx = 0; ndx < pointers.length; ++ndx) {
1194 gl.vertexAttribPointer(0, pointers[ndx][0], pointers[ndx][1], pointers[ndx][3], pointers[ndx][2], pointers[ndx][4]);
1195 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_NORMALIZED, pointers[ndx][3]));
1199 [1, gl.BYTE, 0, false, 0],
1200 [1, gl.SHORT, 0, false, 0],
1201 [1, gl.INT, 0, false, 0],
1202 [1, gl.UNSIGNED_BYTE, 0, false, 0],
1203 [1, gl.UNSIGNED_SHORT, 0, false, 0],
1204 [1, gl.UNSIGNED_INT, 0, false, 0]
1207 for (var ndx = 0; ndx < pointersI.length; ++ndx) {
1208 gl.vertexAttribIPointer(0, pointersI[ndx][0], pointersI[ndx][1], pointersI[ndx][2], pointersI[ndx][4]);
1209 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_NORMALIZED, false));
1212 // Test with multiple VAOs
1213 var vao0 = gl.createVertexArray();
1214 var vao1 = gl.createVertexArray();
1217 gl.bindVertexArray(vao0);
1218 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_NORMALIZED, false));
1220 // set vao 0 to some value
1221 gl.vertexAttribPointer(0, 1, gl.INT, true, 0, 0);
1223 // set vao 1 to some other value
1224 gl.bindVertexArray(vao1);
1225 gl.vertexAttribPointer(0, 1, gl.INT, false, 0, 0);
1227 // verify vao 1 state
1228 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_NORMALIZED, false));
1230 // verify vao 0 state
1231 gl.bindVertexArray(vao0);
1232 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_NORMALIZED, true));
1234 gl.deleteVertexArray(vao0);
1235 gl.deleteVertexArray(vao1);
1236 gl.deleteBuffer(buf);
1241 * @extends {es3fApiCase.ApiCase}
1242 * @param {string} name
1243 * @param {string} description
1245 es3fShaderStateQueryTests.VertexAttributeIntegerCase = function(name, description) {
1246 es3fApiCase.ApiCase.call(this, name, description, gl);
1249 setParentClass(es3fShaderStateQueryTests.VertexAttributeIntegerCase, es3fApiCase.ApiCase);
1251 es3fShaderStateQueryTests.VertexAttributeIntegerCase.prototype.test = function() {
1254 [1, gl.BYTE, 0, false, 0],
1255 [1, gl.SHORT, 0, false, 0],
1256 [1, gl.INT, 0, false, 0],
1257 [1, gl.FLOAT, 0, false, 0],
1258 [1, gl.HALF_FLOAT, 0, false, 0],
1259 [1, gl.UNSIGNED_BYTE, 0, false, 0],
1260 [1, gl.UNSIGNED_SHORT, 0, false, 0],
1261 [1, gl.UNSIGNED_INT, 0, false, 0],
1262 [4, gl.INT_2_10_10_10_REV, 0, false, 0],
1263 [4, gl.UNSIGNED_INT_2_10_10_10_REV, 0, false, 0]
1266 var buf = gl.createBuffer();
1267 gl.bindBuffer(gl.ARRAY_BUFFER, buf);
1269 // Test with default VAO
1271 for (var ndx = 0; ndx < pointers.length; ++ndx) {
1272 gl.vertexAttribPointer(0, pointers[ndx][0], pointers[ndx][1], pointers[ndx][3], pointers[ndx][2], pointers[ndx][4]);
1273 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_INTEGER, false));
1277 [1, gl.BYTE, 0, false, 0],
1278 [1, gl.SHORT, 0, false, 0],
1279 [1, gl.INT, 0, false, 0],
1280 [1, gl.UNSIGNED_BYTE, 0, false, 0],
1281 [1, gl.UNSIGNED_SHORT, 0, false, 0],
1282 [1, gl.UNSIGNED_INT, 0, false, 0]
1285 for (var ndx = 0; ndx < pointersI.length; ++ndx) {
1286 gl.vertexAttribIPointer(0, pointersI[ndx][0], pointersI[ndx][1], pointersI[ndx][2], pointersI[ndx][4]);
1287 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_INTEGER, true));
1290 // Test with multiple VAOs
1291 var vao0 = gl.createVertexArray();
1292 var vao1 = gl.createVertexArray();
1295 gl.bindVertexArray(vao0);
1296 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_INTEGER, false));
1298 // set vao 0 to some value
1299 gl.vertexAttribIPointer(0, 1, gl.INT, 0, 0);
1301 // set vao 1 to some other value
1302 gl.bindVertexArray(vao1);
1303 gl.vertexAttribPointer(0, 1, gl.FLOAT, false, 0, 0);
1305 // verify vao 1 state
1306 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_INTEGER, false));
1308 // verify vao 0 state
1309 gl.bindVertexArray(vao0);
1310 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_INTEGER, true));
1312 gl.deleteVertexArray(vao0);
1313 gl.deleteVertexArray(vao1);
1314 gl.deleteBuffer(buf);
1319 * @extends {es3fApiCase.ApiCase}
1320 * @param {string} name
1321 * @param {string} description
1323 es3fShaderStateQueryTests.VertexAttributeEnabledCase = function(name, description) {
1324 es3fApiCase.ApiCase.call(this, name, description, gl);
1327 setParentClass(es3fShaderStateQueryTests.VertexAttributeEnabledCase, es3fApiCase.ApiCase);
1329 es3fShaderStateQueryTests.VertexAttributeEnabledCase.prototype.test = function() {
1330 // Test with default VAO
1332 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_ENABLED, false));
1333 gl.enableVertexAttribArray(0);
1334 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_ENABLED, true));
1335 gl.disableVertexAttribArray(0);
1336 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_ENABLED, false));
1338 // Test with multiple VAOs
1339 var vao0 = gl.createVertexArray();
1340 var vao1 = gl.createVertexArray();
1343 gl.bindVertexArray(vao0);
1344 // set vao 0 to some value
1345 gl.enableVertexAttribArray(0);
1347 // set vao 1 to some other value
1348 gl.bindVertexArray(vao1);
1349 gl.disableVertexAttribArray(0);
1351 // verify vao 1 state
1352 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_ENABLED, false));
1354 // verify vao 0 state
1355 gl.bindVertexArray(vao0);
1356 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_ENABLED, true));
1358 gl.deleteVertexArray(vao0);
1359 gl.deleteVertexArray(vao1);
1364 * @extends {es3fApiCase.ApiCase}
1365 * @param {string} name
1366 * @param {string} description
1368 es3fShaderStateQueryTests.VertexAttributeDivisorCase = function(name, description) {
1369 es3fApiCase.ApiCase.call(this, name, description, gl);
1372 setParentClass(es3fShaderStateQueryTests.VertexAttributeDivisorCase, es3fApiCase.ApiCase);
1374 es3fShaderStateQueryTests.VertexAttributeDivisorCase.prototype.test = function() {
1375 // Test with default VAO
1377 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_DIVISOR, 0));
1378 gl.vertexAttribDivisor(0, 1);
1379 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_DIVISOR, 1));
1380 gl.vertexAttribDivisor(0, 5);
1381 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_DIVISOR, 5));
1383 // Test with multiple VAOs
1384 var vao0 = gl.createVertexArray();
1385 var vao1 = gl.createVertexArray();
1388 gl.bindVertexArray(vao0);
1389 // set vao 0 to some value
1390 gl.vertexAttribDivisor(0, 1);
1392 // set vao 1 to some other value
1393 gl.bindVertexArray(vao1);
1394 gl.vertexAttribDivisor(0, 5);
1396 // verify vao 1 state
1397 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_DIVISOR, 5));
1399 // verify vao 0 state
1400 gl.bindVertexArray(vao0);
1401 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_DIVISOR, 1));
1403 gl.deleteVertexArray(vao0);
1404 gl.deleteVertexArray(vao1);
1409 * @extends {es3fApiCase.ApiCase}
1410 * @param {string} name
1411 * @param {string} description
1413 es3fShaderStateQueryTests.VertexAttributeBufferBindingCase = function(name, description) {
1414 es3fApiCase.ApiCase.call(this, name, description, gl);
1417 setParentClass(es3fShaderStateQueryTests.VertexAttributeBufferBindingCase, es3fApiCase.ApiCase);
1419 es3fShaderStateQueryTests.VertexAttributeBufferBindingCase.prototype.test = function() {
1420 // Test with default VAO
1422 var buffer = gl.createBuffer();
1423 gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
1425 gl.vertexAttribPointer(0, 4, gl.FLOAT, false, 0, 0);
1427 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, buffer));
1429 gl.deleteBuffer(buffer);
1431 // Test with multiple VAOs
1432 var vao0 = gl.createVertexArray();
1433 var vao1 = gl.createVertexArray();
1434 var buffer0 = gl.createBuffer();
1435 var buffer1 = gl.createBuffer();
1438 gl.bindVertexArray(vao0);
1439 // set vao 0 to some value
1440 gl.bindBuffer(gl.ARRAY_BUFFER, buffer0);
1441 gl.vertexAttribPointer(0, 4, gl.FLOAT, false, 0, 0);
1443 // set vao 1 to some other value
1444 gl.bindVertexArray(vao1);
1445 gl.bindBuffer(gl.ARRAY_BUFFER, buffer1);
1446 gl.vertexAttribPointer(0, 4, gl.FLOAT, false, 0, 0);
1448 // verify vao 1 state
1449 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, buffer1));
1451 // verify vao 0 state
1452 gl.bindVertexArray(vao0);
1453 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, buffer0));
1455 gl.deleteVertexArray(vao0);
1456 gl.deleteVertexArray(vao1);
1457 gl.deleteBuffer(buffer0);
1458 gl.deleteBuffer(buffer1);
1463 * @extends {es3fApiCase.ApiCase}
1464 * @param {string} name
1465 * @param {string} description
1467 es3fShaderStateQueryTests.VertexAttributeOffsetCase = function(name, description) {
1468 es3fApiCase.ApiCase.call(this, name, description, gl);
1471 setParentClass(es3fShaderStateQueryTests.VertexAttributeOffsetCase, es3fApiCase.ApiCase);
1473 es3fShaderStateQueryTests.VertexAttributeOffsetCase.prototype.test = function() {
1475 [1, gl.BYTE, 0, false, 2 * 4],
1476 [1, gl.SHORT, 0, false, 1 * 4],
1477 [1, gl.INT, 0, false, 2 * 4],
1478 [1, gl.FLOAT, 0, false, 0 * 4],
1479 [1, gl.FLOAT, 0, false, 3 * 4],
1480 [1, gl.FLOAT, 0, false, 2 * 4],
1481 [1, gl.HALF_FLOAT, 0, false, 0 * 4],
1482 [4, gl.HALF_FLOAT, 0, false, 1 * 4],
1483 [4, gl.HALF_FLOAT, 0, false, 2 * 4]
1486 var buf = gl.createBuffer();
1487 gl.bindBuffer(gl.ARRAY_BUFFER, buf);
1489 // Test with default VAO
1491 for (var ndx = 0; ndx < pointers.length; ++ndx) {
1492 gl.vertexAttribPointer(0, pointers[ndx][0], pointers[ndx][1], pointers[ndx][3], pointers[ndx][2], pointers[ndx][4]);
1493 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_POINTER, pointers[ndx][4]));
1496 // Test with multiple VAOs
1497 var vao0 = gl.createVertexArray();
1498 var vao1 = gl.createVertexArray();
1501 gl.bindVertexArray(vao0);
1502 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_POINTER, 0));
1504 // set vao 0 to some value
1505 gl.vertexAttribPointer(0, 4, gl.FLOAT, false, 0, 8);
1507 // set vao 1 to some other value
1508 gl.bindVertexArray(vao1);
1509 gl.vertexAttribPointer(0, 4, gl.FLOAT, false, 0, 4);
1511 // verify vao 1 state
1512 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_POINTER, 4));
1514 // verify vao 0 state
1515 gl.bindVertexArray(vao0);
1516 this.check(glsStateQuery.verifyVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_POINTER, 8));
1518 gl.deleteVertexArray(vao0);
1519 gl.deleteVertexArray(vao1);
1520 gl.deleteBuffer(buf);
1525 * @extends {es3fApiCase.ApiCase}
1526 * @param {string} name
1527 * @param {string} description
1529 es3fShaderStateQueryTests.UniformValueFloatCase = function(name, description) {
1530 es3fApiCase.ApiCase.call(this, name, description, gl);
1533 setParentClass(es3fShaderStateQueryTests.UniformValueFloatCase, es3fApiCase.ApiCase);
1535 es3fShaderStateQueryTests.UniformValueFloatCase.prototype.test = function() {
1536 var testVertSource =
1537 '#version 300 es\n' +
1538 'uniform highp float floatUniform;\n' +
1539 'uniform highp vec2 float2Uniform;\n' +
1540 'uniform highp vec3 float3Uniform;\n' +
1541 'uniform highp vec4 float4Uniform;\n' +
1542 'void main (void)\n' +
1544 ' gl_Position = vec4(floatUniform + float2Uniform.x + float3Uniform.x + float4Uniform.x);\n' +
1546 var testFragSource =
1547 '#version 300 es\n' +
1548 'layout(location = 0) out mediump vec4 fragColor;' +
1549 'void main (void)\n' +
1551 ' fragColor = vec4(0.0);\n' +
1554 var shaderVert = gl.createShader(gl.VERTEX_SHADER);
1555 var shaderFrag = gl.createShader(gl.FRAGMENT_SHADER);
1557 gl.shaderSource(shaderVert, testVertSource);
1558 gl.shaderSource(shaderFrag, testFragSource);
1560 gl.compileShader(shaderVert);
1561 gl.compileShader(shaderFrag);
1563 var program = gl.createProgram();
1564 gl.attachShader(program, shaderVert);
1565 gl.attachShader(program, shaderFrag);
1566 gl.linkProgram(program);
1567 gl.useProgram(program);
1571 location = gl.getUniformLocation(program, 'floatUniform');
1572 gl.uniform1f(location, 1);
1573 this.check(glsStateQuery.verifyUniform(program, location, 1));
1575 location = gl.getUniformLocation(program, 'float2Uniform');
1576 gl.uniform2f(location, 1, 2);
1577 this.check(glsStateQuery.verifyUniform(program, location, new Float32Array([1, 2])));
1579 location = gl.getUniformLocation(program, 'float3Uniform');
1580 gl.uniform3f(location, 1, 2, 3);
1581 this.check(glsStateQuery.verifyUniform(program, location, new Float32Array([1, 2, 3])));
1583 location = gl.getUniformLocation(program, 'float4Uniform');
1584 gl.uniform4f(location, 1, 2, 3, 4);
1585 this.check(glsStateQuery.verifyUniform(program, location, new Float32Array([1, 2, 3, 4])));
1587 gl.useProgram(null);
1588 gl.deleteShader(shaderVert);
1589 gl.deleteShader(shaderFrag);
1590 gl.deleteProgram(program);
1595 * @extends {es3fApiCase.ApiCase}
1596 * @param {string} name
1597 * @param {string} description
1599 es3fShaderStateQueryTests.UniformValueIntCase = function(name, description) {
1600 es3fApiCase.ApiCase.call(this, name, description, gl);
1603 setParentClass(es3fShaderStateQueryTests.UniformValueIntCase, es3fApiCase.ApiCase);
1605 es3fShaderStateQueryTests.UniformValueIntCase.prototype.test = function() {
1606 var testVertSource =
1607 '#version 300 es\n' +
1608 'uniform highp int intUniform;\n' +
1609 'uniform highp ivec2 int2Uniform;\n' +
1610 'uniform highp ivec3 int3Uniform;\n' +
1611 'uniform highp ivec4 int4Uniform;\n' +
1612 'void main (void)\n' +
1614 ' gl_Position = vec4(float(intUniform + int2Uniform.x + int3Uniform.x + int4Uniform.x));\n' +
1616 var testFragSource =
1617 '#version 300 es\n' +
1618 'layout(location = 0) out mediump vec4 fragColor;' +
1619 'void main (void)\n' +
1621 ' fragColor = vec4(0.0);\n' +
1624 var shaderVert = gl.createShader(gl.VERTEX_SHADER);
1625 var shaderFrag = gl.createShader(gl.FRAGMENT_SHADER);
1627 gl.shaderSource(shaderVert, testVertSource);
1628 gl.shaderSource(shaderFrag, testFragSource);
1630 gl.compileShader(shaderVert);
1631 gl.compileShader(shaderFrag);
1633 var program = gl.createProgram();
1634 gl.attachShader(program, shaderVert);
1635 gl.attachShader(program, shaderFrag);
1636 gl.linkProgram(program);
1637 gl.useProgram(program);
1641 location = gl.getUniformLocation(program, 'intUniform');
1642 gl.uniform1i(location, 1);
1643 this.check(glsStateQuery.verifyUniform(program, location, 1));
1645 location = gl.getUniformLocation(program, 'int2Uniform');
1646 gl.uniform2i(location, 1, 2);
1647 this.check(glsStateQuery.verifyUniform(program, location, new Int32Array([1, 2])));
1649 location = gl.getUniformLocation(program, 'int3Uniform');
1650 gl.uniform3i(location, 1, 2, 3);
1651 this.check(glsStateQuery.verifyUniform(program, location, new Int32Array([1, 2, 3])));
1653 location = gl.getUniformLocation(program, 'int4Uniform');
1654 gl.uniform4i(location, 1, 2, 3, 4);
1655 this.check(glsStateQuery.verifyUniform(program, location, new Int32Array([1, 2, 3, 4])));
1657 gl.useProgram(null);
1658 gl.deleteShader(shaderVert);
1659 gl.deleteShader(shaderFrag);
1660 gl.deleteProgram(program);
1665 * @extends {es3fApiCase.ApiCase}
1666 * @param {string} name
1667 * @param {string} description
1669 es3fShaderStateQueryTests.UniformValueUintCase = function(name, description) {
1670 es3fApiCase.ApiCase.call(this, name, description, gl);
1673 setParentClass(es3fShaderStateQueryTests.UniformValueUintCase, es3fApiCase.ApiCase);
1675 es3fShaderStateQueryTests.UniformValueUintCase.prototype.test = function() {
1676 var testVertSource =
1677 '#version 300 es\n' +
1678 'uniform highp uint uintUniform;\n' +
1679 'uniform highp uvec2 uint2Uniform;\n' +
1680 'uniform highp uvec3 uint3Uniform;\n' +
1681 'uniform highp uvec4 uint4Uniform;\n' +
1682 'void main (void)\n' +
1684 ' gl_Position = vec4(float(uintUniform + uint2Uniform.x + uint3Uniform.x + uint4Uniform.x));\n' +
1686 var testFragSource =
1687 '#version 300 es\n' +
1688 'layout(location = 0) out mediump vec4 fragColor;' +
1689 'void main (void)\n' +
1691 ' fragColor = vec4(0.0);\n' +
1694 var shaderVert = gl.createShader(gl.VERTEX_SHADER);
1695 var shaderFrag = gl.createShader(gl.FRAGMENT_SHADER);
1697 gl.shaderSource(shaderVert, testVertSource);
1698 gl.shaderSource(shaderFrag, testFragSource);
1700 gl.compileShader(shaderVert);
1701 gl.compileShader(shaderFrag);
1703 var program = gl.createProgram();
1704 gl.attachShader(program, shaderVert);
1705 gl.attachShader(program, shaderFrag);
1706 gl.linkProgram(program);
1707 gl.useProgram(program);
1711 location = gl.getUniformLocation(program, 'uintUniform');
1712 gl.uniform1ui(location, 1);
1713 this.check(glsStateQuery.verifyUniform(program, location, 1));
1715 location = gl.getUniformLocation(program, 'uint2Uniform');
1716 gl.uniform2ui(location, 1, 2);
1717 this.check(glsStateQuery.verifyUniform(program, location, new Uint32Array([1, 2])));
1719 location = gl.getUniformLocation(program, 'uint3Uniform');
1720 gl.uniform3ui(location, 1, 2, 3);
1721 this.check(glsStateQuery.verifyUniform(program, location, new Uint32Array([1, 2, 3])));
1723 location = gl.getUniformLocation(program, 'uint4Uniform');
1724 gl.uniform4ui(location, 1, 2, 3, 4);
1725 this.check(glsStateQuery.verifyUniform(program, location, new Uint32Array([1, 2, 3, 4])));
1727 gl.useProgram(null);
1728 gl.deleteShader(shaderVert);
1729 gl.deleteShader(shaderFrag);
1730 gl.deleteProgram(program);
1735 * @extends {es3fApiCase.ApiCase}
1736 * @param {string} name
1737 * @param {string} description
1739 es3fShaderStateQueryTests.UniformValueBooleanCase = function(name, description) {
1740 es3fApiCase.ApiCase.call(this, name, description, gl);
1743 setParentClass(es3fShaderStateQueryTests.UniformValueBooleanCase, es3fApiCase.ApiCase);
1745 es3fShaderStateQueryTests.UniformValueBooleanCase.prototype.test = function() {
1746 var testVertSource =
1747 '#version 300 es\n' +
1748 'uniform bool boolUniform;\n' +
1749 'uniform bvec2 bool2Uniform;\n' +
1750 'uniform bvec3 bool3Uniform;\n' +
1751 'uniform bvec4 bool4Uniform;\n' +
1752 'void main (void)\n' +
1754 ' gl_Position = vec4(float(boolUniform) + float(bool2Uniform.x) + float(bool3Uniform.x) + float(bool4Uniform.x));\n' +
1756 var testFragSource =
1757 '#version 300 es\n' +
1758 'layout(location = 0) out mediump vec4 fragColor;' +
1759 'void main (void)\n' +
1761 ' fragColor = vec4(0.0);\n' +
1764 var shaderVert = gl.createShader(gl.VERTEX_SHADER);
1765 var shaderFrag = gl.createShader(gl.FRAGMENT_SHADER);
1767 gl.shaderSource(shaderVert, testVertSource);
1768 gl.shaderSource(shaderFrag, testFragSource);
1770 gl.compileShader(shaderVert);
1771 gl.compileShader(shaderFrag);
1773 var program = gl.createProgram();
1774 gl.attachShader(program, shaderVert);
1775 gl.attachShader(program, shaderFrag);
1776 gl.linkProgram(program);
1777 gl.useProgram(program);
1781 location = gl.getUniformLocation(program, 'boolUniform');
1782 gl.uniform1i(location, 1);
1783 this.check(glsStateQuery.verifyUniform(program, location, true));
1785 location = gl.getUniformLocation(program, 'bool2Uniform');
1786 gl.uniform2i(location, 1, 0);
1787 this.check(glsStateQuery.verifyUniform(program, location, [true, false]));
1789 location = gl.getUniformLocation(program, 'bool3Uniform');
1790 gl.uniform3i(location, 1, 0, 1);
1791 this.check(glsStateQuery.verifyUniform(program, location, [true, false, true]));
1793 location = gl.getUniformLocation(program, 'bool4Uniform');
1794 gl.uniform4i(location, 1, 0, 1, 0);
1795 this.check(glsStateQuery.verifyUniform(program, location, [true, false, true, false]));
1797 gl.useProgram(null);
1798 gl.deleteShader(shaderVert);
1799 gl.deleteShader(shaderFrag);
1800 gl.deleteProgram(program);
1805 * @extends {es3fApiCase.ApiCase}
1806 * @param {string} name
1807 * @param {string} description
1809 es3fShaderStateQueryTests.UniformValueSamplerCase = function(name, description) {
1810 es3fApiCase.ApiCase.call(this, name, description, gl);
1813 setParentClass(es3fShaderStateQueryTests.UniformValueSamplerCase, es3fApiCase.ApiCase);
1815 es3fShaderStateQueryTests.UniformValueSamplerCase.prototype.test = function() {
1816 var testVertSource =
1817 '#version 300 es\n' +
1818 'void main (void)\n' +
1820 ' gl_Position = vec4(0.0);\n' +
1822 var testFragSource =
1823 '#version 300 es\n' +
1824 'uniform highp sampler2D uniformSampler;\n' +
1825 'layout(location = 0) out mediump vec4 fragColor;' +
1826 'void main (void)\n' +
1828 ' fragColor = vec4(textureSize(uniformSampler, 0).x);\n' +
1831 var shaderVert = gl.createShader(gl.VERTEX_SHADER);
1832 var shaderFrag = gl.createShader(gl.FRAGMENT_SHADER);
1834 gl.shaderSource(shaderVert, testVertSource);
1835 gl.shaderSource(shaderFrag, testFragSource);
1837 gl.compileShader(shaderVert);
1838 gl.compileShader(shaderFrag);
1840 var program = gl.createProgram();
1841 gl.attachShader(program, shaderVert);
1842 gl.attachShader(program, shaderFrag);
1843 gl.linkProgram(program);
1844 gl.useProgram(program);
1848 location = gl.getUniformLocation(program, 'uniformSampler');
1849 gl.uniform1i(location, 1);
1850 this.check(glsStateQuery.verifyUniform(program, location, 1));
1852 gl.useProgram(null);
1853 gl.deleteShader(shaderVert);
1854 gl.deleteShader(shaderFrag);
1855 gl.deleteProgram(program);
1860 * @extends {es3fApiCase.ApiCase}
1861 * @param {string} name
1862 * @param {string} description
1864 es3fShaderStateQueryTests.UniformValueArrayCase = function(name, description) {
1865 es3fApiCase.ApiCase.call(this, name, description, gl);
1868 setParentClass(es3fShaderStateQueryTests.UniformValueArrayCase, es3fApiCase.ApiCase);
1870 es3fShaderStateQueryTests.UniformValueArrayCase.prototype.test = function() {
1871 var testVertSource =
1872 '#version 300 es\n' +
1873 'uniform highp float arrayUniform[5];' +
1874 'uniform highp vec2 array2Uniform[5];' +
1875 'uniform highp vec3 array3Uniform[5];' +
1876 'uniform highp vec4 array4Uniform[5];' +
1877 'void main (void)\n' +
1879 ' gl_Position = \n' +
1880 ' + vec4(arrayUniform[0] + arrayUniform[1] + arrayUniform[2] + arrayUniform[3] + arrayUniform[4])\n' +
1881 ' + vec4(array2Uniform[0].x + array2Uniform[1].x + array2Uniform[2].x + array2Uniform[3].x + array2Uniform[4].x)\n' +
1882 ' + vec4(array3Uniform[0].x + array3Uniform[1].x + array3Uniform[2].x + array3Uniform[3].x + array3Uniform[4].x)\n' +
1883 ' + vec4(array4Uniform[0].x + array4Uniform[1].x + array4Uniform[2].x + array4Uniform[3].x + array4Uniform[4].x);\n' +
1885 var testFragSource =
1886 '#version 300 es\n' +
1887 'layout(location = 0) out mediump vec4 fragColor;' +
1888 'void main (void)\n' +
1890 ' fragColor = vec4(0.0);\n' +
1893 var shaderVert = gl.createShader(gl.VERTEX_SHADER);
1894 var shaderFrag = gl.createShader(gl.FRAGMENT_SHADER);
1896 gl.shaderSource(shaderVert, testVertSource);
1897 gl.shaderSource(shaderFrag, testFragSource);
1899 gl.compileShader(shaderVert);
1900 gl.compileShader(shaderFrag);
1902 var program = gl.createProgram();
1903 gl.attachShader(program, shaderVert);
1904 gl.attachShader(program, shaderFrag);
1905 gl.linkProgram(program);
1906 gl.useProgram(program);
1910 var uniformValue = [
1911 -1.0, 0.1, 4.0, 800.0,
1912 13.0, 55.0, 12.0, 91.0,
1913 -55.1, 1.1, 98.0, 19.0,
1914 41.0, 65.0, 4.0, 12.2,
1915 95.0, 77.0, 32.0, 48.0
1918 location = gl.getUniformLocation(program, 'arrayUniform');
1919 gl.uniform1fv(location, new Float32Array(uniformValue.slice(0, 5)));
1921 this.check(glsStateQuery.verifyUniform(program, gl.getUniformLocation(program, 'arrayUniform[0]'), uniformValue[0]));
1922 this.check(glsStateQuery.verifyUniform(program, gl.getUniformLocation(program, 'arrayUniform[1]'), uniformValue[1]));
1923 this.check(glsStateQuery.verifyUniform(program, gl.getUniformLocation(program, 'arrayUniform[2]'), uniformValue[2]));
1924 this.check(glsStateQuery.verifyUniform(program, gl.getUniformLocation(program, 'arrayUniform[3]'), uniformValue[3]));
1925 this.check(glsStateQuery.verifyUniform(program, gl.getUniformLocation(program, 'arrayUniform[4]'), uniformValue[4]));
1927 location = gl.getUniformLocation(program, 'array2Uniform');
1928 gl.uniform2fv(location, new Float32Array(uniformValue.slice(0, 10)));
1930 this.check(glsStateQuery.verifyUniform(program, gl.getUniformLocation(program, 'array2Uniform[0]'), new Float32Array([uniformValue[2 * 0], uniformValue[(2 * 0) + 1]])));
1931 this.check(glsStateQuery.verifyUniform(program, gl.getUniformLocation(program, 'array2Uniform[1]'), new Float32Array([uniformValue[2 * 1], uniformValue[(2 * 1) + 1]])));
1932 this.check(glsStateQuery.verifyUniform(program, gl.getUniformLocation(program, 'array2Uniform[2]'), new Float32Array([uniformValue[2 * 2], uniformValue[(2 * 2) + 1]])));
1933 this.check(glsStateQuery.verifyUniform(program, gl.getUniformLocation(program, 'array2Uniform[3]'), new Float32Array([uniformValue[2 * 3], uniformValue[(2 * 3) + 1]])));
1934 this.check(glsStateQuery.verifyUniform(program, gl.getUniformLocation(program, 'array2Uniform[4]'), new Float32Array([uniformValue[2 * 4], uniformValue[(2 * 4) + 1]])));
1936 location = gl.getUniformLocation(program, 'array3Uniform');
1937 gl.uniform3fv(location, new Float32Array(uniformValue.slice(0, 15)));
1939 this.check(glsStateQuery.verifyUniform(program, gl.getUniformLocation(program, 'array3Uniform[0]'), new Float32Array([uniformValue[3 * 0], uniformValue[(3 * 0) + 1], uniformValue[(3 * 0) + 2]])));
1940 this.check(glsStateQuery.verifyUniform(program, gl.getUniformLocation(program, 'array3Uniform[1]'), new Float32Array([uniformValue[3 * 1], uniformValue[(3 * 1) + 1], uniformValue[(3 * 1) + 2]])));
1941 this.check(glsStateQuery.verifyUniform(program, gl.getUniformLocation(program, 'array3Uniform[2]'), new Float32Array([uniformValue[3 * 2], uniformValue[(3 * 2) + 1], uniformValue[(3 * 2) + 2]])));
1942 this.check(glsStateQuery.verifyUniform(program, gl.getUniformLocation(program, 'array3Uniform[3]'), new Float32Array([uniformValue[3 * 3], uniformValue[(3 * 3) + 1], uniformValue[(3 * 3) + 2]])));
1943 this.check(glsStateQuery.verifyUniform(program, gl.getUniformLocation(program, 'array3Uniform[4]'), new Float32Array([uniformValue[3 * 4], uniformValue[(3 * 4) + 1], uniformValue[(3 * 4) + 2]])));
1945 location = gl.getUniformLocation(program, 'array4Uniform');
1946 gl.uniform4fv(location, new Float32Array(uniformValue));
1948 this.check(glsStateQuery.verifyUniform(program, gl.getUniformLocation(program, 'array4Uniform[0]'), new Float32Array([uniformValue[4 * 0], uniformValue[(4 * 0) + 1], uniformValue[(4 * 0) + 2], uniformValue[(4 * 0) + 3]])));
1949 this.check(glsStateQuery.verifyUniform(program, gl.getUniformLocation(program, 'array4Uniform[1]'), new Float32Array([uniformValue[4 * 1], uniformValue[(4 * 1) + 1], uniformValue[(4 * 1) + 2], uniformValue[(4 * 1) + 3]])));
1950 this.check(glsStateQuery.verifyUniform(program, gl.getUniformLocation(program, 'array4Uniform[2]'), new Float32Array([uniformValue[4 * 2], uniformValue[(4 * 2) + 1], uniformValue[(4 * 2) + 2], uniformValue[(4 * 2) + 3]])));
1951 this.check(glsStateQuery.verifyUniform(program, gl.getUniformLocation(program, 'array4Uniform[3]'), new Float32Array([uniformValue[4 * 3], uniformValue[(4 * 3) + 1], uniformValue[(4 * 3) + 2], uniformValue[(4 * 3) + 3]])));
1952 this.check(glsStateQuery.verifyUniform(program, gl.getUniformLocation(program, 'array4Uniform[4]'), new Float32Array([uniformValue[4 * 4], uniformValue[(4 * 4) + 1], uniformValue[(4 * 4) + 2], uniformValue[(4 * 4) + 3]])));
1954 gl.useProgram(null);
1955 gl.deleteShader(shaderVert);
1956 gl.deleteShader(shaderFrag);
1957 gl.deleteProgram(program);
1962 * @extends {es3fApiCase.ApiCase}
1963 * @param {string} name
1964 * @param {string} description
1966 es3fShaderStateQueryTests.UniformValueMatrixCase = function(name, description) {
1967 es3fApiCase.ApiCase.call(this, name, description, gl);
1970 setParentClass(es3fShaderStateQueryTests.UniformValueMatrixCase, es3fApiCase.ApiCase);
1972 es3fShaderStateQueryTests.UniformValueMatrixCase.prototype.test = function() {
1973 var transpose = function(rows, cols, data) {
1974 var matrix = tcuMatrix.matrixFromDataArray(rows, cols, data);
1976 for (var col = 0; col < cols; col++)
1977 result.push(matrix.getColumn(col));
1978 return new Float32Array([].concat.apply([], result));
1981 var testVertSource =
1982 '#version 300 es\n' +
1983 'uniform highp mat2 mat2Uniform;' +
1984 'uniform highp mat3 mat3Uniform;' +
1985 'uniform highp mat4 mat4Uniform;' +
1986 'void main (void)\n' +
1988 ' gl_Position = vec4(mat2Uniform[0][0] + mat3Uniform[0][0] + mat4Uniform[0][0]);\n' +
1990 var testFragSource =
1991 '#version 300 es\n' +
1992 'layout(location = 0) out mediump vec4 fragColor;' +
1993 'void main (void)\n' +
1995 ' fragColor = vec4(0.0);\n' +
1998 var shaderVert = gl.createShader(gl.VERTEX_SHADER);
1999 var shaderFrag = gl.createShader(gl.FRAGMENT_SHADER);
2001 gl.shaderSource(shaderVert, testVertSource);
2002 gl.shaderSource(shaderFrag, testFragSource);
2004 gl.compileShader(shaderVert);
2005 gl.compileShader(shaderFrag);
2007 var program = gl.createProgram();
2008 gl.attachShader(program, shaderVert);
2009 gl.attachShader(program, shaderFrag);
2010 gl.linkProgram(program);
2011 gl.useProgram(program);
2015 var matrixValues = [
2016 -1.0, 0.1, 4.0, 800.0,
2017 13.0, 55.0, 12.0, 91.0,
2018 -55.1, 1.1, 98.0, 19.0,
2019 41.0, 65.0, 4.0, 12.0
2022 // the values of the matrix are returned in column major order but they can be given in either order
2024 location = gl.getUniformLocation(program, 'mat2Uniform');
2025 var m2 = new Float32Array(matrixValues.slice(0, 2 * 2));
2026 gl.uniformMatrix2fv(location, false, m2);
2027 this.check(glsStateQuery.verifyUniform(program, location, m2));
2028 gl.uniformMatrix2fv(location, true, m2);
2029 this.check(glsStateQuery.verifyUniform(program, location, transpose(2, 2, m2)));
2031 location = gl.getUniformLocation(program, 'mat3Uniform');
2032 var m3 = new Float32Array(matrixValues.slice(0, 3 * 3));
2033 gl.uniformMatrix3fv(location, false, m3);
2034 this.check(glsStateQuery.verifyUniform(program, location, m3));
2035 gl.uniformMatrix3fv(location, true, m3);
2036 this.check(glsStateQuery.verifyUniform(program, location, transpose(3, 3, m3)));
2038 location = gl.getUniformLocation(program, 'mat4Uniform');
2039 var m4 = new Float32Array(matrixValues.slice(0, 4 * 4));
2040 gl.uniformMatrix4fv(location, false, m4);
2041 this.check(glsStateQuery.verifyUniform(program, location, m4));
2042 gl.uniformMatrix4fv(location, true, m4);
2043 this.check(glsStateQuery.verifyUniform(program, location, transpose(4, 4, m4)));
2045 gl.useProgram(null);
2046 gl.deleteShader(shaderVert);
2047 gl.deleteShader(shaderFrag);
2048 gl.deleteProgram(program);
2053 * @extends {es3fApiCase.ApiCase}
2054 * @param {string} name
2055 * @param {string} description
2056 * @param {number} shaderType
2057 * @param {number} precisionType
2059 es3fShaderStateQueryTests.PrecisionFormatCase = function(name, description, shaderType, precisionType) {
2060 es3fApiCase.ApiCase.call(this, name, description, gl);
2061 this.m_shaderType = shaderType;
2062 this.m_precisionType = precisionType;
2065 setParentClass(es3fShaderStateQueryTests.PrecisionFormatCase, es3fApiCase.ApiCase);
2067 es3fShaderStateQueryTests.PrecisionFormatCase.prototype.test = function() {
2068 var requirements = {};
2069 requirements[gl.LOW_FLOAT] = [0, 0, 8];
2070 requirements[gl.MEDIUM_FLOAT] = [13, 13, 10];
2071 requirements[gl.HIGH_FLOAT] = [127, 127, 23];
2072 requirements[gl.LOW_INT] = [8, 7, 0];
2073 requirements[gl.MEDIUM_INT] = [15, 14, 0];
2074 requirements[gl.HIGH_INT] = [31, 30, 0];
2077 var expected = requirements[this.m_precisionType];
2078 var result = gl.getShaderPrecisionFormat(this.m_shaderType, this.m_precisionType);
2080 bufferedLogToConsole('Precision:' +
2081 ' range min = ' + result.rangeMin +
2082 ' range max = ' + result.rangeMax +
2083 ' precision = ' + result.precision);
2085 if (this.m_precisionType == gl.HIGH_FLOAT) {
2086 // highp float must be IEEE 754 single
2088 this.check(result.rangeMin == expected[0] ||
2089 result.rangeMax == expected[1] ||
2090 result.precision == expected[2],
2091 'Invalid precision format, expected:' +
2092 ' range min = ' + expected[0] +
2093 ' range max = ' + expected[1] +
2094 ' precision = ' + expected[2]);
2096 this.check(result.rangeMin >= expected[0] ||
2097 result.rangeMax >= expected[1] ||
2098 result.precision >= expected[2],
2099 'Invalid precision format, expected:' +
2100 ' range min >= ' + expected[0] +
2101 ' range max >= ' + expected[1] +
2102 ' precision >= ' + expected[2]);
2108 * @extends {tcuTestCase.DeqpTest}
2110 es3fShaderStateQueryTests.ShaderStateQueryTests = function() {
2111 tcuTestCase.DeqpTest.call(this, 'shader', 'Shader State Query tests');
2114 es3fShaderStateQueryTests.ShaderStateQueryTests.prototype = Object.create(tcuTestCase.DeqpTest.prototype);
2115 es3fShaderStateQueryTests.ShaderStateQueryTests.prototype.constructor = es3fShaderStateQueryTests.ShaderStateQueryTests;
2117 es3fShaderStateQueryTests.ShaderStateQueryTests.prototype.init = function() {
2119 this.addChild(new es3fShaderStateQueryTests.ShaderTypeCase('shader_type', 'SHADER_TYPE'));
2120 this.addChild(new es3fShaderStateQueryTests.ShaderCompileStatusCase('shader_compile_status', 'COMPILE_STATUS'));
2121 this.addChild(new es3fShaderStateQueryTests.ShaderInfoLogCase('shader_info_log', 'INFO_LOG'));
2122 this.addChild(new es3fShaderStateQueryTests.ShaderSourceCase('shader_source', 'SHADER_SOURCE'));
2124 // shader and program
2125 this.addChild(new es3fShaderStateQueryTests.DeleteStatusCase('delete_status', 'DELETE_STATUS'));
2128 this.addChild(new es3fShaderStateQueryTests.CurrentVertexAttribInitialCase('current_vertex_attrib_initial', 'CURRENT_VERTEX_ATTRIB'));
2129 this.addChild(new es3fShaderStateQueryTests.CurrentVertexAttribFloatCase('current_vertex_attrib_float', 'CURRENT_VERTEX_ATTRIB'));
2130 this.addChild(new es3fShaderStateQueryTests.CurrentVertexAttribIntCase('current_vertex_attrib_int', 'CURRENT_VERTEX_ATTRIB'));
2131 this.addChild(new es3fShaderStateQueryTests.CurrentVertexAttribUintCase('current_vertex_attrib_uint', 'CURRENT_VERTEX_ATTRIB'));
2134 this.addChild(new es3fShaderStateQueryTests.ProgramInfoLogCase('program_info_log', 'INFO_LOG'));
2135 this.addChild(new es3fShaderStateQueryTests.ProgramValidateStatusCase('program_validate_status', 'VALIDATE_STATUS'));
2136 this.addChild(new es3fShaderStateQueryTests.ProgramAttachedShadersCase('program_attached_shaders', 'ATTACHED_SHADERS'));
2138 this.addChild(new es3fShaderStateQueryTests.ProgramActiveUniformNameCase('program_active_uniform_name', 'ACTIVE_UNIFORMS'));
2139 this.addChild(new es3fShaderStateQueryTests.ProgramUniformCase('program_active_uniform_types', 'UNIFORM_TYPE, UNIFORM_SIZE, and UNIFORM_IS_ROW_MAJOR'));
2140 this.addChild(new es3fShaderStateQueryTests.ProgramActiveUniformBlocksCase ("program_active_uniform_blocks", "ACTIVE_UNIFORM_BLOCK_x"));
2142 // transform feedback
2143 this.addChild(new es3fShaderStateQueryTests.TransformFeedbackCase('transform_feedback', 'TRANSFORM_FEEDBACK_BUFFER_MODE, TRANSFORM_FEEDBACK_VARYINGS, TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH'));
2145 // attribute related
2146 this.addChild(new es3fShaderStateQueryTests.ActiveAttributesCase('active_attributes', 'ACTIVE_ATTRIBUTES and ACTIVE_ATTRIBUTE_MAX_LENGTH'));
2147 this.addChild(new es3fShaderStateQueryTests.VertexAttributeSizeCase('vertex_attrib_size', 'VERTEX_ATTRIB_ARRAY_SIZE'));
2148 this.addChild(new es3fShaderStateQueryTests.VertexAttributeTypeCase('vertex_attrib_type', 'VERTEX_ATTRIB_ARRAY_TYPE'));
2149 this.addChild(new es3fShaderStateQueryTests.VertexAttributeStrideCase('vertex_attrib_stride', 'VERTEX_ATTRIB_ARRAY_STRIDE'));
2150 this.addChild(new es3fShaderStateQueryTests.VertexAttributeNormalizedCase('vertex_attrib_normalized', 'VERTEX_ATTRIB_ARRAY_NORMALIZED'));
2151 this.addChild(new es3fShaderStateQueryTests.VertexAttributeIntegerCase('vertex_attrib_integer', 'VERTEX_ATTRIB_ARRAY_INTEGER'));
2152 this.addChild(new es3fShaderStateQueryTests.VertexAttributeEnabledCase('vertex_attrib_array_enabled', 'VERTEX_ATTRIB_ARRAY_ENABLED'));
2153 this.addChild(new es3fShaderStateQueryTests.VertexAttributeDivisorCase('vertex_attrib_array_divisor', 'VERTEX_ATTRIB_ARRAY_DIVISOR'));
2154 this.addChild(new es3fShaderStateQueryTests.VertexAttributeBufferBindingCase('vertex_attrib_array_buffer_binding', 'VERTEX_ATTRIB_ARRAY_BUFFER_BINDING'));
2155 this.addChild(new es3fShaderStateQueryTests.VertexAttributeOffsetCase('vertex_attrib_offset', 'VERTEX_ATTRIB_ARRAY_POINTER'));
2158 this.addChild(new es3fShaderStateQueryTests.UniformValueFloatCase('uniform_value_float', 'GetUniform*'));
2159 this.addChild(new es3fShaderStateQueryTests.UniformValueIntCase('uniform_value_int', 'GetUniform*'));
2160 this.addChild(new es3fShaderStateQueryTests.UniformValueUintCase('uniform_value_uint', 'GetUniform*'));
2161 this.addChild(new es3fShaderStateQueryTests.UniformValueBooleanCase('uniform_value_boolean', 'GetUniform*'));
2162 this.addChild(new es3fShaderStateQueryTests.UniformValueSamplerCase('uniform_value_sampler', 'GetUniform*'));
2163 this.addChild(new es3fShaderStateQueryTests.UniformValueArrayCase('uniform_value_array', 'GetUniform*'));
2164 this.addChild(new es3fShaderStateQueryTests.UniformValueMatrixCase('uniform_value_matrix', 'GetUniform*'));
2166 // precision format query
2167 this.addChild(new es3fShaderStateQueryTests.PrecisionFormatCase('precision_vertex_lowp_float', 'GetShaderPrecisionFormat', gl.VERTEX_SHADER, gl.LOW_FLOAT));
2168 this.addChild(new es3fShaderStateQueryTests.PrecisionFormatCase('precision_vertex_mediump_float', 'GetShaderPrecisionFormat', gl.VERTEX_SHADER, gl.MEDIUM_FLOAT));
2169 this.addChild(new es3fShaderStateQueryTests.PrecisionFormatCase('precision_vertex_highp_float', 'GetShaderPrecisionFormat', gl.VERTEX_SHADER, gl.HIGH_FLOAT));
2170 this.addChild(new es3fShaderStateQueryTests.PrecisionFormatCase('precision_vertex_lowp_int', 'GetShaderPrecisionFormat', gl.VERTEX_SHADER, gl.LOW_INT));
2171 this.addChild(new es3fShaderStateQueryTests.PrecisionFormatCase('precision_vertex_mediump_int', 'GetShaderPrecisionFormat', gl.VERTEX_SHADER, gl.MEDIUM_INT));
2172 this.addChild(new es3fShaderStateQueryTests.PrecisionFormatCase('precision_vertex_highp_int', 'GetShaderPrecisionFormat', gl.VERTEX_SHADER, gl.HIGH_INT));
2173 this.addChild(new es3fShaderStateQueryTests.PrecisionFormatCase('precision_fragment_lowp_float', 'GetShaderPrecisionFormat', gl.FRAGMENT_SHADER, gl.LOW_FLOAT));
2174 this.addChild(new es3fShaderStateQueryTests.PrecisionFormatCase('precision_fragment_mediump_float', 'GetShaderPrecisionFormat', gl.FRAGMENT_SHADER, gl.MEDIUM_FLOAT));
2175 this.addChild(new es3fShaderStateQueryTests.PrecisionFormatCase('precision_fragment_highp_float', 'GetShaderPrecisionFormat', gl.FRAGMENT_SHADER, gl.HIGH_FLOAT));
2176 this.addChild(new es3fShaderStateQueryTests.PrecisionFormatCase('precision_fragment_lowp_int', 'GetShaderPrecisionFormat', gl.FRAGMENT_SHADER, gl.LOW_INT));
2177 this.addChild(new es3fShaderStateQueryTests.PrecisionFormatCase('precision_fragment_mediump_int', 'GetShaderPrecisionFormat', gl.FRAGMENT_SHADER, gl.MEDIUM_INT));
2178 this.addChild(new es3fShaderStateQueryTests.PrecisionFormatCase('precision_fragment_highp_int', 'GetShaderPrecisionFormat', gl.FRAGMENT_SHADER, gl.HIGH_INT));
2183 * @param {WebGL2RenderingContext} context
2185 es3fShaderStateQueryTests.run = function(context) {
2187 //Set up Test Root parameters
2188 var state = tcuTestCase.runner;
2189 state.setRoot(new es3fShaderStateQueryTests.ShaderStateQueryTests());
2191 //Set up name and description of this test series.
2192 setCurrentTestName(state.testCases.fullName());
2193 description(state.testCases.getDescription());
2197 tcuTestCase.runTestCases();
2200 testFailedOptions('Failed to es3fShaderStateQueryTests.run tests', false);
2201 tcuTestCase.runner.terminate();