2 // FboCompletenessTests
4 goog.provide('functional.gles3.es3fFboCompletenessTests');
5 goog.require('framework.common.tcuTestCase');
6 goog.require('modules.shared.glsFboCompletenessTests');
7 goog.require('modules.shared.glsFboUtil');
9 goog.scope(function() {
11 var es3fFboCompletenessTests = functional.gles3.es3fFboCompletenessTests;
12 var glsFboUtil = modules.shared.glsFboUtil;
13 var glsFboCompletenessTests = modules.shared.glsFboCompletenessTests;
14 var tcuTestCase = framework.common.tcuTestCase;
16 es3fFboCompletenessTests.initGlDependents = function(gl) {
17 if (!(gl = gl || window.gl)) throw new Error('Invalid gl object');
20 * @type {Array<number>}
22 es3fFboCompletenessTests.s_es3ColorRenderables = [
23 // GLES3, 4.4.4: "An internal format is color-renderable if it is one of
24 // the formats from table 3.12 noted as color-renderable..."
25 gl.R8, gl.RG8, gl.RGB8, gl.RGB565, gl.RGBA4, gl.RGB5_A1, gl.RGBA8,
26 gl.RGB10_A2, gl.RGB10_A2UI, gl.SRGB8_ALPHA8,
27 gl.R8I, gl.R8UI, gl.R16I, gl.R16UI, gl.R32I, gl.R32UI,
28 gl.RG8I, gl.RG8UI, gl.RG16I, gl.RG16UI, gl.RG32I, gl.RG32UI,
29 gl.RGBA81, gl.RGBA8UI, gl.RGB16I, gl.RGBA16UI, gl.RGBA32I, gl.RGBA32UI
33 * @type {Array<number>}
35 es3fFboCompletenessTests.s_es3UnsizedColorRenderables = [
36 // "...or if it is unsized format RGBA or RGB."
37 // See Table 3.3 in GLES3.
38 glsFboUtil.formatkey(gl.RGBA, gl.UNSIGNED_BYTE),
39 glsFboUtil.formatkey(gl.RGBA, gl.UNSIGNED_SHORT_4_4_4_4),
40 glsFboUtil.formatkey(gl.RGBA, gl.UNSIGNED_SHORT_5_5_5_1),
41 glsFboUtil.formatkey(gl.RGB, gl.UNSIGNED_BYTE),
42 glsFboUtil.formatkey(gl.RGB, gl.UNSIGNED_SHORT_5_6_5)
46 * @type {Array<number>}
48 es3fFboCompletenessTests.s_es3DepthRenderables = [
49 // GLES3, 4.4.4: "An internal format is depth-renderable if it is one of
50 // the formats from table 3.13."
51 gl.DEPTH_COMPONENT16, gl.DEPTH_COMPONENT24, gl.DEPTH_COMPONENT32F,
52 gl.DEPTH24_STENCIL8, gl.DEPTH32F_STENCIL8
56 * @type {Array<number>}
58 es3fFboCompletenessTests.s_es3StencilRboRenderables = [
59 // GLES3, 4.4.4: "An internal format is stencil-renderable if it is
65 * @type {Array<number>}
67 es3fFboCompletenessTests.s_es3StencilRenderables = [
68 // "...or one of the formats from table 3.13 whose base internal format is
70 gl.DEPTH24_STENCIL8, gl.DEPTH32F_STENCIL8
74 * @type {Array<number>}
76 es3fFboCompletenessTests.s_es3TextureFloatFormats = [
77 gl.RGBA32F, gl.RGBA16F, gl.R11F_G11F_B10F,
78 gl.RG32F, gl.RG16F, gl.R32F, gl.R16F,
79 gl.RGBA16F, gl.RGB16F, gl.RG16F, gl.R16F
83 * @type {Array<glsFboUtil.formatT>}
85 es3fFboCompletenessTests.s_es3Formats = [
88 glsFboUtil.FormatFlags.REQUIRED_RENDERABLE |
89 glsFboUtil.FormatFlags.COLOR_RENDERABLE |
90 glsFboUtil.FormatFlags.TEXTURE_VALID
92 glsFboUtil.rangeArray(es3fFboCompletenessTests.s_es3UnsizedColorRenderables)
96 glsFboUtil.FormatFlags.REQUIRED_RENDERABLE |
97 glsFboUtil.FormatFlags.COLOR_RENDERABLE |
98 glsFboUtil.FormatFlags.RENDERBUFFER_VALID |
99 glsFboUtil.FormatFlags.TEXTURE_VALID
101 glsFboUtil.rangeArray(es3fFboCompletenessTests.s_es3ColorRenderables)
104 glsFboUtil.FormatFlags.REQUIRED_RENDERABLE |
105 glsFboUtil.FormatFlags.DEPTH_RENDERABLE |
106 glsFboUtil.FormatFlags.RENDERBUFFER_VALID |
107 glsFboUtil.FormatFlags.TEXTURE_VALID
109 glsFboUtil.rangeArray(es3fFboCompletenessTests.s_es3DepthRenderables)
112 glsFboUtil.FormatFlags.REQUIRED_RENDERABLE |
113 glsFboUtil.FormatFlags.STENCIL_RENDERABLE |
114 glsFboUtil.FormatFlags.RENDERBUFFER_VALID
116 glsFboUtil.rangeArray(es3fFboCompletenessTests.s_es3StencilRboRenderables)
119 glsFboUtil.FormatFlags.REQUIRED_RENDERABLE |
120 glsFboUtil.FormatFlags.STENCIL_RENDERABLE |
121 glsFboUtil.FormatFlags.RENDERBUFFER_VALID |
122 glsFboUtil.FormatFlags.TEXTURE_VALID
124 glsFboUtil.rangeArray(es3fFboCompletenessTests.s_es3StencilRenderables)
127 // These are not color-renderable in vanilla ES3, but we need to mark them
128 // as valid for textures, since EXT_color_buffer_(half_)float brings in
129 // color-renderability and only renderbuffer-validity.
131 glsFboUtil.FormatFlags.TEXTURE_VALID,
132 glsFboUtil.rangeArray(es3fFboCompletenessTests.s_es3TextureFloatFormats)
136 // gl.EXT_color_buffer_float
137 es3fFboCompletenessTests.s_extColorBufferFloatFormats = [
138 gl.RGBA32F, gl.RGBA16F, gl.R11F_G11F_B10F, gl.RG32F, gl.RG16F, gl.R32F, gl.R16F
141 // gl.OES_texture_stencil8
142 es3fFboCompletenessTests.s_extOESTextureStencil8 = [
146 es3fFboCompletenessTests.s_es3ExtFormats = [{
147 extensions: 'gl.EXT_color_buffer_float',
148 flags: glsFboUtil.FormatFlags.REQUIRED_RENDERABLE |
149 glsFboUtil.FormatFlags.COLOR_RENDERABLE |
150 glsFboUtil.FormatFlags.RENDERBUFFER_VALID,
151 formats: new glsFboUtil.Range(es3fFboCompletenessTests.s_extColorBufferFloatFormats)
153 extensions: 'gl.OES_texture_stencil8',
154 flags: glsFboUtil.FormatFlags.REQUIRED_RENDERABLE |
155 glsFboUtil.FormatFlags.STENCIL_RENDERABLE |
156 glsFboUtil.FormatFlags.TEXTURE_VALID,
157 formats: new glsFboUtil.Range(es3fFboCompletenessTests.s_extOESTextureStencil8)
161 glsFboCompletenessTests.initGlDependents(gl);
166 * @extends {glsFboUtil.Checker}
168 es3fFboCompletenessTests.ES3Checker = function() {
169 glsFboUtil.Checker.call(this, gl);
170 /** @type {number} */ this.m_numSamples = -1; // GLsizei
171 /** @type {number} */ this.m_depthStencilImage = 0; // GLuint
172 /** @type {number} */ this.m_depthStencilType = gl.NONE;
174 es3fFboCompletenessTests.ES3Checker.prototype = Object.create(glsFboUtil.Checker.prototype);
175 es3fFboCompletenessTests.ES3Checker.prototype.constructor = es3fFboCompletenessTests.ES3Checker;
177 es3fFboCompletenessTests.ES3Checker.prototype.check = function(attPoint, att, image) {
179 var imgSamples = glsFboUtil.imageNumSamples(image);
181 if (this.m_numSamples == -1) {
182 this.m_numSamples = imgSamples;
184 // GLES3: "The value of RENDERBUFFER_SAMPLES is the same for all attached
185 // renderbuffers and, if the attached images are a mix of renderbuffers
186 // and textures, the value of RENDERBUFFER_SAMPLES is zero."
188 // On creating a renderbuffer: "If _samples_ is zero, then
189 // RENDERBUFFER_SAMPLES is set to zero. Otherwise [...] the resulting
190 // value for RENDERBUFFER_SAMPLES is guaranteed to be greater than or
191 // equal to _samples_ and no more than the next larger sample count
192 // supported by the implementation."
194 // Either all attachments are zero-sample renderbuffers and/or
195 // textures, or none of them are.
197 (this.m_numSamples == 0) == (imgSamples == 0),
198 gl.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE
201 // If the attachments requested a different number of samples, the
202 // implementation is allowed to report this as incomplete. However, it
203 // is also possible that despite the different requests, the
204 // implementation allocated the same number of samples to both. Hence
205 // reporting the framebuffer as complete is also legal.
206 this.addPotentialFBOStatus(
207 this.m_numSamples == imgSamples,
208 gl.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE
212 // "Depth and stencil attachments, if present, are the same image."
213 if (attPoint == gl.DEPTH_ATTACHMENT || attPoint == gl.STENCIL_ATTACHMENT) {
214 if (this.m_depthStencilImage == 0) {
215 this.m_depthStencilImage = att.imageName;
216 this.m_depthStencilType = glsFboUtil.attachmentType(att);
220 this.m_depthStencilImage == att.imageName && this.m_depthStencilType == glsFboUtil.attachmentType(att),
221 gl.FRAMEBUFFER_UNSUPPORTED
229 * @typedef {{textureKind: number, numLayers: number, attachmentLayer: number}}
231 es3fFboCompletenessTests.numLayersParamsT;
234 * @param {number} textureKind
235 * @param {number} numLayers
236 * @param {number} attachmentLayer
237 * @return {es3fFboCompletenessTests.numLayersParamsT}
239 es3fFboCompletenessTests.numLayersParams = function(textureKind, numLayers, attachmentLayer) {
240 if (typeof(attachmentLayer) == 'undefined') {
246 textureKind: textureKind, //< gl.TEXTURE_3D or gl.TEXTURE_2D_ARRAY
247 numLayers: numLayers, //< Number of layers in texture
248 attachmentLayer: attachmentLayer //< Layer referenced by attachment
253 * es3fFboCompletenessTests.numLayersParams.getName
254 * @param {es3fFboCompletenessTests.numLayersParamsT} params
257 es3fFboCompletenessTests.numLayersParams.getName = function(params) {
259 (params.textureKind == gl.TEXTURE_3D ? '3d' : '2darr') + '_' +
260 params.numLayers + '_' +
261 params.attachmentLayer
265 * es3fFboCompletenessTests.numLayersParams.getDescription
266 * @param {es3fFboCompletenessTests.numLayersParamsT} params
269 es3fFboCompletenessTests.numLayersParams.getDescription = function(params) {
271 (params.textureKind == gl.TEXTURE_3D ? '3D Texture' : '2D Array Texture') + ', ' +
272 params.numLayers + ' layers, ' +
273 'attached layer ' + params.attachmentLayer + '.'
277 // string, string, glsFboCompleteness::context, params.
280 * @extends {glsFboCompletenessTests.TestBase}
281 * @param {string} name
282 * @param {string} desc
283 * @param {glsFboCompletenessTests.Context} ctx
284 * @param {es3fFboCompletenessTests.numLayersParamsT} params
286 es3fFboCompletenessTests.NumLayersTest = function(name, desc, ctx, params) {
287 glsFboCompletenessTests.TestBase.call(this, name, desc, params);
291 es3fFboCompletenessTests.NumLayersTest.prototype = Object.create(glsFboCompletenessTests.TestBase.prototype);
292 es3fFboCompletenessTests.NumLayersTest.prototype.constructor = es3fFboCompletenessTests.NumLayersTest;
294 es3fFboCompletenessTests.NumLayersTest.prototype.build = function(builder, gl) {
296 if (!(gl = gl || window.gl)) throw new Error('Invalid gl object');
298 var target = gl.COLOR_ATTACHMENT0;
299 var texCfg = builder.makeConfig(
302 case gl.TEXTURE_3D: return glsFboUtil.Texture3D;
303 case gl.TEXTURE_2D_ARRAY: return glsFboUtil.Texture2DArray;
304 default: throw new Error('Impossible case');
306 }(this.m_params.textureKind)
309 texCfg.internalFormat = this.getDefaultFormat(target, gl.TEXTURE, gl);
312 texCfg.numLayers = this.m_params.numLayers;
313 var tex = builder.glCreateTexture(texCfg);
315 var att = builder.makeConfig(glsFboUtil.TextureLayerAttachment);
316 att.layer = this.m_params.attachmentLayer;
319 builder.glAttach(target, att);
321 // return tcuTestCase.IterateResult.STOP;
323 //es3fFboCompletenessTests.NumLayersTest.prototype.isExecutable = function() {
330 es3fFboCompletenessTests.e_samples = {
336 * @typedef {{numSamples: Array<number>}}
338 es3fFboCompletenessTests.numSamplesParamsT;
341 * @param {number} colour
342 * @param {number} depth
343 * @param {number} stencil
344 * @return {es3fFboCompletenessTests.numSamplesParamsT}
346 es3fFboCompletenessTests.numSamplesParams = function(colour, depth, stencil) {
348 numSamples: new Array(3)
350 if (colour !== undefined) {
351 ret.numSamples[0] = colour;
352 if (depth !== undefined) {
353 ret.numSamples[1] = depth;
354 if (stencil !== undefined) {
355 ret.numSamples[2] = stencil;
363 * @param {es3fFboCompletenessTests.numSamplesParamsT} params
366 es3fFboCompletenessTests.numSamplesParams.getName = function(params) {
370 for (var i = 0; i < 3; ++i) {
376 switch (params.numSamples[i]) {
377 case es3fFboCompletenessTests.e_samples.NONE: out += 'none'; break;
378 case es3fFboCompletenessTests.e_samples.TEXTURE: out += 'tex'; break;
379 default: out += 'rbo'; break;
385 * @param {es3fFboCompletenessTests.numSamplesParamsT} params
388 es3fFboCompletenessTests.numSamplesParams.getDescription = function(params) {
390 var names = ['color', 'depth', 'stencil'];
393 for (var i = 0; i < 3; ++i) {
399 if (params.numSamples[i] == es3fFboCompletenessTests.e_samples.TEXTURE) {
400 out += 'texture ' + names[i] + ' attachment';
402 out += params.numSamples[i] + '-sample renderbuffer ' + names[i] + ' attachment';
410 * @extends {glsFboCompletenessTests.TestBase}
411 * @param {string} name
412 * @param {string} desc
413 * @param {glsFboCompletenessTests.Context} ctx
414 * @param {es3fFboCompletenessTests.numSamplesParamsT} params
416 es3fFboCompletenessTests.NumSamplesTest = function(name, desc, ctx, params) {
417 glsFboCompletenessTests.TestBase.call(this, name, desc, params);
420 es3fFboCompletenessTests.NumSamplesTest.prototype = Object.create(glsFboCompletenessTests.TestBase.prototype);
421 es3fFboCompletenessTests.NumSamplesTest.prototype.constructor = es3fFboCompletenessTests.NumSamplesTest;
423 es3fFboCompletenessTests.NumSamplesTest.prototype.build = function(builder, gl) {
424 if (!(gl = gl || window.gl)) throw new Error('Invalid gl object');
427 gl.COLOR_ATTACHMENT0, gl.COLOR_ATTACHMENT1, gl.DEPTH_ATTACHMENT
429 // Non-integer formats for each attachment type.
430 // \todo [2013-12-17 lauri] Add fixed/floating/integer metadata for formats so
431 // we can pick one smartly or maybe try several.
433 gl.RGBA8, gl.RGB565, gl.DEPTH_COMPONENT24
436 var l = s_targets.length;
437 if (this.m_params.numSamples.length != l)
438 throw new Error('Wrong number of params.');
440 for (var i = 0; i < l; ++i) {
441 var target = s_targets[i];
442 var fmt = new glsFboUtil.ImageFormat(s_formats[i], gl.NONE);
444 var ns = this.m_params.numSamples[i];
445 if (ns == es3fFboCompletenessTests.e_samples.NONE)
447 if (ns == es3fFboCompletenessTests.e_samples.TEXTURE) {
448 this.attachTargetToNew(target, gl.TEXTURE, fmt, 64, 64, builder, gl);
450 var rboCfg = builder.makeConfig(glsFboUtil.Renderbuffer);
451 rboCfg.internalFormat = fmt;
452 rboCfg.width = rboCfg.height = 64;
453 rboCfg.numSamples = ns;
455 var rbo = builder.glCreateRbo(rboCfg);
456 // Implementations do not necessarily support sample sizes greater than 1.
457 if (builder.getError() == gl.INVALID_OPERATION) {
458 throw new Error('Unsupported number of samples.');
460 var att = builder.makeConfig(glsFboUtil.RenderbufferAttachment);
462 builder.glAttach(target, att);
469 es3fFboCompletenessTests.init = function() {
471 //(testCtx, renderCtx, factory) {
472 var fboCtx = new glsFboCompletenessTests.Context(null, gl, function() {
473 return new es3fFboCompletenessTests.ES3Checker();
476 fboCtx.addFormats(glsFboUtil.rangeArray(es3fFboCompletenessTests.s_es3Formats));
478 /** @const @type {tcuTestCase.DeqpTest} */
479 var testGroup = tcuTestCase.runner.testCases;
481 testGroup.addChild(fboCtx.createRenderableTests(gl));
482 testGroup.addChild(fboCtx.createAttachmentTests(gl));
483 testGroup.addChild(fboCtx.createSizeTests(gl));
485 /** @type {tcuTestCase.DeqpTest} */
486 var layerTests = tcuTestCase.newTest('layer', 'Tests for layer attachments');
489 var s_layersParams = [
490 es3fFboCompletenessTests.numLayersParams(gl.TEXTURE_2D_ARRAY, 1, 0),
491 es3fFboCompletenessTests.numLayersParams(gl.TEXTURE_2D_ARRAY, 1, 3),
492 es3fFboCompletenessTests.numLayersParams(gl.TEXTURE_2D_ARRAY, 4, 3),
493 es3fFboCompletenessTests.numLayersParams(gl.TEXTURE_2D_ARRAY, 4, 15),
494 es3fFboCompletenessTests.numLayersParams(gl.TEXTURE_3D, 1, 0),
495 es3fFboCompletenessTests.numLayersParams(gl.TEXTURE_3D, 1, 15),
496 es3fFboCompletenessTests.numLayersParams(gl.TEXTURE_3D, 4, 15),
497 es3fFboCompletenessTests.numLayersParams(gl.TEXTURE_3D, 64, 15)
500 for (var i = 0; i < s_layersParams.length; ++i) {
503 layerTests.addChild(new es3fFboCompletenessTests.NumLayersTest(
504 es3fFboCompletenessTests.numLayersParams.getName(s_layersParams[i]),
505 es3fFboCompletenessTests.numLayersParams.getDescription(s_layersParams[i]),
506 fboCtx, s_layersParams[i]
509 testGroup.addChild(layerTests);
511 /** @type {tcuTestCase.DeqpTest} */
512 var sampleTests = tcuTestCase.newTest('sample', 'Tests for multisample attachments');
514 var samples = es3fFboCompletenessTests.e_samples;
517 var s_samplesParams = [
518 es3fFboCompletenessTests.numSamplesParams(0, samples.NONE, samples.NONE),
519 es3fFboCompletenessTests.numSamplesParams(1, samples.NONE, samples.NONE),
520 es3fFboCompletenessTests.numSamplesParams(2, samples.NONE, samples.NONE),
521 es3fFboCompletenessTests.numSamplesParams(0, samples.TEXTURE, samples.NONE),
522 es3fFboCompletenessTests.numSamplesParams(1, samples.TEXTURE, samples.NONE),
523 es3fFboCompletenessTests.numSamplesParams(2, samples.TEXTURE, samples.NONE),
524 es3fFboCompletenessTests.numSamplesParams(2, 1, samples.NONE),
525 es3fFboCompletenessTests.numSamplesParams(2, 2, samples.NONE),
526 es3fFboCompletenessTests.numSamplesParams(0, 0, samples.TEXTURE),
527 es3fFboCompletenessTests.numSamplesParams(1, 2, 0),
528 es3fFboCompletenessTests.numSamplesParams(2, 2, 0),
529 es3fFboCompletenessTests.numSamplesParams(1, 1, 1),
530 es3fFboCompletenessTests.numSamplesParams(1, 2, 4)
533 for (var i = 0; i < s_samplesParams.length; ++i) {
536 sampleTests.addChild(new es3fFboCompletenessTests.NumSamplesTest(
537 es3fFboCompletenessTests.numSamplesParams.getName(s_samplesParams[i]),
538 es3fFboCompletenessTests.numSamplesParams.getDescription(s_samplesParams[i]),
539 fboCtx, s_samplesParams[i]
542 testGroup.addChild(sampleTests);
546 es3fFboCompletenessTests.run = function() {
547 var testName = 'completeness';
548 var testDescription = 'Completeness tests';
549 var state = tcuTestCase.runner;
551 state.testName = testName;
552 state.testCases = tcuTestCase.newTest(testName, testDescription, null);
554 //Set up name and description of this test series.
555 setCurrentTestName(testName);
556 description(testDescription);
558 es3fFboCompletenessTests.init();
559 tcuTestCase.runner.runCallback(tcuTestCase.runTestCases);
561 bufferedLogToConsole(err);
562 tcuTestCase.runner.terminate();