Fix EGLImage format compatibility check.
authorMika Isojärvi <misojarvi@google.com>
Wed, 17 Feb 2016 23:21:00 +0000 (15:21 -0800)
committerMika Isojärvi <misojarvi@google.com>
Thu, 18 Feb 2016 23:08:25 +0000 (15:08 -0800)
Bug: 27224316
Change-Id: I5fa4288379a620c0cd36a8a2fd93d7868857812c

android/cts/master/com.drawelements.deqp.egl.xml
android/cts/master/egl-master.txt
modules/egl/teglAndroidUtil.cpp
modules/egl/teglImageFormatTests.cpp
modules/egl/teglImageUtil.cpp
modules/egl/teglImageUtil.hpp

index e557301..b931e93 100644 (file)
                                        <Test name="tex_rgb8_tex_subimage_rgb8">
                                                <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
                                        </Test>
-                                       <Test name="tex_rgb8_tex_subimage_rgb565">
-                                               <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
-                                       </Test>
                                        <Test name="tex_rgb8_renderbuffer_clear_color">
                                                <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
                                        </Test>
                                        <Test name="tex_rgba8_tex_subimage_rgba8">
                                                <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
                                        </Test>
-                                       <Test name="tex_rgba8_tex_subimage_rgba5_a1">
-                                               <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
-                                       </Test>
-                                       <Test name="tex_rgba8_tex_subimage_rgba4">
-                                               <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
-                                       </Test>
                                        <Test name="tex_rgba8_renderbuffer_clear_color">
                                                <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
                                        </Test>
                                        <Test name="tex_rgba5_a1_tex_subimage_rgba5_a1">
                                                <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
                                        </Test>
-                                       <Test name="tex_rgba5_a1_tex_subimage_rgba4">
-                                               <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
-                                       </Test>
                                        <Test name="tex_rgba5_a1_renderbuffer_clear_color">
                                                <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
                                        </Test>
                                        <Test name="tex_rgba4_tex_subimage_rgba8">
                                                <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
                                        </Test>
-                                       <Test name="tex_rgba4_tex_subimage_rgba5_a1">
-                                               <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
-                                       </Test>
                                        <Test name="tex_rgba4_tex_subimage_rgba4">
                                                <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
                                        </Test>
                                        <Test name="renderbuffer_rgba4_tex_subimage_rgba8">
                                                <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
                                        </Test>
-                                       <Test name="renderbuffer_rgba4_tex_subimage_rgba5_a1">
-                                               <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
-                                       </Test>
                                        <Test name="renderbuffer_rgba4_tex_subimage_rgba4">
                                                <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
                                        </Test>
                                        <Test name="renderbuffer_rgb5_a1_tex_subimage_rgba5_a1">
                                                <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
                                        </Test>
-                                       <Test name="renderbuffer_rgb5_a1_tex_subimage_rgba4">
-                                               <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
-                                       </Test>
                                        <Test name="renderbuffer_rgb5_a1_renderbuffer_clear_color">
                                                <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
                                        </Test>
index 2f76b88..00b7cd1 100644 (file)
@@ -991,30 +991,23 @@ dEQP-EGL.functional.image.create.gles2_renderbuffer_rgb565_read_pixels
 dEQP-EGL.functional.image.create.gles2_renderbuffer_depth16_depth_buffer
 dEQP-EGL.functional.image.create.gles2_renderbuffer_stencil_stencil_buffer
 dEQP-EGL.functional.image.modify.tex_rgb8_tex_subimage_rgb8
-dEQP-EGL.functional.image.modify.tex_rgb8_tex_subimage_rgb565
 dEQP-EGL.functional.image.modify.tex_rgb8_renderbuffer_clear_color
 dEQP-EGL.functional.image.modify.tex_rgb565_tex_subimage_rgb8
 dEQP-EGL.functional.image.modify.tex_rgb565_tex_subimage_rgb565
 dEQP-EGL.functional.image.modify.tex_rgb565_renderbuffer_clear_color
 dEQP-EGL.functional.image.modify.tex_rgba8_tex_subimage_rgba8
-dEQP-EGL.functional.image.modify.tex_rgba8_tex_subimage_rgba5_a1
-dEQP-EGL.functional.image.modify.tex_rgba8_tex_subimage_rgba4
 dEQP-EGL.functional.image.modify.tex_rgba8_renderbuffer_clear_color
 dEQP-EGL.functional.image.modify.tex_rgba5_a1_tex_subimage_rgba8
 dEQP-EGL.functional.image.modify.tex_rgba5_a1_tex_subimage_rgba5_a1
