diff mbox series

[PULL,06/19] ui/gtk: set scanout-mode right before scheduling draw

Message ID 20230717124545.177236-7-marcandre.lureau@redhat.com
State New
Headers show
Series [PULL,01/19] virtio-gpu: fix potential divide-by-zero regression | expand

Commit Message

Marc-André Lureau July 17, 2023, 12:45 p.m. UTC
From: Dongwon Kim <dongwon.kim@intel.com>

Setting scanout mode is better to be done very last minute
right because the mode can be reset anytime after it is set in
dpy_gl_scanout_texture by any asynchronouse dpy_refresh call,
which eventually cancels drawing of the guest scanout texture.

Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
Cc: Vivek Kasireddy <vivek.kasireddy@intel.com>
Signed-off-by: Dongwon Kim <dongwon.kim@intel.com>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20230706183355.29361-1-dongwon.kim@intel.com>
---
 ui/gtk-egl.c     | 2 +-
 ui/gtk-gl-area.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Volker Rümelin July 21, 2023, 6:53 a.m. UTC | #1
Am 17.07.23 um 14:45 schrieb marcandre.lureau@redhat.com:
> From: Dongwon Kim<dongwon.kim@intel.com>
>
> Setting scanout mode is better to be done very last minute
> right because the mode can be reset anytime after it is set in
> dpy_gl_scanout_texture by any asynchronouse dpy_refresh call,
> which eventually cancels drawing of the guest scanout texture.

Hi Dongwon,

this patch breaks the QEMU guest display on my system. QEMU was started 
with ./qemu-system-x86_64 -machine q35 -device 
virtio-vga-gl,xres=1280,yres=768 -display gtk,zoom-to-fit=off,gl=on. I 
can see the OVMF boot screen and then GRUB. After Linux was started, 
plymouth normally shows the OVMF boot logo and a rotating spinner. With 
your patch the guest screen stays black and I see a text cursor in the 
upper left corner. It seems the guest works without issues. I can use 
ssh to log in and I can't find any obvious errors in the guest log 
files. I tested on a host GNOME desktop under X11 and again under 
Wayland. In both cases the result is a black guest screen.

With best regards,
Volker

> Cc: Gerd Hoffmann<kraxel@redhat.com>
> Cc: Marc-André Lureau<marcandre.lureau@redhat.com>
> Cc: Vivek Kasireddy<vivek.kasireddy@intel.com>
> Signed-off-by: Dongwon Kim<dongwon.kim@intel.com>
> Acked-by: Marc-André Lureau<marcandre.lureau@redhat.com>
> Message-ID:<20230706183355.29361-1-dongwon.kim@intel.com>
> ---
>   ui/gtk-egl.c     | 2 +-
>   ui/gtk-gl-area.c | 2 +-
>   2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c
> index eee821d73a..98b3a116bf 100644
> --- a/ui/gtk-egl.c
> +++ b/ui/gtk-egl.c
> @@ -242,7 +242,6 @@ void gd_egl_scanout_texture(DisplayChangeListener *dcl,
>       eglMakeCurrent(qemu_egl_display, vc->gfx.esurface,
>                      vc->gfx.esurface, vc->gfx.ectx);
>   
> -    gtk_egl_set_scanout_mode(vc, true);
>       egl_fb_setup_for_tex(&vc->gfx.guest_fb, backing_width, backing_height,
>                            backing_id, false);
>   }
> @@ -353,6 +352,7 @@ void gd_egl_flush(DisplayChangeListener *dcl,
>       if (vc->gfx.guest_fb.dmabuf && !vc->gfx.guest_fb.dmabuf->draw_submitted) {
>           graphic_hw_gl_block(vc->gfx.dcl.con, true);
>           vc->gfx.guest_fb.dmabuf->draw_submitted = true;
> +        gtk_egl_set_scanout_mode(vc, true);
>           gtk_widget_queue_draw_area(area, x, y, w, h);
>           return;
>       }
> diff --git a/ui/gtk-gl-area.c b/ui/gtk-gl-area.c
> index 4513d3d059..28d9e49888 100644
> --- a/ui/gtk-gl-area.c
> +++ b/ui/gtk-gl-area.c
> @@ -264,7 +264,6 @@ void gd_gl_area_scanout_texture(DisplayChangeListener *dcl,
>           return;
>       }
>   
> -    gtk_gl_area_set_scanout_mode(vc, true);
>       egl_fb_setup_for_tex(&vc->gfx.guest_fb, backing_width, backing_height,
>                            backing_id, false);
>   }
> @@ -284,6 +283,7 @@ void gd_gl_area_scanout_flush(DisplayChangeListener *dcl,
>       if (vc->gfx.guest_fb.dmabuf && !vc->gfx.guest_fb.dmabuf->draw_submitted) {
>           graphic_hw_gl_block(vc->gfx.dcl.con, true);
>           vc->gfx.guest_fb.dmabuf->draw_submitted = true;
> +        gtk_gl_area_set_scanout_mode(vc, true);
>       }
>       gtk_gl_area_queue_render(GTK_GL_AREA(vc->gfx.drawing_area));
>   }
Kim, Dongwon July 24, 2023, 4:47 a.m. UTC | #2
Hi there,

