From 32437099fdae2a4d2d85a630aa2d99a93cad289d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mika=20Isoj=C3=A4rvi?= Date: Wed, 17 Feb 2016 15:21:00 -0800 Subject: [PATCH] Fix EGLImage format compatibility check. Bug: 27224316 Change-Id: I5fa4288379a620c0cd36a8a2fd93d7868857812c --- android/cts/master/com.drawelements.deqp.egl.xml | 21 ----- android/cts/master/egl-master.txt | 7 -- modules/egl/teglAndroidUtil.cpp | 2 +- modules/egl/teglImageFormatTests.cpp | 106 ++++++++++++++++------- modules/egl/teglImageUtil.cpp | 32 ++++++- modules/egl/teglImageUtil.hpp | 2 +- 6 files changed, 108 insertions(+), 62 deletions(-) diff --git a/android/cts/master/com.drawelements.deqp.egl.xml b/android/cts/master/com.drawelements.deqp.egl.xml index e557301..b931e93 100644 --- a/android/cts/master/com.drawelements.deqp.egl.xml +++ b/android/cts/master/com.drawelements.deqp.egl.xml @@ -3149,9 +3149,6 @@ - - - @@ -3167,12 +3164,6 @@ - - - - - - @@ -3182,18 +3173,12 @@ - - - - - - @@ -3203,9 +3188,6 @@ - - - @@ -3218,9 +3200,6 @@ - - - diff --git a/android/cts/master/egl-master.txt b/android/cts/master/egl-master.txt index 2f76b88..00b7cd1 100644 --- a/android/cts/master/egl-master.txt +++ b/android/cts/master/egl-master.txt @@ -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 diff --git a/modules/egl/teglAndroidUtil.cpp b/modules/egl/teglAndroidUtil.cpp index e32c18a..95e3d9e 100644 --- a/modules/egl/teglAndroidUtil.cpp +++ b/modules/egl/teglAndroidUtil.cpp @@ -106,7 +106,7 @@ public: MovePtr 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; diff --git a/modules/egl/teglImageFormatTests.cpp b/modules/egl/teglImageFormatTests.cpp index 2d46751..8d6cea0 100644 --- a/modules/egl/teglImageFormatTests.cpp +++ b/modules/egl/teglImageFormatTests.cpp @@ -185,7 +185,7 @@ public: Create (MovePtr imgSource) : m_imgSource(imgSource) {} string getRequiredExtension (void) const { return m_imgSource->getRequiredExtension(); } bool invokeGLES2 (GLES2ImageApi& api, MovePtr& 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 m_imgSource; @@ -216,6 +216,7 @@ public: ModifyTexSubImage (GLenum format, GLenum type) : m_format(format), m_type(type) {} bool invokeGLES2 (GLES2ImageApi& api, MovePtr& 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(&create)) { - const GLenum createFormat = gles2Create->getFormat(); + const GLenum createFormat = gles2Create->getEffectiveFormat(); if (dynamic_cast(&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(&create)) { - const GLenum createFormat = gles2Create->getFormat(); + const GLenum createFormat = gles2Create->getEffectiveFormat(); if (const GLES2ImageApi::ModifyTexSubImage* gles2TexSubImageModify = dynamic_cast(&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(&modify)) diff --git a/modules/egl/teglImageUtil.cpp b/modules/egl/teglImageUtil.cpp index 1228b8c..169e8c2 100644 --- a/modules/egl/teglImageUtil.cpp +++ b/modules/egl/teglImageUtil.cpp @@ -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 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 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 createBuffer (const glw::Functions&, tcu::Texture2D*) const { fail(); return de::MovePtr(); } 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; diff --git a/modules/egl/teglImageUtil.hpp b/modules/egl/teglImageUtil.hpp index d3c3747..beca1be 100644 --- a/modules/egl/teglImageUtil.hpp +++ b/modules/egl/teglImageUtil.hpp @@ -74,7 +74,7 @@ public: virtual std::string getRequiredExtension(void) const = 0; virtual de::MovePtr 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 createTextureImageSource (eglw::EGLenum source, glw::GLenum internalFormat, glw::GLenum format, glw::GLenum type, bool useTexLevel0 = false); -- 2.7.4