From 45e91661ee457e64279ff86265abdbe214aa6be0 Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 15 Oct 2026 17:27:17 +0100 Subject: [PATCH] Leak resources on linux context shutdown if not bound. Closes #3921 * Linux doesn't support rebinding contexts between EGL (Android binding API) and GLX (linux) even if no context is bound, so if one platform is used then the other we can't bind our child contexts in order to delete objects when a context is destroyed. * We will have to do the same as we do if a different context is bound, and hope that the driver tidies this stuff up for us when the context is deleted. --- renderdoc/driver/gl/egl_platform.cpp | 2 ++ renderdoc/driver/gl/gl_common.h | 2 ++ renderdoc/driver/gl/gl_driver.cpp | 2 +- renderdoc/driver/gl/glx_platform.cpp | 2 ++ 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/renderdoc/driver/gl/egl_platform.cpp b/renderdoc/driver/gl/egl_platform.cpp index f39c026b7..4beb87922 100644 --- a/renderdoc/driver/gl/egl_platform.cpp +++ b/renderdoc/driver/gl/egl_platform.cpp @@ -60,6 +60,8 @@ class EGLPlatform : public GLPlatform RDCDriver m_API = RDCDriver::OpenGLES; bool m_Debug = false; + bool CanFreshBindOnDeletion() { return false; } + bool MakeContextCurrent(GLWindowingData data) { if(EGL.MakeCurrent) diff --git a/renderdoc/driver/gl/gl_common.h b/renderdoc/driver/gl/gl_common.h index 12f626c56..d0d073b4d 100644 --- a/renderdoc/driver/gl/gl_common.h +++ b/renderdoc/driver/gl/gl_common.h @@ -304,6 +304,8 @@ struct GLPlatform virtual GLWindowingData MakeOutputWindow(WindowingData window, bool depth, GLWindowingData share_context) = 0; + virtual bool CanFreshBindOnDeletion() { return true; } + // for pushing and popping a child context. The default implementation just does // MakeContextCurrent but platforms can override this if they need more complex state handling virtual bool PushChildContext(GLWindowingData existing, GLWindowingData newChild, diff --git a/renderdoc/driver/gl/gl_driver.cpp b/renderdoc/driver/gl/gl_driver.cpp index ca788672a..67758717f 100644 --- a/renderdoc/driver/gl/gl_driver.cpp +++ b/renderdoc/driver/gl/gl_driver.cpp @@ -1136,7 +1136,7 @@ void WrappedOpenGL::DeleteContext(void *contextHandle) GLWindowingData savedContext; - if(existing.ctx == NULL) + if(existing.ctx == NULL && m_Platform.CanFreshBindOnDeletion()) { if(m_Platform.PushChildContext(existing, ctxdata.shareGroup->m_BackDoor, &savedContext)) { diff --git a/renderdoc/driver/gl/glx_platform.cpp b/renderdoc/driver/gl/glx_platform.cpp index cfb676e4a..b9c47585e 100644 --- a/renderdoc/driver/gl/glx_platform.cpp +++ b/renderdoc/driver/gl/glx_platform.cpp @@ -53,6 +53,8 @@ class GLXPlatform : public GLPlatform RDCDriver m_API = RDCDriver::OpenGL; bool m_Debug = false; + bool CanFreshBindOnDeletion() { return false; } + bool MakeContextCurrent(GLWindowingData data) { if(GLX.glXMakeCurrent)