@samitouri / QOSamiQemu / commits / 3beb637032

ui/egl: Don't change bound GL context when creating new context

Don't change bound GL context when creating new GL context for consistency with behavior expected by virglrenderer that assumes context-creation doesn't switch context. eglCreateContext() doesn't require GL context to be bound when it's invoked. Update qemu_egl_create_context() to spawn GL sub-contexts from a given shared GL context instead of a currently-bound context. Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> Message-ID: <20260303151422.977399-4-dmitry.osipenko@collabora.com> Message-ID: <20260304165043.1437519-6-alex.bennee@linaro.org> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

Dmitry Osipenko committed Mar 4, 2026 at 16:50 UTC 3beb637032f2591e779bfd1af04be33a90c8cbeb
6 files changed +9 -16
include/ui/egl-context.h
+2 -1
@@ -5,7 +5,8 @@
5 #include "ui/egl-helpers.h"
6
7 QEMUGLContext qemu_egl_create_context(DisplayGLCtx *dgc,
8 - QEMUGLParams *params);
8 + QEMUGLParams *params,
9 + EGLContext share_context);
10 void qemu_egl_destroy_context(DisplayGLCtx *dgc, QEMUGLContext ctx);
11 int qemu_egl_make_context_current(DisplayGLCtx *dgc,
12 QEMUGLContext ctx);
ui/dbus.c
+1 -3
@@ -47,9 +47,7 @@ static DBusDisplay *dbus_display;
47 static QEMUGLContext dbus_create_context(DisplayGLCtx *dgc,
48 QEMUGLParams *params)
49 {
50 - eglMakeCurrent(qemu_egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE,
51 - qemu_egl_rn_ctx);
52 - return qemu_egl_create_context(dgc, params);
50 + return qemu_egl_create_context(dgc, params, qemu_egl_rn_ctx);
51 }
52
53 static bool
ui/egl-context.c
+3 -3
@@ -3,7 +3,8 @@
3 #include "ui/egl-context.h"
4
5 QEMUGLContext qemu_egl_create_context(DisplayGLCtx *dgc,
6 - QEMUGLParams *params)
6 + QEMUGLParams *params,
7 + EGLContext share_context)
8 {
9 EGLContext ctx;
10 EGLint ctx_att_core[] = {
@@ -19,8 +20,7 @@ QEMUGLContext qemu_egl_create_context(DisplayGLCtx *dgc,
20 };
21 bool gles = (qemu_egl_mode == DISPLAY_GL_MODE_ES);
22
22 - ctx = eglCreateContext(qemu_egl_display, qemu_egl_config,
23 - eglGetCurrentContext(),
23 + ctx = eglCreateContext(qemu_egl_display, qemu_egl_config, share_context,
24 gles ? ctx_att_gles : ctx_att_core);
25 return ctx;
26 }
ui/egl-headless.c
+1 -3
@@ -42,9 +42,7 @@ static void egl_gfx_switch(DisplayChangeListener *dcl,
42 static QEMUGLContext egl_create_context(DisplayGLCtx *dgc,
43 QEMUGLParams *params)
44 {
45 - eglMakeCurrent(qemu_egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE,
46 - qemu_egl_rn_ctx);
47 - return qemu_egl_create_context(dgc, params);
45 + return qemu_egl_create_context(dgc, params, qemu_egl_rn_ctx);
46 }
47
48 static void egl_scanout_disable(DisplayChangeListener *dcl)
ui/gtk-egl.c
+1 -3
@@ -219,9 +219,7 @@ QEMUGLContext gd_egl_create_context(DisplayGLCtx *dgc,
219 {
220 VirtualConsole *vc = container_of(dgc, VirtualConsole, gfx.dgc);
221
222 - eglMakeCurrent(qemu_egl_display, vc->gfx.esurface,
223 - vc->gfx.esurface, vc->gfx.ectx);
224 - return qemu_egl_create_context(dgc, params);
222 + return qemu_egl_create_context(dgc, params, vc->gfx.ectx);
223 }
224
225 void gd_egl_scanout_disable(DisplayChangeListener *dcl)
ui/spice-display.c
+1 -3
@@ -1033,9 +1033,7 @@ static void spice_gl_switch(DisplayChangeListener *dcl,
1033 static QEMUGLContext qemu_spice_gl_create_context(DisplayGLCtx *dgc,
1034 QEMUGLParams *params)
1035 {
1036 - eglMakeCurrent(qemu_egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE,
1037 - qemu_egl_rn_ctx);
1038 - return qemu_egl_create_context(dgc, params);
1036 + return qemu_egl_create_context(dgc, params, qemu_egl_rn_ctx);
1037 }
1038
1039 static void qemu_spice_gl_scanout_disable(DisplayChangeListener *dcl)