1 /*------------------------------------------------------------------------- 2 * drawElements Quality Program EGL 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 Test for mapping client color values to native surface colors 22 *//*--------------------------------------------------------------------*/ 23 24 #include "teglNativeColorMappingTests.hpp" 25 26 #include "teglSimpleConfigCase.hpp" 27 28 #include "tcuTexture.hpp" 29 30 #include "egluNativeDisplay.hpp" 31 #include "egluNativeWindow.hpp" 32 #include "egluNativePixmap.hpp" 33 #include "egluUnique.hpp" 34 #include "egluUtil.hpp" 35 36 #include "gluDefs.hpp" 37 #include "glwFunctions.hpp" 38 #include "glwEnums.hpp" 39 40 #include "tcuImageCompare.hpp" 41 #include "tcuTestLog.hpp" 42 #include "tcuTexture.hpp" 43 #include "tcuTextureUtil.hpp" 44 45 #include "deUniquePtr.hpp" 46 #include "deStringUtil.hpp" 47 48 #include "deThread.hpp" 49 50 #include <vector> 51 #include <string> 52 #include <limits> 53 54 using tcu::TestLog; 55 using std::vector; 56 using std::string; 57 58 namespace deqp 59 { 60 namespace egl 61 { 62 namespace 63 { 64 65 EGLContext createGLES2Context (EGLDisplay display, EGLConfig config) 66 { 67 EGLContext context = EGL_NO_CONTEXT; 68 const EGLint attribList[] = 69 { 70 EGL_CONTEXT_CLIENT_VERSION, 2, 71 EGL_NONE 72 }; 73 74 TCU_CHECK_EGL_CALL(eglBindAPI(EGL_OPENGL_ES_API)); 75 76 context = eglCreateContext(display, config, EGL_NO_CONTEXT, attribList); 77 TCU_CHECK_EGL_MSG("eglCreateContext() failed"); 78 TCU_CHECK(context); 79 80 return context; 81 } 82 83 deUint32 createGLES2Program (const glw::Functions& gl, TestLog& log) 84 { 85 const char* const vertexShaderSource = 86 "attribute highp vec2 a_pos;\n" 87 "void main (void)\n" 88 "{\n" 89 "\tgl_Position = vec4(a_pos, 0.0, 1.0);\n" 90 "}"; 91 92 const char* const fragmentShaderSource = 93 "uniform mediump vec4 u_color;\n" 94 "void main (void)\n" 95 "{\n" 96 "\tgl_FragColor = u_color;\n" 97 "}"; 98 99 deUint32 program = 0; 100 deUint32 vertexShader = 0; 101 deUint32 fragmentShader = 0; 102 103 deInt32 vertexCompileStatus; 104 string vertexInfoLog; 105 deInt32 fragmentCompileStatus; 106 string fragmentInfoLog; 107 deInt32 linkStatus; 108 string programInfoLog; 109 110 try 111 { 112 program = gl.createProgram(); 113 vertexShader = gl.createShader(GL_VERTEX_SHADER); 114 fragmentShader = gl.createShader(GL_FRAGMENT_SHADER); 115 116 GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to create shaders and program"); 117 118 gl.shaderSource(vertexShader, 1, &vertexShaderSource, DE_NULL); 119 gl.compileShader(vertexShader); 120 GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to setup vertex shader"); 121 122 gl.shaderSource(fragmentShader, 1, &fragmentShaderSource, DE_NULL); 123 gl.compileShader(fragmentShader); 124 GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to setup fragment shader"); 125 126 { 127 deInt32 infoLogLength = 0; 128 129 gl.getShaderiv(vertexShader, GL_COMPILE_STATUS, &vertexCompileStatus); 130 gl.getShaderiv(vertexShader, GL_INFO_LOG_LENGTH, &infoLogLength); 131 132 vertexInfoLog.resize(infoLogLength, '\0'); 133 134 gl.getShaderInfoLog(vertexShader, (glw::GLsizei)vertexInfoLog.length(), &infoLogLength, &(vertexInfoLog[0])); 135 GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to get vertex shader compile info"); 136 137 vertexInfoLog.resize(infoLogLength); 138 } 139 140 { 141 deInt32 infoLogLength = 0; 142 143 gl.getShaderiv(fragmentShader, GL_COMPILE_STATUS, &fragmentCompileStatus); 144 gl.getShaderiv(fragmentShader, GL_INFO_LOG_LENGTH, &infoLogLength); 145 146 fragmentInfoLog.resize(infoLogLength, '\0'); 147 148 gl.getShaderInfoLog(fragmentShader, (glw::GLsizei)fragmentInfoLog.length(), &infoLogLength, &(fragmentInfoLog[0])); 149 GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to get fragment shader compile info"); 150 151 fragmentInfoLog.resize(infoLogLength); 152 } 153 154 gl.attachShader(program, vertexShader); 155 gl.attachShader(program, fragmentShader); 156 gl.linkProgram(program); 157 GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to setup program"); 158 159 { 160 deInt32 infoLogLength = 0; 161 162 gl.getProgramiv(program, GL_LINK_STATUS, &linkStatus); 163 gl.getProgramiv(program, GL_INFO_LOG_LENGTH, &infoLogLength); 164 165 programInfoLog.resize(infoLogLength, '\0'); 166 167 gl.getProgramInfoLog(program, (glw::GLsizei)programInfoLog.length(), &infoLogLength, &(programInfoLog[0])); 168 GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to get program link info"); 169 170 programInfoLog.resize(infoLogLength); 171 } 172 173 if (linkStatus == 0 || vertexCompileStatus == 0 || fragmentCompileStatus == 0) 174 { 175 176 log.startShaderProgram(linkStatus != 0, programInfoLog.c_str()); 177 178 log << TestLog::Shader(QP_SHADER_TYPE_VERTEX, vertexShaderSource, vertexCompileStatus != 0, vertexInfoLog); 179 log << TestLog::Shader(QP_SHADER_TYPE_FRAGMENT, fragmentShaderSource, fragmentCompileStatus != 0, fragmentInfoLog); 180 181 log.endShaderProgram(); 182 } 183 184 gl.deleteShader(vertexShader); 185 gl.deleteShader(fragmentShader); 186 GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to delete shaders"); 187 188 TCU_CHECK(linkStatus != 0 && vertexCompileStatus != 0 && fragmentCompileStatus != 0); 189 } 190 catch (...) 191 { 192 if (program) 193 gl.deleteProgram(program); 194 195 if (vertexShader) 196 gl.deleteShader(vertexShader); 197 198 if (fragmentShader) 199 gl.deleteShader(fragmentShader); 200 201 throw; 202 } 203 204 return program; 205 } 206 207 void clear (const glw::Functions& gl, const tcu::Vec4& color) 208 { 209 gl.clearColor(color.x(), color.y(), color.z(), color.w()); 210 gl.clear(GL_COLOR_BUFFER_BIT); 211 GLU_EXPECT_NO_ERROR(gl.getError(), "Color clear failed"); 212 } 213 214 void render (const glw::Functions& gl, deUint32 program, const tcu::Vec4& color) 215 { 216 const float positions[] = 217 { 218 -1.0f, -1.0f, 219 1.0f, -1.0f, 220 1.0f, 1.0f, 221 222 1.0f, 1.0f, 223 -1.0f, 1.0f, 224 -1.0f, -1.0f 225 }; 226 227 deUint32 posLocation; 228 deUint32 colorLocation; 229 230 gl.useProgram(program); 231 posLocation = gl.getAttribLocation(program, "a_pos"); 232 gl.enableVertexAttribArray(posLocation); 233 GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to setup shader program for rendering"); 234 235 colorLocation = gl.getUniformLocation(program, "u_color"); 236 gl.uniform4fv(colorLocation, 1, color.getPtr()); 237 238 gl.vertexAttribPointer(posLocation, 2, GL_FLOAT, GL_FALSE, 0, positions); 239 gl.drawArrays(GL_TRIANGLES, 0, 6); 240 GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to render"); 241 } 242 243 bool validate (TestLog& log, EGLDisplay display, EGLConfig config, const tcu::TextureLevel& result, const tcu::Vec4& color) 244 { 245 const tcu::UVec4 eglBitDepth((deUint32)eglu::getConfigAttribInt(display, config, EGL_RED_SIZE), 246 (deUint32)eglu::getConfigAttribInt(display, config, EGL_GREEN_SIZE), 247 (deUint32)eglu::getConfigAttribInt(display, config, EGL_BLUE_SIZE), 248 (deUint32)eglu::getConfigAttribInt(display, config, EGL_ALPHA_SIZE)); 249 250 const tcu::UVec4 nativeBitDepth(tcu::getTextureFormatBitDepth(result.getFormat()).asUint()); 251 const tcu::UVec4 bitDepth(deMinu32(nativeBitDepth.x(), eglBitDepth.x()), 252 deMinu32(nativeBitDepth.y(), eglBitDepth.y()), 253 deMinu32(nativeBitDepth.z(), eglBitDepth.z()), 254 deMinu32(nativeBitDepth.w(), eglBitDepth.w())); 255 256 const tcu::UVec4 uColor = tcu::UVec4((deUint32)(((1u << bitDepth.x()) - 1u) * color.x()), 257 (deUint32)(((1u << bitDepth.y()) - 1u) * color.y()), 258 (deUint32)(((1u << bitDepth.z()) - 1u) * color.z()), 259 (deUint32)(((1u << bitDepth.w()) - 1u) * color.w())); 260 261 tcu::TextureLevel reference(result.getFormat(), result.getWidth(), result.getHeight()); 262 263 for (int y = 0; y < result.getHeight(); y++) 264 { 265 for (int x = 0; x < result.getWidth(); x++) 266 reference.getAccess().setPixel(uColor, x, y); 267 } 268 269 return tcu::intThresholdCompare(log, "Result compare", "Compare results", reference.getAccess(), result.getAccess(), tcu::UVec4(1u, 1u, 1u, (bitDepth.w() > 0 ? 1u : std::numeric_limits<deUint32>::max())), tcu::COMPARE_LOG_RESULT); 270 } 271 272 class NativeColorMappingCase : public SimpleConfigCase 273 { 274 public: 275 enum NativeType 276 { 277 NATIVETYPE_WINDOW = 0, 278 NATIVETYPE_PIXMAP, 279 NATIVETYPE_PBUFFER_COPY_TO_PIXMAP 280 }; 281 282 NativeColorMappingCase (EglTestContext& eglTestCtx, const char* name, const char* description, bool render, NativeType nativeType, const vector<EGLint>& configIds); 283 ~NativeColorMappingCase (void); 284 285 private: 286 void executeForConfig (tcu::egl::Display& display, EGLConfig config); 287 288 NativeType m_nativeType; 289 bool m_render; 290 }; 291 292 NativeColorMappingCase::NativeColorMappingCase (EglTestContext& eglTestCtx, const char* name, const char* description, bool render, NativeType nativeType, const vector<EGLint>& configIds) 293 : SimpleConfigCase (eglTestCtx, name, description, configIds) 294 , m_nativeType (nativeType) 295 , m_render (render) 296 { 297 } 298 299 NativeColorMappingCase::~NativeColorMappingCase (void) 300 { 301 deinit(); 302 } 303 304 void logConfigInfo (TestLog& log, EGLDisplay display, EGLConfig config, NativeColorMappingCase::NativeType nativeType, int waitFrames) 305 { 306 log << TestLog::Message << "EGL_RED_SIZE: " << eglu::getConfigAttribInt(display, config, EGL_RED_SIZE) << TestLog::EndMessage; 307 log << TestLog::Message << "EGL_GREEN_SIZE: " << eglu::getConfigAttribInt(display, config, EGL_GREEN_SIZE) << TestLog::EndMessage; 308 log << TestLog::Message << "EGL_BLUE_SIZE: " << eglu::getConfigAttribInt(display, config, EGL_BLUE_SIZE) << TestLog::EndMessage; 309 log << TestLog::Message << "EGL_ALPHA_SIZE: " << eglu::getConfigAttribInt(display, config, EGL_ALPHA_SIZE) << TestLog::EndMessage; 310 log << TestLog::Message << "EGL_DEPTH_SIZE: " << eglu::getConfigAttribInt(display, config, EGL_DEPTH_SIZE) << TestLog::EndMessage; 311 log << TestLog::Message << "EGL_STENCIL_SIZE: " << eglu::getConfigAttribInt(display, config, EGL_STENCIL_SIZE) << TestLog::EndMessage; 312 log << TestLog::Message << "EGL_SAMPLES: " << eglu::getConfigAttribInt(display, config, EGL_SAMPLES) << TestLog::EndMessage; 313 314 if (nativeType == NativeColorMappingCase::NATIVETYPE_WINDOW) 315 log << TestLog::Message << "Waiting " << waitFrames * 16 << "ms after eglSwapBuffers() and glFinish() for frame to become visible" << TestLog::EndMessage; 316 } 317 318 bool testNativeWindow (TestLog& log, eglu::NativeDisplay& nativeDisplay, eglu::NativeWindow& nativeWindow, EGLDisplay display, EGLContext context, EGLConfig config, const glw::Functions& gl, bool renderColor, int waitFrames, size_t colorCount, const tcu::Vec4* colors) 319 { 320 eglu::UniqueSurface surface(display, eglu::createWindowSurface(nativeDisplay, nativeWindow, display, config, DE_NULL)); 321 tcu::TextureLevel result; 322 deUint32 program = 0; 323 bool isOk = true; 324 325 try 326 { 327 TCU_CHECK_EGL_CALL(eglMakeCurrent(display, *surface, *surface, context)); 328 329 if (renderColor) 330 program = createGLES2Program(gl, log); 331 332 for (int colorNdx = 0; colorNdx < (int)colorCount; colorNdx++) 333 { 334 if (renderColor) 335 render(gl, program, colors[colorNdx]); 336 else 337 clear(gl, colors[colorNdx]); 338 339 TCU_CHECK_EGL_CALL(eglSwapBuffers(display, *surface)); 340 TCU_CHECK_EGL_CALL(eglWaitClient()); 341 deSleep(waitFrames*16); 342 nativeWindow.readScreenPixels(&result); 343 344 if (!validate(log, display, config, result, colors[colorNdx])) 345 isOk = false; 346 } 347 348 TCU_CHECK_EGL_CALL(eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)); 349 } 350 catch (...) 351 { 352 if (program) 353 gl.deleteProgram(program); 354 throw; 355 } 356 357 return isOk; 358 } 359 360 bool testNativePixmap (TestLog& log, eglu::NativeDisplay& nativeDisplay, eglu::NativePixmap& nativePixmap, EGLDisplay display, EGLContext context, EGLConfig config, const glw::Functions& gl, bool renderColor, size_t colorCount, const tcu::Vec4* colors) 361 { 362 eglu::UniqueSurface surface(display, eglu::createPixmapSurface(nativeDisplay, nativePixmap, display, config, DE_NULL)); 363 tcu::TextureLevel result; 364 deUint32 program = 0; 365 bool isOk = true; 366 367 try 368 { 369 TCU_CHECK_EGL_CALL(eglMakeCurrent(display, *surface, *surface, context)); 370 371 if (renderColor) 372 program = createGLES2Program(gl, log); 373 374 for (int colorNdx = 0; colorNdx < (int)colorCount; colorNdx++) 375 { 376 if (renderColor) 377 render(gl, program, colors[colorNdx]); 378 else 379 clear(gl, colors[colorNdx]); 380 381 TCU_CHECK_EGL_CALL(eglWaitClient()); 382 nativePixmap.readPixels(&result); 383 384 if (!validate(log, display, config, result, colors[colorNdx])) 385 isOk = false; 386 } 387 388 TCU_CHECK_EGL_CALL(eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)); 389 } 390 catch (...) 391 { 392 if (program) 393 gl.deleteProgram(program); 394 throw; 395 } 396 397 return isOk; 398 } 399 400 bool testNativePixmapCopy (TestLog& log, eglu::NativePixmap& nativePixmap, EGLDisplay display, EGLContext context, EGLConfig config, const glw::Functions& gl, bool renderColor, size_t colorCount, const tcu::Vec4* colors) 401 { 402 eglu::UniqueSurface surface(display, eglCreatePbufferSurface(display, config, DE_NULL)); 403 tcu::TextureLevel result; 404 deUint32 program = 0; 405 bool isOk = true; 406 407 try 408 { 409 TCU_CHECK_EGL_CALL(eglMakeCurrent(display, *surface, *surface, context)); 410 411 if (renderColor) 412 program = createGLES2Program(gl, log); 413 414 for (int colorNdx = 0; colorNdx < (int)colorCount; colorNdx++) 415 { 416 if (renderColor) 417 render(gl, program, colors[colorNdx]); 418 else 419 clear(gl, colors[colorNdx]); 420 421 TCU_CHECK_EGL_CALL(eglCopyBuffers(display, *surface, nativePixmap.getLegacyNative())); 422 TCU_CHECK_EGL_CALL(eglWaitClient()); 423 nativePixmap.readPixels(&result); 424 425 if (!validate(log, display, config, result, colors[colorNdx])) 426 isOk = false; 427 } 428 429 TCU_CHECK_EGL_CALL(eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)); 430 } 431 catch (...) 432 { 433 if (program) 434 gl.deleteProgram(program); 435 throw; 436 } 437 438 return isOk; 439 } 440 441 void checkSupport (EglTestContext& eglTestCtx, NativeColorMappingCase::NativeType nativeType) 442 { 443 switch (nativeType) 444 { 445 case NativeColorMappingCase::NATIVETYPE_WINDOW: 446 if ((eglTestCtx.getNativeWindowFactory().getCapabilities() & eglu::NativeWindow::CAPABILITY_READ_SCREEN_PIXELS) == 0) 447 throw tcu::NotSupportedError("Native window doesn't support readPixels()", "", __FILE__, __LINE__); 448 break; 449 450 case NativeColorMappingCase::NATIVETYPE_PIXMAP: 451 if ((eglTestCtx.getNativePixmapFactory().getCapabilities() & eglu::NativePixmap::CAPABILITY_READ_PIXELS) == 0) 452 throw tcu::NotSupportedError("Native pixmap doesn't support readPixels()", "", __FILE__, __LINE__); 453 break; 454 455 case NativeColorMappingCase::NATIVETYPE_PBUFFER_COPY_TO_PIXMAP: 456 if ((eglTestCtx.getNativePixmapFactory().getCapabilities() & eglu::NativePixmap::CAPABILITY_READ_PIXELS) == 0 || 457 (eglTestCtx.getNativePixmapFactory().getCapabilities() & eglu::NativePixmap::CAPABILITY_CREATE_SURFACE_LEGACY) == 0) 458 throw tcu::NotSupportedError("Native pixmap doesn't support readPixels() or legacy create surface", "", __FILE__, __LINE__); 459 break; 460 461 default: 462 DE_ASSERT(DE_FALSE); 463 } 464 } 465 466 void NativeColorMappingCase::executeForConfig (tcu::egl::Display& display, EGLConfig config) 467 { 468 const int width = 128; 469 const int height = 128; 470 471 const tcu::Vec4 colors[] = 472 { 473 tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f), 474 tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f), 475 tcu::Vec4(0.0f, 1.0f, 0.0f, 1.0f), 476 tcu::Vec4(0.0f, 1.0f, 1.0f, 1.0f), 477 tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f), 478 tcu::Vec4(1.0f, 0.0f, 1.0f, 1.0f), 479 tcu::Vec4(1.0f, 1.0f, 0.0f, 1.0f), 480 tcu::Vec4(1.0f, 1.0f, 1.0f, 1.0f), 481 482 tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f), 483 tcu::Vec4(0.0f, 0.0f, 0.5f, 1.0f), 484 tcu::Vec4(0.0f, 0.5f, 0.0f, 1.0f), 485 tcu::Vec4(0.0f, 0.5f, 0.5f, 1.0f), 486 tcu::Vec4(0.5f, 0.0f, 0.0f, 1.0f), 487 tcu::Vec4(0.5f, 0.0f, 0.5f, 1.0f), 488 tcu::Vec4(0.5f, 0.5f, 0.0f, 1.0f), 489 tcu::Vec4(0.5f, 0.5f, 0.5f, 1.0f) 490 }; 491 492 const string configIdStr (de::toString(eglu::getConfigAttribInt(display.getEGLDisplay(), config, EGL_CONFIG_ID))); 493 tcu::ScopedLogSection logSection (m_testCtx.getLog(), ("Config ID " + configIdStr).c_str(), ("Config ID " + configIdStr).c_str()); 494 const int waitFrames = 5; 495 496 logConfigInfo(m_testCtx.getLog(), display.getEGLDisplay(), config, m_nativeType, waitFrames); 497 498 checkSupport(m_eglTestCtx, m_nativeType); 499 500 eglu::UniqueContext context(display.getEGLDisplay(), createGLES2Context(display.getEGLDisplay(), config)); 501 glw::Functions gl; 502 503 m_eglTestCtx.getGLFunctions(gl, glu::ApiType::es(2,0)); 504 505 switch (m_nativeType) 506 { 507 case NATIVETYPE_WINDOW: 508 { 509 de::UniquePtr<eglu::NativeWindow> nativeWindow(m_eglTestCtx.createNativeWindow(display.getEGLDisplay(), config, DE_NULL, width, height, eglu::WindowParams::VISIBILITY_VISIBLE)); 510 511 if (!testNativeWindow(m_testCtx.getLog(), m_eglTestCtx.getNativeDisplay(), *nativeWindow, display.getEGLDisplay(), *context, config, gl, m_render, waitFrames, DE_LENGTH_OF_ARRAY(colors), colors)) 512 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid color rendered"); 513 break; 514 } 515 516 case NATIVETYPE_PIXMAP: 517 { 518 de::UniquePtr<eglu::NativePixmap> nativePixmap(m_eglTestCtx.createNativePixmap(display.getEGLDisplay(), config, DE_NULL, width, height)); 519 520 if (!testNativePixmap(m_testCtx.getLog(), m_eglTestCtx.getNativeDisplay(), *nativePixmap, display.getEGLDisplay(), *context, config, gl, m_render, DE_LENGTH_OF_ARRAY(colors), colors)) 521 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid color rendered"); 522 break; 523 } 524 525 case NATIVETYPE_PBUFFER_COPY_TO_PIXMAP: 526 { 527 de::UniquePtr<eglu::NativePixmap> nativePixmap(m_eglTestCtx.createNativePixmap(display.getEGLDisplay(), config, DE_NULL, width, height)); 528 529 if (!testNativePixmapCopy(m_testCtx.getLog(), *nativePixmap, display.getEGLDisplay(), *context, config, gl, m_render, DE_LENGTH_OF_ARRAY(colors), colors)) 530 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid color rendered"); 531 break; 532 } 533 534 default: 535 DE_ASSERT(DE_FALSE); 536 } 537 } 538 539 void addTestGroups (EglTestContext& eglTestCtx, TestCaseGroup* group, NativeColorMappingCase::NativeType type) 540 { 541 eglu::FilterList filters; 542 543 switch (type) 544 { 545 case NativeColorMappingCase::NATIVETYPE_WINDOW: 546 filters << (eglu::ConfigSurfaceType() & EGL_WINDOW_BIT); 547 break; 548 549 case NativeColorMappingCase::NATIVETYPE_PIXMAP: 550 filters << (eglu::ConfigSurfaceType() & EGL_PIXMAP_BIT); 551 break; 552 553 case NativeColorMappingCase::NATIVETYPE_PBUFFER_COPY_TO_PIXMAP: 554 filters << (eglu::ConfigSurfaceType() & EGL_PBUFFER_BIT); 555 break; 556 557 default: 558 DE_ASSERT(DE_FALSE); 559 } 560 561 vector<NamedConfigIdSet> configIdSets; 562 NamedConfigIdSet::getDefaultSets(configIdSets, eglTestCtx.getConfigs(), filters); 563 564 for (vector<NamedConfigIdSet>::iterator i = configIdSets.begin(); i != configIdSets.end(); i++) 565 { 566 group->addChild(new NativeColorMappingCase(eglTestCtx, (string(i->getName()) + "_clear").c_str(), i->getDescription(), false, type, i->getConfigIds())); 567 group->addChild(new NativeColorMappingCase(eglTestCtx, (string(i->getName()) + "_render").c_str(), i->getDescription(), true, type, i->getConfigIds())); 568 } 569 } 570 571 } // anonymous 572 573 NativeColorMappingTests::NativeColorMappingTests (EglTestContext& eglTestCtx) 574 : TestCaseGroup(eglTestCtx, "native_color_mapping", "Tests for mapping client colors to native surface") 575 { 576 } 577 578 void NativeColorMappingTests::init (void) 579 { 580 { 581 TestCaseGroup* windowGroup = new TestCaseGroup(m_eglTestCtx, "native_window", "Tests for mapping client color to native window"); 582 addTestGroups(m_eglTestCtx, windowGroup, NativeColorMappingCase::NATIVETYPE_WINDOW); 583 addChild(windowGroup); 584 } 585 586 { 587 TestCaseGroup* pixmapGroup = new TestCaseGroup(m_eglTestCtx, "native_pixmap", "Tests for mapping client color to native pixmap"); 588 addTestGroups(m_eglTestCtx, pixmapGroup, NativeColorMappingCase::NATIVETYPE_PIXMAP); 589 addChild(pixmapGroup); 590 } 591 592 { 593 TestCaseGroup* pbufferGroup = new TestCaseGroup(m_eglTestCtx, "pbuffer_to_native_pixmap", "Tests for mapping client color to native pixmap with eglCopyBuffers()"); 594 addTestGroups(m_eglTestCtx, pbufferGroup, NativeColorMappingCase::NATIVETYPE_PBUFFER_COPY_TO_PIXMAP); 595 addChild(pbufferGroup); 596 } 597 } 598 599 } // egl 600 } // deqp 601