-dEQP-EGL.functional.image.modify.tex_rgba5_a1_tex_subimage_rgba4
 dEQP-EGL.functional.image.modify.tex_rgba5_a1_renderbuffer_clear_color
 dEQP-EGL.functional.image.modify.tex_rgba4_tex_subimage_rgba8
-dEQP-EGL.functional.image.modify.tex_rgba4_tex_subimage_rgba5_a1
 dEQP-EGL.functional.image.modify.tex_rgba4_tex_subimage_rgba4
 dEQP-EGL.functional.image.modify.tex_rgba4_renderbuffer_clear_color
 dEQP-EGL.functional.image.modify.renderbuffer_rgba4_tex_subimage_rgba8
-dEQP-EGL.functional.image.modify.renderbuffer_rgba4_tex_subimage_rgba5_a1
 dEQP-EGL.functional.image.modify.renderbuffer_rgba4_tex_subimage_rgba4
 dEQP-EGL.functional.image.modify.renderbuffer_rgba4_renderbuffer_clear_color
 dEQP-EGL.functional.image.modify.renderbuffer_rgb5_a1_tex_subimage_rgba8
 dEQP-EGL.functional.image.modify.renderbuffer_rgb5_a1_tex_subimage_rgba5_a1
-dEQP-EGL.functional.image.modify.renderbuffer_rgb5_a1_tex_subimage_rgba4
 dEQP-EGL.functional.image.modify.renderbuffer_rgb5_a1_renderbuffer_clear_color
 dEQP-EGL.functional.image.modify.renderbuffer_rgb565_tex_subimage_rgb8
 dEQP-EGL.functional.image.modify.renderbuffer_rgb565_tex_subimage_rgb565
index e32c18a..95e3d9e 100644 (file)
@@ -106,7 +106,7 @@ public:
        MovePtr<ClientBuffer>   createBuffer                            (const glw::Functions&, Texture2D*) const;
        string                                  getRequiredExtension            (void) const { return "EGL_ANDROID_image_native_buffer"; }
        EGLImageKHR                             createImage                                     (const Library& egl, EGLDisplay dpy, EGLContext ctx, EGLClientBuffer clientBuffer) const;
-       GLenum                                  getFormat                                       (void) const { return m_format; }
+       GLenum                                  getEffectiveFormat                      (void) const { return m_format; }
 
 protected:
        GLenum                                  m_format;
index 2d46751..8d6cea0 100644 (file)
@@ -185,7 +185,7 @@ public:
                                                                Create                                  (MovePtr<ImageSource> imgSource) : m_imgSource(imgSource) {}
                string                                  getRequiredExtension    (void) const { return m_imgSource->getRequiredExtension(); }
                bool                                    invokeGLES2                             (GLES2ImageApi& api, MovePtr<UniqueImage>& image, tcu::Texture2D& ref) const;
-               glw::GLenum                             getFormat                               (void) const { return m_imgSource->getFormat(); }
+               glw::GLenum                             getEffectiveFormat              (void) const { return m_imgSource->getEffectiveFormat(); }
 
        private:
                UniquePtr<ImageSource>  m_imgSource;
@@ -216,6 +216,7 @@ public:
                                                        ModifyTexSubImage               (GLenum format, GLenum type) : m_format(format), m_type(type) {}
                bool                            invokeGLES2                             (GLES2ImageApi& api, MovePtr<UniqueImage>& image, tcu::Texture2D& ref) const;
                GLenum                          getFormat                               (void) const { return m_format; }
+               GLenum                          getType                                 (void) const { return m_type; }
 
        private:
                GLenum                          m_format;
