1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program EGL Module
3 * ---------------------------------------
5 * Copyright 2017 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 Test KHR_wide_color
22 *//*--------------------------------------------------------------------*/
24 #include "teglWideColorTests.hpp"
26 #include "tcuImageCompare.hpp"
27 #include "tcuTestLog.hpp"
28 #include "tcuSurface.hpp"
29 #include "tcuTextureUtil.hpp"
31 #include "egluNativeWindow.hpp"
32 #include "egluStrUtil.hpp"
33 #include "egluUtil.hpp"
34 #include "egluConfigFilter.hpp"
36 #include "eglwLibrary.hpp"
37 #include "eglwEnums.hpp"
39 #include "gluDefs.hpp"
40 #include "gluRenderContext.hpp"
41 #include "gluShaderProgram.hpp"
43 #include "glwDefs.hpp"
44 #include "glwEnums.hpp"
45 #include "glwFunctions.hpp"
48 #include "deRandom.hpp"
50 #include "deStringUtil.hpp"
71 typedef tcu::Vec4 Color;
75 class ReferenceRenderer;
77 class WideColorTests : public TestCaseGroup
80 WideColorTests (EglTestContext& eglTestCtx);
84 WideColorTests (const WideColorTests&);
85 WideColorTests& operator= (const WideColorTests&);
88 class WideColorTest : public TestCase
97 WideColorTest (EglTestContext& eglTestCtx, const char* name, const char* description);
98 ~WideColorTest (void);
102 void checkPixelFloatSupport (void);
103 void checkColorSpaceSupport (void);
104 void checkDisplayP3Support (void);
105 void check1010102Support (void);
106 void checkFP16Support (void);
107 void checkSCRGBSupport (void);
108 void checkSCRGBLinearSupport (void);
109 void checkbt2020linear (void);
110 void checkbt2020pq (void);
111 void checkSMPTE2086 (void);
112 void checkCTA861_3 (void);
115 void initEGLSurface (EGLConfig config);
116 void initEGLContext (EGLConfig config);
118 EGLDisplay m_eglDisplay;
125 ColoredRect (const IVec2& bottomLeft_, const IVec2& topRight_, const Color& color_);
131 ColoredRect::ColoredRect (const IVec2& bottomLeft_, const IVec2& topRight_, const Color& color_)
132 : bottomLeft (bottomLeft_)
133 , topRight (topRight_)
138 void clearColorScreen (const glw::Functions& gl, const Color& clearColor)
140 gl.clearColor(clearColor.x(), clearColor.y(), clearColor.z(), clearColor.w());
141 gl.clear(GL_COLOR_BUFFER_BIT);
144 float windowToDeviceCoordinates (int x, int length)
146 return (2.0f * float(x) / float(length)) - 1.0f;
152 GLES2Renderer (const glw::Functions& gl, int width, int height);
153 ~GLES2Renderer (void);
154 void render (const ColoredRect& coloredRect) const;
157 GLES2Renderer (const GLES2Renderer&);
158 GLES2Renderer& operator= (const GLES2Renderer&);
160 const glw::Functions& m_gl;
161 glu::ShaderProgram m_glProgram;
162 glw::GLuint m_coordLoc;
163 glw::GLuint m_colorLoc;
164 glw::GLuint m_bufWidth;
165 glw::GLuint m_bufHeight;
168 // generate sources for vertex and fragment buffer
169 glu::ProgramSources getSources (void)
171 const char* const vertexShaderSource =
172 "attribute mediump vec2 a_pos;\n"
173 "attribute mediump vec4 a_color;\n"
174 "varying mediump vec4 v_color;\n"
177 "\tv_color = a_color;\n"
178 "\tgl_Position = vec4(a_pos, 0.0, 1.0);\n"
181 const char* const fragmentShaderSource =
182 "varying mediump vec4 v_color;\n"
185 "\tgl_FragColor = v_color;\n"
188 return glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource);
191 GLES2Renderer::GLES2Renderer (const glw::Functions& gl, int width, int height)
193 , m_glProgram (gl, getSources())
194 , m_coordLoc ((glw::GLuint)-1)
195 , m_colorLoc ((glw::GLuint)-1)
197 , m_bufHeight (height)
199 m_colorLoc = m_gl.getAttribLocation(m_glProgram.getProgram(), "a_color");
200 m_coordLoc = m_gl.getAttribLocation(m_glProgram.getProgram(), "a_pos");
201 GLU_EXPECT_NO_ERROR(m_gl.getError(), "Failed to get attribute locations");
204 GLES2Renderer::~GLES2Renderer (void)
208 void GLES2Renderer::render (const struct ColoredRect &coloredRect) const
210 const float x1 = windowToDeviceCoordinates(coloredRect.bottomLeft.x(), m_bufWidth);
211 const float y1 = windowToDeviceCoordinates(coloredRect.bottomLeft.y(), m_bufHeight);
212 const float x2 = windowToDeviceCoordinates(coloredRect.topRight.x(), m_bufWidth);
213 const float y2 = windowToDeviceCoordinates(coloredRect.topRight.y(), m_bufHeight);
215 const glw::GLfloat coords[] =
226 const glw::GLfloat colors[] =
228 coloredRect.color.x(), coloredRect.color.y(), coloredRect.color.z(), coloredRect.color.w(),
229 coloredRect.color.x(), coloredRect.color.y(), coloredRect.color.z(), coloredRect.color.w(),
230 coloredRect.color.x(), coloredRect.color.y(), coloredRect.color.z(), coloredRect.color.w(),
232 coloredRect.color.x(), coloredRect.color.y(), coloredRect.color.z(), coloredRect.color.w(),
233 coloredRect.color.x(), coloredRect.color.y(), coloredRect.color.z(), coloredRect.color.w(),
234 coloredRect.color.x(), coloredRect.color.y(), coloredRect.color.z(), coloredRect.color.w(),
237 m_gl.useProgram(m_glProgram.getProgram());
238 GLU_EXPECT_NO_ERROR(m_gl.getError(), "glUseProgram() failed");
240 m_gl.enableVertexAttribArray(m_coordLoc);
241 m_gl.enableVertexAttribArray(m_colorLoc);
242 GLU_EXPECT_NO_ERROR(m_gl.getError(), "Failed to enable attributes");
244 m_gl.vertexAttribPointer(m_coordLoc, 4, GL_FLOAT, GL_FALSE, 0, coords);
245 m_gl.vertexAttribPointer(m_colorLoc, 4, GL_FLOAT, GL_TRUE, 0, colors);
246 GLU_EXPECT_NO_ERROR(m_gl.getError(), "Failed to set attribute pointers");
248 m_gl.drawArrays(GL_TRIANGLES, 0, DE_LENGTH_OF_ARRAY(coords)/4);
249 GLU_EXPECT_NO_ERROR(m_gl.getError(), "glDrawArrays(), failed");
251 m_gl.disableVertexAttribArray(m_coordLoc);
252 m_gl.disableVertexAttribArray(m_colorLoc);
253 GLU_EXPECT_NO_ERROR(m_gl.getError(), "Failed to disable attributes");
256 GLU_EXPECT_NO_ERROR(m_gl.getError(), "glUseProgram() failed");
259 class ReferenceRenderer
262 ReferenceRenderer (void);
264 ReferenceRenderer (const ReferenceRenderer&);
265 ReferenceRenderer& operator= (const ReferenceRenderer&);
268 WideColorTest::WideColorTest (EglTestContext& eglTestCtx, const char* name, const char* description)
269 : TestCase (eglTestCtx, name, description)
270 , m_eglDisplay (EGL_NO_DISPLAY)
274 WideColorTest::~WideColorTest (void)
279 void WideColorTest::init (void)
281 m_eglDisplay = eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
283 m_eglTestCtx.initGLFunctions(&m_gl, glu::ApiType::es(2,0));
286 void WideColorTest::checkPixelFloatSupport (void)
288 const Library& egl = m_eglTestCtx.getLibrary();
290 if (!eglu::hasExtension(egl, m_eglDisplay, "EGL_EXT_pixel_format_float"))
291 TCU_THROW(NotSupportedError, "EGL_EXT_pixel_format_float is not supported");
294 void WideColorTest::checkColorSpaceSupport (void)
296 const Library& egl = m_eglTestCtx.getLibrary();
298 if (!eglu::hasExtension(egl, m_eglDisplay, "EGL_KHR_gl_colorspace"))
299 TCU_THROW(NotSupportedError, "EGL_KHR_gl_colorspace is not supported");
302 void WideColorTest::checkDisplayP3Support (void)
304 const Library& egl = m_eglTestCtx.getLibrary();
306 if (!eglu::hasExtension(egl, m_eglDisplay, "EGL_EXT_gl_colorspace_display_p3"))
307 TCU_THROW(NotSupportedError, "EGL_EXT_gl_colorspace_display_p3 is not supported");
310 void WideColorTest::checkSCRGBSupport (void)
312 const Library& egl = m_eglTestCtx.getLibrary();
314 if (!eglu::hasExtension(egl, m_eglDisplay, "EGL_EXT_gl_colorspace_scrgb"))
315 TCU_THROW(NotSupportedError, "EGL_EXT_gl_colorspace_scrgb is not supported");
318 void WideColorTest::checkSCRGBLinearSupport (void)
320 const Library& egl = m_eglTestCtx.getLibrary();
322 if (!eglu::hasExtension(egl, m_eglDisplay, "EGL_EXT_gl_colorspace_scrgb_linear"))
323 TCU_THROW(NotSupportedError, "EGL_EXT_gl_colorspace_scrgb_linear is not supported");
326 void WideColorTest::checkbt2020linear (void)
328 const Library& egl = m_eglTestCtx.getLibrary();
330 if (!eglu::hasExtension(egl, m_eglDisplay, "EGL_EXT_gl_colorspace_bt2020_linear"))
331 TCU_THROW(NotSupportedError, "EGL_EXT_gl_colorspace_bt2020_linear is not supported");
334 void WideColorTest::checkbt2020pq (void)
336 const Library& egl = m_eglTestCtx.getLibrary();
338 if (!eglu::hasExtension(egl, m_eglDisplay, "EGL_EXT_gl_colorspace_bt2020_pq"))
339 TCU_THROW(NotSupportedError, "EGL_EXT_gl_colorspace_bt2020_pq is not supported");
342 void WideColorTest::checkSMPTE2086 (void)
344 const Library& egl = m_eglTestCtx.getLibrary();
346 if (!eglu::hasExtension(egl, m_eglDisplay, "EGL_EXT_surface_SMPTE2086_metadata"))
347 TCU_THROW(NotSupportedError, "EGL_EXT_surface_SMPTE2086_metadata is not supported");
350 void WideColorTest::checkCTA861_3 (void)
352 const Library& egl = m_eglTestCtx.getLibrary();
354 if (!eglu::hasExtension(egl, m_eglDisplay, "EGL_EXT_surface_CTA861_3_metadata"))
355 TCU_THROW(NotSupportedError, "EGL_EXT_surface_CTA861_3_metadata is not supported");
358 void WideColorTest::check1010102Support (void)
360 const Library& egl = m_eglTestCtx.getLibrary();
361 tcu::TestLog& log = m_testCtx.getLog();
363 const EGLint attribList[] =
365 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
366 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
373 EGLint numConfigs = 0;
376 // Query from EGL implementation
377 EGLU_CHECK_CALL(egl, chooseConfig(m_eglDisplay, &attribList[0], DE_NULL, 0, &numConfigs));
381 log << tcu::TestLog::Message << "No configs returned." << tcu::TestLog::EndMessage;
382 TCU_THROW(NotSupportedError, "10:10:10:2 pixel format is not supported");
385 log << tcu::TestLog::Message << numConfigs << " configs returned" << tcu::TestLog::EndMessage;
387 EGLU_CHECK_CALL(egl, chooseConfig(m_eglDisplay, &attribList[0], &config, 1, &numConfigs));
390 log << tcu::TestLog::Message << "Fail, more configs returned than requested." << tcu::TestLog::EndMessage;
391 TCU_FAIL("Too many configs returned");
394 EGLint components[4];
396 EGLU_CHECK_CALL(egl, getConfigAttrib(m_eglDisplay, config, EGL_RED_SIZE, &components[0]));
397 EGLU_CHECK_CALL(egl, getConfigAttrib(m_eglDisplay, config, EGL_GREEN_SIZE, &components[1]));
398 EGLU_CHECK_CALL(egl, getConfigAttrib(m_eglDisplay, config, EGL_BLUE_SIZE, &components[2]));
399 EGLU_CHECK_CALL(egl, getConfigAttrib(m_eglDisplay, config, EGL_ALPHA_SIZE, &components[3]));
401 TCU_CHECK_MSG(components[0] == 10, "Missing 10bit deep red channel");
402 TCU_CHECK_MSG(components[1] == 10, "Missing 10bit deep green channel");
403 TCU_CHECK_MSG(components[2] == 10, "Missing 10bit deep blue channel");
404 TCU_CHECK_MSG(components[3] == 2, "Missing 2bit deep alpha channel");
407 void WideColorTest::checkFP16Support (void)
409 const Library& egl = m_eglTestCtx.getLibrary();
410 tcu::TestLog& log = m_testCtx.getLog();
411 EGLint numConfigs = 0;
414 const EGLint attribList[] =
416 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
417 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
422 EGL_COLOR_COMPONENT_TYPE_EXT, EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT,
426 // Query from EGL implementation
427 EGLU_CHECK_CALL(egl, chooseConfig(m_eglDisplay, &attribList[0], DE_NULL, 0, &numConfigs));
431 log << tcu::TestLog::Message << "No configs returned." << tcu::TestLog::EndMessage;
432 TCU_THROW(NotSupportedError, "16:16:16:16 pixel format is not supported");
435 log << tcu::TestLog::Message << numConfigs << " configs returned" << tcu::TestLog::EndMessage;
437 EGLBoolean success = egl.chooseConfig(m_eglDisplay, &attribList[0], &config, 1, &numConfigs);
438 if (success != EGL_TRUE)
440 log << tcu::TestLog::Message << "Fail, eglChooseConfig returned an error." << tcu::TestLog::EndMessage;
441 TCU_FAIL("eglChooseConfig failed");
445 log << tcu::TestLog::Message << "Fail, more configs returned than requested." << tcu::TestLog::EndMessage;
446 TCU_FAIL("Too many configs returned");
449 EGLint components[4];
451 success = egl.getConfigAttrib(m_eglDisplay, config, EGL_RED_SIZE, &components[0]);
452 TCU_CHECK_MSG(success == EGL_TRUE, "eglGetConfigAttrib failed");
454 success = egl.getConfigAttrib(m_eglDisplay, config, EGL_GREEN_SIZE, &components[1]);
455 TCU_CHECK_MSG(success == EGL_TRUE, "eglGetConfigAttrib failed");
457 success = egl.getConfigAttrib(m_eglDisplay, config, EGL_BLUE_SIZE, &components[2]);
458 TCU_CHECK_MSG(success == EGL_TRUE, "eglGetConfigAttrib failed");
460 success = egl.getConfigAttrib(m_eglDisplay, config, EGL_ALPHA_SIZE, &components[3]);
461 TCU_CHECK_MSG(success == EGL_TRUE, "eglGetConfigAttrib failed");
464 TCU_CHECK_MSG(components[0] == 16, "Missing 16bit deep red channel");
465 TCU_CHECK_MSG(components[1] == 16, "Missing 16bit deep green channel");
466 TCU_CHECK_MSG(components[2] == 16, "Missing 16bit deep blue channel");
467 TCU_CHECK_MSG(components[3] == 16, "Missing 16bit deep alpha channel");
470 void WideColorTest::deinit (void)
472 const Library& egl = m_eglTestCtx.getLibrary();
474 if (m_eglDisplay != EGL_NO_DISPLAY)
476 egl.terminate(m_eglDisplay);
477 m_eglDisplay = EGL_NO_DISPLAY;
481 class WideColorFP16Test : public WideColorTest
484 WideColorFP16Test (EglTestContext& eglTestCtx, const char* name, const char* description);
487 void executeTest (void);
488 IterateResult iterate (void);
491 WideColorFP16Test::WideColorFP16Test (EglTestContext& eglTestCtx,
493 const char* description)
494 : WideColorTest(eglTestCtx, name, description)
499 void WideColorFP16Test::executeTest (void)
501 checkPixelFloatSupport();
505 TestCase::IterateResult WideColorFP16Test::iterate (void)
507 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
512 void WideColorFP16Test::init (void)
514 WideColorTest::init();
517 class WideColor1010102Test : public WideColorTest
520 WideColor1010102Test (EglTestContext& eglTestCtx,
522 const char* description);
524 void executeTest (void);
525 IterateResult iterate (void);
528 WideColor1010102Test::WideColor1010102Test (EglTestContext& eglTestCtx, const char* name, const char* description)
529 : WideColorTest(eglTestCtx, name, description)
533 void WideColor1010102Test::executeTest (void)
535 check1010102Support();
538 TestCase::IterateResult WideColor1010102Test::iterate (void)
540 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
550 Iteration(float s, float i, int c)
551 : start(s), increment(i), iterationCount(c) {}
554 class WideColorSurfaceTest : public WideColorTest
557 WideColorSurfaceTest (EglTestContext& eglTestCtx,
559 const char* description,
560 const EGLint* attribList,
562 const std::vector<Iteration>& iterations);
565 void executeTest (void);
566 IterateResult iterate (void);
567 void addWindowAttributes (const EGLint* attributes);
568 void addTestAttributes (const EGLint* attributes);
571 void readPixels (const glw::Functions& gl, float* dataPtr);
572 void readPixels (const glw::Functions& gl, deUint32* dataPtr);
573 void readPixels (const glw::Functions& gl, deUint8* dataPtr);
574 deUint32 expectedUint10 (float reference);
575 deUint32 expectedUint2 (float reference);
576 deUint8 expectedUint8 (float reference);
577 deUint8 expectedAlpha8 (float reference);
578 bool checkWithThreshold8 (deUint8 value, deUint8 reference, deUint8 threshold = 1);
579 bool checkWithThreshold10 (deUint32 value, deUint32 reference, deUint32 threshold = 1);
580 bool checkWithThresholdFloat (float value, float reference, float threshold);
581 void doClearTest (EGLSurface surface);
582 void testPixels (float reference, float increment);
583 void writeEglConfig (EGLConfig config);
586 std::vector<EGLint> m_attribList;
587 std::vector<EGLint> m_winAttribList;
588 std::vector<EGLint> m_testAttribList;
589 EGLConfig m_eglConfig;
590 EGLint m_surfaceType;
591 EGLint m_componentType;
594 const std::vector<struct Iteration> m_iterations;
595 std::stringstream m_debugLog;
598 WideColorSurfaceTest::WideColorSurfaceTest (EglTestContext& eglTestCtx, const char* name, const char* description, const EGLint* attribList, EGLint colorSpace, const std::vector<struct Iteration>& iterations)
599 : WideColorTest (eglTestCtx, name, description)
600 , m_colorSpace (colorSpace)
601 , m_iterations (iterations)
604 while (attribList[idx] != EGL_NONE)
606 if (attribList[idx] == EGL_COLOR_COMPONENT_TYPE_EXT)
608 m_componentType = attribList[idx + 1];
610 else if (attribList[idx] == EGL_SURFACE_TYPE)
612 m_surfaceType = attribList[idx+1];
614 else if (attribList[idx] == EGL_RED_SIZE)
616 m_redSize = attribList[idx + 1];
618 m_attribList.push_back(attribList[idx++]);
619 m_attribList.push_back(attribList[idx++]);
621 m_attribList.push_back(EGL_NONE);
624 void WideColorSurfaceTest::addWindowAttributes(const EGLint* attributes)
627 if (attributes == DE_NULL) return;
629 while (attributes[idx] != EGL_NONE)
631 m_winAttribList.push_back(attributes[idx++]);
632 m_winAttribList.push_back(attributes[idx++]);
636 void WideColorSurfaceTest::addTestAttributes(const EGLint *attributes)
639 if (attributes == DE_NULL) return;
641 while (attributes[idx] != EGL_NONE)
643 m_testAttribList.push_back(attributes[idx++]);
644 m_testAttribList.push_back(attributes[idx++]);
648 void WideColorSurfaceTest::init (void)
650 const Library& egl = m_eglTestCtx.getLibrary();
651 tcu::TestLog& log = m_testCtx.getLog();
653 WideColorTest::init();
655 // Only check for pixel format required for this specific run
656 // If not available, check will abort test with "NotSupported"
660 check1010102Support();
663 checkPixelFloatSupport();
668 if (m_colorSpace != EGL_NONE && !eglu::hasExtension(egl, m_eglDisplay, "EGL_KHR_gl_colorspace"))
669 TCU_THROW(NotSupportedError, "EGL_KHR_gl_colorspace is not supported");
671 switch (m_colorSpace) {
672 case EGL_GL_COLORSPACE_SRGB_KHR:
673 checkColorSpaceSupport();
675 case EGL_GL_COLORSPACE_DISPLAY_P3_EXT:
676 checkDisplayP3Support();
678 case EGL_GL_COLORSPACE_SCRGB_EXT:
681 case EGL_GL_COLORSPACE_SCRGB_LINEAR_EXT:
682 checkSCRGBLinearSupport();
684 case EGL_GL_COLORSPACE_BT2020_LINEAR_EXT:
687 case EGL_GL_COLORSPACE_BT2020_PQ_EXT:
694 EGLint numConfigs = 0;
696 // Query from EGL implementation
697 EGLU_CHECK_CALL(egl, chooseConfig(m_eglDisplay, &m_attribList[0], DE_NULL, 0, &numConfigs));
701 log << tcu::TestLog::Message << "No configs returned." << tcu::TestLog::EndMessage;
702 TCU_FAIL("No configs returned");
705 log << tcu::TestLog::Message << numConfigs << " configs returned" << tcu::TestLog::EndMessage;
707 EGLBoolean success = egl.chooseConfig(m_eglDisplay, &m_attribList[0], &m_eglConfig, 1, &numConfigs);
708 if (success != EGL_TRUE)
710 log << tcu::TestLog::Message << "Fail, eglChooseConfig returned an error." << tcu::TestLog::EndMessage;
711 TCU_FAIL("eglChooseConfig failed");
715 log << tcu::TestLog::Message << "Fail, more configs returned than requested." << tcu::TestLog::EndMessage;
716 TCU_FAIL("Too many configs returned");
719 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
721 writeEglConfig(m_eglConfig);
725 void WideColorSurfaceTest::readPixels (const glw::Functions& gl, float* dataPtr)
727 gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_FLOAT, dataPtr);
728 GLU_EXPECT_NO_ERROR(m_gl.getError(), "glReadPixels with floats");
731 void WideColorSurfaceTest::readPixels (const glw::Functions& gl, deUint32 *dataPtr)
733 gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, dataPtr);
734 GLU_EXPECT_NO_ERROR(m_gl.getError(), "glReadPixels with RGBA_1010102 (32bits)");
737 void WideColorSurfaceTest::readPixels (const glw::Functions& gl, deUint8 *dataPtr)
739 gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, dataPtr);
740 GLU_EXPECT_NO_ERROR(m_gl.getError(), "glReadPixels with RGBA_8888 (8 bit components)");
743 void WideColorSurfaceTest::writeEglConfig (EGLConfig config)
745 const Library& egl = m_eglTestCtx.getLibrary();
746 tcu::TestLog& log = m_testCtx.getLog();
747 qpEglConfigInfo info;
750 info.bufferSize = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_BUFFER_SIZE);
752 info.redSize = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_RED_SIZE);
754 info.greenSize = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_GREEN_SIZE);
756 info.blueSize = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_BLUE_SIZE);
758 info.luminanceSize = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_LUMINANCE_SIZE);
760 info.alphaSize = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_ALPHA_SIZE);
762 info.alphaMaskSize = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_ALPHA_MASK_SIZE);
764 val = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_BIND_TO_TEXTURE_RGB);
765 info.bindToTextureRGB = val == EGL_TRUE ? true : false;
767 val = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_BIND_TO_TEXTURE_RGBA);
768 info.bindToTextureRGBA = val == EGL_TRUE ? true : false;
770 val = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_COLOR_BUFFER_TYPE);
771 std::string colorBufferType = de::toString(eglu::getColorBufferTypeStr(val));
772 info.colorBufferType = colorBufferType.c_str();
774 val = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_CONFIG_CAVEAT);
775 std::string caveat = de::toString(eglu::getConfigCaveatStr(val));
776 info.configCaveat = caveat.c_str();
778 info.configID = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_CONFIG_ID);
780 val = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_CONFORMANT);
781 std::string conformant = de::toString(eglu::getAPIBitsStr(val));
782 info.conformant = conformant.c_str();
784 info.depthSize = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_DEPTH_SIZE);
786 info.level = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_LEVEL);
788 info.maxPBufferWidth = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_MAX_PBUFFER_WIDTH);
790 info.maxPBufferHeight = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_MAX_PBUFFER_HEIGHT);
792 info.maxPBufferPixels = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_MAX_PBUFFER_PIXELS);
794 info.maxSwapInterval = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_MAX_SWAP_INTERVAL);
796 info.minSwapInterval = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_MIN_SWAP_INTERVAL);
798 val = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_NATIVE_RENDERABLE);
799 info.nativeRenderable = val == EGL_TRUE ? true : false;
801 val = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_RENDERABLE_TYPE);
802 std::string renderableTypes = de::toString(eglu::getAPIBitsStr(val));
803 info.renderableType = renderableTypes.c_str();
805 info.sampleBuffers = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_SAMPLE_BUFFERS);
807 info.samples = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_SAMPLES);
809 info.stencilSize = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_STENCIL_SIZE);
811 val = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_SURFACE_TYPE);
812 std::string surfaceTypes = de::toString(eglu::getSurfaceBitsStr(val));
813 info.surfaceTypes = surfaceTypes.c_str();
815 val = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_TRANSPARENT_TYPE);
816 std::string transparentType = de::toString(eglu::getTransparentTypeStr(val));
817 info.transparentType = transparentType.c_str();
819 info.transparentRedValue = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_TRANSPARENT_RED_VALUE);
821 info.transparentGreenValue = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_TRANSPARENT_GREEN_VALUE);
823 info.transparentBlueValue = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_TRANSPARENT_BLUE_VALUE);
825 log.writeEglConfig(&info);
828 deUint32 WideColorSurfaceTest::expectedUint10 (float reference)
836 else if (reference > 1.0)
842 expected = static_cast<deUint32>(deRound(reference * 1023.0));
848 deUint32 WideColorSurfaceTest::expectedUint2 (float reference)
856 else if (reference > 1.0)
862 expected = static_cast<deUint32>(deRound(reference * 3.0));
868 deUint8 WideColorSurfaceTest::expectedUint8 (float reference)
875 else if (reference >= 1.0)
881 // Apply sRGB transfer function when colorspace is sRGB and pixel component
882 // size is 8 bits (which is why we are here in expectedUint8).
883 if (m_colorSpace == EGL_GL_COLORSPACE_SRGB_KHR)
887 if (reference <= 0.0031308)
889 srgbReference = 12.92f * reference;
893 float powRef = deFloatPow(reference, (1.0f/2.4f));
894 srgbReference = (1.055f * powRef) - 0.055f;
896 expected = static_cast<deUint8>(deRound(srgbReference * 255.0));
900 expected = static_cast<deUint8>(deRound(reference * 255.0));
906 deUint8 WideColorSurfaceTest::expectedAlpha8 (float reference)
913 else if (reference >= 1.0)
919 // The sRGB transfer function is not applied to alpha
920 expected = static_cast<deUint8>(deRound(reference * 255.0));
925 // Return true for value out of range (fail)
926 bool WideColorSurfaceTest::checkWithThreshold8(deUint8 value, deUint8 reference, deUint8 threshold)
928 const deUint8 low = reference >= threshold ? static_cast<deUint8>(reference - threshold) : 0;
929 const deUint8 high = reference <= (255 - threshold) ? static_cast<deUint8>(reference + threshold) : 255;
930 return !((value >= low) && (value <= high));
933 bool WideColorSurfaceTest::checkWithThreshold10(deUint32 value, deUint32 reference, deUint32 threshold)
935 const deUint32 low = reference >= threshold ? reference - threshold : 0;
936 const deUint32 high = reference <= (1023 - threshold) ? reference + threshold : 1023;
937 return !((value >= low) && (value <= high));
940 bool WideColorSurfaceTest::checkWithThresholdFloat(float value, float reference, float threshold)
942 const float low = reference - threshold;
943 const float high = reference + threshold;
944 return !((value >= low) && (value <= high));
947 void WideColorSurfaceTest::testPixels (float reference, float increment)
949 tcu::TestLog& log = m_testCtx.getLog();
951 if (m_componentType == EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT)
954 const float expected[4] =
957 reference + increment,
958 reference - increment,
959 reference + 2 * increment
961 readPixels(m_gl, pixels);
963 if (checkWithThresholdFloat(pixels[0], expected[0], increment) ||
964 checkWithThresholdFloat(pixels[1], expected[1], increment) ||
965 checkWithThresholdFloat(pixels[2], expected[2], increment) ||
966 checkWithThresholdFloat(pixels[3], expected[3], increment))
968 if (m_debugLog.str().size() > 0)
970 log << tcu::TestLog::Message
971 << "Prior passing tests\n"
973 << tcu::TestLog::EndMessage;
976 log << tcu::TestLog::Message
977 << "Image comparison failed: "
978 << "reference = " << reference
979 << ", expected = " << expected[0]
980 << ":" << expected[1]
981 << ":" << expected[2]
982 << ":" << expected[3]
983 << ", result = " << pixels[0]
987 << tcu::TestLog::EndMessage;
988 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Color test failed");
992 // Pixel matches expected value
993 m_debugLog << "Image comparison passed: "
994 << "reference = " << reference
995 << ", result = " << pixels[0]
1002 else if (m_redSize > 8)
1004 deUint32 buffer[16];
1005 readPixels(m_gl, buffer);
1007 deUint32 expected[4];
1009 pixels[0] = buffer[0] & 0x3ff;
1010 pixels[1] = (buffer[0] >> 10) & 0x3ff;
1011 pixels[2] = (buffer[0] >> 20) & 0x3ff;
1012 pixels[3] = (buffer[0] >> 30) & 0x3;
1014 expected[0] = expectedUint10(reference);
1015 expected[1] = expectedUint10(reference + increment);
1016 expected[2] = expectedUint10(reference - increment);
1017 expected[3] = expectedUint2(reference + 2 * increment);
1018 if (checkWithThreshold10(pixels[0], expected[0]) || checkWithThreshold10(pixels[1], expected[1])
1019 || checkWithThreshold10(pixels[2], expected[2]) || checkWithThreshold10(pixels[3], expected[3]))
1021 if (m_debugLog.str().size() > 0) {
1022 log << tcu::TestLog::Message
1023 << "Prior passing tests\n"
1025 << tcu::TestLog::EndMessage;
1028 log << tcu::TestLog::Message
1029 << "Image comparison failed: "
1030 << "reference = " << reference
1031 << ", expected = " << static_cast<deUint32>(expected[0])
1032 << ":" << static_cast<deUint32>(expected[1])
1033 << ":" << static_cast<deUint32>(expected[2])
1034 << ":" << static_cast<deUint32>(expected[3])
1035 << ", result = " << static_cast<deUint32>(pixels[0])
1036 << ":" << static_cast<deUint32>(pixels[1])
1037 << ":" << static_cast<deUint32>(pixels[2])
1038 << ":" << static_cast<deUint32>(pixels[3])
1039 << tcu::TestLog::EndMessage;
1040 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Color test failed");
1044 // Pixel matches expected value
1045 m_debugLog << "Image comparison passed: "
1046 << "reference = " << reference
1047 << ", result = " << static_cast<deUint32>(pixels[0])
1048 << ":" << static_cast<deUint32>(pixels[1])
1049 << ":" << static_cast<deUint32>(pixels[2])
1050 << ":" << static_cast<deUint32>(pixels[3])
1057 deUint8 expected[4];
1058 readPixels(m_gl, pixels);
1060 expected[0] = expectedUint8(reference);
1061 expected[1] = expectedUint8(reference + increment);
1062 expected[2] = expectedUint8(reference - increment);
1063 expected[3] = expectedAlpha8(reference + 2 * increment);
1064 if (checkWithThreshold8(pixels[0], expected[0]) || checkWithThreshold8(pixels[1], expected[1])
1065 || checkWithThreshold8(pixels[2], expected[2]) || checkWithThreshold8(pixels[3], expected[3]))
1067 if (m_debugLog.str().size() > 0) {
1068 log << tcu::TestLog::Message
1069 << "(C)Prior passing tests\n"
1071 << tcu::TestLog::EndMessage;
1074 log << tcu::TestLog::Message
1075 << "Image comparison failed: "
1076 << "reference = " << reference
1077 << ", expected = " << static_cast<deUint32>(expected[0])
1078 << ":" << static_cast<deUint32>(expected[1])
1079 << ":" << static_cast<deUint32>(expected[2])
1080 << ":" << static_cast<deUint32>(expected[3])
1081 << ", result = " << static_cast<deUint32>(pixels[0])
1082 << ":" << static_cast<deUint32>(pixels[1])
1083 << ":" << static_cast<deUint32>(pixels[2])
1084 << ":" << static_cast<deUint32>(pixels[3])
1085 << tcu::TestLog::EndMessage;
1086 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Color test failed");
1090 // Pixel matches expected value
1091 m_debugLog << "Image comparison passed: "
1092 << "reference = " << reference
1093 << ", result = " << static_cast<deUint32>(pixels[0])
1094 << ":" << static_cast<deUint32>(pixels[1])
1095 << ":" << static_cast<deUint32>(pixels[2])
1096 << ":" << static_cast<deUint32>(pixels[3])
1102 void WideColorSurfaceTest::doClearTest (EGLSurface surface)
1104 tcu::TestLog& log = m_testCtx.getLog();
1105 const Library& egl = m_eglTestCtx.getLibrary();
1106 const EGLint attribList[] =
1108 EGL_CONTEXT_CLIENT_VERSION, 2,
1111 EGLContext eglContext = egl.createContext(m_eglDisplay, m_eglConfig, EGL_NO_CONTEXT, attribList);
1112 EGLU_CHECK_MSG(egl, "eglCreateContext");
1114 egl.makeCurrent(m_eglDisplay, surface, surface, eglContext);
1115 EGLU_CHECK_MSG(egl, "eglMakeCurrent");
1118 // put gles2Renderer inside it's own scope so that it's cleaned
1119 // up before we hit the destroyContext
1120 const GLES2Renderer gles2Renderer(m_gl, 128, 128);
1122 std::vector<Iteration>::const_iterator it; // declare an Iterator to a vector of strings
1123 log << tcu::TestLog::Message << "m_iterations.count = " << m_iterations.size() << tcu::TestLog::EndMessage;
1124 for(it = m_iterations.begin() ; it < m_iterations.end(); it++)
1126 float reference = it->start;
1127 log << tcu::TestLog::Message << "start = " << it->start
1128 << tcu::TestLog::EndMessage;
1129 log << tcu::TestLog::Message
1130 << "increment = " << it->increment
1131 << tcu::TestLog::EndMessage;
1132 log << tcu::TestLog::Message
1133 << "count = " << it->iterationCount
1134 << tcu::TestLog::EndMessage;
1136 for (int iterationCount = 0; iterationCount < it->iterationCount; iterationCount++)
1138 const Color clearColor(reference, reference + it->increment, reference - it->increment, reference + 2 * it->increment);
1140 clearColorScreen(m_gl, clearColor);
1141 GLU_EXPECT_NO_ERROR(m_gl.getError(), "Clear to test value");
1143 testPixels(reference, it->increment);
1145 // reset buffer contents so that we know render below did something
1146 const Color clearColor2(1.0f - reference, 1.0f, 1.0f, 1.0f);
1147 clearColorScreen(m_gl, clearColor2);
1148 GLU_EXPECT_NO_ERROR(m_gl.getError(), "Clear to 1.0f - reference value");
1150 const ColoredRect coloredRect (IVec2(0.0f, 0.0f), IVec2(1.0f, 1.0f), clearColor);
1151 gles2Renderer.render(coloredRect);
1152 testPixels(reference, it->increment);
1154 reference += it->increment;
1157 EGLU_CHECK_CALL(egl, swapBuffers(m_eglDisplay, surface));
1161 // disconnect surface & context so they can be destroyed when
1162 // this function exits.
1163 EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
1165 egl.destroyContext(m_eglDisplay, eglContext);
1168 void WideColorSurfaceTest::executeTest (void)
1170 tcu::TestLog& log = m_testCtx.getLog();
1171 const Library& egl = m_eglTestCtx.getLibrary();
1172 const eglu::NativeDisplayFactory& displayFactory = m_eglTestCtx.getNativeDisplayFactory();
1173 eglu::NativeDisplay& nativeDisplay = m_eglTestCtx.getNativeDisplay();
1174 egl.bindAPI(EGL_OPENGL_ES_API);
1176 if (m_surfaceType & EGL_PBUFFER_BIT)
1178 log << tcu::TestLog::Message << "Test Pbuffer" << tcu::TestLog::EndMessage;
1180 std::vector<EGLint> attribs;
1181 attribs.push_back(EGL_WIDTH);
1182 attribs.push_back(128);
1183 attribs.push_back(EGL_HEIGHT);
1184 attribs.push_back(128);
1185 if (m_colorSpace != EGL_NONE)
1187 attribs.push_back(EGL_GL_COLORSPACE_KHR);
1188 attribs.push_back(m_colorSpace);
1190 for (deUint32 i = 0; i < m_winAttribList.size(); i++)
1192 attribs.push_back(m_winAttribList[i]);
1194 attribs.push_back(EGL_NONE);
1195 attribs.push_back(EGL_NONE);
1196 const EGLSurface surface = egl.createPbufferSurface(m_eglDisplay, m_eglConfig, attribs.data());
1197 if ((surface == EGL_NO_SURFACE) && (egl.getError() == EGL_BAD_MATCH))
1199 TCU_THROW(NotSupportedError, "Colorspace is not supported with this format");
1201 TCU_CHECK(surface != EGL_NO_SURFACE);
1202 EGLU_CHECK_MSG(egl, "eglCreatePbufferSurface()");
1204 doClearTest(surface);
1206 egl.destroySurface(m_eglDisplay, surface);
1207 EGLU_CHECK_MSG(egl, "eglDestroySurface()");
1209 else if (m_surfaceType & EGL_WINDOW_BIT)
1211 log << tcu::TestLog::Message << "Test Window" << tcu::TestLog::EndMessage;
1213 const eglu::NativeWindowFactory& windowFactory = eglu::selectNativeWindowFactory(displayFactory, m_testCtx.getCommandLine());
1215 de::UniquePtr<eglu::NativeWindow> window (windowFactory.createWindow(&nativeDisplay, m_eglDisplay, m_eglConfig, DE_NULL, eglu::WindowParams(128, 128, eglu::parseWindowVisibility(m_testCtx.getCommandLine()))));
1216 std::vector<EGLAttrib> attribs;
1217 if (m_colorSpace != EGL_NONE)
1219 attribs.push_back(EGL_GL_COLORSPACE_KHR);
1220 attribs.push_back(m_colorSpace);
1222 for (deUint32 i = 0; i < m_winAttribList.size(); i++)
1224 attribs.push_back(m_winAttribList[i]);
1226 attribs.push_back(EGL_NONE);
1227 attribs.push_back(EGL_NONE);
1232 surface = eglu::createWindowSurface(nativeDisplay, *window, m_eglDisplay, m_eglConfig, attribs.data());
1234 catch (const eglu::Error& error)
1236 if (error.getError() == EGL_BAD_MATCH)
1237 TCU_THROW(NotSupportedError, "createWindowSurface is not supported for this config");
1241 TCU_CHECK(surface != EGL_NO_SURFACE);
1242 EGLU_CHECK_MSG(egl, "eglCreateWindowSurface()");
1244 doClearTest(surface);
1246 // If we have any window attributes, check that the values are correct
1247 for (deUint32 i = 0; i < m_winAttribList.size(); i +=2)
1250 egl.querySurface(m_eglDisplay, surface, m_winAttribList[i], &value);
1251 TCU_CHECK(value == m_winAttribList[i+1]);
1254 if (m_testAttribList.size() > 0)
1256 for (deUint32 i = 0; i < m_testAttribList.size(); i +=2)
1258 if (!egl.surfaceAttrib(m_eglDisplay, surface, m_testAttribList[i], m_testAttribList[i+1])) {
1259 TCU_FAIL("Unable to set HDR metadata on surface");
1262 for (deUint32 i = 0; i < m_testAttribList.size(); i +=2)
1265 egl.querySurface(m_eglDisplay, surface, m_testAttribList[i], &value);
1266 TCU_CHECK(value == m_testAttribList[i+1]);
1270 egl.destroySurface(m_eglDisplay, surface);
1271 EGLU_CHECK_MSG(egl, "eglDestroySurface()");
1273 else if (m_surfaceType & EGL_PIXMAP_BIT)
1275 log << tcu::TestLog::Message << "Test Pixmap" << tcu::TestLog::EndMessage;
1277 const eglu::NativePixmapFactory& pixmapFactory = eglu::selectNativePixmapFactory(displayFactory, m_testCtx.getCommandLine());
1279 de::UniquePtr<eglu::NativePixmap> pixmap (pixmapFactory.createPixmap(&nativeDisplay, m_eglDisplay, m_eglConfig, DE_NULL, 128, 128));
1280 const EGLSurface surface = eglu::createPixmapSurface(nativeDisplay, *pixmap, m_eglDisplay, m_eglConfig, DE_NULL);
1281 TCU_CHECK(surface != EGL_NO_SURFACE);
1282 EGLU_CHECK_MSG(egl, "eglCreatePixmapSurface()");
1284 doClearTest(surface);
1286 egl.destroySurface(m_eglDisplay, surface);
1287 EGLU_CHECK_MSG(egl, "eglDestroySurface()");
1290 TCU_FAIL("No valid surface types supported in config");
1293 TestCase::IterateResult WideColorSurfaceTest::iterate (void)
1295 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
1302 WideColorTests::WideColorTests (EglTestContext& eglTestCtx)
1303 : TestCaseGroup(eglTestCtx, "wide_color", "Wide Color tests")
1307 void WideColorTests::init (void)
1309 addChild(new WideColorFP16Test(m_eglTestCtx, "fp16", "Verify that FP16 pixel format is present"));
1310 addChild(new WideColor1010102Test(m_eglTestCtx, "1010102", "Check if 1010102 pixel format is present"));
1312 // This is an increment FP16 can do between -1.0 to 1.0
1313 const float fp16Increment1 = deFloatPow(2.0, -11.0);
1314 // This is an increment FP16 can do between 1.0 to 2.0
1315 const float fp16Increment2 = deFloatPow(2.0, -10.0);
1317 const EGLint windowAttribListFP16[] =
1319 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
1320 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
1325 EGL_COLOR_COMPONENT_TYPE_EXT, EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT,
1329 std::vector<Iteration> fp16Iterations;
1330 // -0.333251953125f ~ -1/3 as seen in FP16
1331 fp16Iterations.push_back(Iteration(-0.333251953125f, fp16Increment1, 10));
1333 fp16Iterations.push_back( Iteration(-fp16Increment1 * 5.0f, fp16Increment1, 10));
1334 // test crossing 1.0
1335 fp16Iterations.push_back( Iteration(1.0f - fp16Increment2 * 5.0f, fp16Increment2, 10));
1336 addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_fp16_default_colorspace", "FP16 window surface has FP16 pixels in it", windowAttribListFP16, EGL_NONE, fp16Iterations));
1337 addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_fp16_colorspace_srgb", "FP16 window surface, explicit sRGB colorspace", windowAttribListFP16, EGL_GL_COLORSPACE_SRGB_KHR, fp16Iterations));
1338 addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_fp16_colorspace_p3", "FP16 window surface, explicit Display-P3 colorspace", windowAttribListFP16, EGL_GL_COLORSPACE_DISPLAY_P3_EXT, fp16Iterations));
1339 addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_fp16_colorspace_scrgb", "FP16 window surface, explicit scRGB colorspace", windowAttribListFP16, EGL_GL_COLORSPACE_SCRGB_EXT, fp16Iterations));
1340 addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_fp16_colorspace_scrgb_linear", "FP16 window surface, explicit scRGB linear colorspace", windowAttribListFP16, EGL_GL_COLORSPACE_SCRGB_LINEAR_EXT, fp16Iterations));
1342 const EGLint pbufferAttribListFP16[] =
1344 EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
1345 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
1350 EGL_COLOR_COMPONENT_TYPE_EXT, EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT,
1353 addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_fp16_default_colorspace", "FP16 pbuffer surface has FP16 pixels in it", pbufferAttribListFP16, EGL_NONE, fp16Iterations));
1354 addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_fp16_colorspace_srgb", "FP16 pbuffer surface, explicit sRGB colorspace", pbufferAttribListFP16, EGL_GL_COLORSPACE_SRGB_KHR, fp16Iterations));
1355 addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_fp16_colorspace_p3", "FP16 pbuffer surface, explicit Display-P3 colorspace", pbufferAttribListFP16, EGL_GL_COLORSPACE_DISPLAY_P3_EXT, fp16Iterations));
1356 addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_fp16_colorspace_scrgb", "FP16 pbuffer surface, explicit scRGB colorspace", pbufferAttribListFP16, EGL_GL_COLORSPACE_SCRGB_EXT, fp16Iterations));
1357 addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_fp16_colorspace_scrgb_linear", "FP16 pbuffer surface, explicit scRGB linear colorspace", pbufferAttribListFP16, EGL_GL_COLORSPACE_SCRGB_LINEAR_EXT, fp16Iterations));
1359 const EGLint windowAttribList1010102[] =
1361 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
1362 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
1370 std::vector<Iteration> int1010102Iterations;
1371 // -0.333251953125f ~ -1/3 as seen in fp16
1372 // Negative values will be 0 on read with fixed point pixel formats
1373 int1010102Iterations.push_back(Iteration(-0.333251953125f, fp16Increment1, 10));
1375 int1010102Iterations.push_back(Iteration(-fp16Increment1 * 5.0f, fp16Increment1, 10));
1376 // test crossing 1.0
1377 // Values > 1.0 will be truncated to 1.0 with fixed point pixel formats
1378 int1010102Iterations.push_back(Iteration(1.0f - fp16Increment2 * 5.0f, fp16Increment2, 10));
1379 addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_1010102_colorspace_default", "1010102 Window surface, default (sRGB) colorspace", windowAttribList1010102, EGL_NONE, int1010102Iterations));
1380 addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_1010102_colorspace_srgb", "1010102 Window surface, explicit sRGB colorspace", windowAttribList1010102, EGL_GL_COLORSPACE_SRGB_KHR, int1010102Iterations));
1381 addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_1010102_colorspace_p3", "1010102 Window surface, explicit Display-P3 colorspace", windowAttribList1010102, EGL_GL_COLORSPACE_DISPLAY_P3_EXT, int1010102Iterations));
1383 const EGLint pbufferAttribList1010102[] =
1385 EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
1386 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
1393 addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_1010102_colorspace_default", "1010102 pbuffer surface, default (sRGB) colorspace", pbufferAttribList1010102, EGL_NONE, int1010102Iterations));
1394 addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_1010102_colorspace_srgb", "1010102 pbuffer surface, explicit sRGB colorspace", pbufferAttribList1010102, EGL_GL_COLORSPACE_SRGB_KHR, int1010102Iterations));
1395 addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_1010102_colorspace_p3", "1010102 pbuffer surface, explicit Display-P3 colorspace", pbufferAttribList1010102, EGL_GL_COLORSPACE_DISPLAY_P3_EXT, int1010102Iterations));
1397 const EGLint windowAttribList8888[] =
1399 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
1400 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
1408 std::vector<Iteration> int8888Iterations;
1409 // -0.333251953125f ~ -1/3 as seen in fp16
1410 // Negative values will be 0 on read with fixed point pixel formats
1411 int8888Iterations.push_back(Iteration(-0.333251953125f, fp16Increment1, 10));
1413 int8888Iterations.push_back(Iteration(-fp16Increment1 * 5.0f, fp16Increment1, 10));
1414 // test crossing 1.0
1415 // Values > 1.0 will be truncated to 1.0 with fixed point pixel formats
1416 int8888Iterations.push_back(Iteration(1.0f - fp16Increment2 * 5.0f, fp16Increment2, 10));
1417 addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_8888_colorspace_default", "8888 window surface, default (sRGB) colorspace", windowAttribList8888, EGL_NONE, int8888Iterations));
1418 addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_8888_colorspace_srgb", "8888 window surface, explicit sRGB colorspace", windowAttribList8888, EGL_GL_COLORSPACE_SRGB_KHR, int8888Iterations));
1419 addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_8888_colorspace_p3", "8888 window surface, explicit Display-P3 colorspace", windowAttribList8888, EGL_GL_COLORSPACE_DISPLAY_P3_EXT, int8888Iterations));
1421 const EGLint pbufferAttribList8888[] =
1423 EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
1424 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
1431 addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_8888_colorspace_default", "8888 pbuffer surface, default (sRGB) colorspace", pbufferAttribList8888, EGL_NONE, int8888Iterations));
1432 addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_8888_colorspace_srgb", "8888 pbuffer surface, explicit sRGB colorspace", pbufferAttribList8888, EGL_GL_COLORSPACE_SRGB_KHR, int8888Iterations));
1433 addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_8888_colorspace_p3", "8888 pbuffer surface, explicit Display-P3 colorspace", pbufferAttribList8888, EGL_GL_COLORSPACE_DISPLAY_P3_EXT, int8888Iterations));
1436 TestCaseGroup* createWideColorTests (EglTestContext& eglTestCtx)
1438 return new WideColorTests(eglTestCtx);
1441 class HdrColorTest : public WideColorTest
1444 HdrColorTest (EglTestContext& eglTestCtx,
1446 const char* description);
1448 void executeTest (void);
1449 IterateResult iterate (void);
1452 HdrColorTest::HdrColorTest (EglTestContext& eglTestCtx, const char* name, const char* description)
1453 : WideColorTest(eglTestCtx, name, description)
1457 #define METADATA_SCALE(x) (static_cast<EGLint>(x * EGL_METADATA_SCALING_EXT))
1459 void HdrColorTest::executeTest (void)
1461 tcu::TestLog& log = m_testCtx.getLog();
1462 const Library& egl = m_eglTestCtx.getLibrary();
1463 egl.bindAPI(EGL_OPENGL_ES_API);
1465 log << tcu::TestLog::Message << "Test HDR Metadata on Window" << tcu::TestLog::EndMessage;
1470 // This is an increment FP16 can do between -1.0 to 1.0
1471 const float fp16Increment1 = deFloatPow(2.0, -11.0);
1472 // This is an increment FP16 can do between 1.0 to 2.0
1473 const float fp16Increment2 = deFloatPow(2.0, -10.0);
1475 std::vector<Iteration> int8888Iterations;
1476 // -0.333251953125f ~ -1/3 as seen in fp16
1477 // Negative values will be 0 on read with fixed point pixel formats
1478 int8888Iterations.push_back(Iteration(-0.333251953125f, fp16Increment1, 10));
1480 int8888Iterations.push_back(Iteration(-fp16Increment1 * 5.0f, fp16Increment1, 10));
1481 // test crossing 1.0
1482 // Values > 1.0 will be truncated to 1.0 with fixed point pixel formats
1483 int8888Iterations.push_back(Iteration(1.0f - fp16Increment2 * 5.0f, fp16Increment2, 10));
1485 const EGLint windowAttribList8888[] =
1487 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
1488 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
1496 WideColorSurfaceTest testObj(m_eglTestCtx, "window_8888_colorspace_default", "8888 window surface, default (sRGB) colorspace", windowAttribList8888, EGL_NONE, int8888Iterations);
1497 const EGLint attrs[] =
1499 EGL_SMPTE2086_DISPLAY_PRIMARY_RX_EXT, METADATA_SCALE(0.640),
1500 EGL_SMPTE2086_DISPLAY_PRIMARY_RY_EXT, METADATA_SCALE(0.330),
1501 EGL_SMPTE2086_DISPLAY_PRIMARY_GX_EXT, METADATA_SCALE(0.290),
1502 EGL_SMPTE2086_DISPLAY_PRIMARY_GY_EXT, METADATA_SCALE(0.600),
1503 EGL_SMPTE2086_DISPLAY_PRIMARY_BX_EXT, METADATA_SCALE(0.150),
1504 EGL_SMPTE2086_DISPLAY_PRIMARY_BY_EXT, METADATA_SCALE(0.060),
1505 EGL_SMPTE2086_WHITE_POINT_X_EXT, METADATA_SCALE(0.3127),
1506 EGL_SMPTE2086_WHITE_POINT_Y_EXT, METADATA_SCALE(0.3290),
1507 EGL_SMPTE2086_MAX_LUMINANCE_EXT, METADATA_SCALE(300.0),
1508 EGL_SMPTE2086_MIN_LUMINANCE_EXT, METADATA_SCALE(0.7),
1509 EGL_CTA861_3_MAX_CONTENT_LIGHT_LEVEL_EXT, METADATA_SCALE(300),
1510 EGL_CTA861_3_MAX_FRAME_AVERAGE_LEVEL_EXT, METADATA_SCALE(75),
1514 testObj.addWindowAttributes(attrs);
1516 const EGLint testAttrs[] =
1518 EGL_SMPTE2086_DISPLAY_PRIMARY_RX_EXT, METADATA_SCALE(0.680),
1519 EGL_SMPTE2086_DISPLAY_PRIMARY_RY_EXT, METADATA_SCALE(0.320),
1520 EGL_SMPTE2086_DISPLAY_PRIMARY_GX_EXT, METADATA_SCALE(0.265),
1521 EGL_SMPTE2086_DISPLAY_PRIMARY_GY_EXT, METADATA_SCALE(0.690),
1522 EGL_SMPTE2086_DISPLAY_PRIMARY_BX_EXT, METADATA_SCALE(0.440),
1523 EGL_SMPTE2086_DISPLAY_PRIMARY_BY_EXT, METADATA_SCALE(0.320),
1524 EGL_SMPTE2086_WHITE_POINT_X_EXT, METADATA_SCALE(0.2200),
1525 EGL_SMPTE2086_WHITE_POINT_Y_EXT, METADATA_SCALE(0.2578),
1526 EGL_SMPTE2086_MAX_LUMINANCE_EXT, METADATA_SCALE(123.0),
1527 EGL_SMPTE2086_MIN_LUMINANCE_EXT, METADATA_SCALE(0.123),
1528 EGL_CTA861_3_MAX_CONTENT_LIGHT_LEVEL_EXT, METADATA_SCALE(234),
1529 EGL_CTA861_3_MAX_FRAME_AVERAGE_LEVEL_EXT, METADATA_SCALE(67),
1532 testObj.addTestAttributes(testAttrs);
1535 testObj.executeTest();
1538 TestCase::IterateResult HdrColorTest::iterate (void)
1540 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
1545 class HdrColorTests : public TestCaseGroup
1548 HdrColorTests (EglTestContext& eglTestCtx);
1552 HdrColorTests (const HdrColorTests&);
1553 HdrColorTests& operator= (const HdrColorTests&);
1556 HdrColorTests::HdrColorTests (EglTestContext& eglTestCtx)
1557 : TestCaseGroup(eglTestCtx, "hdr_color", "HDR Color tests")
1561 void HdrColorTests::init (void)
1563 addChild(new HdrColorTest(m_eglTestCtx, "8888", "Verify that SMPTE 2086 extension exists"));
1566 TestCaseGroup* createHdrColorTests (EglTestContext& eglTestCtx)
1568 return new HdrColorTests(eglTestCtx);