All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/6] ui: some gl scanout improvements.
@ 2017-02-21  9:37 Gerd Hoffmann
  2017-02-21  9:37 ` [Qemu-devel] [PATCH 1/6] console: rename dpy_gl_scanout to dpy_gl_scanout_texture Gerd Hoffmann
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2017-02-21  9:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

  Hi,

Upcoming intel vgpu support will need some updates for the qemu opengl
support, specifically we will need support for importing dma-bufs.
The kernel support for this is still brewing though and thus the qemu
patches are still experimental and a moving target.

While working on it I did some cleanups and improvements on the opengl
code in qemu though, and there is no reason to wait with merging them,
so here are the first bits.

cheers,
  Gerd

Gerd Hoffmann (6):
  console: rename dpy_gl_scanout to dpy_gl_scanout_texture
  console: add dpy_gl_scanout_disable
  virtio-gpu: use dpy_gl_scanout_disable
  spice: add scanout_disable support
  sdl2: add scanout_disable support
  gtk-egl: add scanout_disable support

 hw/display/virtio-gpu-3d.c | 13 ++++++------
 include/ui/console.h       | 21 ++++++++++++-------
 include/ui/gtk.h           | 25 +++++++++++++---------
 include/ui/sdl2.h          | 13 +++++++-----
 ui/console.c               | 30 +++++++++++++++++++-------
 ui/gtk-egl.c               | 25 +++++++++++++---------
 ui/gtk-gl-area.c           | 12 ++++++-----
 ui/gtk.c                   |  5 +++--
 ui/sdl2-gl.c               | 28 ++++++++++++++++---------
 ui/sdl2.c                  |  3 ++-
 ui/spice-display.c         | 52 ++++++++++++++++++++++++++--------------------
 11 files changed, 138 insertions(+), 89 deletions(-)

-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 1/6] console: rename dpy_gl_scanout to dpy_gl_scanout_texture
  2017-02-21  9:37 [Qemu-devel] [PATCH 0/6] ui: some gl scanout improvements Gerd Hoffmann
@ 2017-02-21  9:37 ` Gerd Hoffmann
  2017-02-21  9:37 ` [Qemu-devel] [PATCH 2/6] console: add dpy_gl_scanout_disable Gerd Hoffmann
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2017-02-21  9:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Michael S. Tsirkin

We'll add a variant which accepts dmabufs soon.  Change
the name so we can easily disturgish the two variants.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/display/virtio-gpu-3d.c | 14 +++++++-------
 include/ui/console.h       | 19 +++++++++++--------
 include/ui/gtk.h           | 24 ++++++++++++++----------
 include/ui/sdl2.h          | 12 +++++++-----
 ui/console.c               | 19 +++++++++++--------
 ui/gtk-egl.c               | 10 +++++-----
 ui/gtk-gl-area.c           | 12 +++++++-----
 ui/gtk.c                   |  4 ++--
 ui/sdl2-gl.c               | 12 +++++++-----
 ui/sdl2.c                  |  2 +-
 ui/spice-display.c         | 16 ++++++++--------
 11 files changed, 80 insertions(+), 64 deletions(-)

diff --git a/hw/display/virtio-gpu-3d.c b/hw/display/virtio-gpu-3d.c
index ecb09d1..b526b3f 100644
--- a/hw/display/virtio-gpu-3d.c
+++ b/hw/display/virtio-gpu-3d.c
@@ -177,16 +177,16 @@ static void virgl_cmd_set_scanout(VirtIOGPU *g,
         qemu_console_resize(g->scanout[ss.scanout_id].con,
                             ss.r.width, ss.r.height);
         virgl_renderer_force_ctx_0();
-        dpy_gl_scanout(g->scanout[ss.scanout_id].con, info.tex_id,
-                       info.flags & 1 /* FIXME: Y_0_TOP */,
-                       info.width, info.height,
-                       ss.r.x, ss.r.y, ss.r.width, ss.r.height);
+        dpy_gl_scanout_texture(g->scanout[ss.scanout_id].con, info.tex_id,
+                               info.flags & 1 /* FIXME: Y_0_TOP */,
+                               info.width, info.height,
+                               ss.r.x, ss.r.y, ss.r.width, ss.r.height);
     } else {
         if (ss.scanout_id != 0) {
             dpy_gfx_replace_surface(g->scanout[ss.scanout_id].con, NULL);
         }
-        dpy_gl_scanout(g->scanout[ss.scanout_id].con, 0, false,
-                       0, 0, 0, 0, 0, 0);
+        dpy_gl_scanout_texture(g->scanout[ss.scanout_id].con, 0, false,
+                               0, 0, 0, 0, 0, 0);
     }
     g->scanout[ss.scanout_id].resource_id = ss.resource_id;
 }
@@ -597,7 +597,7 @@ void virtio_gpu_virgl_reset(VirtIOGPU *g)
         if (i != 0) {
             dpy_gfx_replace_surface(g->scanout[i].con, NULL);
         }
-        dpy_gl_scanout(g->scanout[i].con, 0, false, 0, 0, 0, 0, 0, 0);
+        dpy_gl_scanout_texture(g->scanout[i].con, 0, false, 0, 0, 0, 0, 0, 0);
     }
 }
 
diff --git a/include/ui/console.h b/include/ui/console.h
index af6350e..e6ae637 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -215,10 +215,13 @@ typedef struct DisplayChangeListenerOps {
                                    QEMUGLContext ctx);
     QEMUGLContext (*dpy_gl_ctx_get_current)(DisplayChangeListener *dcl);
 
-    void (*dpy_gl_scanout)(DisplayChangeListener *dcl,
-                           uint32_t backing_id, bool backing_y_0_top,
-                           uint32_t backing_width, uint32_t backing_height,
-                           uint32_t x, uint32_t y, uint32_t w, uint32_t h);
+    void (*dpy_gl_scanout_texture)(DisplayChangeListener *dcl,
+                                   uint32_t backing_id,
+                                   bool backing_y_0_top,
+                                   uint32_t backing_width,
+                                   uint32_t backing_height,
+                                   uint32_t x, uint32_t y,
+                                   uint32_t w, uint32_t h);
     void (*dpy_gl_update)(DisplayChangeListener *dcl,
                           uint32_t x, uint32_t y, uint32_t w, uint32_t h);
 
@@ -284,10 +287,10 @@ bool dpy_cursor_define_supported(QemuConsole *con);
 bool dpy_gfx_check_format(QemuConsole *con,
                           pixman_format_code_t format);
 
-void dpy_gl_scanout(QemuConsole *con,
-                    uint32_t backing_id, bool backing_y_0_top,
-                    uint32_t backing_width, uint32_t backing_height,
-                    uint32_t x, uint32_t y, uint32_t w, uint32_t h);
+void dpy_gl_scanout_texture(QemuConsole *con,
+                            uint32_t backing_id, bool backing_y_0_top,
+                            uint32_t backing_width, uint32_t backing_height,
+                            uint32_t x, uint32_t y, uint32_t w, uint32_t h);
 void dpy_gl_update(QemuConsole *con,
                    uint32_t x, uint32_t y, uint32_t w, uint32_t h);
 
diff --git a/include/ui/gtk.h b/include/ui/gtk.h
index 47ffddb..408e21b 100644
--- a/include/ui/gtk.h
+++ b/include/ui/gtk.h
@@ -103,11 +103,13 @@ void gd_egl_switch(DisplayChangeListener *dcl,
                    DisplaySurface *surface);
 QEMUGLContext gd_egl_create_context(DisplayChangeListener *dcl,
                                     QEMUGLParams *params);
-void gd_egl_scanout(DisplayChangeListener *dcl,
-                    uint32_t backing_id, bool backing_y_0_top,
-                    uint32_t backing_width, uint32_t backing_height,
-                    uint32_t x, uint32_t y,
-                    uint32_t w, uint32_t h);
+void gd_egl_scanout_texture(DisplayChangeListener *dcl,
+                            uint32_t backing_id,
+                            bool backing_y_0_top,
+                            uint32_t backing_width,
+                            uint32_t backing_height,
+                            uint32_t x, uint32_t y,
+                            uint32_t w, uint32_t h);
 void gd_egl_scanout_flush(DisplayChangeListener *dcl,
                           uint32_t x, uint32_t y, uint32_t w, uint32_t h);
 void gtk_egl_init(void);
@@ -126,11 +128,13 @@ QEMUGLContext gd_gl_area_create_context(DisplayChangeListener *dcl,
                                         QEMUGLParams *params);
 void gd_gl_area_destroy_context(DisplayChangeListener *dcl,
                                 QEMUGLContext ctx);
-void gd_gl_area_scanout(DisplayChangeListener *dcl,
-                        uint32_t backing_id, bool backing_y_0_top,
-                        uint32_t backing_width, uint32_t backing_height,
-                        uint32_t x, uint32_t y,
-                        uint32_t w, uint32_t h);
+void gd_gl_area_scanout_texture(DisplayChangeListener *dcl,
+                                uint32_t backing_id,
+                                bool backing_y_0_top,
+                                uint32_t backing_width,
+                                uint32_t backing_height,
+                                uint32_t x, uint32_t y,
+                                uint32_t w, uint32_t h);
 void gd_gl_area_scanout_flush(DisplayChangeListener *dcl,
                               uint32_t x, uint32_t y, uint32_t w, uint32_t h);
 void gtk_gl_area_init(void);
diff --git a/include/ui/sdl2.h b/include/ui/sdl2.h
index 683bb6a..2de792f 100644
--- a/include/ui/sdl2.h
+++ b/include/ui/sdl2.h
@@ -62,11 +62,13 @@ int sdl2_gl_make_context_current(DisplayChangeListener *dcl,
                                  QEMUGLContext ctx);
 QEMUGLContext sdl2_gl_get_current_context(DisplayChangeListener *dcl);
 
-void sdl2_gl_scanout(DisplayChangeListener *dcl,
-                     uint32_t backing_id, bool backing_y_0_top,
-                     uint32_t backing_width, uint32_t backing_height,
-                     uint32_t x, uint32_t y,
-                     uint32_t w, uint32_t h);
+void sdl2_gl_scanout_texture(DisplayChangeListener *dcl,
+                             uint32_t backing_id,
+                             bool backing_y_0_top,
+                             uint32_t backing_width,
+                             uint32_t backing_height,
+                             uint32_t x, uint32_t y,
+                             uint32_t w, uint32_t h);
 void sdl2_gl_scanout_flush(DisplayChangeListener *dcl,
                            uint32_t x, uint32_t y, uint32_t w, uint32_t h);
 
diff --git a/ui/console.c b/ui/console.c
index 49d0740..22c3c7d 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -1735,16 +1735,19 @@ QEMUGLContext dpy_gl_ctx_get_current(QemuConsole *con)
     return con->gl->ops->dpy_gl_ctx_get_current(con->gl);
 }
 
-void dpy_gl_scanout(QemuConsole *con,
-                    uint32_t backing_id, bool backing_y_0_top,
-                    uint32_t backing_width, uint32_t backing_height,
-                    uint32_t x, uint32_t y, uint32_t width, uint32_t height)
+void dpy_gl_scanout_texture(QemuConsole *con,
+                            uint32_t backing_id,
+                            bool backing_y_0_top,
+                            uint32_t backing_width,
+                            uint32_t backing_height,
+                            uint32_t x, uint32_t y,
+                            uint32_t width, uint32_t height)
 {
     assert(con->gl);
-    con->gl->ops->dpy_gl_scanout(con->gl, backing_id,
-                                 backing_y_0_top,
-                                 backing_width, backing_height,
-                                 x, y, width, height);
+    con->gl->ops->dpy_gl_scanout_texture(con->gl, backing_id,
+                                         backing_y_0_top,
+                                         backing_width, backing_height,
+                                         x, y, width, height);
 }
 
 void dpy_gl_update(QemuConsole *con,
diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c
index 3f5d328..d5541c3 100644
--- a/ui/gtk-egl.c
+++ b/ui/gtk-egl.c
@@ -170,11 +170,11 @@ QEMUGLContext gd_egl_create_context(DisplayChangeListener *dcl,
     return qemu_egl_create_context(dcl, params);
 }
 
-void gd_egl_scanout(DisplayChangeListener *dcl,
-                    uint32_t backing_id, bool backing_y_0_top,
-                    uint32_t backing_width, uint32_t backing_height,
-                    uint32_t x, uint32_t y,
-                    uint32_t w, uint32_t h)
+void gd_egl_scanout_texture(DisplayChangeListener *dcl,
+                            uint32_t backing_id, bool backing_y_0_top,
+                            uint32_t backing_width, uint32_t backing_height,
+                            uint32_t x, uint32_t y,
+                            uint32_t w, uint32_t h)
 {
     VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);
 
diff --git a/ui/gtk-gl-area.c b/ui/gtk-gl-area.c
index 0df5a36..b05c665 100644
--- a/ui/gtk-gl-area.c
+++ b/ui/gtk-gl-area.c
@@ -167,11 +167,13 @@ void gd_gl_area_destroy_context(DisplayChangeListener *dcl, QEMUGLContext ctx)
     /* FIXME */
 }
 
-void gd_gl_area_scanout(DisplayChangeListener *dcl,
-                        uint32_t backing_id, bool backing_y_0_top,
-                        uint32_t backing_width, uint32_t backing_height,
-                        uint32_t x, uint32_t y,
-                        uint32_t w, uint32_t h)
+void gd_gl_area_scanout_texture(DisplayChangeListener *dcl,
+                                uint32_t backing_id,
+                                bool backing_y_0_top,
+                                uint32_t backing_width,
+                                uint32_t backing_height,
+                                uint32_t x, uint32_t y,
+                                uint32_t w, uint32_t h)
 {
     VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);
 
diff --git a/ui/gtk.c b/ui/gtk.c
index f21e9e7..1dd0b53 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -669,7 +669,7 @@ static const DisplayChangeListenerOps dcl_gl_area_ops = {
     .dpy_gl_ctx_destroy      = gd_gl_area_destroy_context,
     .dpy_gl_ctx_make_current = gd_gl_area_make_current,
     .dpy_gl_ctx_get_current  = gd_gl_area_get_current_context,
-    .dpy_gl_scanout          = gd_gl_area_scanout,
+    .dpy_gl_scanout_texture  = gd_gl_area_scanout_texture,
     .dpy_gl_update           = gd_gl_area_scanout_flush,
 };
 
@@ -688,7 +688,7 @@ static const DisplayChangeListenerOps dcl_egl_ops = {
     .dpy_gl_ctx_destroy      = qemu_egl_destroy_context,
     .dpy_gl_ctx_make_current = gd_egl_make_current,
     .dpy_gl_ctx_get_current  = qemu_egl_get_current_context,
-    .dpy_gl_scanout          = gd_egl_scanout,
+    .dpy_gl_scanout_texture  = gd_egl_scanout_texture,
     .dpy_gl_update           = gd_egl_scanout_flush,
 };
 
diff --git a/ui/sdl2-gl.c b/ui/sdl2-gl.c
index 039645d..e25aa3b 100644
--- a/ui/sdl2-gl.c
+++ b/ui/sdl2-gl.c
@@ -184,11 +184,13 @@ QEMUGLContext sdl2_gl_get_current_context(DisplayChangeListener *dcl)
     return (QEMUGLContext)sdlctx;
 }
 
-void sdl2_gl_scanout(DisplayChangeListener *dcl,
-                     uint32_t backing_id, bool backing_y_0_top,
-                     uint32_t backing_width, uint32_t backing_height,
-                     uint32_t x, uint32_t y,
-                     uint32_t w, uint32_t h)
+void sdl2_gl_scanout_texture(DisplayChangeListener *dcl,
+                             uint32_t backing_id,
+                             bool backing_y_0_top,
+                             uint32_t backing_width,
+                             uint32_t backing_height,
+                             uint32_t x, uint32_t y,
+                             uint32_t w, uint32_t h)
 {
     struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl);
 
diff --git a/ui/sdl2.c b/ui/sdl2.c
index 91fb111..febda80 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -733,7 +733,7 @@ static const DisplayChangeListenerOps dcl_gl_ops = {
     .dpy_gl_ctx_destroy      = sdl2_gl_destroy_context,
     .dpy_gl_ctx_make_current = sdl2_gl_make_context_current,
     .dpy_gl_ctx_get_current  = sdl2_gl_get_current_context,
-    .dpy_gl_scanout          = sdl2_gl_scanout,
+    .dpy_gl_scanout_texture  = sdl2_gl_scanout_texture,
     .dpy_gl_update           = sdl2_gl_scanout_flush,
 };
 #endif
diff --git a/ui/spice-display.c b/ui/spice-display.c
index 64e472e..b80a9f3 100644
--- a/ui/spice-display.c
+++ b/ui/spice-display.c
@@ -928,13 +928,13 @@ static QEMUGLContext qemu_spice_gl_create_context(DisplayChangeListener *dcl,
     return qemu_egl_create_context(dcl, params);
 }
 
-static void qemu_spice_gl_scanout(DisplayChangeListener *dcl,
-                                  uint32_t tex_id,
-                                  bool y_0_top,
-                                  uint32_t backing_width,
-                                  uint32_t backing_height,
-                                  uint32_t x, uint32_t y,
-                                  uint32_t w, uint32_t h)
+static void qemu_spice_gl_scanout_texture(DisplayChangeListener *dcl,
+                                          uint32_t tex_id,
+                                          bool y_0_top,
+                                          uint32_t backing_width,
+                                          uint32_t backing_height,
+                                          uint32_t x, uint32_t y,
+                                          uint32_t w, uint32_t h)
 {
     SimpleSpiceDisplay *ssd = container_of(dcl, SimpleSpiceDisplay, dcl);
     EGLint stride = 0, fourcc = 0;
@@ -993,7 +993,7 @@ static const DisplayChangeListenerOps display_listener_gl_ops = {
     .dpy_gl_ctx_make_current = qemu_egl_make_context_current,
     .dpy_gl_ctx_get_current  = qemu_egl_get_current_context,
 
-    .dpy_gl_scanout          = qemu_spice_gl_scanout,
+    .dpy_gl_scanout_texture  = qemu_spice_gl_scanout_texture,
     .dpy_gl_update           = qemu_spice_gl_update,
 };
 
-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 2/6] console: add dpy_gl_scanout_disable
  2017-02-21  9:37 [Qemu-devel] [PATCH 0/6] ui: some gl scanout improvements Gerd Hoffmann
  2017-02-21  9:37 ` [Qemu-devel] [PATCH 1/6] console: rename dpy_gl_scanout to dpy_gl_scanout_texture Gerd Hoffmann
