WM/GPU: Clear VAO cache of batch preset when switching context.

This is needed for multiple windows to draw the batch presets.
This will not be needed once we use only one context for UI.
This commit is contained in:
Clément Foucault 2018-02-26 19:49:06 +01:00
parent 13261304a3
commit fa7e4cc685
Notes: blender-bot 2023-05-22 12:40:41 +02:00
Referenced by issue #55565, RenderDoc fails to launch 2.8 with BadDrawable error
3 changed files with 17 additions and 1 deletions

View File

@ -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__ */

View File

@ -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);

View File

@ -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);