Add new EGL tests for HDR am: fcfa77ea6a am: 3b92d7b7b9
authorCourtney Goeltzenleuchter <courtneygo@google.com>
Wed, 31 Jan 2018 17:13:29 +0000 (17:13 +0000)
committerandroid-build-merger <android-build-merger@google.com>
Wed, 31 Jan 2018 17:13:29 +0000 (17:13 +0000)
am: d1957b9d94

Change-Id: I927c198497f370896afe507a6502797c572b71bb

1  2 
android/cts/master/egl-master.txt
modules/egl/teglWideColorTests.cpp

@@@ -2491,7 -2491,6 +2491,7 @@@ dEQP-EGL.functional.get_proc_address.ex
  dEQP-EGL.functional.get_proc_address.extension.gl_khr_blend_equation_advanced
  dEQP-EGL.functional.get_proc_address.extension.gl_khr_debug
  dEQP-EGL.functional.get_proc_address.extension.gl_khr_robustness
 +dEQP-EGL.functional.get_proc_address.extension.gl_khr_parallel_shader_compile
  dEQP-EGL.functional.get_proc_address.extension.gl_nv_bindless_texture
  dEQP-EGL.functional.get_proc_address.extension.gl_nv_blend_equation_advanced
  dEQP-EGL.functional.get_proc_address.extension.gl_nv_conditional_render
@@@ -3671,3 -3670,4 +3671,4 @@@ dEQP-EGL.functional.wide_color.window_8
  dEQP-EGL.functional.wide_color.pbuffer_8888_colorspace_default
  dEQP-EGL.functional.wide_color.pbuffer_8888_colorspace_srgb
  dEQP-EGL.functional.wide_color.pbuffer_8888_colorspace_p3
+ dEQP-EGL.functional.hdr_color.8888
@@@ -102,10 -102,15 +102,14 @@@ public
        void                            checkPixelFloatSupport          (void);
        void                            checkColorSpaceSupport          (void);
        void                            checkDisplayP3Support           (void);
 -      void                            checkDisplayP3LinearSupport (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);
@@@ -261,6 -266,10 +265,6 @@@ private
        ReferenceRenderer&      operator=                               (const ReferenceRenderer&);
  };
  
 -ReferenceRenderer::ReferenceRenderer (void)
 -{
 -}
 -
  WideColorTest::WideColorTest (EglTestContext& eglTestCtx, const char* name, const char* description)
        : TestCase                               (eglTestCtx, name, description)
        , m_eglDisplay                   (EGL_NO_DISPLAY)
@@@ -303,6 -312,14 +307,6 @@@ void WideColorTest::checkDisplayP3Suppo
                TCU_THROW(NotSupportedError, "EGL_EXT_gl_colorspace_display_p3 is not supported");
  }
  
 -void WideColorTest::checkDisplayP3LinearSupport (void)
 -{
 -      const Library&  egl     = m_eglTestCtx.getLibrary();
 -
 -      if (!eglu::hasExtension(egl, m_eglDisplay, "EGL_EXT_gl_colorspace_display_p3_linear"))
 -              TCU_THROW(NotSupportedError, "EGL_EXT_gl_colorspace_display_p3_linear is not supported");
 -}
 -
  void WideColorTest::checkSCRGBSupport (void)
  {
        const Library&  egl     = m_eglTestCtx.getLibrary();
  
  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_gl_colorspace_scrgb_linear"))
-               TCU_THROW(NotSupportedError, "EGL_EXT_gl_colorspace_scrgb_linear is not supported");
+       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)
@@@ -528,6 -577,8 +564,8 @@@ public
        void                            init                                    (void);
        void                            executeTest                             (void);
        IterateResult           iterate                                 (void);
+       void                            addWindowAttributes             (const EGLint* attributes);
+       void                            addTestAttributes               (const EGLint* attributes);
  
  protected:
        void                            readPixels                              (const glw::Functions& gl, float* dataPtr);
  
  private:
        std::vector<EGLint>                                     m_attribList;
+       std::vector<EGLint>                                     m_winAttribList;
+       std::vector<EGLint>                                     m_testAttribList;
        EGLConfig                                                       m_eglConfig;
        EGLint                                                          m_surfaceType;
        EGLint                                                          m_componentType;
@@@ -581,6 -634,30 +621,30 @@@ WideColorSurfaceTest::WideColorSurfaceT
        m_attribList.push_back(EGL_NONE);
  }
  
+ void WideColorSurfaceTest::addWindowAttributes(const EGLint* attributes)
+ {
+       deUint32 idx = 0;
+       if (attributes == DE_NULL) return;
+       while (attributes[idx] != EGL_NONE)
+       {
+               m_winAttribList.push_back(attributes[idx++]);
+               m_winAttribList.push_back(attributes[idx++]);
+       }
+ }
+ 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();
                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;
        }