I guess removing this line would have been causing the problem. Can you 
add this line back and test it?

diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c
index eee821d73a..98b3a116bf 100644
--- a/ui/gtk-egl.c
+++ b/ui/gtk-egl.c
@@ -242,7 +242,6 @@ void gd_egl_scanout_texture(DisplayChangeListener *dcl,
       eglMakeCurrent(qemu_egl_display, vc->gfx.esurface,
                      vc->gfx.esurface, vc->gfx.ectx);
   -    gtk_egl_set_scanout_mode(vc, true);
       egl_fb_setup_for_tex(&vc->gfx.guest_fb, backing_width, 
backing_height,
                            backing_id, false);
   }

Thanks!

On 7/20/2023 11:53 PM, Volker Rümelin wrote:
> Am 17.07.23 um 14:45 schrieb marcandre.lureau@redhat.com:
>> From: Dongwon Kim<dongwon.kim@intel.com>
>>
>> Setting scanout mode is better to be done very last minute
>> right because the mode can be reset anytime after it is set in
>> dpy_gl_scanout_texture by any asynchronouse dpy_refresh call,
>> which eventually cancels drawing of the guest scanout texture.
>
> Hi Dongwon,
>
> this patch breaks the QEMU guest display on my system. QEMU was 
> started with ./qemu-system-x86_64 -machine q35 -device 
> virtio-vga-gl,xres=1280,yres=768 -display gtk,zoom-to-fit=off,gl=on. I 
> can see the OVMF boot screen and then GRUB. After Linux was started, 
> plymouth normally shows the OVMF boot logo and a rotating spinner. 
> With your patch the guest screen stays black and I see a text cursor 
> in the upper left corner. It seems the guest works without issues. I 
> can use ssh to log in and I can't find any obvious errors in the guest 
> log files. I tested on a host GNOME desktop under X11 and again under 
> Wayland. In both cases the result is a black guest screen.
>
> With best regards,
> Volker
>
>> Cc: Gerd Hoffmann<kraxel@redhat.com>
>> Cc: Marc-André Lureau<marcandre.lureau@redhat.com>
>> Cc: Vivek Kasireddy<vivek.kasireddy@intel.com>
>> Signed-off-by: Dongwon Kim<dongwon.kim@intel.com>
>> Acked-by: Marc-André Lureau<marcandre.lureau@redhat.com>
>> Message-ID:<20230706183355.29361-1-dongwon.kim@intel.com>
>> ---
>>   ui/gtk-egl.c     | 2 +-
>>   ui/gtk-gl-area.c | 2 +-
>>   2 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c
>> index eee821d73a..98b3a116bf 100644
>> --- a/ui/gtk-egl.c
>> +++ b/ui/gtk-egl.c
>> @@ -242,7 +242,6 @@ void gd_egl_scanout_texture(DisplayChangeListener 
>> *dcl,
>>       eglMakeCurrent(qemu_egl_display, vc->gfx.esurface,
>>                      vc->gfx.esurface, vc->gfx.ectx);
>>   -    gtk_egl_set_scanout_mode(vc, true);
>>       egl_fb_setup_for_tex(&vc->gfx.guest_fb, backing_width, 
>> backing_height,
>>                            backing_id, false);
>>   }
>> @@ -353,6 +352,7 @@ void gd_egl_flush(DisplayChangeListener *dcl,
>>       if (vc->gfx.guest_fb.dmabuf && 
>> !vc->gfx.guest_fb.dmabuf->draw_submitted) {
>>           graphic_hw_gl_block(vc->gfx.dcl.con, true);
>>           vc->gfx.guest_fb.dmabuf->draw_submitted = true;
>> +        gtk_egl_set_scanout_mode(vc, true);
>>           gtk_widget_queue_draw_area(area, x, y, w, h);
>>           return;
>>       }
>> diff --git a/ui/gtk-gl-area.c b/ui/gtk-gl-area.c
>> index 4513d3d059..28d9e49888 100644
>> --- a/ui/gtk-gl-area.c
>> +++ b/ui/gtk-gl-area.c
>> @@ -264,7 +264,6 @@ void 
>> gd_gl_area_scanout_texture(DisplayChangeListener *dcl,
>>           return;
>>       }
>>   -    gtk_gl_area_set_scanout_mode(vc, true);
>>       egl_fb_setup_for_tex(&vc->gfx.guest_fb, backing_width, 
>> backing_height,
>>                            backing_id, false);
>>   }
>> @@ -284,6 +283,7 @@ void 
>> gd_gl_area_scanout_flush(DisplayChangeListener *dcl,
>>       if (vc->gfx.guest_fb.dmabuf && 
>> !vc->gfx.guest_fb.dmabuf->draw_submitted) {
>>           graphic_hw_gl_block(vc->gfx.dcl.con, true);
>>           vc->gfx.guest_fb.dmabuf->draw_submitted = true;
>> +        gtk_gl_area_set_scanout_mode(vc, true);
>>       }
>> gtk_gl_area_queue_render(GTK_GL_AREA(vc->gfx.drawing_area));
>>   }
>
Volker Rümelin July 24, 2023, 5:23 p.m. UTC | #3
Am 24.07.23 um 06:47 schrieb Kim, Dongwon:
> Hi there,
>
> I guess removing this line would have been causing the problem. Can 
> you add this line back and test it?
>
> diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c
> index eee821d73a..98b3a116bf 100644
> --- a/ui/gtk-egl.c
> +++ b/ui/gtk-egl.c
> @@ -242,7 +242,6 @@ void gd_egl_scanout_texture(DisplayChangeListener 
> *dcl,
>       eglMakeCurrent(qemu_egl_display, vc->gfx.esurface,
>                      vc->gfx.esurface, vc->gfx.ectx);
>   -    gtk_egl_set_scanout_mode(vc, true);
>       egl_fb_setup_for_tex(&vc->gfx.guest_fb, backing_width, 
> backing_height,
>                            backing_id, false);
>   }
>
> Thanks!
>

