From nobody Wed Apr 2 13:35:53 2025 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1742946269; cv=none; d=zohomail.com; s=zohoarc; b=F9SHHbhaUoI4CrbrT0xPj25rCYZ4v+ZAR4tCsJKVc02grDOWFWqXahY1j/odv7ePury0pw0cMCwd0D2Yuwvl3cdtcrNcGJZf9Deob00HrENK5R5rCi+30LPr652BawaL1ls54Bq6l/DFJpdBaQWYs6N1Xtf5V6hAl99v0MxVPMY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742946269; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1zNGosqIZcbtPJC7gDn8n8UxxZz/kddupJBz/vL0/Ys=; b=bEu6gJ53TbTKgfdSHVG7khqM44s7bM9bxTBczs9W32y4R4eGNNimB7c9kxVijPN9UT5eo16p6TGQgD7LNvH6QiLUFODD2kxm2HMbu89A+81ddJiUKPQjFX2v3h0DZ+w2q03yetIUQYbtXWQX5bycyjcFGcrwxNF2EHalKxpiFUE= 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+importer=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 1742946269163689.1017290187581; Tue, 25 Mar 2025 16:44:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txDve-0000P6-4D; Tue, 25 Mar 2025 19:43:30 -0400 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 1txDvb-0000OA-Kk for qemu-devel@nongnu.org; Tue, 25 Mar 2025 19:43:27 -0400 Received: from mgamail.intel.com ([198.175.65.12]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1txDvZ-0005Gz-RF for qemu-devel@nongnu.org; Tue, 25 Mar 2025 19:43:27 -0400 Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2025 16:43:19 -0700 Received: from vkasired-desk2.fm.intel.com ([10.105.128.132]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2025 16:43:18 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1742946206; x=1774482206; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GUPbIlrSAOGAWvUKfKQQlreI6b7vKByoVl8Mn2xfEqE=; b=Q6rWroDAXJJhA3WlL7uvNN2wM5dra5T5cEUMTc3VywZ/a2dXHv6Lju+T Pa1eQMClcgyilUa1SiDksU6KRvyANTSZYqJwUpZegqUvqod2E69lZ+jfG UOjoy72xmz/N+EbUtcA2ANuIA3UqOimslZCZZHLuL1XeLVdDoGL5XdMYb 1HodY6r2ORTTLHK9x7vTSPUbnkMylDNEf2erzM4ww9KtLqW+aAvCuwwGp FPwnjgF8HDN2mcWEJ5mM0AdiJqA240BwUt6lxDwCe80zoMvLiBAAGIzCk XJLZHPnT59Qw0XdolE28UuVYDoUsS9kckTrVgXR/ZheYnhd1lDAYT0dIe A==; X-CSE-ConnectionGUID: OeAnHpZGStWkUbwOvEDWTA== X-CSE-MsgGUID: ffkblxS6Rlqeq/09HvZYsA== X-IronPort-AV: E=McAfee;i="6700,10204,11384"; a="55582833" X-IronPort-AV: E=Sophos;i="6.14,276,1736841600"; d="scan'208";a="55582833" X-CSE-ConnectionGUID: CNzz1PR4S76lvR1ugZy2Jg== X-CSE-MsgGUID: kgpRvg1/T+iNt0jvdBpvTA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,276,1736841600"; d="scan'208";a="124332496" From: Vivek Kasireddy To: qemu-devel@nongnu.org Cc: Vivek Kasireddy , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Dmitry Osipenko , Frediano Ziglio , Dongwon Kim Subject: [PATCH v2 1/6] ui/spice: Add an option for users to provide a preferred codec Date: Tue, 25 Mar 2025 16:39:31 -0700 Message-ID: <20250325234115.1332883-2-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250325234115.1332883-1-vivek.kasireddy@intel.com> References: <20250325234115.1332883-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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.12; envelope-from=vivek.kasireddy@intel.com; helo=mgamail.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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1742946270146019000 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: Dmitry Osipenko Cc: Frediano Ziglio Cc: Dongwon Kim Signed-off-by: Vivek Kasireddy --- qemu-options.hx | 5 +++++ ui/spice-core.c | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/qemu-options.hx b/qemu-options.hx index dc694a99a3..608a07cfc1 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2281,6 +2281,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" + " [,video-codecs=3D:\n" " [,gl=3D[on|off]][,rendernode=3D]\n" " enable spice\n" " at least one of {port, tls-port} is mandatory\n", @@ -2369,6 +2370,10 @@ SRST ``seamless-migration=3D[on|off]`` Enable/disable spice seamless migration. Default is off. =20 + ``video-codecs=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 0326c63bec..907b0e9a81 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -488,6 +488,9 @@ static QemuOptsList qemu_spice_opts =3D { },{ .name =3D "streaming-video", .type =3D QEMU_OPT_STRING, + },{ + .name =3D "video-codecs", + .type =3D QEMU_OPT_STRING, },{ .name =3D "agent-mouse", .type =3D QEMU_OPT_BOOL, @@ -662,6 +665,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 *video_codecs =3D NULL; int port, tls_port, addr_flags; spice_image_compression_t compression; spice_wan_compression_t wan_compr; @@ -801,6 +805,14 @@ static void qemu_spice_init(void) spice_server_set_streaming_video(spice_server, SPICE_STREAM_VIDEO_= OFF); } =20 + video_codecs =3D qemu_opt_get(opts, "video-codecs"); + if (video_codecs) { + if (spice_server_set_video_codecs(spice_server, video_codecs)) { + error_report("invalid video codecs"); + exit(1); + } + } + spice_server_set_agent_mouse (spice_server, qemu_opt_get_bool(opts, "agent-mouse", 1)); spice_server_set_playback_compression --=20 2.48.1 From nobody Wed Apr 2 13:35:53 2025 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1742946224; cv=none; d=zohomail.com; s=zohoarc; b=Czu5zK6zoELdAXfQrBmNtmNGit/mP0bhEDYb6CDVxOIs/6rczsRvvHGkGjTbwPeK1zOk438Tyw14Wk/ukaB4ckZk7Vrq4bkx9xRFExGWSuKEbVLK+V08OH5wyC9qFB51LdjgySxWcQf8VdAQyBqpQakRXA8hfKJm4TAUHlbM1P8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742946224; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=tJHaKing7kb70ACwYdFNMrjMzTP2ZCGk7auR5qy6ORM=; b=ZPf9Y+de3aV+vcauCHgLL3ai8LLtoyzgL3yJfXmf04tcp7t+HM+0ZyLvonPx8C4nGz3kCztt7Ifb8Fem6S0ukfHNhKhAJvC7HQi+YJ0hdRlYf0RBNwIZwnRBBUbUj2xv4LQ3xkAm/1WsxpPMCSNUp1HnBm7t/H50YqumAe/rQdQ= 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+importer=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 1742946224030222.79493669300302; Tue, 25 Mar 2025 16:43:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txDvd-0000Of-LP; Tue, 25 Mar 2025 19:43:29 -0400 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 1txDvc-0000OF-1i for qemu-devel@nongnu.org; Tue, 25 Mar 2025 19:43:28 -0400 Received: from mgamail.intel.com ([198.175.65.12]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1txDva-0005HG-Fw for qemu-devel@nongnu.org; Tue, 25 Mar 2025 19:43:27 -0400 Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2025 16:43:19 -0700 Received: from vkasired-desk2.fm.intel.com ([10.105.128.132]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2025 16:43:18 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1742946207; x=1774482207; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/yhzdTVtbjLDOfbBVYK0yLq4kmiWJb3G6zaE5uCqEKw=; b=Vz5EenhxZ4h+9j3+xEv12n6l+9uLq6H3GJO+SOsEx4IzEuW987Jt0bxq zh2JYLk4nKR+EfhQyQ5AdoSoyMVyzxaqqk3gOTDHNzYJbEXNPY+mzSGnO Crn2RMP4ByI6HebrNbQVbHa4LIMmGwQZ+nFUJv+NzOmTDkH5C34YlGnVC c78rjEtgZSrpTpmyWLvBwGdpVpXpcwwzzgeBvrwt1yOqEYICM1VkoK0ET 3s9dL7IKC3Ur7bgGJWOtAAROwZVV27+G0yFjqMcry2YPz3nqSxCOLVNq2 wVBaWxysn90nuC7cmifjoM1XEOmRTD90Da4uVcMPUQr0UG+bDdeH6ALvQ A==; X-CSE-ConnectionGUID: xVUJX4O8SQWGWG20nXk40w== X-CSE-MsgGUID: B+UmL4WzQ+C5Vaz2qEO8aQ== X-IronPort-AV: E=McAfee;i="6700,10204,11384"; a="55582837" X-IronPort-AV: E=Sophos;i="6.14,276,1736841600"; d="scan'208";a="55582837" X-CSE-ConnectionGUID: 7B5tVD4QQqSZHeDTxpjtOg== X-CSE-MsgGUID: /KkoT80HQdiAappEy1/H/A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,276,1736841600"; d="scan'208";a="124332499" From: Vivek Kasireddy To: qemu-devel@nongnu.org Cc: Vivek Kasireddy , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Dmitry Osipenko , Frediano Ziglio , Dongwon Kim Subject: [PATCH v2 2/6] ui/spice: Enable gl=on option for non-local or remote clients Date: Tue, 25 Mar 2025 16:39:32 -0700 Message-ID: <20250325234115.1332883-3-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250325234115.1332883-1-vivek.kasireddy@intel.com> References: <20250325234115.1332883-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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.12; envelope-from=vivek.kasireddy@intel.com; helo=mgamail.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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1742946226297019000 Newer versions of Spice server should be able to accept dmabuf fds from Qemu for clients that are connected via the network. In other words, when this option is enabled, Qemu would share a dmabuf fd with Spice which would encode and send the data associated with the fd to a client that could be located on a different machine. Cc: Gerd Hoffmann Cc: Marc-Andr=C3=A9 Lureau Cc: Dmitry Osipenko Cc: Frediano Ziglio Cc: Dongwon Kim Signed-off-by: Vivek Kasireddy --- include/ui/spice-display.h | 1 + ui/spice-core.c | 4 ++++ ui/spice-display.c | 1 + 3 files changed, 6 insertions(+) diff --git a/include/ui/spice-display.h b/include/ui/spice-display.h index e1a9b36185..f4922dd74b 100644 --- a/include/ui/spice-display.h +++ b/include/ui/spice-display.h @@ -151,6 +151,7 @@ struct SimpleSpiceCursor { }; =20 extern bool spice_opengl; +extern bool remote_client; =20 int qemu_spice_rect_is_empty(const QXLRect* r); void qemu_spice_rect_union(QXLRect *dest, const QXLRect *r); diff --git a/ui/spice-core.c b/ui/spice-core.c index 907b0e9a81..6c3bfe1d0f 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -848,9 +848,13 @@ static void qemu_spice_init(void) #ifdef HAVE_SPICE_GL if (qemu_opt_get_bool(opts, "gl", 0)) { if ((port !=3D 0) || (tls_port !=3D 0)) { +#if SPICE_SERVER_VERSION >=3D 0x000f03 /* release 0.15.3 */ + remote_client =3D 1; +#else error_report("SPICE GL support is local-only for now and " "incompatible with -spice port/tls-port"); exit(1); +#endif } egl_init(qemu_opt_get(opts, "rendernode"), DISPLAY_GL_MODE_ON, &er= ror_fatal); spice_opengl =3D 1; diff --git a/ui/spice-display.c b/ui/spice-display.c index c794ae0649..bf4caf0d1b 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -29,6 +29,7 @@ #include "ui/spice-display.h" =20 bool spice_opengl; +bool remote_client; =20 int qemu_spice_rect_is_empty(const QXLRect* r) { --=20 2.48.1 From nobody Wed Apr 2 13:35:53 2025 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1742946303; cv=none; d=zohomail.com; s=zohoarc; b=WoEziYIQKyjlT6DUAMYIoXctOMS+NSv72x6T6ouMv2PYDcQ9mlOJygPNE6zo8s4Wv48a2eBl/KfFMFRsf9Js3I9WGO94Oj9evQjkaMQBBP5v3JxI6oAD6YWWIUeI68/usJN2zY2zCEgdTOnGfmOMloVG2BTJa1PsaZJCXrbpODg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742946303; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Ms5CKr61VDoDL9XWjIv8ItetgYXZcPJXqccJDK7qBbs=; b=iNzgZRxFf6SzSz41701EMAyQdo8Cl4Wag58uNjLA+WkQLKkl81JkTYJgpgLJfHtebSiIpTNDoRPcsXUuXY2CTVTVh53+kjAuSpSWVTVa/SczLQp0D/8wyocn5jYmzvF8Tk0wmiICrYX/E2GTOINkCBPHR6Lh1qDhUkH3cQbSHSo= 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+importer=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 174294630314311.676757016040028; Tue, 25 Mar 2025 16:45:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txDvg-0000PP-29; Tue, 25 Mar 2025 19:43:32 -0400 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 1txDvd-0000Oi-Lr for qemu-devel@nongnu.org; Tue, 25 Mar 2025 19:43:29 -0400 Received: from mgamail.intel.com ([198.175.65.12]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1txDvb-0005Gz-Uk for qemu-devel@nongnu.org; Tue, 25 Mar 2025 19:43:29 -0400 Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2025 16:43:19 -0700 Received: from vkasired-desk2.fm.intel.com ([10.105.128.132]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2025 16:43:18 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1742946208; x=1774482208; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gilOvD+ZFdvZm09hlDiPqRgDGyPEDoaNjCx+Ynr01Hc=; b=RnSv/r9x/dldEkY8JLlh9wz+kAl2Pg/3wTp2iGkl6LXBhsv7ydb5yzQ6 KnVzPtYa/P+C+4lUnDF5kdw5czjhEQR5QdmnfHHVStcEHLLH1VHM9Ro10 xHnwlBTUo1Pax4WLgVkZpOExeFZyVnrQyVHZggSO7LnHBPtGn4BK/wLaU g7d5YfC+VtdDEcspedCYHp4h9cyYTjPqIzZWN8740JmyCvcMmOAoUbHQz mwPJpsfjJm/cy3lPAH18E+d5IHzkMVB3qLI+6QHPmtVHLEQdPWgkVBcD+ r9thoyx0jkZYmu47rx2xWv401KUc9ltRyCA9gN+0BfrgcsPJ7aZSZ0H6C Q==; X-CSE-ConnectionGUID: vCf23y1fRrGcgpTTmSqHXQ== X-CSE-MsgGUID: QlzMSoJBRTSlMeBLEhn8Mw== X-IronPort-AV: E=McAfee;i="6700,10204,11384"; a="55582841" X-IronPort-AV: E=Sophos;i="6.14,276,1736841600"; d="scan'208";a="55582841" X-CSE-ConnectionGUID: K1PSUXKTQhaVQ+tBlD1oFQ== X-CSE-MsgGUID: KDlAAC1xTvSP73PHYVXweA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,276,1736841600"; d="scan'208";a="124332502" From: Vivek Kasireddy To: qemu-devel@nongnu.org Cc: Vivek Kasireddy , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Dmitry Osipenko , Frediano Ziglio , Dongwon Kim Subject: [PATCH v2 3/6] ui/spice: Submit the gl_draw requests at 60 FPS for remote clients Date: Tue, 25 Mar 2025 16:39:33 -0700 Message-ID: <20250325234115.1332883-4-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250325234115.1332883-1-vivek.kasireddy@intel.com> References: <20250325234115.1332883-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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.12; envelope-from=vivek.kasireddy@intel.com; helo=mgamail.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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1742946304254019000 In the specific case where the display layer (virtio-gpu) is using dmabuf, and if remote clients are enabled (-spice gl=3Don,port=3Dxxxx), it makes sense to limit the maximum (streaming) rate to 60 FPS using the GUI timer. This matches the behavior of GTK UI where the display updates are submitted at 60 FPS (assuming the underlying mode is WxY@60). Cc: Gerd Hoffmann Cc: Marc-Andr=C3=A9 Lureau Cc: Dmitry Osipenko Cc: Frediano Ziglio Cc: Dongwon Kim Signed-off-by: Vivek Kasireddy --- ui/spice-display.c | 53 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/ui/spice-display.c b/ui/spice-display.c index bf4caf0d1b..2c4daa0707 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -842,12 +842,32 @@ static void qemu_spice_gl_block_timer(void *opaque) warn_report("spice: no gl-draw-done within one second"); } =20 +static void spice_gl_draw(SimpleSpiceDisplay *ssd, + uint32_t x, uint32_t y, uint32_t w, uint32_t h) +{ + uint64_t cookie; + + 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); +} + static void spice_gl_refresh(DisplayChangeListener *dcl) { SimpleSpiceDisplay *ssd =3D container_of(dcl, SimpleSpiceDisplay, dcl); - uint64_t cookie; =20 - if (!ssd->ds || qemu_console_is_gl_blocked(ssd->dcl.con)) { + if (!ssd->ds) { + return; + } + + if (qemu_console_is_gl_blocked(ssd->dcl.con)) { + if (remote_client && ssd->gl_updates && ssd->have_scanout) { + glFlush(); + spice_gl_draw(ssd, 0, 0, + surface_width(ssd->ds), surface_height(ssd->ds)); + ssd->gl_updates =3D 0; + /* To stream at 60 FPS, the (GUI) timer delay needs to be ~17 = ms */ + dcl->update_interval =3D 1000 / (2 * GUI_REFRESH_INTERVAL_DEFA= ULT) + 1; + } return; } =20 @@ -855,11 +875,8 @@ static void spice_gl_refresh(DisplayChangeListener *dc= l) if (ssd->gl_updates && ssd->have_surface) { 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, 0, 0, - surface_width(ssd->ds), - surface_height(ssd->ds), - cookie); + spice_gl_draw(ssd, 0, 0, + surface_width(ssd->ds), surface_height(ssd->ds)); ssd->gl_updates =3D 0; } } @@ -926,6 +943,20 @@ static void qemu_spice_gl_scanout_disable(DisplayChang= eListener *dcl) SimpleSpiceDisplay *ssd =3D container_of(dcl, SimpleSpiceDisplay, dcl); =20 trace_qemu_spice_gl_scanout_disable(ssd->qxl.id); + + /* + * We need to check for the case of "lost" updates, where a gl_draw + * was not submitted because the timer did not get a chance to run. + * One case where this happens is when the Guest VM is getting + * rebooted. If the console is blocked in this situation, we need + * to unblock it. Otherwise, newer updates would not take effect. + */ + if (qemu_console_is_gl_blocked(ssd->dcl.con)) { + if (remote_client && ssd->gl_updates && ssd->have_scanout) { + ssd->gl_updates =3D 0; + qemu_spice_gl_block(ssd, false); + } + } 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; @@ -1029,7 +1060,6 @@ 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 */ - uint64_t cookie; int fd; uint32_t width, height, texture; =20 @@ -1107,8 +1137,11 @@ static void qemu_spice_gl_update(DisplayChangeListen= er *dcl, trace_qemu_spice_gl_update(ssd->qxl.id, w, h, x, y); 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); + if (remote_client) { + ssd->gl_updates++; + } else { + spice_gl_draw(ssd, x, y, w, h); + } } =20 static const DisplayChangeListenerOps display_listener_gl_ops =3D { --=20 2.48.1 From nobody Wed Apr 2 13:35:53 2025 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1742946260; cv=none; d=zohomail.com; s=zohoarc; b=M0FhXhwnsmMqGAX5r3LUDVBjr8Kuzfq6N1sAHdCV4cp2i9r96jEHE1hkGlL2CUlqNGJqAvAUygodm/fgiTU9jBooZaoqe1D+OzfSmkvPKMsCDUUe+UDsN6veLQkhtbzLsiJ1I7607oeIfu8zxLAWiH2H0hm9WiA7CRxnnFYo8eM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742946260; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ANkwGP56lf5d94CRGb/J0z1tNNtFYsxD9lko8KiSq6Q=; b=dYb8dWwmibFFA7uIoqmSGccyeW5Viat0OL71nnqff5GtFdjvKjhyk5l/TCZYXrYh7r/oqfnA8gRBrLbB4+yFuiI8Pu91j09VS+0N/MD0dVej1w61ST2yD6YQW4hotYKcpHGf0x+OxgkIJi/A3wfWcjxRRRBAxD3Hq0fwSWOu5JY= 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+importer=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 1742946260835325.55008579225637; Tue, 25 Mar 2025 16:44:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txDvh-0000QI-FO; Tue, 25 Mar 2025 19:43:33 -0400 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 1txDve-0000PE-6J for qemu-devel@nongnu.org; Tue, 25 Mar 2025 19:43:30 -0400 Received: from mgamail.intel.com ([198.175.65.12]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1txDvc-0005HG-E2 for qemu-devel@nongnu.org; Tue, 25 Mar 2025 19:43:29 -0400 Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2025 16:43:19 -0700 Received: from vkasired-desk2.fm.intel.com ([10.105.128.132]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2025 16:43:18 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1742946209; x=1774482209; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ncD6agZmF3oz1bSf+Cj/TALHncQK1yrSZlA8HMMyTHs=; b=kNAfG7I6eKpOpwZkghkGd+RHsd1X5G/WhZUR+z9buSQ2tIAbof2wIlGk xR+1yAROvo8/Ot2lJDMdePbsJAwdc31vrlJWPjmY7KB6RhoyNvXN30KRw m7Bd3FcKIZccVi6el2EZ04Cgykj+e268vpn2tmCdiQe3qcVUO72c3ktsJ t3jhMor9SKY4bSllGsUdPWIE04eI2nnlDbIsIqxx8G7TlOgCQ/+ZyyFh9 T8SQmCVydz+i9e6NhHazT5iLAJz3zVm/fgVGNmuTF6mw7jWww5o15rtcY TBLh7m0DvRXeNiwvpjHdbef0Zk3gU8R00HXoHKnhQVmxPkdgETPQIC6an g==; X-CSE-ConnectionGUID: P98zSwivSs+qG+MPn/GQKw== X-CSE-MsgGUID: pwdMZSIYSdqmyzfjsgTcwQ== X-IronPort-AV: E=McAfee;i="6700,10204,11384"; a="55582846" X-IronPort-AV: E=Sophos;i="6.14,276,1736841600"; d="scan'208";a="55582846" X-CSE-ConnectionGUID: Gbj/qVDpRxO8GAuZc2NPLQ== X-CSE-MsgGUID: hG/KNTs7RSSXR5LVSCGeZA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,276,1736841600"; d="scan'208";a="124332505" From: Vivek Kasireddy To: qemu-devel@nongnu.org Cc: Vivek Kasireddy , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Dmitry Osipenko , Frediano Ziglio , Dongwon Kim Subject: [PATCH v2 4/6] ui/console-gl: Add a helper to create a texture with linear memory layout Date: Tue, 25 Mar 2025 16:39:34 -0700 Message-ID: <20250325234115.1332883-5-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250325234115.1332883-1-vivek.kasireddy@intel.com> References: <20250325234115.1332883-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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.12; envelope-from=vivek.kasireddy@intel.com; helo=mgamail.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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1742946263044019100 There are cases where we do not want the memory layout of a texture to be tiled as the component processing the texture would not know how to de-tile either via software or hardware. Therefore, ensuring that the memory backing the texture has a linear layout is absolutely necessary in these situations. Cc: Gerd Hoffmann Cc: Marc-Andr=C3=A9 Lureau Cc: Dmitry Osipenko Cc: Frediano Ziglio Cc: Dongwon Kim Signed-off-by: Vivek Kasireddy --- include/ui/console.h | 2 ++ ui/console-gl.c | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/include/ui/console.h b/include/ui/console.h index 46b3128185..fa2dd53e2e 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -422,6 +422,8 @@ bool console_gl_check_format(DisplayChangeListener *dcl, pixman_format_code_t format); void surface_gl_create_texture(QemuGLShader *gls, DisplaySurface *surface); +void surface_gl_create_texture_from_fd(DisplaySurface *surface, + int fd, GLuint *texture); void surface_gl_update_texture(QemuGLShader *gls, DisplaySurface *surface, int x, int y, int w, int h); diff --git a/ui/console-gl.c b/ui/console-gl.c index 103b954017..8ee882bc3c 100644 --- a/ui/console-gl.c +++ b/ui/console-gl.c @@ -96,6 +96,32 @@ void surface_gl_create_texture(QemuGLShader *gls, glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); } =20 +void surface_gl_create_texture_from_fd(DisplaySurface *surface, + int fd, GLuint *texture) +{ + unsigned long size =3D surface_stride(surface) * surface_height(surfac= e); + GLuint mem_obj; + + if (!epoxy_has_gl_extension("GL_EXT_memory_object") || + !epoxy_has_gl_extension("GL_EXT_memory_object_fd")) { + return; + } + +#ifdef GL_EXT_memory_object_fd + glCreateMemoryObjectsEXT(1, &mem_obj); + glImportMemoryFdEXT(mem_obj, size, GL_HANDLE_TYPE_OPAQUE_FD_EXT, fd); + if (!glIsMemoryObjectEXT(mem_obj)) { + return; + } + + glGenTextures(1, texture); + glBindTexture(GL_TEXTURE_2D, *texture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_TILING_EXT, GL_LINEAR_TILING= _EXT); + glTexStorageMem2DEXT(GL_TEXTURE_2D, 1, GL_RGBA8, surface_width(surface= ), + surface_height(surface), mem_obj, 0); +#endif +} + void surface_gl_update_texture(QemuGLShader *gls, DisplaySurface *surface, int x, int y, int w, int h) --=20 2.48.1 From nobody Wed Apr 2 13:35:53 2025 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1742946302; cv=none; d=zohomail.com; s=zohoarc; b=nRo7c369PCxwvhGtv+nhNjonNPbWPsF5X8OkcF/oOAuuegsfFMTew/Gw68WAYefybHsxksZzpjPHCbSFFn4NrmMcfYpetzpqaJz3/SMowhh1c4HKdtEAB6LCMPXgFQ4w9z75wVZmgPkSGNdyhzAT6X03ZToGrDDsk6i1iCl2xwo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742946302; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4YTf0Rj76haGvX5oo2JlkUNAy1XrHKVmbZoGKUeU+Uk=; b=I8E48OQSXvPCCge4s/htw2dXWhDd4dsNPMkarcT1d8UDw7d06XcAyq3JpXJmjKD9CuQVbLr31aNYlBBnjXLVqpfc5UcBa+m3CisiBlCzsuwaj28ZS5wGqFCZTETh7t45g/G8PEQiZZPju9JKJfSAW+g0ipJKDP+54YjAyqjePaM= 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+importer=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 1742946302072870.7771970568568; Tue, 25 Mar 2025 16:45:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txDvi-0000QQ-Kg; Tue, 25 Mar 2025 19:43:34 -0400 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 1txDvf-0000Pa-3j for qemu-devel@nongnu.org; Tue, 25 Mar 2025 19:43:31 -0400 Received: from mgamail.intel.com ([198.175.65.12]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1txDvc-0005HU-Jw for qemu-devel@nongnu.org; Tue, 25 Mar 2025 19:43:30 -0400 Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2025 16:43:19 -0700 Received: from vkasired-desk2.fm.intel.com ([10.105.128.132]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2025 16:43:18 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1742946209; x=1774482209; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SsML3id1zQyQzm0yL+5r+uEIFe5oIh+u9jre2KLjHn4=; b=a/BcgeRi/vt6roE0U8i4je5w3cvBVqiizCmI70g7B3zqjrPl8e8mfgDj RKoluNgR3h7AxfaM2Uv3mhaNM4mnjAMKCgbFexTsSTNxQP3/vjYrqZ8Ey 9qLeIjmvj3hRAW5p2qI4tf04B30mv3VixPGY0rCk7c4Pb7xKtxbSMHyJC RMwP/JU/fdWRLooatOkiG/3YYwZ2bfkIQ4tzZq4hrsAGhdMgevxffD7YK ozpnksc0N8UoD06dauwmivtaTkSUaM/6bFZ1DFVATSYPUBs5PpP1PRo5G ype/3DEsO6NolkzsUpWD8Kovyztpcd8HT2qEnPUm0kRFboVhxTdhtu8Qo g==; X-CSE-ConnectionGUID: 2V6Lh3iaQhCPnOnRNo8uLA== X-CSE-MsgGUID: 5Xynzmj4TheK+4zWj68K2A== X-IronPort-AV: E=McAfee;i="6700,10204,11384"; a="55582849" X-IronPort-AV: E=Sophos;i="6.14,276,1736841600"; d="scan'208";a="55582849" X-CSE-ConnectionGUID: tlxqlSucRjmyHi6ekryCYA== X-CSE-MsgGUID: qj7ORnR+S7WlUxfdHHeKlg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,276,1736841600"; d="scan'208";a="124332508" From: Vivek Kasireddy To: qemu-devel@nongnu.org Cc: Vivek Kasireddy , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Dmitry Osipenko , Frediano Ziglio , Dongwon Kim Subject: [PATCH v2 5/6] ui/spice: Create a new texture with linear layout when gl=on is enabled Date: Tue, 25 Mar 2025 16:39:35 -0700 Message-ID: <20250325234115.1332883-6-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250325234115.1332883-1-vivek.kasireddy@intel.com> References: <20250325234115.1332883-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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.12; envelope-from=vivek.kasireddy@intel.com; helo=mgamail.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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1742946303767019100 Since most encoders/decoders (invoked by Spice) may not work with tiled memory associated with a texture, we need to create another texture that has linear memory layout and use that instead. Note that, there does not seem to be a direct way to indicate to the GL implementation that a texture's backing memory needs to be linear. Instead, we have to do it in a roundabout way where we need to first create a tiled texture and import that as a memory object to create a new texture that has a linear memory layout. Cc: Gerd Hoffmann Cc: Marc-Andr=C3=A9 Lureau Cc: Dmitry Osipenko Cc: Frediano Ziglio Cc: Dongwon Kim Signed-off-by: Vivek Kasireddy --- ui/spice-display.c | 63 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/ui/spice-display.c b/ui/spice-display.c index 2c4daa0707..047d453a0b 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -26,6 +26,7 @@ #include "ui/console.h" #include "trace.h" =20 +#include "standard-headers/drm/drm_fourcc.h" #include "ui/spice-display.h" =20 bool spice_opengl; @@ -890,11 +891,65 @@ static void spice_gl_update(DisplayChangeListener *dc= l, ssd->gl_updates++; } =20 +static bool spice_gl_replace_fd_texture(SimpleSpiceDisplay *ssd, + EGLint *stride, EGLint *fourcc, + EGLuint64KHR *modifier, + int *fd) +{ + GLuint texture =3D 0; + + if (!remote_client) { + return true; + } + + if (surface_format(ssd->ds) =3D=3D PIXMAN_r5g6b5) { + return true; + } + + if (*modifier =3D=3D DRM_FORMAT_MOD_LINEAR) { + return true; + } + + /* + * We really want to ensure that the memory layout of the texture + * is linear; otherwise, the encoder's output may show corruption. + */ + surface_gl_create_texture_from_fd(ssd->ds, *fd, &texture); + + /* + * A successful return after glImportMemoryFdEXT() means that + * the ownership of fd has been passed to GL. In other words, + * the fd we got above should not be used anymore. + */ + if (texture > 0) { + *fd =3D egl_get_fd_for_texture(texture, + stride, fourcc, + NULL); + if (*fd < 0) { + glDeleteTextures(1, &texture); + *fd =3D egl_get_fd_for_texture(ssd->ds->texture, + stride, fourcc, + NULL); + if (*fd < 0) { + surface_gl_destroy_texture(ssd->gls, ssd->ds); + warn_report("spice: no texture available to display"); + return false; + } + } else { + surface_gl_destroy_texture(ssd->gls, ssd->ds); + ssd->ds->texture =3D texture; + } + } + return true; +} + static void spice_gl_switch(DisplayChangeListener *dcl, struct DisplaySurface *new_surface) { SimpleSpiceDisplay *ssd =3D container_of(dcl, SimpleSpiceDisplay, dcl); EGLint stride, fourcc; + EGLuint64KHR modifier; + bool ret; int fd; =20 if (ssd->ds) { @@ -905,12 +960,18 @@ static void spice_gl_switch(DisplayChangeListener *dc= l, surface_gl_create_texture(ssd->gls, ssd->ds); fd =3D egl_get_fd_for_texture(ssd->ds->texture, &stride, &fourcc, - NULL); + &modifier); if (fd < 0) { surface_gl_destroy_texture(ssd->gls, ssd->ds); return; } =20 + ret =3D spice_gl_replace_fd_texture(ssd, &stride, &fourcc, &modifi= er, &fd); + if (!ret) { + surface_gl_destroy_texture(ssd->gls, ssd->ds); + return; + } + trace_qemu_spice_gl_surface(ssd->qxl.id, surface_width(ssd->ds), surface_height(ssd->ds), --=20 2.48.1 From nobody Wed Apr 2 13:35:53 2025 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1742946257; cv=none; d=zohomail.com; s=zohoarc; b=GQ+Bzdwa+Y5H6XjOZchQC++WmWhXTAQTXwAv5wPZQZY8FY/EjKipRQ+IF2laBFXvr5xaZe2XAG4Zlkr3LUbZjiJc0YRD+6NuOOd0Bb8W6V8iQAB5pv/BxPWEI0jkX2iEE4PLHHCtULYyYvuEWIESfUJnlAnmIHdCGI6QI47eYCI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742946257; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ooR/krm5NK8itwM1g55Y6bMk8JknZW8511apP6DutAw=; b=TrHf7bUep75JE+8ewqH6BuwopWYT0YP4lyxSUmfrzU9ccaCAgbWlra8HLAlZnI02hYuqwkd1bHdKwuihdMYlRsllgJf+Ww00M2p6jPyTUcnD6+FAPLjtJjdD3dWqL2BqEk3T3588HEO9dVv7jO+DYJUZWieUyHXhFjayVmFQQuI= 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+importer=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 1742946257509203.99499804592017; Tue, 25 Mar 2025 16:44:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txDvl-0000Ro-2z; Tue, 25 Mar 2025 19:43:37 -0400 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 1txDvf-0000Pl-Rh for qemu-devel@nongnu.org; Tue, 25 Mar 2025 19:43:31 -0400 Received: from mgamail.intel.com ([198.175.65.12]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1txDve-0005Gz-1C for qemu-devel@nongnu.org; Tue, 25 Mar 2025 19:43:31 -0400 Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2025 16:43:20 -0700 Received: from vkasired-desk2.fm.intel.com ([10.105.128.132]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2025 16:43:18 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1742946210; x=1774482210; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SE7yhbP+AWXupah990h9uyu4eFpaGpDOFqgO8RURnbU=; b=gDuTDkv4LZGKuwXcfD2//aJ46ax2ntQpXP1dnAUDrJIkcVlroxN+xgIU TrPFrcmM1QDkE/2jNbGNYF7iv6r/aA/UnZVzJLferUP18sLDg/ZXQqFlz w1OrGscNMNdT5rUy7ZPdZODEgJR8fGiFZ9V2COsCeowEItWKaGJ9VfC3g NfnsGCjnBgGBFihYzd7dS6KkffLddGLlS4f4JUCperv2GuEmBn9Pc1r5b fUgOXyxI0CLu6E44HVpvQr3+izQSewoDG13EnXS0WVgLZ9lZNoDX6DS+0 99I0ooag6gADJh4enMh5MckQ9C63S5t0j2xbrpvXcPuikKdURjK3pXzo5 A==; X-CSE-ConnectionGUID: sDRBK8OlQYah7R7zHiBZ4g== X-CSE-MsgGUID: gTHF1k4/TCS6TfXmpPLUig== X-IronPort-AV: E=McAfee;i="6700,10204,11384"; a="55582853" X-IronPort-AV: E=Sophos;i="6.14,276,1736841600"; d="scan'208";a="55582853" X-CSE-ConnectionGUID: OPOi+L8XQfqhLQxKJAmuiw== X-CSE-MsgGUID: l7l4lM4bSXums8DUvn7HnA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,276,1736841600"; d="scan'208";a="124332511" From: Vivek Kasireddy To: qemu-devel@nongnu.org Cc: Vivek Kasireddy , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Dmitry Osipenko , Frediano Ziglio , Dongwon Kim Subject: [PATCH v2 6/6] ui/spice: Blit the scanout texture if its memory layout is not linear Date: Tue, 25 Mar 2025 16:39:36 -0700 Message-ID: <20250325234115.1332883-7-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250325234115.1332883-1-vivek.kasireddy@intel.com> References: <20250325234115.1332883-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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.12; envelope-from=vivek.kasireddy@intel.com; helo=mgamail.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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1742946259819019100 In cases where the scanout buffer is provided as a texture (e.g. Virgl) we need to check to see if it has a linear memory layout or not. If it doesn't have a linear layout, then blitting it onto the texture associated with the display surface (which already has a linear layout) seems to ensure that there is no corruption seen regardless of which encoder or decoder is used. Cc: Gerd Hoffmann Cc: Marc-Andr=C3=A9 Lureau Cc: Dmitry Osipenko Cc: Frediano Ziglio Cc: Dongwon Kim Signed-off-by: Vivek Kasireddy --- include/ui/spice-display.h | 3 ++ ui/spice-display.c | 67 +++++++++++++++++++++++++++++++++++--- 2 files changed, 65 insertions(+), 5 deletions(-) diff --git a/include/ui/spice-display.h b/include/ui/spice-display.h index f4922dd74b..d087d7198a 100644 --- a/include/ui/spice-display.h +++ b/include/ui/spice-display.h @@ -132,6 +132,9 @@ struct SimpleSpiceDisplay { egl_fb guest_fb; egl_fb blit_fb; egl_fb cursor_fb; + bool backing_y_0_top; + bool blit_scanout_texture; + bool new_scanout_texture; bool have_hot; #endif }; diff --git a/ui/spice-display.c b/ui/spice-display.c index 047d453a0b..3fa15d6981 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -1035,20 +1035,34 @@ static void qemu_spice_gl_scanout_texture(DisplayCh= angeListener *dcl, { SimpleSpiceDisplay *ssd =3D container_of(dcl, SimpleSpiceDisplay, dcl); EGLint stride =3D 0, fourcc =3D 0; + EGLuint64KHR modifier =3D 0; int fd =3D -1; =20 assert(tex_id); - fd =3D egl_get_fd_for_texture(tex_id, &stride, &fourcc, NULL); + + fd =3D egl_get_fd_for_texture(tex_id, &stride, &fourcc, &modifier); if (fd < 0) { fprintf(stderr, "%s: failed to get fd for texture\n", __func__); return; } 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, - stride, fourcc, y_0_top); - qemu_spice_gl_monitor_config(ssd, x, y, w, h); + if (remote_client && modifier !=3D DRM_FORMAT_MOD_LINEAR) { + egl_fb_destroy(&ssd->guest_fb); + egl_fb_setup_for_tex(&ssd->guest_fb, + backing_width, backing_height, + tex_id, false); + ssd->backing_y_0_top =3D y_0_top; + ssd->blit_scanout_texture =3D true; + ssd->new_scanout_texture =3D true; + close(fd); + } else { + /* note: spice server will close the fd */ + spice_qxl_gl_scanout(&ssd->qxl, fd, backing_width, backing_height, + stride, fourcc, y_0_top); + qemu_spice_gl_monitor_config(ssd, x, y, w, h); + } + ssd->have_surface =3D false; ssd->have_scanout =3D true; } @@ -1114,6 +1128,41 @@ static void qemu_spice_gl_release_dmabuf(DisplayChan= geListener *dcl, egl_dmabuf_release_texture(dmabuf); } =20 +static bool spice_gl_blit_scanout_texture(SimpleSpiceDisplay *ssd) +{ + EGLint stride =3D 0, fourcc =3D 0; + int fd; + + egl_fb_destroy(&ssd->blit_fb); + egl_fb_setup_for_tex(&ssd->blit_fb, + surface_width(ssd->ds), surface_height(ssd->ds), + ssd->ds->texture, false); + egl_fb_blit(&ssd->blit_fb, &ssd->guest_fb, false); + glFlush(); + + if (!ssd->new_scanout_texture) { + return true; + } + + fd =3D egl_get_fd_for_texture(ssd->ds->texture, + &stride, &fourcc, + NULL); + if (fd < 0) { + fprintf(stderr, "%s: failed to get fd for texture\n", __func__); + return false; + } + + spice_qxl_gl_scanout(&ssd->qxl, fd, + surface_width(ssd->ds), + surface_height(ssd->ds), + stride, fourcc, ssd->backing_y_0_top); + qemu_spice_gl_monitor_config(ssd, 0, 0, + surface_width(ssd->ds), + surface_height(ssd->ds)); + ssd->new_scanout_texture =3D false; + return true; +} + static void qemu_spice_gl_update(DisplayChangeListener *dcl, uint32_t x, uint32_t y, uint32_t w, uint3= 2_t h) { @@ -1121,6 +1170,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 ret; int fd; uint32_t width, height, texture; =20 @@ -1195,6 +1245,13 @@ static void qemu_spice_gl_update(DisplayChangeListen= er *dcl, glFlush(); } =20 + if (remote_client && ssd->blit_scanout_texture) { + ret =3D spice_gl_blit_scanout_texture(ssd); + if (!ret) { + return; + } + } + trace_qemu_spice_gl_update(ssd->qxl.id, w, h, x, y); qemu_spice_gl_block(ssd, true); glFlush(); --=20 2.48.1