| /*------------------------------------------------------------------------- |
| * drawElements Quality Program EGL Module |
| * --------------------------------------- |
| * |
| * Copyright 2017 The Android Open Source Project |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| * |
| *//*! |
| * \file |
| * \brief Test KHR_wide_color |
| *//*--------------------------------------------------------------------*/ |
| |
| #include "teglWideColorTests.hpp" |
| |
| #include "tcuImageCompare.hpp" |
| #include "tcuTestLog.hpp" |
| #include "tcuSurface.hpp" |
| #include "tcuTextureUtil.hpp" |
| |
| #include "egluNativeWindow.hpp" |
| #include "egluStrUtil.hpp" |
| #include "egluUtil.hpp" |
| #include "egluConfigFilter.hpp" |
| |
| #include "eglwLibrary.hpp" |
| #include "eglwEnums.hpp" |
| |
| #include "gluDefs.hpp" |
| #include "gluRenderContext.hpp" |
| #include "gluContextInfo.hpp" |
| #include "gluShaderProgram.hpp" |
| |
| #include "glw.h" |
| #include "glwDefs.hpp" |
| #include "glwEnums.hpp" |
| #include "glwFunctions.hpp" |
| |
| #include "deMath.h" |
| #include "deRandom.hpp" |
| #include "deString.h" |
| #include "deStringUtil.hpp" |
| |
| #include <string> |
| #include <vector> |
| #include <sstream> |
| |
| using std::string; |
| using std::vector; |
| using glw::GLubyte; |
| using glw::GLfloat; |
| using tcu::IVec2; |
| |
| using namespace eglw; |
| |
| namespace deqp |
| { |
| namespace egl |
| { |
| namespace |
| { |
| |
| typedef tcu::Vec4 Color; |
| |
| class GLES2Renderer; |
| |
| class ReferenceRenderer; |
| |
| class WideColorTests : public TestCaseGroup |
| { |
| public: |
| WideColorTests (EglTestContext& eglTestCtx); |
| void init (void); |
| |
| private: |
| WideColorTests (const WideColorTests&); |
| WideColorTests& operator= (const WideColorTests&); |
| }; |
| |
| class WideColorTest : public TestCase |
| { |
| public: |
| enum DrawType |
| { |
| DRAWTYPE_GLES2_CLEAR, |
| DRAWTYPE_GLES2_RENDER |
| }; |
| |
| WideColorTest (EglTestContext& eglTestCtx, const char* name, const char* description); |
| ~WideColorTest (void); |
| |
| void init (void); |
| void deinit (void); |
| void checkPixelFloatSupport (void); |
| void checkColorSpaceSupport (void); |
| void checkDisplayP3Support (void); |
| void checkDisplayP3PassthroughSupport (void); |
| void check1010102Support (void); |
| void checkFP16Support (void); |
| void checkSCRGBSupport (void); |
| void checkSCRGBLinearSupport (void); |
| void checkbt2020linear (void); |
| void checkbt2020pq (void); |
| void checkSMPTE2086 (void); |
| void checkCTA861_3 (void); |
| |
| protected: |
| void initEGLSurface (EGLConfig config); |
| void initEGLContext (EGLConfig config); |
| |
| EGLDisplay m_eglDisplay; |
| glw::Functions m_gl; |
| }; |
| |
| struct ColoredRect |
| { |
| public: |
| ColoredRect (const IVec2& bottomLeft_, const IVec2& topRight_, const Color& color_); |
| IVec2 bottomLeft; |
| IVec2 topRight; |
| Color color; |
| }; |
| |
| ColoredRect::ColoredRect (const IVec2& bottomLeft_, const IVec2& topRight_, const Color& color_) |
| : bottomLeft (bottomLeft_) |
| , topRight (topRight_) |
| , color (color_) |
| { |
| } |
| |
| void clearColorScreen (const glw::Functions& gl, const Color& clearColor) |
| { |
| gl.clearColor(clearColor.x(), clearColor.y(), clearColor.z(), clearColor.w()); |
| gl.clear(GL_COLOR_BUFFER_BIT); |
| } |
| |
| float windowToDeviceCoordinates (int x, int length) |
| { |
| return (2.0f * float(x) / float(length)) - 1.0f; |
| } |
| |
| class GLES2Renderer |
| { |
| public: |
| GLES2Renderer (const glw::Functions& gl, int width, int height); |
| ~GLES2Renderer (void); |
| void render (const ColoredRect& coloredRect) const; |
| |
| private: |
| GLES2Renderer (const GLES2Renderer&); |
| GLES2Renderer& operator= (const GLES2Renderer&); |
| |
| const glw::Functions& m_gl; |
| glu::ShaderProgram m_glProgram; |
| glw::GLuint m_coordLoc; |
| glw::GLuint m_colorLoc; |
| glw::GLuint m_bufWidth; |
| glw::GLuint m_bufHeight; |
| }; |
| |
| // generate sources for vertex and fragment buffer |
| glu::ProgramSources getSources (void) |
| { |
| const char* const vertexShaderSource = |
| "attribute mediump vec2 a_pos;\n" |
| "attribute mediump vec4 a_color;\n" |
| "varying mediump vec4 v_color;\n" |
| "void main(void)\n" |
| "{\n" |
| "\tv_color = a_color;\n" |
| "\tgl_Position = vec4(a_pos, 0.0, 1.0);\n" |
| "}"; |
| |
| const char* const fragmentShaderSource = |
| "varying mediump vec4 v_color;\n" |
| "void main(void)\n" |
| "{\n" |
| "\tgl_FragColor = v_color;\n" |
| "}"; |
| |
| return glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource); |
| } |
| |
| GLES2Renderer::GLES2Renderer (const glw::Functions& gl, int width, int height) |
| : m_gl (gl) |
| , m_glProgram (gl, getSources()) |
| , m_coordLoc ((glw::GLuint)-1) |
| , m_colorLoc ((glw::GLuint)-1) |
| , m_bufWidth (width) |
| , m_bufHeight (height) |
| { |
| m_colorLoc = m_gl.getAttribLocation(m_glProgram.getProgram(), "a_color"); |
| m_coordLoc = m_gl.getAttribLocation(m_glProgram.getProgram(), "a_pos"); |
| GLU_EXPECT_NO_ERROR(m_gl.getError(), "Failed to get attribute locations"); |
| } |
| |
| GLES2Renderer::~GLES2Renderer (void) |
| { |
| } |
| |
| void GLES2Renderer::render (const struct ColoredRect &coloredRect) const |
| { |
| const float x1 = windowToDeviceCoordinates(coloredRect.bottomLeft.x(), m_bufWidth); |
| const float y1 = windowToDeviceCoordinates(coloredRect.bottomLeft.y(), m_bufHeight); |
| const float x2 = windowToDeviceCoordinates(coloredRect.topRight.x(), m_bufWidth); |
| const float y2 = windowToDeviceCoordinates(coloredRect.topRight.y(), m_bufHeight); |
| |
| const glw::GLfloat coords[] = |
| { |
| x1, y1, 0.0f, 1.0f, |
| x1, y2, 0.0f, 1.0f, |
| x2, y2, 0.0f, 1.0f, |
| |
| x2, y2, 0.0f, 1.0f, |
| x2, y1, 0.0f, 1.0f, |
| x1, y1, 0.0f, 1.0f |
| }; |
| |
| const glw::GLfloat colors[] = |
| { |
| coloredRect.color.x(), coloredRect.color.y(), coloredRect.color.z(), coloredRect.color.w(), |
| coloredRect.color.x(), coloredRect.color.y(), coloredRect.color.z(), coloredRect.color.w(), |
| coloredRect.color.x(), coloredRect.color.y(), coloredRect.color.z(), coloredRect.color.w(), |
| |
| coloredRect.color.x(), coloredRect.color.y(), coloredRect.color.z(), coloredRect.color.w(), |
| coloredRect.color.x(), coloredRect.color.y(), coloredRect.color.z(), coloredRect.color.w(), |
| coloredRect.color.x(), coloredRect.color.y(), coloredRect.color.z(), coloredRect.color.w(), |
| }; |
| |
| m_gl.useProgram(m_glProgram.getProgram()); |
| GLU_EXPECT_NO_ERROR(m_gl.getError(), "glUseProgram() failed"); |
| |
| m_gl.enableVertexAttribArray(m_coordLoc); |
| m_gl.enableVertexAttribArray(m_colorLoc); |
| GLU_EXPECT_NO_ERROR(m_gl.getError(), "Failed to enable attributes"); |
| |
| m_gl.vertexAttribPointer(m_coordLoc, 4, GL_FLOAT, GL_FALSE, 0, coords); |
| m_gl.vertexAttribPointer(m_colorLoc, 4, GL_FLOAT, GL_TRUE, 0, colors); |
| GLU_EXPECT_NO_ERROR(m_gl.getError(), "Failed to set attribute pointers"); |
| |
| m_gl.drawArrays(GL_TRIANGLES, 0, DE_LENGTH_OF_ARRAY(coords)/4); |
| GLU_EXPECT_NO_ERROR(m_gl.getError(), "glDrawArrays(), failed"); |
| |
| m_gl.disableVertexAttribArray(m_coordLoc); |
| m_gl.disableVertexAttribArray(m_colorLoc); |
| GLU_EXPECT_NO_ERROR(m_gl.getError(), "Failed to disable attributes"); |
| |
| m_gl.useProgram(0); |
| GLU_EXPECT_NO_ERROR(m_gl.getError(), "glUseProgram() failed"); |
| } |
| |
| class ReferenceRenderer |
| { |
| public: |
| ReferenceRenderer (void); |
| private: |
| ReferenceRenderer (const ReferenceRenderer&); |
| ReferenceRenderer& operator= (const ReferenceRenderer&); |
| }; |
| |
| WideColorTest::WideColorTest (EglTestContext& eglTestCtx, const char* name, const char* description) |
| : TestCase (eglTestCtx, name, description) |
| , m_eglDisplay (EGL_NO_DISPLAY) |
| { |
| } |
| |
| WideColorTest::~WideColorTest (void) |
| { |
| deinit(); |
| } |
| |
| void WideColorTest::init (void) |
| { |
| m_eglDisplay = eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay()); |
| |
| m_eglTestCtx.initGLFunctions(&m_gl, glu::ApiType::es(2,0)); |
| } |
| |
| void WideColorTest::checkPixelFloatSupport (void) |
| { |
| const Library& egl = m_eglTestCtx.getLibrary(); |
| |
| if (!eglu::hasExtension(egl, m_eglDisplay, "EGL_EXT_pixel_format_float")) |
| TCU_THROW(NotSupportedError, "EGL_EXT_pixel_format_float is not supported"); |
| } |
| |
| void WideColorTest::checkColorSpaceSupport (void) |
| { |
| const Library& egl = m_eglTestCtx.getLibrary(); |
| |
| if (!eglu::hasExtension(egl, m_eglDisplay, "EGL_KHR_gl_colorspace")) |
| TCU_THROW(NotSupportedError, "EGL_KHR_gl_colorspace is not supported"); |
| } |
| |
| void WideColorTest::checkDisplayP3Support (void) |
| { |
| const Library& egl = m_eglTestCtx.getLibrary(); |
| |
| if (!eglu::hasExtension(egl, m_eglDisplay, "EGL_EXT_gl_colorspace_display_p3")) |
| TCU_THROW(NotSupportedError, "EGL_EXT_gl_colorspace_display_p3 is not supported"); |
| } |
| |
| void WideColorTest::checkDisplayP3PassthroughSupport (void) |
| { |
| const Library& egl = m_eglTestCtx.getLibrary(); |
| |
| if (!eglu::hasExtension(egl, m_eglDisplay, "EGL_EXT_gl_colorspace_display_p3_passthrough")) |
| TCU_THROW(NotSupportedError, "EGL_EXT_gl_colorspace_display_p3_passthrough is not supported"); |
| } |
| |
| void WideColorTest::checkSCRGBSupport (void) |
| { |
| const Library& egl = m_eglTestCtx.getLibrary(); |
| |
| if (!eglu::hasExtension(egl, m_eglDisplay, "EGL_EXT_gl_colorspace_scrgb")) |
| TCU_THROW(NotSupportedError, "EGL_EXT_gl_colorspace_scrgb is not supported"); |
| } |
| |
| void WideColorTest::checkSCRGBLinearSupport (void) |
| { |
| const Library& egl = m_eglTestCtx.getLibrary(); |
| |
| if (!eglu::hasExtension(egl, m_eglDisplay, "EGL_EXT_gl_colorspace_scrgb_linear")) |
| TCU_THROW(NotSupportedError, "EGL_EXT_gl_colorspace_scrgb_linear is not supported"); |
| } |
| |
| void WideColorTest::checkbt2020linear (void) |
| { |
| const Library& egl = m_eglTestCtx.getLibrary(); |
| |
| if (!eglu::hasExtension(egl, m_eglDisplay, "EGL_EXT_gl_colorspace_bt2020_linear")) |
| TCU_THROW(NotSupportedError, "EGL_EXT_gl_colorspace_bt2020_linear is not supported"); |
| } |
| |
| void WideColorTest::checkbt2020pq (void) |
| { |
| const Library& egl = m_eglTestCtx.getLibrary(); |
| |
| if (!eglu::hasExtension(egl, m_eglDisplay, "EGL_EXT_gl_colorspace_bt2020_pq")) |
| TCU_THROW(NotSupportedError, "EGL_EXT_gl_colorspace_bt2020_pq is not supported"); |
| } |
| |
| void WideColorTest::checkSMPTE2086 (void) |
| { |
| const Library& egl = m_eglTestCtx.getLibrary(); |
| |
| if (!eglu::hasExtension(egl, m_eglDisplay, "EGL_EXT_surface_SMPTE2086_metadata")) |
| TCU_THROW(NotSupportedError, "EGL_EXT_surface_SMPTE2086_metadata is not supported"); |
| } |
| |
| void WideColorTest::checkCTA861_3 (void) |
| { |
| const Library& egl = m_eglTestCtx.getLibrary(); |
| |
| if (!eglu::hasExtension(egl, m_eglDisplay, "EGL_EXT_surface_CTA861_3_metadata")) |
| TCU_THROW(NotSupportedError, "EGL_EXT_surface_CTA861_3_metadata is not supported"); |
| } |
| |
| void WideColorTest::check1010102Support (void) |
| { |
| const Library& egl = m_eglTestCtx.getLibrary(); |
| tcu::TestLog& log = m_testCtx.getLog(); |
| |
| const EGLint attribList[] = |
| { |
| EGL_SURFACE_TYPE, EGL_WINDOW_BIT, |
| EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, |
| EGL_RED_SIZE, 10, |
| EGL_GREEN_SIZE, 10, |
| EGL_BLUE_SIZE, 10, |
| EGL_ALPHA_SIZE, 2, |
| EGL_NONE, EGL_NONE |
| }; |
| EGLint numConfigs = 0; |
| EGLConfig config; |
| |
| // Query from EGL implementation |
| EGLU_CHECK_CALL(egl, chooseConfig(m_eglDisplay, &attribList[0], DE_NULL, 0, &numConfigs)); |
| |
| if (numConfigs <= 0) |
| { |
| log << tcu::TestLog::Message << "No configs returned." << tcu::TestLog::EndMessage; |
| TCU_THROW(NotSupportedError, "10:10:10:2 pixel format is not supported"); |
| } |
| |
| log << tcu::TestLog::Message << numConfigs << " configs returned" << tcu::TestLog::EndMessage; |
| |
| EGLU_CHECK_CALL(egl, chooseConfig(m_eglDisplay, &attribList[0], &config, 1, &numConfigs)); |
| if (numConfigs > 1) |
| { |
| log << tcu::TestLog::Message << "Fail, more configs returned than requested." << tcu::TestLog::EndMessage; |
| TCU_FAIL("Too many configs returned"); |
| } |
| |
| EGLint components[4]; |
| |
| EGLU_CHECK_CALL(egl, getConfigAttrib(m_eglDisplay, config, EGL_RED_SIZE, &components[0])); |
| EGLU_CHECK_CALL(egl, getConfigAttrib(m_eglDisplay, config, EGL_GREEN_SIZE, &components[1])); |
| EGLU_CHECK_CALL(egl, getConfigAttrib(m_eglDisplay, config, EGL_BLUE_SIZE, &components[2])); |
| EGLU_CHECK_CALL(egl, getConfigAttrib(m_eglDisplay, config, EGL_ALPHA_SIZE, &components[3])); |
| |
| TCU_CHECK_MSG(components[0] == 10, "Missing 10bit deep red channel"); |
| TCU_CHECK_MSG(components[1] == 10, "Missing 10bit deep green channel"); |
| TCU_CHECK_MSG(components[2] == 10, "Missing 10bit deep blue channel"); |
| TCU_CHECK_MSG(components[3] == 2, "Missing 2bit deep alpha channel"); |
| } |
| |
| void WideColorTest::checkFP16Support (void) |
| { |
| const Library& egl = m_eglTestCtx.getLibrary(); |
| tcu::TestLog& log = m_testCtx.getLog(); |
| EGLint numConfigs = 0; |
| EGLConfig config; |
| |
| const EGLint attribList[] = |
| { |
| EGL_SURFACE_TYPE, EGL_WINDOW_BIT, |
| EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, |
| EGL_RED_SIZE, 16, |
| EGL_GREEN_SIZE, 16, |
| EGL_BLUE_SIZE, 16, |
| EGL_ALPHA_SIZE, 16, |
| EGL_COLOR_COMPONENT_TYPE_EXT, EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT, |
| EGL_NONE, EGL_NONE |
| }; |
| |
| // Query from EGL implementation |
| EGLU_CHECK_CALL(egl, chooseConfig(m_eglDisplay, &attribList[0], DE_NULL, 0, &numConfigs)); |
| |
| if (numConfigs <= 0) |
| { |
| log << tcu::TestLog::Message << "No configs returned." << tcu::TestLog::EndMessage; |
| TCU_THROW(NotSupportedError, "16:16:16:16 pixel format is not supported"); |
| } |
| |
| log << tcu::TestLog::Message << numConfigs << " configs returned" << tcu::TestLog::EndMessage; |
| |
| EGLBoolean success = egl.chooseConfig(m_eglDisplay, &attribList[0], &config, 1, &numConfigs); |
| if (success != EGL_TRUE) |
| { |
| log << tcu::TestLog::Message << "Fail, eglChooseConfig returned an error." << tcu::TestLog::EndMessage; |
| TCU_FAIL("eglChooseConfig failed"); |
| } |
| if (numConfigs > 1) |
| { |
| log << tcu::TestLog::Message << "Fail, more configs returned than requested." << tcu::TestLog::EndMessage; |
| TCU_FAIL("Too many configs returned"); |
| } |
| |
| EGLint components[4]; |
| |
| success = egl.getConfigAttrib(m_eglDisplay, config, EGL_RED_SIZE, &components[0]); |
| TCU_CHECK_MSG(success == EGL_TRUE, "eglGetConfigAttrib failed"); |
| EGLU_CHECK(egl); |
| success = egl.getConfigAttrib(m_eglDisplay, config, EGL_GREEN_SIZE, &components[1]); |
| TCU_CHECK_MSG(success == EGL_TRUE, "eglGetConfigAttrib failed"); |
| EGLU_CHECK(egl); |
| success = egl.getConfigAttrib(m_eglDisplay, config, EGL_BLUE_SIZE, &components[2]); |
| TCU_CHECK_MSG(success == EGL_TRUE, "eglGetConfigAttrib failed"); |
| EGLU_CHECK(egl); |
| success = egl.getConfigAttrib(m_eglDisplay, config, EGL_ALPHA_SIZE, &components[3]); |
| TCU_CHECK_MSG(success == EGL_TRUE, "eglGetConfigAttrib failed"); |
| EGLU_CHECK(egl); |
| |
| TCU_CHECK_MSG(components[0] == 16, "Missing 16bit deep red channel"); |
| TCU_CHECK_MSG(components[1] == 16, "Missing 16bit deep green channel"); |
| TCU_CHECK_MSG(components[2] == 16, "Missing 16bit deep blue channel"); |
| TCU_CHECK_MSG(components[3] == 16, "Missing 16bit deep alpha channel"); |
| } |
| |
| void WideColorTest::deinit (void) |
| { |
| const Library& egl = m_eglTestCtx.getLibrary(); |
| |
| if (m_eglDisplay != EGL_NO_DISPLAY) |
| { |
| egl.terminate(m_eglDisplay); |
| m_eglDisplay = EGL_NO_DISPLAY; |
| } |
| } |
| |
| class WideColorFP16Test : public WideColorTest |
| { |
| public: |
| WideColorFP16Test (EglTestContext& eglTestCtx, const char* name, const char* description); |
| |
| void init (void); |
| void executeTest (void); |
| IterateResult iterate (void); |
| }; |
| |
| WideColorFP16Test::WideColorFP16Test (EglTestContext& eglTestCtx, |
| const char* name, |
| const char* description) |
| : WideColorTest(eglTestCtx, name, description) |
| { |
| } |
| |
| |
| void WideColorFP16Test::executeTest (void) |
| { |
| checkPixelFloatSupport(); |
| checkFP16Support(); |
| } |
| |
| TestCase::IterateResult WideColorFP16Test::iterate (void) |
| { |
| m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); |
| executeTest(); |
| return STOP; |
| } |
| |
| void WideColorFP16Test::init (void) |
| { |
| WideColorTest::init(); |
| } |
| |
| class WideColor1010102Test : public WideColorTest |
| { |
| public: |
| WideColor1010102Test (EglTestContext& eglTestCtx, |
| const char* name, |
| const char* description); |
| |
| void executeTest (void); |
| IterateResult iterate (void); |
| }; |
| |
| WideColor1010102Test::WideColor1010102Test (EglTestContext& eglTestCtx, const char* name, const char* description) |
| : WideColorTest(eglTestCtx, name, description) |
| { |
| } |
| |
| void WideColor1010102Test::executeTest (void) |
| { |
| check1010102Support(); |
| } |
| |
| TestCase::IterateResult WideColor1010102Test::iterate (void) |
| { |
| m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); |
| executeTest(); |
| return STOP; |
| } |
| |
| struct Iteration |
| { |
| float start; |
| float increment; |
| int iterationCount; |
| Iteration(float s, float i, int c) |
| : start(s), increment(i), iterationCount(c) {} |
| }; |
| |
| class WideColorSurfaceTest : public WideColorTest |
| { |
| public: |
| WideColorSurfaceTest (EglTestContext& eglTestCtx, |
| const char* name, |
| const char* description, |
| const EGLint* attribList, |
| EGLint colorSpace, |
| const std::vector<Iteration>& iterations); |
| |
| void init (void); |
| void executeTest (void); |
| IterateResult iterate (void); |
| void addTestAttributes (const EGLint* attributes); |
| |
| protected: |
| void readPixels (const glw::Functions& gl, float* dataPtr); |
| void readPixels (const glw::Functions& gl, deUint32* dataPtr); |
| void readPixels (const glw::Functions& gl, deUint8* dataPtr); |
| deUint32 expectedUint10 (float reference); |
| deUint32 expectedUint2 (float reference); |
| deUint8 expectedUint8 (float reference); |
| deUint8 expectedAlpha8 (float reference); |
| bool checkWithThreshold8 (deUint8 value, deUint8 reference, deUint8 threshold = 1); |
| bool checkWithThreshold10 (deUint32 value, deUint32 reference, deUint32 threshold = 1); |
| bool checkWithThresholdFloat (float value, float reference, float threshold); |
| void doClearTest (EGLSurface surface); |
| void testPixels (float reference, float increment); |
| void testFramebufferColorEncoding (); |
| void writeEglConfig (EGLConfig config); |
| |
| private: |
| std::vector<EGLint> m_attribList; |
| std::vector<EGLint> m_testAttribList; |
| EGLConfig m_eglConfig; |
| EGLint m_surfaceType; |
| EGLint m_componentType; |
| EGLint m_requestedRedSize; |
| EGLint m_redSize; |
| EGLint m_alphaSize; |
| EGLint m_colorSpace; |
| const std::vector<struct Iteration> m_iterations; |
| std::stringstream m_debugLog; |
| }; |
| |
| WideColorSurfaceTest::WideColorSurfaceTest (EglTestContext& eglTestCtx, const char* name, const char* description, const EGLint* attribList, EGLint colorSpace, const std::vector<struct Iteration>& iterations) |
| : WideColorTest (eglTestCtx, name, description) |
| , m_surfaceType (0) |
| , m_componentType (EGL_COLOR_COMPONENT_TYPE_FIXED_EXT) |
| , m_requestedRedSize (0) |
| , m_redSize (0) |
| , m_alphaSize (0) |
| , m_colorSpace (colorSpace) |
| , m_iterations (iterations) |
| { |
| deUint32 idx = 0; |
| while (attribList[idx] != EGL_NONE) |
| { |
| if (attribList[idx] == EGL_COLOR_COMPONENT_TYPE_EXT) |
| { |
| m_componentType = attribList[idx + 1]; |
| } |
| else if (attribList[idx] == EGL_SURFACE_TYPE) |
| { |
| m_surfaceType = attribList[idx+1]; |
| } |
| else if (attribList[idx] == EGL_RED_SIZE) |
| { |
| m_requestedRedSize = attribList[idx + 1]; |
| } |
| m_attribList.push_back(attribList[idx++]); |
| m_attribList.push_back(attribList[idx++]); |
| } |
| m_attribList.push_back(EGL_NONE); |
| } |
| |
| void WideColorSurfaceTest::addTestAttributes(const EGLint *attributes) |
| { |
| deUint32 idx = 0; |
| if (attributes == DE_NULL) return; |
| |
| while (attributes[idx] != EGL_NONE) |
| { |
| m_testAttribList.push_back(attributes[idx++]); |
| m_testAttribList.push_back(attributes[idx++]); |
| } |
| } |
| |
| void WideColorSurfaceTest::init (void) |
| { |
| const Library& egl = m_eglTestCtx.getLibrary(); |
| tcu::TestLog& log = m_testCtx.getLog(); |
| |
| WideColorTest::init(); |
| |
| // Only check for pixel format required for this specific run |
| // If not available, check will abort test with "NotSupported" |
| switch (m_requestedRedSize) |
| { |
| case 10: |
| check1010102Support(); |
| break; |
| case 16: |
| checkPixelFloatSupport(); |
| checkFP16Support(); |
| break; |
| } |
| |
| if (m_colorSpace != EGL_NONE && !eglu::hasExtension(egl, m_eglDisplay, "EGL_KHR_gl_colorspace")) |
| TCU_THROW(NotSupportedError, "EGL_KHR_gl_colorspace is not supported"); |
| |
| switch (m_colorSpace) { |
| case EGL_GL_COLORSPACE_SRGB_KHR: |
| checkColorSpaceSupport(); |
| break; |
| case EGL_GL_COLORSPACE_DISPLAY_P3_EXT: |
| checkDisplayP3Support(); |
| break; |
| case EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT: |
| checkDisplayP3PassthroughSupport(); |
| break; |
| case EGL_GL_COLORSPACE_SCRGB_EXT: |
| checkSCRGBSupport(); |
| break; |
| case EGL_GL_COLORSPACE_SCRGB_LINEAR_EXT: |
| checkSCRGBLinearSupport(); |
| break; |
| case EGL_GL_COLORSPACE_BT2020_LINEAR_EXT: |
| checkbt2020linear(); |
| break; |
| case EGL_GL_COLORSPACE_BT2020_PQ_EXT: |
| checkbt2020pq(); |
| break; |
| default: |
| break; |
| } |
| |
| EGLint numConfigs = 0; |
| |
| // Query from EGL implementation |
| EGLU_CHECK_CALL(egl, chooseConfig(m_eglDisplay, &m_attribList[0], DE_NULL, 0, &numConfigs)); |
| |
| if (numConfigs <= 0) |
| { |
| log << tcu::TestLog::Message << "No configs returned." << tcu::TestLog::EndMessage; |
| TCU_THROW(NotSupportedError, "No configs available with the requested attributes"); |
| } |
| |
| log << tcu::TestLog::Message << numConfigs << " configs returned" << tcu::TestLog::EndMessage; |
| |
| EGLBoolean success = egl.chooseConfig(m_eglDisplay, &m_attribList[0], &m_eglConfig, 1, &numConfigs); |
| if (success != EGL_TRUE) |
| { |
| log << tcu::TestLog::Message << "Fail, eglChooseConfig returned an error." << tcu::TestLog::EndMessage; |
| TCU_FAIL("eglChooseConfig failed"); |
| } |
| if (numConfigs > 1) |
| { |
| log << tcu::TestLog::Message << "Fail, more configs returned than requested." << tcu::TestLog::EndMessage; |
| TCU_FAIL("Too many configs returned"); |
| } |
| |
| m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); |
| |
| m_redSize = eglu::getConfigAttribInt(egl, m_eglDisplay, m_eglConfig, EGL_RED_SIZE); |
| m_alphaSize = eglu::getConfigAttribInt(egl, m_eglDisplay, m_eglConfig, EGL_ALPHA_SIZE); |
| writeEglConfig(m_eglConfig); |
| } |
| |
| void WideColorSurfaceTest::readPixels (const glw::Functions& gl, float* dataPtr) |
| { |
| gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_FLOAT, dataPtr); |
| GLU_EXPECT_NO_ERROR(m_gl.getError(), "glReadPixels with floats"); |
| } |
| |
| void WideColorSurfaceTest::readPixels (const glw::Functions& gl, deUint32 *dataPtr) |
| { |
| gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, dataPtr); |
| GLU_EXPECT_NO_ERROR(m_gl.getError(), "glReadPixels with RGBA_1010102 (32bits)"); |
| } |
| |
| void WideColorSurfaceTest::readPixels (const glw::Functions& gl, deUint8 *dataPtr) |
| { |
| gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, dataPtr); |
| GLU_EXPECT_NO_ERROR(m_gl.getError(), "glReadPixels with RGBA_8888 (8 bit components)"); |
| } |
| |
| void WideColorSurfaceTest::writeEglConfig (EGLConfig config) |
| { |
| const Library& egl = m_eglTestCtx.getLibrary(); |
| tcu::TestLog& log = m_testCtx.getLog(); |
| qpEglConfigInfo info; |
| EGLint val = 0; |
| |
| info.bufferSize = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_BUFFER_SIZE); |
| |
| info.redSize = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_RED_SIZE); |
| |
| info.greenSize = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_GREEN_SIZE); |
| |
| info.blueSize = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_BLUE_SIZE); |
| |
| info.luminanceSize = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_LUMINANCE_SIZE); |
| |
| info.alphaSize = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_ALPHA_SIZE); |
| |
| info.alphaMaskSize = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_ALPHA_MASK_SIZE); |
| |
| val = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_BIND_TO_TEXTURE_RGB); |
| info.bindToTextureRGB = val == EGL_TRUE ? true : false; |
| |
| val = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_BIND_TO_TEXTURE_RGBA); |
| info.bindToTextureRGBA = val == EGL_TRUE ? true : false; |
| |
| val = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_COLOR_BUFFER_TYPE); |
| std::string colorBufferType = de::toString(eglu::getColorBufferTypeStr(val)); |
| info.colorBufferType = colorBufferType.c_str(); |
| |
| val = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_CONFIG_CAVEAT); |
| std::string caveat = de::toString(eglu::getConfigCaveatStr(val)); |
| info.configCaveat = caveat.c_str(); |
| |
| info.configID = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_CONFIG_ID); |
| |
| val = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_CONFORMANT); |
| std::string conformant = de::toString(eglu::getAPIBitsStr(val)); |
| info.conformant = conformant.c_str(); |
| |
| info.depthSize = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_DEPTH_SIZE); |
| |
| info.level = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_LEVEL); |
| |
| info.maxPBufferWidth = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_MAX_PBUFFER_WIDTH); |
| |
| info.maxPBufferHeight = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_MAX_PBUFFER_HEIGHT); |
| |
| info.maxPBufferPixels = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_MAX_PBUFFER_PIXELS); |
| |
| info.maxSwapInterval = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_MAX_SWAP_INTERVAL); |
| |
| info.minSwapInterval = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_MIN_SWAP_INTERVAL); |
| |
| val = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_NATIVE_RENDERABLE); |
| info.nativeRenderable = val == EGL_TRUE ? true : false; |
| |
| val = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_RENDERABLE_TYPE); |
| std::string renderableTypes = de::toString(eglu::getAPIBitsStr(val)); |
| info.renderableType = renderableTypes.c_str(); |
| |
| info.sampleBuffers = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_SAMPLE_BUFFERS); |
| |
| info.samples = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_SAMPLES); |
| |
| info.stencilSize = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_STENCIL_SIZE); |
| |
| val = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_SURFACE_TYPE); |
| std::string surfaceTypes = de::toString(eglu::getSurfaceBitsStr(val)); |
| info.surfaceTypes = surfaceTypes.c_str(); |
| |
| val = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_TRANSPARENT_TYPE); |
| std::string transparentType = de::toString(eglu::getTransparentTypeStr(val)); |
| info.transparentType = transparentType.c_str(); |
| |
| info.transparentRedValue = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_TRANSPARENT_RED_VALUE); |
| |
| info.transparentGreenValue = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_TRANSPARENT_GREEN_VALUE); |
| |
| info.transparentBlueValue = eglu::getConfigAttribInt(egl, m_eglDisplay, config, EGL_TRANSPARENT_BLUE_VALUE); |
| |
| log.writeEglConfig(&info); |
| } |
| |
| deUint32 WideColorSurfaceTest::expectedUint10 (float reference) |
| { |
| deUint32 expected; |
| |
| if (reference < 0.0) |
| { |
| expected = 0; |
| } |
| else if (reference > 1.0) |
| { |
| expected = 1023; |
| } |
| else |
| { |
| expected = static_cast<deUint32>(deRound(reference * 1023.0)); |
| } |
| |
| return expected; |
| } |
| |
| deUint32 WideColorSurfaceTest::expectedUint2 (float reference) |
| { |
| deUint32 expected; |
| |
| if (reference < 0.0) |
| { |
| expected = 0; |
| } |
| else if (reference > 1.0) |
| { |
| expected = 3; |
| } |
| else |
| { |
| expected = static_cast<deUint32>(deRound(reference * 3.0)); |
| } |
| |
| return expected; |
| } |
| |
| deUint8 WideColorSurfaceTest::expectedUint8 (float reference) |
| { |
| deUint8 expected; |
| if (reference < 0.0) |
| { |
| expected = 0; |
| } |
| else if (reference >= 1.0) |
| { |
| expected = 255; |
| } |
| else |
| { |
| // Apply sRGB transfer function when colorspace is sRGB or Display P3 and |
| // pixel component size is 8 bits (which is why we are here in expectedUint8). |
| if (m_colorSpace == EGL_GL_COLORSPACE_SRGB_KHR || |
| m_colorSpace == EGL_GL_COLORSPACE_DISPLAY_P3_EXT) |
| { |
| float srgbReference; |
| |
| if (reference <= 0.0031308) |
| { |
| srgbReference = 12.92f * reference; |
| } |
| else |
| { |
| float powRef = deFloatPow(reference, (1.0f/2.4f)); |
| srgbReference = (1.055f * powRef) - 0.055f; |
| } |
| expected = static_cast<deUint8>(deRound(srgbReference * 255.0)); |
| } |
| else |
| { |
| expected = static_cast<deUint8>(deRound(reference * 255.0)); |
| } |
| } |
| return expected; |
| } |
| |
| deUint8 WideColorSurfaceTest::expectedAlpha8 (float reference) |
| { |
| deUint8 expected; |
| if (m_alphaSize == 0) |
| { |
| // Surfaces without alpha are read back as opaque. |
| expected = 255; |
| } |
| else if (reference < 0.0) |
| { |
| expected = 0; |
| } |
| else if (reference >= 1.0) |
| { |
| expected = 255; |
| } |
| else |
| { |
| // The sRGB transfer function is not applied to alpha |
| expected = static_cast<deUint8>(deRound(reference * 255.0)); |
| } |
| return expected; |
| } |
| |
| // Return true for value out of range (fail) |
| bool WideColorSurfaceTest::checkWithThreshold8(deUint8 value, deUint8 reference, deUint8 threshold) |
| { |
| const deUint8 low = reference >= threshold ? static_cast<deUint8>(reference - threshold) : 0; |
| const deUint8 high = reference <= (255 - threshold) ? static_cast<deUint8>(reference + threshold) : 255; |
| return !((value >= low) && (value <= high)); |
| } |
| |
| bool WideColorSurfaceTest::checkWithThreshold10(deUint32 value, deUint32 reference, deUint32 threshold) |
| { |
| const deUint32 low = reference >= threshold ? reference - threshold : 0; |
| const deUint32 high = reference <= (1023 - threshold) ? reference + threshold : 1023; |
| return !((value >= low) && (value <= high)); |
| } |
| |
| bool WideColorSurfaceTest::checkWithThresholdFloat(float value, float reference, float threshold) |
| { |
| const float low = reference - threshold; |
| const float high = reference + threshold; |
| return !((value >= low) && (value <= high)); |
| } |
| |
| void WideColorSurfaceTest::testPixels (float reference, float increment) |
| { |
| tcu::TestLog& log = m_testCtx.getLog(); |
| |
| if (m_componentType == EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT) |
| { |
| float pixels[16]; |
| const float expected[4] = |
| { |
| reference, |
| reference + increment, |
| reference - increment, |
| reference + 2 * increment |
| }; |
| readPixels(m_gl, pixels); |
| |
| if (checkWithThresholdFloat(pixels[0], expected[0], increment) || |
| checkWithThresholdFloat(pixels[1], expected[1], increment) || |
| checkWithThresholdFloat(pixels[2], expected[2], increment) || |
| checkWithThresholdFloat(pixels[3], expected[3], increment)) |
| { |
| if (m_debugLog.str().size() > 0) |
| { |
| log << tcu::TestLog::Message |
| << "Prior passing tests\n" |
| << m_debugLog.str() |
| << tcu::TestLog::EndMessage; |
| m_debugLog.str(""); |
| } |
| log << tcu::TestLog::Message |
| << "Image comparison failed: " |
| << "reference = " << reference |
| << ", expected = " << expected[0] |
| << ":" << expected[1] |
| << ":" << expected[2] |
| << ":" << expected[3] |
| << ", result = " << pixels[0] |
| << ":" << pixels[1] |
| << ":" << pixels[2] |
| << ":" << pixels[3] |
| << tcu::TestLog::EndMessage; |
| m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Color test failed"); |
| } |
| else |
| { |
| // Pixel matches expected value |
| m_debugLog << "Image comparison passed: " |
| << "reference = " << reference |
| << ", result = " << pixels[0] |
| << ":" << pixels[1] |
| << ":" << pixels[2] |
| << ":" << pixels[3] |
| << "\n"; |
| } |
| } |
| else if (m_redSize > 8) |
| { |
| deUint32 buffer[16]; |
| readPixels(m_gl, buffer); |
| deUint32 pixels[4]; |
| deUint32 expected[4]; |
| |
| pixels[0] = buffer[0] & 0x3ff; |
| pixels[1] = (buffer[0] >> 10) & 0x3ff; |
| pixels[2] = (buffer[0] >> 20) & 0x3ff; |
| pixels[3] = (buffer[0] >> 30) & 0x3; |
| |
| expected[0] = expectedUint10(reference); |
| expected[1] = expectedUint10(reference + increment); |
| expected[2] = expectedUint10(reference - increment); |
| expected[3] = expectedUint2(reference + 2 * increment); |
| if (checkWithThreshold10(pixels[0], expected[0]) || checkWithThreshold10(pixels[1], expected[1]) |
| || checkWithThreshold10(pixels[2], expected[2]) || checkWithThreshold10(pixels[3], expected[3])) |
| { |
| if (m_debugLog.str().size() > 0) { |
| log << tcu::TestLog::Message |
| << "Prior passing tests\n" |
| << m_debugLog.str() |
| << tcu::TestLog::EndMessage; |
| m_debugLog.str(""); |
| } |
| log << tcu::TestLog::Message |
| << "Image comparison failed: " |
| << "reference = " << reference |
| << ", expected = " << static_cast<deUint32>(expected[0]) |
| << ":" << static_cast<deUint32>(expected[1]) |
| << ":" << static_cast<deUint32>(expected[2]) |
| << ":" << static_cast<deUint32>(expected[3]) |
| << ", result = " << static_cast<deUint32>(pixels[0]) |
| << ":" << static_cast<deUint32>(pixels[1]) |
| << ":" << static_cast<deUint32>(pixels[2]) |
| << ":" << static_cast<deUint32>(pixels[3]) |
| << tcu::TestLog::EndMessage; |
| m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Color test failed"); |
| } |
| else |
| { |
| // Pixel matches expected value |
| m_debugLog << "Image comparison passed: " |
| << "reference = " << reference |
| << ", result = " << static_cast<deUint32>(pixels[0]) |
| << ":" << static_cast<deUint32>(pixels[1]) |
| << ":" << static_cast<deUint32>(pixels[2]) |
| << ":" << static_cast<deUint32>(pixels[3]) |
| << "\n"; |
| } |
| } |
| else |
| { |
| deUint8 pixels[16]; |
| deUint8 expected[4]; |
| readPixels(m_gl, pixels); |
| |
| expected[0] = expectedUint8(reference); |
| expected[1] = expectedUint8(reference + increment); |
| expected[2] = expectedUint8(reference - increment); |
| expected[3] = expectedAlpha8(reference + 2 * increment); |
| if (checkWithThreshold8(pixels[0], expected[0]) || checkWithThreshold8(pixels[1], expected[1]) |
| || checkWithThreshold8(pixels[2], expected[2]) || checkWithThreshold8(pixels[3], expected[3])) |
| { |
| if (m_debugLog.str().size() > 0) { |
| log << tcu::TestLog::Message |
| << "Prior passing tests\n" |
| << m_debugLog.str() |
| << tcu::TestLog::EndMessage; |
| m_debugLog.str(""); |
| } |
| log << tcu::TestLog::Message |
| << "Image comparison failed: " |
| << "reference = " << reference |
| << ", expected = " << static_cast<deUint32>(expected[0]) |
| << ":" << static_cast<deUint32>(expected[1]) |
| << ":" << static_cast<deUint32>(expected[2]) |
| << ":" << static_cast<deUint32>(expected[3]) |
| << ", result = " << static_cast<deUint32>(pixels[0]) |
| << ":" << static_cast<deUint32>(pixels[1]) |
| << ":" << static_cast<deUint32>(pixels[2]) |
| << ":" << static_cast<deUint32>(pixels[3]) |
| << tcu::TestLog::EndMessage; |
| m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Color test failed"); |
| } |
| else |
| { |
| // Pixel matches expected value |
| m_debugLog << "Image comparison passed: " |
| << "reference = " << reference |
| << ", result = " << static_cast<deUint32>(pixels[0]) |
| << ":" << static_cast<deUint32>(pixels[1]) |
| << ":" << static_cast<deUint32>(pixels[2]) |
| << ":" << static_cast<deUint32>(pixels[3]) |
| << "\n"; |
| } |
| } |
| } |
| |
| void WideColorSurfaceTest::testFramebufferColorEncoding() |
| { |
| GLint framebufferColorEncoding; |
| m_gl.getFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_BACK, GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING, &framebufferColorEncoding); |
| GLU_EXPECT_NO_ERROR(m_gl.getError(), "Get framebuffer color encoding"); |
| bool correct = false; |
| if (m_colorSpace == EGL_GL_COLORSPACE_SRGB_KHR || m_colorSpace == EGL_GL_COLORSPACE_DISPLAY_P3_EXT) |
| { |
| if (m_redSize == 8) |
| { |
| correct = framebufferColorEncoding == GL_SRGB; |
| } |
| else if (m_redSize == 16) |
| { |
| correct = framebufferColorEncoding == GL_LINEAR; |
| } |
| else if (m_redSize == 10) |
| { |
| correct = true; |
| } |
| } |
| else |
| { |
| correct = framebufferColorEncoding == GL_LINEAR; |
| } |
| if (!correct) |
| { |
| m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Framebuffer color encoding is wrong"); |
| } |
| } |
| |
| void WideColorSurfaceTest::doClearTest (EGLSurface surface) |
| { |
| tcu::TestLog& log = m_testCtx.getLog(); |
| const Library& egl = m_eglTestCtx.getLibrary(); |
| const EGLint attribList[] = |
| { |
| EGL_CONTEXT_CLIENT_VERSION, 2, |
| EGL_NONE |
| }; |
| EGLContext eglContext = egl.createContext(m_eglDisplay, m_eglConfig, EGL_NO_CONTEXT, attribList); |
| EGLU_CHECK_MSG(egl, "eglCreateContext"); |
| |
| egl.makeCurrent(m_eglDisplay, surface, surface, eglContext); |
| EGLU_CHECK_MSG(egl, "eglMakeCurrent"); |
| |
| { |
| // put gles2Renderer inside it's own scope so that it's cleaned |
| // up before we hit the destroyContext |
| const GLES2Renderer gles2Renderer(m_gl, 128, 128); |
| |
| std::vector<Iteration>::const_iterator it; // declare an Iterator to a vector of strings |
| log << tcu::TestLog::Message << "m_iterations.count = " << m_iterations.size() << tcu::TestLog::EndMessage; |
| for(it = m_iterations.begin() ; it < m_iterations.end(); it++) |
| { |
| float reference = it->start; |
| log << tcu::TestLog::Message << "start = " << it->start |
| << tcu::TestLog::EndMessage; |
| log << tcu::TestLog::Message |
| << "increment = " << it->increment |
| << tcu::TestLog::EndMessage; |
| log << tcu::TestLog::Message |
| << "count = " << it->iterationCount |
| << tcu::TestLog::EndMessage; |
| m_debugLog.str(""); |
| for (int iterationCount = 0; iterationCount < it->iterationCount; iterationCount++) |
| { |
| const Color clearColor(reference, reference + it->increment, reference - it->increment, reference + 2 * it->increment); |
| |
| clearColorScreen(m_gl, clearColor); |
| GLU_EXPECT_NO_ERROR(m_gl.getError(), "Clear to test value"); |
| |
| testPixels(reference, it->increment); |
| |
| // reset buffer contents so that we know render below did something |
| const Color clearColor2(1.0f - reference, 1.0f, 1.0f, 1.0f); |
| clearColorScreen(m_gl, clearColor2); |
| GLU_EXPECT_NO_ERROR(m_gl.getError(), "Clear to 1.0f - reference value"); |
| |
| const ColoredRect coloredRect (IVec2(0, 0), IVec2(1, 1), clearColor); |
| gles2Renderer.render(coloredRect); |
| testPixels(reference, it->increment); |
| |
| reference += it->increment; |
| |
| // If this device is ES3 compatible, so do some additional testing |
| if (glu::IsES3Compatible(m_gl)) |
| testFramebufferColorEncoding(); |
| } |
| |
| EGLU_CHECK_CALL(egl, swapBuffers(m_eglDisplay, surface)); |
| } |
| } |
| |
| // disconnect surface & context so they can be destroyed when |
| // this function exits. |
| EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)); |
| |
| egl.destroyContext(m_eglDisplay, eglContext); |
| } |
| |
| void WideColorSurfaceTest::executeTest (void) |
| { |
| tcu::TestLog& log = m_testCtx.getLog(); |
| const Library& egl = m_eglTestCtx.getLibrary(); |
| const eglu::NativeDisplayFactory& displayFactory = m_eglTestCtx.getNativeDisplayFactory(); |
| eglu::NativeDisplay& nativeDisplay = m_eglTestCtx.getNativeDisplay(); |
| egl.bindAPI(EGL_OPENGL_ES_API); |
| |
| if (m_surfaceType & EGL_PBUFFER_BIT) |
| { |
| log << tcu::TestLog::Message << "Test Pbuffer" << tcu::TestLog::EndMessage; |
| |
| std::vector<EGLint> attribs; |
| attribs.push_back(EGL_WIDTH); |
| attribs.push_back(128); |
| attribs.push_back(EGL_HEIGHT); |
| attribs.push_back(128); |
| if (m_colorSpace != EGL_NONE) |
| { |
| attribs.push_back(EGL_GL_COLORSPACE_KHR); |
| attribs.push_back(m_colorSpace); |
| } |
| attribs.push_back(EGL_NONE); |
| attribs.push_back(EGL_NONE); |
| const EGLSurface surface = egl.createPbufferSurface(m_eglDisplay, m_eglConfig, attribs.data()); |
| if ((surface == EGL_NO_SURFACE) && (egl.getError() == EGL_BAD_MATCH)) |
| { |
| TCU_THROW(NotSupportedError, "Colorspace is not supported with this format"); |
| } |
| TCU_CHECK(surface != EGL_NO_SURFACE); |
| EGLU_CHECK_MSG(egl, "eglCreatePbufferSurface()"); |
| |
| doClearTest(surface); |
| |
| egl.destroySurface(m_eglDisplay, surface); |
| EGLU_CHECK_MSG(egl, "eglDestroySurface()"); |
| } |
| else if (m_surfaceType & EGL_WINDOW_BIT) |
| { |
| log << tcu::TestLog::Message << "Test Window" << tcu::TestLog::EndMessage; |
| |
| const eglu::NativeWindowFactory& windowFactory = eglu::selectNativeWindowFactory(displayFactory, m_testCtx.getCommandLine()); |
| |
| de::UniquePtr<eglu::NativeWindow> window (windowFactory.createWindow(&nativeDisplay, m_eglDisplay, m_eglConfig, DE_NULL, eglu::WindowParams(128, 128, eglu::parseWindowVisibility(m_testCtx.getCommandLine())))); |
| std::vector<EGLAttrib> attribs; |
| if (m_colorSpace != EGL_NONE) |
| { |
| attribs.push_back(EGL_GL_COLORSPACE_KHR); |
| attribs.push_back(m_colorSpace); |
| } |
| attribs.push_back(EGL_NONE); |
| attribs.push_back(EGL_NONE); |
| |
| EGLSurface surface; |
| try |
| { |
| surface = eglu::createWindowSurface(nativeDisplay, *window, m_eglDisplay, m_eglConfig, attribs.data()); |
| } |
| catch (const eglu::Error& error) |
| { |
| if (error.getError() == EGL_BAD_MATCH) |
| TCU_THROW(NotSupportedError, "createWindowSurface is not supported for this config"); |
| |
| throw; |
| } |
| TCU_CHECK(surface != EGL_NO_SURFACE); |
| EGLU_CHECK_MSG(egl, "eglCreateWindowSurface()"); |
| |
| doClearTest(surface); |
| |
| if (m_testAttribList.size() > 0) |
| { |
| for (deUint32 i = 0; i < m_testAttribList.size(); i +=2) |
| { |
| if (!egl.surfaceAttrib(m_eglDisplay, surface, m_testAttribList[i], m_testAttribList[i+1])) |
| { |
| // Implementation can return EGL_BAD_PARAMETER if given value is not supported. |
| EGLint error = egl.getError(); |
| if (error != EGL_BAD_PARAMETER) |
| TCU_FAIL("Unable to set HDR metadata on surface"); |
| |
| log << tcu::TestLog::Message << |
| "Warning: Metadata value " << m_testAttribList[i+1] << " for attrib 0x" << |
| std::hex << m_testAttribList[i] << std::dec << |
| " not supported by the implementation." << tcu::TestLog::EndMessage; |
| m_testAttribList[i+1] = EGL_BAD_PARAMETER; |
| } |
| } |
| for (deUint32 i = 0; i < m_testAttribList.size(); i +=2) |
| { |
| // Skip unsupported values. |
| if (m_testAttribList[i+1] == EGL_BAD_PARAMETER) |
| continue; |
| |
| EGLint value; |
| egl.querySurface(m_eglDisplay, surface, m_testAttribList[i], &value); |
| TCU_CHECK(value == m_testAttribList[i+1]); |
| } |
| } |
| |
| egl.destroySurface(m_eglDisplay, surface); |
| EGLU_CHECK_MSG(egl, "eglDestroySurface()"); |
| } |
| else if (m_surfaceType & EGL_PIXMAP_BIT) |
| { |
| log << tcu::TestLog::Message << "Test Pixmap" << tcu::TestLog::EndMessage; |
| |
| const eglu::NativePixmapFactory& pixmapFactory = eglu::selectNativePixmapFactory(displayFactory, m_testCtx.getCommandLine()); |
| |
| de::UniquePtr<eglu::NativePixmap> pixmap (pixmapFactory.createPixmap(&nativeDisplay, m_eglDisplay, m_eglConfig, DE_NULL, 128, 128)); |
| const EGLSurface surface = eglu::createPixmapSurface(nativeDisplay, *pixmap, m_eglDisplay, m_eglConfig, DE_NULL); |
| TCU_CHECK(surface != EGL_NO_SURFACE); |
| EGLU_CHECK_MSG(egl, "eglCreatePixmapSurface()"); |
| |
| doClearTest(surface); |
| |
| egl.destroySurface(m_eglDisplay, surface); |
| EGLU_CHECK_MSG(egl, "eglDestroySurface()"); |
| } |
| else |
| TCU_FAIL("No valid surface types supported in config"); |
| } |
| |
| TestCase::IterateResult WideColorSurfaceTest::iterate (void) |
| { |
| m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); |
| executeTest(); |
| return STOP; |
| } |
| |
| } // anonymous |
| |
| WideColorTests::WideColorTests (EglTestContext& eglTestCtx) |
| : TestCaseGroup(eglTestCtx, "wide_color", "Wide Color tests") |
| { |
| } |
| |
| void WideColorTests::init (void) |
| { |
| addChild(new WideColorFP16Test(m_eglTestCtx, "fp16", "Verify that FP16 pixel format is present")); |
| addChild(new WideColor1010102Test(m_eglTestCtx, "1010102", "Check if 1010102 pixel format is present")); |
| |
| // This is an increment FP16 can do between -1.0 to 1.0 |
| const float fp16Increment1 = deFloatPow(2.0, -11.0); |
| // This is an increment FP16 can do between 1.0 to 2.0 |
| const float fp16Increment2 = deFloatPow(2.0, -10.0); |
| |
| std::vector<Iteration> iterations; |
| // -0.333251953125f ~ -1/3 as seen in FP16 |
| // Negative values will be 0 on read with fixed point pixel formats |
| iterations.push_back(Iteration(-0.333251953125f, fp16Increment1, 10)); |
| // test crossing 0 |
| iterations.push_back(Iteration(-fp16Increment1 * 5.0f, fp16Increment1, 10)); |
| // test crossing 1.0 |
| // Values > 1.0 will be truncated to 1.0 with fixed point pixel formats |
| iterations.push_back(Iteration(1.0f - fp16Increment2 * 5.0f, fp16Increment2, 10)); |
| |
| const EGLint windowAttribListFP16[] = |
| { |
| EGL_SURFACE_TYPE, EGL_WINDOW_BIT, |
| EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, |
| EGL_RED_SIZE, 16, |
| EGL_GREEN_SIZE, 16, |
| EGL_BLUE_SIZE, 16, |
| EGL_ALPHA_SIZE, 16, |
| EGL_COLOR_COMPONENT_TYPE_EXT, EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT, |
| EGL_NONE, EGL_NONE |
| }; |
| addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_fp16_default_colorspace", "FP16 window surface has FP16 pixels in it", windowAttribListFP16, EGL_NONE, iterations)); |
| addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_fp16_colorspace_srgb", "FP16 window surface, explicit sRGB colorspace", windowAttribListFP16, EGL_GL_COLORSPACE_SRGB_KHR, iterations)); |
| addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_fp16_colorspace_p3", "FP16 window surface, explicit Display-P3 colorspace", windowAttribListFP16, EGL_GL_COLORSPACE_DISPLAY_P3_EXT, iterations)); |
| 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)); |
| addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_fp16_colorspace_scrgb", "FP16 window surface, explicit scRGB colorspace", windowAttribListFP16, EGL_GL_COLORSPACE_SCRGB_EXT, iterations)); |
| 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)); |
| addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_fp16_colorspace_bt2020_linear", "FP16 window surface, explicit BT2020 linear colorspace", windowAttribListFP16, EGL_GL_COLORSPACE_BT2020_LINEAR_EXT, iterations)); |
| addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_fp16_colorspace_bt2020_pq", "FP16 window surface, explicit BT2020 PQ colorspace", windowAttribListFP16, EGL_GL_COLORSPACE_BT2020_PQ_EXT, iterations)); |
| |
| const EGLint pbufferAttribListFP16[] = |
| { |
| EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, |
| EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, |
| EGL_RED_SIZE, 16, |
| EGL_GREEN_SIZE, 16, |
| EGL_BLUE_SIZE, 16, |
| EGL_ALPHA_SIZE, 16, |
| EGL_COLOR_COMPONENT_TYPE_EXT, EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT, |
| EGL_NONE, EGL_NONE |
| }; |
| addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_fp16_default_colorspace", "FP16 pbuffer surface has FP16 pixels in it", pbufferAttribListFP16, EGL_NONE, iterations)); |
| addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_fp16_colorspace_srgb", "FP16 pbuffer surface, explicit sRGB colorspace", pbufferAttribListFP16, EGL_GL_COLORSPACE_SRGB_KHR, iterations)); |
| addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_fp16_colorspace_p3", "FP16 pbuffer surface, explicit Display-P3 colorspace", pbufferAttribListFP16, EGL_GL_COLORSPACE_DISPLAY_P3_EXT, iterations)); |
| 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)); |
| addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_fp16_colorspace_scrgb", "FP16 pbuffer surface, explicit scRGB colorspace", pbufferAttribListFP16, EGL_GL_COLORSPACE_SCRGB_EXT, iterations)); |
| 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)); |
| addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_fp16_colorspace_bt2020_linear", "FP16 pbuffer surface, explicit BT2020 linear colorspace", pbufferAttribListFP16, EGL_GL_COLORSPACE_BT2020_LINEAR_EXT, iterations)); |
| addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_fp16_colorspace_bt2020_pq", "FP16 pbuffer surface, explicit BT2020 PQ colorspace", pbufferAttribListFP16, EGL_GL_COLORSPACE_BT2020_PQ_EXT, iterations)); |
| |
| const EGLint windowAttribList1010102[] = |
| { |
| EGL_SURFACE_TYPE, EGL_WINDOW_BIT, |
| EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, |
| EGL_RED_SIZE, 10, |
| EGL_GREEN_SIZE, 10, |
| EGL_BLUE_SIZE, 10, |
| EGL_ALPHA_SIZE, 2, |
| EGL_NONE, EGL_NONE |
| }; |
| addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_1010102_colorspace_default", "1010102 Window surface, default (sRGB) colorspace", windowAttribList1010102, EGL_NONE, iterations)); |
| addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_1010102_colorspace_srgb", "1010102 Window surface, explicit sRGB colorspace", windowAttribList1010102, EGL_GL_COLORSPACE_SRGB_KHR, iterations)); |
| addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_1010102_colorspace_p3", "1010102 Window surface, explicit Display-P3 colorspace", windowAttribList1010102, EGL_GL_COLORSPACE_DISPLAY_P3_EXT, iterations)); |
| 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)); |
| addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_1010102_colorspace_bt2020_linear", "1010102 Window surface, explicit BT2020 linear colorspace", windowAttribList1010102, EGL_GL_COLORSPACE_BT2020_LINEAR_EXT, iterations)); |
| addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_1010102_colorspace_bt2020_pq", "1010102 Window surface, explicit BT2020 PQ colorspace", windowAttribList1010102, EGL_GL_COLORSPACE_BT2020_PQ_EXT, iterations)); |
| |
| const EGLint pbufferAttribList1010102[] = |
| { |
| EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, |
| EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, |
| EGL_RED_SIZE, 10, |
| EGL_GREEN_SIZE, 10, |
| EGL_BLUE_SIZE, 10, |
| EGL_ALPHA_SIZE, 2, |
| EGL_NONE, EGL_NONE |
| }; |
| addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_1010102_colorspace_default", "1010102 pbuffer surface, default (sRGB) colorspace", pbufferAttribList1010102, EGL_NONE, iterations)); |
| addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_1010102_colorspace_srgb", "1010102 pbuffer surface, explicit sRGB colorspace", pbufferAttribList1010102, EGL_GL_COLORSPACE_SRGB_KHR, iterations)); |
| addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_1010102_colorspace_p3", "1010102 pbuffer surface, explicit Display-P3 colorspace", pbufferAttribList1010102, EGL_GL_COLORSPACE_DISPLAY_P3_EXT, iterations)); |
| 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)); |
| addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_1010102_colorspace_bt2020_linear", "1010102 pbuffer surface, explicit BT2020 linear colorspace", pbufferAttribList1010102, EGL_GL_COLORSPACE_BT2020_LINEAR_EXT, iterations)); |
| addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_1010102_colorspace_bt2020_pq", "1010102 pbuffer surface, explicit BT2020 PQ colorspace", pbufferAttribList1010102, EGL_GL_COLORSPACE_BT2020_PQ_EXT, iterations)); |
| |
| const EGLint windowAttribList8888[] = |
| { |
| EGL_SURFACE_TYPE, EGL_WINDOW_BIT, |
| EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, |
| EGL_RED_SIZE, 8, |
| EGL_GREEN_SIZE, 8, |
| EGL_BLUE_SIZE, 8, |
| EGL_ALPHA_SIZE, 8, |
| EGL_NONE, EGL_NONE |
| }; |
| addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_8888_colorspace_default", "8888 window surface, default (sRGB) colorspace", windowAttribList8888, EGL_NONE, iterations)); |
| addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_8888_colorspace_srgb", "8888 window surface, explicit sRGB colorspace", windowAttribList8888, EGL_GL_COLORSPACE_SRGB_KHR, iterations)); |
| addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_8888_colorspace_p3", "8888 window surface, explicit Display-P3 colorspace", windowAttribList8888, EGL_GL_COLORSPACE_DISPLAY_P3_EXT, iterations)); |
| 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)); |
| |
| const EGLint pbufferAttribList8888[] = |
| { |
| EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, |
| EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, |
| EGL_RED_SIZE, 8, |
| EGL_GREEN_SIZE, 8, |
| EGL_BLUE_SIZE, 8, |
| EGL_ALPHA_SIZE, 8, |
| EGL_NONE, EGL_NONE |
| }; |
| addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_8888_colorspace_default", "8888 pbuffer surface, default (sRGB) colorspace", pbufferAttribList8888, EGL_NONE, iterations)); |
| addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_8888_colorspace_srgb", "8888 pbuffer surface, explicit sRGB colorspace", pbufferAttribList8888, EGL_GL_COLORSPACE_SRGB_KHR, iterations)); |
| addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_8888_colorspace_p3", "8888 pbuffer surface, explicit Display-P3 colorspace", pbufferAttribList8888, EGL_GL_COLORSPACE_DISPLAY_P3_EXT, iterations)); |
| 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)); |
| |
| const EGLint windowAttribList888[] = |
| { |
| EGL_SURFACE_TYPE, EGL_WINDOW_BIT, |
| EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, |
| EGL_RED_SIZE, 8, |
| EGL_GREEN_SIZE, 8, |
| EGL_BLUE_SIZE, 8, |
| EGL_NONE, EGL_NONE |
| }; |
| addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_888_colorspace_default", "888 window surface, default (sRGB) colorspace", windowAttribList888, EGL_NONE, iterations)); |
| addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_888_colorspace_srgb", "888 window surface, explicit sRGB colorspace", windowAttribList888, EGL_GL_COLORSPACE_SRGB_KHR, iterations)); |
| addChild(new WideColorSurfaceTest(m_eglTestCtx, "window_888_colorspace_p3", "888 window surface, explicit Display-P3 colorspace", windowAttribList888, EGL_GL_COLORSPACE_DISPLAY_P3_EXT, iterations)); |
| 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)); |
| |
| const EGLint pbufferAttribList888[] = |
| { |
| EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, |
| EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, |
| EGL_RED_SIZE, 8, |
| EGL_GREEN_SIZE, 8, |
| EGL_BLUE_SIZE, 8, |
| EGL_NONE, EGL_NONE |
| }; |
| addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_888_colorspace_default", "888 pbuffer surface, default (sRGB) colorspace", pbufferAttribList888, EGL_NONE, iterations)); |
| addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_888_colorspace_srgb", "888 pbuffer surface, explicit sRGB colorspace", pbufferAttribList888, EGL_GL_COLORSPACE_SRGB_KHR, iterations)); |
| addChild(new WideColorSurfaceTest(m_eglTestCtx, "pbuffer_888_colorspace_p3", "888 pbuffer surface, explicit Display-P3 colorspace", pbufferAttribList888, EGL_GL_COLORSPACE_DISPLAY_P3_EXT, iterations)); |
| 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)); |
| |
| } |
| |
| TestCaseGroup* createWideColorTests (EglTestContext& eglTestCtx) |
| { |
| return new WideColorTests(eglTestCtx); |
| } |
| |
| class Smpte2086ColorTest : public WideColorTest |
| { |
| public: |
| Smpte2086ColorTest (EglTestContext& eglTestCtx, |
| const char* name, |
| const char* description); |
| |
| void executeTest (void); |
| IterateResult iterate (void); |
| }; |
| |
| Smpte2086ColorTest::Smpte2086ColorTest (EglTestContext& eglTestCtx, const char* name, const char* description) |
| : WideColorTest(eglTestCtx, name, description) |
| { |
| } |
| |
| #define METADATA_SCALE(x) (static_cast<EGLint>(x * EGL_METADATA_SCALING_EXT)) |
| |
| void Smpte2086ColorTest::executeTest (void) |
| { |
| tcu::TestLog& log = m_testCtx.getLog(); |
| const Library& egl = m_eglTestCtx.getLibrary(); |
| egl.bindAPI(EGL_OPENGL_ES_API); |
| |
| log << tcu::TestLog::Message << "Test SMPTE 2086 Metadata on Window" << tcu::TestLog::EndMessage; |
| |
| checkSMPTE2086(); |
| |
| // This is an increment FP16 can do between -1.0 to 1.0 |
| const float fp16Increment1 = deFloatPow(2.0, -11.0); |
| // This is an increment FP16 can do between 1.0 to 2.0 |
| const float fp16Increment2 = deFloatPow(2.0, -10.0); |
| |
| std::vector<Iteration> int8888Iterations; |
| // -0.333251953125f ~ -1/3 as seen in fp16 |
| // Negative values will be 0 on read with fixed point pixel formats |
| int8888Iterations.push_back(Iteration(-0.333251953125f, fp16Increment1, 10)); |
| // test crossing 0 |
| int8888Iterations.push_back(Iteration(-fp16Increment1 * 5.0f, fp16Increment1, 10)); |
| // test crossing 1.0 |
| // Values > 1.0 will be truncated to 1.0 with fixed point pixel formats |
| int8888Iterations.push_back(Iteration(1.0f - fp16Increment2 * 5.0f, fp16Increment2, 10)); |
| |
| const EGLint windowAttribList8888[] = |
| { |
| EGL_SURFACE_TYPE, EGL_WINDOW_BIT, |
| EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, |
| EGL_RED_SIZE, 8, |
| EGL_GREEN_SIZE, 8, |
| EGL_BLUE_SIZE, 8, |
| EGL_ALPHA_SIZE, 8, |
| EGL_NONE, EGL_NONE |
| }; |
| |
| WideColorSurfaceTest testObj(m_eglTestCtx, "window_8888_colorspace_default", "8888 window surface, default (sRGB) colorspace", windowAttribList8888, EGL_NONE, int8888Iterations); |
| |
| const EGLint testAttrs[] = |
| { |
| EGL_SMPTE2086_DISPLAY_PRIMARY_RX_EXT, METADATA_SCALE(0.680), |
| EGL_SMPTE2086_DISPLAY_PRIMARY_RY_EXT, METADATA_SCALE(0.320), |
| EGL_SMPTE2086_DISPLAY_PRIMARY_GX_EXT, METADATA_SCALE(0.265), |
| EGL_SMPTE2086_DISPLAY_PRIMARY_GY_EXT, METADATA_SCALE(0.690), |
| EGL_SMPTE2086_DISPLAY_PRIMARY_BX_EXT, METADATA_SCALE(0.440), |
| EGL_SMPTE2086_DISPLAY_PRIMARY_BY_EXT, METADATA_SCALE(0.320), |
| EGL_SMPTE2086_WHITE_POINT_X_EXT, METADATA_SCALE(0.2200), |
| EGL_SMPTE2086_WHITE_POINT_Y_EXT, METADATA_SCALE(0.2578), |
| EGL_SMPTE2086_MAX_LUMINANCE_EXT, METADATA_SCALE(1.31), |
| EGL_SMPTE2086_MIN_LUMINANCE_EXT, METADATA_SCALE(0.123), |
| EGL_NONE |
| }; |
| testObj.addTestAttributes(testAttrs); |
| |
| testObj.init(); |
| testObj.executeTest(); |
| } |
| |
| TestCase::IterateResult Smpte2086ColorTest::iterate (void) |
| { |
| m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); |
| executeTest(); |
| return STOP; |
| } |
| |
| class Cta8613ColorTest : public WideColorTest |
| { |
| public: |
| Cta8613ColorTest (EglTestContext& eglTestCtx, |
| const char* name, |
| const char* description); |
| |
| void executeTest (void); |
| IterateResult iterate (void); |
| }; |
| |
| Cta8613ColorTest::Cta8613ColorTest (EglTestContext& eglTestCtx, const char* name, const char* description) |
| : WideColorTest(eglTestCtx, name, description) |
| { |
| } |
| |
| #define METADATA_SCALE(x) (static_cast<EGLint>(x * EGL_METADATA_SCALING_EXT)) |
| |
| void Cta8613ColorTest::executeTest (void) |
| { |
| tcu::TestLog& log = m_testCtx.getLog(); |
| const Library& egl = m_eglTestCtx.getLibrary(); |
| egl.bindAPI(EGL_OPENGL_ES_API); |
| |
| log << tcu::TestLog::Message << "Test CTA 861.3 Metadata on Window" << tcu::TestLog::EndMessage; |
| |
| checkCTA861_3(); |
| |
| // This is an increment FP16 can do between -1.0 to 1.0 |
| const float fp16Increment1 = deFloatPow(2.0, -11.0); |
| // This is an increment FP16 can do between 1.0 to 2.0 |
| const float fp16Increment2 = deFloatPow(2.0, -10.0); |
| |
| std::vector<Iteration> int8888Iterations; |
| // -0.333251953125f ~ -1/3 as seen in fp16 |
| // Negative values will be 0 on read with fixed point pixel formats |
| int8888Iterations.push_back(Iteration(-0.333251953125f, fp16Increment1, 10)); |
| // test crossing 0 |
| int8888Iterations.push_back(Iteration(-fp16Increment1 * 5.0f, fp16Increment1, 10)); |
| // test crossing 1.0 |
| // Values > 1.0 will be truncated to 1.0 with fixed point pixel formats |
| int8888Iterations.push_back(Iteration(1.0f - fp16Increment2 * 5.0f, fp16Increment2, 10)); |
| |
| const EGLint windowAttribList8888[] = |
| { |
| EGL_SURFACE_TYPE, EGL_WINDOW_BIT, |
| EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, |
| EGL_RED_SIZE, 8, |
| EGL_GREEN_SIZE, 8, |
| EGL_BLUE_SIZE, 8, |
| EGL_ALPHA_SIZE, 8, |
| EGL_NONE, EGL_NONE |
| }; |
| |
| WideColorSurfaceTest testObj(m_eglTestCtx, "window_8888_colorspace_default", "8888 window surface, default (sRGB) colorspace", windowAttribList8888, EGL_NONE, int8888Iterations); |
| |
| const EGLint testAttrs[] = |
| { |
| EGL_CTA861_3_MAX_CONTENT_LIGHT_LEVEL_EXT, METADATA_SCALE(1.31), |
| EGL_CTA861_3_MAX_FRAME_AVERAGE_LEVEL_EXT, METADATA_SCALE(0.6), |
| EGL_NONE |
| }; |
| testObj.addTestAttributes(testAttrs); |
| |
| testObj.init(); |
| testObj.executeTest(); |
| } |
| |
| TestCase::IterateResult Cta8613ColorTest::iterate (void) |
| { |
| m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); |
| executeTest(); |
| return STOP; |
| } |
| |
| class HdrColorTests : public TestCaseGroup |
| { |
| public: |
| HdrColorTests (EglTestContext& eglTestCtx); |
| void init (void); |
| |
| private: |
| HdrColorTests (const HdrColorTests&); |
| HdrColorTests& operator= (const HdrColorTests&); |
| }; |
| |
| HdrColorTests::HdrColorTests (EglTestContext& eglTestCtx) |
| : TestCaseGroup(eglTestCtx, "hdr_metadata", "HDR Metadata tests") |
| { |
| } |
| |
| void HdrColorTests::init (void) |
| { |
| addChild(new Smpte2086ColorTest(m_eglTestCtx, "smpte2086", "Verify that SMPTE 2086 extension exists")); |
| addChild(new Cta8613ColorTest(m_eglTestCtx, "cta861_3", "Verify that CTA 861.3 extension exists")); |
| } |
| |
| TestCaseGroup* createHdrColorTests (EglTestContext& eglTestCtx) |
| { |
| return new HdrColorTests(eglTestCtx); |
| } |
| |
| } // egl |
| } // deqp |