EGLContext 资源是否自动释放?
Are EGLContext resources freed automatically?
我正在开发一个运行在不同 EGL 实现上的应用程序,例如 Mesa、ANGLE、AMD EGL 等。该应用程序创建多个线程,每个线程都有多个 EGLContext。
当一个线程退出时,它应该在销毁上下文之前释放在上下文中创建的所有纹理、缓冲区等(eglDestroyContext),还是仅仅销毁上下文就足够了?假设硬件可能是 iGPU,并且它使用系统 RAM 作为内存。
如果你愿意,你可以摧毁它们,但你不必:
EGL 1.5 spec,第 3.7.2 节 "Destroying Rendering Contexts",第 57 页(强调我的):
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).
我正在开发一个运行在不同 EGL 实现上的应用程序,例如 Mesa、ANGLE、AMD EGL 等。该应用程序创建多个线程,每个线程都有多个 EGLContext。
当一个线程退出时,它应该在销毁上下文之前释放在上下文中创建的所有纹理、缓冲区等(eglDestroyContext),还是仅仅销毁上下文就足够了?假设硬件可能是 iGPU,并且它使用系统 RAM 作为内存。
如果你愿意,你可以摧毁它们,但你不必:
EGL 1.5 spec,第 3.7.2 节 "Destroying Rendering Contexts",第 57 页(强调我的):
EGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx);
All resources associated with
ctx
are marked for deletion as soon as possible. When multiple contexts share objects (seeeglCreateContext
), 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. FollowingeglDestroyContext
, the context and the handle referring to it are treated in the same fashion as a context destroyed byeglTerminate
(see section 3.2).