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.es3fFboStateQueryTests');
23 goog.require('framework.common.tcuTestCase');
24 goog.require('functional.gles3.es3fApiCase');
25 goog.require('modules.shared.glsStateQuery');
27 goog.scope(function() {
28 var es3fFboStateQueryTests = functional.gles3.es3fFboStateQueryTests;
29 var tcuTestCase = framework.common.tcuTestCase;
30 var glsStateQuery = modules.shared.glsStateQuery;
31 var es3fApiCase = functional.gles3.es3fApiCase;
33 var setParentClass = function(child, parent) {
34 child.prototype = Object.create(parent.prototype);
35 child.prototype.constructor = child;
39 es3fFboStateQueryTests.colorBits = [8, 8, 8, 8];
40 es3fFboStateQueryTests.depthBits = 0;
41 es3fFboStateQueryTests.stencilBits = 0;
45 * @extends {es3fApiCase.ApiCase}
46 * @param {string} name
47 * @param {string} description
48 * @param {number} framebufferTarget
50 es3fFboStateQueryTests.DefaultFramebufferCase = function(name, description, framebufferTarget) {
51 es3fApiCase.ApiCase.call(this, name, description, gl);
52 this.m_framebufferTarget = framebufferTarget;
55 setParentClass(es3fFboStateQueryTests.DefaultFramebufferCase, es3fApiCase.ApiCase);
57 es3fFboStateQueryTests.DefaultFramebufferCase.prototype.test = function() {
58 var hasColorBuffer = es3fFboStateQueryTests.colorBits[0] > 0 ||
59 es3fFboStateQueryTests.colorBits[1] > 0 ||
60 es3fFboStateQueryTests.colorBits[2] > 0 ||
61 es3fFboStateQueryTests.colorBits[3] > 0;
67 var attachmentExists = [
69 es3fFboStateQueryTests.depthBits > 0,
70 es3fFboStateQueryTests.stencilBits > 0
73 for (var ndx = 0; ndx < attachments.length; ++ndx) {
74 var objType = gl.getFramebufferAttachmentParameter(this.m_framebufferTarget, attachments[ndx], gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE);
75 if (attachmentExists[ndx]) {
76 this.check(objType === gl.FRAMEBUFFER_DEFAULT);
78 // \note [jarkko] FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE "identifes the type of object which contains the attached image". However, it
79 // is unclear if an object of type FRAMEBUFFER_DEFAULT can contain a null image (or a 0-bits-per-pixel image). Accept both
80 // FRAMEBUFFER_DEFAULT and NONE as valid results in these cases.
81 this.check(objType === gl.FRAMEBUFFER_DEFAULT || objType === gl.NONE);
88 * @extends {es3fApiCase.ApiCase}
89 * @param {string} name
90 * @param {string} description
92 es3fFboStateQueryTests.AttachmentObjectCase = function(name, description) {
93 es3fApiCase.ApiCase.call(this, name, description, gl);
96 setParentClass(es3fFboStateQueryTests.AttachmentObjectCase, es3fApiCase.ApiCase);
98 es3fFboStateQueryTests.AttachmentObjectCase.prototype.test = function() {
99 var framebufferID = gl.createFramebuffer();
100 gl.bindFramebuffer(gl.FRAMEBUFFER, framebufferID);
103 this.check(glsStateQuery.verifyAttachment(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, gl.NONE));
104 this.check(glsStateQuery.verifyAttachment(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, null));
107 var textureID = gl.createTexture();
108 gl.bindTexture(gl.TEXTURE_2D, textureID);
109 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA8, 128, 128, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
111 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, textureID, 0);
113 this.check(glsStateQuery.verifyColorAttachment(gl.FRAMEBUFFER, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, gl.TEXTURE));
114 this.check(glsStateQuery.verifyColorAttachment(gl.FRAMEBUFFER, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, textureID));
116 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, null, 0);
119 var renderbufferID = gl.createRenderbuffer();
120 gl.bindRenderbuffer(gl.RENDERBUFFER, renderbufferID);
121 gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGB8, 128, 128);
123 gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, renderbufferID);
125 this.check(glsStateQuery.verifyColorAttachment(gl.FRAMEBUFFER, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, gl.RENDERBUFFER));
126 this.check(glsStateQuery.verifyColorAttachment(gl.FRAMEBUFFER, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, renderbufferID));
128 gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, null);
129 gl.deleteRenderbuffer(renderbufferID);
131 gl.deleteFramebuffer(framebufferID);
136 * @extends {es3fApiCase.ApiCase}
137 * @param {string} name
138 * @param {string} description
140 es3fFboStateQueryTests.AttachmentTextureLevelCase = function(name, description) {
141 es3fApiCase.ApiCase.call(this, name, description, gl);
144 setParentClass(es3fFboStateQueryTests.AttachmentTextureLevelCase, es3fApiCase.ApiCase);
146 es3fFboStateQueryTests.AttachmentTextureLevelCase.prototype.test = function() {
147 var framebufferID = gl.createFramebuffer();
148 gl.bindFramebuffer(gl.FRAMEBUFFER, framebufferID);
149 for (var mipmapLevel = 0; mipmapLevel < 7; ++mipmapLevel) {
150 var textureID = gl.createTexture();
151 gl.bindTexture(gl.TEXTURE_2D, textureID);
152 gl.texStorage2D(gl.TEXTURE_2D, 7, gl.RGB8, 128, 128);
154 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, textureID, mipmapLevel);
156 this.check(glsStateQuery.verifyColorAttachment(gl.FRAMEBUFFER, gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL, mipmapLevel));
158 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, null, 0);
159 gl.deleteTexture(textureID);
161 gl.deleteFramebuffer(framebufferID);
166 * @extends {es3fApiCase.ApiCase}
167 * @param {string} name
168 * @param {string} description
170 es3fFboStateQueryTests.AttachmentTextureCubeMapFaceCase = function(name, description) {
171 es3fApiCase.ApiCase.call(this, name, description, gl);
174 setParentClass(es3fFboStateQueryTests.AttachmentTextureCubeMapFaceCase, es3fApiCase.ApiCase);
176 es3fFboStateQueryTests.AttachmentTextureCubeMapFaceCase.prototype.test = function() {
177 var framebufferID = gl.createFramebuffer();
178 gl.bindFramebuffer(gl.FRAMEBUFFER, framebufferID);
179 var textureID = gl.createTexture();
180 gl.bindTexture(gl.TEXTURE_CUBE_MAP, textureID);
182 gl.texStorage2D(gl.TEXTURE_CUBE_MAP, 1, gl.RGB8, 128, 128);
185 gl.TEXTURE_CUBE_MAP_POSITIVE_X, gl.TEXTURE_CUBE_MAP_NEGATIVE_X,
186 gl.TEXTURE_CUBE_MAP_POSITIVE_Y, gl.TEXTURE_CUBE_MAP_NEGATIVE_Y,
187 gl.TEXTURE_CUBE_MAP_POSITIVE_Z, gl.TEXTURE_CUBE_MAP_NEGATIVE_Z
190 for (var ndx = 0; ndx < faces.length; ++ndx) {
191 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, faces[ndx], textureID, 0);
192 this.check(glsStateQuery.verifyColorAttachment(gl.FRAMEBUFFER, gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE, faces[ndx]));
195 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, null, 0);
196 gl.deleteTexture(textureID);
197 gl.deleteFramebuffer(framebufferID);
202 * @extends {es3fApiCase.ApiCase}
203 * @param {string} name
204 * @param {string} description
206 es3fFboStateQueryTests.AttachmentTextureLayerCase = function(name, description) {
207 es3fApiCase.ApiCase.call(this, name, description, gl);
210 setParentClass(es3fFboStateQueryTests.AttachmentTextureLayerCase, es3fApiCase.ApiCase);
212 es3fFboStateQueryTests.AttachmentTextureLayerCase.prototype.test = function() {
213 var framebufferID = gl.createFramebuffer();
214 gl.bindFramebuffer(gl.FRAMEBUFFER, framebufferID);
216 var textureID = gl.createTexture();
217 gl.bindTexture(gl.TEXTURE_3D, textureID);
218 gl.texStorage3D(gl.TEXTURE_3D, 1, gl.RGBA8, 16, 16, 16);
220 for (var layer = 0; layer < 16; ++layer) {
221 gl.framebufferTextureLayer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, textureID, 0, layer);
222 this.check(glsStateQuery.verifyColorAttachment(gl.FRAMEBUFFER, gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER, layer));
225 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, null, 0);
226 gl.deleteTexture(textureID);
228 textureID = gl.createTexture();
229 gl.bindTexture(gl.TEXTURE_2D_ARRAY, textureID);
230 gl.texStorage3D(gl.TEXTURE_2D_ARRAY, 1, gl.RGBA8, 16, 16, 16);
232 for (var layer = 0; layer < 16; ++layer) {
233 gl.framebufferTextureLayer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, textureID, 0, layer);
234 this.check(glsStateQuery.verifyColorAttachment(gl.FRAMEBUFFER, gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER, layer));
237 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, null, 0);
238 gl.deleteTexture(textureID);
239 gl.deleteFramebuffer(framebufferID);
244 * @extends {es3fApiCase.ApiCase}
245 * @param {string} name
246 * @param {string} description
248 es3fFboStateQueryTests.AttachmentTextureColorCodingCase = function(name, description) {
249 es3fApiCase.ApiCase.call(this, name, description, gl);
252 setParentClass(es3fFboStateQueryTests.AttachmentTextureColorCodingCase, es3fApiCase.ApiCase);
254 es3fFboStateQueryTests.AttachmentTextureColorCodingCase.prototype.test = function() {
255 var framebufferID = gl.createFramebuffer();
256 gl.bindFramebuffer(gl.FRAMEBUFFER, framebufferID);
258 var renderbufferID = gl.createRenderbuffer();
259 gl.bindRenderbuffer(gl.RENDERBUFFER, renderbufferID);
260 gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGB8, 128, 128);
262 gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, renderbufferID);
264 this.check(glsStateQuery.verifyColorAttachment(gl.FRAMEBUFFER, gl.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING, gl.LINEAR));
266 gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, null);
267 gl.deleteRenderbuffer(renderbufferID);
269 // srgb8_alpha8 color
270 renderbufferID = gl.createRenderbuffer();
271 gl.bindRenderbuffer(gl.RENDERBUFFER, renderbufferID);
272 gl.renderbufferStorage(gl.RENDERBUFFER, gl.SRGB8_ALPHA8, 128, 128);
274 gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, renderbufferID);
276 this.check(glsStateQuery.verifyColorAttachment(gl.FRAMEBUFFER, gl.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING, gl.SRGB));
278 gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, null);
279 gl.deleteRenderbuffer(renderbufferID);
282 renderbufferID = gl.createRenderbuffer();
283 gl.bindRenderbuffer(gl.RENDERBUFFER, renderbufferID);
284 gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, 128, 128);
286 gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, renderbufferID);
288 this.check(glsStateQuery.verifyAttachment(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING, gl.LINEAR));
290 gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, null);
291 gl.deleteRenderbuffer(renderbufferID);
292 gl.deleteFramebuffer(framebufferID);
297 * @extends {es3fApiCase.ApiCase}
298 * @param {string} name
299 * @param {string} description
301 es3fFboStateQueryTests.AttachmentTextureComponentTypeCase = function(name, description) {
302 es3fApiCase.ApiCase.call(this, name, description, gl);
305 setParentClass(es3fFboStateQueryTests.AttachmentTextureComponentTypeCase, es3fApiCase.ApiCase);
307 es3fFboStateQueryTests.AttachmentTextureComponentTypeCase.prototype.test = function() {
308 var framebufferID = gl.createFramebuffer();
309 gl.bindFramebuffer(gl.FRAMEBUFFER, framebufferID);
310 // color-renderable required texture formats
311 var requiredColorformats = [
312 [gl.R8, gl.UNSIGNED_NORMALIZED],
313 [gl.RG8, gl.UNSIGNED_NORMALIZED],
314 [gl.RGB8, gl.UNSIGNED_NORMALIZED],
315 [gl.RGB565, gl.UNSIGNED_NORMALIZED],
316 [gl.RGBA4, gl.UNSIGNED_NORMALIZED],
317 [gl.RGB5_A1, gl.UNSIGNED_NORMALIZED],
318 [gl.RGBA8, gl.UNSIGNED_NORMALIZED],
319 [gl.RGB10_A2, gl.UNSIGNED_NORMALIZED],
320 [gl.RGB10_A2UI, gl.UNSIGNED_INT],
321 [gl.SRGB8_ALPHA8, gl.UNSIGNED_NORMALIZED],
323 [gl.R8UI, gl.UNSIGNED_INT],
325 [gl.R16UI, gl.UNSIGNED_INT],
327 [gl.R32UI, gl.UNSIGNED_INT],
329 [gl.RG8UI, gl.UNSIGNED_INT],
331 [gl.RG16UI, gl.UNSIGNED_INT],
333 [gl.RG32UI, gl.UNSIGNED_INT],
335 [gl.RGBA8UI, gl.UNSIGNED_INT],
336 [gl.RGBA16I, gl.INT],
337 [gl.RGBA16UI, gl.UNSIGNED_INT],
338 [gl.RGBA32I, gl.INT],
339 [gl.RGBA32UI, gl.UNSIGNED_INT]
342 for (var ndx = 0; ndx < requiredColorformats.length; ++ndx) {
343 var colorFormat = requiredColorformats[ndx][0];
344 var componentType = requiredColorformats[ndx][1];
346 var textureID = gl.createTexture();
347 gl.bindTexture(gl.TEXTURE_2D, textureID);
348 gl.texStorage2D(gl.TEXTURE_2D, 1, colorFormat, 128, 128);
350 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, textureID, 0);
352 this.check(glsStateQuery.verifyColorAttachment(gl.FRAMEBUFFER, gl.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE, componentType));
354 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, null, 0);
355 gl.deleteTexture(textureID);
357 gl.deleteFramebuffer(framebufferID);
362 * @extends {es3fApiCase.ApiCase}
363 * @param {string} name
364 * @param {string} description
366 es3fFboStateQueryTests.AttachmentSizeInitialCase = function(name, description) {
367 es3fApiCase.ApiCase.call(this, name, description, gl);
370 setParentClass(es3fFboStateQueryTests.AttachmentSizeInitialCase, es3fApiCase.ApiCase);
372 es3fFboStateQueryTests.AttachmentSizeInitialCase.prototype.attachmentExists = function(attachment) {
373 var objType = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, attachment, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE);
374 return objType !== gl.NONE;
378 * @this {es3fApiCase.ApiCase}
380 var checkAttachmentComponentSizeAtLeast = function(target, attachment, r, g, b, a, d, s) {
381 var referenceSizes = [r, g, b, a, d, s];
383 gl.FRAMEBUFFER_ATTACHMENT_RED_SIZE, gl.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE,
384 gl.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE, gl.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE,
385 gl.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE, gl.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE
388 for (var ndx = 0; ndx < referenceSizes.length; ++ndx) {
389 if (referenceSizes[ndx] == -1)
392 var value = /** @type {number} */ (gl.getFramebufferAttachmentParameter(target, attachment, paramNames[ndx]));
394 this.check(value >= referenceSizes[ndx], 'Expected greater or equal to ' + referenceSizes[ndx] + ' got ' + value);
399 * @this {es3fApiCase.ApiCase}
401 var checkAttachmentComponentSizeExactly = function(target, attachment, r, g, b, a, d, s) {
402 var referenceSizes = [r, g, b, a, d, s];
404 gl.FRAMEBUFFER_ATTACHMENT_RED_SIZE, gl.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE,
405 gl.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE, gl.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE,
406 gl.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE, gl.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE
409 for (var ndx = 0; ndx < referenceSizes.length; ++ndx) {
410 if (referenceSizes[ndx] == -1)
413 var value = gl.getFramebufferAttachmentParameter(target, attachment, paramNames[ndx]);
415 this.check(value == referenceSizes[ndx], 'Expected equal to ' + referenceSizes[ndx] + ' got ' + value);
419 es3fFboStateQueryTests.AttachmentSizeInitialCase.prototype.test = function() {
421 if (this.attachmentExists(gl.BACK)) {
422 checkAttachmentComponentSizeAtLeast.bind(this,
425 es3fFboStateQueryTests.colorBits[0],
426 es3fFboStateQueryTests.colorBits[1],
427 es3fFboStateQueryTests.colorBits[2],
428 es3fFboStateQueryTests.colorBits[3],
433 if (this.attachmentExists(gl.DEPTH)) {
434 checkAttachmentComponentSizeAtLeast.bind(this,
441 es3fFboStateQueryTests.depthBits,
445 if (this.attachmentExists(gl.STENCIL)) {
446 checkAttachmentComponentSizeAtLeast.bind(this,
454 es3fFboStateQueryTests.stencilBits);
460 * @extends {es3fApiCase.ApiCase}
461 * @param {string} name
462 * @param {string} description
464 es3fFboStateQueryTests.AttachmentSizeCase = function(name, description) {
465 es3fApiCase.ApiCase.call(this, name, description, gl);
468 setParentClass(es3fFboStateQueryTests.AttachmentSizeCase, es3fApiCase.ApiCase);
470 es3fFboStateQueryTests.AttachmentSizeCase.prototype.test = function() {
471 var framebufferID = gl.createFramebuffer();
472 gl.bindFramebuffer(gl.FRAMEBUFFER, framebufferID);
473 // check some color targets
475 var colorAttachments = [
476 //format, red, green, blue, alpha
477 [gl.RGBA8, 8, 8, 8, 8],
478 [gl.RGB565, 5, 6, 5, 0],
479 [gl.RGBA4, 4, 4, 4, 4],
480 [gl.RGB5_A1, 5, 5, 5, 1],
481 [gl.RGBA8I, 8, 8, 8, 8],
482 [gl.RG32UI, 32, 32, 0, 0]
484 for (var ndx = 0; ndx < colorAttachments.length; ++ndx)
485 this.testColorAttachment(colorAttachments[ndx][0], gl.COLOR_ATTACHMENT0, colorAttachments[ndx][1], colorAttachments[ndx][2], colorAttachments[ndx][3], colorAttachments[ndx][4]);
487 // check some depth targets
489 var depthAttachments = [
490 // format, attachment, depth, stencil
491 [gl.DEPTH_COMPONENT16, gl.DEPTH_ATTACHMENT, 16, 0],
492 [gl.DEPTH_COMPONENT24, gl.DEPTH_ATTACHMENT, 24, 0],
493 [gl.DEPTH_COMPONENT32F, gl.DEPTH_ATTACHMENT, 32, 0],
494 [gl.DEPTH24_STENCIL8, gl.DEPTH_STENCIL_ATTACHMENT, 24, 8],
495 [gl.DEPTH32F_STENCIL8, gl.DEPTH_STENCIL_ATTACHMENT, 32, 8]
497 for (var ndx = 0; ndx < depthAttachments.length; ++ndx)
498 this.testDepthAttachment(depthAttachments[ndx][0], depthAttachments[ndx][1], depthAttachments[ndx][2], depthAttachments[ndx][3]);
499 gl.deleteFramebuffer(framebufferID);
504 * @extends {es3fFboStateQueryTests.AttachmentSizeCase}
505 * @param {string} name
506 * @param {string} description
508 es3fFboStateQueryTests.AttachmentSizeRboCase = function(name, description) {
509 es3fFboStateQueryTests.AttachmentSizeCase.call(this, name, description);
512 setParentClass(es3fFboStateQueryTests.AttachmentSizeRboCase, es3fFboStateQueryTests.AttachmentSizeCase);
514 es3fFboStateQueryTests.AttachmentSizeRboCase.prototype.testColorAttachment = function(internalFormat, attachment, r, g, b, a) {
515 var renderbufferID = gl.createRenderbuffer();
516 gl.bindRenderbuffer(gl.RENDERBUFFER, renderbufferID);
517 gl.renderbufferStorage(gl.RENDERBUFFER, internalFormat, 128, 128);
519 gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, renderbufferID);
521 checkAttachmentComponentSizeAtLeast.bind(this, gl.FRAMEBUFFER, attachment, r, g, b, a, -1, -1);
522 checkAttachmentComponentSizeExactly.bind(this, gl.FRAMEBUFFER, attachment, -1, -1, -1, -1, 0, 0);
524 gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, null);
525 gl.deleteRenderbuffer(renderbufferID);
528 es3fFboStateQueryTests.AttachmentSizeRboCase.prototype.testDepthAttachment = function(internalFormat, attachment, depth, stencil) {
529 var renderbufferID = gl.createRenderbuffer();
530 gl.bindRenderbuffer(gl.RENDERBUFFER, renderbufferID);
531 gl.renderbufferStorage(gl.RENDERBUFFER, internalFormat, 128, 128);
533 gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, renderbufferID);
535 checkAttachmentComponentSizeAtLeast.bind(this, gl.FRAMEBUFFER, attachment, -1, -1, -1, -1, depth, stencil);
536 checkAttachmentComponentSizeExactly.bind(this, gl.FRAMEBUFFER, attachment, 0, 0, 0, 0, -1, -1);
538 gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, null);
539 gl.deleteRenderbuffer(renderbufferID);
544 * @extends {es3fFboStateQueryTests.AttachmentSizeCase}
545 * @param {string} name
546 * @param {string} description
548 es3fFboStateQueryTests.AttachmentSizeTextureCase = function(name, description) {
549 es3fFboStateQueryTests.AttachmentSizeCase.call(this, name, description);
552 setParentClass(es3fFboStateQueryTests.AttachmentSizeTextureCase, es3fFboStateQueryTests.AttachmentSizeCase);
554 es3fFboStateQueryTests.AttachmentSizeTextureCase.prototype.testColorAttachment = function(internalFormat, attachment, r, g, b, a) {
555 var textureID = gl.createTexture();
556 gl.bindTexture(gl.TEXTURE_2D, textureID);
557 gl.texStorage2D(gl.TEXTURE_2D, 1, internalFormat, 128, 128);
559 gl.framebufferTexture2D(gl.FRAMEBUFFER, attachment, gl.TEXTURE_2D, textureID, 0);
561 checkAttachmentComponentSizeAtLeast.bind(this, gl.FRAMEBUFFER, attachment, r, g, b, a, -1, -1);
562 checkAttachmentComponentSizeExactly.bind(this, gl.FRAMEBUFFER, attachment, -1, -1, -1, -1, 0, 0);
564 gl.framebufferTexture2D(gl.FRAMEBUFFER, attachment, gl.TEXTURE_2D, null, 0);
565 gl.deleteTexture(textureID);
568 es3fFboStateQueryTests.AttachmentSizeTextureCase.prototype.testDepthAttachment = function(internalFormat, attachment, depth, stencil) {
569 // don't test stencil formats with textures
570 if (attachment == gl.DEPTH_STENCIL_ATTACHMENT)
573 var textureID = gl.createTexture();
574 gl.bindTexture(gl.TEXTURE_2D, textureID);
575 gl.texStorage2D(gl.TEXTURE_2D, 1, internalFormat, 128, 128);
577 gl.framebufferTexture2D(gl.FRAMEBUFFER, attachment, gl.TEXTURE_2D, textureID, 0);
579 checkAttachmentComponentSizeAtLeast.bind(this, gl.FRAMEBUFFER, attachment, -1, -1, -1, -1, depth, stencil);
580 checkAttachmentComponentSizeExactly.bind(this, gl.FRAMEBUFFER, attachment, 0, 0, 0, 0, -1, -1);
582 gl.framebufferTexture2D(gl.FRAMEBUFFER, attachment, gl.TEXTURE_2D, null, 0);
583 gl.deleteTexture(textureID);
588 * @extends {es3fApiCase.ApiCase}
589 * @param {string} name
590 * @param {string} description
592 es3fFboStateQueryTests.UnspecifiedAttachmentTextureColorCodingCase = function(name, description) {
593 es3fApiCase.ApiCase.call(this, name, description, gl);
596 setParentClass(es3fFboStateQueryTests.UnspecifiedAttachmentTextureColorCodingCase, es3fApiCase.ApiCase);
598 es3fFboStateQueryTests.UnspecifiedAttachmentTextureColorCodingCase.prototype.test = function() {
599 var framebufferID = gl.createFramebuffer();
600 gl.bindFramebuffer(gl.FRAMEBUFFER, framebufferID);
602 var renderbufferID = gl.createRenderbuffer();
603 gl.bindRenderbuffer(gl.RENDERBUFFER, renderbufferID);
605 gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, renderbufferID);
607 this.check(glsStateQuery.verifyColorAttachment(gl.FRAMEBUFFER, gl.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING, gl.LINEAR));
609 gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, null);
610 gl.deleteRenderbuffer(renderbufferID);
613 renderbufferID = gl.createRenderbuffer();
614 gl.bindRenderbuffer(gl.RENDERBUFFER, renderbufferID);
616 gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, renderbufferID);
618 this.check(glsStateQuery.verifyAttachment(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING, gl.LINEAR));
620 gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, null);
621 gl.deleteRenderbuffer(renderbufferID);
622 gl.deleteFramebuffer(framebufferID);
627 * @extends {es3fApiCase.ApiCase}
628 * @param {string} name
629 * @param {string} description
631 es3fFboStateQueryTests.UnspecifiedAttachmentSizeCase = function(name, description) {
632 es3fApiCase.ApiCase.call(this, name, description, gl);
635 setParentClass(es3fFboStateQueryTests.UnspecifiedAttachmentSizeCase, es3fApiCase.ApiCase);
637 es3fFboStateQueryTests.UnspecifiedAttachmentSizeCase.prototype.test = function() {
638 var framebufferID = gl.createFramebuffer();
639 gl.bindFramebuffer(gl.FRAMEBUFFER, framebufferID);
640 // check color target
641 this.testColorAttachment();
643 // check depth target
644 this.testDepthAttachment();
645 gl.deleteFramebuffer(framebufferID);
650 * @extends {es3fFboStateQueryTests.UnspecifiedAttachmentSizeCase}
651 * @param {string} name
652 * @param {string} description
654 es3fFboStateQueryTests.UnspecifiedAttachmentSizeRboCase = function(name, description) {
655 es3fFboStateQueryTests.UnspecifiedAttachmentSizeCase.call(this, name, description);
658 setParentClass(es3fFboStateQueryTests.UnspecifiedAttachmentSizeRboCase, es3fFboStateQueryTests.UnspecifiedAttachmentSizeCase);
660 es3fFboStateQueryTests.UnspecifiedAttachmentSizeRboCase.prototype.testColorAttachment = function() {
661 var renderbufferID = gl.createRenderbuffer();
662 gl.bindRenderbuffer(gl.RENDERBUFFER, renderbufferID);
664 gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, renderbufferID);
666 checkAttachmentComponentSizeExactly.bind(this, gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, 0, 0, 0, 0, 0, 0);
668 gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, null);
669 gl.deleteRenderbuffer(renderbufferID);
672 es3fFboStateQueryTests.UnspecifiedAttachmentSizeRboCase.prototype.testDepthAttachment = function() {
673 var renderbufferID = gl.createRenderbuffer();
674 gl.bindRenderbuffer(gl.RENDERBUFFER, renderbufferID);
676 gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, renderbufferID);
678 checkAttachmentComponentSizeExactly.bind(this, gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, 0, 0, 0, 0, 0, 0);
680 gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, null);
681 gl.deleteRenderbuffer(renderbufferID);
686 * @extends {es3fFboStateQueryTests.UnspecifiedAttachmentSizeCase}
687 * @param {string} name
688 * @param {string} description
690 es3fFboStateQueryTests.UnspecifiedAttachmentSizeTextureCase = function(name, description) {
691 es3fFboStateQueryTests.UnspecifiedAttachmentSizeCase.call(this, name, description);
694 setParentClass(es3fFboStateQueryTests.UnspecifiedAttachmentSizeTextureCase, es3fFboStateQueryTests.UnspecifiedAttachmentSizeCase);
696 es3fFboStateQueryTests.UnspecifiedAttachmentSizeTextureCase.prototype.testColorAttachment = function() {
697 var textureID = gl.createTexture();
698 gl.bindTexture(gl.TEXTURE_2D, textureID);
700 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, textureID, 0);
702 checkAttachmentComponentSizeExactly.bind(this, gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, 0, 0, 0, 0, 0, 0);
704 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, null, 0);
705 gl.deleteTexture(textureID);
708 es3fFboStateQueryTests.UnspecifiedAttachmentSizeTextureCase.prototype.testDepthAttachment = function() {
709 var textureID = gl.createTexture();
710 gl.bindTexture(gl.TEXTURE_2D, textureID);
712 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, textureID, 0);
714 checkAttachmentComponentSizeExactly.bind(this, gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, 0, 0, 0, 0, 0, 0);
716 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, null, 0);
717 gl.deleteTexture(textureID);
722 * @extends {es3fApiCase.ApiCase}
723 * @param {string} name
724 * @param {string} description
726 es3fFboStateQueryTests.UnspecifiedAttachmentTextureComponentTypeCase = function(name, description) {
727 es3fApiCase.ApiCase.call(this, name, description, gl);
730 setParentClass(es3fFboStateQueryTests.UnspecifiedAttachmentTextureComponentTypeCase, es3fApiCase.ApiCase);
732 es3fFboStateQueryTests.UnspecifiedAttachmentTextureComponentTypeCase.prototype.test = function() {
737 * @extends {tcuTestCase.DeqpTest}
739 es3fFboStateQueryTests.FboStateQueryTests = function() {
740 tcuTestCase.DeqpTest.call(this, 'fbo', 'Fbo State Query tests');
743 es3fFboStateQueryTests.FboStateQueryTests.prototype = Object.create(tcuTestCase.DeqpTest.prototype);
744 es3fFboStateQueryTests.FboStateQueryTests.prototype.constructor = es3fFboStateQueryTests.FboStateQueryTests;
746 es3fFboStateQueryTests.FboStateQueryTests.prototype.init = function() {
747 var red = /** @type {number} */ (gl.getParameter(gl.RED_BITS));
748 var green = /** @type {number} */ (gl.getParameter(gl.GREEN_BITS));
749 var blue = /** @type {number} */ (gl.getParameter(gl.BLUE_BITS));
750 var alpha = /** @type {number} */ (gl.getParameter(gl.ALPHA_BITS));
751 es3fFboStateQueryTests.colorBits = [red, green, blue, alpha];
752 es3fFboStateQueryTests.depthBits = /** @type {number} */ (gl.getParameter(gl.DEPTH_BITS));
753 es3fFboStateQueryTests.stencilBits = /** @type {number} */ (gl.getParameter(gl.STENCIL_BITS));
755 this.addChild(new es3fFboStateQueryTests.DefaultFramebufferCase('draw_framebuffer_default_framebuffer', 'default framebuffer', gl.DRAW_FRAMEBUFFER));
756 this.addChild(new es3fFboStateQueryTests.DefaultFramebufferCase('read_framebuffer_default_framebuffer', 'default framebuffer', gl.READ_FRAMEBUFFER));
757 this.addChild(new es3fFboStateQueryTests.AttachmentObjectCase('framebuffer_attachment_object', 'FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE and FRAMEBUFFER_ATTACHMENT_OBJECT_NAME'));
758 this.addChild(new es3fFboStateQueryTests.AttachmentTextureLevelCase('framebuffer_attachment_texture_level', 'FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL'));
759 this.addChild(new es3fFboStateQueryTests.AttachmentTextureCubeMapFaceCase('framebuffer_attachment_texture_cube_map_face', 'FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE'));
760 this.addChild(new es3fFboStateQueryTests.AttachmentTextureLayerCase('framebuffer_attachment_texture_layer', 'FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER'));
761 this.addChild(new es3fFboStateQueryTests.AttachmentTextureColorCodingCase('framebuffer_attachment_color_encoding', 'FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING'));
762 this.addChild(new es3fFboStateQueryTests.AttachmentTextureComponentTypeCase('framebuffer_attachment_component_type', 'FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE'));
763 this.addChild(new es3fFboStateQueryTests.AttachmentSizeInitialCase('framebuffer_attachment_x_size_initial', 'FRAMEBUFFER_ATTACHMENT_x_SIZE'));
764 this.addChild(new es3fFboStateQueryTests.AttachmentSizeRboCase('framebuffer_attachment_x_size_rbo', 'FRAMEBUFFER_ATTACHMENT_x_SIZE'));
765 this.addChild(new es3fFboStateQueryTests.AttachmentSizeTextureCase('framebuffer_attachment_x_size_texture', 'FRAMEBUFFER_ATTACHMENT_x_SIZE'));
766 this.addChild(new es3fFboStateQueryTests.UnspecifiedAttachmentTextureColorCodingCase('framebuffer_unspecified_attachment_color_encoding', 'FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING'));
767 this.addChild(new es3fFboStateQueryTests.UnspecifiedAttachmentTextureComponentTypeCase('framebuffer_unspecified_attachment_component_type', 'FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE'));
768 this.addChild(new es3fFboStateQueryTests.UnspecifiedAttachmentSizeRboCase('framebuffer_unspecified_attachment_x_size_rbo', 'FRAMEBUFFER_ATTACHMENT_x_SIZE'));
769 this.addChild(new es3fFboStateQueryTests.UnspecifiedAttachmentSizeTextureCase('framebuffer_unspecified_attachment_x_size_texture', 'FRAMEBUFFER_ATTACHMENT_x_SIZE'));
774 * @param {WebGL2RenderingContext} context
776 es3fFboStateQueryTests.run = function(context) {
778 //Set up Test Root parameters
779 var state = tcuTestCase.runner;
780 state.setRoot(new es3fFboStateQueryTests.FboStateQueryTests());
782 //Set up name and description of this test series.
783 setCurrentTestName(state.testCases.fullName());
784 description(state.testCases.getDescription());
788 tcuTestCase.runTestCases();
791 testFailedOptions('Failed to es3fFboStateQueryTests.run tests', false);
792 tcuTestCase.runner.terminate();