Are EGLContext resources freed automatically?

781 views Asked by At

I'm developing an app which runs on different EGL implementations, such as Mesa, ANGLE, AMD EGL, etc. The app creates multiple threads, each thread has a number of EGLContexts.

When a thread exits, should it deallocate all textures, buffers, etc. created in a context before destroying it (eglDestroyContext), or is it enough to simply destroy the context? Assume that the hardware may be iGPU and it's using system RAM as its memory.

1

There are 1 answers

0
genpfault On BEST ANSWER

You can destroy them if you want, but you don't have to:

EGL 1.5 spec, section 3.7.2 "Destroying Rendering Contexts", page 57 (emphasis mine):

EGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx);

All resources associated with ctx are marked for deletion as soon as possible. When multiple contexts share objects (see eglCreateContext), such shared objects are not deleted until after all contexts on the share list are destroyed, unless the objects are first explicitly deleted by the application. Following eglDestroyContext, the context and the handle referring to it are treated in the same fashion as a context destroyed by eglTerminate (see section 3.2).