diff options
author | Julian Eisel <julian@blender.org> | 2020-06-23 18:19:00 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2020-06-23 18:28:53 +0300 |
commit | 2dd60e6c2cbdf3e39ed3451ee0f67a5b00a7a5bc (patch) | |
tree | f49fd69364dfe0a045c6df0081f51d559cefb80a /source/blender/windowmanager/intern/wm_surface.c | |
parent | 1e0426da7c735b5d59f23b2b9303d9c1d72ca7f8 (diff) |
Fix T77830: Crash in VR session when opening material preview
Draw-manager mutex has to be set before activating OpenGL/GPU context.
Otherwise, parallel jobs (like preview rendering) may try to activate
the context from another thread.
Also: Use WM wrappers for activating/releasing OpenGL context, which
have an additional assert check.
Suggest to backport this for 2.83.1.
Diffstat (limited to 'source/blender/windowmanager/intern/wm_surface.c')
-rw-r--r-- | source/blender/windowmanager/intern/wm_surface.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/source/blender/windowmanager/intern/wm_surface.c b/source/blender/windowmanager/intern/wm_surface.c index e8850693d69..12e55790259 100644 --- a/source/blender/windowmanager/intern/wm_surface.c +++ b/source/blender/windowmanager/intern/wm_surface.c @@ -53,10 +53,17 @@ void wm_surfaces_iter(bContext *C, void (*cb)(bContext *C, wmSurface *)) void wm_surface_clear_drawable(void) { if (g_drawable) { + WM_opengl_context_release(g_drawable->ghost_ctx); + GPU_context_active_set(NULL); + BLF_batch_reset(); gpu_batch_presets_reset(); immDeactivate(); + if (g_drawable->deactivate) { + g_drawable->deactivate(); + } + g_drawable = NULL; } } @@ -67,7 +74,10 @@ void wm_surface_set_drawable(wmSurface *surface, bool activate) g_drawable = surface; if (activate) { - GHOST_ActivateOpenGLContext(surface->ghost_ctx); + if (surface->activate) { + surface->activate(); + } + WM_opengl_context_activate(surface->ghost_ctx); } GPU_context_active_set(surface->gpu_ctx); @@ -109,6 +119,8 @@ void wm_surface_remove(wmSurface *surface) void wm_surfaces_free(void) { + wm_surface_clear_drawable(); + for (wmSurface *surf = global_surface_list.first, *surf_next; surf; surf = surf_next) { surf_next = surf->next; wm_surface_remove(surf); |