Destroy glx context on fail/deinit

This commit is contained in:
dec05eba
2024-03-21 10:49:11 +01:00
parent 61a25c0dcc
commit c2af57a978
2 changed files with 15 additions and 0 deletions

View File

@@ -213,6 +213,7 @@ struct gsr_egl {
Bool (*glXMakeContextCurrent)(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx); Bool (*glXMakeContextCurrent)(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
// TODO: Remove // TODO: Remove
GLXContext (*glXCreateNewContext)(Display *dpy, GLXFBConfig config, int renderType, GLXContext shareList, Bool direct); GLXContext (*glXCreateNewContext)(Display *dpy, GLXFBConfig config, int renderType, GLXContext shareList, Bool direct);
void (*glXDestroyContext)(Display *dpy, GLXContext ctx);
void (*glXSwapBuffers)(Display *dpy, GLXDrawable drawable); void (*glXSwapBuffers)(Display *dpy, GLXDrawable drawable);
FUNC_glXCreateContextAttribsARB glXCreateContextAttribsARB; FUNC_glXCreateContextAttribsARB glXCreateContextAttribsARB;

View File

@@ -318,6 +318,12 @@ static bool gsr_egl_switch_to_glx_context(gsr_egl *self) {
return true; return true;
fail: fail:
if(self->glx_context) {
self->glXMakeContextCurrent(self->x11.dpy, None, None, NULL);
self->glXDestroyContext(self->x11.dpy, self->glx_context);
self->glx_context = NULL;
self->glx_fb_config = NULL;
}
return false; return false;
} }
@@ -372,6 +378,7 @@ static bool gsr_egl_load_glx(gsr_egl *self, void *library) {
{ (void**)&self->glXChooseFBConfig, "glXChooseFBConfig" }, { (void**)&self->glXChooseFBConfig, "glXChooseFBConfig" },
{ (void**)&self->glXMakeContextCurrent, "glXMakeContextCurrent" }, { (void**)&self->glXMakeContextCurrent, "glXMakeContextCurrent" },
{ (void**)&self->glXCreateNewContext, "glXCreateNewContext" }, { (void**)&self->glXCreateNewContext, "glXCreateNewContext" },
{ (void**)&self->glXDestroyContext, "glXDestroyContext" },
{ (void**)&self->glXSwapBuffers, "glXSwapBuffers" }, { (void**)&self->glXSwapBuffers, "glXSwapBuffers" },
{ NULL, NULL } { NULL, NULL }
@@ -567,6 +574,13 @@ void gsr_egl_unload(gsr_egl *self) {
self->egl_display = NULL; self->egl_display = NULL;
} }
if(self->glx_context) {
self->glXMakeContextCurrent(self->x11.dpy, None, None, NULL);
self->glXDestroyContext(self->x11.dpy, self->glx_context);
self->glx_context = NULL;
self->glx_fb_config = NULL;
}
if(self->x11.window) { if(self->x11.window) {
XDestroyWindow(self->x11.dpy, self->x11.window); XDestroyWindow(self->x11.dpy, self->x11.window);
self->x11.window = None; self->x11.window = None;