Fix extension checks for EGL external image tests
authorAndy Candet <Andy.Candet@imgtec.com>
Sat, 16 Apr 2022 20:16:53 +0000 (21:16 +0100)
committerMatthew Netsch <quic_mnetsch@quicinc.com>
Thu, 2 Jun 2022 21:21:49 +0000 (21:21 +0000)
Commit 2090c97 extended dEQP-EGL.functional.image.modify.* with new
actions to test sampling from an external image. The actions implement
getRequiredExtension, so they were likely intended to be skipped if
GL_OES_EGL_image_external is not available.

However, extension checks are only performed for actions invoked through
ImageFormatCase. These actions are invoked one level down the call
stack, through RenderTryAll.

The result is that 22 tests in dEQP-EGL.functional.image.modify.* fail
during shader compilation if the extension is not available.

This commit adds an extension check to RenderTryAll::invokeGLES. Actions
will be skipped if the check fails. This is probably what was intended
in the first place, since RenderTryAll ignores NotSupported results.

Affects: dEQP-EGL.functional.image.modify.*

Components: EGL

Change-Id: Id1106d69fbe71d39695fc32513d80d23f1e94b40

modules/egl/teglImageFormatTests.cpp

index 218eaf2..c900381 100644 (file)
@@ -421,6 +421,36 @@ static void framebufferRenderbuffer (const glw::Functions& gl, GLenum attachment
                                                ("EGLImage as " + string(glu::getFramebufferAttachmentName(attachment)) + " not supported").c_str());
 }
 
+static set<string> getSupportedExtensions (tcu::TestLog& log, const Library& egl, const EGLDisplay dpy, const glw::Functions gl)
+{
+       set<string>                             exts;
+       const vector<string>    glExts  = de::splitString((const char*) gl.getString(GL_EXTENSIONS));
+       const vector<string>    eglExts = eglu::getDisplayExtensions(egl, dpy);
+
+       exts.insert(glExts.begin(), glExts.end());
+       exts.insert(eglExts.begin(), eglExts.end());
+
+       if (eglu::getVersion(egl, dpy) >= eglu::Version(1, 5))
+       {
+               // EGL 1.5 has built-in support for EGLImage and GL sources
+               exts.insert("EGL_KHR_image_base");
+               exts.insert("EGL_KHR_gl_texture_2D_image");
+               exts.insert("EGL_KHR_gl_texture_cubemap_image");
+               exts.insert("EGL_KHR_gl_renderbuffer_image");
+       }
+
+       if (!de::contains(exts, "EGL_KHR_image_base") && !de::contains(exts, "EGL_KHR_image"))
+       {
+               log << tcu::TestLog::Message
+                       << "EGL version is under 1.5 and neither EGL_KHR_image nor EGL_KHR_image_base is supported."
+                       << "One should be supported."
+                       << tcu::TestLog::EndMessage;
+               TCU_THROW(NotSupportedError, "Extension not supported: EGL_KHR_image_base");
+       }
+
+       return exts;
+}
+
 static const float squareTriangleCoords[] =
 {
        -1.0, -1.0,
@@ -1205,11 +1235,17 @@ bool GLESImageApi::RenderTryAll::invokeGLES (GLESImageApi& api, MovePtr<UniqueIm
        GLESImageApi::RenderDepthbuffer                                 renderDepth;
        GLESImageApi::RenderStencilbuffer                               renderStencil;
        Action*                                                                                 actions[]                               = { &renderTex2D, &renderExternal, &renderExternalSamplerArray, &renderReadPixels, &renderDepth, &renderStencil };
+       set<string>                                                                             exts                                    = getSupportedExtensions(log, api.m_egl, api.m_display, api.m_gl);
 
        for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(actions); ++ndx)
        {
                try
                {
+                       const string ext = actions[ndx]->getRequiredExtension();
+
+                       if (!de::contains(exts, ext))
+                               TCU_THROW_EXPR(NotSupportedError, "Extension not supported", ext.c_str());
+
                        if (!actions[ndx]->invoke(api, img, reference))
                                return false;
 
@@ -1387,32 +1423,7 @@ ImageFormatCase::~ImageFormatCase (void)
 
 void ImageFormatCase::checkExtensions (void)
 {
-       const Library&                  egl             = m_eglTestCtx.getLibrary();
-       const EGLDisplay                dpy             = m_display;
-       set<string>                             exts;
-       const vector<string>    glExts  = de::splitString((const char*) m_gl.getString(GL_EXTENSIONS));
-       const vector<string>    eglExts = eglu::getDisplayExtensions(egl, dpy);
-
-       exts.insert(glExts.begin(), glExts.end());
-       exts.insert(eglExts.begin(), eglExts.end());
-
-       if (eglu::getVersion(egl, dpy) >= eglu::Version(1, 5))
-       {
-               // EGL 1.5 has built-in support for EGLImage and GL sources
-               exts.insert("EGL_KHR_image_base");
-               exts.insert("EGL_KHR_gl_texture_2D_image");
-               exts.insert("EGL_KHR_gl_texture_cubemap_image");
-               exts.insert("EGL_KHR_gl_renderbuffer_image");
-       }
-
-       if (!de::contains(exts, "EGL_KHR_image_base") && !de::contains(exts, "EGL_KHR_image"))
-       {
-               getLog() << tcu::TestLog::Message
-                                << "EGL version is under 1.5 and neither EGL_KHR_image nor EGL_KHR_image_base is supported."
-                                << "One should be supported."
-                                << tcu::TestLog::EndMessage;
-               TCU_THROW(NotSupportedError, "Extension not supported: EGL_KHR_image_base");
-       }
+       set<string> exts = getSupportedExtensions(getLog(), m_eglTestCtx.getLibrary(), m_display, m_gl);
 
        for (int operationNdx = 0; operationNdx < (int)m_spec.operations.size(); operationNdx++)
        {