1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL (ES) Module
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.
21 * \brief Framebuffer completeness tests.
22 *//*--------------------------------------------------------------------*/
24 #include "es2fFboCompletenessTests.hpp"
26 #include "glsFboCompletenessTests.hpp"
27 #include "gluObjectWrapper.hpp"
30 using deqp::gls::Range;
31 using namespace deqp::gls::FboUtil;
32 using namespace deqp::gls::FboUtil::config;
33 namespace fboc = deqp::gls::fboc;
34 typedef tcu::TestCase::IterateResult IterateResult;
43 static const FormatKey s_es2ColorRenderables[] =
45 GL_RGBA4, GL_RGB5_A1, GL_RGB565,
48 // GLES2 does not strictly allow these, but this seems to be a bug in the
49 // specification. For now, let's assume the unsized formats corresponding to
50 // the color-renderable sized formats are allowed.
51 // See https://cvs.khronos.org/bugzilla/show_bug.cgi?id=7333
53 static const FormatKey s_es2UnsizedColorRenderables[] =
55 GLS_UNSIZED_FORMATKEY(GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4),
56 GLS_UNSIZED_FORMATKEY(GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1),
57 GLS_UNSIZED_FORMATKEY(GL_RGB, GL_UNSIGNED_SHORT_5_6_5)
60 static const FormatKey s_es2DepthRenderables[] =
65 static const FormatKey s_es2StencilRenderables[] =
70 static const FormatEntry s_es2Formats[] =
72 { COLOR_RENDERABLE | TEXTURE_VALID,
73 GLS_ARRAY_RANGE(s_es2UnsizedColorRenderables) },
74 { REQUIRED_RENDERABLE | COLOR_RENDERABLE | RENDERBUFFER_VALID,
75 GLS_ARRAY_RANGE(s_es2ColorRenderables) },
76 { REQUIRED_RENDERABLE | DEPTH_RENDERABLE | RENDERBUFFER_VALID,
77 GLS_ARRAY_RANGE(s_es2DepthRenderables) },
78 { REQUIRED_RENDERABLE | STENCIL_RENDERABLE | RENDERBUFFER_VALID,
79 GLS_ARRAY_RANGE(s_es2StencilRenderables) },
82 // We have here only the extensions that are redundant in vanilla GLES3. Those
83 // that are applicable both to GLES2 and GLES3 are in glsFboCompletenessTests.cpp.
85 // GL_OES_texture_float
86 static const FormatKey s_oesTextureFloatFormats[] =
88 GLS_UNSIZED_FORMATKEY(GL_RGBA, GL_FLOAT),
89 GLS_UNSIZED_FORMATKEY(GL_RGB, GL_FLOAT),
92 // GL_OES_texture_half_float
93 static const FormatKey s_oesTextureHalfFloatFormats[] =
95 GLS_UNSIZED_FORMATKEY(GL_RGBA, GL_HALF_FLOAT_OES),
96 GLS_UNSIZED_FORMATKEY(GL_RGB, GL_HALF_FLOAT_OES),
99 // GL_EXT_sRGB_write_control
100 static const FormatKey s_extSrgbWriteControlFormats[] =
105 // DEQP_gles3_core_no_extension_features
106 static const FormatKey s_es3NoExtRboFormats[] =
110 static const FormatKey s_es3NoExtTextureFormats[] =
118 static const FormatKey s_es3NoExtTextureColorRenderableFormats[] =
124 // with ES3 core and GL_EXT_color_buffer_float
125 static const FormatKey s_es3NoExtExtColorBufferFloatFormats[] =
127 // \note Only the GLES2+exts subset of formats
128 GL_R11F_G11F_B10F, GL_RGBA16F, GL_RG16F, GL_R16F,
131 // with ES3 core with OES_texture_stencil8
132 static const FormatKey s_es3NoExtOesTextureStencil8Formats[] =
137 static const FormatExtEntry s_es2ExtFormats[] =
139 // The extension does not specify these to be color-renderable.
141 "GL_OES_texture_float",
142 (deUint32)TEXTURE_VALID,
143 GLS_ARRAY_RANGE(s_oesTextureFloatFormats)
146 "GL_OES_texture_half_float",
147 (deUint32)TEXTURE_VALID,
148 GLS_ARRAY_RANGE(s_oesTextureHalfFloatFormats)
151 // GL_EXT_sRGB_write_control makes SRGB8_ALPHA8 color-renderable
153 "GL_EXT_sRGB_write_control",
154 (deUint32)(REQUIRED_RENDERABLE | TEXTURE_VALID | COLOR_RENDERABLE | RENDERBUFFER_VALID),
155 GLS_ARRAY_RANGE(s_extSrgbWriteControlFormats)
158 // Since GLES3 is "backwards compatible" to GLES2, we might actually be running on a GLES3
159 // context. Since GLES3 added some features to core with no corresponding GLES2 extension,
160 // some tests might produce wrong results (since they are using rules of GLES2 & extensions)
162 // To avoid this, require new features of GLES3 that have no matching GLES2 extension if
163 // context is GLES3. This can be done with a DEQP_* extensions.
165 // \note Not all feature changes are listed here but only those that alter GLES2 subset of
168 "DEQP_gles3_core_compatible",
169 (deUint32)(REQUIRED_RENDERABLE | COLOR_RENDERABLE | RENDERBUFFER_VALID),
170 GLS_ARRAY_RANGE(s_es3NoExtRboFormats)
173 "DEQP_gles3_core_compatible",
174 (deUint32)TEXTURE_VALID,
175 GLS_ARRAY_RANGE(s_es3NoExtTextureFormats)
178 "DEQP_gles3_core_compatible",
179 (deUint32)(REQUIRED_RENDERABLE | TEXTURE_VALID | COLOR_RENDERABLE | RENDERBUFFER_VALID),
180 GLS_ARRAY_RANGE(s_es3NoExtTextureColorRenderableFormats)
183 "DEQP_gles3_core_compatible GL_EXT_color_buffer_float",
184 (deUint32)(REQUIRED_RENDERABLE | COLOR_RENDERABLE | RENDERBUFFER_VALID),
185 GLS_ARRAY_RANGE(s_es3NoExtExtColorBufferFloatFormats)
188 "DEQP_gles3_core_compatible GL_OES_texture_stencil8",
189 (deUint32)(REQUIRED_RENDERABLE | STENCIL_RENDERABLE | TEXTURE_VALID),
190 GLS_ARRAY_RANGE(s_es3NoExtOesTextureStencil8Formats)
194 class ES2Checker : public Checker
197 ES2Checker (const glu::RenderContext& ctx);
198 void check (GLenum attPoint, const Attachment& att,
201 GLsizei m_width; //< The common width of images
202 GLsizei m_height; //< The common height of images
205 ES2Checker::ES2Checker (const glu::RenderContext& ctx)\
212 void ES2Checker::check (GLenum attPoint, const Attachment& att, const Image* image)
216 // GLES2: "All attached images have the same width and height."
219 m_width = image->width;
220 m_height = image->height;
222 else if (image->width != m_width || image->height != m_height)
224 // Since GLES3 is "backwards compatible" to GLES2, we might actually be running
225 // on a GLES3 context. On GLES3, FRAMEBUFFER_INCOMPLETE_DIMENSIONS is not generated
226 // if attachments have different sizes.
227 if (!gls::FboUtil::checkExtensionSupport(m_renderCtx, "DEQP_gles3_core_compatible"))
230 addFBOStatus(GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS, "Sizes of attachments differ");
233 // GLES2, 4.4.5: "some implementations may not support rendering to
234 // particular combinations of internal formats. If the combination of
235 // formats of the images attached to a framebuffer object are not
236 // supported by the implementation, then the framebuffer is not complete
237 // under the clause labeled FRAMEBUFFER_UNSUPPORTED."
239 // Hence it is _always_ allowed to report FRAMEBUFFER_UNSUPPORTED.
240 addPotentialFBOStatus(GL_FRAMEBUFFER_UNSUPPORTED, "Particular format combinations need not to be supported");
243 struct FormatCombination
246 ImageFormat colorFmt;
248 ImageFormat depthFmt;
250 ImageFormat stencilFmt;
253 class SupportedCombinationTest : public fboc::TestBase
256 SupportedCombinationTest (fboc::Context& ctx,
257 const char* name, const char* desc)
258 : TestBase (ctx, name, desc) {}
260 IterateResult iterate (void);
261 bool tryCombination (const FormatCombination& comb);
262 GLenum formatKind (ImageFormat fmt);
265 bool SupportedCombinationTest::tryCombination (const FormatCombination& comb)
267 glu::Framebuffer fbo(m_ctx.getRenderContext());
268 FboBuilder builder(*fbo, GL_FRAMEBUFFER, fboc::gl(*this));
270 attachTargetToNew(GL_COLOR_ATTACHMENT0, comb.colorKind, comb.colorFmt,
272 attachTargetToNew(GL_DEPTH_ATTACHMENT, comb.depthKind, comb.depthFmt,
274 attachTargetToNew(GL_STENCIL_ATTACHMENT, comb.stencilKind, comb.stencilFmt,
277 const GLenum glStatus = fboc::gl(*this).checkFramebufferStatus(GL_FRAMEBUFFER);
279 return (glStatus == GL_FRAMEBUFFER_COMPLETE);
282 GLenum SupportedCombinationTest::formatKind (ImageFormat fmt)
284 if (fmt.format == GL_NONE)
287 const FormatFlags flags = m_ctx.getCoreFormats().getFormatInfo(fmt);
288 const bool rbo = (flags & RENDERBUFFER_VALID) != 0;
289 // exactly one of renderbuffer and texture is supported by vanilla GLES2 formats
290 DE_ASSERT(rbo != ((flags & TEXTURE_VALID) != 0));
292 return rbo ? GL_RENDERBUFFER : GL_TEXTURE;
295 IterateResult SupportedCombinationTest::iterate (void)
297 const FormatDB& db = m_ctx.getCoreFormats();
298 const ImageFormat none = ImageFormat::none();
299 Formats colorFmts = db.getFormats(COLOR_RENDERABLE);
300 Formats depthFmts = db.getFormats(DEPTH_RENDERABLE);
301 Formats stencilFmts = db.getFormats(STENCIL_RENDERABLE);
302 FormatCombination comb;
305 colorFmts.insert(none);
306 depthFmts.insert(none);
307 stencilFmts.insert(none);
309 for (Formats::const_iterator col = colorFmts.begin(); col != colorFmts.end(); col++)
311 comb.colorFmt = *col;
312 comb.colorKind = formatKind(*col);
313 for (Formats::const_iterator dep = depthFmts.begin(); dep != depthFmts.end(); dep++)
315 comb.depthFmt = *dep;
316 comb.depthKind = formatKind(*dep);
317 for (Formats::const_iterator stc = stencilFmts.begin();
318 stc != stencilFmts.end(); stc++)
320 comb.stencilFmt = *stc;
321 comb.stencilKind = formatKind(*stc);
322 succ = tryCombination(comb);
332 fail("No supported format combination found");
337 class ES2CheckerFactory : public CheckerFactory
340 Checker* createChecker (const glu::RenderContext& ctx) { return new ES2Checker(ctx); }
343 class TestGroup : public TestCaseGroup
346 TestGroup (Context& ctx);
349 ES2CheckerFactory m_checkerFactory;
350 fboc::Context m_fboc;
353 TestGroup::TestGroup (Context& ctx)
354 : TestCaseGroup (ctx, "completeness", "Completeness tests")
355 , m_checkerFactory ()
356 , m_fboc (ctx.getTestContext(), ctx.getRenderContext(), m_checkerFactory)
358 const FormatEntries stdRange = GLS_ARRAY_RANGE(s_es2Formats);
359 const FormatExtEntries extRange = GLS_ARRAY_RANGE(s_es2ExtFormats);
361 m_fboc.addFormats(stdRange);
362 m_fboc.addExtFormats(extRange);
363 m_fboc.setHaveMulticolorAtts(
364 ctx.getContextInfo().isExtensionSupported("GL_NV_fbo_color_attachments"));
367 void TestGroup::init (void)
369 tcu::TestCaseGroup* attCombTests = m_fboc.createAttachmentTests();
370 addChild(m_fboc.createRenderableTests());
371 attCombTests->addChild(new SupportedCombinationTest(
374 "Test for existence of a supported combination of formats"));
375 addChild(attCombTests);
376 addChild(m_fboc.createSizeTests());
379 tcu::TestCaseGroup* createFboCompletenessTests (Context& context)
381 return new TestGroup(context);