Make sure that the WM_opengl_context_create is always called on the main thread

Avoid the error 170 ("The requested resource is in use").
This commit is contained in:
Germano Cavalcante 2018-03-07 20:05:51 -03:00
parent fef1b01553
commit 8d8f7e52c1
3 changed files with 5 additions and 2 deletions

View File

@ -1952,7 +1952,6 @@ void DRW_engines_free(void)
void DRW_opengl_context_create(void)
{
BLI_assert(DST.ogl_context == NULL); /* Ensure it's called once */
BLI_assert(BLI_thread_is_main());
BLI_mutex_init(&DST.ogl_context_mutex);

View File

@ -200,7 +200,6 @@ static void drw_deferred_shader_add(
BLI_addtail(&comp->queue, dsh);
/* Create one context per task. */
BLI_assert(BLI_thread_is_main());
comp->ogl_context = WM_opengl_context_create();
WM_opengl_context_activate(DST.ogl_context);

View File

@ -2075,6 +2075,11 @@ void wm_window_IME_end(wmWindow *win)
void *WM_opengl_context_create(void)
{
/* On Windows there is a problem creating contexts that share lists
* from one context that is current in another thread.
* So we should call this function only on the main thread.
*/
BLI_assert(BLI_thread_is_main());
return GHOST_CreateOpenGLContext(g_system);
}