@ 2017-02-21  9:37 ` Gerd Hoffmann
  2017-02-21  9:37 ` [Qemu-devel] [PATCH 3/6] virtio-gpu: use dpy_gl_scanout_disable Gerd Hoffmann
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2017-02-21  9:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

Helper function (and DisplayChangeListenerOps ptr) to disable scanouts.
Replaces using dpy_gl_scanout_texture with 0x0 size and no texture
specified.

Allows cleanups to make the io and gfx emulation code more readable.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/ui/console.h |  2 ++
 ui/console.c         | 11 +++++++++++
 2 files changed, 13 insertions(+)

diff --git a/include/ui/console.h b/include/ui/console.h
index e6ae637..ac2895c 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -215,6 +215,7 @@ typedef struct DisplayChangeListenerOps {
                                    QEMUGLContext ctx);
     QEMUGLContext (*dpy_gl_ctx_get_current)(DisplayChangeListener *dcl);
 
+    void (*dpy_gl_scanout_disable)(DisplayChangeListener *dcl);
     void (*dpy_gl_scanout_texture)(DisplayChangeListener *dcl,
                                    uint32_t backing_id,
                                    bool backing_y_0_top,
@@ -287,6 +288,7 @@ bool dpy_cursor_define_supported(QemuConsole *con);
 bool dpy_gfx_check_format(QemuConsole *con,
                           pixman_format_code_t format);
 
+void dpy_gl_scanout_disable(QemuConsole *con);
 void dpy_gl_scanout_texture(QemuConsole *con,
                             uint32_t backing_id, bool backing_y_0_top,
                             uint32_t backing_width, uint32_t backing_height,
diff --git a/ui/console.c b/ui/console.c
index 22c3c7d..d1ff750 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -1735,6 +1735,17 @@ QEMUGLContext dpy_gl_ctx_get_current(QemuConsole *con)
     return con->gl->ops->dpy_gl_ctx_get_current(con->gl);
 }
 
+void dpy_gl_scanout_disable(QemuConsole *con)
+{
+    assert(con->gl);
+    if (con->gl->ops->dpy_gl_scanout_disable) {
+        con->gl->ops->dpy_gl_scanout_disable(con->gl);
+    } else {
+        con->gl->ops->dpy_gl_scanout_texture(con->gl, 0, false, 0, 0,
+                                             0, 0, 0, 0);
+    }
+}
+
 void dpy_gl_scanout_texture(QemuConsole *con,
                             uint32_t backing_id,
                             bool backing_y_0_top,
-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 3/6] virtio-gpu: use dpy_gl_scanout_disable
  2017-02-21  9:37 [Qemu-devel] [PATCH 0/6] ui: some gl scanout improvements Gerd Hoffmann
  2017-02-21  9:37 ` [Qemu-devel] [PATCH 1/6] console: rename dpy_gl_scanout to dpy_gl_scanout_texture Gerd Hoffmann
  2017-02-21  9:37 ` [Qemu-devel] [PATCH 2/6] console: add dpy_gl_scanout_disable Gerd Hoffmann
@ 2017-02-21  9:37 ` Gerd Hoffmann
  2017-02-21  9:37 ` [Qemu-devel] [PATCH 4/6] spice: add scanout_disable support Gerd Hoffmann
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2017-02-21  9:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Michael S. Tsirkin

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/display/virtio-gpu-3d.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/hw/display/virtio-gpu-3d.c b/hw/display/virtio-gpu-3d.c
index b526b3f..f49b7fe 100644
--- a/hw/display/virtio-gpu-3d.c
+++ b/hw/display/virtio-gpu-3d.c
@@ -185,8 +185,7 @@ static void virgl_cmd_set_scanout(VirtIOGPU *g,
         if (ss.scanout_id != 0) {
             dpy_gfx_replace_surface(g->scanout[ss.scanout_id].con, NULL);
         }
-        dpy_gl_scanout_texture(g->scanout[ss.scanout_id].con, 0, false,
-                               0, 0, 0, 0, 0, 0);
+        dpy_gl_scanout_disable(g->scanout[ss.scanout_id].con);
     }
     g->scanout[ss.scanout_id].resource_id = ss.resource_id;
 }
