From nobody Sat Nov 15 23:39:23 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=1745907262; cv=none; d=zohomail.com; s=zohoarc; b=UBWW+m2wbJ07CskgWPY2rsWBcWs4TOvU4GJq5QHJZtcIDaLytMkIXBPX5LpxvWTqiV4oMrvwLFs2bmWwH8AVuGqaYPqJob+vMXldxkx51VTdLNTpka/EQHt8Lehse52JhtngKA4IGEE9NCAATrHhH29aqr2ESAVK7UhECwyGzWA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1745907262; 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=VUlM4X/t2Yt6ot35CQMWpxuEQTbUq1Z9LlNsRJU01D8=; b=FCDnNaz1XNrq6MdVCJ2btq6lfIgppB7iRGpKQ7Nx7T1T1H9SQnjNhwO5FlFb5XWYKdWf5vjeJP9KfbBO/iloajtF7puEkKN9QJJypT/RC8iEsFRe5DrDsRzrxM4v00r2so+bDNHF3U7YzbrF3VpyAzVdkh1K0j5Q5rf6uiN96co= 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 1745907262320796.948741042061; Mon, 28 Apr 2025 23:14:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u9eCu-0000mj-08; Tue, 29 Apr 2025 02:12:40 -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 1u9eCb-0000Xd-6g for qemu-devel@nongnu.org; Tue, 29 Apr 2025 02:12:21 -0400 Received: from mgamail.intel.com ([192.198.163.9]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u9eCY-0005MH-DF for qemu-devel@nongnu.org; Tue, 29 Apr 2025 02:12:19 -0400 Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2025 23:12:10 -0700 Received: from vkasired-desk2.fm.intel.com ([10.105.128.132]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2025 23:12:05 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1745907139; x=1777443139; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hZhn5KZdOeyv+nzABRzyG2dgF19g/XdGsIUnsInYycg=; b=kygs4OVUZaJd99av4+3VwDNJb5oVzXOPw3FA1qCwztW/jmlIxOGTIZgX EV5UDbBy9z/0YWl563D3Yk9iGxCfkpp9HD/1rSl/X4wHFRGpWS+K+7058 mX/sXS8K068VcHQp5KfpwNcQpA6o4htV0/AR+qTgrvO0sTGDkbrml73Ii pAY1Q0+sIrcJZ5j2A1ULSJyKrqtCqkpebbfFL6LNfRIH16XeIm0ruVN8u iBA4AMreJHmCEgFtTS0imCRaT7n+UV1+ysCHX3lhwYUfbLIzqMVwWKva+ 9CEsz2ccgqniA/Bu4izk8EmbKtodLKFh+5fB6YCTgMSufUdja0igzEWLg g==; X-CSE-ConnectionGUID: mkFe9cQdSNyf+u1++wfZ5g== X-CSE-MsgGUID: xd4obuW9SySYUDCPnEeHSg== X-IronPort-AV: E=McAfee;i="6700,10204,11417"; a="58169816" X-IronPort-AV: E=Sophos;i="6.15,248,1739865600"; d="scan'208";a="58169816" X-CSE-ConnectionGUID: 5Il5I5aUSB+1vT4XI+plmA== X-CSE-MsgGUID: QwYPd6EMSKycC0w9WhOWYw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,248,1739865600"; d="scan'208";a="133687166" 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 v3 1/6] ui/spice: Add an option for users to provide a preferred codec Date: Mon, 28 Apr 2025 23:08:25 -0700 Message-ID: <20250429060952.59508-2-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250429060952.59508-1-vivek.kasireddy@intel.com> References: <20250429060952.59508-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=192.198.163.9; envelope-from=vivek.kasireddy@intel.com; helo=mgamail.intel.com X-Spam_score_int: -48 X-Spam_score: -4.9 X-Spam_bar: ---- X-Spam_report: (-4.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.484, 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1745907263994019100 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.49.0 From nobody Sat Nov 15 23:39:23 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=1745907168; cv=none; d=zohomail.com; s=zohoarc; b=RXvfE3iTbBruU3uFDPVOGL2+nMamTakysNu3Q+UEw07n2J2lTiNp8ehxlDWJxEM5dBTHAUqXvWueos2gzgutmN30FQ19Pd0dNQKH3qBv+3OTzIJAiS/k76SDcaC8+8XazFEyxBW5/Ryp7Wsda9O221VKRZjQboYWm0r6TQ/QTfc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1745907168; 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=XzqiqNYKIeFNI/7cdaCjY9abrB5aYJBn7tFu/zovRF0=; b=Gzs7KljhivAzV3oJNhy1THMGq6CIIAYvvObwSk4iRCnDgrZiMRseCz0SncpCd2E5/nup2vd9VdhMMKd3wFT2kBi/IdlIPus92DSrCEv7ZE1MxjVyHX0ZqngyOYiriAyd2DgcQjmumhCtE6EYzWBD1QLjQx+30pvYFLgDz2+KD+Y= 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 17459071682494.094850919325836; Mon, 28 Apr 2025 23:12:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u9eCd-0000ZS-P0; Tue, 29 Apr 2025 02:12:23 -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 1u9eCX-0000W3-Om for qemu-devel@nongnu.org; Tue, 29 Apr 2025 02:12:18 -0400 Received: from mgamail.intel.com ([192.198.163.9]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u9eCU-0005MH-Uz for qemu-devel@nongnu.org; Tue, 29 Apr 2025 02:12:17 -0400 Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2025 23:12:10 -0700 Received: from vkasired-desk2.fm.intel.com ([10.105.128.132]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2025 23:12:05 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1745907135; x=1777443135; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FwoHFOGEmvR//f0X656oVgm6BG9908c723pjOWvbflw=; b=B7W2OXYIQvgwnELkQX6gxKB+/hGeoLGoQq6xkoVN4y9fRq3n62uI8d/O YdrLMsdxpDjTOotdU62bEs1b1nOwlkeV7LgE6wMShaGLk0pTVVtV1W0SA 1gm1GVfuja7sj6GsGQgt59yhVXUy3Vb9/T+nhM0hDLvFYv6+xj2imhkuP JZEQ1YyaReaPLYgta1bKDip2cAawvbOMZFUbAR18ZulaOuJcvZATbj9HO CWlD4IGdiChERmw7fQ7c9VE6RpYlWFRZsnz9mzX6DBsIghx6Fp27QvtfS Xbfx2aePSuxomDI9Wr/gZENBAFmUVXKX2iursvjn+03csm3Z/vKDaQFeq w==; X-CSE-ConnectionGUID: aAaLEfQ1QASln7bLFzoi+w== X-CSE-MsgGUID: zK3cFua5RmC5QEDDYK2/CA== X-IronPort-AV: E=McAfee;i="6700,10204,11417"; a="58169821" X-IronPort-AV: E=Sophos;i="6.15,248,1739865600"; d="scan'208";a="58169821" X-CSE-ConnectionGUID: uhaGMmQBSzW8wRcZpjak6w== X-CSE-MsgGUID: 7mP4r32qQsSxKzpEiKZbKg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,248,1739865600"; d="scan'208";a="133687168" 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 v3 2/6] ui/spice: Enable gl=on option for non-local or remote clients Date: Mon, 28 Apr 2025 23:08:26 -0700 Message-ID: <20250429060952.59508-3-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250429060952.59508-1-vivek.kasireddy@intel.com> References: <20250429060952.59508-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=192.198.163.9; envelope-from=vivek.kasireddy@intel.com; helo=mgamail.intel.com X-Spam_score_int: -48 X-Spam_score: -4.9 X-Spam_bar: ---- X-Spam_report: (-4.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.484, 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1745907169796019100 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.49.0 From nobody Sat Nov 15 23:39:23 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=1745907193; cv=none; d=zohomail.com; s=zohoarc; b=A7zSj7skR+fvhMfHVRM2du3wUSZfwcxlQqiA2oBQnGixGBTcgarlB25LO2k2FG7pEmnhVo/g56MJFzvMQTcujakjS75uRTHSvkSpCQLPCgTAA2AS+3J8VcaRmj/0wi8Ipnkx4IYEOmMU8UgrfjQimBxxrRSdDd3NN1yyOxKuT90= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1745907193; 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=ecFit7Tszf/6CWNIn9sMsMe9/oO6Jb2isNijRtLxVdo=; b=kxjcUoZbb/DaFyzCBU9pUNottkotJvxxKmqeCxaOcqt3qndgR3seoKGkmXq+bMUW8Qs2tdZsqvBsT9iqcuKcY9pnjIUSKqXIJESaeISlBlYgDmyeHozHAYmCBh6i4KbCq4C3G3zLA6wCdGj0TXcMJ9ZamSvU412dkpm1tKhoxE8= 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 1745907193544625.5039613967017; Mon, 28 Apr 2025 23:13:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u9eCp-0000eS-EO; Tue, 29 Apr 2025 02:12:36 -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 1u9eCc-0000YV-M0 for qemu-devel@nongnu.org; Tue, 29 Apr 2025 02:12:22 -0400 Received: from mgamail.intel.com ([192.198.163.9]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u9eCa-0005MH-Rg for qemu-devel@nongnu.org; Tue, 29 Apr 2025 02:12:22 -0400 Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2025 23:12:10 -0700 Received: from vkasired-desk2.fm.intel.com ([10.105.128.132]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2025 23:12:05 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1745907141; x=1777443141; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kG5jWO1IgUfvqZ1f/TklTK1++Vo1wEV/QobNWBp/ze8=; b=Mps3Ux6HIGueQPIFsWGjVPr+b109zwjynssCtKEn8PzmklfRY2tFGK6t xwG/c/1qAmU069SvQEbAzSzgEm4i9xrZ6u7lRLJbsUMzSyWkzd54/tVUP b4ySdUTg0BgkZJtPVSczUezKRIrhV/JrgCPw04/iYIvF5k5noLXZqi24y rvqwOKogRpTatoerp9dlGonzHa7s9sSADdOSttGvYuCpeg5r0N2fZYyjx MicTJShntaWp1mbpQheUvc3wPrIlbDIMf40QlAuQ/EsFAVYBf2AndnhSa uBqD6vgUVL+ezd+n8tp3EOe1+2g/xiu3cB3X29aOk+pJFthTWQs0fUrGK w==; X-CSE-ConnectionGUID: 4VIe14IsRtStgYsROa9j4Q== X-CSE-MsgGUID: tWDOnA0sQMaYULfYxH2ptw== X-IronPort-AV: E=McAfee;i="6700,10204,11417"; a="58169830" X-IronPort-AV: E=Sophos;i="6.15,248,1739865600"; d="scan'208";a="58169830" X-CSE-ConnectionGUID: VBOUh7CeT6eRC0NDUKzijg== X-CSE-MsgGUID: sNyask+oSv6N1AZ4Gko5VA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,248,1739865600"; d="scan'208";a="133687170" 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 v3 3/6] ui/spice: Submit the gl_draw requests at 60 FPS for remote clients Date: Mon, 28 Apr 2025 23:08:27 -0700 Message-ID: <20250429060952.59508-4-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250429060952.59508-1-vivek.kasireddy@intel.com> References: <20250429060952.59508-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=192.198.163.9; envelope-from=vivek.kasireddy@intel.com; helo=mgamail.intel.com X-Spam_score_int: -48 X-Spam_score: -4.9 X-Spam_bar: ---- X-Spam_report: (-4.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.484, 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1745907195991019100 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.49.0 From nobody Sat Nov 15 23:39:23 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=1745907216; cv=none; d=zohomail.com; s=zohoarc; b=MVsgpbfbfO9PyQ2VVhftHTvHazZljJZvtUBAF15wn4p2F9aw+jzK56pguoGsxKSTU4mw0dFv3FR/vnU65Ibo4JWTAeuffs5KOBXnDsX4RpzAqsqPb4wVGKQ3xfa2i/wUCwnHKyOCjboINvAewYIkvQyGBmMMwqNXn1sPAklN6tw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1745907216; 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=Zb6SkMektE18EA7yQID6dm/Jg9EVhcOdNqgSFcJxkw8=; b=LDwLVbFJ6fPFuSiOYKqyXb3aRBLkPALpN5PkK1u2PMHZjLob1iqbGSxY/Z1SjuwD1IJbSVW5rw05QkWLt0gRdDDh19oeZzhZlGKqmq4nTp3xymJctVHqWtRYzmvuVr2jK+FfRphPGbOsZIsdgiLCCiGaqKAt34AU0dH0ZhgmMto= 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 1745907216756560.7266293271334; Mon, 28 Apr 2025 23:13:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u9eCv-0000qN-TM; Tue, 29 Apr 2025 02:12:42 -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 1u9eCe-0000a3-3C for qemu-devel@nongnu.org; Tue, 29 Apr 2025 02:12:27 -0400 Received: from mgamail.intel.com ([192.198.163.9]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u9eCb-0005Mm-OE for qemu-devel@nongnu.org; Tue, 29 Apr 2025 02:12:23 -0400 Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2025 23:12:10 -0700 Received: from vkasired-desk2.fm.intel.com ([10.105.128.132]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2025 23:12:05 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1745907142; x=1777443142; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0uQUu7jwWHtxWQnUaOy1/HzHY9G5+CCLW6sT3sEd1lA=; b=ZI1pshXQP5vU3wMNmPr5WW72pExbKsUPR8mC3CG2maKRFuT99v4L9Lme T5tdMokR4ZtJXR0hEryoL95m/ffkB2wUsjR7vJexfsnxJ+ddBv+Wq6YTy 5KWsbHsE3AhFKDzu6qtpnZqSZez1utqPA1YNkSiO1luwjgsN55U/Yo7dr YKPcDtm/X4nuXyXnePKot/3zDv24tsm7hkRk0FnlxAOOn6zZNYRHz26jf YYwyItA3XbN21nU6SbntJv4h46ukPlSPfzS/qito4YnAOALFVXOZvf7mo rX3zyCVM9ES5/zPp9GaWrVzL6iykFYKx6F9u9LxP/Ew0debx8Lgh5bJbQ A==; X-CSE-ConnectionGUID: 3ilKcBImSTW7raxAohRmOg== X-CSE-MsgGUID: 2s2mMQE8Rzq7lzz65lV7Xg== X-IronPort-AV: E=McAfee;i="6700,10204,11417"; a="58169834" X-IronPort-AV: E=Sophos;i="6.15,248,1739865600"; d="scan'208";a="58169834" X-CSE-ConnectionGUID: HX0lm92dRVyOGH1Fyg/NAA== X-CSE-MsgGUID: FftOUFKETmSVhZjBaK345A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,248,1739865600"; d="scan'208";a="133687173" 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 v3 4/6] ui/console-gl: Add a helper to create a texture with linear memory layout Date: Mon, 28 Apr 2025 23:08:28 -0700 Message-ID: <20250429060952.59508-5-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250429060952.59508-1-vivek.kasireddy@intel.com> References: <20250429060952.59508-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=192.198.163.9; envelope-from=vivek.kasireddy@intel.com; helo=mgamail.intel.com X-Spam_score_int: -48 X-Spam_score: -4.9 X-Spam_bar: ---- X-Spam_report: (-4.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.484, 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1745907219916019100 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 | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 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..f83012fed4 100644 --- a/ui/console-gl.c +++ b/ui/console-gl.c @@ -25,6 +25,7 @@ * THE SOFTWARE. */ #include "qemu/osdep.h" +#include "qemu/error-report.h" #include "ui/console.h" #include "ui/shader.h" =20 @@ -96,6 +97,33 @@ 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 (glGetError() !=3D GL_NO_ERROR) { + error_report("spice: cannot import memory object from fd"); + 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.49.0 From nobody Sat Nov 15 23:39:23 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=1745907198; cv=none; d=zohomail.com; s=zohoarc; b=He/oUDRxphhvgh5kgR/1WkvnVBd+wLU/mWeiMG28piL/AyFVihHOdPva/+jlvZKHa+TZwD28bR9JvJYFLnsiVgnNM4V1rasfs0kC+5vE+R2wnRdyZydVrvEMKXINncXg9/dF4o/dTVt6dNkDO8EFLqesVMstwJQaee4SJgq6i54= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1745907198; 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=wMNXTWLrMXkASkaRrX7djPL9AxU2oMo/25nK5TOFx/g=; b=AvYa9Xw5W8IUlnKLTR4xSxWry+RvwEiv9prYKdxH59404DVkQB1lVDCdJjB8U3OJb3CAaVL02/eXbnnDkt8Avjll33SFNL2C5LJET4hCrHPz860T9ujNVlIoc95qfCo69cFzbLGIl1whwsotGQS3omMPuUKfsVFX2GSBG0f6ZgA= 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 1745907198665986.8746403546991; Mon, 28 Apr 2025 23:13:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u9eCv-0000pG-2E; Tue, 29 Apr 2025 02:12:41 -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 1u9eCf-0000ap-UX for qemu-devel@nongnu.org; Tue, 29 Apr 2025 02:12:29 -0400 Received: from mgamail.intel.com ([192.198.163.9]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u9eCe-0005Ma-5h for qemu-devel@nongnu.org; Tue, 29 Apr 2025 02:12:25 -0400 Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2025 23:12:10 -0700 Received: from vkasired-desk2.fm.intel.com ([10.105.128.132]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2025 23:12:05 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1745907144; x=1777443144; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Q/7IV4zXWPUNZVc5NISNGgaHsZd/LQO2N4LerTRJBK4=; b=D9izVgN3VRYivMvIs3vpwlqoOjaJwj4BjBRlgCJRKNmsHNsjm2vGkNeL 2rfwAuHuTEpOzCYPUlhezuUFHQY3apdExDGSfh76y/O5IKD+kussvYqZq 2aLT/7yBkdFg8GfbZBH0NeQUNCd+oq0dBNHgbI8CbNGfeOkztknQQ7mUT i+oG310zCtheqyiKtRIaCLhC+/MB+mQEux8vj9teNWjeMIYFGEWyFgynK V9RdWyGkM/RHuZRLG6mg8+f51MqR0eJA+oimOAx5X2A9FpF1uc+xu33Lr pMY5pVtgbF31Ev1YB9PotdfXZ13+Jskv7NLotusTowxtZeaOwPBye6aqt w==; X-CSE-ConnectionGUID: m2cpyFRIQjCm8Q7j3lxKyQ== X-CSE-MsgGUID: nxFtkTgSTVWn1Mxdyv6wfw== X-IronPort-AV: E=McAfee;i="6700,10204,11417"; a="58169841" X-IronPort-AV: E=Sophos;i="6.15,248,1739865600"; d="scan'208";a="58169841" X-CSE-ConnectionGUID: MZTwtlBtTSqclV3Z+pp9Pw== X-CSE-MsgGUID: 8iHTZ+NNSp6G8aGvDJ9oCg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,248,1739865600"; d="scan'208";a="133687174" 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 v3 5/6] ui/spice: Create a new texture with linear layout when gl=on is enabled Date: Mon, 28 Apr 2025 23:08:29 -0700 Message-ID: <20250429060952.59508-6-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250429060952.59508-1-vivek.kasireddy@intel.com> References: <20250429060952.59508-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=192.198.163.9; envelope-from=vivek.kasireddy@intel.com; helo=mgamail.intel.com X-Spam_score_int: -48 X-Spam_score: -4.9 X-Spam_bar: ---- X-Spam_report: (-4.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.484, 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1745907199983019000 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.49.0 From nobody Sat Nov 15 23:39:23 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=1745907186; cv=none; d=zohomail.com; s=zohoarc; b=WwG80NAYjUP84ttQQF6pVaytYYPhrWoq0K9QyP7gw3vbCGZthlvqCZYfyYGxm3vu4oiVhAWZVLCc02NB1djmnjPKPJ5pLcBhfA0k6sWCAcRy93Fp44Doe4cGrYqoJb9LF0HqNynbpaWUpecWRtaIgtoqnczjeofGxIe23vZfayY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1745907186; 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=u8z6LW3Y0GrT/OBg5u+YC2/IFL9sviYVQFTjwFPAvJ0=; b=ONT4tSrYPeUdliTXmbqcVtgpZmGwrtMJqFGn1SuRXzOEb9Xf7yMjWnw4XBAvqWS9rjetNwO9e4KsNjiAINKno02Ore5MWNWFAM45Yx562KuOhk5zu7/Oh1mivZsuNTNCDleZOFTqakhaYQmOjqlqiM1h2lzbVDmt6tIpRTL4NEo= 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 174590718641451.50601788660322; Mon, 28 Apr 2025 23:13:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u9eCw-0000qp-5H; Tue, 29 Apr 2025 02:12:42 -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 1u9eCg-0000b0-6W for qemu-devel@nongnu.org; Tue, 29 Apr 2025 02:12:29 -0400 Received: from mgamail.intel.com ([192.198.163.9]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u9eCe-0005MH-5i for qemu-devel@nongnu.org; Tue, 29 Apr 2025 02:12:25 -0400 Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2025 23:12:10 -0700 Received: from vkasired-desk2.fm.intel.com ([10.105.128.132]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2025 23:12:05 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1745907144; x=1777443144; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xyJgixVGy2/ZdOJLBT4m37r+RUqgTU2ICmfmg8ws5K0=; b=Kt+6cTnmYYxH++s92IUvRiaGeD8tPAArVyYfHB1lvINxXbXKOmxaxchW w6YTutzQjllZKGV4wp1/qc4xIOkuq4cFiz0MVn1kwfT3vW39k2Bb4Yqzn 0p5ttjkdkpDsom2gs7gpNgOvV016fGkIGdeLyVvvvVOZIJr+d0lZekUvf Cbrw/3Rt97QRDlnnbDmtB8gjnrnxiC3NbaHszDnUC1aOk+cSoLajDifXC eyGdYe5kY9WPf4vgs/gWctAdkx9yZS+/ycs8iWl84SmZGysAa5HqnIAUH 043k5vB9E2EyC3wSTpDMKdhtBD0C9zQ3Xzp8EDuw5u0omORQMIUAwOGSD A==; X-CSE-ConnectionGUID: IpRxhNEaTMqOeWltaoHtbQ== X-CSE-MsgGUID: LPrOFuCYRT+TgNoBPVv/dw== X-IronPort-AV: E=McAfee;i="6700,10204,11417"; a="58169837" X-IronPort-AV: E=Sophos;i="6.15,248,1739865600"; d="scan'208";a="58169837" X-CSE-ConnectionGUID: TVoL0VuQRhGrzkizw1nGyw== X-CSE-MsgGUID: hXisuGyoT02ejkAYOUibfQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,248,1739865600"; d="scan'208";a="133687176" 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 v3 6/6] ui/spice: Blit the scanout texture if its memory layout is not linear Date: Mon, 28 Apr 2025 23:08:30 -0700 Message-ID: <20250429060952.59508-7-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250429060952.59508-1-vivek.kasireddy@intel.com> References: <20250429060952.59508-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=192.198.163.9; envelope-from=vivek.kasireddy@intel.com; helo=mgamail.intel.com X-Spam_score_int: -48 X-Spam_score: -4.9 X-Spam_bar: ---- X-Spam_report: (-4.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.484, 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1745907188226019000 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.49.0