From patchwork Sat Jan 20 00:30:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Kasireddy, Vivek" X-Patchwork-Id: 1888714 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=hM1TerbU; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TGyfH6XCFz23fH for ; Sat, 20 Jan 2024 11:53:42 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rQzbb-0001rE-Sj; Fri, 19 Jan 2024 19:53:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rQzbZ-0001qh-MB for qemu-devel@nongnu.org; Fri, 19 Jan 2024 19:53:02 -0500 Received: from mgamail.intel.com ([192.55.52.120]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rQzbX-0000HA-SX for qemu-devel@nongnu.org; Fri, 19 Jan 2024 19:53:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705711979; x=1737247979; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VhMoDg2Dfnr8VM+IjInSXHA29VWyPI/mwx53F/p9aJY=; b=hM1TerbUVWkZDHdAyba3nD5IA2j3dHSVEvKOaDTqqFn5zAHzHrRu+pSb yJlaZJmva/Vb2jv53t2/gk4VXmoyDZ3F5JzfJiltShAPr+KPORw1lqAw8 hNwaitC1BnCHGn8jvyKYkTtXJpffmoTcbzvDr6beBabrtI4xMrbE3L1oS vdaSFtF+YAm24bgEVqR4NnJ/5v9DGFcHJNpUcLb6kt7/ULGPZnFgQeT8K zjbVa4IIZTcm3f/fzkKCPrgL7Xkn85uUWqoFniEKcPTd3vHGVhiAtkZuC GIciFiHho33TZz/lKJXHr/ASlmtWhVGoaj90YhOmS5Xmk5IRd9AjU7mXj A==; X-IronPort-AV: E=McAfee;i="6600,9927,10957"; a="399763752" X-IronPort-AV: E=Sophos;i="6.05,206,1701158400"; d="scan'208";a="399763752" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jan 2024 16:52:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10957"; a="904297436" X-IronPort-AV: E=Sophos;i="6.05,206,1701158400"; d="scan'208";a="904297436" Received: from vkasired-desk2.fm.intel.com ([10.105.128.132]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jan 2024 16:52:52 -0800 From: Vivek Kasireddy To: qemu-devel@nongnu.org Cc: Vivek Kasireddy , Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Frediano Ziglio , Dongwon Kim Subject: [PATCH v1 1/7] ui/spice: Add an option for users to provide a preferred codec Date: Fri, 19 Jan 2024 16:30:07 -0800 Message-Id: <20240120003013.1829757-2-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240120003013.1829757-1-vivek.kasireddy@intel.com> References: <20240120003013.1829757-1-vivek.kasireddy@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=192.55.52.120; envelope-from=vivek.kasireddy@intel.com; helo=mgamail.intel.com X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.519, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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é Lureau Cc: Frediano Ziglio Cc: Dongwon Kim Signed-off-by: Vivek Kasireddy --- v2: - Don't override the default Spice codec if preferred-codec is not provided (Frediano) --- 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 b66570ae00..caaafe01d5 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2260,6 +2260,7 @@ DEF("spice", HAS_ARG, QEMU_OPTION_spice, " [,streaming-video=[off|all|filter]][,disable-copy-paste=on|off]\n" " [,disable-agent-file-xfer=on|off][,agent-mouse=[on|off]]\n" " [,playback-compression=[on|off]][,seamless-migration=[on|off]]\n" + " [,preferred-codec=:\n" " [,gl=[on|off]][,rendernode=]\n" " enable spice\n" " at least one of {port, tls-port} is mandatory\n", @@ -2348,6 +2349,10 @@ SRST ``seamless-migration=[on|off]`` Enable/disable spice seamless migration. Default is off. + ``preferred-codec=:`` + Provide the preferred codec the Spice server should use. + Default would be spice:mjpeg. + ``gl=[on|off]`` Enable/disable OpenGL context. Default is off. diff --git a/ui/spice-core.c b/ui/spice-core.c index db21db2c94..13bfbe4e89 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -488,6 +488,9 @@ static QemuOptsList qemu_spice_opts = { },{ .name = "streaming-video", .type = QEMU_OPT_STRING, + },{ + .name = "preferred-codec", + .type = QEMU_OPT_STRING, },{ .name = "agent-mouse", .type = QEMU_OPT_BOOL, @@ -663,6 +666,7 @@ static void qemu_spice_init(void) char *x509_key_file = NULL, *x509_cert_file = NULL, *x509_cacert_file = NULL; + const char *preferred_codec = NULL; int port, tls_port, addr_flags; spice_image_compression_t compression; spice_wan_compression_t wan_compr; @@ -802,6 +806,14 @@ static void qemu_spice_init(void) spice_server_set_streaming_video(spice_server, SPICE_STREAM_VIDEO_OFF); } + preferred_codec = qemu_opt_get(opts, "preferred-codec"); + if (preferred_codec) { + if (spice_server_set_video_codecs(spice_server, preferred_codec)) { + error_report("Preferred codec name is not valid"); + exit(1); + } + } + spice_server_set_agent_mouse (spice_server, qemu_opt_get_bool(opts, "agent-mouse", 1)); spice_server_set_playback_compression From patchwork Sat Jan 20 00:30:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Kasireddy, Vivek" X-Patchwork-Id: 1888718 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=dL0FCcar; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TGyfd6xC5z1yWl for ; Sat, 20 Jan 2024 11:54:01 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rQzbe-0001rt-5I; Fri, 19 Jan 2024 19:53:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rQzbb-0001rA-LL for qemu-devel@nongnu.org; Fri, 19 Jan 2024 19:53:03 -0500 Received: from mgamail.intel.com ([192.55.52.120]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rQzbZ-0000HV-HK for qemu-devel@nongnu.org; Fri, 19 Jan 2024 19:53:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705711981; x=1737247981; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UmuSXtMKLQfmwnfzVXPDW5lf8tnHK7D5DmWuTya8UEE=; b=dL0FCcarpjhkx0r6z+nF5RCWfz8O9oN55Jw5GqOxAoIT8zkqd6fxWY02 NpUCZwEYyV+pbvL1pN/PQn92kb82uuBRJGRqMIfx9ul61R5jfOgaR4KmE Zcx2DLRq5dqQBMGeZm84OJOZyBxTkhz0o9y1NcO1VIC+1IdSQSFfytIcv r8mknfw3mparzTP3Sa9nG3dKQYB8u/fyU4na2z85bpHTm+I9LLKnaR4PR dyHXuP4ah41ltwK3jrT50+l/Rb5ZuFryXwMj6MwEtyDP/pkDSUEep2JVR LyD8UzbbVJ1tWgdWoaBj4wFywDa2ri0W3GNrwPC7hA4SWamPgFeh/9j4B Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10957"; a="399763755" X-IronPort-AV: E=Sophos;i="6.05,206,1701158400"; d="scan'208";a="399763755" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jan 2024 16:52:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10957"; a="904297439" X-IronPort-AV: E=Sophos;i="6.05,206,1701158400"; d="scan'208";a="904297439" Received: from vkasired-desk2.fm.intel.com ([10.105.128.132]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jan 2024 16:52:52 -0800 From: Vivek Kasireddy To: qemu-devel@nongnu.org Cc: Vivek Kasireddy , Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Frediano Ziglio , Dongwon Kim Subject: [PATCH v1 2/7] ui/spice: Enable gl=on option for non-local or remote clients Date: Fri, 19 Jan 2024 16:30:08 -0800 Message-Id: <20240120003013.1829757-3-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240120003013.1829757-1-vivek.kasireddy@intel.com> References: <20240120003013.1829757-1-vivek.kasireddy@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=192.55.52.120; envelope-from=vivek.kasireddy@intel.com; helo=mgamail.intel.com X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.519, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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é Lureau 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 { }; extern bool spice_opengl; +extern bool remote_client; 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 13bfbe4e89..3b9a54685f 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -849,9 +849,13 @@ static void qemu_spice_init(void) #ifdef HAVE_SPICE_GL if (qemu_opt_get_bool(opts, "gl", 0)) { if ((port != 0) || (tls_port != 0)) { +#if SPICE_SERVER_VERSION >= 0x000f03 /* release 0.15.3 */ + remote_client = 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"), DISPLAYGL_MODE_ON, &error_fatal); spice_opengl = 1; diff --git a/ui/spice-display.c b/ui/spice-display.c index 6eb98a5a5c..384b8508d4 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -29,6 +29,7 @@ #include "ui/spice-display.h" bool spice_opengl; +bool remote_client; int qemu_spice_rect_is_empty(const QXLRect* r) { From patchwork Sat Jan 20 00:30:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Kasireddy, Vivek" X-Patchwork-Id: 1888720 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=STi+O1SA; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TGygq1HVDz1yWl for ; Sat, 20 Jan 2024 11:55:03 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rQzbf-0001sn-Av; Fri, 19 Jan 2024 19:53:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rQzbd-0001ri-32 for qemu-devel@nongnu.org; Fri, 19 Jan 2024 19:53:05 -0500 Received: from mgamail.intel.com ([192.55.52.120]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rQzba-0000Hu-NP for qemu-devel@nongnu.org; Fri, 19 Jan 2024 19:53:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705711982; x=1737247982; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kCCgPG2+hBw8fqMp3Qo56Mmdj33nLHntNW1mtEsJTKU=; b=STi+O1SAemSybpxBkFcljss2C19vUusAMrhrY4zQBBQMduge/Y5XOwRf rkbyKmOOffDY08sfME7HVY3btus/dMGtWVkm6zWJff8U+eTBKTu9TdIRJ cp4IRxVLzz8WRiuvJM8jssxvppa2B83rabvpix6zpVlG6wh2duEFtIivf sVOmyfMup4BiLiijF+324PjDdJJ1pUrrXcwab+AVsyANuTvNGG+KQtc+2 3hUbD719RwHmUx0KMMNtGJnCKSqbL6yCdRK+3j1rDtFoYDX5sGsjyB9uv 5rhLJDNDGFGgWS2WsK8EFRO9/5tNc1Rn3eYgW1/DQhCe2NftFXPsAl6SX Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10957"; a="399763758" X-IronPort-AV: E=Sophos;i="6.05,206,1701158400"; d="scan'208";a="399763758" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jan 2024 16:52:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10957"; a="904297442" X-IronPort-AV: E=Sophos;i="6.05,206,1701158400"; d="scan'208";a="904297442" Received: from vkasired-desk2.fm.intel.com ([10.105.128.132]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jan 2024 16:52:52 -0800 From: Vivek Kasireddy To: qemu-devel@nongnu.org Cc: Vivek Kasireddy , Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Frediano Ziglio , Dongwon Kim Subject: [PATCH v1 3/7] ui/spice: Submit the gl_draw requests at 60 FPS for remote clients Date: Fri, 19 Jan 2024 16:30:09 -0800 Message-Id: <20240120003013.1829757-4-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240120003013.1829757-1-vivek.kasireddy@intel.com> References: <20240120003013.1829757-1-vivek.kasireddy@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=192.55.52.120; envelope-from=vivek.kasireddy@intel.com; helo=mgamail.intel.com X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.519, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org In the specific case where the display layer (virtio-gpu) is using dmabuf, and if remote clients are enabled (-spice gl=on,port=xxxx), 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é Lureau Cc: Frediano Ziglio Cc: Dongwon Kim Signed-off-by: Vivek Kasireddy --- ui/spice-display.c | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/ui/spice-display.c b/ui/spice-display.c index 384b8508d4..90c04623ec 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -841,12 +841,31 @@ static void qemu_spice_gl_block_timer(void *opaque) warn_report("spice: no gl-draw-done within one second"); } +static void spice_gl_draw(SimpleSpiceDisplay *ssd, + uint32_t x, uint32_t y, uint32_t w, uint32_t h) +{ + uint64_t cookie; + + cookie = (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 = container_of(dcl, SimpleSpiceDisplay, dcl); - uint64_t cookie; + QemuDmaBuf *dmabuf = ssd->guest_dmabuf; - 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 && dmabuf) { + spice_gl_draw(ssd, 0, 0, dmabuf->width, dmabuf->height); + ssd->gl_updates = 0; + /* To stream at 60 FPS, the (GUI) timer delay needs to be ~17 ms */ + dcl->update_interval = 1000 / (2 * GUI_REFRESH_INTERVAL_DEFAULT) + 1; + } return; } @@ -854,11 +873,8 @@ static void spice_gl_refresh(DisplayChangeListener *dcl) if (ssd->gl_updates && ssd->have_surface) { qemu_spice_gl_block(ssd, true); glFlush(); - cookie = (uintptr_t)qxl_cookie_new(QXL_COOKIE_TYPE_GL_DRAW_DONE, 0); - spice_qxl_gl_draw_async(&ssd->qxl, 0, 0, - surface_width(ssd->ds), - surface_height(ssd->ds), - cookie); + spice_gl_draw(ssd, 0, 0, + surface_width(ssd->ds), surface_height(ssd->ds)); ssd->gl_updates = 0; } } @@ -1025,7 +1041,6 @@ static void qemu_spice_gl_update(DisplayChangeListener *dcl, EGLint stride = 0, fourcc = 0; bool render_cursor = false; bool y_0_top = false; /* FIXME */ - uint64_t cookie; int fd; if (!ssd->have_scanout) { @@ -1098,8 +1113,11 @@ static void qemu_spice_gl_update(DisplayChangeListener *dcl, trace_qemu_spice_gl_update(ssd->qxl.id, w, h, x, y); qemu_spice_gl_block(ssd, true); glFlush(); - cookie = (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); + } } static const DisplayChangeListenerOps display_listener_gl_ops = { From patchwork Sat Jan 20 00:30:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Kasireddy, Vivek" X-Patchwork-Id: 1888717 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=dyGbyXxf; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TGyfb2Qkfz1yWl for ; Sat, 20 Jan 2024 11:53:59 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rQzbe-0001rr-4z; Fri, 19 Jan 2024 19:53:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rQzbb-0001rB-PE for qemu-devel@nongnu.org; Fri, 19 Jan 2024 19:53:03 -0500 Received: from mgamail.intel.com ([192.55.52.120]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rQzba-0000HA-1R for qemu-devel@nongnu.org; Fri, 19 Jan 2024 19:53:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705711982; x=1737247982; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=w6zsMuKR5+dos2BSIN9Npc/spxx3lltKpXTlvh/rSkg=; b=dyGbyXxfsN3GGJdRD7svG8LKuvZOXpeb1P7MEOfmyGzncU4LZjbrfJ+c eVvpDE2OxFkEmBGqkl5w1nup4eGlSR+5fjFpDyGLO6SFXZ9/AUuHLpXB8 mjqlopVcq0iIgoXpMJeeaXm73y5aX/+g6JC3+Dq+Tlx45N2LFvQ0F/dba mNp9TMSBBcCSIsEguRptoFuwldJW/evXb1C1H6vVhvyB8JHOMLgNNiE9r AOV5gVLJndu/SRuHe3yDvwOmYHl28dzjxxEmcjht50p7zEHKYVbQaWglY nq4Oo+Mx8A77icWz1O3rS5szbY59QBNNHJes/3M/IfZvPrQCOSX6EMUEJ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10957"; a="399763762" X-IronPort-AV: E=Sophos;i="6.05,206,1701158400"; d="scan'208";a="399763762" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jan 2024 16:52:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10957"; a="904297445" X-IronPort-AV: E=Sophos;i="6.05,206,1701158400"; d="scan'208";a="904297445" Received: from vkasired-desk2.fm.intel.com ([10.105.128.132]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jan 2024 16:52:52 -0800 From: Vivek Kasireddy To: qemu-devel@nongnu.org Cc: Vivek Kasireddy , Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Frediano Ziglio , Dongwon Kim Subject: [PATCH v1 4/7] ui/console-gl: Add an option to override a surface's glformat Date: Fri, 19 Jan 2024 16:30:10 -0800 Message-Id: <20240120003013.1829757-5-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240120003013.1829757-1-vivek.kasireddy@intel.com> References: <20240120003013.1829757-1-vivek.kasireddy@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=192.55.52.120; envelope-from=vivek.kasireddy@intel.com; helo=mgamail.intel.com X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.519, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org In some cases where a UI component (e.g, Spice) needs to choose a particular glformat for a surface while creating a texture, this new GLenum provides an option to do so. One situation where this needs to be done is when the Host endianness is causing issues such as interchanged R and B channels. Cc: Gerd Hoffmann Cc: Marc-André Lureau Cc: Frediano Ziglio Cc: Dongwon Kim Signed-off-by: Vivek Kasireddy --- include/ui/surface.h | 1 + ui/console-gl.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/include/ui/surface.h b/include/ui/surface.h index 4244e0ca4a..a39fee55a2 100644 --- a/include/ui/surface.h +++ b/include/ui/surface.h @@ -20,6 +20,7 @@ typedef struct DisplaySurface { uint8_t flags; #ifdef CONFIG_OPENGL GLenum glformat; + GLenum target_glformat; GLenum gltype; GLuint texture; #endif diff --git a/ui/console-gl.c b/ui/console-gl.c index 103b954017..dee317f42c 100644 --- a/ui/console-gl.c +++ b/ui/console-gl.c @@ -72,6 +72,12 @@ void surface_gl_create_texture(QemuGLShader *gls, g_assert_not_reached(); } + /* The caller wants to override the glformat in some specific cases */ + if (surface->target_glformat && + surface->target_glformat != surface->glformat) { + surface->glformat = surface->target_glformat; + } + glGenTextures(1, &surface->texture); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, surface->texture); From patchwork Sat Jan 20 00:30:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Kasireddy, Vivek" X-Patchwork-Id: 1888719 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Pv4BhBEC; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TGygg35Xlz1yWl for ; Sat, 20 Jan 2024 11:54:55 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rQzbf-0001t8-Vf; Fri, 19 Jan 2024 19:53:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rQzbd-0001ru-ST for qemu-devel@nongnu.org; Fri, 19 Jan 2024 19:53:05 -0500 Received: from mgamail.intel.com ([192.55.52.120]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rQzbc-0000HV-17 for qemu-devel@nongnu.org; Fri, 19 Jan 2024 19:53:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705711984; x=1737247984; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0l+PsH2fLrrdH4iP9164gk31Qk9B4U0bQLvvhVpe58M=; b=Pv4BhBECiqxDv/7v/JMTL460RkbcL1cG7HheGgYZU1UFSuiR3i2vcW30 r1ao8vHTOtVqy4orCJ1f+v2Id4urqKiV+++C8xDAaGwui0mKZPGx/Koxy hYtZfHhA/P9m4D4p46Xbqxo23w+PIDlNgddQtjNArTG52bNaqDoTG47DG +YdArDKtyrM8nQxC1kfMS67K9XrEldQQqgApdfRXg7w+zWGVCjr41rIMI wRg1Dz35dup36o7BhJnr/969KiO0GrQk5vdgMIGOW9NaDt2nl1Se1Ss6x c6wFOERL8Jhr7UlKYVqeO6ZEHlVK/Upe7klbShik9ipeSwOzJzxCowtTJ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10957"; a="399763765" X-IronPort-AV: E=Sophos;i="6.05,206,1701158400"; d="scan'208";a="399763765" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jan 2024 16:52:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10957"; a="904297449" X-IronPort-AV: E=Sophos;i="6.05,206,1701158400"; d="scan'208";a="904297449" Received: from vkasired-desk2.fm.intel.com ([10.105.128.132]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jan 2024 16:52:52 -0800 From: Vivek Kasireddy To: qemu-devel@nongnu.org Cc: Vivek Kasireddy , Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Frediano Ziglio , Dongwon Kim Subject: [PATCH v1 5/7] ui/spice: Override the surface's glformat when gl=on is enabled Date: Fri, 19 Jan 2024 16:30:11 -0800 Message-Id: <20240120003013.1829757-6-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240120003013.1829757-1-vivek.kasireddy@intel.com> References: <20240120003013.1829757-1-vivek.kasireddy@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=192.55.52.120; envelope-from=vivek.kasireddy@intel.com; helo=mgamail.intel.com X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.519, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org When testing with gl=on on an Intel Host, it was noticed that the R and B channels were interchanged while the Guest FB image was displayed. This was only seen if the display layer (virtio-gpu) did not directly share the dmabuf fd with Spice (i.e, blob=false). One of the main differences in the case where blob=true vs blob=false is that we create the dmabuf fd from a texture in the latter case whereas we directly pass the fd from the display layer to Spice in the former case. Although, the surface's format (PIXMAN_BE_b8g8r8x8) is the same in both cases, the creation of the texture (which involves copying data from Pixman image into a GPU buffer) appears to somehow result in having the R and B channels interchanged. One way to ensure correct behavior is we have glformat=GL_RGBA while creating the texture. It looks like having glformat=GL_RGBA and gltype = GL_UNSIGNED_BYTE should work regardless of the Host's endianness but let us limit this change only to this specific use-case for now. Cc: Gerd Hoffmann Cc: Marc-André Lureau Cc: Frediano Ziglio Cc: Dongwon Kim Signed-off-by: Vivek Kasireddy --- ui/spice-display.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ui/spice-display.c b/ui/spice-display.c index 90c04623ec..08b4aec921 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -900,6 +900,9 @@ static void spice_gl_switch(DisplayChangeListener *dcl, } ssd->ds = new_surface; if (ssd->ds) { + if (remote_client && surface_format(ssd->ds) != PIXMAN_r5g6b5) { + ssd->ds->target_glformat = GL_RGBA; + } surface_gl_create_texture(ssd->gls, ssd->ds); fd = egl_get_fd_for_texture(ssd->ds->texture, &stride, &fourcc, From patchwork Sat Jan 20 00:30:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Kasireddy, Vivek" X-Patchwork-Id: 1888715 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=IM0a9SzR; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TGyfJ1RTQz23fK for ; Sat, 20 Jan 2024 11:53:42 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rQzbk-0001u2-WC; Fri, 19 Jan 2024 19:53:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rQzbd-0001rs-SC for qemu-devel@nongnu.org; Fri, 19 Jan 2024 19:53:05 -0500 Received: from mgamail.intel.com ([192.55.52.120]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rQzbc-0000HA-2Z for qemu-devel@nongnu.org; Fri, 19 Jan 2024 19:53:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705711984; x=1737247984; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aH1svmPvRSrhxRPRQhEiXVSt38d9wIOqogeHz9Ctq7s=; b=IM0a9SzRIoctuLI/m83TXFIz1HKsVTq+v/JX92Xj4LJ9YUp8FwX59poi XN2+G6NjjqGBgv4/0zQGZPNbHP/ZCu3kfOo4S8OGqu4q2YQZwTT/JWKA0 mwEJ53DUi8l4j2+XIkI7f7ljnPMgj2K1nwehEau9dJwQyHNuZ4Kom4+tK 4LC94ajKUVPAcmNup0cI5JpoIWt1pvRlLK2d6kif7AZH0GelzhYWHk1Wo YuxD4XEYiLyNs81SyqrS6rwbkrNG8RfGbBANB26AGWhU5I2j+e315W/LL hzxBA2iCt9U/FGtaQuhX9yU9AHsBBYIEdCDrPJalhS7aYmmJQo+9gA8hV Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10957"; a="399763768" X-IronPort-AV: E=Sophos;i="6.05,206,1701158400"; d="scan'208";a="399763768" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jan 2024 16:52:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10957"; a="904297451" X-IronPort-AV: E=Sophos;i="6.05,206,1701158400"; d="scan'208";a="904297451" Received: from vkasired-desk2.fm.intel.com ([10.105.128.132]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jan 2024 16:52:52 -0800 From: Vivek Kasireddy To: qemu-devel@nongnu.org Cc: Vivek Kasireddy , Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Frediano Ziglio , Dongwon Kim Subject: [PATCH v1 6/7] ui/console-gl: Add a helper to create a texture with linear memory layout Date: Fri, 19 Jan 2024 16:30:12 -0800 Message-Id: <20240120003013.1829757-7-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240120003013.1829757-1-vivek.kasireddy@intel.com> References: <20240120003013.1829757-1-vivek.kasireddy@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=192.55.52.120; envelope-from=vivek.kasireddy@intel.com; helo=mgamail.intel.com X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.519, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org There are cases where we do not want the memory layout of a texture to be tiled as the component processing the texture memory 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. Note that, requesting GL implementation to create a texture with linear memory layout can only be done using memory objects. And, a memory object can be created by importing a dmabuf fd. Cc: Gerd Hoffmann Cc: Marc-André Lureau 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 a4a49ffc64..e53e3ce03e 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -444,6 +444,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 dee317f42c..2c1b2ae377 100644 --- a/ui/console-gl.c +++ b/ui/console-gl.c @@ -102,6 +102,32 @@ void surface_gl_create_texture(QemuGLShader *gls, glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); } +void surface_gl_create_texture_from_fd(DisplaySurface *surface, + int fd, GLuint *texture) +{ + unsigned long size = surface_stride(surface) * surface_height(surface); + 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) From patchwork Sat Jan 20 00:30:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Kasireddy, Vivek" X-Patchwork-Id: 1888716 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=YFE+8avg; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TGyfP1V47z1yWl for ; Sat, 20 Jan 2024 11:53:49 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rQzbl-0001u3-RL; Fri, 19 Jan 2024 19:53:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rQzbf-0001sX-5P for qemu-devel@nongnu.org; Fri, 19 Jan 2024 19:53:07 -0500 Received: from mgamail.intel.com ([192.55.52.120]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rQzbd-0000Hu-Dc for qemu-devel@nongnu.org; Fri, 19 Jan 2024 19:53:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705711985; x=1737247985; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MJ8rtDIcQk012Iggqg+BBERZJYsckiVBOTAXB2wUZy0=; b=YFE+8avgDCMHfXAzI2m3CQFRnxp2CTdbFNGR5UV+FnImn1iMBFxOLFYx kTXhA6Y1OxtaJuHAHuxA2nM0Gw64ebmLzfJHvFQR/tEc+XUaBNBApmyJ6 7ZrxS1pjEGXTqjdO85vSXJiViFLvasBv5LUGdbZavuojof/meCy/eVXIX ZpG3pVXiGYzbcV5iuKwpnaprVvAzWy9aOAFt7Gw9wsND9jKCDKNjkiVPt GoOEO5UBhwKh7riEmbDuQwTGXaiD3B2i36pyYaZx1Qfb1VHzi2Rocpsp8 berQaktZKloEzjg+2Gfzzrg+3f/3feixuF/Bqcyl6BSjlgaG5UQEQWMJm g==; X-IronPort-AV: E=McAfee;i="6600,9927,10957"; a="399763771" X-IronPort-AV: E=Sophos;i="6.05,206,1701158400"; d="scan'208";a="399763771" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jan 2024 16:52:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10957"; a="904297454" X-IronPort-AV: E=Sophos;i="6.05,206,1701158400"; d="scan'208";a="904297454" Received: from vkasired-desk2.fm.intel.com ([10.105.128.132]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jan 2024 16:52:52 -0800 From: Vivek Kasireddy To: qemu-devel@nongnu.org Cc: Vivek Kasireddy , Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Frediano Ziglio , Dongwon Kim Subject: [PATCH v1 7/7] ui/spice: Create another texture with linear layout when gl=on is enabled Date: Fri, 19 Jan 2024 16:30:13 -0800 Message-Id: <20240120003013.1829757-8-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240120003013.1829757-1-vivek.kasireddy@intel.com> References: <20240120003013.1829757-1-vivek.kasireddy@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=192.55.52.120; envelope-from=vivek.kasireddy@intel.com; helo=mgamail.intel.com X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.519, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Since most encoders (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 first need to create a tiled texture and obtain a dmabuf fd associated with it via EGL. Next, we have to create a memory object by importing the dmabuf fd created earlier and finally create a linear texture by using the memory object as the texture storage mechanism. Cc: Gerd Hoffmann Cc: Marc-André Lureau Cc: Frediano Ziglio Cc: Dongwon Kim Signed-off-by: Vivek Kasireddy --- ui/spice-display.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/ui/spice-display.c b/ui/spice-display.c index 08b4aec921..94cb378dbe 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -893,6 +893,7 @@ static void spice_gl_switch(DisplayChangeListener *dcl, { SimpleSpiceDisplay *ssd = container_of(dcl, SimpleSpiceDisplay, dcl); EGLint stride, fourcc; + GLuint texture = 0; int fd; if (ssd->ds) { @@ -912,6 +913,38 @@ static void spice_gl_switch(DisplayChangeListener *dcl, return; } + if (remote_client && surface_format(ssd->ds) != PIXMAN_r5g6b5) { + /* + * 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 = egl_get_fd_for_texture(texture, + &stride, &fourcc, + NULL); + if (fd < 0) { + glDeleteTextures(1, &texture); + fd = egl_get_fd_for_texture(ssd->ds->texture, + &stride, &fourcc, + NULL); + if (fd < 0) { + surface_gl_destroy_texture(ssd->gls, ssd->ds); + return; + } + } else { + surface_gl_destroy_texture(ssd->gls, ssd->ds); + ssd->ds->texture = texture; + } + } + } + trace_qemu_spice_gl_surface(ssd->qxl.id, surface_width(ssd->ds), surface_height(ssd->ds),