Skip to content

Commit

Permalink
ui/sdl2: set swap interval explicitly when OpenGL is enabled
Browse files Browse the repository at this point in the history
Before 176e378 (ui/sdl2: OpenGL window context)
SDL_CreateRenderer was called unconditionally setting
the swap interval to 0. Since SDL_CreateRenderer is now no
longer called when OpenGL is enabled, the swap interval is
no longer set explicitly and vsync handling depends on
the environment settings which may lead to a performance
regression with virgl as reported in
   https://gitlab.com/qemu-project/qemu/-/issues/2565

Restore the old vsync handling by explicitly calling
SDL_GL_SetSwapInterval if OpenGL is enabled.

Fixes: 176e378 (ui/sdl2: OpenGL window context)
Closes: https://gitlab.com/qemu-project/qemu/-/issues/2565

Signed-off-by: Gert Wollny <[email protected]>
Acked-by: Marc-André Lureau <[email protected]>
Message-ID: <01020191e05ce6df-84da6386-62c2-4ce8-840e-ad216ac253dd-000000@eu-west-1.amazonses.com>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
(cherry picked from commit ae23cd0)
Signed-off-by: Michael Tokarev <[email protected]>
  • Loading branch information
gerddie authored and Michael Tokarev committed Sep 25, 2024
1 parent bec9a96 commit b95002f
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions ui/sdl2.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ void sdl2_window_create(struct sdl2_console *scon)
SDL_SetHint(SDL_HINT_RENDER_BATCHING, "1");

scon->winctx = SDL_GL_CreateContext(scon->real_window);
SDL_GL_SetSwapInterval(0);
} else {
/* The SDL renderer is only used by sdl2-2D, when OpenGL is disabled */
scon->real_renderer = SDL_CreateRenderer(scon->real_window, -1, 0);
Expand Down

0 comments on commit b95002f

Please sign in to comment.