@@ -1214,7 +1215,7 @@ bool isCompatibleCreateAndRenderActions (const Action& create, const Action& ren
 {
        if (const GLES2ImageApi::Create* gles2Create = dynamic_cast<const GLES2ImageApi::Create*>(&create))
        {
-               const GLenum createFormat = gles2Create->getFormat();
+               const GLenum createFormat = gles2Create->getEffectiveFormat();
 
                if (dynamic_cast<const GLES2ImageApi::RenderTexture2D*>(&render))
                {
@@ -1291,38 +1292,84 @@ TestCaseGroup* createSimpleCreationTests (EglTestContext& eglTestCtx, const stri
        return new SimpleCreationTests(eglTestCtx, name, desc);
 }
 
-bool isCompatibleFormats (GLenum createFormat, GLenum modifyFormat)
+bool isCompatibleFormats (GLenum createFormat, GLenum modifyFormat, GLenum modifyType)
 {
-       switch (createFormat)
+       switch (modifyFormat)
        {
                case GL_RGB:
-               case GL_RGB8:
-               case GL_RGB565:
-                       if (modifyFormat == GL_RGB
-                               || modifyFormat == GL_RGB8
-                               || modifyFormat == GL_RGB565)
-                               return true;
-                       else
-                               return false;
+                       switch (modifyType)
+                       {
+                               case GL_UNSIGNED_BYTE:
+                                       return createFormat == GL_RGB
+                                                       || createFormat == GL_RGB8
+                                                       || createFormat == GL_RGB565
+                                                       || createFormat == GL_SRGB8;
+
+                               case GL_BYTE:
+                                       return createFormat == GL_RGB8_SNORM;
+
+                               case GL_UNSIGNED_SHORT_5_6_5:
+                                       return createFormat == GL_RGB
+                                                       || createFormat == GL_RGB565;
+
+                               case GL_UNSIGNED_INT_10F_11F_11F_REV:
+                                       return createFormat == GL_R11F_G11F_B10F;
+
+                               case GL_UNSIGNED_INT_5_9_9_9_REV:
+                                       return createFormat == GL_RGB9_E5;
+
+                               case GL_HALF_FLOAT:
+                                       return createFormat == GL_RGB16F
+                                                       || createFormat == GL_R11F_G11F_B10F
+                                                       || createFormat == GL_RGB9_E5;
+
+                               case GL_FLOAT:
+                                       return createFormat == GL_RGB16F
+                                                       || createFormat == GL_RGB32F
+                                                       || createFormat == GL_R11F_G11F_B10F
+                                                       || createFormat == GL_RGB9_E5;
+
+                               default:
+                                       DE_FATAL("Unknown modify type");
+                                       return false;
+                       }
 
                case GL_RGBA:
-               case GL_RGBA4:
-               case GL_RGBA8:
-               case GL_RGB5_A1:
-                       if (modifyFormat == GL_RGBA
-                               || modifyFormat == GL_RGBA8
-                               || modifyFormat == GL_RGBA4
-                               || modifyFormat == GL_RGB5_A1)
-                               return true;
-                       else
-                               return false;
+                       switch (modifyType)
+                       {
+                               case GL_UNSIGNED_BYTE:
+                                       return createFormat == GL_RGBA8
+                                               || createFormat == GL_RGB5_A1
+                                               || createFormat == GL_RGBA4
+                                               || createFormat == GL_SRGB8_ALPHA8
+                                               || createFormat == GL_RGBA;
 
-               case GL_DEPTH_COMPONENT16:
-               case GL_STENCIL_INDEX8:
-                       return false;
+                               case GL_UNSIGNED_SHORT_4_4_4_4:
+                                       return createFormat == GL_RGBA4
+                                               || createFormat == GL_RGBA;
+
+                               case GL_UNSIGNED_SHORT_5_5_5_1:
+                                       return createFormat == GL_RGB5_A1
+                                               || createFormat == GL_RGBA;
+
+                               case GL_UNSIGNED_INT_2_10_10_10_REV:
+                                       return createFormat == GL_RGB10_A2
+                                               || createFormat == GL_RGB5_A1;
+
+                               case GL_HALF_FLOAT:
+                                       return createFormat == GL_RGBA16F;
+
+                               case GL_FLOAT:
+                                       return createFormat == GL_RGBA16F
+                                               || createFormat == GL_RGBA32F;
+
+                               default:
+                                       DE_FATAL("Unknown modify type");
+                                       return false;
+                       };
 
                default:
-                       DE_ASSERT(false);
+                       DE_FATAL("Unknown modify format");
                        return false;
        }
 }
@@ -1331,13 +1378,14 @@ bool isCompatibleCreateAndModifyActions (const Action& create, const Action& mod
 {
        if (const GLES2ImageApi::Create* gles2Create = dynamic_cast<const GLES2ImageApi::Create*>(&create))
        {
-               const GLenum createFormat = gles2Create->getFormat();
+               const GLenum createFormat = gles2Create->getEffectiveFormat();
 
                if (const GLES2ImageApi::ModifyTexSubImage* gles2TexSubImageModify = dynamic_cast<const GLES2ImageApi::ModifyTexSubImage*>(&modify))
                {
-                       const GLenum modifyFormat  = gles2TexSubImageModify->getFormat();
+                       const GLenum modifyFormat       = gles2TexSubImageModify->getFormat();
+                       const GLenum modifyType         = gles2TexSubImageModify->getType();
 
-                       return isCompatibleFormats(createFormat, modifyFormat);
+                       return isCompatibleFormats(createFormat, modifyFormat, modifyType);
                }
 
                if (dynamic_cast<const GLES2ImageApi::ModifyRenderbufferClearColor*>(&modify))
index 1228b8c..169e8c2 100644 (file)
@@ -180,7 +180,7 @@ class TextureImageSource : public GLImageSource
 public:
                                                        TextureImageSource      (GLenum internalFormat, GLenum format, GLenum type, bool useTexLevel0) : m_internalFormat(internalFormat), m_format(format), m_type(type), m_useTexLevel0(useTexLevel0) {}
        MovePtr<ClientBuffer>   createBuffer            (const glw::Functions& gl, Texture2D* reference) const;
-       GLenum                                  getFormat                       (void) const { return m_format; }
+       GLenum                                  getEffectiveFormat      (void) const;
        GLenum                                  getInternalFormat       (void) const { return m_internalFormat; }
 
 protected:
@@ -194,6 +194,32 @@ protected:
        const bool                              m_useTexLevel0;
 };
 
+bool isSizedFormat (GLenum format)
+{
+       try
+       {
+               glu::mapGLInternalFormat(format);
+               return true;
+       }
+       catch (const tcu::InternalError&)
+       {
+               return false;
+       }
+}
+
+GLenum getEffectiveFormat (GLenum format, GLenum type)
+{
+       return glu::getInternalFormat(glu::mapGLTransferFormat(format, type));
+}
+
+GLenum TextureImageSource::getEffectiveFormat (void) const
+{
+       if (isSizedFormat(m_internalFormat))
+               return m_internalFormat;
+       else
+               return deqp::egl::Image::getEffectiveFormat(m_format, m_type);
+}
+
 AttribMap TextureImageSource::getCreateAttribs (void) const
 {
        AttribMap ret;
@@ -307,7 +333,7 @@ public:
 
        string                                  getRequiredExtension    (void) const    { return "EGL_KHR_gl_renderbuffer_image"; }
        MovePtr<ClientBuffer>   createBuffer                    (const glw::Functions& gl, Texture2D* reference) const;
-       GLenum                                  getFormat                               (void) const { return m_format; }
+       GLenum                                  getEffectiveFormat              (void) const { return m_format; }
 
 protected:
        EGLenum                                 getSource                               (void) const    { return EGL_GL_RENDERBUFFER_KHR; }
@@ -492,7 +518,7 @@ public:
        string                                  getRequiredExtension    (void) const { fail(); return ""; }
        MovePtr<ClientBuffer>   createBuffer                    (const glw::Functions&, tcu::Texture2D*) const { fail(); return de::MovePtr<ClientBuffer>(); }
        EGLImageKHR                             createImage                             (const Library& egl, EGLDisplay dpy, EGLContext ctx, EGLClientBuffer clientBuffer) const;
-       GLenum                                  getFormat                               (void) const { return m_format; }
+       GLenum                                  getEffectiveFormat              (void) const { return m_format; }
 
 private:
        const string                    m_message;
index d3c3747..beca1be 100644 (file)
@@ -74,7 +74,7 @@ public:
        virtual std::string                                     getRequiredExtension(void) const = 0;
        virtual de::MovePtr<ClientBuffer>       createBuffer            (const glw::Functions& gl, tcu::Texture2D* reference = DE_NULL) const = 0;
        virtual eglw::EGLImageKHR                       createImage                     (const eglw::Library& egl, eglw::EGLDisplay dpy, eglw::EGLContext ctx, eglw::EGLClientBuffer clientBuffer) const = 0;
-       virtual glw::GLenum                                     getFormat                       (void) const = 0;
+       virtual glw::GLenum                                     getEffectiveFormat      (void) const = 0;
 };
 
 de::MovePtr<ImageSource> createTextureImageSource                      (eglw::EGLenum source, glw::GLenum internalFormat, glw::GLenum format, glw::GLenum type, bool useTexLevel0 = false);