Fix some bugs for EGL cases
authorJian Li <jian.li@arm.com>
Mon, 9 Dec 2019 05:24:05 +0000 (13:24 +0800)
committerAmy Liu <amy.liu@arm.com>
Mon, 27 Apr 2020 07:17:04 +0000 (03:17 -0400)
eglTerminate() wasn't called in proper sequence.
Resource wasn't released properly for not supported cases.

Affects:

dEQP-EGL.functional.image.*
dEQP-EGL.functional.resize.*
dEQP-EGL.functional.buffer_age.*
dEQP-EGL.functional.partial_update.*

Components: AOSP

VK-GL-CTS issue: 2153

Change-Id: Ic0a82aa176b9a8344f757916d61ea8f64c58eca5
(cherry picked from commit 53bfacd3d71753cda3448735e56ad249848c2460)

modules/egl/teglBufferAgeTests.cpp
modules/egl/teglImageFormatTests.cpp
modules/egl/teglPartialUpdateTests.cpp
modules/egl/teglResizeTests.cpp

index e1a3dc219cbd745ead93327cf403e55669a5c839..7a9f80cd7fc6e84a5821fbf332519b86787cd74f 100644 (file)
@@ -390,6 +390,14 @@ void BufferAgeTest::init (void)
        const Library&  egl     = m_eglTestCtx.getLibrary();
 
        m_eglDisplay = eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
+
+       if (eglu::hasExtension(egl, m_eglDisplay, "EGL_EXT_buffer_age") == false)
+       {
+               egl.terminate(m_eglDisplay);
+               m_eglDisplay = EGL_NO_DISPLAY;
+               TCU_THROW(NotSupportedError, "EGL_EXT_buffer_age is not supported");
+       }
+
        m_eglConfig      = getEGLConfig(m_eglTestCtx.getLibrary(), m_eglDisplay, m_preserveColorBuffer);
 
        if (m_eglConfig == DE_NULL)
@@ -401,9 +409,6 @@ void BufferAgeTest::init (void)
 
        m_eglTestCtx.initGLFunctions(&m_gl, glu::ApiType::es(2,0));
 
-       if (eglu::hasExtension(egl, m_eglDisplay, "EGL_EXT_buffer_age") == false)
-               TCU_THROW(NotSupportedError, "EGL_EXT_buffer_age is not supported");
-
        m_gles2Renderer = new GLES2Renderer(m_gl);
        m_refRenderer   = new ReferenceRenderer();
 }
index 3e3c333303817c92cec649ee71b5693a223d9041..1dee13ce64c94318eca78737e79233e1d7236fba 100644 (file)
@@ -1007,6 +1007,8 @@ void ImageFormatCase::deinit (void)
 {
        const Library& egl = m_eglTestCtx.getLibrary();
 
+       m_img.clear();
+
        for (int contexNdx = 0 ; contexNdx < (int)m_apiContexts.size(); contexNdx++)
                delete m_apiContexts[contexNdx];
 
index a70374a40e8d12f7f1456e7cfabeaf2708008ead..f496533a3902eefca42b81b860f8b00fe3b77bcb 100644 (file)
@@ -375,6 +375,14 @@ void PartialUpdateTest::init (void)
        const Library&  egl     = m_eglTestCtx.getLibrary();
 
        m_eglDisplay            = eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
+
+       if (!eglu::hasExtension(egl, m_eglDisplay, "EGL_KHR_partial_update"))
+       {
+               egl.terminate(m_eglDisplay);
+               m_eglDisplay = EGL_NO_DISPLAY;
+               TCU_THROW(NotSupportedError, "EGL_KHR_partial_update is not supported");
+       }
+
        m_eglConfig                     = getEGLConfig(m_eglTestCtx.getLibrary(), m_eglDisplay);
 
        //create surface and context and make them current
@@ -385,9 +393,6 @@ void PartialUpdateTest::init (void)
 
        m_supportBufferAge = eglu::hasExtension(egl, m_eglDisplay, "EGL_EXT_buffer_age");
 
-       if (!eglu::hasExtension(egl, m_eglDisplay, "EGL_KHR_partial_update"))
-               TCU_THROW(NotSupportedError, "EGL_KHR_partial_update is not supported");
-
        m_gles2Renderer = new GLES2Renderer(m_gl);
        m_refRenderer   = new ReferenceRenderer();
 }
index 4686d11417afa46011d20d64245e567cf3b6f07a..30b5f5b29827d4764cdd699d3795bc5a692c8c57 100644 (file)
@@ -195,14 +195,16 @@ void ResizeTest::init (void)
 
 void ResizeTest::deinit (void)
 {
-       if (m_display != EGL_NO_DISPLAY)
-               m_eglTestCtx.getLibrary().terminate(m_display);
-
        m_config                = DE_NULL;
-       m_display               = EGL_NO_DISPLAY;
        m_context.clear();
        m_surface.clear();
        m_nativeWindow.clear();
+
+       if (m_display != EGL_NO_DISPLAY)
+       {
+               m_eglTestCtx.getLibrary().terminate(m_display);
+               m_display       = EGL_NO_DISPLAY;
+       }
 }
 
 void ResizeTest::resize (IVec2 size)