Browse Source

libobs-opengl: Drop gl pointers on device_leave_context

Mac was already dropping a most of these when leaving contexts,
this patch brings the same drops to linux and also drops vertex/index
buffers that were noticed as leaking across contexts and resulting in
invalid bindings by later draws. Especially with the new spacing labels.

(cherry picked from commit 599b017881239c84da7c9bf560ddb47333a5a8f1)
Kurt Kartaltepe 2 years ago
parent
commit
0a7228f1da
2 changed files with 8 additions and 0 deletions
  1. 2 0
      libobs-opengl/gl-cocoa.m
  2. 6 0
      libobs-opengl/gl-nix.c

+ 2 - 0
libobs-opengl/gl-cocoa.m

@@ -265,6 +265,8 @@ void device_leave_context(gs_device_t *device)
 {
 	glFlush();
 	[NSOpenGLContext clearCurrentContext];
+	device->cur_vertex_buffer = NULL;
+	device->cur_index_buffer = NULL;
 	device->cur_render_target = NULL;
 	device->cur_zstencil_buffer = NULL;
 	device->cur_swap = NULL;

+ 6 - 0
libobs-opengl/gl-nix.c

@@ -86,6 +86,12 @@ extern void device_enter_context(gs_device_t *device)
 
 extern void device_leave_context(gs_device_t *device)
 {
+	device->cur_render_target = NULL;
+	device->cur_zstencil_buffer = NULL;
+	device->cur_vertex_buffer = NULL;
+	device->cur_index_buffer = NULL;
+	device->cur_swap = NULL;
+	device->cur_fbo = NULL;
 	gl_vtable->device_leave_context(device);
 }