diff --git a/source/blender/gpu/GPU_batch.h b/source/blender/gpu/GPU_batch.h index 5807af7b359..fda24018150 100644 --- a/source/blender/gpu/GPU_batch.h +++ b/source/blender/gpu/GPU_batch.h @@ -32,6 +32,7 @@ #define __GPU_BATCH_H__ #include "../../../intern/gawain/gawain/gwn_batch.h" +#include "../../../intern/gawain/gawain/gwn_batch_private.h" struct rctf; @@ -65,6 +66,7 @@ Gwn_Batch *GPU_batch_preset_sphere(int lod) ATTR_WARN_UNUSED_RESULT; Gwn_Batch *GPU_batch_preset_sphere_wire(int lod) ATTR_WARN_UNUSED_RESULT; void gpu_batch_presets_init(void); +void gpu_batch_presets_reset(void); void gpu_batch_presets_exit(void); #endif /* __GPU_BATCH_H__ */ diff --git a/source/blender/gpu/intern/gpu_batch_presets.c b/source/blender/gpu/intern/gpu_batch_presets.c index 21d6906083a..950f1a2dab3 100644 --- a/source/blender/gpu/intern/gpu_batch_presets.c +++ b/source/blender/gpu/intern/gpu_batch_presets.c @@ -193,6 +193,17 @@ void gpu_batch_presets_init(void) g_presets_3d.batch.sphere_wire_med = batch_sphere_wire(8, 16); } +void gpu_batch_presets_reset(void) +{ + /* Reset vao caches for these every time we switch opengl context. + * This way they will draw correctly for each window. */ + gwn_batch_vao_cache_clear(g_presets_3d.batch.sphere_low); + gwn_batch_vao_cache_clear(g_presets_3d.batch.sphere_med); + gwn_batch_vao_cache_clear(g_presets_3d.batch.sphere_high); + gwn_batch_vao_cache_clear(g_presets_3d.batch.sphere_wire_low); + gwn_batch_vao_cache_clear(g_presets_3d.batch.sphere_wire_med); +} + void gpu_batch_presets_exit(void) { GWN_batch_discard(g_presets_3d.batch.sphere_low); diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 278a70b9c9d..018318556e8 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -79,6 +79,7 @@ #include "PIL_time.h" +#include "GPU_batch.h" #include "GPU_draw.h" #include "GPU_extensions.h" #include "GPU_init_exit.h" @@ -381,6 +382,7 @@ void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win) } if (tmpwin) { + gpu_batch_presets_reset(); immDeactivate(); } @@ -501,7 +503,7 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm, const char *title, wm #endif GHOST_kDrawingContextTypeOpenGL, glSettings); - + if (ghostwin) { GHOST_RectangleHandle bounds; @@ -1028,6 +1030,7 @@ void wm_window_make_drawable(wmWindowManager *wm, wmWindow *win) printf("%s: set drawable %d\n", __func__, win->winid); } + gpu_batch_presets_reset(); immDeactivate(); GHOST_ActivateWindowDrawingContext(win->ghostwin); GWN_context_active_set(win->gwnctx);