From nobody Fri Apr 19 21:34:53 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1674464311; cv=none; d=zohomail.com; s=zohoarc; b=jDpfcllaC0Hluaq9yoJaDM8UCzUiTyQzPdIowOegay1MS59Rf72n+V/7VvgzKdD4pDVcjCi/4rOBZIhfKeT/2aA+dqeN5aYcwJrejApteK3uoCFZJgf5jGOGWwNMiE8aboVqyFuUVg+ChfGFSAqyta5ODnChA15x7wyh390+6pc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674464311; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UV18E2GO1aYVcSWJoOjKOcb5RUaL1jglqMoIIi+PFvE=; b=Fhv+go6nKbPSQdDAABbWtq+P0R6WFAotXfbvkepHDBcalKR+8VUs5xa+Dmi0Pr8GEmf9c3y8L3FGay9ylJ3kGCap3VZbHY6JwnqUiff4Sbfcy+8qDE5WZX066SCPXLPpSnxjCz3lJUPAbwf1FJhBM5TdthH2s6TfCSPEOwoAVkM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1674464311170543.9572383927857; Mon, 23 Jan 2023 00:58:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pJse9-00053Q-DI; Mon, 23 Jan 2023 03:57:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pJse4-000531-8e for qemu-devel@nongnu.org; Mon, 23 Jan 2023 03:57:40 -0500 Received: from mga05.intel.com ([192.55.52.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pJse2-0002Sq-J8 for qemu-devel@nongnu.org; Mon, 23 Jan 2023 03:57:40 -0500 Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2023 00:57:28 -0800 Received: from vkasired-desk2.fm.intel.com ([10.105.128.127]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2023 00:57:28 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674464258; x=1706000258; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dhNTF3QDCDcr1faDyACdENyYpr5UW+kl+qZ031o1tSg=; b=ewpjRc/AjYXf/f8oAfw6+wfj8Tax6TLuACDvU189wuhNem6U3z+QREDw TCeYDN0CFFAnGfUMltYSr3G8op3hb/qJfKIz5XrPZB+FuYfdvt2v3Xm3z HDyZpfraCd32TtZy7REBWJemyLPnSOFmbw/dFU/1dXGgKOolVMIaBSe7P 64NYJZS0O4LghQ8J86G5xf9nEvmN/Xx/3leITr11+VOsKlUGbejp+x09Z /qyH2r5pi1svzCLaDCZnJc3tFs5DgL4AnaRLHOVu4u/271WoJWW+G98+q aE+is0NFeDdTTar6fROsg5AoDe3FoAv5C7hht3pennJiIsx11KvPBEEnb Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10598"; a="412227799" X-IronPort-AV: E=Sophos;i="5.97,239,1669104000"; d="scan'208";a="412227799" X-IronPort-AV: E=McAfee;i="6500,9779,10598"; a="639057575" X-IronPort-AV: E=Sophos;i="5.97,239,1669104000"; d="scan'208";a="639057575" From: Vivek Kasireddy To: qemu-devel@nongnu.org Cc: Vivek Kasireddy , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Dongwon Kim Subject: [RFC v2 1/2] spice: Add an option for users to provide a preferred codec Date: Mon, 23 Jan 2023 00:37:54 -0800 Message-Id: <20230123083755.1038286-2-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230123083755.1038286-1-vivek.kasireddy@intel.com> References: <20230123083755.1038286-1-vivek.kasireddy@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=192.55.52.43; envelope-from=vivek.kasireddy@intel.com; helo=mga05.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1674464312681100002 Giving users an option to choose a particular codec will enable them to make an appropriate decision based on their hardware and use-case. Cc: Gerd Hoffmann Cc: Marc-Andr=C3=A9 Lureau Cc: Dongwon Kim Signed-off-by: Vivek Kasireddy --- qemu-options.hx | 5 +++++ ui/spice-core.c | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/qemu-options.hx b/qemu-options.hx index 3aa3a2f5a3..aab8df0922 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2142,6 +2142,7 @@ DEF("spice", HAS_ARG, QEMU_OPTION_spice, " [,streaming-video=3D[off|all|filter]][,disable-copy-paste=3Don= |off]\n" " [,disable-agent-file-xfer=3Don|off][,agent-mouse=3D[on|off]]\n" " [,playback-compression=3D[on|off]][,seamless-migration=3D[on|o= ff]]\n" + " [,preferred-codec=3D:\n" " [,gl=3D[on|off]][,rendernode=3D]\n" " enable spice\n" " at least one of {port, tls-port} is mandatory\n", @@ -2237,6 +2238,10 @@ SRST ``seamless-migration=3D[on|off]`` Enable/disable spice seamless migration. Default is off. =20 + ``preferred-codec=3D:`` + Provide the preferred codec the Spice server should use. + Default would be spice:mjpeg. + ``gl=3D[on|off]`` Enable/disable OpenGL context. Default is off. =20 diff --git a/ui/spice-core.c b/ui/spice-core.c index 72f8f1681c..6e00211e3a 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -469,6 +469,9 @@ static QemuOptsList qemu_spice_opts =3D { },{ .name =3D "streaming-video", .type =3D QEMU_OPT_STRING, + },{ + .name =3D "preferred-codec", + .type =3D QEMU_OPT_STRING, },{ .name =3D "agent-mouse", .type =3D QEMU_OPT_BOOL, @@ -644,6 +647,7 @@ static void qemu_spice_init(void) char *x509_key_file =3D NULL, *x509_cert_file =3D NULL, *x509_cacert_file =3D NULL; + const char *preferred_codec =3D NULL; int port, tls_port, addr_flags; spice_image_compression_t compression; spice_wan_compression_t wan_compr; @@ -795,6 +799,16 @@ static void qemu_spice_init(void) spice_server_set_streaming_video(spice_server, SPICE_STREAM_VIDEO_= OFF); } =20 + preferred_codec =3D qemu_opt_get(opts, "preferred-codec"); + if (preferred_codec) { + if (spice_server_set_video_codecs(spice_server, preferred_codec)) { + error_report("Preferred codec name is not valid"); + exit(1); + } + } else { + spice_server_set_video_codecs(spice_server, "spice:mjpeg"); + } + spice_server_set_agent_mouse (spice_server, qemu_opt_get_bool(opts, "agent-mouse", 1)); spice_server_set_playback_compression --=20 2.37.2 From nobody Fri Apr 19 21:34:53 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1674464312; cv=none; d=zohomail.com; s=zohoarc; b=ZVTq2qYnoQRSWkV9Vq2C4w2B/o/PLFsZ85/+5n6xHgPJPwHomQ9UcE179ojWs55KTcxcsWY0LJzvcmA4YgGqpWGbdW0pbSdb6NWUh3rXPLAlYjfFxq7gNfEWdxANBUpWj5qrFBIY01F9LjAm+rf/Lizad54Pe9P0321KceNS8to= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674464312; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Z0LFcC1rPdCyxQXds4czcPjhbvR8/obZRDrEwZrmTGc=; b=ObCmXjX0H506dUrm58bOpQyUIdQ3cyQNaSwm0E3oWGRpckebYSv8R1h28SDMr8zUWnyrEAjA6ppi5AmS2z9FVv+bfwAfpxVEMT82atH7Oxi9MA8OvT/RN1kbSpE64x5cURa9pfdQrEwya6TZGj8hxERcIr7QZa52uuO0YkwNfg0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1674464312818838.4219249383519; Mon, 23 Jan 2023 00:58:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pJseB-00053y-8m; Mon, 23 Jan 2023 03:57:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pJse7-00053U-ML for qemu-devel@nongnu.org; Mon, 23 Jan 2023 03:57:43 -0500 Received: from mga05.intel.com ([192.55.52.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pJse3-0002TJ-Rd for qemu-devel@nongnu.org; Mon, 23 Jan 2023 03:57:41 -0500 Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2023 00:57:28 -0800 Received: from vkasired-desk2.fm.intel.com ([10.105.128.127]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2023 00:57:28 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674464259; x=1706000259; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LA0rbr64R4MnwERitrEP/9d0s0CcFUx8zLRj4ewP6l0=; b=mLjciHUOjkw3KZDBX/0ebZulP/fYQUzux4/NgZYBLJN6jZzrYEGtLmFE fSvSg+O1iSXtY+C+/r3GSnlYprSgQl3kRWAw7YldiU2am1p3ihmh4UWNz jid8CkRT5Sfv0xkbIuRD2ovKdbPPzTdDOCUYt1TNFDuu+rS7KDQ1nOLqS cWemm0k5J03UQgj99ZF2FTf9bVO3WxFGW38UM2XCwJ17lVibUO7BV6AEt wbdNCGHUO4Fo7YprTo/H9UQ3c+mKRLHDgJ2csxIFYD96GDve6BmObZUPc U5ZqRh90BadbHGs837C2PT8N7szUJQMAMMBOXeCjwqE0205w8/2IESUGo A==; X-IronPort-AV: E=McAfee;i="6500,9779,10598"; a="412227802" X-IronPort-AV: E=Sophos;i="5.97,239,1669104000"; d="scan'208";a="412227802" X-IronPort-AV: E=McAfee;i="6500,9779,10598"; a="639057582" X-IronPort-AV: E=Sophos;i="5.97,239,1669104000"; d="scan'208";a="639057582" From: Vivek Kasireddy To: qemu-devel@nongnu.org Cc: Vivek Kasireddy , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Dongwon Kim Subject: [RFC v2 2/2] spice: Add an option to forward the dmabuf directly to the encoder (v2) Date: Mon, 23 Jan 2023 00:37:55 -0800 Message-Id: <20230123083755.1038286-3-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230123083755.1038286-1-vivek.kasireddy@intel.com> References: <20230123083755.1038286-1-vivek.kasireddy@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=192.55.52.43; envelope-from=vivek.kasireddy@intel.com; helo=mga05.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1674464314524100009 This patch adds support for gl=3Don and port !=3D 0. In other words, with this option enabled, it should be possible to stream the content associated with the dmabuf to a remote client. Here is the flow of things from the Qemu side: - Call gl_scanout (to update the fd) and gl_draw_async just like in the local display case. - Additionally, create an update with the cmd set to QXL_CMD_DRAW to trigger the creation of a new drawable (associated with the fd) by the Spice server. - Wait (or block) until the Encoder is done encoding the content. - Unblock the pipeline once the async completion cookie is received. v2: - Use the existing gl_scanout and gl_draw_async APIs instead of adding new ones. Cc: Gerd Hoffmann Cc: Marc-Andr=C3=A9 Lureau Cc: Dongwon Kim Signed-off-by: Vivek Kasireddy --- include/ui/spice-display.h | 1 + qemu-options.hx | 6 ++- ui/spice-core.c | 22 +++++++++-- ui/spice-display.c | 75 ++++++++++++++++++++++++++++---------- 4 files changed, 81 insertions(+), 23 deletions(-) diff --git a/include/ui/spice-display.h b/include/ui/spice-display.h index e271e011da..df74f5ee9b 100644 --- a/include/ui/spice-display.h +++ b/include/ui/spice-display.h @@ -153,6 +153,7 @@ struct SimpleSpiceCursor { }; =20 extern bool spice_opengl; +extern bool spice_dmabuf_encode; =20 int qemu_spice_rect_is_empty(const QXLRect* r); void qemu_spice_rect_union(QXLRect *dest, const QXLRect *r); diff --git a/qemu-options.hx b/qemu-options.hx index aab8df0922..3016f8a6f7 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2143,7 +2143,7 @@ DEF("spice", HAS_ARG, QEMU_OPTION_spice, " [,disable-agent-file-xfer=3Don|off][,agent-mouse=3D[on|off]]\n" " [,playback-compression=3D[on|off]][,seamless-migration=3D[on|o= ff]]\n" " [,preferred-codec=3D:\n" - " [,gl=3D[on|off]][,rendernode=3D]\n" + " [,gl=3D[on|off]][,rendernode=3D][,dmabuf-encode=3D[on|of= f]]\n" " enable spice\n" " at least one of {port, tls-port} is mandatory\n", QEMU_ARCH_ALL) @@ -2248,6 +2248,10 @@ SRST ``rendernode=3D`` DRM render node for OpenGL rendering. If not specified, it will pick the first available. (Since 2.9) + + ``dmabuf-encode=3D[on|off]`` + Forward the dmabuf directly to the encoder (Gstreamer). + Default is off. ERST =20 DEF("portrait", 0, QEMU_OPTION_portrait, diff --git a/ui/spice-core.c b/ui/spice-core.c index 6e00211e3a..c9b856b056 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -494,6 +494,9 @@ static QemuOptsList qemu_spice_opts =3D { },{ .name =3D "rendernode", .type =3D QEMU_OPT_STRING, + },{ + .name =3D "dmabuf-encode", + .type =3D QEMU_OPT_BOOL, #endif }, { /* end of list */ } @@ -843,11 +846,24 @@ static void qemu_spice_init(void) g_free(password); =20 #ifdef HAVE_SPICE_GL + if (qemu_opt_get_bool(opts, "dmabuf-encode", 0)) { + spice_dmabuf_encode =3D 1; + } if (qemu_opt_get_bool(opts, "gl", 0)) { - if ((port !=3D 0) || (tls_port !=3D 0)) { - error_report("SPICE GL support is local-only for now and " - "incompatible with -spice port/tls-port"); + if (((port !=3D 0) || (tls_port !=3D 0)) && !spice_dmabuf_encode) { + error_report("Add dmabuf-encode=3Don option to enable GL strea= ming"); exit(1); + } else if (spice_dmabuf_encode) { + if (port =3D=3D 0 && tls_port =3D=3D 0) { + error_report("dmabuf-encode=3Don is only meant to be used = for " + "non-local displays"); + exit(1); + } + if (g_strcmp0(preferred_codec, "gstreamer:h264")) { + error_report("dmabuf-encode=3Don currently only works and = tested" + "with gstreamer:h264"); + exit(1); + } } if (egl_rendernode_init(qemu_opt_get(opts, "rendernode"), DISPLAYGL_MODE_ON) !=3D 0) { diff --git a/ui/spice-display.c b/ui/spice-display.c index 494168e7fe..90ada643a2 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -28,6 +28,7 @@ #include "ui/spice-display.h" =20 bool spice_opengl; +bool spice_dmabuf_encode; =20 int qemu_spice_rect_is_empty(const QXLRect* r) { @@ -117,7 +118,7 @@ void qemu_spice_wakeup(SimpleSpiceDisplay *ssd) } =20 static void qemu_spice_create_one_update(SimpleSpiceDisplay *ssd, - QXLRect *rect) + QXLRect *rect, bool dmabuf) { SimpleSpiceUpdate *update; QXLDrawable *drawable; @@ -168,15 +169,17 @@ static void qemu_spice_create_one_update(SimpleSpiceD= isplay *ssd, image->bitmap.palette =3D 0; image->bitmap.format =3D SPICE_BITMAP_FMT_32BIT; =20 - dest =3D pixman_image_create_bits(PIXMAN_LE_x8r8g8b8, bw, bh, - (void *)update->bitmap, bw * 4); - pixman_image_composite(PIXMAN_OP_SRC, ssd->surface, NULL, ssd->mirror, - rect->left, rect->top, 0, 0, - rect->left, rect->top, bw, bh); - pixman_image_composite(PIXMAN_OP_SRC, ssd->mirror, NULL, dest, - rect->left, rect->top, 0, 0, - 0, 0, bw, bh); - pixman_image_unref(dest); + if (!dmabuf) { + dest =3D pixman_image_create_bits(PIXMAN_LE_x8r8g8b8, bw, bh, + (void *)update->bitmap, bw * 4); + pixman_image_composite(PIXMAN_OP_SRC, ssd->surface, NULL, ssd->mir= ror, + rect->left, rect->top, 0, 0, + rect->left, rect->top, bw, bh); + pixman_image_composite(PIXMAN_OP_SRC, ssd->mirror, NULL, dest, + rect->left, rect->top, 0, 0, + 0, 0, bw, bh); + pixman_image_unref(dest); + } =20 cmd->type =3D QXL_CMD_DRAW; cmd->data =3D (uintptr_t)drawable; @@ -220,7 +223,7 @@ static void qemu_spice_create_update(SimpleSpiceDisplay= *ssd) .left =3D x, .right =3D x + bw, }; - qemu_spice_create_one_update(ssd, &update); + qemu_spice_create_one_update(ssd, &update, false); dirty_top[blk] =3D -1; } } else { @@ -241,7 +244,7 @@ static void qemu_spice_create_update(SimpleSpiceDisplay= *ssd) .left =3D x, .right =3D x + bw, }; - qemu_spice_create_one_update(ssd, &update); + qemu_spice_create_one_update(ssd, &update, false); dirty_top[blk] =3D -1; } } @@ -848,9 +851,26 @@ static void qemu_spice_gl_block_timer(void *opaque) warn_report("spice: no gl-draw-done within one second"); } =20 +static void spice_gl_create_update(SimpleSpiceDisplay *ssd, + uint32_t width, uint32_t height) +{ + QXLRect update =3D { + .top =3D 0, + .bottom =3D height, + .left =3D 0, + .right =3D width, + }; + + WITH_QEMU_LOCK_GUARD(&ssd->lock) { + qemu_spice_create_one_update(ssd, &update, true); + } + qemu_spice_wakeup(ssd); +} + static void spice_gl_refresh(DisplayChangeListener *dcl) { SimpleSpiceDisplay *ssd =3D container_of(dcl, SimpleSpiceDisplay, dcl); + bool local_display =3D spice_dmabuf_encode ? false : true; uint64_t cookie; =20 if (!ssd->ds || qemu_console_is_gl_blocked(ssd->dcl.con)) { @@ -865,7 +885,11 @@ static void spice_gl_refresh(DisplayChangeListener *dc= l) spice_qxl_gl_draw_async(&ssd->qxl, 0, 0, surface_width(ssd->ds), surface_height(ssd->ds), - cookie); + cookie, local_display); + if (!local_display) { + spice_gl_create_update(ssd, surface_width(ssd->ds), + surface_height(ssd->ds)); + } ssd->gl_updates =3D 0; } } @@ -891,6 +915,9 @@ static void spice_gl_switch(DisplayChangeListener *dcl, } ssd->ds =3D new_surface; if (ssd->ds) { + if (spice_dmabuf_encode) { + qemu_spice_create_host_primary(ssd); + } surface_gl_create_texture(ssd->gls, ssd->ds); fd =3D egl_get_fd_for_texture(ssd->ds->texture, &stride, &fourcc, @@ -909,7 +936,9 @@ static void spice_gl_switch(DisplayChangeListener *dcl, spice_qxl_gl_scanout(&ssd->qxl, fd, surface_width(ssd->ds), surface_height(ssd->ds), - stride, fourcc, false); + stride, fourcc, false, + spice_dmabuf_encode ? false : true); + ssd->have_surface =3D true; ssd->have_scanout =3D false; =20 @@ -932,7 +961,8 @@ static void qemu_spice_gl_scanout_disable(DisplayChange= Listener *dcl) SimpleSpiceDisplay *ssd =3D container_of(dcl, SimpleSpiceDisplay, dcl); =20 trace_qemu_spice_gl_scanout_disable(ssd->qxl.id); - spice_qxl_gl_scanout(&ssd->qxl, -1, 0, 0, 0, 0, false); + spice_qxl_gl_scanout(&ssd->qxl, -1, 0, 0, 0, 0, false, + spice_dmabuf_encode ? false : true); qemu_spice_gl_monitor_config(ssd, 0, 0, 0, 0); ssd->have_surface =3D false; ssd->have_scanout =3D false; @@ -960,7 +990,9 @@ static void qemu_spice_gl_scanout_texture(DisplayChange= Listener *dcl, =20 /* note: spice server will close the fd */ spice_qxl_gl_scanout(&ssd->qxl, fd, backing_width, backing_height, - stride, fourcc, y_0_top); + stride, fourcc, y_0_top, + spice_dmabuf_encode ? false : true); + qemu_spice_gl_monitor_config(ssd, x, y, w, h); ssd->have_surface =3D false; ssd->have_scanout =3D true; @@ -1031,6 +1063,7 @@ static void qemu_spice_gl_update(DisplayChangeListene= r *dcl, EGLint stride =3D 0, fourcc =3D 0; bool render_cursor =3D false; bool y_0_top =3D false; /* FIXME */ + bool local_display =3D spice_dmabuf_encode ? false : true; uint64_t cookie; int fd; =20 @@ -1072,7 +1105,7 @@ static void qemu_spice_gl_update(DisplayChangeListene= r *dcl, &stride, &fourcc, NULL); spice_qxl_gl_scanout(&ssd->qxl, fd, dmabuf->width, dmabuf->height, - stride, fourcc, false); + stride, fourcc, false, local_display); } } else { trace_qemu_spice_gl_forward_dmabuf(ssd->qxl.id, @@ -1081,7 +1114,7 @@ static void qemu_spice_gl_update(DisplayChangeListene= r *dcl, spice_qxl_gl_scanout(&ssd->qxl, dup(dmabuf->fd), dmabuf->width, dmabuf->height, dmabuf->stride, dmabuf->fourcc, - dmabuf->y0_top); + dmabuf->y0_top, local_display); } qemu_spice_gl_monitor_config(ssd, 0, 0, dmabuf->width, dmabuf->hei= ght); ssd->guest_dmabuf_refresh =3D false; @@ -1104,7 +1137,11 @@ static void qemu_spice_gl_update(DisplayChangeListen= er *dcl, qemu_spice_gl_block(ssd, true); glFlush(); 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); + spice_qxl_gl_draw_async(&ssd->qxl, x, y, w, h, cookie, local_display); + if (!local_display) { + spice_gl_create_update(ssd, surface_width(ssd->ds), + surface_height(ssd->ds)); + } } =20 static const DisplayChangeListenerOps display_listener_gl_ops =3D { --=20 2.37.2