Not all display backends support various opengl contexts in multi-threads. Add a field to declare it. For now, only spice/egl has been tested successfully.
Signed-off-by: Marc-André Lureau <marcandre.lur...@redhat.com> --- ui/console.c | 6 ++++++ ui/spice-display.c | 1 + include/ui/console.h | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ui/console.c b/ui/console.c index 2407b48..52b204c 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1682,6 +1682,12 @@ bool dpy_cursor_define_supported(QemuConsole *con) return false; } +bool dpy_gl_ctx_is_mt_safe(QemuConsole *con) +{ + assert(con->gl); + return con->gl->ops->dpy_gl_ctx_is_mt_safe; +} + QEMUGLContext dpy_gl_ctx_create(QemuConsole *con, struct QEMUGLParams *qparams) { diff --git a/ui/spice-display.c b/ui/spice-display.c index 99132b6..1c916dd 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -916,6 +916,7 @@ static const DisplayChangeListenerOps display_listener_gl_ops = { .dpy_gl_ctx_destroy = qemu_egl_destroy_context, .dpy_gl_ctx_make_current = qemu_egl_make_context_current, .dpy_gl_ctx_get_current = qemu_egl_get_current_context, + .dpy_gl_ctx_is_mt_safe = true, .dpy_gl_scanout = qemu_spice_gl_scanout, .dpy_gl_update = qemu_spice_gl_update, diff --git a/include/ui/console.h b/include/ui/console.h index 2703a3a..2e7bb0e 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -221,7 +221,7 @@ typedef struct DisplayChangeListenerOps { uint32_t x, uint32_t y, uint32_t w, uint32_t h); void (*dpy_gl_update)(DisplayChangeListener *dcl, uint32_t x, uint32_t y, uint32_t w, uint32_t h); - + bool dpy_gl_ctx_is_mt_safe; /* the ctx* functions are mt-safe */ } DisplayChangeListenerOps; struct DisplayChangeListener { @@ -296,6 +296,7 @@ QEMUGLContext dpy_gl_ctx_create(QemuConsole *con, void dpy_gl_ctx_destroy(QemuConsole *con, QEMUGLContext ctx); int dpy_gl_ctx_make_current(QemuConsole *con, QEMUGLContext ctx); QEMUGLContext dpy_gl_ctx_get_current(QemuConsole *con); +bool dpy_gl_ctx_is_mt_safe(QemuConsole *con); bool console_has_gl(QemuConsole *con); -- 2.9.0