2 goog
.provide('modules.shared.glsFboCompletenessTests');
3 goog
.require('framework.common.tcuTestCase');
4 goog
.require('framework.opengl.gluObjectWrapper');
5 goog
.require('framework.opengl.gluStrUtil');
6 goog
.require('modules.shared.glsFboUtil');
8 goog
.scope(function() {
10 var glsFboCompletenessTests
= modules
.shared
.glsFboCompletenessTests
;
11 var glsFboUtil
= modules
.shared
.glsFboUtil
;
12 var gluObjectWrapper
= framework
.opengl
.gluObjectWrapper
;
13 var gluStrUtil
= framework
.opengl
.gluStrUtil
;
14 var tcuTestCase
= framework
.common
.tcuTestCase
;
17 * @param {WebGL2RenderingContext} gl
19 glsFboCompletenessTests
.initGlDependents = function(gl
) {
20 if (!(gl
= gl
|| window
.gl
)) throw new Error('Invalid gl object');
22 // The following extensions are applicable both to ES2 and ES3.
25 * @type {Array<number>}
27 glsFboCompletenessTests
.s_oesDepthTextureFormats
= [
28 glsFboUtil
.formatkey(gl
.DEPTH_COMPONENT
, gl
.UNSIGNED_SHORT
),
29 glsFboUtil
.formatkey(gl
.DEPTH_COMPONENT
, gl
.UNSIGNED_INT
)
33 * OES_packed_depth_stencil
34 * @type {Array<number>}
36 glsFboCompletenessTests
.s_oesPackedDepthStencilSizedFormats
= [
41 * s_oesPackedDepthStencilTexFormats
42 * @type {Array<number>}
44 glsFboCompletenessTests
.s_oesPackedDepthStencilTexFormats
= [
45 glsFboUtil
.formatkey(gl
.DEPTH_STENCIL
, gl
.UNSIGNED_INT_24_8
)
49 * OES_required_internalformat
50 * @type {Array<number>}
52 glsFboCompletenessTests
.s_oesRequiredInternalFormatColorFormats
= [
53 // Same as ES2 RBO formats, plus RGBA8 (even without OES_rgb8_rgba8)
54 gl
.RGB5_A1
, gl
.RGBA8
, gl
.RGBA4
, gl
.RGB565
58 * s_oesRequiredInternalFormatDepthFormats
59 * @type {Array<number>}
61 glsFboCompletenessTests
.s_oesRequiredInternalFormatDepthFormats
= [
66 * EXT_color_buffer_half_float
67 * @type {Array<number>}
69 glsFboCompletenessTests
.s_extColorBufferHalfFloatFormats
= [
70 gl
.RGBA16F
, gl
.RGB16F
, gl
.RG16F
, gl
.R16F
74 * s_oesDepth24SizedFormats
75 * @type {Array<number>}
77 glsFboCompletenessTests
.s_oesDepth24SizedFormats
= [
82 * s_oesDepth32SizedFormats
83 * @type {Array<number>}
85 glsFboCompletenessTests
.s_oesDepth32SizedFormats
= [
86 gl
['DEPTH_COMPONENT32']
90 * s_oesRgb8Rgba8RboFormats
91 * @type {Array<number>}
93 glsFboCompletenessTests
.s_oesRgb8Rgba8RboFormats
= [
98 * s_oesRequiredInternalFormatRgb8ColorFormat
99 * @type {Array<number>}
101 glsFboCompletenessTests
.s_oesRequiredInternalFormatRgb8ColorFormat
= [
106 * s_extTextureType2101010RevFormats
107 * @type {Array<number>}
109 glsFboCompletenessTests
.s_extTextureType2101010RevFormats
= [
110 glsFboUtil
.formatkey(gl
.RGBA
, gl
.UNSIGNED_INT_2_10_10_10_REV
),
111 glsFboUtil
.formatkey(gl
.RGB
, gl
.UNSIGNED_INT_2_10_10_10_REV
)
115 * s_oesRequiredInternalFormat10bitColorFormats
116 * @type {Array<number>}
118 glsFboCompletenessTests
.s_oesRequiredInternalFormat10bitColorFormats
= [
119 gl
.RGB10_A2
, gl
['RGB10']
123 * s_extTextureRgRboFormats
124 * @type {Array<number>}
126 glsFboCompletenessTests
.s_extTextureRgRboFormats
= [
131 * s_extTextureRgTexFormats
132 * @type {Array<number>}
134 glsFboCompletenessTests
.s_extTextureRgTexFormats
= [
135 glsFboUtil
.formatkey(gl
.RED
, gl
.UNSIGNED_BYTE
),
136 glsFboUtil
.formatkey(gl
.RG
, gl
.UNSIGNED_BYTE
)
140 * s_extTextureRgFloatTexFormats
141 * @type {Array<number>}
143 glsFboCompletenessTests
.s_extTextureRgFloatTexFormats
= [
144 glsFboUtil
.formatkey(gl
.RED
, gl
.FLOAT
),
145 glsFboUtil
.formatkey(gl
.RG
, gl
.FLOAT
)
149 * s_extTextureRgHalfFloatTexFormats
150 * @type {Array<number>}
152 glsFboCompletenessTests
.s_extTextureRgHalfFloatTexFormats
= [
153 glsFboUtil
.formatkey(gl
.RED
, gl
['HALF_FLOAT_OES']),
154 glsFboUtil
.formatkey(gl
.RG
, gl
['HALF_FLOAT_OES'])
158 * s_nvPackedFloatRboFormats
159 * @type {Array<number>}
161 glsFboCompletenessTests
.s_nvPackedFloatRboFormats
= [
166 * s_nvPackedFloatTexFormats
167 * @type {Array<number>}
169 glsFboCompletenessTests
.s_nvPackedFloatTexFormats
= [
170 glsFboUtil
.formatkey(gl
.RGB
, gl
.UNSIGNED_INT_10F_11F_11F_REV
)
174 * s_extSrgbRboFormats
175 * @type {Array<number>}
177 glsFboCompletenessTests
.s_extSrgbRboFormats
= [
182 * s_extSrgbRenderableTexFormats
183 * @type {Array<number>}
185 glsFboCompletenessTests
.s_extSrgbRenderableTexFormats
= [
186 glsFboUtil
.formatkey(gl
['SRGB_ALPHA'], gl
.UNSIGNED_BYTE
)
190 * s_extSrgbNonRenderableTexFormats
191 * @type {Array<number>}
193 glsFboCompletenessTests
.s_extSrgbNonRenderableTexFormats
= [
194 glsFboUtil
.formatkey(gl
.SRGB
, gl
.UNSIGNED_BYTE
),
199 * s_nvSrgbFormatsRboFormats
200 * @type {Array<number>}
202 glsFboCompletenessTests
.s_nvSrgbFormatsRboFormats
= [
207 * s_nvSrgbFormatsTextureFormats
208 * The extension does not actually require any unsized format
209 * to be renderable. However, the renderablility of unsized
210 * SRGB,UBYTE internalformat-type pair is implied.
211 * @type {Array<number>}
213 glsFboCompletenessTests
.s_nvSrgbFormatsTextureFormats
= [
215 glsFboUtil
.formatkey(gl
.SRGB
, gl
.UNSIGNED_BYTE
)
219 * s_oesRgb8Rgba8TexFormats
220 * @type {Array<number>}
222 glsFboCompletenessTests
.s_oesRgb8Rgba8TexFormats
= [
223 glsFboUtil
.formatkey(gl
.RGB
, gl
.UNSIGNED_BYTE
),
224 glsFboUtil
.formatkey(gl
.RGBA
, gl
.UNSIGNED_BYTE
)
227 var fmt
= glsFboUtil
.FormatFlags
;
231 * @type {Array<glsFboUtil.FormatExtEntry>}
233 glsFboCompletenessTests
.s_esExtFormats
= [
234 new glsFboUtil
.FormatExtEntry(
236 fmt
.REQUIRED_RENDERABLE
| fmt
.DEPTH_RENDERABLE
| fmt
.TEXTURE_VALID
,
237 glsFboUtil
.rangeArray(glsFboCompletenessTests
.s_oesDepthTextureFormats
)
239 new glsFboUtil
.FormatExtEntry(
240 'OES_packed_depth_stencil',
241 fmt
.REQUIRED_RENDERABLE
| fmt
.DEPTH_RENDERABLE
| fmt
.STENCIL_RENDERABLE
| fmt
.RENDERBUFFER_VALID
,
242 glsFboUtil
.rangeArray(glsFboCompletenessTests
.s_oesPackedDepthStencilSizedFormats
)
244 new glsFboUtil
.FormatExtEntry(
245 'OES_packed_depth_stencil OES_required_internalformat',
246 fmt
.DEPTH_RENDERABLE
| fmt
.STENCIL_RENDERABLE
| fmt
.TEXTURE_VALID
,
247 glsFboUtil
.rangeArray(glsFboCompletenessTests
.s_oesPackedDepthStencilTexFormats
)
250 // \todo [2013-12-10 lauri] Find out if OES_texture_half_float is really a
251 // requirement on ES3 also. Or is color_buffer_half_float applicatble at
252 // all on ES3, since there's also EXT_color_buffer_float?
253 new glsFboUtil
.FormatExtEntry(
254 'OES_texture_half_float EXT_color_buffer_half_float',
255 fmt
.REQUIRED_RENDERABLE
| fmt
.COLOR_RENDERABLE
| fmt
.RENDERBUFFER_VALID
,
256 glsFboUtil
.rangeArray(glsFboCompletenessTests
.s_extColorBufferHalfFloatFormats
)
259 // OES_required_internalformat doesn't actually specify that these are renderable,
260 // since it was written against ES 1.1.
261 new glsFboUtil
.FormatExtEntry(
262 'OES_required_internalformat',
263 // Allow but don't require RGBA8 to be color-renderable if
264 // OES_rgb8_rgba8 is not present.
265 fmt
.COLOR_RENDERABLE
| fmt
.TEXTURE_VALID
,
266 glsFboUtil
.rangeArray(glsFboCompletenessTests
.s_oesRequiredInternalFormatColorFormats
)
268 new glsFboUtil
.FormatExtEntry(
269 'OES_required_internalformat',
270 fmt
.DEPTH_RENDERABLE
| fmt
.TEXTURE_VALID
,
271 glsFboUtil
.rangeArray(glsFboCompletenessTests
.s_oesRequiredInternalFormatDepthFormats
)
273 new glsFboUtil
.FormatExtEntry(
275 fmt
.REQUIRED_RENDERABLE
| fmt
.COLOR_RENDERABLE
| fmt
.RENDERBUFFER_VALID
,
276 glsFboUtil
.rangeArray(glsFboCompletenessTests
.s_extTextureRgRboFormats
)
279 // These are not specified to be color-renderable, but the wording is
280 // exactly as ambiguous as the wording in the ES2 spec.
281 new glsFboUtil
.FormatExtEntry(
283 fmt
.REQUIRED_RENDERABLE
| fmt
.TEXTURE_VALID
,
284 glsFboUtil
.rangeArray(glsFboCompletenessTests
.s_extTextureRgTexFormats
)
286 new glsFboUtil
.FormatExtEntry(
287 'EXT_texture_rg OES_texture_float',
288 fmt
.REQUIRED_RENDERABLE
| fmt
.TEXTURE_VALID
,
289 glsFboUtil
.rangeArray(glsFboCompletenessTests
.s_extTextureRgFloatTexFormats
)
291 new glsFboUtil
.FormatExtEntry(
292 'EXT_texture_rg OES_texture_half_float',
293 fmt
.REQUIRED_RENDERABLE
| fmt
.TEXTURE_VALID
,
294 glsFboUtil
.rangeArray(glsFboCompletenessTests
.s_extTextureRgHalfFloatTexFormats
)
297 // Some Tegra drivers report gl.EXT_packed_float even for ES. Treat it as
298 // a synonym for the NV_ version.
299 new glsFboUtil
.FormatExtEntry(
301 fmt
.REQUIRED_RENDERABLE
| fmt
.TEXTURE_VALID
,
302 glsFboUtil
.rangeArray(glsFboCompletenessTests
.s_nvPackedFloatTexFormats
)
304 new glsFboUtil
.FormatExtEntry(
305 'EXT_packed_float EXT_color_buffer_half_float',
306 fmt
.REQUIRED_RENDERABLE
| fmt
.COLOR_RENDERABLE
| fmt
.RENDERBUFFER_VALID
,
307 glsFboUtil
.rangeArray(glsFboCompletenessTests
.s_nvPackedFloatRboFormats
)
309 new glsFboUtil
.FormatExtEntry(
311 fmt
.COLOR_RENDERABLE
| fmt
.TEXTURE_VALID
,
312 glsFboUtil
.rangeArray(glsFboCompletenessTests
.s_extSrgbRenderableTexFormats
)
314 new glsFboUtil
.FormatExtEntry(
317 glsFboUtil
.rangeArray(glsFboCompletenessTests
.s_extSrgbNonRenderableTexFormats
)
319 new glsFboUtil
.FormatExtEntry(
321 fmt
.REQUIRED_RENDERABLE
| fmt
.COLOR_RENDERABLE
| fmt
.RENDERBUFFER_VALID
,
322 glsFboUtil
.rangeArray(glsFboCompletenessTests
.s_extSrgbRboFormats
)
324 new glsFboUtil
.FormatExtEntry(
326 fmt
.REQUIRED_RENDERABLE
| fmt
.COLOR_RENDERABLE
| fmt
.RENDERBUFFER_VALID
,
327 glsFboUtil
.rangeArray(glsFboCompletenessTests
.s_nvSrgbFormatsRboFormats
)
329 new glsFboUtil
.FormatExtEntry(
331 fmt
.REQUIRED_RENDERABLE
| fmt
.COLOR_RENDERABLE
| fmt
.TEXTURE_VALID
,
332 glsFboUtil
.rangeArray(glsFboCompletenessTests
.s_nvSrgbFormatsTextureFormats
)
335 // In Khronos bug 7333 discussion, the consensus is that these texture
336 // formats, at least, should be color-renderable. Still, that cannot be
337 // found in any extension specs, so only allow it, not require it.
338 new glsFboUtil
.FormatExtEntry(
340 fmt
.COLOR_RENDERABLE
| fmt
.TEXTURE_VALID
,
341 glsFboUtil
.rangeArray(glsFboCompletenessTests
.s_oesRgb8Rgba8TexFormats
)
343 new glsFboUtil
.FormatExtEntry(
345 fmt
.REQUIRED_RENDERABLE
| fmt
.COLOR_RENDERABLE
| fmt
.RENDERBUFFER_VALID
,
346 glsFboUtil
.rangeArray(glsFboCompletenessTests
.s_oesRgb8Rgba8RboFormats
)
348 new glsFboUtil
.FormatExtEntry(
349 'OES_rgb8_rgba8 OES_required_internalformat',
351 glsFboUtil
.rangeArray(glsFboCompletenessTests
.s_oesRequiredInternalFormatRgb8ColorFormat
)
354 // The depth-renderability of the depth RBO formats is not explicitly
355 // spelled out, but all renderbuffer formats are meant to be renderable.
356 new glsFboUtil
.FormatExtEntry(
358 fmt
.REQUIRED_RENDERABLE
| fmt
.DEPTH_RENDERABLE
| fmt
.RENDERBUFFER_VALID
,
359 glsFboUtil
.rangeArray(glsFboCompletenessTests
.s_oesDepth24SizedFormats
)
361 new glsFboUtil
.FormatExtEntry(
362 'OES_depth24 OES_required_internalformat OES_depth_texture',
364 glsFboUtil
.rangeArray(glsFboCompletenessTests
.s_oesDepth24SizedFormats
)
367 new glsFboUtil
.FormatExtEntry(
369 fmt
.REQUIRED_RENDERABLE
| fmt
.DEPTH_RENDERABLE
| fmt
.RENDERBUFFER_VALID
,
370 glsFboUtil
.rangeArray(glsFboCompletenessTests
.s_oesDepth32SizedFormats
)
372 new glsFboUtil
.FormatExtEntry(
373 'OES_depth32 OES_required_internalformat OES_depth_texture',
375 glsFboUtil
.rangeArray(glsFboCompletenessTests
.s_oesDepth32SizedFormats
)
378 new glsFboUtil
.FormatExtEntry(
379 'EXT_texture_type_2_10_10_10_REV',
380 fmt
.TEXTURE_VALID
, // explicitly unrenderable
381 glsFboUtil
.rangeArray(glsFboCompletenessTests
.s_extTextureType2101010RevFormats
)
383 new glsFboUtil
.FormatExtEntry(
384 'EXT_texture_type_2_10_10_10_REV OES_required_internalformat',
385 fmt
.TEXTURE_VALID
, // explicitly unrenderable
386 glsFboUtil
.rangeArray(glsFboCompletenessTests
.s_oesRequiredInternalFormat10bitColorFormats
)
390 }; // initGlDependents ----------------------------------------
394 * @param {null} testCtx
395 * @param {WebGLRenderingContextBase} renderCtx
396 * @param {glsFboUtil.CheckerFactory} factory
398 glsFboCompletenessTests
.Context = function(testCtx
, renderCtx
, factory
) {
400 this.m_testCtx
= testCtx
;
401 this.m_renderCtx
= renderCtx
;
402 this.m_ctxFormats
= new glsFboUtil
.FormatDB();
403 this.m_minFormats
= new glsFboUtil
.FormatDB();
404 this.m_maxFormats
= new glsFboUtil
.FormatDB();
405 this.m_verifier
= new glsFboUtil
.FboVerifier(this.m_ctxFormats
, factory
);
406 this.m_haveMultiColorAtts
= false;
409 var extRange
= glsFboUtil
.rangeArray(glsFboCompletenessTests
.s_esExtFormats
);
410 this.addExtFormats(extRange
);
415 glsFboCompletenessTests
.Context
.prototype.getRenderContext = function() {
416 return this.m_renderCtx
;
420 glsFboCompletenessTests
.Context
.prototype.getTestContext = function() {
421 return this.m_testCtx
;
424 // const FboVerifier&
425 glsFboCompletenessTests
.Context
.prototype.getVerifier = function() {
426 return this.m_verifier
;
430 glsFboCompletenessTests
.Context
.prototype.getMinFormats = function() {
431 return this.m_minFormats
;
435 glsFboCompletenessTests
.Context
.prototype.getCtxFormats = function() {
436 return this.m_ctxFormats
;
440 glsFboCompletenessTests
.Context
.prototype.haveMultiColorAtts = function() {
441 return this.m_haveMultiColorAtts
;
444 glsFboCompletenessTests
.Context
.prototype.setHaveMulticolorAtts = function(have
) {
445 this.m_haveMultiColorAtts
= (have
== true);
448 glsFboCompletenessTests
.Context
.prototype.addFormats = function(fmtRange
) {
449 glsFboUtil
.addFormats(this.m_minFormats
, fmtRange
);
450 glsFboUtil
.addFormats(this.m_ctxFormats
, fmtRange
);
451 glsFboUtil
.addFormats(this.m_maxFormats
, fmtRange
);
453 glsFboCompletenessTests
.Context
.prototype.addExtFormats = function(extRange
) {
454 glsFboUtil
.addExtFormats(this.m_ctxFormats
, extRange
, this.m_renderCtx
);
455 glsFboUtil
.addExtFormats(this.m_maxFormats
, extRange
, this.m_renderCtx
);
458 glsFboCompletenessTests
.Context
.prototype.createRenderableTests = function(gl
) {
460 /** @type {tcuTestCase.DeqpTest} */
461 var renderableTests
= tcuTestCase
.newTest('renderable', 'Tests for support of renderable image formats');
462 /** @type {tcuTestCase.DeqpTest} */
463 var rbRenderableTests
= tcuTestCase
.newTest('renderbuffer', 'Tests for renderbuffer formats');
464 /** @type {tcuTestCase.DeqpTest} */
465 var texRenderableTests
= tcuTestCase
.newTest('texture', 'Tests for texture formats');
468 [gl
.DEPTH_ATTACHMENT
, 'depth', 'Tests for depth attachments'],
469 [gl
.STENCIL_ATTACHMENT
, 'stencil', 'Tests for stencil attachments'],
470 [gl
.COLOR_ATTACHMENT0
, 'color0', 'Tests for color attachments']
473 // At each attachment point, iterate through all the possible formats to
474 // detect both false positives and false negatives.
475 var rboFmts
= this.m_maxFormats
.getFormats(glsFboUtil
.FormatFlags
.ANY_FORMAT
);
476 var texFmts
= this.m_maxFormats
.getFormats(glsFboUtil
.FormatFlags
.ANY_FORMAT
);
478 for (var i
= 0, l_attPoints
= attPoints
.length
; i
< l_attPoints
; ++i
) {
479 var rbAttTests
= tcuTestCase
.newTest(attPoints
[i
][1], attPoints
[i
][2]);
480 var texAttTests
= tcuTestCase
.newTest(attPoints
[i
][1], attPoints
[i
][2]);
482 for (var j
= 0, l_rboFmts
= rboFmts
.length
; j
< l_rboFmts
; ++j
) {
483 var params
= glsFboCompletenessTests
.renderableParams(
484 attPoints
[i
][0], gl
.RENDERBUFFER
, rboFmts
[j
]
487 new glsFboCompletenessTests
.RenderableTest(
488 glsFboCompletenessTests
.renderableParams
.getName(params
),
489 glsFboCompletenessTests
.renderableParams
.getDescription(params
),
494 rbRenderableTests
.addChild(rbAttTests
);
496 for (var j
= 0, l_texFmts
= texFmts
.length
; j
< l_texFmts
; ++j
) {
497 var params
= glsFboCompletenessTests
.renderableParams(
498 attPoints
[i
][0], gl
.TEXTURE
, texFmts
[j
]
500 texAttTests
.addChild(
501 new glsFboCompletenessTests
.RenderableTest(
502 glsFboCompletenessTests
.renderableParams
.getName(params
),
503 glsFboCompletenessTests
.renderableParams
.getDescription(params
),
508 texRenderableTests
.addChild(texAttTests
);
511 renderableTests
.addChild(rbRenderableTests
);
512 renderableTests
.addChild(texRenderableTests
);
514 return renderableTests
;
517 glsFboCompletenessTests
.Context
.prototype.createAttachmentTests = function(gl
) {
519 var attCombTests
= tcuTestCase
.newTest('attachment_combinations', 'Tests for attachment combinations');
521 var s_bufTypes
= [gl
.NONE
, gl
.RENDERBUFFER
, gl
.TEXTURE
];
522 var ls_bufTypes
= s_bufTypes
.length
;
524 for (var col0
= 0; col0
< ls_bufTypes
; ++col0
)
525 for (var coln
= 0; coln
< ls_bufTypes
; ++coln
)
526 for (var dep
= 0; dep
< ls_bufTypes
; ++dep
)
527 for (var stc
= 0; stc
< ls_bufTypes
; ++stc
) {
528 var params
= glsFboCompletenessTests
.attachmentParams(
529 s_bufTypes
[col0
], s_bufTypes
[coln
], s_bufTypes
[dep
], s_bufTypes
[stc
]
531 attCombTests
.addChild(new glsFboCompletenessTests
.AttachmentTest(
532 glsFboCompletenessTests
.attachmentParams
.getName(params
),
533 glsFboCompletenessTests
.attachmentParams
.getDescription(params
),
540 glsFboCompletenessTests
.Context
.prototype.createSizeTests = function(gl
) {
542 var sizeTests
= tcuTestCase
.newTest('size', 'Tests for attachment sizes');
544 sizeTests
.addChild(new glsFboCompletenessTests
.EmptyImageTest(
545 'zero', 'Test for zero-sized image attachment', this
554 * @extends {tcuTestCase.DeqpTest}
555 * @param {string} name
556 * @param {string} desc
557 * @param {Object} params
559 glsFboCompletenessTests
.TestBase = function(name
, desc
, params
) {
560 tcuTestCase
.DeqpTest
.call(this, name
, desc
);
561 this.m_params
= params
;
563 glsFboCompletenessTests
.TestBase
.prototype = Object
.create(tcuTestCase
.DeqpTest
.prototype);
564 glsFboCompletenessTests
.TestBase
.prototype.constructor = glsFboCompletenessTests
.TestBase
;
566 glsFboCompletenessTests
.TestBase
.prototype.getContext = function() {
567 return tcuTestCase
.runner
;
570 // GLenum attPoint, GLenum bufType
572 * @param {number} attPoint
573 * @param {number} bufType
574 * @param {WebGLRenderingContextBase=} gl
576 glsFboCompletenessTests
.TestBase
.prototype.getDefaultFormat = function(attPoint
, bufType
, gl
) {
577 gl
= gl
|| window
.gl
;
579 if (bufType
== gl
.NONE
) {
580 return glsFboUtil
.ImageFormat
.none();
583 // Prefer a standard format, if there is one, but if not, use a format
584 // provided by an extension.
585 var formats
= this.m_ctx
.getMinFormats().getFormats(
586 glsFboUtil
.formatFlag(attPoint
, gl
) | glsFboUtil
.formatFlag(bufType
, gl
)
589 if (!formats
.length
) {
590 formats
= this.m_ctx
.getCtxFormats().getFormats(
591 glsFboUtil
.formatFlag(attPoint
, gl
) | glsFboUtil
.formatFlag(bufType
, gl
)
594 if (!formats
.length
) {
595 throw new Error('Unsupported attachment kind for attachment point');
603 * @param {number} bufType
604 * @param {glsFboUtil.ImageFormat} format
605 * @param {number} width
606 * @param {number} height
607 * @param {glsFboUtil.FboBuilder} builder
608 * @param {WebGLRenderingContextBase=} gl
609 * @return {glsFboUtil.Image}
611 glsFboCompletenessTests
.makeImage = function(bufType
, format
, width
, height
, builder
, gl
) {
612 gl
= gl
|| window
.gl
;
618 case gl
.RENDERBUFFER
:
619 image
= /** @type {glsFboUtil.Renderbuffer}*/(builder
.makeConfig(glsFboUtil
.Renderbuffer
));
622 image
= /** @type {glsFboUtil.Texture2D}*/(builder
.makeConfig(glsFboUtil
.Texture2D
));
625 throw new Error('Impossible case');
627 image
.internalFormat
= format
;
629 image
.height
= height
;
634 * @param {number} bufType
635 * @param {glsFboUtil.ImageFormat} format
636 * @param {number} width
637 * @param {number} height
638 * @param {glsFboUtil.FboBuilder} builder
639 * @param {WebGLRenderingContextBase=} gl
640 * @return {glsFboUtil.Attachment}
642 glsFboCompletenessTests
.makeAttachment = function(bufType
, format
, width
, height
, builder
, gl
) {
643 gl
= gl
|| window
.gl
;
644 var cfg
= glsFboCompletenessTests
.makeImage(bufType
, format
, width
, height
, builder
, gl
);
645 if (cfg
== null) return null;
647 /** @type {glsFboUtil.Attachment} */ var att
= null;
650 var mask
= glsFboUtil
.Config
.s_types
.RENDERBUFFER
| glsFboUtil
.Config
.s_types
.TEXTURE_2D
;
652 switch (cfg
.type
& mask
) {
653 case glsFboUtil
.Config
.s_types
.RENDERBUFFER
:
654 img
= builder
.glCreateRbo(/** @type {glsFboUtil.Renderbuffer} */(cfg
));
655 att
= /** @type {glsFboUtil.RenderbufferAttachment} */ (builder
.makeConfig(glsFboUtil
.RenderbufferAttachment
));
657 case glsFboUtil
.Config
.s_types
.TEXTURE_2D
:
658 img
= builder
.glCreateTexture(/** @type {glsFboUtil.Texture2D} */(cfg
));
659 att
= /** @type {glsFboUtil.TextureFlatAttachment} */ (builder
.makeConfig(glsFboUtil
.TextureFlatAttachment
));
660 att
.texTarget
= gl
.TEXTURE_2D
;
663 throw new Error('Unsupported config.');
669 //GLenum target, GLenum bufType, ImageFormat format, GLsizei width, GLsizei height, FboBuilder& builder, webglctx
671 * @param {number} target
672 * @param {number} bufType
673 * @param {glsFboUtil.ImageFormat} format
674 * @param {number} width
675 * @param {number} height
676 * @param {glsFboUtil.FboBuilder} builder
677 * @param {WebGL2RenderingContext} gl
679 glsFboCompletenessTests
.TestBase
.prototype.attachTargetToNew = function(
680 target
, bufType
, format
, width
, height
, builder
, gl
683 if (imgFmt
.format
== gl
.NONE
)
684 imgFmt
= this.getDefaultFormat(target
, bufType
, gl
);
685 var att
= glsFboCompletenessTests
.makeAttachment(bufType
, imgFmt
, width
, height
, builder
, gl
);
686 builder
.glAttach(target
, att
);
690 * @param {number} status
691 * @param {WebGLRenderingContextBase=} gl
694 glsFboCompletenessTests
.statusName = function(status
, gl
) {
695 gl
= gl
|| window
.gl
;
697 var errorName
= gluStrUtil
.getErrorName(status
);
698 if (status
!= gl
.NO_ERROR
&& errorName
!= '')
699 return errorName
+ ' (during FBO initialization)';
701 var fbStatusName
= gluStrUtil
.getFramebufferStatusName(status
);
702 if (fbStatusName
!= '')
705 return 'unknown value (' + status
+ ')';
708 glsFboCompletenessTests
.TestBase
.prototype.iterate = function() {
711 var fbo
= new gluObjectWrapper
.Framebuffer(gl
);
712 var builder
= new glsFboUtil
.FboBuilder(fbo
.get(), gl
.FRAMEBUFFER
, gl
);
713 var ret
= this.build(builder
, gl
);
714 var statuses
= this.m_ctx
.getVerifier().validStatusCodes(builder
, gl
);
716 var errorCode
= builder
.getError();
717 if (errorCode
!= gl
.NO_ERROR
) {
718 bufferedLogToConsole('Received ' + gluStrUtil
.getErrorName(errorCode
) + ' (during FBO initialization).');
719 if (statuses
.isErrorCodeValid(errorCode
))
721 else if (statuses
.isErrorCodeRequired(gl
.NO_ERROR
))
722 testFailedOptions('Excepted no error but got ' + gluStrUtil
.getErrorName(errorCode
), true);
724 testFailedOptions('Got wrong error code', true);
726 var fboStatus
= gl
.checkFramebufferStatus(gl
.FRAMEBUFFER
);
727 var validStatus
= statuses
.isFBOStatusValid(fboStatus
);
728 bufferedLogToConsole('Received ' + gluStrUtil
.getFramebufferStatusName(fboStatus
));
730 if (fboStatus
== gl
.FRAMEBUFFER_COMPLETE
) {
731 testFailedOptions('Framebuffer checked as complete, expected incomplete', true);
732 } else if (statuses
.isFBOStatusRequired(gl
.FRAMEBUFFER_COMPLETE
)) {
733 testFailedOptions('Framebuffer checked as incomplete, expected complete', true);
735 // An incomplete status is allowed, but not _this_ incomplete status.
736 testFailedOptions('Framebuffer checked as incomplete, but with wrong status', true);
738 } else if (fboStatus
!= gl
.FRAMEBUFFER_COMPLETE
&& statuses
.isFBOStatusValid(gl
.FRAMEBUFFER_COMPLETE
)) {
739 testPassedOptions('Warning: framebuffer object could have checked as complete but did not.', true);
747 return tcuTestCase
.IterateResult
.STOP
;
750 glsFboCompletenessTests
.formatName = function(format
, gl
) {
751 if (!(gl
= gl
|| window
.gl
)) throw new Error('Invalid GL object');
753 var s
= gluStrUtil
.getPixelFormatName(format
.format
).substr(3).toLowerCase();
755 if (format
.unsizedType
!= gl
.NONE
)
756 s
+= '_' + gluStrUtil
.getTypeName(format
.unsizedType
).substr(3).toLowerCase();
760 glsFboCompletenessTests
.formatDesc = function(format
, gl
) {
761 if (!(gl
= gl
|| window
.gl
)) throw new Error('Invalid GL object');
763 var s
= gluStrUtil
.getPixelFormatName(format
.format
);
765 if (format
.unsizedType
!= gl
.NONE
)
766 s
+= ' with type ' + gluStrUtil
.getTypeName(format
.unsizedType
);
772 * @typedef {{attPoint: number, bufType: number, format: glsFboUtil.ImageFormat}}
774 glsFboCompletenessTests
.renderableParamsT
;
777 * @param {number} attPoint
778 * @param {number} bufType
779 * @param {glsFboUtil.ImageFormat} format
780 * @return {glsFboCompletenessTests.renderableParamsT}
782 glsFboCompletenessTests
.renderableParams = function(attPoint
, bufType
, format
) {
791 * @param {glsFboCompletenessTests.renderableParamsT} params
792 * @param {WebGLRenderingContextBase=} gl
795 glsFboCompletenessTests
.renderableParams
.getName = function(params
, gl
) {
796 return glsFboCompletenessTests
.formatName(params
.format
, gl
);
799 * @param {glsFboCompletenessTests.renderableParamsT} params
800 * @param {WebGLRenderingContextBase=} gl
803 glsFboCompletenessTests
.renderableParams
.getDescription = function(params
, gl
) {
804 return glsFboCompletenessTests
.formatDesc(params
.format
, gl
);
809 * @extends {glsFboCompletenessTests.TestBase}
810 * @param {string} name
811 * @param {string} desc
812 * @param {glsFboCompletenessTests.Context} ctx
813 * @param {glsFboCompletenessTests.renderableParamsT} params
815 glsFboCompletenessTests
.RenderableTest = function(name
, desc
, ctx
, params
) {
816 glsFboCompletenessTests
.TestBase
.call(this, name
, desc
, params
);
819 glsFboCompletenessTests
.RenderableTest
.prototype = Object
.create(glsFboCompletenessTests
.TestBase
.prototype);
820 glsFboCompletenessTests
.RenderableTest
.prototype.constructor = glsFboCompletenessTests
.RenderableTest
;
822 glsFboCompletenessTests
.RenderableTest
.prototype.build = function(builder
, gl
) {
823 this.attachTargetToNew(this.m_params
.attPoint
, this.m_params
.bufType
, this.m_params
.format
, 64, 64, builder
, gl
);
827 glsFboCompletenessTests
.attTypeName = function(bufType
, gl
) {
828 if (!(gl
= gl
|| window
.gl
)) throw new Error('Invalid GL object');
830 case gl
.NONE
: return 'none';
831 case gl
.RENDERBUFFER
: return 'rbo';
832 case gl
.TEXTURE
: return 'tex';
835 throw new Error('Impossible case');
839 * @typedef {{color0Kind: number, colornKind: number, depthKind: number, stencilKind: number}}
841 glsFboCompletenessTests
.attachmentParamsT
;
844 * @param {number} color0Kind
845 * @param {number} colornKind
846 * @param {number} depthKind
847 * @param {number} stencilKind
848 * @return {glsFboCompletenessTests.attachmentParamsT}
850 glsFboCompletenessTests
.attachmentParams = function(color0Kind
, colornKind
, depthKind
, stencilKind
) {
852 color0Kind
: color0Kind
,
853 colornKind
: colornKind
,
854 depthKind
: depthKind
,
855 stencilKind
: stencilKind
860 * @param {glsFboCompletenessTests.attachmentParamsT} params
861 * @param {WebGLRenderingContextBase=} gl
864 glsFboCompletenessTests
.attachmentParams
.getName = function(params
, gl
) {
865 return (glsFboCompletenessTests
.attTypeName(params
.color0Kind
, gl
) + '_' +
866 glsFboCompletenessTests
.attTypeName(params
.colornKind
, gl
) + '_' +
867 glsFboCompletenessTests
.attTypeName(params
.depthKind
, gl
) + '_' +
868 glsFboCompletenessTests
.attTypeName(params
.stencilKind
, gl
));
871 * @param {glsFboCompletenessTests.attachmentParamsT} params
874 glsFboCompletenessTests
.attachmentParams
.getDescription
= glsFboCompletenessTests
.attachmentParams
.getName
;
878 * @extends {glsFboCompletenessTests.TestBase}
879 * @param {string} name
880 * @param {string} desc
881 * @param {glsFboCompletenessTests.Context} ctx
882 * @param {glsFboCompletenessTests.attachmentParamsT} params
884 glsFboCompletenessTests
.AttachmentTest = function(name
, desc
, ctx
, params
) {
885 glsFboCompletenessTests
.TestBase
.call(this, name
, desc
, params
);
888 glsFboCompletenessTests
.AttachmentTest
.prototype = Object
.create(glsFboCompletenessTests
.TestBase
.prototype);
889 glsFboCompletenessTests
.AttachmentTest
.prototype.constructor = glsFboCompletenessTests
.AttachmentTest
;
891 glsFboCompletenessTests
.AttachmentTest
.prototype.makeDepthAndStencil = function(builder
, gl
) {
893 /** @type {glsFboUtil.Attachment} */
896 if (this.m_params
.stencilKind
== this.m_params
.depthKind
) {
897 // If there is a common stencil+depth -format, try to use a common
898 // image for both attachments.
899 var flags
= glsFboUtil
.FormatFlags
.DEPTH_RENDERABLE
|
900 glsFboUtil
.FormatFlags
.STENCIL_RENDERABLE
|
901 glsFboUtil
.formatFlag(this.m_params
.stencilKind
, gl
);
903 var formats
= this.m_ctx
.getMinFormats().getFormats(flags
);
904 if (formats
.length
) {
905 var format
= formats
[0];
906 att
= glsFboCompletenessTests
.makeAttachment(this.m_params
.depthKind
, format
, 64, 64, builder
, gl
);
907 builder
.glAttach(gl
.DEPTH_ATTACHMENT
, att
);
908 builder
.glAttach(gl
.STENCIL_ATTACHMENT
, att
);
912 // Either the kinds were separate, or a suitable format was not found.
913 // Create separate images.
914 this.attachTargetToNew(gl
.STENCIL_ATTACHMENT
, this.m_params
.stencilKind
,
915 glsFboUtil
.ImageFormat
.none(), 64, 64, builder
, gl
);
916 this.attachTargetToNew(gl
.DEPTH_ATTACHMENT
, this.m_params
.depthKind
,
917 glsFboUtil
.ImageFormat
.none(), 64, 64, builder
, gl
);
920 glsFboCompletenessTests
.AttachmentTest
.prototype.build = function(builder
, gl
) {
922 this.attachTargetToNew(gl
.COLOR_ATTACHMENT0
, this.m_params
.color0Kind
,
923 glsFboUtil
.ImageFormat
.none(), 64, 64, builder
, gl
);
925 if (this.m_params
.colornKind
!= gl
.NONE
) {
926 if (this.m_ctx
.haveMultiColorAtts())
927 throw new Error('Multiple attachments not supported');
928 var maxAttachments
= gl
.getParameter(gl
.MAX_COLOR_ATTACHMENTS
);
930 for (var i
= 1; i
< maxAttachments
; ++i
) {
931 this.attachTargetToNew(gl
.COLOR_ATTACHMENT0
+ i
, this.m_params
.colornKind
,
932 glsFboUtil
.ImageFormat
.none(), 64, 64, builder
, gl
);
936 this.makeDepthAndStencil(builder
, gl
);
943 * @extends {glsFboCompletenessTests.TestBase}
944 * @param {string} name
945 * @param {string} desc
946 * @param {glsFboCompletenessTests.Context} ctx
948 glsFboCompletenessTests
.EmptyImageTest = function(name
, desc
, ctx
) {
949 glsFboCompletenessTests
.TestBase
.call(this, name
, desc
, null);
952 glsFboCompletenessTests
.EmptyImageTest
.prototype = Object
.create(glsFboCompletenessTests
.TestBase
.prototype);
953 glsFboCompletenessTests
.EmptyImageTest
.prototype.constructor = glsFboCompletenessTests
.EmptyImageTest
;
955 glsFboCompletenessTests
.EmptyImageTest
.prototype.build = function(builder
, gl
) {
956 this.attachTargetToNew(gl
.COLOR_ATTACHMENT0
, gl
.RENDERBUFFER
,
957 glsFboUtil
.ImageFormat
.none(), 0, 0, builder
, gl
);