Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2018-02-20 01:50:52 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-02-21 17:28:26 +0300
commit1b3f9ecd0d0bdf20de24f72d73517cc97d925a15 (patch)
treee56337f844a8f58ce249d28ae60486f94175c718 /source/blender
parentd4ee0cee51e01cf62acc1e239844fcb6c7dbf449 (diff)
Gawain: Add new context/vao manager.
This allows allocation of VAOs from different opengl contexts and thread as long as the drawing happens in the same context. Allocation is thread safe as long as we abide by the "one opengl context per thread" rule. We can still free from any thread and actual freeing will occur at new vao allocation or next context binding.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenloader/intern/readfile.c1
-rw-r--r--source/blender/makesdna/DNA_windowmanager_types.h1
-rw-r--r--source/blender/windowmanager/intern/wm_files.c2
-rw-r--r--source/blender/windowmanager/intern/wm_window.c28
4 files changed, 23 insertions, 9 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 6e89ed36add..38149ae94ae 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -6496,6 +6496,7 @@ static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm)
oldnewmap_insert(fd->globmap, hook, win->workspace_hook, 0);
win->ghostwin = NULL;
+ win->gwnctx = NULL;
win->eventstate = NULL;
win->tweak = NULL;
#ifdef WIN32
diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h
index d67f86dd99c..9e1d5e4ec93 100644
--- a/source/blender/makesdna/DNA_windowmanager_types.h
+++ b/source/blender/makesdna/DNA_windowmanager_types.h
@@ -180,6 +180,7 @@ typedef struct wmWindow {
struct wmWindow *next, *prev;
void *ghostwin; /* don't want to include ghost.h stuff */
+ void *gwnctx; /* don't want to include gawin stuff */
struct Scene *scene; /* The scene displayed in this window. */
struct Scene *new_scene; /* temporary when switching */
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 98606379a61..34006fe87b8 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -182,6 +182,7 @@ static void wm_window_match_init(bContext *C, ListBase *wmlist)
static void wm_window_substitute_old(wmWindowManager *wm, wmWindow *oldwin, wmWindow *win)
{
win->ghostwin = oldwin->ghostwin;
+ win->gwnctx = oldwin->gwnctx;
win->active = oldwin->active;
if (win->active)
wm->winactive = win;
@@ -190,6 +191,7 @@ static void wm_window_substitute_old(wmWindowManager *wm, wmWindow *oldwin, wmWi
GHOST_SetWindowUserData(win->ghostwin, win); /* pointer back */
oldwin->ghostwin = NULL;
+ oldwin->gwnctx = NULL;
win->eventstate = oldwin->eventstate;
oldwin->eventstate = NULL;
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 9aecee75a15..3268841334d 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -87,6 +87,8 @@
#include "UI_resources.h"
+#include "../../../intern/gawain/gawain/gwn_context.h"
+
/* for assert */
#ifndef NDEBUG
# include "BLI_threads.h"
@@ -169,11 +171,17 @@ static void wm_window_check_position(rcti *rect)
}
-static void wm_ghostwindow_destroy(wmWindow *win)
+static void wm_ghostwindow_destroy(wmWindowManager *wm, wmWindow *win)
{
if (win->ghostwin) {
+ /* We need this window's opengl context active to discard it. */
+ wm_window_make_drawable(wm, win);
+ /* Delete local gawain objects. */
+ GWN_context_discard(win->gwnctx);
+
GHOST_DisposeWindow(g_system, win->ghostwin);
win->ghostwin = NULL;
+ win->gwnctx = NULL;
}
}
@@ -192,11 +200,6 @@ void wm_window_free(bContext *C, wmWindowManager *wm, wmWindow *win)
CTX_wm_window_set(C, NULL);
}
- /* always set drawable and active to NULL,
- * prevents non-drawable state of main windows (bugs #22967 and #25071, possibly #22477 too) */
- wm->windrawable = NULL;
- wm->winactive = NULL;
-
/* end running jobs, a job end also removes its timer */
for (wt = wm->timers.first; wt; wt = wtnext) {
wtnext = wt->next;
@@ -217,7 +220,12 @@ void wm_window_free(bContext *C, wmWindowManager *wm, wmWindow *win)
wm_draw_data_free(win);
- wm_ghostwindow_destroy(win);
+ wm_ghostwindow_destroy(wm, win);
+
+ /* always set drawable and active to NULL,
+ * prevents non-drawable state of main windows (bugs #22967 and #25071, possibly #22477 too) */
+ wm->windrawable = NULL;
+ wm->winactive = NULL;
BKE_workspace_instance_hook_free(G.main, win->workspace_hook);
MEM_freeN(win->stereo3d_format);
@@ -484,6 +492,8 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm, const char *title, wm
if (ghostwin) {
GHOST_RectangleHandle bounds;
+
+ win->gwnctx = GWN_context_create();
/* the new window has already been made drawable upon creation */
wm->windrawable = win;
@@ -1000,7 +1010,7 @@ void wm_window_make_drawable(wmWindowManager *wm, wmWindow *win)
{
if (win != wm->windrawable && win->ghostwin) {
// win->lmbut = 0; /* keeps hanging when mousepressed while other window opened */
-
+
wm->windrawable = win;
if (G.debug & G_DEBUG_EVENTS) {
printf("%s: set drawable %d\n", __func__, win->winid);
@@ -1008,6 +1018,7 @@ void wm_window_make_drawable(wmWindowManager *wm, wmWindow *win)
immDeactivate();
GHOST_ActivateWindowDrawingContext(win->ghostwin);
+ GWN_context_active_set(win->gwnctx);
immActivate();
/* this can change per window */
@@ -1784,7 +1795,6 @@ void wm_window_raise(wmWindow *win)
void wm_window_swap_buffers(wmWindow *win)
{
-
#ifdef WIN32
glDisable(GL_SCISSOR_TEST);
GHOST_SwapWindowBuffers(win->ghostwin);