@@ -597,7 +596,7 @@ void virtio_gpu_virgl_reset(VirtIOGPU *g)
         if (i != 0) {
             dpy_gfx_replace_surface(g->scanout[i].con, NULL);
         }
-        dpy_gl_scanout_texture(g->scanout[i].con, 0, false, 0, 0, 0, 0, 0, 0);
+        dpy_gl_scanout_disable(g->scanout[i].con);
     }
 }
 
-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 4/6] spice: add scanout_disable support
  2017-02-21  9:37 [Qemu-devel] [PATCH 0/6] ui: some gl scanout improvements Gerd Hoffmann
                   ` (2 preceding siblings ...)
  2017-02-21  9:37 ` [Qemu-devel] [PATCH 3/6] virtio-gpu: use dpy_gl_scanout_disable Gerd Hoffmann
@ 2017-02-21  9:37 ` Gerd Hoffmann
  2017-02-21  9:37 ` [Qemu-devel] [PATCH 5/6] sdl2: " Gerd Hoffmann
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2017-02-21  9:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/spice-display.c | 36 +++++++++++++++++++++---------------
 1 file changed, 21 insertions(+), 15 deletions(-)

diff --git a/ui/spice-display.c b/ui/spice-display.c
index b80a9f3..23ccf2a 100644
--- a/ui/spice-display.c
+++ b/ui/spice-display.c
@@ -928,6 +928,17 @@ static QEMUGLContext qemu_spice_gl_create_context(DisplayChangeListener *dcl,
     return qemu_egl_create_context(dcl, params);
 }
 
