* [Qemu-devel] [PULL 0/4] ui: console+vnc fixes, switch spice to pure opengl with gl=on. @ 2016-09-28 12:01 Gerd Hoffmann 2016-09-28 12:01 ` [Qemu-devel] [PULL 1/4] console: skip same-size resize Gerd Hoffmann ` (4 more replies) 0 siblings, 5 replies; 6+ messages in thread From: Gerd Hoffmann @ 2016-09-28 12:01 UTC (permalink / raw) To: qemu-devel; +Cc: Gerd Hoffmann Hi, Here is the ui patch queue with two small bug fixes and with pure opengl support for spice, i.e. with gl=on we'll render everything (including classic DisplaySurfaces) into a opengl texture for dma-buf passing. please pull, Gerd The following changes since commit 7cfdc02dae0d2ff58c897496cfdbbafc0eda0f3f: Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging (2016-09-26 19:47:00 +0100) are available in the git repository at: git://git.kraxel.org/qemu tags/pull-ui-20160928-1 for you to fetch changes up to d9d2663c336b4ff7af9528f2cd3736791f4c0da5: ui/vnc-enc-tight: remove switch and have single return (2016-09-28 12:55:09 +0200) ---------------------------------------------------------------- ui: console+vnc fixes, switch spice to pure opengl with gl=on. ---------------------------------------------------------------- Alex Bennée (1): ui/vnc-enc-tight: remove switch and have single return Gerd Hoffmann (2): console: track gl_block state in QemuConsole spice/gl: render DisplaySurface via opengl Marc-André Lureau (1): console: skip same-size resize include/ui/console.h | 1 + include/ui/spice-display.h | 5 ++- ui/console.c | 22 +++++++++-- ui/spice-display.c | 92 ++++++++++++++++++++++++++++++++++++++++++---- ui/vnc-enc-tight.c | 6 +-- 5 files changed, 109 insertions(+), 17 deletions(-) ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [PULL 1/4] console: skip same-size resize 2016-09-28 12:01 [Qemu-devel] [PULL 0/4] ui: console+vnc fixes, switch spice to pure opengl with gl=on Gerd Hoffmann @ 2016-09-28 12:01 ` Gerd Hoffmann 2016-09-28 12:01 ` [Qemu-devel] [PULL 2/4] console: track gl_block state in QemuConsole Gerd Hoffmann ` (3 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: Gerd Hoffmann @ 2016-09-28 12:01 UTC (permalink / raw) To: qemu-devel; +Cc: Marc-André Lureau, Gerd Hoffmann From: Marc-André Lureau <marcandre.lureau@redhat.com> virtio-gpu does a set-scanout at each frame (it might be a driver regression). qemu_console_resize() recreate a surface even if the size didn't change, and this shows up in profiling reports because the surface is cleared. With this patch, I get a +15-20% glmark2 improvement. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-id: 20160826094711.14470-1-marcandre.lureau@redhat.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> --- ui/console.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ui/console.c b/ui/console.c index 3940762..394786b 100644 --- a/ui/console.c +++ b/ui/console.c @@ -2101,6 +2101,13 @@ void qemu_console_resize(QemuConsole *s, int width, int height) DisplaySurface *surface; assert(s->console_type == GRAPHIC_CONSOLE); + + if (s->surface && + pixman_image_get_width(s->surface->image) == width && + pixman_image_get_height(s->surface->image) == height) { + return; + } + surface = qemu_create_displaysurface(width, height); dpy_gfx_replace_surface(s, surface); } -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PULL 2/4] console: track gl_block state in QemuConsole 2016-09-28 12:01 [Qemu-devel] [PULL 0/4] ui: console+vnc fixes, switch spice to pure opengl with gl=on Gerd Hoffmann 2016-09-28 12:01 ` [Qemu-devel] [PULL 1/4] console: skip same-size resize Gerd Hoffmann @ 2016-09-28 12:01 ` Gerd Hoffmann 2016-09-28 12:01 ` [Qemu-devel] [PULL 3/4] spice/gl: render DisplaySurface via opengl Gerd Hoffmann ` (2 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: Gerd Hoffmann @ 2016-09-28 12:01 UTC (permalink / raw) To: qemu-devel; +Cc: Gerd Hoffmann Keep track of gl_block state (added in bba19b8 console: block rendering until client is done) in QemuConsole and allow to query it. This way we can avoid state inconsistencies in case different code paths make use of this. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-id: 1474617028-3979-2-git-send-email-kraxel@redhat.com --- include/ui/console.h | 1 + ui/console.c | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index d9c13d2..e2589e2 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -387,6 +387,7 @@ QemuConsole *qemu_console_lookup_by_device_name(const char *device_id, bool qemu_console_is_visible(QemuConsole *con); bool qemu_console_is_graphic(QemuConsole *con); bool qemu_console_is_fixedsize(QemuConsole *con); +bool qemu_console_is_gl_blocked(QemuConsole *con); char *qemu_console_get_label(QemuConsole *con); int qemu_console_get_index(QemuConsole *con); uint32_t qemu_console_get_head(QemuConsole *con); diff --git a/ui/console.c b/ui/console.c index 394786b..fa3e658 100644 --- a/ui/console.c +++ b/ui/console.c @@ -123,6 +123,7 @@ struct QemuConsole { DisplaySurface *surface; int dcls; DisplayChangeListener *gl; + bool gl_block; /* Graphic console state. */ Object *device; @@ -264,10 +265,10 @@ void graphic_hw_update(QemuConsole *con) void graphic_hw_gl_block(QemuConsole *con, bool block) { - if (!con) { - con = active_console; - } - if (con && con->hw_ops->gl_block) { + assert(con != NULL); + + con->gl_block = block; + if (con->hw_ops->gl_block) { con->hw_ops->gl_block(con->hw, block); } } @@ -1879,6 +1880,12 @@ bool qemu_console_is_fixedsize(QemuConsole *con) return con && (con->console_type != TEXT_CONSOLE); } +bool qemu_console_is_gl_blocked(QemuConsole *con) +{ + assert(con != NULL); + return con->gl_block; +} + char *qemu_console_get_label(QemuConsole *con) { if (con->console_type == GRAPHIC_CONSOLE) { -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PULL 3/4] spice/gl: render DisplaySurface via opengl 2016-09-28 12:01 [Qemu-devel] [PULL 0/4] ui: console+vnc fixes, switch spice to pure opengl with gl=on Gerd Hoffmann 2016-09-28 12:01 ` [Qemu-devel] [PULL 1/4] console: skip same-size resize Gerd Hoffmann 2016-09-28 12:01 ` [Qemu-devel] [PULL 2/4] console: track gl_block state in QemuConsole Gerd Hoffmann @ 2016-09-28 12:01 ` Gerd Hoffmann 2016-09-28 12:01 ` [Qemu-devel] [PULL 4/4] ui/vnc-enc-tight: remove switch and have single return Gerd Hoffmann 2016-09-28 16:43 ` [Qemu-devel] [PULL 0/4] ui: console+vnc fixes, switch spice to pure opengl with gl=on Peter Maydell 4 siblings, 0 replies; 6+ messages in thread From: Gerd Hoffmann @ 2016-09-28 12:01 UTC (permalink / raw) To: qemu-devel; +Cc: Gerd Hoffmann This switches over spice (in opengl mode) to render DisplaySurface updates into a opengl texture, using the helper functions in ui/console-gl.c. With this patch applied spice (with gl=on) will stop using qxl rendering ops, it will use dma-buf passing all the time, i.e. for bios/bootloader (before virtio-gpu driver is loaded) too. This should improve performance even using spice (with gl=on) with non-accelerated stdvga because we stop squeezing all display updates through a unix/tcp socket and basically using a shared memory transport instead. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-id: 1474617028-3979-3-git-send-email-kraxel@redhat.com --- include/ui/spice-display.h | 5 ++- ui/spice-display.c | 92 ++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 88 insertions(+), 9 deletions(-) diff --git a/include/ui/spice-display.h b/include/ui/spice-display.h index 42e0fdf..184d4c3 100644 --- a/include/ui/spice-display.h +++ b/include/ui/spice-display.h @@ -119,7 +119,10 @@ struct SimpleSpiceDisplay { /* opengl rendering */ QEMUBH *gl_unblock_bh; QEMUTimer *gl_unblock_timer; - int dmabuf_fd; + ConsoleGLState *gls; + int gl_updates; + bool have_scanout; + bool have_surface; #endif }; diff --git a/ui/spice-display.c b/ui/spice-display.c index 99132b6..5e6f78a 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -850,6 +850,74 @@ static void qemu_spice_gl_block_timer(void *opaque) fprintf(stderr, "WARNING: spice: no gl-draw-done within one second\n"); } +static void spice_gl_refresh(DisplayChangeListener *dcl) +{ + SimpleSpiceDisplay *ssd = container_of(dcl, SimpleSpiceDisplay, dcl); + uint64_t cookie; + + if (!ssd->ds || qemu_console_is_gl_blocked(ssd->dcl.con)) { + return; + } + + graphic_hw_update(dcl->con); + if (ssd->gl_updates && ssd->have_surface) { + qemu_spice_gl_block(ssd, true); + cookie = (uintptr_t)qxl_cookie_new(QXL_COOKIE_TYPE_GL_DRAW_DONE, 0); + spice_qxl_gl_draw_async(&ssd->qxl, 0, 0, + surface_width(ssd->ds), + surface_height(ssd->ds), + cookie); + ssd->gl_updates = 0; + } +} + +static void spice_gl_update(DisplayChangeListener *dcl, + int x, int y, int w, int h) +{ + SimpleSpiceDisplay *ssd = container_of(dcl, SimpleSpiceDisplay, dcl); + + surface_gl_update_texture(ssd->gls, ssd->ds, x, y, w, h); + ssd->gl_updates++; +} + +static void spice_gl_switch(DisplayChangeListener *dcl, + struct DisplaySurface *new_surface) +{ + SimpleSpiceDisplay *ssd = container_of(dcl, SimpleSpiceDisplay, dcl); + EGLint stride, fourcc; + int fd; + + if (ssd->ds) { + surface_gl_destroy_texture(ssd->gls, ssd->ds); + } + ssd->ds = new_surface; + if (ssd->ds) { + surface_gl_create_texture(ssd->gls, ssd->ds); + fd = egl_get_fd_for_texture(ssd->ds->texture, + &stride, &fourcc); + if (fd < 0) { + surface_gl_destroy_texture(ssd->gls, ssd->ds); + return; + } + + dprint(1, "%s: %dx%d (stride %d/%d, fourcc 0x%x)\n", __func__, + surface_width(ssd->ds), surface_height(ssd->ds), + surface_stride(ssd->ds), stride, fourcc); + + /* note: spice server will close the fd */ + spice_qxl_gl_scanout(&ssd->qxl, fd, + surface_width(ssd->ds), + surface_height(ssd->ds), + stride, fourcc, false); + ssd->have_surface = true; + ssd->have_scanout = false; + + qemu_spice_gl_monitor_config(ssd, 0, 0, + surface_width(ssd->ds), + surface_height(ssd->ds)); + } +} + static QEMUGLContext qemu_spice_gl_create_context(DisplayChangeListener *dcl, QEMUGLParams *params) { @@ -887,6 +955,8 @@ static void qemu_spice_gl_scanout(DisplayChangeListener *dcl, /* 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); } @@ -897,6 +967,10 @@ static void qemu_spice_gl_update(DisplayChangeListener *dcl, SimpleSpiceDisplay *ssd = container_of(dcl, SimpleSpiceDisplay, dcl); uint64_t cookie; + if (!ssd->have_scanout) { + return; + } + dprint(2, "%s: %dx%d+%d+%d\n", __func__, w, h, x, y); qemu_spice_gl_block(ssd, true); cookie = (uintptr_t)qxl_cookie_new(QXL_COOKIE_TYPE_GL_DRAW_DONE, 0); @@ -904,13 +978,13 @@ static void qemu_spice_gl_update(DisplayChangeListener *dcl, } static const DisplayChangeListenerOps display_listener_gl_ops = { - .dpy_name = "spice-egl", - .dpy_gfx_update = display_update, - .dpy_gfx_switch = display_switch, - .dpy_gfx_check_format = qemu_pixman_check_format, - .dpy_refresh = display_refresh, - .dpy_mouse_set = display_mouse_set, - .dpy_cursor_define = display_mouse_define, + .dpy_name = "spice-egl", + .dpy_gfx_update = spice_gl_update, + .dpy_gfx_switch = spice_gl_switch, + .dpy_gfx_check_format = console_gl_check_format, + .dpy_refresh = spice_gl_refresh, + .dpy_mouse_set = display_mouse_set, + .dpy_cursor_define = display_mouse_define, .dpy_gl_ctx_create = qemu_spice_gl_create_context, .dpy_gl_ctx_destroy = qemu_egl_destroy_context, @@ -933,10 +1007,12 @@ static void qemu_spice_display_init_one(QemuConsole *con) #ifdef HAVE_SPICE_GL if (display_opengl) { ssd->dcl.ops = &display_listener_gl_ops; - ssd->dmabuf_fd = -1; ssd->gl_unblock_bh = qemu_bh_new(qemu_spice_gl_unblock_bh, ssd); ssd->gl_unblock_timer = timer_new_ms(QEMU_CLOCK_REALTIME, qemu_spice_gl_block_timer, ssd); + ssd->gls = console_gl_init_context(); + ssd->have_surface = false; + ssd->have_scanout = false; } #endif ssd->dcl.con = con; -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PULL 4/4] ui/vnc-enc-tight: remove switch and have single return 2016-09-28 12:01 [Qemu-devel] [PULL 0/4] ui: console+vnc fixes, switch spice to pure opengl with gl=on Gerd Hoffmann ` (2 preceding siblings ...) 2016-09-28 12:01 ` [Qemu-devel] [PULL 3/4] spice/gl: render DisplaySurface via opengl Gerd Hoffmann @ 2016-09-28 12:01 ` Gerd Hoffmann 2016-09-28 16:43 ` [Qemu-devel] [PULL 0/4] ui: console+vnc fixes, switch spice to pure opengl with gl=on Peter Maydell 4 siblings, 0 replies; 6+ messages in thread From: Gerd Hoffmann @ 2016-09-28 12:01 UTC (permalink / raw) To: qemu-devel; +Cc: Alex Bennée, Gerd Hoffmann From: Alex Bennée <alex.bennee@linaro.org> When enabling the sanitizer build it will complain about control reaching a non-void function. Normally the compiler should detect that there is only one possible exit given a static VNC_SERVER_FB_BYTES. As we always expect a static VNC_SERVER_FB_BYTES I've added a compile time assert and just called the sub-function directly. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> --- ui/vnc-enc-tight.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ui/vnc-enc-tight.c b/ui/vnc-enc-tight.c index 49df85e..1e53b1c 100644 --- a/ui/vnc-enc-tight.c +++ b/ui/vnc-enc-tight.c @@ -707,10 +707,8 @@ check_solid_tile32(VncState *vs, int x, int y, int w, int h, static bool check_solid_tile(VncState *vs, int x, int y, int w, int h, uint32_t* color, bool samecolor) { - switch (VNC_SERVER_FB_BYTES) { - case 4: - return check_solid_tile32(vs, x, y, w, h, color, samecolor); - } + QEMU_BUILD_BUG_ON(VNC_SERVER_FB_BYTES != 4); + return check_solid_tile32(vs, x, y, w, h, color, samecolor); } static void find_best_solid_area(VncState *vs, int x, int y, int w, int h, -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PULL 0/4] ui: console+vnc fixes, switch spice to pure opengl with gl=on. 2016-09-28 12:01 [Qemu-devel] [PULL 0/4] ui: console+vnc fixes, switch spice to pure opengl with gl=on Gerd Hoffmann ` (3 preceding siblings ...) 2016-09-28 12:01 ` [Qemu-devel] [PULL 4/4] ui/vnc-enc-tight: remove switch and have single return Gerd Hoffmann @ 2016-09-28 16:43 ` Peter Maydell 4 siblings, 0 replies; 6+ messages in thread From: Peter Maydell @ 2016-09-28 16:43 UTC (permalink / raw) To: Gerd Hoffmann; +Cc: QEMU Developers On 28 September 2016 at 05:01, Gerd Hoffmann <kraxel@redhat.com> wrote: > Hi, > > Here is the ui patch queue with two small bug fixes and with pure opengl > support for spice, i.e. with gl=on we'll render everything (including > classic DisplaySurfaces) into a opengl texture for dma-buf passing. > > please pull, > Gerd > > The following changes since commit 7cfdc02dae0d2ff58c897496cfdbbafc0eda0f3f: > > Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging (2016-09-26 19:47:00 +0100) > > are available in the git repository at: > > > git://git.kraxel.org/qemu tags/pull-ui-20160928-1 > > for you to fetch changes up to d9d2663c336b4ff7af9528f2cd3736791f4c0da5: > > ui/vnc-enc-tight: remove switch and have single return (2016-09-28 12:55:09 +0200) > > ---------------------------------------------------------------- > ui: console+vnc fixes, switch spice to pure opengl with gl=on. > > ---------------------------------------------------------------- > Alex Bennée (1): > ui/vnc-enc-tight: remove switch and have single return > > Gerd Hoffmann (2): > console: track gl_block state in QemuConsole > spice/gl: render DisplaySurface via opengl > > Marc-André Lureau (1): > console: skip same-size resize Applied, thanks. -- PMM ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-09-28 16:43 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-09-28 12:01 [Qemu-devel] [PULL 0/4] ui: console+vnc fixes, switch spice to pure opengl with gl=on Gerd Hoffmann 2016-09-28 12:01 ` [Qemu-devel] [PULL 1/4] console: skip same-size resize Gerd Hoffmann 2016-09-28 12:01 ` [Qemu-devel] [PULL 2/4] console: track gl_block state in QemuConsole Gerd Hoffmann 2016-09-28 12:01 ` [Qemu-devel] [PULL 3/4] spice/gl: render DisplaySurface via opengl Gerd Hoffmann 2016-09-28 12:01 ` [Qemu-devel] [PULL 4/4] ui/vnc-enc-tight: remove switch and have single return Gerd Hoffmann 2016-09-28 16:43 ` [Qemu-devel] [PULL 0/4] ui: console+vnc fixes, switch spice to pure opengl with gl=on Peter Maydell
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).