Hello Akihiko, On 2/18/26 10:02, Akihiko Odaki wrote: > On 2026/02/18 6:49, Dmitry Osipenko wrote: >> SDL API changes GL context to a newly created GL context, which differs >> from other GL providers that don't switch context. Change SDL backend to >> restore the original GL context. This allows Qemu's virtio-gpu to support >> new virglrenderer async-fencing feature for Virgl contexts, otherwise >> virglrenderer's vrend creates a fence-sync context on the Qemu's >> main-loop thread that erroneously stays in-use by the main-loop after >> creation, not allowing vrend's fence-sync thread switch to this new >> context that belongs to it. >> >> Reviewed-by: Akihiko Odaki <[email protected]> >> Acked-by: Michael S. Tsirkin <[email protected]> >> Tested-by: Alex Bennée <[email protected]> >> Acked-by: Pierre-Eric Pelloux-Prayer <[email protected]> >> Reviewed-by: Yiwei Zhang <[email protected]> >> Signed-off-by: Dmitry Osipenko <[email protected]> >> --- >> ui/sdl2-gl.c | 3 +++ >> 1 file changed, 3 insertions(+) >> >> diff --git a/ui/sdl2-gl.c b/ui/sdl2-gl.c >> index 3be17d1079af..ea2301305d3e 100644 >> --- a/ui/sdl2-gl.c >> +++ b/ui/sdl2-gl.c >> @@ -168,6 +168,9 @@ QEMUGLContext sdl2_gl_create_context(DisplayGLCtx >> *dgc, >> SDL_GL_CONTEXT_PROFILE_ES); >> ctx = SDL_GL_CreateContext(scon->real_window); >> } >> + >> + SDL_GL_MakeCurrent(scon->real_window, scon->winctx); > > Looking at this patch now, I think this should pass NULL instead of > scon->winctx instead. The patch message says it restores "the original > GL context", but with all the "unset context after GL operations" > patches, no context should be bound. As those patches do, this should > also unset the context and prevent a thread from keeping holding the > context.
The gl_create_context() is invoked by virglrender while vrend performs GL, not while QEMU performs GL. Unbinding ctx feels like irrelevant behaviour in a case of vrend, since vrend creates new GL ctx and continues to perform GL operations - hence ctx shouldn't be unbound in case of vrend. Better will be to get current bound GL context at the beginning of gl_create_context() and restore it at the end. This will work reasonably for both QEMU and vrend cases, where in case of QEMU performing GL internally the restored ctx will be NULL. Will change it in v19 and improve the func naming + terminology. Thanks for the review. -- Best regards, Dmitry
