diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-09-08 04:15:06 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-09-08 05:15:50 +0300 |
commit | ca8ffc523e3d08fc55c5cf000fa9fc3888950bf7 (patch) | |
tree | 389e302ad5c013642cfd0b9e9db0cb0ecf32897b /source/blender/draw/intern/draw_manager_shader.c | |
parent | 28ea459a61f65de03724db8709271d41f6bf135b (diff) |
fix flush
Diffstat (limited to 'source/blender/draw/intern/draw_manager_shader.c')
-rw-r--r-- | source/blender/draw/intern/draw_manager_shader.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/source/blender/draw/intern/draw_manager_shader.c b/source/blender/draw/intern/draw_manager_shader.c index 7eeb5a2fb67..85c04b73529 100644 --- a/source/blender/draw/intern/draw_manager_shader.c +++ b/source/blender/draw/intern/draw_manager_shader.c @@ -29,6 +29,7 @@ #include "BLI_string_utils.h" #include "BLI_threads.h" +#include "BKE_context.h" #include "BKE_global.h" #include "BKE_main.h" @@ -41,6 +42,8 @@ #include "WM_api.h" #include "WM_types.h" +#include "wm_window.h" + #include "draw_manager.h" extern char datatoc_gpu_shader_2D_vert_glsl[]; @@ -73,6 +76,7 @@ typedef struct DRWShaderCompiler { ThreadMutex compilation_lock; void *gl_context; + GPUContext *gpu_context; bool own_context; int shaders_done; /* To compute progress. */ @@ -102,10 +106,10 @@ static void drw_deferred_shader_compilation_exec( { DRWShaderCompiler *comp = (DRWShaderCompiler *)custom_data; void *gl_context = comp->gl_context; + GPUContext *gpu_context = comp->gpu_context; -#if TRUST_NO_ONE BLI_assert(gl_context != NULL); -#endif + BLI_assert(gpu_context != NULL); const bool use_main_context_workaround = GPU_use_main_context_workaround(); if (use_main_context_workaround) { @@ -114,6 +118,7 @@ static void drw_deferred_shader_compilation_exec( } WM_opengl_context_activate(gl_context); + GPU_context_active_set(gpu_context); while (true) { BLI_spin_lock(&comp->list_lock); @@ -160,6 +165,7 @@ static void drw_deferred_shader_compilation_exec( BLI_spin_unlock(&comp->list_lock); } + GPU_context_active_set(NULL); WM_opengl_context_release(gl_context); if (use_main_context_workaround) { GPU_context_main_unlock(); @@ -188,7 +194,12 @@ static void drw_deferred_shader_compilation_free(void *custom_data) if (comp->own_context) { /* Only destroy if the job owns the context. */ + WM_opengl_context_activate(comp->gl_context); + GPU_context_active_set(comp->gpu_context); + GPU_context_discard(comp->gpu_context); WM_opengl_context_dispose(comp->gl_context); + + wm_window_reset_drawable(); } MEM_freeN(comp); @@ -238,6 +249,7 @@ static void drw_deferred_shader_add(GPUMaterial *mat, bool deferred) /* Do not recreate context, just pass ownership. */ if (old_comp->gl_context) { comp->gl_context = old_comp->gl_context; + comp->gpu_context = old_comp->gpu_context; old_comp->own_context = false; comp->own_context = job_own_context; } @@ -249,10 +261,15 @@ static void drw_deferred_shader_add(GPUMaterial *mat, bool deferred) if (comp->gl_context == NULL) { if (use_main_context) { comp->gl_context = DST.gl_context; + comp->gpu_context = DST.gpu_context; } else { comp->gl_context = WM_opengl_context_create(); + comp->gpu_context = GPU_context_create(NULL); + GPU_context_active_set(NULL); + WM_opengl_context_activate(DST.gl_context); + GPU_context_active_set(DST.gpu_context); } comp->own_context = job_own_context; } |