On 3/3/26 15:52, Akihiko Odaki wrote:
> On 2026/03/03 21:05, Dmitry Osipenko wrote:
>> On 3/3/26 06:49, Akihiko Odaki wrote:
>>> On 2026/03/02 23:59, Dmitry Osipenko wrote:
>>>> 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 common parent GL context instead of a currently-bound context.
>>>>
>>>> Signed-off-by: Dmitry Osipenko <[email protected]>
>>>> ---
>>>>    ui/dbus.c          | 2 --
>>>>    ui/egl-context.c   | 3 +--
>>>>    ui/egl-headless.c  | 2 --
>>>>    ui/gtk-egl.c       | 4 ----
>>>>    ui/spice-display.c | 2 --
>>>>    5 files changed, 1 insertion(+), 12 deletions(-)
>>>>
>>>> diff --git a/ui/dbus.c b/ui/dbus.c
>>>> index 905ee6fea71b..750a064e3fbf 100644
>>>> --- a/ui/dbus.c
>>>> +++ b/ui/dbus.c
>>>> @@ -47,8 +47,6 @@ static DBusDisplay *dbus_display;
>>>>    static QEMUGLContext dbus_create_context(DisplayGLCtx *dgc,
>>>>                                             QEMUGLParams *params)
>>>>    {
>>>> -    eglMakeCurrent(qemu_egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE,
>>>> -                   qemu_egl_rn_ctx);
>>>>        return qemu_egl_create_context(dgc, params);
>>>>    }
>>>>    diff --git a/ui/egl-context.c b/ui/egl-context.c
>>>> index aed3e3ba1f3f..f9a998768beb 100644
>>>> --- a/ui/egl-context.c
>>>> +++ b/ui/egl-context.c
>>>> @@ -19,8 +19,7 @@ QEMUGLContext qemu_egl_create_context(DisplayGLCtx
>>>> *dgc,
>>>>       };
>>>>       bool gles = (qemu_egl_mode == DISPLAY_GL_MODE_ES);
>>>>    -   ctx = eglCreateContext(qemu_egl_display, qemu_egl_config,
>>>> -                          eglGetCurrentContext(),
>>>> +   ctx = eglCreateContext(qemu_egl_display, qemu_egl_config,
>>>> qemu_egl_rn_ctx,
>>>>                              gles ? ctx_att_gles : ctx_att_core);
>>>>       return ctx;
>>>>    }
>>>> diff --git a/ui/egl-headless.c b/ui/egl-headless.c
>>>> index 1f6b845500dd..19955792ac95 100644
>>>> --- a/ui/egl-headless.c
>>>> +++ b/ui/egl-headless.c
>>>> @@ -42,8 +42,6 @@ static void egl_gfx_switch(DisplayChangeListener
>>>> *dcl,
>>>>    static QEMUGLContext egl_create_context(DisplayGLCtx *dgc,
>>>>                                            QEMUGLParams *params)
>>>>    {
>>>> -    eglMakeCurrent(qemu_egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE,
>>>> -                   qemu_egl_rn_ctx);
>>>>        return qemu_egl_create_context(dgc, params);
>>>>    }
>>>>    diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c
>>>> index 0dbb429958e5..6b3519419039 100644
>>>> --- a/ui/gtk-egl.c
>>>> +++ b/ui/gtk-egl.c
>>>> @@ -217,10 +217,6 @@ void gd_egl_switch(DisplayChangeListener *dcl,
>>>>    QEMUGLContext gd_egl_create_context(DisplayGLCtx *dgc,
>>>>                                        QEMUGLParams *params)
>>>>    {
>>>> -    VirtualConsole *vc = container_of(dgc, VirtualConsole, gfx.dgc);
>>>> -
>>>> -    eglMakeCurrent(qemu_egl_display, vc->gfx.esurface,
>>>> -                   vc->gfx.esurface, vc->gfx.ectx);
>>>
>>> This uses vc->gfx.ectx instead of qemu_egl_rn_ctx so it should be passed
>>> to qemu_egl_create_context().
>>
>> Good catch. AFAICS, the vc->gfx.ectx is initialized only once in the
>> code. Will double check.
>>
>> One problem with gtk-egl display is that this is the only display type I
>> haven't tested because it's not obvious how to do it, The gdk-area is
>> what always get used on my machine with both x11 and wayland, and
>> forcing gtk-egl in the code instead of gdk-area results in a crash. I'd
>> appreciate if anyone could clarify how to make QEMU use gtk-egl or
>> whether it has been obsoleted and doesn't work with modern GTK.
>>
> 
> The following worked for me:
> GDK_BACKEND=x11 qemu-system-aarch64 -M virt -display gtk,gl=on

That works, thanks a lot.

-- 
Best regards,
Dmitry

Reply via email to