+static void qemu_spice_gl_scanout_disable(DisplayChangeListener *dcl)
+{
+    SimpleSpiceDisplay *ssd = container_of(dcl, SimpleSpiceDisplay, dcl);
+
+    dprint(1, "%s: no framebuffer\n", __func__);
+    spice_qxl_gl_scanout(&ssd->qxl, -1, 0, 0, 0, 0, false);
+    qemu_spice_gl_monitor_config(ssd, 0, 0, 0, 0);
+    ssd->have_surface = false;
+    ssd->have_scanout = false;
+}
+
 static void qemu_spice_gl_scanout_texture(DisplayChangeListener *dcl,
                                           uint32_t tex_id,
                                           bool y_0_top,
@@ -940,27 +951,21 @@ static void qemu_spice_gl_scanout_texture(DisplayChangeListener *dcl,
     EGLint stride = 0, fourcc = 0;
     int fd = -1;
 
-    if (tex_id) {
-        fd = egl_get_fd_for_texture(tex_id, &stride, &fourcc);
-        if (fd < 0) {
-            fprintf(stderr, "%s: failed to get fd for texture\n", __func__);
-            return;
-        }
-        dprint(1, "%s: %dx%d (stride %d, fourcc 0x%x)\n", __func__,
-               w, h, stride, fourcc);
-    } else {
-        dprint(1, "%s: no texture (no framebuffer)\n", __func__);
+    assert(tex_id);
+    fd = egl_get_fd_for_texture(tex_id, &stride, &fourcc);
+    if (fd < 0) {
+        fprintf(stderr, "%s: failed to get fd for texture\n", __func__);
+        return;
     }
-
-    assert(!tex_id || fd >= 0);
+    dprint(1, "%s: %dx%d (stride %d, fourcc 0x%x)\n", __func__,
+           w, h, stride, fourcc);
 
     /* note: spice server will close the fd */
     spice_qxl_gl_scanout(&ssd->qxl, fd, backing_width, backing_height,
                          stride, fourcc, y_0_top);
-    ssd->have_surface = false;
-    ssd->have_scanout = (tex_id != 0);
-
     qemu_spice_gl_monitor_config(ssd, x, y, w, h);
+    ssd->have_surface = false;
+    ssd->have_scanout = true;
 }
 
 static void qemu_spice_gl_update(DisplayChangeListener *dcl,
@@ -993,6 +998,7 @@ static const DisplayChangeListenerOps display_listener_gl_ops = {
     .dpy_gl_ctx_make_current = qemu_egl_make_context_current,
     .dpy_gl_ctx_get_current  = qemu_egl_get_current_context,
 
+    .dpy_gl_scanout_disable  = qemu_spice_gl_scanout_disable,
     .dpy_gl_scanout_texture  = qemu_spice_gl_scanout_texture,
     .dpy_gl_update           = qemu_spice_gl_update,
 };
-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 5/6] sdl2: add scanout_disable support
  2017-02-21  9:37 [Qemu-devel] [PATCH 0/6] ui: some gl scanout improvements Gerd Hoffmann
                   ` (3 preceding siblings ...)
  2017-02-21  9:37 ` [Qemu-devel] [PATCH 4/6] spice: add scanout_disable support Gerd Hoffmann
@ 2017-02-21  9:37 ` Gerd Hoffmann
  2017-02-21  9:37 ` [Qemu-devel] [PATCH 6/6] gtk-egl: " Gerd Hoffmann
  2017-02-21 10:31 ` [Qemu-devel] [PATCH 0/6] ui: some gl scanout improvements Marc-André Lureau
  6 siblings, 0 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2017-02-21  9:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/ui/sdl2.h |  1 +
 ui/sdl2-gl.c      | 16 +++++++++++-----
 ui/sdl2.c         |  1 +
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/include/ui/sdl2.h b/include/ui/sdl2.h
index 2de792f..aaf226c 100644
--- a/include/ui/sdl2.h
+++ b/include/ui/sdl2.h
@@ -62,6 +62,7 @@ int sdl2_gl_make_context_current(DisplayChangeListener *dcl,
                                  QEMUGLContext ctx);
 QEMUGLContext sdl2_gl_get_current_context(DisplayChangeListener *dcl);
 
+void sdl2_gl_scanout_disable(DisplayChangeListener *dcl);
 void sdl2_gl_scanout_texture(DisplayChangeListener *dcl,
                              uint32_t backing_id,
                              bool backing_y_0_top,
diff --git a/ui/sdl2-gl.c b/ui/sdl2-gl.c
index e25aa3b..1cd77e2 100644
--- a/ui/sdl2-gl.c
+++ b/ui/sdl2-gl.c
@@ -184,6 +184,17 @@ QEMUGLContext sdl2_gl_get_current_context(DisplayChangeListener *dcl)
     return (QEMUGLContext)sdlctx;
 }
 
+void sdl2_gl_scanout_disable(DisplayChangeListener *dcl)
+{
+    struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl);
+
+    assert(scon->opengl);
+    scon->w = 0;
+    scon->h = 0;
+    scon->tex_id = 0;
+    sdl2_set_scanout_mode(scon, false);
+}
+
 void sdl2_gl_scanout_texture(DisplayChangeListener *dcl,
                              uint32_t backing_id,
                              bool backing_y_0_top,
@@ -204,11 +215,6 @@ void sdl2_gl_scanout_texture(DisplayChangeListener *dcl,
 
     SDL_GL_MakeCurrent(scon->real_window, scon->winctx);
 
-    if (scon->tex_id == 0 || scon->w == 0 || scon->h == 0) {
-        sdl2_set_scanout_mode(scon, false);
-        return;
-    }
-
     sdl2_set_scanout_mode(scon, true);
     if (!scon->fbo_id) {
         glGenFramebuffers(1, &scon->fbo_id);
diff --git a/ui/sdl2.c b/ui/sdl2.c
index febda80..faf9bdf 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -733,6 +733,7 @@ static const DisplayChangeListenerOps dcl_gl_ops = {
     .dpy_gl_ctx_destroy      = sdl2_gl_destroy_context,
     .dpy_gl_ctx_make_current = sdl2_gl_make_context_current,
     .dpy_gl_ctx_get_current  = sdl2_gl_get_current_context,
+    .dpy_gl_scanout_disable  = sdl2_gl_scanout_disable,
     .dpy_gl_scanout_texture  = sdl2_gl_scanout_texture,
     .dpy_gl_update           = sdl2_gl_scanout_flush,
 };
-- 
1.8.3.1

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

* [Qemu-devel] [PATCH 6/6] gtk-egl: add scanout_disable support
  2017-02-21  9:37 [Qemu-devel] [PATCH 0/6] ui: some gl scanout improvements Gerd Hoffmann
                   ` (4 preceding siblings ...)
  2017-02-21  9:37 ` [Qemu-devel] [PATCH 5/6] sdl2: " Gerd Hoffmann
@ 2017-02-21  9:37 ` Gerd Hoffmann
  2017-02-21 10:31 ` [Qemu-devel] [PATCH 0/6] ui: some gl scanout improvements Marc-André Lureau
  6 siblings, 0 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2017-02-21  9:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/ui/gtk.h |  1 +
 ui/gtk-egl.c     | 15 ++++++++++-----
 ui/gtk.c         |  1 +
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/include/ui/gtk.h b/include/ui/gtk.h
index 408e21b..ca9a226 100644
--- a/include/ui/gtk.h
+++ b/include/ui/gtk.h
@@ -103,6 +103,7 @@ void gd_egl_switch(DisplayChangeListener *dcl,
                    DisplaySurface *surface);
 QEMUGLContext gd_egl_create_context(DisplayChangeListener *dcl,
                                     QEMUGLParams *params);
+void gd_egl_scanout_disable(DisplayChangeListener *dcl);
 void gd_egl_scanout_texture(DisplayChangeListener *dcl,
                             uint32_t backing_id,
                             bool backing_y_0_top,
diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c
index d5541c3..d53288f 100644
--- a/ui/gtk-egl.c
+++ b/ui/gtk-egl.c
@@ -170,6 +170,16 @@ QEMUGLContext gd_egl_create_context(DisplayChangeListener *dcl,
     return qemu_egl_create_context(dcl, params);
 }
 
+void gd_egl_scanout_disable(DisplayChangeListener *dcl)
+{
+    VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);
+
+    vc->gfx.w = 0;
+    vc->gfx.h = 0;
+    vc->gfx.tex_id = 0;
+    gtk_egl_set_scanout_mode(vc, false);
+}
+
 void gd_egl_scanout_texture(DisplayChangeListener *dcl,
                             uint32_t backing_id, bool backing_y_0_top,
                             uint32_t backing_width, uint32_t backing_height,
@@ -188,11 +198,6 @@ void gd_egl_scanout_texture(DisplayChangeListener *dcl,
     eglMakeCurrent(qemu_egl_display, vc->gfx.esurface,
                    vc->gfx.esurface, vc->gfx.ectx);
 
-    if (vc->gfx.tex_id == 0 || vc->gfx.w == 0 || vc->gfx.h == 0) {
-        gtk_egl_set_scanout_mode(vc, false);
-        return;
-    }
-
     gtk_egl_set_scanout_mode(vc, true);
     if (!vc->gfx.fbo_id) {
         glGenFramebuffers(1, &vc->gfx.fbo_id);
diff --git a/ui/gtk.c b/ui/gtk.c
index 1dd0b53..640ff84 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -688,6 +688,7 @@ static const DisplayChangeListenerOps dcl_egl_ops = {
     .dpy_gl_ctx_destroy      = qemu_egl_destroy_context,
     .dpy_gl_ctx_make_current = gd_egl_make_current,
     .dpy_gl_ctx_get_current  = qemu_egl_get_current_context,
+    .dpy_gl_scanout_disable  = gd_egl_scanout_disable,
     .dpy_gl_scanout_texture  = gd_egl_scanout_texture,
     .dpy_gl_update           = gd_egl_scanout_flush,
 };
-- 
1.8.3.1

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

* Re: [Qemu-devel] [PATCH 0/6] ui: some gl scanout improvements.
  2017-02-21  9:37 [Qemu-devel] [PATCH 0/6] ui: some gl scanout improvements Gerd Hoffmann
                   ` (5 preceding siblings ...)
  2017-02-21  9:37 ` [Qemu-devel] [PATCH 6/6] gtk-egl: " Gerd Hoffmann
@ 2017-02-21 10:31 ` Marc-André Lureau
  6 siblings, 0 replies; 8+ messages in thread
From: Marc-André Lureau @ 2017-02-21 10:31 UTC (permalink / raw)
  To: Gerd Hoffmann, qemu-devel

On Tue, Feb 21, 2017 at 1:38 PM Gerd Hoffmann <kraxel@redhat.com> wrote:

>   Hi,
>
> Upcoming intel vgpu support will need some updates for the qemu opengl
> support, specifically we will need support for importing dma-bufs.
> The kernel support for this is still brewing though and thus the qemu
> patches are still experimental and a moving target.
>
> While working on it I did some cleanups and improvements on the opengl
> code in qemu though, and there is no reason to wait with merging them,
> so here are the first bits.
>
> cheers,
>   Gerd
>
> Gerd Hoffmann (6):
>   console: rename dpy_gl_scanout to dpy_gl_scanout_texture
>   console: add dpy_gl_scanout_disable
>   virtio-gpu: use dpy_gl_scanout_disable
>   spice: add scanout_disable support
>   sdl2: add scanout_disable support
>   gtk-egl: add scanout_disable support
>

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



>
>  hw/display/virtio-gpu-3d.c | 13 ++++++------
>  include/ui/console.h       | 21 ++++++++++++-------
>  include/ui/gtk.h           | 25 +++++++++++++---------
>  include/ui/sdl2.h          | 13 +++++++-----
>  ui/console.c               | 30 +++++++++++++++++++-------
>  ui/gtk-egl.c               | 25 +++++++++++++---------
>  ui/gtk-gl-area.c           | 12 ++++++-----
>  ui/gtk.c                   |  5 +++--
>  ui/sdl2-gl.c               | 28 ++++++++++++++++---------
>  ui/sdl2.c                  |  3 ++-
>  ui/spice-display.c         | 52
> ++++++++++++++++++++++++++--------------------
>  11 files changed, 138 insertions(+), 89 deletions(-)
>
> --
> 1.8.3.1
>
>
> --
Marc-André Lureau

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

end of thread, other threads:[~2017-02-21 10:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-21  9:37 [Qemu-devel] [PATCH 0/6] ui: some gl scanout improvements Gerd Hoffmann
2017-02-21  9:37 ` [Qemu-devel] [PATCH 1/6] console: rename dpy_gl_scanout to dpy_gl_scanout_texture Gerd Hoffmann
2017-02-21  9:37 ` [Qemu-devel] [PATCH 2/6] console: add dpy_gl_scanout_disable Gerd Hoffmann
2017-02-21  9:37 ` [Qemu-devel] [PATCH 3/6] virtio-gpu: use dpy_gl_scanout_disable Gerd Hoffmann
2017-02-21  9:37 ` [Qemu-devel] [PATCH 4/6] spice: add scanout_disable support Gerd Hoffmann
2017-02-21  9:37 ` [Qemu-devel] [PATCH 5/6] sdl2: " Gerd Hoffmann
2017-02-21  9:37 ` [Qemu-devel] [PATCH 6/6] gtk-egl: " Gerd Hoffmann
2017-02-21 10:31 ` [Qemu-devel] [PATCH 0/6] ui: some gl scanout improvements Marc-André Lureau

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.