@@@ -1117,6 -1200,10 +1187,10 @@@ void WideColorSurfaceTest::executeTest 
                        attribs.push_back(EGL_GL_COLORSPACE_KHR);
                        attribs.push_back(m_colorSpace);
                }
+               for (deUint32 i = 0; i < m_winAttribList.size(); i++)
+               {
+                       attribs.push_back(m_winAttribList[i]);
+               }
                attribs.push_back(EGL_NONE);
                attribs.push_back(EGL_NONE);
                const EGLSurface surface = egl.createPbufferSurface(m_eglDisplay, m_eglConfig, attribs.data());
                        attribs.push_back(EGL_GL_COLORSPACE_KHR);
                        attribs.push_back(m_colorSpace);
                }
+               for (deUint32 i = 0; i < m_winAttribList.size(); i++)
+               {
+                       attribs.push_back(m_winAttribList[i]);
+               }
                attribs.push_back(EGL_NONE);
                attribs.push_back(EGL_NONE);
  
  
                doClearTest(surface);
  
+               // If we have any window attributes, check that the values are correct
+               for (deUint32 i = 0; i < m_winAttribList.size(); i +=2)
+               {
+                       EGLint value;
+                       egl.querySurface(m_eglDisplay, surface, m_winAttribList[i], &value);
+                       TCU_CHECK(value == m_winAttribList[i+1]);
+               }
+               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])) {
+                                       TCU_FAIL("Unable to set HDR metadata on surface");
+                               }
+                       }
+                       for (deUint32 i = 0; i < m_testAttribList.size(); i +=2)
+                       {
+                               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()");
        }
@@@ -1336,5 -1451,135 +1438,135 @@@ TestCaseGroup* createWideColorTests (Eg
        return new WideColorTests(eglTestCtx);
  }
  
+ class HdrColorTest : public WideColorTest
+ {
+ public:
+       HdrColorTest            (EglTestContext&        eglTestCtx,
+                                                        const char*            name,
+                                                        const char*            description);
+       void                            executeTest                             (void);
+       IterateResult           iterate                                 (void);
+ };
+ HdrColorTest::HdrColorTest (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 HdrColorTest::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 HDR Metadata on Window" << tcu::TestLog::EndMessage;
+       checkSMPTE2086();
+       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 attrs[] =
+       {
+               EGL_SMPTE2086_DISPLAY_PRIMARY_RX_EXT, METADATA_SCALE(0.640),
+               EGL_SMPTE2086_DISPLAY_PRIMARY_RY_EXT, METADATA_SCALE(0.330),
+               EGL_SMPTE2086_DISPLAY_PRIMARY_GX_EXT, METADATA_SCALE(0.290),
+               EGL_SMPTE2086_DISPLAY_PRIMARY_GY_EXT, METADATA_SCALE(0.600),
+               EGL_SMPTE2086_DISPLAY_PRIMARY_BX_EXT, METADATA_SCALE(0.150),
+               EGL_SMPTE2086_DISPLAY_PRIMARY_BY_EXT, METADATA_SCALE(0.060),
+               EGL_SMPTE2086_WHITE_POINT_X_EXT, METADATA_SCALE(0.3127),
+               EGL_SMPTE2086_WHITE_POINT_Y_EXT, METADATA_SCALE(0.3290),
+               EGL_SMPTE2086_MAX_LUMINANCE_EXT, METADATA_SCALE(300.0),
+               EGL_SMPTE2086_MIN_LUMINANCE_EXT, METADATA_SCALE(0.7),
+               EGL_CTA861_3_MAX_CONTENT_LIGHT_LEVEL_EXT, METADATA_SCALE(300),
+               EGL_CTA861_3_MAX_FRAME_AVERAGE_LEVEL_EXT, METADATA_SCALE(75),
+               EGL_NONE
+       };
+       testObj.addWindowAttributes(attrs);
+       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(123.0),
+               EGL_SMPTE2086_MIN_LUMINANCE_EXT, METADATA_SCALE(0.123),
+               EGL_CTA861_3_MAX_CONTENT_LIGHT_LEVEL_EXT, METADATA_SCALE(234),
+               EGL_CTA861_3_MAX_FRAME_AVERAGE_LEVEL_EXT, METADATA_SCALE(67),
+               EGL_NONE
+       };
+       testObj.addTestAttributes(testAttrs);
+       testObj.init();
+       testObj.executeTest();
+ }
+ TestCase::IterateResult HdrColorTest::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_color", "HDR Color tests")
+ {
+ }
+ void HdrColorTests::init (void)
+ {
+       addChild(new HdrColorTest(m_eglTestCtx, "8888", "Verify that SMPTE 2086 extension exists"));
+ }
+ TestCaseGroup* createHdrColorTests (EglTestContext& eglTestCtx)
+ {
+       return new HdrColorTests(eglTestCtx);
+ }
  } // egl
  } // deqp