Commit f84be0ee authored by Seungha Yang's avatar Seungha Yang 🐑

glcontext/wgl: Call wglShareLists from the other context's thread

During wglShareLists() call, the other context should not be
the current in a different thread. That's restriction of wgl.
So calling wglShareLists() in the corresponding other context's thread
seems to the most safe way.
parent 8d122f21
Pipeline #57441 failed with stages
in 80 minutes and 21 seconds
......@@ -147,6 +147,31 @@ _create_context_with_flags (GstGLContextWGL * context_wgl, HDC dpy,
return ret;
}
typedef struct
{
GstGLContextWGL *self;
GError **error;
gboolean ret;
} ShareListData;
static void
gst_gl_context_wgl_share_from_other_thread (GstGLContext * other_context,
ShareListData * data)
{
HGLRC external_gl_context =
(HGLRC) gst_gl_context_get_gl_context (other_context);
if (!wglShareLists (external_gl_context, data->self->wgl_context)) {
g_set_error (data->error, GST_GL_CONTEXT_ERROR,
GST_GL_CONTEXT_ERROR_CREATE_CONTEXT,
"failed to share contexts through wglShareLists 0x%x",
(unsigned int) GetLastError ());
data->ret = FALSE;
}
data->ret = TRUE;
}
static gboolean
gst_gl_context_wgl_create_context (GstGLContext * context,
GstGLAPI gl_api, GstGLContext * other_context, GError ** error)
......@@ -247,13 +272,16 @@ gst_gl_context_wgl_create_context (GstGLContext * context,
}
if (external_gl_context) {
if (!wglShareLists (external_gl_context, context_wgl->wgl_context)) {
g_set_error (error, GST_GL_CONTEXT_ERROR,
GST_GL_CONTEXT_ERROR_CREATE_CONTEXT,
"failed to share contexts through wglShareLists 0x%x",
(unsigned int) GetLastError ());
ShareListData data;
data.self = context_wgl;
data.error = error;
gst_gl_context_thread_add (other_context,
(GstGLContextThreadFunc) gst_gl_context_wgl_share_from_other_thread,
&data);
if (!data.ret)
goto failure;
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment