qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] qemu/ui: set swap interval explicitly when OpenGL is enabled
@ 2024-09-11  9:14 gert.wollny
  2024-09-11 10:06 ` Marc-André Lureau
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: gert.wollny @ 2024-09-11  9:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gert Wollny

From: Gert Wollny <gert.wollny@collabora.com>

Before 176e3783f2ab (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: 176e3783f2ab (ui/sdl2: OpenGL window context)
Closes: https://gitlab.com/qemu-project/qemu/-/issues/2565

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
---
 ui/sdl2.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/ui/sdl2.c b/ui/sdl2.c
index 98ed974371..51299f3645 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -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);
-- 
2.44.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] qemu/ui: set swap interval explicitly when OpenGL is enabled
  2024-09-11  9:14 [PATCH] qemu/ui: set swap interval explicitly when OpenGL is enabled gert.wollny
@ 2024-09-11 10:06 ` Marc-André Lureau
  2024-09-11 12:10 ` Philippe Mathieu-Daudé
  2024-09-16 14:46 ` Michael Tokarev
  2 siblings, 0 replies; 4+ messages in thread
From: Marc-André Lureau @ 2024-09-11 10:06 UTC (permalink / raw)
  To: gert.wollny; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1593 bytes --]

On Wed, Sep 11, 2024 at 1:15 PM <gert.wollny@collabora.com> wrote:

> From: Gert Wollny <gert.wollny@collabora.com>
>
> Before 176e3783f2ab (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: 176e3783f2ab (ui/sdl2: OpenGL window context)
> Closes: https://gitlab.com/qemu-project/qemu/-/issues/2565
>
> Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
>

Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>


> ---
>  ui/sdl2.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/ui/sdl2.c b/ui/sdl2.c
> index 98ed974371..51299f3645 100644
> --- a/ui/sdl2.c
> +++ b/ui/sdl2.c
> @@ -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);
> --
> 2.44.2
>
>
>

-- 
Marc-André Lureau

[-- Attachment #2: Type: text/html, Size: 2698 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] qemu/ui: set swap interval explicitly when OpenGL is enabled
  2024-09-11  9:14 [PATCH] qemu/ui: set swap interval explicitly when OpenGL is enabled gert.wollny
  2024-09-11 10:06 ` Marc-André Lureau
@ 2024-09-11 12:10 ` Philippe Mathieu-Daudé
  2024-09-16 14:46 ` Michael Tokarev
  2 siblings, 0 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-09-11 12:10 UTC (permalink / raw)
  To: gert.wollny, qemu-devel

On 11/9/24 11:14, gert.wollny@collabora.com wrote:
> From: Gert Wollny <gert.wollny@collabora.com>
> 
> Before 176e3783f2ab (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: 176e3783f2ab (ui/sdl2: OpenGL window context)
> Closes: https://gitlab.com/qemu-project/qemu/-/issues/2565
> 
> Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
> ---
>   ui/sdl2.c | 1 +
>   1 file changed, 1 insertion(+)

Queued, thanks.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] qemu/ui: set swap interval explicitly when OpenGL is enabled
  2024-09-11  9:14 [PATCH] qemu/ui: set swap interval explicitly when OpenGL is enabled gert.wollny
  2024-09-11 10:06 ` Marc-André Lureau
  2024-09-11 12:10 ` Philippe Mathieu-Daudé
@ 2024-09-16 14:46 ` Michael Tokarev
  2 siblings, 0 replies; 4+ messages in thread
From: Michael Tokarev @ 2024-09-16 14:46 UTC (permalink / raw)
  To: gert.wollny, qemu-devel, qemu-stable

On 11.09.2024 12:14, gert.wollny@collabora.com wrote:
> From: Gert Wollny <gert.wollny@collabora.com>
> 
> Before 176e3783f2ab (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: 176e3783f2ab (ui/sdl2: OpenGL window context)
> Closes: https://gitlab.com/qemu-project/qemu/-/issues/2565

Is it a qemu-stable material (8.2, 9.0, 9.1) ?

Picked it up for now, please notify me if I should drop it.

Also please notify me if I should pick some other changes
for -stable.

Thanks,

/mjt


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-09-16 14:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-11  9:14 [PATCH] qemu/ui: set swap interval explicitly when OpenGL is enabled gert.wollny
2024-09-11 10:06 ` Marc-André Lureau
2024-09-11 12:10 ` Philippe Mathieu-Daudé
2024-09-16 14:46 ` Michael Tokarev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).