1/*------------------------------------------------------------------------- 2 * drawElements Quality Program OpenGL (ES) Module 3 * ----------------------------------------------- 4 * 5 * Copyright 2014 The Android Open Source Project 6 * 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 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 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. 18 * 19 *//*! 20 * \file 21 * \brief Framebuffer completeness tests. 22 *//*--------------------------------------------------------------------*/ 23 24#include "glsFboCompletenessTests.hpp" 25 26#include "gluStrUtil.hpp" 27#include "gluObjectWrapper.hpp" 28#include "deStringUtil.hpp" 29 30#include <cctype> 31#include <iterator> 32#include <algorithm> 33 34using namespace glw; 35using glu::RenderContext; 36using glu::getFramebufferStatusName; 37using glu::getTextureFormatName; 38using glu::getTypeName; 39using glu::getErrorName; 40using glu::Framebuffer; 41using tcu::TestCase; 42using tcu::TestCaseGroup; 43using tcu::TestLog; 44using tcu::MessageBuilder; 45using tcu::TestNode; 46using std::string; 47using de::toString; 48using de::toLower; 49using namespace deqp::gls::FboUtil; 50using namespace deqp::gls::FboUtil::config; 51typedef TestCase::IterateResult IterateResult; 52 53namespace deqp 54{ 55namespace gls 56{ 57namespace fboc 58{ 59 60namespace details 61{ 62 63// The following extensions are applicable both to ES2 and ES3. 64 65// GL_OES_depth_texture 66static const FormatKey s_oesDepthTextureFormats[] = 67{ 68 GLS_UNSIZED_FORMATKEY(GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT), 69 GLS_UNSIZED_FORMATKEY(GL_DEPTH_COMPONENT, GL_UNSIGNED_INT), 70}; 71 72// GL_OES_packed_depth_stencil 73static const FormatKey s_oesPackedDepthStencilSizedFormats[] = 74{ 75 GL_DEPTH24_STENCIL8, 76}; 77 78static const FormatKey s_oesPackedDepthStencilTexFormats[] = 79{ 80 GLS_UNSIZED_FORMATKEY(GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8), 81}; 82 83// GL_OES_required_internalformat 84static const FormatKey s_oesRequiredInternalFormatColorFormats[] = 85{ 86 // Same as ES2 RBO formats, plus RGBA8 (even without OES_rgb8_rgba8) 87 GL_RGB5_A1, GL_RGBA8, GL_RGBA4, GL_RGB565 88}; 89 90static const FormatKey s_oesRequiredInternalFormatDepthFormats[] = 91{ 92 GL_DEPTH_COMPONENT16, 93}; 94 95// GL_EXT_color_buffer_half_float 96static const FormatKey s_extColorBufferHalfFloatFormats[] = 97{ 98 GL_RGBA16F, GL_RGB16F, GL_RG16F, GL_R16F, 99}; 100 101static const FormatKey s_oesDepth24SizedFormats[] = 102{ 103 GL_DEPTH_COMPONENT24 104}; 105 106static const FormatKey s_oesDepth32SizedFormats[] = 107{ 108 GL_DEPTH_COMPONENT32 109}; 110 111static const FormatKey s_oesRgb8Rgba8RboFormats[] = 112{ 113 GL_RGB8, 114 GL_RGBA8, 115}; 116 117static const FormatKey s_oesRequiredInternalFormatRgb8ColorFormat[] = 118{ 119 GL_RGB8, 120}; 121 122static const FormatKey s_extTextureType2101010RevFormats[] = 123{ 124 GLS_UNSIZED_FORMATKEY(GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV), 125 GLS_UNSIZED_FORMATKEY(GL_RGB, GL_UNSIGNED_INT_2_10_10_10_REV), 126}; 127 128static const FormatKey s_oesRequiredInternalFormat10bitColorFormats[] = 129{ 130 GL_RGB10_A2, GL_RGB10, 131}; 132 133static const FormatKey s_extTextureRgRboFormats[] = 134{ 135 GL_R8, GL_RG8, 136}; 137 138static const FormatKey s_extTextureRgTexFormats[] = 139{ 140 GLS_UNSIZED_FORMATKEY(GL_RED, GL_UNSIGNED_BYTE), 141 GLS_UNSIZED_FORMATKEY(GL_RG, GL_UNSIGNED_BYTE), 142}; 143 144static const FormatKey s_extTextureRgFloatTexFormats[] = 145{ 146 GLS_UNSIZED_FORMATKEY(GL_RED, GL_FLOAT), 147 GLS_UNSIZED_FORMATKEY(GL_RG, GL_FLOAT), 148}; 149 150static const FormatKey s_extTextureRgHalfFloatTexFormats[] = 151{ 152 GLS_UNSIZED_FORMATKEY(GL_RED, GL_HALF_FLOAT_OES), 153 GLS_UNSIZED_FORMATKEY(GL_RG, GL_HALF_FLOAT_OES), 154}; 155 156static const FormatKey s_nvPackedFloatRboFormats[] = 157{ 158 GL_R11F_G11F_B10F, 159}; 160 161static const FormatKey s_nvPackedFloatTexFormats[] = 162{ 163 GLS_UNSIZED_FORMATKEY(GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV), 164}; 165 166static const FormatKey s_extSrgbRboFormats[] = 167{ 168 GL_SRGB8_ALPHA8, 169}; 170 171static const FormatKey s_extSrgbRenderableTexFormats[] = 172{ 173 GLS_UNSIZED_FORMATKEY(GL_SRGB_ALPHA, GL_UNSIGNED_BYTE), 174}; 175 176static const FormatKey s_extSrgbNonRenderableTexFormats[] = 177{ 178 GLS_UNSIZED_FORMATKEY(GL_SRGB, GL_UNSIGNED_BYTE), 179}; 180 181static const FormatKey s_nvSrgbFormatsRboFormats[] = 182{ 183 GL_SRGB8, 184}; 185 186static const FormatKey s_nvSrgbFormatsTextureFormats[] = 187{ 188 GL_SRGB8, 189 190 // The extension does not actually require any unsized format 191 // to be renderable. However, the renderablility of unsized 192 // SRGB,UBYTE internalformat-type pair is implied. 193 GLS_UNSIZED_FORMATKEY(GL_SRGB, GL_UNSIGNED_BYTE), 194}; 195 196static const FormatKey s_oesRgb8Rgba8TexFormats[] = 197{ 198 GLS_UNSIZED_FORMATKEY(GL_RGB, GL_UNSIGNED_BYTE), 199 GLS_UNSIZED_FORMATKEY(GL_RGBA, GL_UNSIGNED_BYTE), 200}; 201 202static const FormatKey s_extTextureSRGBR8Formats[] = 203{ 204 GL_SR8_EXT, 205}; 206 207static const FormatKey s_extTextureSRGBRG8Formats[] = 208{ 209 GL_SRG8_EXT, 210}; 211 212static const FormatExtEntry s_esExtFormats[] = 213{ 214 { 215 "GL_OES_depth_texture", 216 (deUint32)(REQUIRED_RENDERABLE | DEPTH_RENDERABLE | TEXTURE_VALID), 217 GLS_ARRAY_RANGE(s_oesDepthTextureFormats), 218 }, 219 { 220 "GL_OES_packed_depth_stencil", 221 (deUint32)(REQUIRED_RENDERABLE | DEPTH_RENDERABLE | STENCIL_RENDERABLE | RENDERBUFFER_VALID), 222 GLS_ARRAY_RANGE(s_oesPackedDepthStencilSizedFormats) 223 }, 224 { 225 "GL_OES_packed_depth_stencil GL_OES_required_internalformat", 226 (deUint32)TEXTURE_VALID, 227 GLS_ARRAY_RANGE(s_oesPackedDepthStencilSizedFormats) 228 }, 229 { 230 "GL_OES_packed_depth_stencil GL_OES_depth_texture", 231 (deUint32)(DEPTH_RENDERABLE | STENCIL_RENDERABLE | TEXTURE_VALID), 232 GLS_ARRAY_RANGE(s_oesPackedDepthStencilTexFormats) 233 }, 234 // The ANGLE extension incorporates GL_OES_depth_texture/GL_OES_packed_depth_stencil. 235 { 236 "GL_ANGLE_depth_texture", 237 (deUint32)(REQUIRED_RENDERABLE | DEPTH_RENDERABLE | TEXTURE_VALID), 238 GLS_ARRAY_RANGE(s_oesDepthTextureFormats), 239 }, 240 { 241 "GL_OES_packed_depth_stencil GL_ANGLE_depth_texture", 242 (deUint32)(DEPTH_RENDERABLE | STENCIL_RENDERABLE | TEXTURE_VALID), 243 GLS_ARRAY_RANGE(s_oesPackedDepthStencilTexFormats), 244 }, 245 // \todo [2013-12-10 lauri] Find out if OES_texture_half_float is really a 246 // requirement on ES3 also. Or is color_buffer_half_float applicatble at 247 // all on ES3, since there's also EXT_color_buffer_float? 248 { 249 "GL_OES_texture_half_float GL_EXT_color_buffer_half_float", 250 (deUint32)(REQUIRED_RENDERABLE | COLOR_RENDERABLE | RENDERBUFFER_VALID), 251 GLS_ARRAY_RANGE(s_extColorBufferHalfFloatFormats) 252 }, 253 254 // OES_required_internalformat doesn't actually specify that these are renderable, 255 // since it was written against ES 1.1. 256 { 257 "GL_OES_required_internalformat", 258 // Allow but don't require RGBA8 to be color-renderable if 259 // OES_rgb8_rgba8 is not present. 260 (deUint32)(COLOR_RENDERABLE | TEXTURE_VALID), 261 GLS_ARRAY_RANGE(s_oesRequiredInternalFormatColorFormats) 262 }, 263 { 264 "GL_OES_required_internalformat", 265 (deUint32)(DEPTH_RENDERABLE | TEXTURE_VALID), 266 GLS_ARRAY_RANGE(s_oesRequiredInternalFormatDepthFormats) 267 }, 268 { 269 "GL_EXT_texture_rg", 270 (deUint32)(REQUIRED_RENDERABLE | COLOR_RENDERABLE | RENDERBUFFER_VALID | TEXTURE_VALID), 271 GLS_ARRAY_RANGE(s_extTextureRgRboFormats) 272 }, 273 // These are not specified to be color-renderable, but the wording is 274 // exactly as ambiguous as the wording in the ES2 spec. 275 { 276 "GL_EXT_texture_rg", 277 (deUint32)(COLOR_RENDERABLE | TEXTURE_VALID), 278 GLS_ARRAY_RANGE(s_extTextureRgTexFormats) 279 }, 280 { 281 "GL_EXT_texture_rg GL_OES_texture_float", 282 (deUint32)(COLOR_RENDERABLE | TEXTURE_VALID), 283 GLS_ARRAY_RANGE(s_extTextureRgFloatTexFormats) 284 }, 285 { 286 "GL_EXT_texture_rg GL_OES_texture_half_float", 287 (deUint32)(COLOR_RENDERABLE | TEXTURE_VALID), 288 GLS_ARRAY_RANGE(s_extTextureRgHalfFloatTexFormats) 289 }, 290 291 { 292 "GL_NV_packed_float", 293 (deUint32)(COLOR_RENDERABLE | TEXTURE_VALID), 294 GLS_ARRAY_RANGE(s_nvPackedFloatTexFormats) 295 }, 296 { 297 "GL_NV_packed_float GL_EXT_color_buffer_half_float", 298 (deUint32)(REQUIRED_RENDERABLE | COLOR_RENDERABLE | RENDERBUFFER_VALID), 299 GLS_ARRAY_RANGE(s_nvPackedFloatRboFormats) 300 }, 301 302 { 303 "GL_EXT_sRGB", 304 (deUint32)(COLOR_RENDERABLE | TEXTURE_VALID), 305 GLS_ARRAY_RANGE(s_extSrgbRenderableTexFormats) 306 }, 307 { 308 "GL_EXT_sRGB", 309 (deUint32)TEXTURE_VALID, 310 GLS_ARRAY_RANGE(s_extSrgbNonRenderableTexFormats) 311 }, 312 { 313 "GL_EXT_sRGB", 314 (deUint32)(REQUIRED_RENDERABLE | COLOR_RENDERABLE | RENDERBUFFER_VALID), 315 GLS_ARRAY_RANGE(s_extSrgbRboFormats) 316 }, 317 { 318 "GL_NV_sRGB_formats", 319 (deUint32)(REQUIRED_RENDERABLE | COLOR_RENDERABLE | RENDERBUFFER_VALID), 320 GLS_ARRAY_RANGE(s_nvSrgbFormatsRboFormats) 321 }, 322 { 323 "GL_NV_sRGB_formats", 324 (deUint32)(REQUIRED_RENDERABLE | COLOR_RENDERABLE | TEXTURE_VALID), 325 GLS_ARRAY_RANGE(s_nvSrgbFormatsTextureFormats) 326 }, 327 328 // In Khronos bug 7333 discussion, the consensus is that these texture 329 // formats, at least, should be color-renderable. Still, that cannot be 330 // found in any extension specs, so only allow it, not require it. 331 { 332 "GL_OES_rgb8_rgba8", 333 (deUint32)(COLOR_RENDERABLE | TEXTURE_VALID), 334 GLS_ARRAY_RANGE(s_oesRgb8Rgba8TexFormats) 335 }, 336 { 337 "GL_OES_rgb8_rgba8", 338 (deUint32)(REQUIRED_RENDERABLE | COLOR_RENDERABLE | RENDERBUFFER_VALID), 339 GLS_ARRAY_RANGE(s_oesRgb8Rgba8RboFormats) 340 }, 341 { 342 "GL_OES_rgb8_rgba8 GL_OES_required_internalformat", 343 (deUint32)TEXTURE_VALID, 344 GLS_ARRAY_RANGE(s_oesRequiredInternalFormatRgb8ColorFormat) 345 }, 346 347 // The depth-renderability of the depth RBO formats is not explicitly 348 // spelled out, but all renderbuffer formats are meant to be renderable. 349 { 350 "GL_OES_depth24", 351 (deUint32)(REQUIRED_RENDERABLE | DEPTH_RENDERABLE | RENDERBUFFER_VALID), 352 GLS_ARRAY_RANGE(s_oesDepth24SizedFormats) 353 }, 354 { 355 "GL_OES_depth24 GL_OES_required_internalformat GL_OES_depth_texture", 356 (deUint32)TEXTURE_VALID, 357 GLS_ARRAY_RANGE(s_oesDepth24SizedFormats) 358 }, 359 360 { 361 "GL_OES_depth32", 362 (deUint32)(REQUIRED_RENDERABLE | DEPTH_RENDERABLE | RENDERBUFFER_VALID), 363 GLS_ARRAY_RANGE(s_oesDepth32SizedFormats) 364 }, 365 { 366 "GL_OES_depth32 GL_OES_required_internalformat GL_OES_depth_texture", 367 (deUint32)TEXTURE_VALID, 368 GLS_ARRAY_RANGE(s_oesDepth32SizedFormats) 369 }, 370 371 { 372 "GL_EXT_texture_type_2_10_10_10_REV", 373 (deUint32)TEXTURE_VALID, // explicitly unrenderable 374 GLS_ARRAY_RANGE(s_extTextureType2101010RevFormats) 375 }, 376 { 377 "GL_EXT_texture_type_2_10_10_10_REV GL_OES_required_internalformat", 378 (deUint32)TEXTURE_VALID, // explicitly unrenderable 379 GLS_ARRAY_RANGE(s_oesRequiredInternalFormat10bitColorFormats) 380 }, 381 382 { 383 "GL_EXT_texture_sRGB_R8", 384 (deUint32)TEXTURE_VALID, 385 GLS_ARRAY_RANGE(s_extTextureSRGBR8Formats) 386 }, 387 { 388 "GL_EXT_texture_sRGB_RG8", 389 (deUint32)TEXTURE_VALID, 390 GLS_ARRAY_RANGE(s_extTextureSRGBRG8Formats) 391 }, 392}; 393 394Context::Context (TestContext& testCtx, 395 RenderContext& renderCtx, 396 CheckerFactory& factory) 397 : m_testCtx (testCtx) 398 , m_renderCtx (renderCtx) 399 , m_verifier (m_ctxFormats, factory, renderCtx) 400 , m_haveMultiColorAtts (false) 401{ 402 FormatExtEntries extRange = GLS_ARRAY_RANGE(s_esExtFormats); 403 addExtFormats(extRange); 404} 405 406void Context::addFormats (FormatEntries fmtRange) 407{ 408 FboUtil::addFormats(m_coreFormats, fmtRange); 409 FboUtil::addFormats(m_ctxFormats, fmtRange); 410 FboUtil::addFormats(m_allFormats, fmtRange); 411} 412 413void Context::addExtFormats (FormatExtEntries extRange) 414{ 415 FboUtil::addExtFormats(m_ctxFormats, extRange, &m_renderCtx); 416 FboUtil::addExtFormats(m_allFormats, extRange, DE_NULL); 417} 418 419void TestBase::pass (void) 420{ 421 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); 422} 423 424void TestBase::qualityWarning (const char* msg) 425{ 426 m_testCtx.setTestResult(QP_TEST_RESULT_QUALITY_WARNING, msg); 427} 428 429void TestBase::fail (const char* msg) 430{ 431 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, msg); 432} 433 434const glw::Functions& gl (const TestBase& test) 435{ 436 return test.getContext().getRenderContext().getFunctions(); 437} 438 439static bool isFormatFeatureSupported (const FormatDB& db, const ImageFormat& format, FormatFlags feature) 440{ 441 return db.isKnownFormat(format) && ((db.getFormatInfo(format) & feature) == feature); 442} 443 444static void logAffectingExtensions (const char* prefix, const FormatDB& db, const ImageFormat& format, FormatFlags feature, tcu::MessageBuilder& msg) 445{ 446 const std::set<std::set<std::string> > rows = db.getFormatFeatureExtensions(format, feature); 447 448 for (std::set<std::set<std::string> >::const_iterator rowIt = rows.begin(); rowIt != rows.end(); ++rowIt) 449 { 450 const std::set<std::string>& requiredExtensions = *rowIt; 451 std::set<std::string>::const_iterator it = requiredExtensions.begin(); 452 std::string extName; 453 454 msg << prefix; 455 456 extName = *it++; 457 while (it != requiredExtensions.end()) 458 { 459 msg << getExtensionDescription(extName); 460 extName = *it++; 461 msg << (it == requiredExtensions.end() ? " and " : ", "); 462 } 463 464 msg << getExtensionDescription(extName) << '\n'; 465 } 466} 467 468static void logFormatInfo (const config::Framebuffer& fbo, const FormatDB& ctxFormats, const FormatDB& coreFormats, const FormatDB& allFormats, tcu::TestLog& log) 469{ 470 static const struct 471 { 472 const char* name; 473 const FormatFlags flag; 474 } s_renderability[] = 475 { 476 { "color-renderable", COLOR_RENDERABLE }, 477 { "depth-renderable", DEPTH_RENDERABLE }, 478 { "stencil-renderable", STENCIL_RENDERABLE }, 479 }; 480 481 std::set<ImageFormat> formats; 482 483 for (config::TextureMap::const_iterator it = fbo.textures.begin(); it != fbo.textures.end(); ++it) 484 formats.insert(it->second->internalFormat); 485 for (config::RboMap::const_iterator it = fbo.rbos.begin(); it != fbo.rbos.end(); ++it) 486 formats.insert(it->second->internalFormat); 487 488 if (!formats.empty()) 489 { 490 const tcu::ScopedLogSection supersection(log, "Format", "Format info"); 491 492 for (std::set<ImageFormat>::const_iterator it = formats.begin(); it != formats.end(); ++it) 493 { 494 const tcu::ScopedLogSection section(log, "FormatInfo", de::toString(*it)); 495 496 // texture validity 497 if (isFormatFeatureSupported(ctxFormats, *it, TEXTURE_VALID)) 498 { 499 tcu::MessageBuilder msg(&log); 500 msg << "* Valid texture format\n"; 501 502 if (isFormatFeatureSupported(coreFormats, *it, TEXTURE_VALID)) 503 msg << "\t* core feature"; 504 else 505 { 506 msg << "\t* defined in supported extension(s):\n"; 507 logAffectingExtensions("\t\t- ", ctxFormats, *it, TEXTURE_VALID, msg); 508 } 509 510 msg << tcu::TestLog::EndMessage; 511 } 512 else 513 { 514 tcu::MessageBuilder msg(&log); 515 msg << "* Unsupported texture format\n"; 516 517 if (isFormatFeatureSupported(allFormats, *it, TEXTURE_VALID)) 518 { 519 msg << "\t* requires any of the extensions or combinations:\n"; 520 logAffectingExtensions("\t\t- ", allFormats, *it, TEXTURE_VALID, msg); 521 } 522 else 523 msg << "\t* no extension can make this format valid"; 524 525 msg << tcu::TestLog::EndMessage; 526 } 527 528 // RBO validity 529 if (isFormatFeatureSupported(ctxFormats, *it, RENDERBUFFER_VALID)) 530 { 531 tcu::MessageBuilder msg(&log); 532 msg << "* Valid renderbuffer format\n"; 533 534 if (isFormatFeatureSupported(coreFormats, *it, RENDERBUFFER_VALID)) 535 msg << "\t* core feature"; 536 else 537 { 538 msg << "\t* defined in supported extension(s):\n"; 539 logAffectingExtensions("\t\t- ", ctxFormats, *it, RENDERBUFFER_VALID, msg); 540 } 541 542 msg << tcu::TestLog::EndMessage; 543 } 544 else 545 { 546 tcu::MessageBuilder msg(&log); 547 msg << "* Unsupported renderbuffer format\n"; 548 549 if (isFormatFeatureSupported(allFormats, *it, RENDERBUFFER_VALID)) 550 { 551 msg << "\t* requires any of the extensions or combinations:\n"; 552 logAffectingExtensions("\t\t- ", allFormats, *it, RENDERBUFFER_VALID, msg); 553 } 554 else 555 msg << "\t* no extension can make this format valid"; 556 557 msg << tcu::TestLog::EndMessage; 558 } 559 560 // renderability 561 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_renderability); ++ndx) 562 { 563 if (isFormatFeatureSupported(ctxFormats, *it, s_renderability[ndx].flag | REQUIRED_RENDERABLE)) 564 { 565 tcu::MessageBuilder msg(&log); 566 msg << "* Format is " << s_renderability[ndx].name << "\n"; 567 568 if (isFormatFeatureSupported(coreFormats, *it, s_renderability[ndx].flag | REQUIRED_RENDERABLE)) 569 msg << "\t* core feature"; 570 else 571 { 572 msg << "\t* defined in supported extension(s):\n"; 573 logAffectingExtensions("\t\t- ", ctxFormats, *it, s_renderability[ndx].flag | REQUIRED_RENDERABLE, msg); 574 } 575 576 msg << tcu::TestLog::EndMessage; 577 } 578 else if (isFormatFeatureSupported(ctxFormats, *it, s_renderability[ndx].flag)) 579 { 580 tcu::MessageBuilder msg(&log); 581 msg << "* Format is allowed to be " << s_renderability[ndx].name << " but not required\n"; 582 583 if (isFormatFeatureSupported(coreFormats, *it, s_renderability[ndx].flag)) 584 msg << "\t* core feature"; 585 else if (isFormatFeatureSupported(allFormats, *it, s_renderability[ndx].flag)) 586 { 587 msg << "\t* extensions that would make format " << s_renderability[ndx].name << ":\n"; 588 logAffectingExtensions("\t\t- ", allFormats, *it, s_renderability[ndx].flag, msg); 589 } 590 else 591 msg << "\t* no extension can make this format " << s_renderability[ndx].name; 592 593 msg << tcu::TestLog::EndMessage; 594 } 595 else 596 { 597 tcu::MessageBuilder msg(&log); 598 msg << "* Format is NOT " << s_renderability[ndx].name << "\n"; 599 600 if (isFormatFeatureSupported(allFormats, *it, s_renderability[ndx].flag)) 601 { 602 if (isFormatFeatureSupported(allFormats, *it, s_renderability[ndx].flag | REQUIRED_RENDERABLE)) 603 { 604 msg << "\t* extensions that would make format " << s_renderability[ndx].name << ":\n"; 605 logAffectingExtensions("\t\t- ", allFormats, *it, s_renderability[ndx].flag | REQUIRED_RENDERABLE, msg); 606 } 607 else 608 { 609 msg << "\t* extensions that are allowed to make format " << s_renderability[ndx].name << ":\n"; 610 logAffectingExtensions("\t\t- ", allFormats, *it, s_renderability[ndx].flag, msg); 611 } 612 } 613 else 614 msg << "\t* no extension can make this format " << s_renderability[ndx].name; 615 616 msg << tcu::TestLog::EndMessage; 617 } 618 } 619 } 620 } 621} 622 623IterateResult TestBase::iterate (void) 624{ 625 glu::Framebuffer fbo (m_ctx.getRenderContext()); 626 FboBuilder builder (*fbo, GL_FRAMEBUFFER, gl(*this)); 627 const IterateResult ret = build(builder); 628 const ValidStatusCodes reference = m_ctx.getVerifier().validStatusCodes(builder); 629 const GLenum errorCode = builder.getError(); 630 631 logFramebufferConfig(builder, m_testCtx.getLog()); 632 logFormatInfo(builder, m_ctx.getCtxFormats(), m_ctx.getCoreFormats(), m_ctx.getAllFormats(), m_testCtx.getLog()); 633 reference.logRules(m_testCtx.getLog()); 634 reference.logLegalResults(m_testCtx.getLog()); 635 636 // \todo [2013-12-04 lauri] Check if drawing operations succeed. 637 638 if (errorCode != GL_NO_ERROR) 639 { 640 m_testCtx.getLog() 641 << TestLog::Message 642 << "Received " << glu::getErrorStr(errorCode) << " (during FBO initialization)." 643 << TestLog::EndMessage; 644 645 if (reference.isErrorCodeValid(errorCode)) 646 pass(); 647 else if (reference.isErrorCodeRequired(GL_NO_ERROR)) 648 fail(("Expected no error but got " + de::toString(glu::getErrorStr(errorCode))).c_str()); 649 else 650 fail("Got wrong error code"); 651 } 652 else 653 { 654 const GLenum fboStatus = gl(*this).checkFramebufferStatus(GL_FRAMEBUFFER); 655 const bool validStatus = reference.isFBOStatusValid(fboStatus); 656 657 m_testCtx.getLog() 658 << TestLog::Message 659 << "Received " << glu::getFramebufferStatusStr(fboStatus) << "." 660 << TestLog::EndMessage; 661 662 if (!validStatus) 663 { 664 if (fboStatus == GL_FRAMEBUFFER_COMPLETE) 665 fail("Framebuffer checked as complete, expected incomplete"); 666 else if (reference.isFBOStatusRequired(GL_FRAMEBUFFER_COMPLETE)) 667 fail("Framebuffer checked is incomplete, expected complete"); 668 else 669 // An incomplete status is allowed, but not _this_ incomplete status. 670 fail("Framebuffer checked as incomplete, but with wrong status"); 671 } 672 else if (fboStatus == GL_FRAMEBUFFER_UNSUPPORTED) 673 { 674 // The spec requires 675 // "when both depth and stencil attachments are present,implementations are only required 676 // to support framebuffer objects where both attachments refer to the same image." 677 // 678 // Thus, it is acceptable for an implementation returning GL_FRAMEBUFFER_UNSUPPORTED, 679 // and the test cannot be marked as failed. 680 pass(); 681 } 682 else if (fboStatus != GL_FRAMEBUFFER_COMPLETE && reference.isFBOStatusValid(GL_FRAMEBUFFER_COMPLETE)) 683 qualityWarning("Framebuffer object could have checked as complete but did not."); 684 else 685 pass(); 686 } 687 688 return ret; 689} 690 691IterateResult TestBase::build (FboBuilder& builder) 692{ 693 DE_UNREF(builder); 694 return STOP; 695} 696 697ImageFormat TestBase::getDefaultFormat (GLenum attPoint, GLenum bufType) const 698{ 699 if (bufType == GL_NONE) 700 { 701 return ImageFormat::none(); 702 } 703 704 // Prefer a standard format, if there is one, but if not, use a format 705 // provided by an extension. 706 Formats formats = m_ctx.getCoreFormats().getFormats(formatFlag(attPoint) | 707 formatFlag(bufType)); 708 Formats::const_iterator it = formats.begin(); 709 if (it == formats.end()) 710 { 711 formats = m_ctx.getCtxFormats().getFormats(formatFlag(attPoint) | 712 formatFlag(bufType)); 713 it = formats.begin(); 714 } 715 if (it == formats.end()) 716 throw tcu::NotSupportedError("Unsupported attachment kind for attachment point", 717 "", __FILE__, __LINE__); 718 return *it; 719} 720 721Image* makeImage (GLenum bufType, ImageFormat format, 722 GLsizei width, GLsizei height, FboBuilder& builder) 723{ 724 Image* image = DE_NULL; 725 switch (bufType) 726 { 727 case GL_NONE: 728 return DE_NULL; 729 case GL_RENDERBUFFER: 730 image = &builder.makeConfig<Renderbuffer>(); 731 break; 732 case GL_TEXTURE: 733 image = &builder.makeConfig<Texture2D>(); 734 break; 735 default: 736 DE_FATAL("Impossible case"); 737 } 738 image->internalFormat = format; 739 image->width = width; 740 image->height = height; 741 return image; 742} 743 744Attachment* makeAttachment (GLenum bufType, ImageFormat format, 745 GLsizei width, GLsizei height, FboBuilder& builder) 746{ 747 Image* const imgCfg = makeImage (bufType, format, width, height, builder); 748 Attachment* att = DE_NULL; 749 GLuint img = 0; 750 751 if (Renderbuffer* rboCfg = dynamic_cast<Renderbuffer*>(imgCfg)) 752 { 753 img = builder.glCreateRbo(*rboCfg); 754 att = &builder.makeConfig<RenderbufferAttachment>(); 755 } 756 else if (Texture2D* texCfg = dynamic_cast<Texture2D*>(imgCfg)) 757 { 758 img = builder.glCreateTexture(*texCfg); 759 TextureFlatAttachment& texAtt = builder.makeConfig<TextureFlatAttachment>(); 760 texAtt.texTarget = GL_TEXTURE_2D; 761 att = &texAtt; 762 } 763 else 764 { 765 DE_ASSERT(imgCfg == DE_NULL); 766 return DE_NULL; 767 } 768 att->imageName = img; 769 return att; 770} 771 772void TestBase::attachTargetToNew (GLenum target, GLenum bufType, ImageFormat format, 773 GLsizei width, GLsizei height, FboBuilder& builder) 774{ 775 ImageFormat imgFmt = format; 776 if (imgFmt.format == GL_NONE) 777 imgFmt = getDefaultFormat(target, bufType); 778 779 const Attachment* const att = makeAttachment(bufType, imgFmt, width, height, builder); 780 builder.glAttach(target, att); 781} 782 783static string formatName (ImageFormat format) 784{ 785 const string s = getTextureFormatName(format.format); 786 const string fmtStr = toLower(s.substr(3)); 787 788 if (format.unsizedType != GL_NONE) 789 { 790 const string typeStr = getTypeName(format.unsizedType); 791 return fmtStr + "_" + toLower(typeStr.substr(3)); 792 } 793 794 return fmtStr; 795} 796 797static string formatDesc (ImageFormat format) 798{ 799 const string fmtStr = getTextureFormatName(format.format); 800 801 if (format.unsizedType != GL_NONE) 802 { 803 const string typeStr = getTypeName(format.unsizedType); 804 return fmtStr + " with type " + typeStr; 805 } 806 807 return fmtStr; 808} 809 810struct RenderableParams 811{ 812 GLenum attPoint; 813 GLenum bufType; 814 ImageFormat format; 815 static string getName (const RenderableParams& params) 816 { 817 return formatName(params.format); 818 } 819 static string getDescription (const RenderableParams& params) 820 { 821 return formatDesc(params.format); 822 } 823}; 824 825class RenderableTest : public ParamTest<RenderableParams> 826{ 827public: 828 RenderableTest (Context& group, const Params& params) 829 : ParamTest<RenderableParams> (group, params) {} 830 IterateResult build (FboBuilder& builder); 831}; 832 833IterateResult RenderableTest::build (FboBuilder& builder) 834{ 835 attachTargetToNew(m_params.attPoint, m_params.bufType, m_params.format, 64, 64, builder); 836 return STOP; 837} 838 839string attTypeName (GLenum bufType) 840{ 841 switch (bufType) 842 { 843 case GL_NONE: 844 return "none"; 845 case GL_RENDERBUFFER: 846 return "rbo"; 847 case GL_TEXTURE: 848 return "tex"; 849 default: 850 DE_FATAL("Impossible case"); 851 } 852 return ""; // Shut up compiler 853} 854 855struct AttachmentParams 856{ 857 GLenum color0Kind; 858 GLenum colornKind; 859 GLenum depthKind; 860 GLenum stencilKind; 861 862 static string getName (const AttachmentParams& params); 863 static string getDescription (const AttachmentParams& params) 864 { 865 return getName(params); 866 } 867}; 868 869string AttachmentParams::getName (const AttachmentParams& params) 870{ 871 return (attTypeName(params.color0Kind) + "_" + 872 attTypeName(params.colornKind) + "_" + 873 attTypeName(params.depthKind) + "_" + 874 attTypeName(params.stencilKind)); 875} 876 877//! Test for combinations of different kinds of attachments 878class AttachmentTest : public ParamTest<AttachmentParams> 879{ 880public: 881 AttachmentTest (Context& group, Params& params) 882 : ParamTest<AttachmentParams> (group, params) {} 883 884protected: 885 IterateResult build (FboBuilder& builder); 886 void makeDepthAndStencil (FboBuilder& builder); 887}; 888 889 890void AttachmentTest::makeDepthAndStencil (FboBuilder& builder) 891{ 892 if (m_params.stencilKind == m_params.depthKind) 893 { 894 // If there is a common stencil+depth -format, try to use a common 895 // image for both attachments. 896 const FormatFlags flags = 897 DEPTH_RENDERABLE | STENCIL_RENDERABLE | formatFlag(m_params.stencilKind); 898 const Formats& formats = m_ctx.getCoreFormats().getFormats(flags); 899 Formats::const_iterator it = formats.begin(); 900 if (it != formats.end()) 901 { 902 const ImageFormat format = *it; 903 Attachment* att = makeAttachment(m_params.depthKind, format, 64, 64, builder); 904 builder.glAttach(GL_DEPTH_ATTACHMENT, att); 905 builder.glAttach(GL_STENCIL_ATTACHMENT, att); 906 return; 907 } 908 } 909 // Either the kinds were separate, or a suitable format was not found. 910 // Create separate images. 911 attachTargetToNew(GL_STENCIL_ATTACHMENT, m_params.stencilKind, ImageFormat::none(), 912 64, 64, builder); 913 attachTargetToNew(GL_DEPTH_ATTACHMENT, m_params.depthKind, ImageFormat::none(), 914 64, 64, builder); 915} 916 917IterateResult AttachmentTest::build (FboBuilder& builder) 918{ 919 attachTargetToNew(GL_COLOR_ATTACHMENT0, m_params.color0Kind, ImageFormat::none(), 920 64, 64, builder); 921 922 if (m_params.colornKind != GL_NONE) 923 { 924 TCU_CHECK_AND_THROW(NotSupportedError, m_ctx.haveMultiColorAtts(), 925 "Multiple attachments not supported"); 926 GLint maxAttachments = 1; 927 gl(*this).getIntegerv(GL_MAX_COLOR_ATTACHMENTS, &maxAttachments); 928 GLU_EXPECT_NO_ERROR( 929 gl(*this).getError(), "Couldn't read GL_MAX_COLOR_ATTACHMENTS"); 930 931 for (int i = 1; i < maxAttachments; i++) 932 { 933 attachTargetToNew(GL_COLOR_ATTACHMENT0 + i, m_params.colornKind, 934 ImageFormat::none(), 64, 64, builder); 935 } 936 } 937 938 makeDepthAndStencil(builder); 939 940 return STOP; 941} 942 943class EmptyImageTest : public TestBase 944{ 945public: 946 EmptyImageTest (Context& group, 947 const char* name, const char* desc) 948 : TestBase (group, name, desc) {} 949 950 IterateResult build (FboBuilder& builder); 951}; 952 953IterateResult EmptyImageTest::build (FboBuilder& builder) 954{ 955 attachTargetToNew(GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, ImageFormat::none(), 956 0, 0, builder); 957 return STOP; 958} 959 960 961class DistinctSizeTest : public TestBase 962{ 963public: 964 DistinctSizeTest (Context& group, 965 const char* name, const char* desc) 966 : TestBase (group, name, desc) {} 967 968 IterateResult build (FboBuilder& builder); 969}; 970 971IterateResult DistinctSizeTest::build (FboBuilder& builder) 972{ 973 attachTargetToNew(GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, ImageFormat::none(), 974 64, 64, builder); 975 attachTargetToNew(GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, ImageFormat::none(), 976 128, 128, builder); 977 return STOP; 978} 979 980TestCaseGroup* Context::createRenderableTests (void) 981{ 982 TestCaseGroup* const renderableTests = new TestCaseGroup( 983 m_testCtx, "renderable", "Tests for support of renderable image formats"); 984 985 TestCaseGroup* const rbRenderableTests = new TestCaseGroup( 986 m_testCtx, "renderbuffer", "Tests for renderbuffer formats"); 987 988 TestCaseGroup* const texRenderableTests = new TestCaseGroup( 989 m_testCtx, "texture", "Tests for texture formats"); 990 991 static const struct AttPoint { 992 GLenum attPoint; 993 const char* name; 994 const char* desc; 995 } attPoints[] = 996 { 997 { GL_COLOR_ATTACHMENT0, "color0", "Tests for color attachments" }, 998 { GL_STENCIL_ATTACHMENT, "stencil", "Tests for stencil attachments" }, 999 { GL_DEPTH_ATTACHMENT, "depth", "Tests for depth attachments" }, 1000 }; 1001 1002 // At each attachment point, iterate through all the possible formats to 1003 // detect both false positives and false negatives. 1004 const Formats rboFmts = m_allFormats.getFormats(ANY_FORMAT); 1005 const Formats texFmts = m_allFormats.getFormats(ANY_FORMAT); 1006 1007 for (const AttPoint* it = DE_ARRAY_BEGIN(attPoints); it != DE_ARRAY_END(attPoints); it++) 1008 { 1009 TestCaseGroup* const rbAttTests = new TestCaseGroup(m_testCtx, it->name, it->desc); 1010 TestCaseGroup* const texAttTests = new TestCaseGroup(m_testCtx, it->name, it->desc); 1011 1012 for (Formats::const_iterator it2 = rboFmts.begin(); it2 != rboFmts.end(); it2++) 1013 { 1014 const RenderableParams params = { it->attPoint, GL_RENDERBUFFER, *it2 }; 1015 rbAttTests->addChild(new RenderableTest(*this, params)); 1016 } 1017 rbRenderableTests->addChild(rbAttTests); 1018 1019 for (Formats::const_iterator it2 = texFmts.begin(); it2 != texFmts.end(); it2++) 1020 { 1021 const RenderableParams params = { it->attPoint, GL_TEXTURE, *it2 }; 1022 texAttTests->addChild(new RenderableTest(*this, params)); 1023 } 1024 texRenderableTests->addChild(texAttTests); 1025 } 1026 renderableTests->addChild(rbRenderableTests); 1027 renderableTests->addChild(texRenderableTests); 1028 1029 return renderableTests; 1030} 1031 1032TestCaseGroup* Context::createAttachmentTests (void) 1033{ 1034 TestCaseGroup* const attCombTests = new TestCaseGroup( 1035 m_testCtx, "attachment_combinations", "Tests for attachment combinations"); 1036 1037 static const GLenum s_bufTypes[] = { GL_NONE, GL_RENDERBUFFER, GL_TEXTURE }; 1038 static const Range<GLenum> s_kinds = GLS_ARRAY_RANGE(s_bufTypes); 1039 1040 for (const GLenum* col0 = s_kinds.begin(); col0 != s_kinds.end(); ++col0) 1041 for (const GLenum* coln = s_kinds.begin(); coln != s_kinds.end(); ++coln) 1042 for (const GLenum* dep = s_kinds.begin(); dep != s_kinds.end(); ++dep) 1043 for (const GLenum* stc = s_kinds.begin(); stc != s_kinds.end(); ++stc) 1044 { 1045 AttachmentParams params = { *col0, *coln, *dep, *stc }; 1046 attCombTests->addChild(new AttachmentTest(*this, params)); 1047 } 1048 1049 return attCombTests; 1050} 1051 1052TestCaseGroup* Context::createSizeTests (void) 1053{ 1054 TestCaseGroup* const sizeTests = new TestCaseGroup( 1055 m_testCtx, "size", "Tests for attachment sizes"); 1056 sizeTests->addChild(new EmptyImageTest( 1057 *this, "zero", 1058 "Test for zero-sized image attachment")); 1059 sizeTests->addChild(new DistinctSizeTest( 1060 *this, "distinct", 1061 "Test for attachments with different sizes")); 1062 1063 return sizeTests; 1064} 1065 1066} // details 1067 1068} // fboc 1069} // gls 1070} // deqp 1071