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"
44 #include "glwDefs.hpp"
45 #include "glwEnums.hpp"
46 #include "glwFunctions.hpp"
49 #include "deRandom.hpp"
51 #include "deStringUtil.hpp"
72 typedef tcu::Vec4 Color;
76 class ReferenceRenderer;
78 class WideColorTests : public TestCaseGroup
81 WideColorTests (EglTestContext& eglTestCtx);
85 WideColorTests (const WideColorTests&);
86 WideColorTests& operator= (const WideColorTests&);
89 class WideColorTest : public TestCase
98 WideColorTest (EglTestContext& eglTestCtx, const char* name, const char* description);
99 ~WideColorTest (void);
103 void checkPixelFloatSupport (void);
104 void checkColorSpaceSupport (void);
105 void checkDisplayP3Support (void);
106 void checkDisplayP3PassthroughSupport (void);
107 void check1010102Support (void);
108 void checkFP16Support (void);
109 void checkSCRGBSupport (void);
110 void checkSCRGBLinearSupport (void);
111 void checkbt2020linear (void);
112 void checkbt2020pq (void);
113 void checkSMPTE2086 (void);
114 void checkCTA861_3 (void);
117 void initEGLSurface (EGLConfig config);
118 void initEGLContext (EGLConfig config);
120 EGLDisplay m_eglDisplay;
127 ColoredRect (const IVec2& bottomLeft_, const IVec2& topRight_, const Color& color_);
133 ColoredRect::ColoredRect (const IVec2& bottomLeft_, const IVec2& topRight_, const Color& color_)
134 : bottomLeft (bottomLeft_)
135 , topRight (topRight_)
140 void clearColorScreen (const glw::Functions& gl, const Color& clearColor)
142 gl.clearColor(clearColor.x(), clearColor.y(), clearColor.z(), clearColor.w());
143 gl.clear(GL_COLOR_BUFFER_BIT);
146 float windowToDeviceCoordinates (int x, int length)
148 return (2.0f * float(x) / float(length)) - 1.0f;
154 GLES2Renderer (const glw::Functions& gl, int width, int height);
155 ~GLES2Renderer (void);
156 void render (const ColoredRect& coloredRect) const;
159 GLES2Renderer (const GLES2Renderer&);
160 GLES2Renderer& operator= (const GLES2Renderer&);
162 const glw::Functions& m_gl;
163 glu::ShaderProgram m_glProgram;
164 glw::GLuint m_coordLoc;
165 glw::GLuint m_colorLoc;
166 glw::GLuint m_bufWidth;
167 glw::GLuint m_bufHeight;
170 // generate sources for vertex and fragment buffer
171 glu::ProgramSources getSources (void)
173 const char* const vertexShaderSource =
174 "attribute mediump vec2 a_pos;\n"
175 "attribute mediump vec4 a_color;\n"
176 "varying mediump vec4 v_color;\n"
179 "\tv_color = a_color;\n"
180 "\tgl_Position = vec4(a_pos, 0.0, 1.0);\n"
183 const char* const fragmentShaderSource =
184 "varying mediump vec4 v_color;\n"
187 "\tgl_FragColor = v_color;\n"
190 return glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource);
193 GLES2Renderer::GLES2Renderer (const glw::Functions& gl, int width, int height)
195 , m_glProgram (gl, getSources())
196 , m_coordLoc ((glw::GLuint)-1)
197 , m_colorLoc ((glw::GLuint)-1)
199 , m_bufHeight (height)
201 m_colorLoc = m_gl.getAttribLocation(m_glProgram.getProgram(), "a_color");
202 m_coordLoc = m_gl.getAttribLocation(m_glProgram.getProgram(), "a_pos");
203 GLU_EXPECT_NO_ERROR(m_gl.getError(), "Failed to get attribute locations");
206 GLES2Renderer::~GLES2Renderer (void)
210 void GLES2Renderer::render (const struct ColoredRect &coloredRect) const
212 const float x1 = windowToDeviceCoordinates(coloredRect.bottomLeft.x(), m_bufWidth);
213 const float y1 = windowToDeviceCoordinates(coloredRect.bottomLeft.y(), m_bufHeight);
214 const float x2 = windowToDeviceCoordinates(coloredRect.topRight.x(), m_bufWidth);
215 const float y2 = windowToDeviceCoordinates(coloredRect.topRight.y(), m_bufHeight);
217 const glw::GLfloat coords[] =
228 const glw::GLfloat colors[] =
230 coloredRect.color.x(), coloredRect.color.y(), coloredRect.color.z(), coloredRect.color.w(),
231 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(),
234 coloredRect.color.x(), coloredRect.color.y(), coloredRect.color.z(), coloredRect.color.w(),
235 coloredRect.color.x(), coloredRect.color.y(), coloredRect.color.z(), coloredRect.color.w(),
236 coloredRect.color.x(), coloredRect.color.y(), coloredRect.color.z(), coloredRect.color.w(),
239 m_gl.useProgram(m_glProgram.getProgram());
240 GLU_EXPECT_NO_ERROR(m_gl.getError(), "glUseProgram() failed");
242 m_gl.enableVertexAttribArray(m_coordLoc);
243 m_gl.enableVertexAttribArray(m_colorLoc);
244 GLU_EXPECT_NO_ERROR(m_gl.getError(), "Failed to enable attributes");
246 m_gl.vertexAttribPointer(m_coordLoc, 4, GL_FLOAT, GL_FALSE, 0, coords);
247 m_gl.vertexAttribPointer(m_colorLoc, 4, GL_FLOAT, GL_TRUE, 0, colors);
248 GLU_EXPECT_NO_ERROR(m_gl.getError(), "Failed to set attribute pointers");
250 m_gl.drawArrays(GL_TRIANGLES, 0, DE_LENGTH_OF_ARRAY(coords)/4);
251 GLU_EXPECT_NO_ERROR(m_gl.getError(), "glDrawArrays(), failed");
253 m_gl.disableVertexAttribArray(m_coordLoc);
254 m_gl.disableVertexAttribArray(m_colorLoc);
255 GLU_EXPECT_NO_ERROR(m_gl.getError(), "Failed to disable attributes");
258 GLU_EXPECT_NO_ERROR(m_gl.getError(), "glUseProgram() failed");
261 class ReferenceRenderer
264 ReferenceRenderer (void);
266 ReferenceRenderer (const ReferenceRenderer&);
267 ReferenceRenderer& operator= (const ReferenceRenderer&);
270 WideColorTest::WideColorTest (EglTestContext& eglTestCtx, const char* name, const char* description)
271 : TestCase (eglTestCtx, name, description)
272 , m_eglDisplay (EGL_NO_DISPLAY)
276 WideColorTest::~WideColorTest (void)
281 void WideColorTest::init (void)
283 m_eglDisplay = eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
285 m_eglTestCtx.initGLFunctions(&m_gl, glu::ApiType::es(2,0));
288 void WideColorTest::checkPixelFloatSupport (void)
290 const Library& egl = m_eglTestCtx.getLibrary();
292 if (!eglu::hasExtension(egl, m_eglDisplay, "EGL_EXT_pixel_format_float"))
293 TCU_THROW(NotSupportedError, "EGL_EXT_pixel_format_float is not supported");
296 void WideColorTest::checkColorSpaceSupport (void)
298 const Library& egl = m_eglTestCtx.getLibrary();
300 if (!eglu::hasExtension(egl, m_eglDisplay, "EGL_KHR_gl_colorspace"))
301 TCU_THROW(NotSupportedError, "EGL_KHR_gl_colorspace is not supported");
304 void WideColorTest::checkDisplayP3Support (void)
306 const Library& egl = m_eglTestCtx.getLibrary();
308 if (!eglu::hasExtension(egl, m_eglDisplay, "EGL_EXT_gl_colorspace_display_p3"))
309 TCU_THROW(NotSupportedError, "EGL_EXT_gl_colorspace_display_p3 is not supported");
312 void WideColorTest::checkDisplayP3PassthroughSupport (void)
314 const Library& egl = m_eglTestCtx.getLibrary();
316 if (!eglu::hasExtension(egl, m_eglDisplay, "EGL_EXT_gl_colorspace_display_p3_passthrough"))
317 TCU_THROW(NotSupportedError, "EGL_EXT_gl_colorspace_display_p3_passthrough is not supported");
320 void WideColorTest::checkSCRGBSupport (void)
322 const Library& egl = m_eglTestCtx.getLibrary();
324 if (!eglu::hasExtension(egl, m_eglDisplay, "EGL_EXT_gl_colorspace_scrgb"))
325 TCU_THROW(NotSupportedError, "EGL_EXT_gl_colorspace_scrgb is not supported");
328 void WideColorTest::checkSCRGBLinearSupport (void)
330 const Library& egl = m_eglTestCtx.getLibrary();
332 if (!eglu::hasExtension(egl, m_eglDisplay, "EGL_EXT_gl_colorspace_scrgb_linear"))
333 TCU_THROW(NotSupportedError, "EGL_EXT_gl_colorspace_scrgb_linear is not supported");
336 void WideColorTest::checkbt2020linear (void)
338 const Library& egl = m_eglTestCtx.getLibrary();
340 if (!eglu::hasExtension(egl, m_eglDisplay, "EGL_EXT_gl_colorspace_bt2020_linear"))
341 TCU_THROW(NotSupportedError, "EGL_EXT_gl_colorspace_bt2020_linear is not supported");
344 void WideColorTest::checkbt2020pq (void)
346 const Library& egl = m_eglTestCtx.getLibrary();
348 if (!eglu::hasExtension(egl, m_eglDisplay, "EGL_EXT_gl_colorspace_bt2020_pq"))
349 TCU_THROW(NotSupportedError, "EGL_EXT_gl_colorspace_bt2020_pq is not supported");
352 void WideColorTest::checkSMPTE2086 (void)
354 const Library& egl = m_eglTestCtx.getLibrary();
356 if (!eglu::hasExtension(egl, m_eglDisplay, "EGL_EXT_surface_SMPTE2086_metadata"))
357 TCU_THROW(NotSupportedError, "EGL_EXT_surface_SMPTE2086_metadata is not supported");
360 void WideColorTest::checkCTA861_3 (void)
362 const Library& egl = m_eglTestCtx.getLibrary();
364 if (!eglu::hasExtension(egl, m_eglDisplay, "EGL_EXT_surface_CTA861_3_metadata"))
365 TCU_THROW(NotSupportedError, "EGL_EXT_surface_CTA861_3_metadata is not supported");
368 void WideColorTest::check1010102Support (void)
370 const Library& egl = m_eglTestCtx.getLibrary();
371 tcu::TestLog& log = m_testCtx.getLog();
373 const EGLint attribList[] =
375 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
376 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
383 EGLint numConfigs = 0;
386 // Query from EGL implementation
387 EGLU_CHECK_CALL(egl, chooseConfig(m_eglDisplay, &attribList[0], DE_NULL, 0, &numConfigs));
391 log << tcu::TestLog::Message << "No configs returned." << tcu::TestLog::EndMessage;
392 TCU_THROW(NotSupportedError, "10:10:10:2 pixel format is not supported");
395 log << tcu::TestLog::Message << numConfigs << " configs returned" << tcu::TestLog::EndMessage;
397 EGLU_CHECK_CALL(egl, chooseConfig(m_eglDisplay, &attribList[0], &config, 1, &numConfigs));
400 log << tcu::TestLog::Message << "Fail, more configs returned than requested." << tcu::TestLog::EndMessage;
401 TCU_FAIL("Too many configs returned");
404 EGLint components[4];
406 EGLU_CHECK_CALL(egl, getConfigAttrib(m_eglDisplay, config, EGL_RED_SIZE, &components[0]));
407 EGLU_CHECK_CALL(egl, getConfigAttrib(m_eglDisplay, config, EGL_GREEN_SIZE, &components[1]));
408 EGLU_CHECK_CALL(egl, getConfigAttrib(m_eglDisplay, config, EGL_BLUE_SIZE, &components[2]));
409 EGLU_CHECK_CALL(egl, getConfigAttrib(m_eglDisplay, config, EGL_ALPHA_SIZE, &components[3]));
411 TCU_CHECK_MSG(components[0] == 10, "Missing 10bit deep red channel");
412 TCU_CHECK_MSG(components[1] == 10, "Missing 10bit deep green channel");
413 TCU_CHECK_MSG(components[2] == 10, "Missing 10bit deep blue channel");
414 TCU_CHECK_MSG(components[3] == 2, "Missing 2bit deep alpha channel");
417 void WideColorTest::checkFP16Support (void)
419 const Library& egl = m_eglTestCtx.getLibrary();
420 tcu::TestLog& log = m_testCtx.getLog();
421 EGLint numConfigs = 0;
424 const EGLint attribList[] =
426 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
427 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
432 EGL_COLOR_COMPONENT_TYPE_EXT, EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT,
436 // Query from EGL implementation
437 EGLU_CHECK_CALL(egl, chooseConfig(m_eglDisplay, &attribList[0], DE_NULL, 0, &numConfigs));
441 log << tcu::TestLog::Message << "No configs returned." << tcu::TestLog::EndMessage;
442 TCU_THROW(NotSupportedError, "16:16:16:16 pixel format is not supported");
445 log << tcu::TestLog::Message << numConfigs << " configs returned" << tcu::TestLog::EndMessage;
447 EGLBoolean success = egl.chooseConfig(m_eglDisplay, &attribList[0], &config, 1, &numConfigs);
448 if (success != EGL_TRUE)
450 log << tcu::TestLog::Message << "Fail, eglChooseConfig returned an error." << tcu::TestLog::EndMessage;
451 TCU_FAIL("eglChooseConfig failed");
455 log << tcu::TestLog::Message << "Fail, more configs returned than requested." << tcu::TestLog::EndMessage;
456 TCU_FAIL("Too many configs returned");
459 EGLint components[4];
461 success = egl.getConfigAttrib(m_eglDisplay, config, EGL_RED_SIZE, &components[0]);
462 TCU_CHECK_MSG(success == EGL_TRUE, "eglGetConfigAttrib failed");
464 success = egl.getConfigAttrib(m_eglDisplay, config, EGL_GREEN_SIZE, &components[1]);
465 TCU_CHECK_MSG(success == EGL_TRUE, "eglGetConfigAttrib failed");
467 success = egl.getConfigAttrib(m_eglDisplay, config, EGL_BLUE_SIZE, &components[2]);
468 TCU_CHECK_MSG(success == EGL_TRUE, "eglGetConfigAttrib failed");
470 success = egl.getConfigAttrib(m_eglDisplay, config, EGL_ALPHA_SIZE, &components[3]);
471 TCU_CHECK_MSG(success == EGL_TRUE, "eglGetConfigAttrib failed");
474 TCU_CHECK_MSG(components[0] == 16, "Missing 16bit deep red channel");
475 TCU_CHECK_MSG(components[1] == 16, "Missing 16bit deep green channel");
476 TCU_CHECK_MSG(components[2] == 16, "Missing 16bit deep blue channel");
477 TCU_CHECK_MSG(components[3] == 16, "Missing 16bit deep alpha channel");
480 void WideColorTest::deinit (void)
482 const Library& egl = m_eglTestCtx.getLibrary();
484 if (m_eglDisplay != EGL_NO_DISPLAY)
486 egl.terminate(m_eglDisplay);
487 m_eglDisplay = EGL_NO_DISPLAY;
491 class WideColorFP16Test : public WideColorTest
494 WideColorFP16Test (EglTestContext& eglTestCtx, const char* name, const char* description);
497 void executeTest (void);
498 IterateResult iterate (void);
501 WideColorFP16Test::WideColorFP16Test (EglTestContext& eglTestCtx,
503 const char* description)
504 : WideColorTest(eglTestCtx, name, description)
509 void WideColorFP16Test::executeTest (void)
511 checkPixelFloatSupport();
515 TestCase::IterateResult WideColorFP16Test::iterate (void)
517 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
522 void WideColorFP16Test::init (void)
524 WideColorTest::init();
527 class WideColor1010102Test : public WideColorTest
530 WideColor1010102Test (EglTestContext& eglTestCtx,
532 const char* description);
534 void executeTest (void);
535 IterateResult iterate (void);
538 WideColor1010102Test::WideColor1010102Test (EglTestContext& eglTestCtx, const char* name, const char* description)
539 : WideColorTest(eglTestCtx, name, description)
543 void WideColor1010102Test::executeTest (void)
545 check1010102Support();
548 TestCase::IterateResult WideColor1010102Test::iterate (void)
550 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
560 Iteration(float s, float i, int c)
561 : start(s), increment(i), iterationCount(c) {}
564 class WideColorSurfaceTest : public WideColorTest
567 WideColorSurfaceTest (EglTestContext& eglTestCtx,
569 const char* description,
570 const EGLint* attribList,
572 const std::vector<Iteration>& iterations);
575 void executeTest (void);
576 IterateResult iterate (void);
577 void addTestAttributes (const EGLint* attributes);
580 void readPixels (const glw::Functions& gl, float* dataPtr);
581 void readPixels (const glw::Functions& gl, deUint32* dataPtr);
582 void readPixels (const glw::Functions& gl, deUint8* dataPtr);
583 deUint32 expectedUint10 (float reference);
584 deUint32 expectedUint2 (float reference);
585 deUint8 expectedUint8 (float reference);
586 deUint8 expectedAlpha8 (float reference);
587 bool checkWithThreshold8 (deUint8 value, deUint8 reference, deUint8 threshold = 1);
588 bool checkWithThreshold10 (deUint32 value, deUint32 reference, deUint32 threshold = 1);
589 bool checkWithThresholdFloat (float value, float reference, float threshold);
590 void doClearTest (EGLSurface surface);
591 void testPixels (float reference, float increment);
592 void testFramebufferColorEncoding ();
593 void writeEglConfig (EGLConfig config);
596 std::vector<EGLint> m_attribList;
597 std::vector<EGLint> m_testAttribList;
598 EGLConfig m_eglConfig;
599 EGLint m_surfaceType;
600 EGLint m_componentType;
601 EGLint m_requestedRedSize;
605 const std::vector<struct Iteration> m_iterations;
606 std::stringstream m_debugLog;
609 WideColorSurfaceTest::WideColorSurfaceTest (EglTestContext& eglTestCtx, const char* name, const char* description, const EGLint* attribList, EGLint colorSpace, const std::vector<struct Iteration>& iterations)
610 : WideColorTest (eglTestCtx, name, description)
612 , m_componentType (EGL_COLOR_COMPONENT_TYPE_FIXED_EXT)
613 , m_requestedRedSize (0)
616 , m_colorSpace (colorSpace)
617 , m_iterations (iterations)
620 while (attribList[idx] != EGL_NONE)
622 if (attribList[idx] == EGL_COLOR_COMPONENT_TYPE_EXT)
624 m_componentType = attribList[idx + 1];
626 else if (attribList[idx] == EGL_SURFACE_TYPE)
628 m_surfaceType = attribList[idx+1];
630 else if (attribList[idx] == EGL_RED_SIZE)
632 m_requestedRedSize = attribList[idx + 1];
634 m_attribList.push_back(attribList[idx++]);
635 m_attribList.push_back(attribList[idx++]);
637 m_attribList.push_back(EGL_NONE);
640 void WideColorSurfaceTest::addTestAttributes(const EGLint *attributes)
643 if (attributes == DE_NULL) return;
645 while (attributes[idx] != EGL_NONE)
647 m_testAttribList.push_back(attributes[idx++]);
648 m_testAttribList.push_back(attributes[idx++]);
652 void WideColorSurfaceTest::init (void)
654 const Library& egl = m_eglTestCtx.getLibrary();
655 tcu::TestLog& log = m_testCtx.getLog();
657 WideColorTest::init();
659 // Only check for pixel format required for this specific run
660 // If not available, check will abort test with "NotSupported"
661 switch (m_requestedRedSize)
664 check1010102Support();
667 checkPixelFloatSupport();
672 if (m_colorSpace != EGL_NONE && !eglu::hasExtension(egl, m_eglDisplay, "EGL_KHR_gl_colorspace"))
673 TCU_THROW(NotSupportedError, "EGL_KHR_gl_colorspace is not supported");
675 switch (m_colorSpace) {
676 case EGL_GL_COLORSPACE_SRGB_KHR:
677 checkColorSpaceSupport();
679 case EGL_GL_COLORSPACE_DISPLAY_P3_EXT:
680 checkDisplayP3Support();
682 case EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT:
683 checkDisplayP3PassthroughSupport();
685 case EGL_GL_COLORSPACE_SCRGB_EXT:
688 case EGL_GL_COLORSPACE_SCRGB_LINEAR_EXT:
689 checkSCRGBLinearSupport();
691 case EGL_GL_COLORSPACE_BT2020_LINEAR_EXT:
694 case EGL_GL_COLORSPACE_BT2020_PQ_EXT:
701 EGLint numConfigs = 0;
703 // Query from EGL implementation
704 EGLU_CHECK_CALL(egl, chooseConfig(m_eglDisplay, &m_attribList[0], DE_NULL, 0, &numConfigs));
708 log << tcu::TestLog::Message << "No configs returned." << tcu::TestLog::EndMessage;
709 TCU_THROW(NotSupportedError, "No configs available with the requested attributes");
712 log << tcu::TestLog::Message << numConfigs << " configs returned" << tcu::TestLog::EndMessage;
714 EGLBoolean success = egl.chooseConfig(m_eglDisplay, &m_attribList[0], &m_eglConfig, 1, &numConfigs);
715 if (success != EGL_TRUE)
717 log << tcu::TestLog::Message << "Fail, eglChooseConfig returned an error." << tcu::TestLog::EndMessage;
718 TCU_FAIL("eglChooseConfig failed");
722 log << tcu::TestLog::Message << "Fail, more configs returned than requested." << tcu::TestLog::EndMessage;
723 TCU_FAIL("Too many configs returned");
726 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
728 m_redSize = eglu::getConfigAttribInt(egl, m_eglDisplay, m_eglConfig, EGL_RED_SIZE);
729 m_alphaSize = eglu::getConfigAttribInt(egl, m_eglDisplay, m_eglConfig, EGL_ALPHA_SIZE);
730 writeEglConfig(m_eglConfig);
733 void WideColorSurfaceTest::readPixels (const glw::Functions& gl, float* dataPtr)
735 gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_FLOAT, dataPtr);
736 GLU_EXPECT_NO_ERROR(m_gl.getError(), "glReadPixels with floats");
739 void WideColorSurfaceTest::readPixels (const glw::Functions& gl, deUint32 *dataPtr)
741 gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, dataPtr);
742 GLU_EXPECT_NO_ERROR(m_gl.getError(), "glReadPixels with RGBA_1010102 (32bits)");
745 void WideColorSurfaceTest::readPixels (const glw::Functions& gl, deUint8 *dataPtr)
747 gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, dataPtr);
748 GLU_EXPECT_NO_ERROR(m_gl.getError(), "glReadPixels with RGBA_8888 (8 bit components)");
751 void WideColorSurfaceTest::writeEglConfig (EGLConfig config)
753 const Library& egl = m_eglTestCtx.getLibrary();
754 tcu::TestLog& log = m_testCtx.getLog();
755 qpEglConfigInfo info;
758 info.bufferSize = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_BUFFER_SIZE);
760 info.redSize = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_RED_SIZE);
762 info.greenSize = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_GREEN_SIZE);
764 info.blueSize = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_BLUE_SIZE);
766 info.luminanceSize = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_LUMINANCE_SIZE);
768 info.alphaSize = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_ALPHA_SIZE);
770 info.alphaMaskSize = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_ALPHA_MASK_SIZE);
772 val = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_BIND_TO_TEXTURE_RGB);
773 info.bindToTextureRGB = val == EGL_TRUE ? true : false;
775 val = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_BIND_TO_TEXTURE_RGBA);
776 info.bindToTextureRGBA = val == EGL_TRUE ? true : false;
778 val = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_COLOR_BUFFER_TYPE);
779 std::string colorBufferType = de::toString(eglu::getColorBufferTypeStr(val));
780 info.colorBufferType = colorBufferType.c_str();
782 val = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_CONFIG_CAVEAT);
783 std::string caveat = de::toString(eglu::getConfigCaveatStr(val));
784 info.configCaveat = caveat.c_str();
786 info.configID = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_CONFIG_ID);
788 val = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_CONFORMANT);
789 std::string conformant = de::toString(eglu::getAPIBitsStr(val));
790 info.conformant = conformant.c_str();
792 info.depthSize = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_DEPTH_SIZE);
794 info.level = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_LEVEL);
796 info.maxPBufferWidth = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_MAX_PBUFFER_WIDTH);
798 info.maxPBufferHeight = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_MAX_PBUFFER_HEIGHT);
800 info.maxPBufferPixels = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_MAX_PBUFFER_PIXELS);
802 info.maxSwapInterval = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_MAX_SWAP_INTERVAL);
804 info.minSwapInterval = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_MIN_SWAP_INTERVAL);
806 val = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_NATIVE_RENDERABLE);
807 info.nativeRenderable = val == EGL_TRUE ? true : false;
809 val = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_RENDERABLE_TYPE);
810 std::string renderableTypes = de::toString(eglu::getAPIBitsStr(val));
811 info.renderableType = renderableTypes.c_str();
813 info.sampleBuffers = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_SAMPLE_BUFFERS);
815 info.samples = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_SAMPLES);
817 info.stencilSize = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_STENCIL_SIZE);
819 val = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_SURFACE_TYPE);
820 std::string surfaceTypes = de::toString(eglu::getSurfaceBitsStr(val));
821 info.surfaceTypes = surfaceTypes.c_str();
823 val = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_TRANSPARENT_TYPE);
824 std::string transparentType = de::toString(eglu::getTransparentTypeStr(val));
825 info.transparentType = transparentType.c_str();
827 info.transparentRedValue = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_TRANSPARENT_RED_VALUE);
829 info.transparentGreenValue = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_TRANSPARENT_GREEN_VALUE);
831 info.transparentBlueValue = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_TRANSPARENT_BLUE_VALUE);
833 log.writeEglConfig(&info);
836 deUint32 WideColorSurfaceTest::expectedUint10 (float reference)
844 else if (reference > 1.0)
850 expected = static_cast<deUint32>(deRound(reference * 1023.0));
856 deUint32 WideColorSurfaceTest::expectedUint2 (float reference)
864 else if (reference > 1.0)
870 expected = static_cast<deUint32>(deRound(reference * 3.0));
876 deUint8 WideColorSurfaceTest::expectedUint8 (float reference)
883 else if (reference >= 1.0)
889 // Apply sRGB transfer function when colorspace is sRGB or Display P3 and
890 // pixel component size is 8 bits (which is why we are here in expectedUint8).
891 if (m_colorSpace == EGL_GL_COLORSPACE_SRGB_KHR ||
892 m_colorSpace == EGL_GL_COLORSPACE_DISPLAY_P3_EXT)
896 if (reference <= 0.0031308)
898 srgbReference = 12.92f * reference;
902 float powRef = deFloatPow(reference, (1.0f/2.4f));
903 srgbReference = (1.055f * powRef) - 0.055f;
905 expected = static_cast<deUint8>(deRound(srgbReference * 255.0));
909 expected = static_cast<deUint8>(deRound(reference * 255.0));
915 deUint8 WideColorSurfaceTest::expectedAlpha8 (float reference)
918 if (m_alphaSize == 0)
920 // Surfaces without alpha are read back as opaque.
923 else if (reference < 0.0)
927 else if (reference >= 1.0)
933 // The sRGB transfer function is not applied to alpha
934 expected = static_cast<deUint8>(deRound(reference * 255.0));
939 // Return true for value out of range (fail)
940 bool WideColorSurfaceTest::checkWithThreshold8(deUint8 value, deUint8 reference, deUint8 threshold)
942 const deUint8 low = reference >= threshold ? static_cast<deUint8>(reference - threshold) : 0;
943 const deUint8 high = reference <= (255 - threshold) ? static_cast<deUint8>(reference + threshold) : 255;
944 return !((value >= low) && (value <= high));
947 bool WideColorSurfaceTest::checkWithThreshold10(deUint32 value, deUint32 reference, deUint32 threshold)
949 const deUint32 low = reference >= threshold ? reference - threshold : 0;
950 const deUint32 high = reference <= (1023 - threshold) ? reference + threshold : 1023;
951 return !((value >= low) && (value <= high));
954 bool WideColorSurfaceTest::checkWithThresholdFloat(float value, float reference, float threshold)
956 const float low = reference - threshold;
957 const float high = reference + threshold;
958 return !((value >= low) && (value <= high));
961 void WideColorSurfaceTest::testPixels (float reference, float increment)
963 tcu::TestLog& log = m_testCtx.getLog();
965 if (m_componentType == EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT)
968 const float expected[4] =
971 reference + increment,
972 reference - increment,
973 reference + 2 * increment
975 readPixels(m_gl, pixels);
977 if (checkWithThresholdFloat(pixels[0], expected[0], increment) ||
978 checkWithThresholdFloat(pixels[1], expected[1], increment) ||
979 checkWithThresholdFloat(pixels[2], expected[2], increment) ||
980 checkWithThresholdFloat(pixels[3], expected[3], increment))
982 if (m_debugLog.str().size() > 0)
984 log << tcu::TestLog::Message
985 << "Prior passing tests\n"
987 << tcu::TestLog::EndMessage;
990 log << tcu::TestLog::Message
991 << "Image comparison failed: "
992 << "reference = " << reference
993 << ", expected = " << expected[0]
994 << ":" << expected[1]
995 << ":" << expected[2]
996 << ":" << expected[3]
997 << ", result = " << pixels[0]
1001 << tcu::TestLog::EndMessage;
1002 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Color test failed");
1006 // Pixel matches expected value
1007 m_debugLog << "Image comparison passed: "
1008 << "reference = " << reference
1009 << ", result = " << pixels[0]
1016 else if (m_redSize > 8)
1018 deUint32 buffer[16];
1019 readPixels(m_gl, buffer);
1021 deUint32 expected[4];
1023 pixels[0] = buffer[0] & 0x3ff;
1024 pixels[1] = (buffer[0] >> 10) & 0x3ff;
1025 pixels[2] = (buffer[0] >> 20) & 0x3ff;
1026 pixels[3] = (buffer[0] >> 30) & 0x3;
1028 expected[0] = expectedUint10(reference);
1029 expected[1] = expectedUint10(reference + increment);
1030 expected[2] = expectedUint10(reference - increment);
1031 expected[3] = expectedUint2(reference + 2 * increment);
1032 if (checkWithThreshold10(pixels[0], expected[0]) || checkWithThreshold10(pixels[1], expected[1])
1033 || checkWithThreshold10(pixels[2], expected[2]) || checkWithThreshold10(pixels[3], expected[3]))
1035 if (m_debugLog.str().size() > 0) {
1036 log << tcu::TestLog::Message
1037 << "Prior passing tests\n"
1039 << tcu::TestLog::EndMessage;
1042 log << tcu::TestLog::Message
1043 << "Image comparison failed: "
1044 << "reference = " << reference
1045 << ", expected = " << static_cast<deUint32>(expected[0])
1046 << ":" << static_cast<deUint32>(expected[1])
1047 << ":" << static_cast<deUint32>(expected[2])
1048 << ":" << static_cast<deUint32>(expected[3])
1049 << ", result = " << static_cast<deUint32>(pixels[0])
1050 << ":" << static_cast<deUint32>(pixels[1])
1051 << ":" << static_cast<deUint32>(pixels[2])
1052 << ":" << static_cast<deUint32>(pixels[3])
1053 << tcu::TestLog::EndMessage;
1054 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Color test failed");
1058 // Pixel matches expected value
1059 m_debugLog << "Image comparison passed: "
1060 << "reference = " << reference
1061 << ", result = " << static_cast<deUint32>(pixels[0])
1062 << ":" << static_cast<deUint32>(pixels[1])
1063 << ":" << static_cast<deUint32>(pixels[2])
1064 << ":" << static_cast<deUint32>(pixels[3])
1071 deUint8 expected[4];
1072 readPixels(m_gl, pixels);
1074 expected[0] = expectedUint8(reference);
1075 expected[1] = expectedUint8(reference + increment);
1076 expected[2] = expectedUint8(reference - increment);
1077 expected[3] = expectedAlpha8(reference + 2 * increment);
1078 if (checkWithThreshold8(pixels[0], expected[0]) || checkWithThreshold8(pixels[1], expected[1])
1079 || checkWithThreshold8(pixels[2], expected[2]) || checkWithThreshold8(pixels[3], expected[3]))
1081 if (m_debugLog.str().size() > 0) {
1082 log << tcu::TestLog::Message
1083 << "Prior passing tests\n"
1085 << tcu::TestLog::EndMessage;
1088 log << tcu::TestLog::Message
1089 << "Image comparison failed: "
1090 << "reference = " << reference
1091 << ", expected = " << static_cast<deUint32>(expected[0])
1092 << ":" << static_cast<deUint32>(expected[1])
1093 << ":" << static_cast<deUint32>(expected[2])
1094 << ":" << static_cast<deUint32>(expected[3])
1095 << ", result = " << static_cast<deUint32>(pixels[0])
1096 << ":" << static_cast<deUint32>(pixels[1])
1097 << ":" << static_cast<deUint32>(pixels[2])
1098 << ":" << static_cast<deUint32>(pixels[3])
1099 << tcu::TestLog::EndMessage;
1100 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Color test failed");
1104 // Pixel matches expected value
1105 m_debugLog << "Image comparison passed: "
1106 << "reference = " << reference
1107 << ", result = " << static_cast<deUint32>(pixels[0])
1108 << ":" << static_cast<deUint32>(pixels[1])
1109 << ":" << static_cast<deUint32>(pixels[2])
1110 << ":" << static_cast<deUint32>(pixels[3])
1116 void WideColorSurfaceTest::testFramebufferColorEncoding()
1118 GLint framebufferColorEncoding;
1119 m_gl.getFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_BACK, GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING, &framebufferColorEncoding);
1120 GLU_EXPECT_NO_ERROR(m_gl.getError(), "Get framebuffer color encoding");
1121 bool correct = false;
1122 if (m_colorSpace == EGL_GL_COLORSPACE_SRGB_KHR || m_colorSpace == EGL_GL_COLORSPACE_DISPLAY_P3_EXT)
1126 correct = framebufferColorEncoding == GL_SRGB;
1128 else if (m_redSize == 16)
1130 correct = framebufferColorEncoding == GL_LINEAR;
1135 correct = framebufferColorEncoding == GL_LINEAR;
1139 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Framebuffer color encoding is wrong");
1143 void WideColorSurfaceTest::doClearTest (EGLSurface surface)
1145 tcu::TestLog& log = m_testCtx.getLog();
1146 const Library& egl = m_eglTestCtx.getLibrary();
1147 const EGLint attribList[] =
1149 EGL_CONTEXT_CLIENT_VERSION, 2,
1152 EGLContext eglContext = egl.createContext(m_eglDisplay, m_eglConfig, EGL_NO_CONTEXT, attribList);
1153 EGLU_CHECK_MSG(egl, "eglCreateContext");
1155 egl.makeCurrent(m_eglDisplay, surface, surface, eglContext);
1156 EGLU_CHECK_MSG(egl, "eglMakeCurrent");
1159 // put gles2Renderer inside it's own scope so that it's cleaned
1160 // up before we hit the destroyContext
1161 const GLES2Renderer gles2Renderer(m_gl, 128, 128);
1163 std::vector<Iteration>::const_iterator it; // declare an Iterator to a vector of strings
1164 log << tcu::TestLog::Message << "m_iterations.count = " << m_iterations.size() << tcu::TestLog::EndMessage;
1165 for(it = m_iterations.begin() ; it < m_iterations.end(); it++)
1167 float reference = it->start;
1168 log << tcu::TestLog::Message << "start = " << it->start
1169 << tcu::TestLog::EndMessage;
1170 log << tcu::TestLog::Message
1171 << "increment = " << it->increment
1172 << tcu::TestLog::EndMessage;
1173 log << tcu::TestLog::Message
1174 << "count = " << it->iterationCount
1175 << tcu::TestLog::EndMessage;
1177 for (int iterationCount = 0; iterationCount < it->iterationCount; iterationCount++)
1179 const Color clearColor(reference, reference + it->increment, reference - it->increment, reference + 2 * it->increment);
1181 clearColorScreen(m_gl, clearColor);
1182 GLU_EXPECT_NO_ERROR(m_gl.getError(), "Clear to test value");
1184 testPixels(reference, it->increment);
1186 // reset buffer contents so that we know render below did something
1187 const Color clearColor2(1.0f - reference, 1.0f, 1.0f, 1.0f);
1188 clearColorScreen(m_gl, clearColor2);
1189 GLU_EXPECT_NO_ERROR(m_gl.getError(), "Clear to 1.0f - reference value");
1191 const ColoredRect coloredRect (IVec2(0, 0), IVec2(1, 1), clearColor);
1192 gles2Renderer.render(coloredRect);
1193 testPixels(reference, it->increment);
1195 reference += it->increment;
1197 testFramebufferColorEncoding();
1200 EGLU_CHECK_CALL(egl, swapBuffers(m_eglDisplay, surface));
1204 // disconnect surface & context so they can be destroyed when
1205 // this function exits.
1206 EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
1208 egl.destroyContext(m_eglDisplay, eglContext);
1211 void WideColorSurfaceTest::executeTest (void)
1213 tcu::TestLog& log = m_testCtx.getLog();
1214 const Library& egl = m_eglTestCtx.getLibrary();
1215 const eglu::NativeDisplayFactory& displayFactory = m_eglTestCtx.getNativeDisplayFactory();
1216 eglu::NativeDisplay& nativeDisplay = m_eglTestCtx.getNativeDisplay();
1217 egl.bindAPI(EGL_OPENGL_ES_API);
1219 if (m_surfaceType & EGL_PBUFFER_BIT)
1221 log << tcu::TestLog::Message << "Test Pbuffer" << tcu::TestLog::EndMessage;
1223 std::vector<EGLint> attribs;
1224 attribs.push_back(EGL_WIDTH);
1225 attribs.push_back(128);
1226 attribs.push_back(EGL_HEIGHT);
1227 attribs.push_back(128);
1228 if (m_colorSpace != EGL_NONE)
1230 attribs.push_back(EGL_GL_COLORSPACE_KHR);
1231 attribs.push_back(m_colorSpace);
1233 attribs.push_back(EGL_NONE);
1234 attribs.push_back(EGL_NONE);
1235 const EGLSurface surface = egl.createPbufferSurface(m_eglDisplay, m_eglConfig, attribs.data());
1236 if ((surface == EGL_NO_SURFACE) && (egl.getError() == EGL_BAD_MATCH))
1238 TCU_THROW(NotSupportedError, "Colorspace is not supported with this format");
1240 TCU_CHECK(surface != EGL_NO_SURFACE);
1241 EGLU_CHECK_MSG(egl, "eglCreatePbufferSurface()");
1243 doClearTest(surface);
1245 egl.destroySurface(m_eglDisplay, surface);
1246 EGLU_CHECK_MSG(egl, "eglDestroySurface()");
1248 else if (m_surfaceType & EGL_WINDOW_BIT)
1250 log << tcu::TestLog::Message << "Test Window" << tcu::TestLog::EndMessage;
1252 const eglu::NativeWindowFactory& windowFactory = eglu::selectNativeWindowFactory(displayFactory, m_testCtx.getCommandLine());
1254 de::UniquePtr<eglu::NativeWindow> window (windowFactory.createWindow(&nativeDisplay, m_eglDisplay, m_eglConfig, DE_NULL, eglu::WindowParams(128, 128, eglu::parseWindowVisibility(m_testCtx.getCommandLine()))));
1255 std::vector<EGLAttrib> attribs;
1256 if (m_colorSpace != EGL_NONE)
1258 attribs.push_back(EGL_GL_COLORSPACE_KHR);
1259 attribs.push_back(m_colorSpace);
1261 attribs.push_back(EGL_NONE);
1262 attribs.push_back(EGL_NONE);
1267 surface = eglu::createWindowSurface(nativeDisplay, *window, m_eglDisplay, m_eglConfig, attribs.data());
1269 catch (const eglu::Error& error)
1271 if (error.getError() == EGL_BAD_MATCH)
1272 TCU_THROW(NotSupportedError, "createWindowSurface is not supported for this config");
1276 TCU_CHECK(surface != EGL_NO_SURFACE);
1277 EGLU_CHECK_MSG(egl, "eglCreateWindowSurface()");
1279 doClearTest(surface);
1281 if (m_testAttribList.size() > 0)
1283 for (deUint32 i = 0; i < m_testAttribList.size(); i +=2)
1285 if (!egl.surfaceAttrib(m_eglDisplay, surface, m_testAttribList[i], m_testAttribList[i+1]))
1287 // Implementation can return EGL_BAD_PARAMETER if given value is not supported.
1288 EGLint error = egl.getError();
1289 if (error != EGL_BAD_PARAMETER)
1290 TCU_FAIL("Unable to set HDR metadata on surface");
1292 log << tcu::TestLog::Message <<
1293 "Warning: Metadata value " << m_testAttribList[i+1] << " for attrib 0x" <<
1294 std::hex << m_testAttribList[i] << std::dec <<
1295 " not supported by the implementation." << tcu::TestLog::EndMessage;
1296 m_testAttribList[i+1] = EGL_BAD_PARAMETER;
1299 for (deUint32 i = 0; i < m_testAttribList.size(); i +=2)
1301 // Skip unsupported values.
1302 if (m_testAttribList[i+1] == EGL_BAD_PARAMETER)
1306 egl.querySurface(m_eglDisplay, surface, m_testAttribList[i], &value);
1307 TCU_CHECK(value == m_testAttribList[i+1]);
1311 egl.destroySurface(m_eglDisplay, surface);
1312 EGLU_CHECK_MSG(egl, "eglDestroySurface()");
1314 else if (m_surfaceType & EGL_PIXMAP_BIT)
1316 log << tcu::TestLog::Message << "Test Pixmap" << tcu::TestLog::EndMessage;
1318 const eglu::NativePixmapFactory& pixmapFactory = eglu::selectNativePixmapFactory(displayFactory, m_testCtx.getCommandLine());
1320 de::UniquePtr<eglu::NativePixmap> pixmap (pixmapFactory.createPixmap(&nativeDisplay, m_eglDisplay, m_eglConfig, DE_NULL, 128, 128));
1321 const EGLSurface surface = eglu::createPixmapSurface(nativeDisplay, *pixmap, m_eglDisplay, m_eglConfig, DE_NULL);
1322 TCU_CHECK(surface != EGL_NO_SURFACE);
1323 EGLU_CHECK_MSG(egl, "eglCreatePixmapSurface()");
1325 doClearTest(surface);
1327 egl.destroySurface(m_eglDisplay, surface);
1328 EGLU_CHECK_MSG(egl, "eglDestroySurface()");
1331 TCU_FAIL("No valid surface types supported in config");
1334 TestCase::IterateResult WideColorSurfaceTest::iterate (void)
1336 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
1343 WideColorTests::WideColorTests (EglTestContext& eglTestCtx)
1344 : TestCaseGroup(eglTestCtx, "wide_color", "Wide Color tests")
1348 void WideColorTests::init (void)
1350 addChild(new WideColorFP16Test(m_eglTestCtx, "fp16", "Verify that FP16 pixel format is present"));
1351 addChild(new WideColor1010102Test(m_eglTestCtx, "1010102", "Check if 1010102 pixel format is present"));
1353 // This is an increment FP16 can do between -1.0 to 1.0
1354 const float fp16Increment1 = deFloatPow(2.0, -11.0);
1355 // This is an increment FP16 can do between 1.0 to 2.0
1356 const float fp16Increment2 = deFloatPow(2.0, -10.0);
1358 std::vector<Iteration> iterations;
1359 // -0.333251953125f ~ -1/3 as seen in FP16
1360 // Negative values will be 0 on read with fixed point pixel formats
1361 iterations.push_back(Iteration(-0.333251953125f, fp16Increment1, 10));
1363 iterations.push_back(Iteration(-fp16Increment1 * 5.0f, fp16Increment1, 10));
1364 // test crossing 1.0
1365 // Values > 1.0 will be truncated to 1.0 with fixed point pixel formats
1366 iterations.push_back(Iteration(1.0f - fp16Increment2 * 5.0f, fp16Increment2, 10));
1368 const EGLint windowAttribListFP16[] =
1370 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
1371 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
1376 EGL_COLOR_COMPONENT_TYPE_EXT, EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT,
1379 addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_fp16_default_colorspace", "FP16 window surface has FP16 pixels in it", windowAttribListFP16, EGL_NONE, iterations));
1380 addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_fp16_colorspace_srgb", "FP16 window surface, explicit sRGB colorspace", windowAttribListFP16, EGL_GL_COLORSPACE_SRGB_KHR, iterations));
1381 addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_fp16_colorspace_p3", "FP16 window surface, explicit Display-P3 colorspace", windowAttribListFP16, EGL_GL_COLORSPACE_DISPLAY_P3_EXT, iterations));
1382 addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_fp16_colorspace_p3_passthrough", "FP16 window surface, explicit Display-P3 colorspace", windowAttribListFP16, EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT, iterations));
1383 addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_fp16_colorspace_scrgb", "FP16 window surface, explicit scRGB colorspace", windowAttribListFP16, EGL_GL_COLORSPACE_SCRGB_EXT, iterations));
1384 addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_fp16_colorspace_scrgb_linear", "FP16 window surface, explicit scRGB linear colorspace", windowAttribListFP16, EGL_GL_COLORSPACE_SCRGB_LINEAR_EXT, iterations));
1386 const EGLint pbufferAttribListFP16[] =
1388 EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
1389 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
1394 EGL_COLOR_COMPONENT_TYPE_EXT, EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT,
1397 addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_fp16_default_colorspace", "FP16 pbuffer surface has FP16 pixels in it", pbufferAttribListFP16, EGL_NONE, iterations));
1398 addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_fp16_colorspace_srgb", "FP16 pbuffer surface, explicit sRGB colorspace", pbufferAttribListFP16, EGL_GL_COLORSPACE_SRGB_KHR, iterations));
1399 addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_fp16_colorspace_p3", "FP16 pbuffer surface, explicit Display-P3 colorspace", pbufferAttribListFP16, EGL_GL_COLORSPACE_DISPLAY_P3_EXT, iterations));
1400 addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_fp16_colorspace_p3_passthrough", "FP16 pbuffer surface, explicit Display-P3 colorspace", pbufferAttribListFP16, EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT, iterations));
1401 addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_fp16_colorspace_scrgb", "FP16 pbuffer surface, explicit scRGB colorspace", pbufferAttribListFP16, EGL_GL_COLORSPACE_SCRGB_EXT, iterations));
1402 addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_fp16_colorspace_scrgb_linear", "FP16 pbuffer surface, explicit scRGB linear colorspace", pbufferAttribListFP16, EGL_GL_COLORSPACE_SCRGB_LINEAR_EXT, iterations));
1404 const EGLint windowAttribList1010102[] =
1406 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
1407 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
1414 addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_1010102_colorspace_default", "1010102 Window surface, default (sRGB) colorspace", windowAttribList1010102, EGL_NONE, iterations));
1415 addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_1010102_colorspace_srgb", "1010102 Window surface, explicit sRGB colorspace", windowAttribList1010102, EGL_GL_COLORSPACE_SRGB_KHR, iterations));
1416 addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_1010102_colorspace_p3", "1010102 Window surface, explicit Display-P3 colorspace", windowAttribList1010102, EGL_GL_COLORSPACE_DISPLAY_P3_EXT, iterations));
1417 addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_1010102_colorspace_p3_passthrough", "1010102 Window surface, explicit Display-P3 colorspace", windowAttribList1010102, EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT, iterations));
1419 const EGLint pbufferAttribList1010102[] =
1421 EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
1422 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
1429 addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_1010102_colorspace_default", "1010102 pbuffer surface, default (sRGB) colorspace", pbufferAttribList1010102, EGL_NONE, iterations));
1430 addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_1010102_colorspace_srgb", "1010102 pbuffer surface, explicit sRGB colorspace", pbufferAttribList1010102, EGL_GL_COLORSPACE_SRGB_KHR, iterations));
1431 addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_1010102_colorspace_p3", "1010102 pbuffer surface, explicit Display-P3 colorspace", pbufferAttribList1010102, EGL_GL_COLORSPACE_DISPLAY_P3_EXT, iterations));
1432 addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_1010102_colorspace_p3_passthrough", "1010102 pbuffer surface, explicit Display-P3 colorspace", pbufferAttribList1010102, EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT, iterations));
1434 const EGLint windowAttribList8888[] =
1436 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
1437 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
1444 addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_8888_colorspace_default", "8888 window surface, default (sRGB) colorspace", windowAttribList8888, EGL_NONE, iterations));
1445 addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_8888_colorspace_srgb", "8888 window surface, explicit sRGB colorspace", windowAttribList8888, EGL_GL_COLORSPACE_SRGB_KHR, iterations));
1446 addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_8888_colorspace_p3", "8888 window surface, explicit Display-P3 colorspace", windowAttribList8888, EGL_GL_COLORSPACE_DISPLAY_P3_EXT, iterations));
1447 addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_8888_colorspace_p3_passthrough", "8888 window surface, explicit Display-P3 colorspace", windowAttribList8888, EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT, iterations));
1449 const EGLint pbufferAttribList8888[] =
1451 EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
1452 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
1459 addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_8888_colorspace_default", "8888 pbuffer surface, default (sRGB) colorspace", pbufferAttribList8888, EGL_NONE, iterations));
1460 addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_8888_colorspace_srgb", "8888 pbuffer surface, explicit sRGB colorspace", pbufferAttribList8888, EGL_GL_COLORSPACE_SRGB_KHR, iterations));
1461 addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_8888_colorspace_p3", "8888 pbuffer surface, explicit Display-P3 colorspace", pbufferAttribList8888, EGL_GL_COLORSPACE_DISPLAY_P3_EXT, iterations));
1462 addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_8888_colorspace_p3_passthrough", "8888 pbuffer surface, explicit Display-P3 colorspace", pbufferAttribList8888, EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT, iterations));
1464 const EGLint windowAttribList888[] =
1466 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
1467 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
1473 addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_888_colorspace_default", "888 window surface, default (sRGB) colorspace", windowAttribList888, EGL_NONE, iterations));
1474 addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_888_colorspace_srgb", "888 window surface, explicit sRGB colorspace", windowAttribList888, EGL_GL_COLORSPACE_SRGB_KHR, iterations));
1475 addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_888_colorspace_p3", "888 window surface, explicit Display-P3 colorspace", windowAttribList888, EGL_GL_COLORSPACE_DISPLAY_P3_EXT, iterations));
1476 addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_888_colorspace_p3_passthrough", "888 window surface, explicit Display-P3 colorspace", windowAttribList888, EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT, iterations));
1478 const EGLint pbufferAttribList888[] =
1480 EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
1481 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
1487 addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_888_colorspace_default", "888 pbuffer surface, default (sRGB) colorspace", pbufferAttribList888, EGL_NONE, iterations));
1488 addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_888_colorspace_srgb", "888 pbuffer surface, explicit sRGB colorspace", pbufferAttribList888, EGL_GL_COLORSPACE_SRGB_KHR, iterations));
1489 addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_888_colorspace_p3", "888 pbuffer surface, explicit Display-P3 colorspace", pbufferAttribList888, EGL_GL_COLORSPACE_DISPLAY_P3_EXT, iterations));
1490 addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_888_colorspace_p3_passthrough", "888 pbuffer surface, explicit Display-P3 colorspace", pbufferAttribList888, EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT, iterations));
1494 TestCaseGroup* createWideColorTests (EglTestContext& eglTestCtx)
1496 return new WideColorTests(eglTestCtx);
1499 class Smpte2086ColorTest : public WideColorTest
1502 Smpte2086ColorTest (EglTestContext& eglTestCtx,
1504 const char* description);
1506 void executeTest (void);
1507 IterateResult iterate (void);
1510 Smpte2086ColorTest::Smpte2086ColorTest (EglTestContext& eglTestCtx, const char* name, const char* description)
1511 : WideColorTest(eglTestCtx, name, description)
1515 #define METADATA_SCALE(x) (static_cast<EGLint>(x * EGL_METADATA_SCALING_EXT))
1517 void Smpte2086ColorTest::executeTest (void)
1519 tcu::TestLog& log = m_testCtx.getLog();
1520 const Library& egl = m_eglTestCtx.getLibrary();
1521 egl.bindAPI(EGL_OPENGL_ES_API);
1523 log << tcu::TestLog::Message << "Test SMPTE 2086 Metadata on Window" << tcu::TestLog::EndMessage;
1527 // This is an increment FP16 can do between -1.0 to 1.0
1528 const float fp16Increment1 = deFloatPow(2.0, -11.0);
1529 // This is an increment FP16 can do between 1.0 to 2.0
1530 const float fp16Increment2 = deFloatPow(2.0, -10.0);
1532 std::vector<Iteration> int8888Iterations;
1533 // -0.333251953125f ~ -1/3 as seen in fp16
1534 // Negative values will be 0 on read with fixed point pixel formats
1535 int8888Iterations.push_back(Iteration(-0.333251953125f, fp16Increment1, 10));
1537 int8888Iterations.push_back(Iteration(-fp16Increment1 * 5.0f, fp16Increment1, 10));
1538 // test crossing 1.0
1539 // Values > 1.0 will be truncated to 1.0 with fixed point pixel formats
1540 int8888Iterations.push_back(Iteration(1.0f - fp16Increment2 * 5.0f, fp16Increment2, 10));
1542 const EGLint windowAttribList8888[] =
1544 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
1545 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
1553 WideColorSurfaceTest testObj(m_eglTestCtx, "window_8888_colorspace_default", "8888 window surface, default (sRGB) colorspace", windowAttribList8888, EGL_NONE, int8888Iterations);
1555 const EGLint testAttrs[] =
1557 EGL_SMPTE2086_DISPLAY_PRIMARY_RX_EXT, METADATA_SCALE(0.680),
1558 EGL_SMPTE2086_DISPLAY_PRIMARY_RY_EXT, METADATA_SCALE(0.320),
1559 EGL_SMPTE2086_DISPLAY_PRIMARY_GX_EXT, METADATA_SCALE(0.265),
1560 EGL_SMPTE2086_DISPLAY_PRIMARY_GY_EXT, METADATA_SCALE(0.690),
1561 EGL_SMPTE2086_DISPLAY_PRIMARY_BX_EXT, METADATA_SCALE(0.440),
1562 EGL_SMPTE2086_DISPLAY_PRIMARY_BY_EXT, METADATA_SCALE(0.320),
1563 EGL_SMPTE2086_WHITE_POINT_X_EXT, METADATA_SCALE(0.2200),
1564 EGL_SMPTE2086_WHITE_POINT_Y_EXT, METADATA_SCALE(0.2578),
1565 EGL_SMPTE2086_MAX_LUMINANCE_EXT, METADATA_SCALE(1.31),
1566 EGL_SMPTE2086_MIN_LUMINANCE_EXT, METADATA_SCALE(0.123),
1569 testObj.addTestAttributes(testAttrs);
1572 testObj.executeTest();
1575 TestCase::IterateResult Smpte2086ColorTest::iterate (void)
1577 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
1582 class Cta8613ColorTest : public WideColorTest
1585 Cta8613ColorTest (EglTestContext& eglTestCtx,
1587 const char* description);
1589 void executeTest (void);
1590 IterateResult iterate (void);
1593 Cta8613ColorTest::Cta8613ColorTest (EglTestContext& eglTestCtx, const char* name, const char* description)
1594 : WideColorTest(eglTestCtx, name, description)
1598 #define METADATA_SCALE(x) (static_cast<EGLint>(x * EGL_METADATA_SCALING_EXT))
1600 void Cta8613ColorTest::executeTest (void)
1602 tcu::TestLog& log = m_testCtx.getLog();
1603 const Library& egl = m_eglTestCtx.getLibrary();
1604 egl.bindAPI(EGL_OPENGL_ES_API);
1606 log << tcu::TestLog::Message << "Test CTA 861.3 Metadata on Window" << tcu::TestLog::EndMessage;
1610 // This is an increment FP16 can do between -1.0 to 1.0
1611 const float fp16Increment1 = deFloatPow(2.0, -11.0);
1612 // This is an increment FP16 can do between 1.0 to 2.0
1613 const float fp16Increment2 = deFloatPow(2.0, -10.0);
1615 std::vector<Iteration> int8888Iterations;
1616 // -0.333251953125f ~ -1/3 as seen in fp16
1617 // Negative values will be 0 on read with fixed point pixel formats
1618 int8888Iterations.push_back(Iteration(-0.333251953125f, fp16Increment1, 10));
1620 int8888Iterations.push_back(Iteration(-fp16Increment1 * 5.0f, fp16Increment1, 10));
1621 // test crossing 1.0
1622 // Values > 1.0 will be truncated to 1.0 with fixed point pixel formats
1623 int8888Iterations.push_back(Iteration(1.0f - fp16Increment2 * 5.0f, fp16Increment2, 10));
1625 const EGLint windowAttribList8888[] =
1627 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
1628 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
1636 WideColorSurfaceTest testObj(m_eglTestCtx, "window_8888_colorspace_default", "8888 window surface, default (sRGB) colorspace", windowAttribList8888, EGL_NONE, int8888Iterations);
1638 const EGLint testAttrs[] =
1640 EGL_CTA861_3_MAX_CONTENT_LIGHT_LEVEL_EXT, METADATA_SCALE(1.31),
1641 EGL_CTA861_3_MAX_FRAME_AVERAGE_LEVEL_EXT, METADATA_SCALE(0.6),
1644 testObj.addTestAttributes(testAttrs);
1647 testObj.executeTest();
1650 TestCase::IterateResult Cta8613ColorTest::iterate (void)
1652 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
1657 class HdrColorTests : public TestCaseGroup
1660 HdrColorTests (EglTestContext& eglTestCtx);
1664 HdrColorTests (const HdrColorTests&);
1665 HdrColorTests& operator= (const HdrColorTests&);
1668 HdrColorTests::HdrColorTests (EglTestContext& eglTestCtx)
1669 : TestCaseGroup(eglTestCtx, "hdr_metadata", "HDR Metadata tests")
1673 void HdrColorTests::init (void)
1675 addChild(new Smpte2086ColorTest(m_eglTestCtx, "smpte2086", "Verify that SMPTE 2086 extension exists"));
1676 addChild(new Cta8613ColorTest(m_eglTestCtx, "cta861_3", "Verify that CTA 861.3 extension exists"));
1679 TestCaseGroup* createHdrColorTests (EglTestContext& eglTestCtx)
1681 return new HdrColorTests(eglTestCtx);