1e5c31af7Sopenharmony_ci/*------------------------------------------------------------------------- 2e5c31af7Sopenharmony_ci * drawElements Quality Program OpenGL (ES) Module 3e5c31af7Sopenharmony_ci * ----------------------------------------------- 4e5c31af7Sopenharmony_ci * 5e5c31af7Sopenharmony_ci * Copyright 2014 The Android Open Source Project 6e5c31af7Sopenharmony_ci * 7e5c31af7Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 8e5c31af7Sopenharmony_ci * you may not use this file except in compliance with the License. 9e5c31af7Sopenharmony_ci * You may obtain a copy of the License at 10e5c31af7Sopenharmony_ci * 11e5c31af7Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 12e5c31af7Sopenharmony_ci * 13e5c31af7Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 14e5c31af7Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 15e5c31af7Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16e5c31af7Sopenharmony_ci * See the License for the specific language governing permissions and 17e5c31af7Sopenharmony_ci * limitations under the License. 18e5c31af7Sopenharmony_ci * 19e5c31af7Sopenharmony_ci *//*! 20e5c31af7Sopenharmony_ci * \file 21e5c31af7Sopenharmony_ci * \brief Framebuffer completeness tests. 22e5c31af7Sopenharmony_ci *//*--------------------------------------------------------------------*/ 23e5c31af7Sopenharmony_ci 24e5c31af7Sopenharmony_ci#include "es2fFboCompletenessTests.hpp" 25e5c31af7Sopenharmony_ci 26e5c31af7Sopenharmony_ci#include "glsFboCompletenessTests.hpp" 27e5c31af7Sopenharmony_ci#include "gluObjectWrapper.hpp" 28e5c31af7Sopenharmony_ci 29e5c31af7Sopenharmony_ciusing namespace glw; 30e5c31af7Sopenharmony_ciusing deqp::gls::Range; 31e5c31af7Sopenharmony_ciusing namespace deqp::gls::FboUtil; 32e5c31af7Sopenharmony_ciusing namespace deqp::gls::FboUtil::config; 33e5c31af7Sopenharmony_cinamespace fboc = deqp::gls::fboc; 34e5c31af7Sopenharmony_citypedef tcu::TestCase::IterateResult IterateResult; 35e5c31af7Sopenharmony_ci 36e5c31af7Sopenharmony_cinamespace deqp 37e5c31af7Sopenharmony_ci{ 38e5c31af7Sopenharmony_cinamespace gles2 39e5c31af7Sopenharmony_ci{ 40e5c31af7Sopenharmony_cinamespace Functional 41e5c31af7Sopenharmony_ci{ 42e5c31af7Sopenharmony_ci 43e5c31af7Sopenharmony_cistatic const FormatKey s_es2ColorRenderables[] = 44e5c31af7Sopenharmony_ci{ 45e5c31af7Sopenharmony_ci GL_RGBA4, GL_RGB5_A1, GL_RGB565, 46e5c31af7Sopenharmony_ci}; 47e5c31af7Sopenharmony_ci 48e5c31af7Sopenharmony_ci// GLES2 does not strictly allow these, but this seems to be a bug in the 49e5c31af7Sopenharmony_ci// specification. For now, let's assume the unsized formats corresponding to 50e5c31af7Sopenharmony_ci// the color-renderable sized formats are allowed. 51e5c31af7Sopenharmony_ci// See https://cvs.khronos.org/bugzilla/show_bug.cgi?id=7333 52e5c31af7Sopenharmony_ci 53e5c31af7Sopenharmony_cistatic const FormatKey s_es2UnsizedColorRenderables[] = 54e5c31af7Sopenharmony_ci{ 55e5c31af7Sopenharmony_ci GLS_UNSIZED_FORMATKEY(GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4), 56e5c31af7Sopenharmony_ci GLS_UNSIZED_FORMATKEY(GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1), 57e5c31af7Sopenharmony_ci GLS_UNSIZED_FORMATKEY(GL_RGB, GL_UNSIGNED_SHORT_5_6_5) 58e5c31af7Sopenharmony_ci}; 59e5c31af7Sopenharmony_ci 60e5c31af7Sopenharmony_cistatic const FormatKey s_es2DepthRenderables[] = 61e5c31af7Sopenharmony_ci{ 62e5c31af7Sopenharmony_ci GL_DEPTH_COMPONENT16, 63e5c31af7Sopenharmony_ci}; 64e5c31af7Sopenharmony_ci 65e5c31af7Sopenharmony_cistatic const FormatKey s_es2StencilRenderables[] = 66e5c31af7Sopenharmony_ci{ 67e5c31af7Sopenharmony_ci GL_STENCIL_INDEX8, 68e5c31af7Sopenharmony_ci}; 69e5c31af7Sopenharmony_ci 70e5c31af7Sopenharmony_cistatic const FormatEntry s_es2Formats[] = 71e5c31af7Sopenharmony_ci{ 72e5c31af7Sopenharmony_ci { COLOR_RENDERABLE | TEXTURE_VALID, 73e5c31af7Sopenharmony_ci GLS_ARRAY_RANGE(s_es2UnsizedColorRenderables) }, 74e5c31af7Sopenharmony_ci { REQUIRED_RENDERABLE | COLOR_RENDERABLE | RENDERBUFFER_VALID, 75e5c31af7Sopenharmony_ci GLS_ARRAY_RANGE(s_es2ColorRenderables) }, 76e5c31af7Sopenharmony_ci { REQUIRED_RENDERABLE | DEPTH_RENDERABLE | RENDERBUFFER_VALID, 77e5c31af7Sopenharmony_ci GLS_ARRAY_RANGE(s_es2DepthRenderables) }, 78e5c31af7Sopenharmony_ci { REQUIRED_RENDERABLE | STENCIL_RENDERABLE | RENDERBUFFER_VALID, 79e5c31af7Sopenharmony_ci GLS_ARRAY_RANGE(s_es2StencilRenderables) }, 80e5c31af7Sopenharmony_ci}; 81e5c31af7Sopenharmony_ci 82e5c31af7Sopenharmony_ci// We have here only the extensions that are redundant in vanilla GLES3. Those 83e5c31af7Sopenharmony_ci// that are applicable both to GLES2 and GLES3 are in glsFboCompletenessTests.cpp. 84e5c31af7Sopenharmony_ci 85e5c31af7Sopenharmony_ci// GL_OES_texture_float 86e5c31af7Sopenharmony_cistatic const FormatKey s_oesTextureFloatFormats[] = 87e5c31af7Sopenharmony_ci{ 88e5c31af7Sopenharmony_ci GLS_UNSIZED_FORMATKEY(GL_RGBA, GL_FLOAT), 89e5c31af7Sopenharmony_ci GLS_UNSIZED_FORMATKEY(GL_RGB, GL_FLOAT), 90e5c31af7Sopenharmony_ci}; 91e5c31af7Sopenharmony_ci 92e5c31af7Sopenharmony_ci// GL_OES_texture_half_float 93e5c31af7Sopenharmony_cistatic const FormatKey s_oesTextureHalfFloatFormats[] = 94e5c31af7Sopenharmony_ci{ 95e5c31af7Sopenharmony_ci GLS_UNSIZED_FORMATKEY(GL_RGBA, GL_HALF_FLOAT_OES), 96e5c31af7Sopenharmony_ci GLS_UNSIZED_FORMATKEY(GL_RGB, GL_HALF_FLOAT_OES), 97e5c31af7Sopenharmony_ci}; 98e5c31af7Sopenharmony_ci 99e5c31af7Sopenharmony_ci// GL_EXT_color_buffer_half_float 100e5c31af7Sopenharmony_cistatic const FormatKey s_extColorBufferHalfFloatUnsized[] = 101e5c31af7Sopenharmony_ci{ 102e5c31af7Sopenharmony_ci GLS_UNSIZED_FORMATKEY(GL_RGBA, GL_HALF_FLOAT_OES), 103e5c31af7Sopenharmony_ci}; 104e5c31af7Sopenharmony_ci 105e5c31af7Sopenharmony_ci// GL_EXT_sRGB_write_control 106e5c31af7Sopenharmony_cistatic const FormatKey s_extSrgbWriteControlFormats[] = 107e5c31af7Sopenharmony_ci{ 108e5c31af7Sopenharmony_ci GL_SRGB8_ALPHA8 109e5c31af7Sopenharmony_ci}; 110e5c31af7Sopenharmony_ci 111e5c31af7Sopenharmony_ci// DEQP_gles3_core_no_extension_features 112e5c31af7Sopenharmony_cistatic const FormatKey s_es3NoExtRboFormats[] = 113e5c31af7Sopenharmony_ci{ 114e5c31af7Sopenharmony_ci GL_RGB10_A2, 115e5c31af7Sopenharmony_ci GL_SRGB8_ALPHA8, 116e5c31af7Sopenharmony_ci}; 117e5c31af7Sopenharmony_cistatic const FormatKey s_es3NoExtTextureFormats[] = 118e5c31af7Sopenharmony_ci{ 119e5c31af7Sopenharmony_ci GL_R16F, 120e5c31af7Sopenharmony_ci GL_RG16F, 121e5c31af7Sopenharmony_ci GL_RGB16F, 122e5c31af7Sopenharmony_ci GL_RGBA16F, 123e5c31af7Sopenharmony_ci GL_R11F_G11F_B10F, 124e5c31af7Sopenharmony_ci}; 125e5c31af7Sopenharmony_cistatic const FormatKey s_es3NoExtTextureColorRenderableFormats[] = 126e5c31af7Sopenharmony_ci{ 127e5c31af7Sopenharmony_ci GL_R8, 128e5c31af7Sopenharmony_ci GL_RG8, 129e5c31af7Sopenharmony_ci GL_RGB8, 130e5c31af7Sopenharmony_ci GL_RGBA4, 131e5c31af7Sopenharmony_ci GL_RGB5_A1, 132e5c31af7Sopenharmony_ci GL_RGBA8, 133e5c31af7Sopenharmony_ci GL_RGB10_A2, 134e5c31af7Sopenharmony_ci GL_RGB565, 135e5c31af7Sopenharmony_ci GL_SRGB8_ALPHA8, 136e5c31af7Sopenharmony_ci}; 137e5c31af7Sopenharmony_ci 138e5c31af7Sopenharmony_ci// with ES3 core and GL_EXT_color_buffer_float 139e5c31af7Sopenharmony_cistatic const FormatKey s_es3NoExtExtColorBufferFloatFormats[] = 140e5c31af7Sopenharmony_ci{ 141e5c31af7Sopenharmony_ci // \note Only the GLES2+exts subset of formats 142e5c31af7Sopenharmony_ci GL_R11F_G11F_B10F, GL_RGBA16F, GL_RG16F, GL_R16F, 143e5c31af7Sopenharmony_ci}; 144e5c31af7Sopenharmony_ci 145e5c31af7Sopenharmony_ci// with ES3 core with OES_texture_stencil8 146e5c31af7Sopenharmony_cistatic const FormatKey s_es3NoExtOesTextureStencil8Formats[] = 147e5c31af7Sopenharmony_ci{ 148e5c31af7Sopenharmony_ci GL_STENCIL_INDEX8, 149e5c31af7Sopenharmony_ci}; 150e5c31af7Sopenharmony_ci 151e5c31af7Sopenharmony_ci// DEQP_gles3_core_changed_features 152e5c31af7Sopenharmony_cistatic const FormatKey s_es3NoExtDepthRenderable[] = 153e5c31af7Sopenharmony_ci{ 154e5c31af7Sopenharmony_ci GL_DEPTH_COMPONENT16, 155e5c31af7Sopenharmony_ci GL_DEPTH_COMPONENT24, 156e5c31af7Sopenharmony_ci GL_DEPTH24_STENCIL8, 157e5c31af7Sopenharmony_ci}; 158e5c31af7Sopenharmony_ci 159e5c31af7Sopenharmony_cistatic const FormatKey s_es3NoExtStencilRenderable[] = 160e5c31af7Sopenharmony_ci{ 161e5c31af7Sopenharmony_ci GL_DEPTH24_STENCIL8, 162e5c31af7Sopenharmony_ci}; 163e5c31af7Sopenharmony_ci 164e5c31af7Sopenharmony_cistatic const FormatExtEntry s_es2ExtFormats[] = 165e5c31af7Sopenharmony_ci{ 166e5c31af7Sopenharmony_ci // The extension does not specify these to be color-renderable. 167e5c31af7Sopenharmony_ci { 168e5c31af7Sopenharmony_ci "GL_OES_texture_float", 169e5c31af7Sopenharmony_ci (deUint32)TEXTURE_VALID, 170e5c31af7Sopenharmony_ci GLS_ARRAY_RANGE(s_oesTextureFloatFormats) 171e5c31af7Sopenharmony_ci }, 172e5c31af7Sopenharmony_ci { 173e5c31af7Sopenharmony_ci "GL_OES_texture_half_float", 174e5c31af7Sopenharmony_ci (deUint32)TEXTURE_VALID, 175e5c31af7Sopenharmony_ci GLS_ARRAY_RANGE(s_oesTextureHalfFloatFormats) 176e5c31af7Sopenharmony_ci }, 177e5c31af7Sopenharmony_ci // However GL_EXT_color_buffer_half_float does say explicitly 178e5c31af7Sopenharmony_ci // that the RGBA variant should be renderable. 179e5c31af7Sopenharmony_ci { 180e5c31af7Sopenharmony_ci "GL_OES_texture_half_float GL_EXT_color_buffer_half_float", 181e5c31af7Sopenharmony_ci (deUint32)(REQUIRED_RENDERABLE | COLOR_RENDERABLE), 182e5c31af7Sopenharmony_ci GLS_ARRAY_RANGE(s_extColorBufferHalfFloatUnsized) 183e5c31af7Sopenharmony_ci }, 184e5c31af7Sopenharmony_ci 185e5c31af7Sopenharmony_ci // GL_EXT_sRGB_write_control makes SRGB8_ALPHA8 color-renderable 186e5c31af7Sopenharmony_ci { 187e5c31af7Sopenharmony_ci "GL_EXT_sRGB_write_control", 188e5c31af7Sopenharmony_ci (deUint32)(REQUIRED_RENDERABLE | TEXTURE_VALID | COLOR_RENDERABLE | RENDERBUFFER_VALID), 189e5c31af7Sopenharmony_ci GLS_ARRAY_RANGE(s_extSrgbWriteControlFormats) 190e5c31af7Sopenharmony_ci }, 191e5c31af7Sopenharmony_ci 192e5c31af7Sopenharmony_ci // Since GLES3 is "backwards compatible" to GLES2, we might actually be running on a GLES3 193e5c31af7Sopenharmony_ci // context. Since GLES3 added some features to core with no corresponding GLES2 extension, 194e5c31af7Sopenharmony_ci // some tests might produce wrong results (since they are using rules of GLES2 & extensions) 195e5c31af7Sopenharmony_ci // 196e5c31af7Sopenharmony_ci // To avoid this, require new features of GLES3 that have no matching GLES2 extension if 197e5c31af7Sopenharmony_ci // context is GLES3. This can be done with a DEQP_* extensions. 198e5c31af7Sopenharmony_ci // 199e5c31af7Sopenharmony_ci // \note Not all feature changes are listed here but only those that alter GLES2 subset of 200e5c31af7Sopenharmony_ci // the formats 201e5c31af7Sopenharmony_ci { 202e5c31af7Sopenharmony_ci "DEQP_gles3_core_compatible", 203e5c31af7Sopenharmony_ci (deUint32)(REQUIRED_RENDERABLE | COLOR_RENDERABLE | RENDERBUFFER_VALID), 204e5c31af7Sopenharmony_ci GLS_ARRAY_RANGE(s_es3NoExtRboFormats) 205e5c31af7Sopenharmony_ci }, 206e5c31af7Sopenharmony_ci { 207e5c31af7Sopenharmony_ci "DEQP_gles3_core_compatible", 208e5c31af7Sopenharmony_ci (deUint32)TEXTURE_VALID, 209e5c31af7Sopenharmony_ci GLS_ARRAY_RANGE(s_es3NoExtTextureFormats) 210e5c31af7Sopenharmony_ci }, 211e5c31af7Sopenharmony_ci { 212e5c31af7Sopenharmony_ci "DEQP_gles3_core_compatible", 213e5c31af7Sopenharmony_ci (deUint32)(REQUIRED_RENDERABLE | TEXTURE_VALID | COLOR_RENDERABLE | RENDERBUFFER_VALID), 214e5c31af7Sopenharmony_ci GLS_ARRAY_RANGE(s_es3NoExtTextureColorRenderableFormats) 215e5c31af7Sopenharmony_ci }, 216e5c31af7Sopenharmony_ci { 217e5c31af7Sopenharmony_ci "DEQP_gles3_core_compatible GL_EXT_color_buffer_float", 218e5c31af7Sopenharmony_ci (deUint32)(REQUIRED_RENDERABLE | COLOR_RENDERABLE | RENDERBUFFER_VALID), 219e5c31af7Sopenharmony_ci GLS_ARRAY_RANGE(s_es3NoExtExtColorBufferFloatFormats) 220e5c31af7Sopenharmony_ci }, 221e5c31af7Sopenharmony_ci { 222e5c31af7Sopenharmony_ci "DEQP_gles3_core_compatible GL_OES_texture_stencil8", 223e5c31af7Sopenharmony_ci (deUint32)(REQUIRED_RENDERABLE | STENCIL_RENDERABLE | TEXTURE_VALID), 224e5c31af7Sopenharmony_ci GLS_ARRAY_RANGE(s_es3NoExtOesTextureStencil8Formats) 225e5c31af7Sopenharmony_ci }, 226e5c31af7Sopenharmony_ci { 227e5c31af7Sopenharmony_ci "DEQP_gles3_core_compatible GL_OES_texture_half_float GL_EXT_color_buffer_half_float", 228e5c31af7Sopenharmony_ci (deUint32)(REQUIRED_RENDERABLE | COLOR_RENDERABLE), 229e5c31af7Sopenharmony_ci GLS_ARRAY_RANGE(s_oesTextureHalfFloatFormats) 230e5c31af7Sopenharmony_ci }, 231e5c31af7Sopenharmony_ci { 232e5c31af7Sopenharmony_ci "DEQP_gles3_core_compatible", 233e5c31af7Sopenharmony_ci (deUint32)(REQUIRED_RENDERABLE | DEPTH_RENDERABLE | RENDERBUFFER_VALID | TEXTURE_VALID), 234e5c31af7Sopenharmony_ci GLS_ARRAY_RANGE(s_es3NoExtDepthRenderable) 235e5c31af7Sopenharmony_ci }, 236e5c31af7Sopenharmony_ci { 237e5c31af7Sopenharmony_ci "DEQP_gles3_core_compatible", 238e5c31af7Sopenharmony_ci (deUint32)(REQUIRED_RENDERABLE | STENCIL_RENDERABLE | RENDERBUFFER_VALID | TEXTURE_VALID), 239e5c31af7Sopenharmony_ci GLS_ARRAY_RANGE(s_es3NoExtStencilRenderable) 240e5c31af7Sopenharmony_ci }, 241e5c31af7Sopenharmony_ci}; 242e5c31af7Sopenharmony_ci 243e5c31af7Sopenharmony_ciclass ES2Checker : public Checker 244e5c31af7Sopenharmony_ci{ 245e5c31af7Sopenharmony_cipublic: 246e5c31af7Sopenharmony_ci ES2Checker (const glu::RenderContext& ctx, const FormatDB& formats); 247e5c31af7Sopenharmony_ci void check (GLenum attPoint, const Attachment& att, 248e5c31af7Sopenharmony_ci const Image* image); 249e5c31af7Sopenharmony_ciprivate: 250e5c31af7Sopenharmony_ci GLsizei m_width; //< The common width of images 251e5c31af7Sopenharmony_ci GLsizei m_height; //< The common height of images 252e5c31af7Sopenharmony_ci}; 253e5c31af7Sopenharmony_ci 254e5c31af7Sopenharmony_ciES2Checker::ES2Checker (const glu::RenderContext& ctx, const FormatDB& formats)\ 255e5c31af7Sopenharmony_ci : Checker (ctx, formats) 256e5c31af7Sopenharmony_ci , m_width (-1) 257e5c31af7Sopenharmony_ci , m_height (-1) 258e5c31af7Sopenharmony_ci{ 259e5c31af7Sopenharmony_ci} 260e5c31af7Sopenharmony_ci 261e5c31af7Sopenharmony_civoid ES2Checker::check (GLenum attPoint, const Attachment& att, const Image* image) 262e5c31af7Sopenharmony_ci{ 263e5c31af7Sopenharmony_ci DE_UNREF(attPoint); 264e5c31af7Sopenharmony_ci DE_UNREF(att); 265e5c31af7Sopenharmony_ci // GLES2: "All attached images have the same width and height." 266e5c31af7Sopenharmony_ci if (m_width == -1) 267e5c31af7Sopenharmony_ci { 268e5c31af7Sopenharmony_ci m_width = image->width; 269e5c31af7Sopenharmony_ci m_height = image->height; 270e5c31af7Sopenharmony_ci } 271e5c31af7Sopenharmony_ci else if (image->width != m_width || image->height != m_height) 272e5c31af7Sopenharmony_ci { 273e5c31af7Sopenharmony_ci // Since GLES3 is "backwards compatible" to GLES2, we might actually be running 274e5c31af7Sopenharmony_ci // on a GLES3 context. On GLES3, FRAMEBUFFER_INCOMPLETE_DIMENSIONS is not generated 275e5c31af7Sopenharmony_ci // if attachments have different sizes. 276e5c31af7Sopenharmony_ci if (!gls::FboUtil::checkExtensionSupport(m_renderCtx, "DEQP_gles3_core_compatible")) 277e5c31af7Sopenharmony_ci { 278e5c31af7Sopenharmony_ci // running on GLES2 279e5c31af7Sopenharmony_ci addFBOStatus(GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS, "Sizes of attachments differ"); 280e5c31af7Sopenharmony_ci } 281e5c31af7Sopenharmony_ci } 282e5c31af7Sopenharmony_ci // GLES2, 4.4.5: "some implementations may not support rendering to 283e5c31af7Sopenharmony_ci // particular combinations of internal formats. If the combination of 284e5c31af7Sopenharmony_ci // formats of the images attached to a framebuffer object are not 285e5c31af7Sopenharmony_ci // supported by the implementation, then the framebuffer is not complete 286e5c31af7Sopenharmony_ci // under the clause labeled FRAMEBUFFER_UNSUPPORTED." 287e5c31af7Sopenharmony_ci // 288e5c31af7Sopenharmony_ci // Hence it is _always_ allowed to report FRAMEBUFFER_UNSUPPORTED. 289e5c31af7Sopenharmony_ci addPotentialFBOStatus(GL_FRAMEBUFFER_UNSUPPORTED, "Particular format combinations need not to be supported"); 290e5c31af7Sopenharmony_ci} 291e5c31af7Sopenharmony_ci 292e5c31af7Sopenharmony_cistruct FormatCombination 293e5c31af7Sopenharmony_ci{ 294e5c31af7Sopenharmony_ci GLenum colorKind; 295e5c31af7Sopenharmony_ci ImageFormat colorFmt; 296e5c31af7Sopenharmony_ci GLenum depthKind; 297e5c31af7Sopenharmony_ci ImageFormat depthFmt; 298e5c31af7Sopenharmony_ci GLenum stencilKind; 299e5c31af7Sopenharmony_ci ImageFormat stencilFmt; 300e5c31af7Sopenharmony_ci}; 301e5c31af7Sopenharmony_ci 302e5c31af7Sopenharmony_ciclass SupportedCombinationTest : public fboc::TestBase 303e5c31af7Sopenharmony_ci{ 304e5c31af7Sopenharmony_cipublic: 305e5c31af7Sopenharmony_ci SupportedCombinationTest (fboc::Context& ctx, 306e5c31af7Sopenharmony_ci const char* name, const char* desc) 307e5c31af7Sopenharmony_ci : TestBase (ctx, name, desc) {} 308e5c31af7Sopenharmony_ci 309e5c31af7Sopenharmony_ci IterateResult iterate (void); 310e5c31af7Sopenharmony_ci bool tryCombination (const FormatCombination& comb); 311e5c31af7Sopenharmony_ci GLenum formatKind (ImageFormat fmt); 312e5c31af7Sopenharmony_ci}; 313e5c31af7Sopenharmony_ci 314e5c31af7Sopenharmony_cibool SupportedCombinationTest::tryCombination (const FormatCombination& comb) 315e5c31af7Sopenharmony_ci{ 316e5c31af7Sopenharmony_ci glu::Framebuffer fbo(m_ctx.getRenderContext()); 317e5c31af7Sopenharmony_ci FboBuilder builder(*fbo, GL_FRAMEBUFFER, fboc::gl(*this)); 318e5c31af7Sopenharmony_ci 319e5c31af7Sopenharmony_ci attachTargetToNew(GL_COLOR_ATTACHMENT0, comb.colorKind, comb.colorFmt, 320e5c31af7Sopenharmony_ci 64, 64, builder); 321e5c31af7Sopenharmony_ci attachTargetToNew(GL_DEPTH_ATTACHMENT, comb.depthKind, comb.depthFmt, 322e5c31af7Sopenharmony_ci 64, 64, builder); 323e5c31af7Sopenharmony_ci attachTargetToNew(GL_STENCIL_ATTACHMENT, comb.stencilKind, comb.stencilFmt, 324e5c31af7Sopenharmony_ci 64, 64, builder); 325e5c31af7Sopenharmony_ci 326e5c31af7Sopenharmony_ci const GLenum glStatus = fboc::gl(*this).checkFramebufferStatus(GL_FRAMEBUFFER); 327e5c31af7Sopenharmony_ci 328e5c31af7Sopenharmony_ci return (glStatus == GL_FRAMEBUFFER_COMPLETE); 329e5c31af7Sopenharmony_ci} 330e5c31af7Sopenharmony_ci 331e5c31af7Sopenharmony_ciGLenum SupportedCombinationTest::formatKind (ImageFormat fmt) 332e5c31af7Sopenharmony_ci{ 333e5c31af7Sopenharmony_ci if (fmt.format == GL_NONE) 334e5c31af7Sopenharmony_ci return GL_NONE; 335e5c31af7Sopenharmony_ci 336e5c31af7Sopenharmony_ci const FormatFlags flags = m_ctx.getCoreFormats().getFormatInfo(fmt); 337e5c31af7Sopenharmony_ci const bool rbo = (flags & RENDERBUFFER_VALID) != 0; 338e5c31af7Sopenharmony_ci // exactly one of renderbuffer and texture is supported by vanilla GLES2 formats 339e5c31af7Sopenharmony_ci DE_ASSERT(rbo != ((flags & TEXTURE_VALID) != 0)); 340e5c31af7Sopenharmony_ci 341e5c31af7Sopenharmony_ci return rbo ? GL_RENDERBUFFER : GL_TEXTURE; 342e5c31af7Sopenharmony_ci} 343e5c31af7Sopenharmony_ci 344e5c31af7Sopenharmony_ciIterateResult SupportedCombinationTest::iterate (void) 345e5c31af7Sopenharmony_ci{ 346e5c31af7Sopenharmony_ci const FormatDB& db = m_ctx.getCoreFormats(); 347e5c31af7Sopenharmony_ci const ImageFormat none = ImageFormat::none(); 348e5c31af7Sopenharmony_ci Formats colorFmts = db.getFormats(COLOR_RENDERABLE); 349e5c31af7Sopenharmony_ci Formats depthFmts = db.getFormats(DEPTH_RENDERABLE); 350e5c31af7Sopenharmony_ci Formats stencilFmts = db.getFormats(STENCIL_RENDERABLE); 351e5c31af7Sopenharmony_ci FormatCombination comb; 352e5c31af7Sopenharmony_ci bool succ = false; 353e5c31af7Sopenharmony_ci 354e5c31af7Sopenharmony_ci colorFmts.insert(none); 355e5c31af7Sopenharmony_ci depthFmts.insert(none); 356e5c31af7Sopenharmony_ci stencilFmts.insert(none); 357e5c31af7Sopenharmony_ci 358e5c31af7Sopenharmony_ci for (Formats::const_iterator col = colorFmts.begin(); col != colorFmts.end(); col++) 359e5c31af7Sopenharmony_ci { 360e5c31af7Sopenharmony_ci comb.colorFmt = *col; 361e5c31af7Sopenharmony_ci comb.colorKind = formatKind(*col); 362e5c31af7Sopenharmony_ci for (Formats::const_iterator dep = depthFmts.begin(); dep != depthFmts.end(); dep++) 363e5c31af7Sopenharmony_ci { 364e5c31af7Sopenharmony_ci comb.depthFmt = *dep; 365e5c31af7Sopenharmony_ci comb.depthKind = formatKind(*dep); 366e5c31af7Sopenharmony_ci for (Formats::const_iterator stc = stencilFmts.begin(); 367e5c31af7Sopenharmony_ci stc != stencilFmts.end(); stc++) 368e5c31af7Sopenharmony_ci { 369e5c31af7Sopenharmony_ci comb.stencilFmt = *stc; 370e5c31af7Sopenharmony_ci comb.stencilKind = formatKind(*stc); 371e5c31af7Sopenharmony_ci succ = tryCombination(comb); 372e5c31af7Sopenharmony_ci if (succ) 373e5c31af7Sopenharmony_ci break; 374e5c31af7Sopenharmony_ci } 375e5c31af7Sopenharmony_ci } 376e5c31af7Sopenharmony_ci } 377e5c31af7Sopenharmony_ci 378e5c31af7Sopenharmony_ci if (succ) 379e5c31af7Sopenharmony_ci pass(); 380e5c31af7Sopenharmony_ci else 381e5c31af7Sopenharmony_ci fail("No supported format combination found"); 382e5c31af7Sopenharmony_ci 383e5c31af7Sopenharmony_ci return STOP; 384e5c31af7Sopenharmony_ci} 385e5c31af7Sopenharmony_ci 386e5c31af7Sopenharmony_ciclass ES2CheckerFactory : public CheckerFactory 387e5c31af7Sopenharmony_ci{ 388e5c31af7Sopenharmony_cipublic: 389e5c31af7Sopenharmony_ci Checker* createChecker (const glu::RenderContext& ctx, const FormatDB& formats) { return new ES2Checker(ctx, formats); } 390e5c31af7Sopenharmony_ci}; 391e5c31af7Sopenharmony_ci 392e5c31af7Sopenharmony_ciclass TestGroup : public TestCaseGroup 393e5c31af7Sopenharmony_ci{ 394e5c31af7Sopenharmony_cipublic: 395e5c31af7Sopenharmony_ci TestGroup (Context& ctx); 396e5c31af7Sopenharmony_ci void init (void); 397e5c31af7Sopenharmony_ciprivate: 398e5c31af7Sopenharmony_ci ES2CheckerFactory m_checkerFactory; 399e5c31af7Sopenharmony_ci fboc::Context m_fboc; 400e5c31af7Sopenharmony_ci}; 401e5c31af7Sopenharmony_ci 402e5c31af7Sopenharmony_ciTestGroup::TestGroup (Context& ctx) 403e5c31af7Sopenharmony_ci : TestCaseGroup (ctx, "completeness", "Completeness tests") 404e5c31af7Sopenharmony_ci , m_checkerFactory () 405e5c31af7Sopenharmony_ci , m_fboc (ctx.getTestContext(), ctx.getRenderContext(), m_checkerFactory) 406e5c31af7Sopenharmony_ci{ 407e5c31af7Sopenharmony_ci const FormatEntries stdRange = GLS_ARRAY_RANGE(s_es2Formats); 408e5c31af7Sopenharmony_ci const FormatExtEntries extRange = GLS_ARRAY_RANGE(s_es2ExtFormats); 409e5c31af7Sopenharmony_ci 410e5c31af7Sopenharmony_ci m_fboc.addFormats(stdRange); 411e5c31af7Sopenharmony_ci m_fboc.addExtFormats(extRange); 412e5c31af7Sopenharmony_ci m_fboc.setHaveMulticolorAtts( 413e5c31af7Sopenharmony_ci ctx.getContextInfo().isExtensionSupported("GL_NV_fbo_color_attachments")); 414e5c31af7Sopenharmony_ci} 415e5c31af7Sopenharmony_ci 416e5c31af7Sopenharmony_civoid TestGroup::init (void) 417e5c31af7Sopenharmony_ci{ 418e5c31af7Sopenharmony_ci tcu::TestCaseGroup* attCombTests = m_fboc.createAttachmentTests(); 419e5c31af7Sopenharmony_ci addChild(m_fboc.createRenderableTests()); 420e5c31af7Sopenharmony_ci attCombTests->addChild(new SupportedCombinationTest( 421e5c31af7Sopenharmony_ci m_fboc, 422e5c31af7Sopenharmony_ci "exists_supported", 423e5c31af7Sopenharmony_ci "Test for existence of a supported combination of formats")); 424e5c31af7Sopenharmony_ci addChild(attCombTests); 425e5c31af7Sopenharmony_ci addChild(m_fboc.createSizeTests()); 426e5c31af7Sopenharmony_ci} 427e5c31af7Sopenharmony_ci 428e5c31af7Sopenharmony_citcu::TestCaseGroup* createFboCompletenessTests (Context& context) 429e5c31af7Sopenharmony_ci{ 430e5c31af7Sopenharmony_ci return new TestGroup(context); 431e5c31af7Sopenharmony_ci} 432e5c31af7Sopenharmony_ci 433e5c31af7Sopenharmony_ci} // Functional 434e5c31af7Sopenharmony_ci} // gles2 435e5c31af7Sopenharmony_ci} // deqp 436