Adding back this line fixes the black guest screen when running the host 
under X11. For Wayland I had to add back the similar line in 
ui/gtk-gl-area.c.

With best regards,
Volker

> On 7/20/2023 11:53 PM, Volker Rümelin wrote:
>> Am 17.07.23 um 14:45 schrieb marcandre.lureau@redhat.com:
>>> From: Dongwon Kim<dongwon.kim@intel.com>
>>>
>>> Setting scanout mode is better to be done very last minute
>>> right because the mode can be reset anytime after it is set in
>>> dpy_gl_scanout_texture by any asynchronouse dpy_refresh call,
>>> which eventually cancels drawing of the guest scanout texture.
>>
>> Hi Dongwon,
>>
>> this patch breaks the QEMU guest display on my system. QEMU was 
>> started with ./qemu-system-x86_64 -machine q35 -device 
>> virtio-vga-gl,xres=1280,yres=768 -display gtk,zoom-to-fit=off,gl=on. 
>> I can see the OVMF boot screen and then GRUB. After Linux was 
>> started, plymouth normally shows the OVMF boot logo and a rotating 
>> spinner. With your patch the guest screen stays black and I see a 
>> text cursor in the upper left corner. It seems the guest works 
>> without issues. I can use ssh to log in and I can't find any obvious 
>> errors in the guest log files. I tested on a host GNOME desktop under 
>> X11 and again under Wayland. In both cases the result is a black 
>> guest screen.
>>
>> With best regards,
>> Volker
>>
>>> Cc: Gerd Hoffmann<kraxel@redhat.com>
>>> Cc: Marc-André Lureau<marcandre.lureau@redhat.com>
>>> Cc: Vivek Kasireddy<vivek.kasireddy@intel.com>
>>> Signed-off-by: Dongwon Kim<dongwon.kim@intel.com>
>>> Acked-by: Marc-André Lureau<marcandre.lureau@redhat.com>
>>> Message-ID:<20230706183355.29361-1-dongwon.kim@intel.com>
>>> ---
>>>   ui/gtk-egl.c     | 2 +-
>>>   ui/gtk-gl-area.c | 2 +-
>>>   2 files changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c
>>> index eee821d73a..98b3a116bf 100644
>>> --- a/ui/gtk-egl.c
>>> +++ b/ui/gtk-egl.c
>>> @@ -242,7 +242,6 @@ void 
>>> gd_egl_scanout_texture(DisplayChangeListener *dcl,
>>>       eglMakeCurrent(qemu_egl_display, vc->gfx.esurface,
>>>                      vc->gfx.esurface, vc->gfx.ectx);
>>>   -    gtk_egl_set_scanout_mode(vc, true);
>>>       egl_fb_setup_for_tex(&vc->gfx.guest_fb, backing_width, 
>>> backing_height,
>>>                            backing_id, false);
>>>   }
>>> @@ -353,6 +352,7 @@ void gd_egl_flush(DisplayChangeListener *dcl,
>>>       if (vc->gfx.guest_fb.dmabuf && 
>>> !vc->gfx.guest_fb.dmabuf->draw_submitted) {
>>>           graphic_hw_gl_block(vc->gfx.dcl.con, true);
>>>           vc->gfx.guest_fb.dmabuf->draw_submitted = true;
>>> +        gtk_egl_set_scanout_mode(vc, true);
>>>           gtk_widget_queue_draw_area(area, x, y, w, h);
>>>           return;
>>>       }
>>> diff --git a/ui/gtk-gl-area.c b/ui/gtk-gl-area.c
>>> index 4513d3d059..28d9e49888 100644
>>> --- a/ui/gtk-gl-area.c
>>> +++ b/ui/gtk-gl-area.c
>>> @@ -264,7 +264,6 @@ void 
>>> gd_gl_area_scanout_texture(DisplayChangeListener *dcl,
>>>           return;
>>>       }
>>>   -    gtk_gl_area_set_scanout_mode(vc, true);
>>>       egl_fb_setup_for_tex(&vc->gfx.guest_fb, backing_width, 
>>> backing_height,
>>>                            backing_id, false);
>>>   }
>>> @@ -284,6 +283,7 @@ void 
>>> gd_gl_area_scanout_flush(DisplayChangeListener *dcl,
>>>       if (vc->gfx.guest_fb.dmabuf && 
>>> !vc->gfx.guest_fb.dmabuf->draw_submitted) {
>>>           graphic_hw_gl_block(vc->gfx.dcl.con, true);
>>>           vc->gfx.guest_fb.dmabuf->draw_submitted = true;
>>> +        gtk_gl_area_set_scanout_mode(vc, true);
>>>       }
>>> gtk_gl_area_queue_render(GTK_GL_AREA(vc->gfx.drawing_area));
>>>   }
>>
diff mbox series

