From nobody Fri Oct 24 21:59:44 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520325651874645.3973591604483; Tue, 6 Mar 2018 00:40:51 -0800 (PST) Received: from localhost ([::1]:54175 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1et89Q-0006v0-9M for importer@patchew.org; Tue, 06 Mar 2018 03:40:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42888) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1et87K-0005cW-1f for qemu-devel@nongnu.org; Tue, 06 Mar 2018 03:38:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1et87H-0003iJ-UE for qemu-devel@nongnu.org; Tue, 06 Mar 2018 03:38:38 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:55100 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1et87H-0003i5-OW for qemu-devel@nongnu.org; Tue, 06 Mar 2018 03:38:35 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5ACFC4023150 for ; Tue, 6 Mar 2018 08:38:35 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-39.ams2.redhat.com [10.36.116.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id C79BE1C709; Tue, 6 Mar 2018 08:38:32 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 333921751D; Tue, 6 Mar 2018 09:38:32 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 6 Mar 2018 09:38:30 +0100 Message-Id: <20180306083832.8144-2-kraxel@redhat.com> In-Reply-To: <20180306083832.8144-1-kraxel@redhat.com> References: <20180306083832.8144-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 06 Mar 2018 08:38:35 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 06 Mar 2018 08:38:35 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kraxel@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2 1/3] spice: drop dprint() debug logging X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Some calls are deleted, some are converted into tracepoints. Signed-off-by: Gerd Hoffmann --- ui/spice-display.c | 75 ++++++++++++++++----------------------------------= ---- ui/trace-events | 9 +++++++ 2 files changed, 31 insertions(+), 53 deletions(-) diff --git a/ui/spice-display.c b/ui/spice-display.c index 98ccdfb687..f3ae6beb3d 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -26,20 +26,8 @@ =20 #include "ui/spice-display.h" =20 -static int debug =3D 0; bool spice_opengl; =20 -static void GCC_FMT_ATTR(2, 3) dprint(int level, const char *fmt, ...) -{ - va_list args; - - if (level <=3D debug) { - va_start(args, fmt); - vfprintf(stderr, fmt, args); - va_end(args); - } -} - int qemu_spice_rect_is_empty(const QXLRect* r) { return r->top =3D=3D r->bottom || r->left =3D=3D r->right; @@ -322,8 +310,6 @@ void qemu_spice_create_host_memslot(SimpleSpiceDisplay = *ssd) { QXLDevMemSlot memslot; =20 - dprint(1, "%s/%d:\n", __func__, ssd->qxl.id); - memset(&memslot, 0, sizeof(memslot)); memslot.slot_group_id =3D MEMSLOT_GROUP_HOST; memslot.virt_end =3D ~0; @@ -347,10 +333,6 @@ void qemu_spice_create_host_primary(SimpleSpiceDisplay= *ssd) ssd->buf =3D g_malloc(ssd->bufsize); } =20 - dprint(1, "%s/%d: %ux%u (size %" PRIu64 "/%d)\n", __func__, ssd->qxl.i= d, - surface_width(ssd->ds), surface_height(ssd->ds), - surface_size, ssd->bufsize); - surface.format =3D SPICE_SURFACE_FMT_32_xRGB; surface.width =3D surface_width(ssd->ds); surface.height =3D surface_height(ssd->ds); @@ -366,8 +348,6 @@ void qemu_spice_create_host_primary(SimpleSpiceDisplay = *ssd) =20 void qemu_spice_destroy_host_primary(SimpleSpiceDisplay *ssd) { - dprint(1, "%s/%d:\n", __func__, ssd->qxl.id); - qemu_spice_destroy_primary_surface(ssd, 0, QXL_SYNC); } =20 @@ -389,8 +369,7 @@ void qemu_spice_display_update(SimpleSpiceDisplay *ssd, { QXLRect update_area; =20 - dprint(2, "%s/%d: x %d y %d w %d h %d\n", __func__, - ssd->qxl.id, x, y, w, h); + trace_qemu_spice_display_update(ssd->qxl.id, x, y, w, h); update_area.left =3D x, update_area.right =3D x + w; update_area.top =3D y; @@ -413,8 +392,10 @@ void qemu_spice_display_switch(SimpleSpiceDisplay *ssd, surface_height(surface) =3D=3D pixman_image_get_height(ssd->surfac= e) && surface_format(surface) =3D=3D pixman_image_get_format(ssd->surfac= e)) { /* no-resize fast path: just swap backing store */ - dprint(1, "%s/%d: fast (%dx%d)\n", __func__, ssd->qxl.id, - surface_width(surface), surface_height(surface)); + trace_qemu_spice_display_surface(ssd->qxl.id, + surface_width(surface), + surface_height(surface), + true); qemu_mutex_lock(&ssd->lock); ssd->ds =3D surface; pixman_image_unref(ssd->surface); @@ -427,11 +408,10 @@ void qemu_spice_display_switch(SimpleSpiceDisplay *ss= d, } =20 /* full mode switch */ - dprint(1, "%s/%d: full (%dx%d -> %dx%d)\n", __func__, ssd->qxl.id, - ssd->surface ? pixman_image_get_width(ssd->surface) : 0, - ssd->surface ? pixman_image_get_height(ssd->surface) : 0, - surface ? surface_width(surface) : 0, - surface ? surface_height(surface) : 0); + trace_qemu_spice_display_surface(ssd->qxl.id, + surface_width(surface), + surface_height(surface), + false); =20 memset(&ssd->dirty, 0, sizeof(ssd->dirty)); if (ssd->surface) { @@ -495,7 +475,6 @@ void qemu_spice_cursor_refresh_bh(void *opaque) =20 void qemu_spice_display_refresh(SimpleSpiceDisplay *ssd) { - dprint(3, "%s/%d:\n", __func__, ssd->qxl.id); graphic_hw_update(ssd->dcl.con); =20 qemu_mutex_lock(&ssd->lock); @@ -505,10 +484,10 @@ void qemu_spice_display_refresh(SimpleSpiceDisplay *s= sd) } qemu_mutex_unlock(&ssd->lock); =20 + trace_qemu_spice_display_refresh(ssd->qxl.id, ssd->notify); if (ssd->notify) { ssd->notify =3D 0; qemu_spice_wakeup(ssd); - dprint(2, "%s/%d: notify\n", __func__, ssd->qxl.id); } } =20 @@ -516,21 +495,17 @@ void qemu_spice_display_refresh(SimpleSpiceDisplay *s= sd) =20 static void interface_attach_worker(QXLInstance *sin, QXLWorker *qxl_worke= r) { - SimpleSpiceDisplay *ssd =3D container_of(sin, SimpleSpiceDisplay, qxl); - - dprint(1, "%s/%d:\n", __func__, ssd->qxl.id); + /* nothing to do */ } =20 static void interface_set_compression_level(QXLInstance *sin, int level) { - dprint(1, "%s/%d:\n", __func__, sin->id); /* nothing to do */ } =20 #if SPICE_NEEDS_SET_MM_TIME static void interface_set_mm_time(QXLInstance *sin, uint32_t mm_time) { - dprint(3, "%s/%d:\n", __func__, sin->id); /* nothing to do */ } #endif @@ -554,8 +529,6 @@ static int interface_get_command(QXLInstance *sin, QXLC= ommandExt *ext) SimpleSpiceUpdate *update; int ret =3D false; =20 - dprint(3, "%s/%d:\n", __func__, ssd->qxl.id); - qemu_mutex_lock(&ssd->lock); update =3D QTAILQ_FIRST(&ssd->updates); if (update !=3D NULL) { @@ -570,7 +543,6 @@ static int interface_get_command(QXLInstance *sin, QXLC= ommandExt *ext) =20 static int interface_req_cmd_notification(QXLInstance *sin) { - dprint(2, "%s/%d:\n", __func__, sin->id); return 1; } =20 @@ -582,7 +554,6 @@ static void interface_release_resource(QXLInstance *sin, SimpleSpiceCursor *cursor; QXLCommandExt *ext; =20 - dprint(2, "%s/%d:\n", __func__, ssd->qxl.id); ext =3D (void *)(intptr_t)(rext.info->id); switch (ext->cmd.type) { case QXL_CMD_DRAW: @@ -603,8 +574,6 @@ static int interface_get_cursor_command(QXLInstance *si= n, QXLCommandExt *ext) SimpleSpiceDisplay *ssd =3D container_of(sin, SimpleSpiceDisplay, qxl); int ret; =20 - dprint(3, "%s/%d:\n", __func__, ssd->qxl.id); - qemu_mutex_lock(&ssd->lock); if (ssd->ptr_define) { *ext =3D ssd->ptr_define->ext; @@ -623,7 +592,6 @@ static int interface_get_cursor_command(QXLInstance *si= n, QXLCommandExt *ext) =20 static int interface_req_cursor_notification(QXLInstance *sin) { - dprint(2, "%s:\n", __func__); return 1; } =20 @@ -680,7 +648,7 @@ static void interface_set_client_capabilities(QXLInstan= ce *sin, uint8_t client_present, uint8_t caps[58]) { - dprint(3, "%s:\n", __func__); + /* nothing to do */ } =20 static int interface_client_monitors_config(QXLInstance *sin, @@ -705,9 +673,9 @@ static int interface_client_monitors_config(QXLInstance= *sin, info.width =3D mc->monitors[head].width; info.height =3D mc->monitors[head].height; } + + trace_qemu_spice_ui_info(ssd->qxl.id, info.width, info.height); dpy_set_ui_info(ssd->dcl.con, &info); - dprint(1, "%s/%d: size %dx%d\n", __func__, ssd->qxl.id, - info.width, info.height); return 1; } =20 @@ -902,9 +870,10 @@ static void spice_gl_switch(DisplayChangeListener *dcl, return; } =20 - 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); + trace_qemu_spice_gl_surface(ssd->qxl.id, + surface_width(ssd->ds), + surface_height(ssd->ds), + fourcc); =20 /* note: spice server will close the fd */ spice_qxl_gl_scanout(&ssd->qxl, fd, @@ -932,7 +901,7 @@ static void qemu_spice_gl_scanout_disable(DisplayChange= Listener *dcl) { SimpleSpiceDisplay *ssd =3D container_of(dcl, SimpleSpiceDisplay, dcl); =20 - dprint(1, "%s: no framebuffer\n", __func__); + trace_qemu_spice_gl_scanout_disable(ssd->qxl.id); 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 =3D false; @@ -957,8 +926,7 @@ static void qemu_spice_gl_scanout_texture(DisplayChange= Listener *dcl, 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); + trace_qemu_spice_gl_scanout_texture(ssd->qxl.id, w, h, fourcc); =20 /* note: spice server will close the fd */ spice_qxl_gl_scanout(&ssd->qxl, fd, backing_width, backing_height, @@ -978,7 +946,8 @@ static void qemu_spice_gl_update(DisplayChangeListener = *dcl, return; } =20 - dprint(2, "%s: %dx%d+%d+%d\n", __func__, w, h, x, y); + + trace_qemu_spice_gl_update(ssd->qxl.id, w, h, x, y); qemu_spice_gl_block(ssd, true); cookie =3D (uintptr_t)qxl_cookie_new(QXL_COOKIE_TYPE_GL_DRAW_DONE, 0); spice_qxl_gl_draw_async(&ssd->qxl, x, y, w, h, cookie); diff --git a/ui/trace-events b/ui/trace-events index 861b68a305..518e950a01 100644 --- a/ui/trace-events +++ b/ui/trace-events @@ -75,6 +75,15 @@ qemu_spice_create_primary_surface(int qid, uint32_t sid,= void *surface, int asyn qemu_spice_destroy_primary_surface(int qid, uint32_t sid, int async) "%d s= id=3D%u async=3D%d" qemu_spice_wakeup(uint32_t qid) "%d" qemu_spice_create_update(uint32_t left, uint32_t right, uint32_t top, uint= 32_t bottom) "lr %d -> %d, tb -> %d -> %d" +qemu_spice_display_update(int qid, uint32_t x, uint32_t y, uint32_t w, uin= t32_t h) "%d +%d+%d %dx%d" +qemu_spice_display_surface(int qid, uint32_t w, uint32_t h, int fast) "%d = %dx%d, fast %d" +qemu_spice_display_refresh(int qid, int notify) "%d notify %d" +qemu_spice_ui_info(int qid, uint32_t width, uint32_t height) "%d %dx%d" + +qemu_spice_gl_surface(int qid, uint32_t w, uint32_t h, uint32_t fourcc) "%= d %dx%d, fourcc 0x%x" +qemu_spice_gl_scanout_disable(int qid) "%d" +qemu_spice_gl_scanout_texture(int qid, uint32_t w, uint32_t h, uint32_t fo= urcc) "%d %dx%d, fourcc 0x%x" +qemu_spice_gl_update(int qid, uint32_t x, uint32_t y, uint32_t w, uint32_t= h) "%d +%d+%d %dx%d" =20 # ui/keymaps.c keymap_parse(const char *file) "file %s" --=20 2.9.3 From nobody Fri Oct 24 21:59:44 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520325651784333.25169152172646; Tue, 6 Mar 2018 00:40:51 -0800 (PST) Received: from localhost ([::1]:54170 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1et89J-0006r1-Q6 for importer@patchew.org; Tue, 06 Mar 2018 03:40:43 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42885) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1et87K-0005cV-1P for qemu-devel@nongnu.org; Tue, 06 Mar 2018 03:38:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1et87G-0003hV-1q for qemu-devel@nongnu.org; Tue, 06 Mar 2018 03:38:38 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:48416 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1et87F-0003hA-Tl for qemu-devel@nongnu.org; Tue, 06 Mar 2018 03:38:33 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 09CA4EAEA0 for ; Tue, 6 Mar 2018 08:38:33 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-39.ams2.redhat.com [10.36.116.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id C60C1213AEF8; Tue, 6 Mar 2018 08:38:32 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 3BB8B1751E; Tue, 6 Mar 2018 09:38:32 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 6 Mar 2018 09:38:31 +0100 Message-Id: <20180306083832.8144-3-kraxel@redhat.com> In-Reply-To: <20180306083832.8144-1-kraxel@redhat.com> References: <20180306083832.8144-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 06 Mar 2018 08:38:33 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 06 Mar 2018 08:38:33 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kraxel@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2 2/3] spice: add scanout_dmabuf support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add support for scanout dmabufs. Just pass them through to spice-server. Signed-off-by: Gerd Hoffmann --- ui/spice-display.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ui/spice-display.c b/ui/spice-display.c index f3ae6beb3d..a494db1196 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -936,6 +936,20 @@ static void qemu_spice_gl_scanout_texture(DisplayChang= eListener *dcl, ssd->have_scanout =3D true; } =20 +static void qemu_spice_gl_scanout_dmabuf(DisplayChangeListener *dcl, + QemuDmaBuf *dmabuf) +{ + SimpleSpiceDisplay *ssd =3D container_of(dcl, SimpleSpiceDisplay, dcl); + + /* note: spice server will close the fd, so hand over a dup */ + spice_qxl_gl_scanout(&ssd->qxl, dup(dmabuf->fd), + dmabuf->width, dmabuf->height, + dmabuf->stride, dmabuf->fourcc, false); + qemu_spice_gl_monitor_config(ssd, 0, 0, dmabuf->width, dmabuf->height); + ssd->have_surface =3D false; + ssd->have_scanout =3D true; +} + static void qemu_spice_gl_update(DisplayChangeListener *dcl, uint32_t x, uint32_t y, uint32_t w, uint3= 2_t h) { @@ -969,6 +983,7 @@ static const DisplayChangeListenerOps display_listener_= gl_ops =3D { =20 .dpy_gl_scanout_disable =3D qemu_spice_gl_scanout_disable, .dpy_gl_scanout_texture =3D qemu_spice_gl_scanout_texture, + .dpy_gl_scanout_dmabuf =3D qemu_spice_gl_scanout_dmabuf, .dpy_gl_update =3D qemu_spice_gl_update, }; =20 --=20 2.9.3 From nobody Fri Oct 24 21:59:44 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520325653581980.3022814158419; Tue, 6 Mar 2018 00:40:53 -0800 (PST) Received: from localhost ([::1]:54174 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1et89O-0006ua-HF for importer@patchew.org; Tue, 06 Mar 2018 03:40:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42884) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1et87K-0005cU-0f for qemu-devel@nongnu.org; Tue, 06 Mar 2018 03:38:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1et87H-0003i1-Em for qemu-devel@nongnu.org; Tue, 06 Mar 2018 03:38:38 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:48418 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1et87H-0003hu-9Z for qemu-devel@nongnu.org; Tue, 06 Mar 2018 03:38:35 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D95C0EAEA0 for ; Tue, 6 Mar 2018 08:38:34 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-39.ams2.redhat.com [10.36.116.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id C467E111CB8C; Tue, 6 Mar 2018 08:38:32 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 45F7D17528; Tue, 6 Mar 2018 09:38:32 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 6 Mar 2018 09:38:32 +0100 Message-Id: <20180306083832.8144-4-kraxel@redhat.com> In-Reply-To: <20180306083832.8144-1-kraxel@redhat.com> References: <20180306083832.8144-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 06 Mar 2018 08:38:34 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 06 Mar 2018 08:38:34 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kraxel@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2 3/3] spice: add cursor_dmabuf support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add support for cursor dmabufs. qemu has to render the cursor for that, so in case a cursor is present qemu allocates a new dmabuf, blits the scanout, blends in the pointer and passes on the new dmabuf to spice-server. Without cursor qemu continues to simply pass on the scanout dmabuf as-is. Signed-off-by: Gerd Hoffmann --- include/ui/spice-display.h | 9 ++++ ui/spice-display.c | 114 +++++++++++++++++++++++++++++++++++++++++= ++-- ui/trace-events | 3 ++ 3 files changed, 121 insertions(+), 5 deletions(-) diff --git a/include/ui/spice-display.h b/include/ui/spice-display.h index 6b5c73b21c..87a84a59d4 100644 --- a/include/ui/spice-display.h +++ b/include/ui/spice-display.h @@ -122,6 +122,15 @@ struct SimpleSpiceDisplay { int gl_updates; bool have_scanout; bool have_surface; + + QemuDmaBuf *guest_dmabuf; + bool guest_dmabuf_refresh; + bool render_cursor; + + egl_fb guest_fb; + egl_fb blit_fb; + egl_fb cursor_fb; + bool have_hot; #endif }; =20 diff --git a/ui/spice-display.c b/ui/spice-display.c index a494db1196..61edc9d1ea 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -941,25 +941,126 @@ static void qemu_spice_gl_scanout_dmabuf(DisplayChan= geListener *dcl, { SimpleSpiceDisplay *ssd =3D container_of(dcl, SimpleSpiceDisplay, dcl); =20 - /* note: spice server will close the fd, so hand over a dup */ - spice_qxl_gl_scanout(&ssd->qxl, dup(dmabuf->fd), - dmabuf->width, dmabuf->height, - dmabuf->stride, dmabuf->fourcc, false); - qemu_spice_gl_monitor_config(ssd, 0, 0, dmabuf->width, dmabuf->height); + ssd->guest_dmabuf =3D dmabuf; + ssd->guest_dmabuf_refresh =3D true; + ssd->have_surface =3D false; ssd->have_scanout =3D true; } =20 +static void qemu_spice_gl_cursor_dmabuf(DisplayChangeListener *dcl, + QemuDmaBuf *dmabuf, bool have_hot, + uint32_t hot_x, uint32_t hot_y) +{ + SimpleSpiceDisplay *ssd =3D container_of(dcl, SimpleSpiceDisplay, dcl); + + ssd->have_hot =3D have_hot; + ssd->hot_x =3D hot_x; + ssd->hot_y =3D hot_y; + + trace_qemu_spice_gl_cursor(ssd->qxl.id, dmabuf !=3D NULL, have_hot); + if (dmabuf) { + egl_dmabuf_import_texture(dmabuf); + if (!dmabuf->texture) { + return; + } + egl_fb_setup_for_tex(&ssd->cursor_fb, dmabuf->width, dmabuf->heigh= t, + dmabuf->texture, false); + } else { + egl_fb_destroy(&ssd->cursor_fb); + } +} + +static void qemu_spice_gl_cursor_position(DisplayChangeListener *dcl, + uint32_t pos_x, uint32_t pos_y) +{ + SimpleSpiceDisplay *ssd =3D container_of(dcl, SimpleSpiceDisplay, dcl); + + ssd->ptr_x =3D pos_x; + ssd->ptr_y =3D pos_y; +} + +static void qemu_spice_gl_release_dmabuf(DisplayChangeListener *dcl, + QemuDmaBuf *dmabuf) +{ + SimpleSpiceDisplay *ssd =3D container_of(dcl, SimpleSpiceDisplay, dcl); + + if (ssd->guest_dmabuf =3D=3D dmabuf) { + ssd->guest_dmabuf =3D NULL; + ssd->guest_dmabuf_refresh =3D false; + } + egl_dmabuf_release_texture(dmabuf); +} + static void qemu_spice_gl_update(DisplayChangeListener *dcl, uint32_t x, uint32_t y, uint32_t w, uint3= 2_t h) { SimpleSpiceDisplay *ssd =3D container_of(dcl, SimpleSpiceDisplay, dcl); + EGLint stride =3D 0, fourcc =3D 0; + bool render_cursor =3D false; + bool y_0_top =3D false; /* FIXME */ uint64_t cookie; + int fd; =20 if (!ssd->have_scanout) { return; } =20 + if (ssd->cursor_fb.texture) { + render_cursor =3D true; + } + if (ssd->render_cursor !=3D render_cursor) { + ssd->render_cursor =3D render_cursor; + ssd->guest_dmabuf_refresh =3D true; + egl_fb_destroy(&ssd->blit_fb); + } + + if (ssd->guest_dmabuf_refresh) { + QemuDmaBuf *dmabuf =3D ssd->guest_dmabuf; + if (render_cursor) { + egl_dmabuf_import_texture(dmabuf); + if (!dmabuf->texture) { + return; + } + + /* source framebuffer */ + egl_fb_setup_for_tex(&ssd->guest_fb, + dmabuf->width, dmabuf->height, + dmabuf->texture, false); + + /* dest framebuffer */ + if (ssd->blit_fb.width !=3D dmabuf->width || + ssd->blit_fb.height !=3D dmabuf->height) { + trace_qemu_spice_gl_render_dmabuf(ssd->qxl.id, dmabuf->wid= th, + dmabuf->height); + egl_fb_destroy(&ssd->blit_fb); + egl_fb_setup_new_tex(&ssd->blit_fb, + dmabuf->width, dmabuf->height); + fd =3D egl_get_fd_for_texture(ssd->blit_fb.texture, + &stride, &fourcc); + spice_qxl_gl_scanout(&ssd->qxl, fd, + dmabuf->width, dmabuf->height, + stride, fourcc, false); + } + } else { + trace_qemu_spice_gl_forward_dmabuf(ssd->qxl.id, + dmabuf->width, dmabuf->heig= ht); + /* note: spice server will close the fd, so hand over a dup */ + spice_qxl_gl_scanout(&ssd->qxl, dup(dmabuf->fd), + dmabuf->width, dmabuf->height, + dmabuf->stride, dmabuf->fourcc, false); + } + qemu_spice_gl_monitor_config(ssd, 0, 0, dmabuf->width, dmabuf->hei= ght); + ssd->guest_dmabuf_refresh =3D false; + } + + if (render_cursor) { + egl_texture_blit(ssd->gls, &ssd->blit_fb, &ssd->guest_fb, + !y_0_top); + egl_texture_blend(ssd->gls, &ssd->blit_fb, &ssd->cursor_fb, + !y_0_top, ssd->ptr_x, ssd->ptr_y); + glFlush(); + } =20 trace_qemu_spice_gl_update(ssd->qxl.id, w, h, x, y); qemu_spice_gl_block(ssd, true); @@ -984,6 +1085,9 @@ static const DisplayChangeListenerOps display_listener= _gl_ops =3D { .dpy_gl_scanout_disable =3D qemu_spice_gl_scanout_disable, .dpy_gl_scanout_texture =3D qemu_spice_gl_scanout_texture, .dpy_gl_scanout_dmabuf =3D qemu_spice_gl_scanout_dmabuf, + .dpy_gl_cursor_dmabuf =3D qemu_spice_gl_cursor_dmabuf, + .dpy_gl_cursor_position =3D qemu_spice_gl_cursor_position, + .dpy_gl_release_dmabuf =3D qemu_spice_gl_release_dmabuf, .dpy_gl_update =3D qemu_spice_gl_update, }; =20 diff --git a/ui/trace-events b/ui/trace-events index 518e950a01..a957f363f1 100644 --- a/ui/trace-events +++ b/ui/trace-events @@ -83,6 +83,9 @@ qemu_spice_ui_info(int qid, uint32_t width, uint32_t heig= ht) "%d %dx%d" qemu_spice_gl_surface(int qid, uint32_t w, uint32_t h, uint32_t fourcc) "%= d %dx%d, fourcc 0x%x" qemu_spice_gl_scanout_disable(int qid) "%d" qemu_spice_gl_scanout_texture(int qid, uint32_t w, uint32_t h, uint32_t fo= urcc) "%d %dx%d, fourcc 0x%x" +qemu_spice_gl_cursor(int qid, bool enabled, bool hotspot) "%d enabled %d, = hotspot %d" +qemu_spice_gl_forward_dmabuf(int qid, uint32_t width, uint32_t height) "%d= %dx%d" +qemu_spice_gl_render_dmabuf(int qid, uint32_t width, uint32_t height) "%d = %dx%d" qemu_spice_gl_update(int qid, uint32_t x, uint32_t y, uint32_t w, uint32_t= h) "%d +%d+%d %dx%d" =20 # ui/keymaps.c --=20 2.9.3