Patch

diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c
index eee821d73a..98b3a116bf 100644
--- a/ui/gtk-egl.c
+++ b/ui/gtk-egl.c
@@ -242,7 +242,6 @@  void gd_egl_scanout_texture(DisplayChangeListener *dcl,
     eglMakeCurrent(qemu_egl_display, vc->gfx.esurface,
                    vc->gfx.esurface, vc->gfx.ectx);
 
-    gtk_egl_set_scanout_mode(vc, true);
     egl_fb_setup_for_tex(&vc->gfx.guest_fb, backing_width, backing_height,
                          backing_id, false);
 }
@@ -353,6 +352,7 @@  void gd_egl_flush(DisplayChangeListener *dcl,
     if (vc->gfx.guest_fb.dmabuf && !vc->gfx.guest_fb.dmabuf->draw_submitted) {
         graphic_hw_gl_block(vc->gfx.dcl.con, true);
         vc->gfx.guest_fb.dmabuf->draw_submitted = true;
+        gtk_egl_set_scanout_mode(vc, true);
         gtk_widget_queue_draw_area(area, x, y, w, h);
         return;
     }
diff --git a/ui/gtk-gl-area.c b/ui/gtk-gl-area.c
index 4513d3d059..28d9e49888 100644
--- a/ui/gtk-gl-area.c
+++ b/ui/gtk-gl-area.c
@@ -264,7 +264,6 @@  void gd_gl_area_scanout_texture(DisplayChangeListener *dcl,
         return;
     }
 
-    gtk_gl_area_set_scanout_mode(vc, true);
     egl_fb_setup_for_tex(&vc->gfx.guest_fb, backing_width, backing_height,
                          backing_id, false);
 }
@@ -284,6 +283,7 @@  void gd_gl_area_scanout_flush(DisplayChangeListener *dcl,
     if (vc->gfx.guest_fb.dmabuf && !vc->gfx.guest_fb.dmabuf->draw_submitted) {
         graphic_hw_gl_block(vc->gfx.dcl.con, true);
         vc->gfx.guest_fb.dmabuf->draw_submitted = true;
+        gtk_gl_area_set_scanout_mode(vc, true);
     }
     gtk_gl_area_queue_render(GTK_GL_AREA(vc->gfx.drawing_area));
 }