From nobody Fri Dec 19 16:06:31 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=1747277451; cv=none; d=zohomail.com; s=zohoarc; b=DbwcXgQh2zvZbBKmzUAWo255rSG8P7b/Jm/oxjcgF2E7xFbxjh7kN8HGorR8xDCq0fZwhMUCJz1ZKj9TCk/BJyxJmML4S/08/ws/xTgsyxX078qlC5lwka4E4a93a9OfIAQsEGI+65jm4BejGpRCK4aD4yYtgr55wAur3aYVx9A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747277451; 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=0On/zEI9fQXygOZwRAGOZu1t2ycYC2qAjcCqVDL1XqQ=; b=gPW5vWRtotQMGNsKcgFqF4xwJJkRMKB9t3ekAFcqSVMmacqllWalONxvOxXeY+cM36lfJWom7rQkb8tUNeTp+IRY2OIveKibWEEZUu5v2LM7ZhOwd5ilDFNxMX4dtwfALuo4sKHe1GRo4b4Mkiih+NisE/DWnj/+nWHlUzrpRuU= 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 1747277451030292.41039468356587; Wed, 14 May 2025 19:50:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFOf9-0006lX-9b; Wed, 14 May 2025 22:49:35 -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 1uFOf6-0006kV-P6 for qemu-devel@nongnu.org; Wed, 14 May 2025 22:49:32 -0400 Received: from mgamail.intel.com ([192.198.163.16]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFOf5-0005hp-0Y for qemu-devel@nongnu.org; Wed, 14 May 2025 22:49:32 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2025 19:49:19 -0700 Received: from vkasired-desk2.fm.intel.com ([10.105.128.132]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2025 19:49:19 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1747277371; x=1778813371; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NymX+OvNvqfitAD9MeVg+2BvNLTTzBo4mgjZyaMzdaU=; b=DWiAG5ly/OS7Hdb7WQSTJeXrp+AyJ6PUaGlNbDzvWiYW53s3mZik5deP wS1HWvKVrpQSaxTOid7GM21jMLs8B7mYPeOYITWIWlrJGu7xWMKXBmawz 3JMnpIhPJVSQoNmkGXM/dn9pLAV5+s3Q2J6TwvaxNZBuQYMjqv3vdX4dc T1ZFEXiooKXdGdTVxNOxzSLyES6EWJ34m7aNljS8bAGRMeYw6riTSHd0e 7tQjSX+UkkX87zcrOjAFMk+m8A9tQgOWyLuX+elYlGNNZITMMSGok8D76 bIFJERQeU21CF5zAl150h2r8RGX0jYCsWrc6UIbFlPdikPaVvradDqfVC g==; X-CSE-ConnectionGUID: P+XQwSbaQTG+9IM+DM+grQ== X-CSE-MsgGUID: kJfLo1IHQnm8uZFptWbnEg== X-IronPort-AV: E=McAfee;i="6700,10204,11433"; a="36819293" X-IronPort-AV: E=Sophos;i="6.15,289,1739865600"; d="scan'208";a="36819293" X-CSE-ConnectionGUID: aVYoyly7QK+aLVBry5qhbQ== X-CSE-MsgGUID: 7Py3bt8WRLKNe0z/4vtLWg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,289,1739865600"; d="scan'208";a="142246645" 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 v4 1/7] ui/egl-helpers: Error check the fds in egl_dmabuf_export_texture() Date: Wed, 14 May 2025 19:45:39 -0700 Message-ID: <20250515024734.758335-2-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250515024734.758335-1-vivek.kasireddy@intel.com> References: <20250515024734.758335-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.16; envelope-from=vivek.kasireddy@intel.com; helo=mgamail.intel.com X-Spam_score_int: -60 X-Spam_score: -6.1 X-Spam_bar: ------ X-Spam_report: (-6.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.686, 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: 1747277451839116600 While trying to export and obtain fds associated with a texture, it is possible that the fds returned after eglExportDMABUFImageMESA() call are -1. Therefore, we need to evaluate the value of all fds and return false if any of them are -1. Cc: Gerd Hoffmann Cc: Marc-Andr=C3=A9 Lureau Cc: Dmitry Osipenko Cc: Frediano Ziglio Cc: Dongwon Kim Signed-off-by: Vivek Kasireddy --- ui/egl-helpers.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c index 9cda2bbbee..07d8edd3dc 100644 --- a/ui/egl-helpers.c +++ b/ui/egl-helpers.c @@ -289,6 +289,7 @@ bool egl_dmabuf_export_texture(uint32_t tex_id, int *fd= , EGLint *offset, { EGLImageKHR image; EGLuint64KHR modifiers[DMABUF_MAX_PLANES]; + int i; =20 image =3D eglCreateImageKHR(qemu_egl_display, eglGetCurrentContext(), EGL_GL_TEXTURE_2D_KHR, @@ -308,6 +309,11 @@ bool egl_dmabuf_export_texture(uint32_t tex_id, int *f= d, EGLint *offset, *modifier =3D modifiers[0]; } =20 + for (i =3D 0; i < *num_planes; i++) { + if (fd[i] < 0) { + return false; + } + } return true; } =20 --=20 2.49.0 From nobody Fri Dec 19 16:06:31 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=1747277450; cv=none; d=zohomail.com; s=zohoarc; b=YErGN8Q4no1CJoOXfBzbIgiV9WAsMUbM2HYOv2eBDBy4GyGAIY8mkEYWQvFUiVYhTmvcBA8X1nhWR4xoUbiOCCGv/jmQE5YhPZ39J9d10TKMZVZY+k+h5+SfLXpEU8DAGu0pEjWCBqt2Jc2s/Xb9j16yPGDDyd40RWE3WH+e7uw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747277450; 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=N/wkC9af96fCzOPOc8WGq57VEKqBIsVQhbsd30cz910=; b=b9GHekPaecNME82M6XNELr5jeJO1bTGgiC5Y8YwqL7oxyl/YyY9Rg+5uEGnp+AytN2q662Dlxg0CvEErQumyFLdjss6TDc5NveWDZQki8qqTm2/YWxkIio4NGondBRwGqQyPelLCp2G9E7CeHAjR7Lbo6rLfRe1MPrycooTD4Ug= 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 1747277450375197.0601567332161; Wed, 14 May 2025 19:50:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFOf6-0006k7-2e; Wed, 14 May 2025 22:49:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFOf4-0006i3-LF for qemu-devel@nongnu.org; Wed, 14 May 2025 22:49:30 -0400 Received: from mgamail.intel.com ([192.198.163.16]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFOf2-0005hp-O4 for qemu-devel@nongnu.org; Wed, 14 May 2025 22:49:30 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2025 19:49:19 -0700 Received: from vkasired-desk2.fm.intel.com ([10.105.128.132]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2025 19:49:19 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1747277369; x=1778813369; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KKt9VbiO6D4vGHHdtSdCWLYNyMy3i/lYilY4X9dAV9Q=; b=CmPRS0b992IMBIzbRemQ1Npio0chkKlIAYtRGGLzg3Mzr/pl/sGvn+Bb u7L1ymk7pUPTqRP9f4pCh0LRDwHI83QODZYosOZkDy6FJ210Z2ClFZMwx NG/frgzK2TRpBqSOv1u+3NaQO6B07heMbSmjqfuiY6qW9AeRDr9f/qq8W OykXkWu/oYbk7wlUt4ocdO6qTclR9nLm6lY30ZbGaPGwYR1vCW/q8Q0bt taRBRFCHVGpAP6lwb85v+7tNjtEa7f5RQpgOl/S9l4UH1sCiOV4yVGMDC gQdeRT7Z31/gWm67I0WGayIBJjRKIC0EUOrJTgLPfKGE7vl/fpJ0sKqTt g==; X-CSE-ConnectionGUID: KnFZ7D1WSHS72OekrA/0JA== X-CSE-MsgGUID: sujwXiDwSdO0a1gH7XNBeA== X-IronPort-AV: E=McAfee;i="6700,10204,11433"; a="36819297" X-IronPort-AV: E=Sophos;i="6.15,289,1739865600"; d="scan'208";a="36819297" X-CSE-ConnectionGUID: HurVam2lSOi2EQJrnAEesw== X-CSE-MsgGUID: bbkPlyHySre6CLjpjmcEvA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,289,1739865600"; d="scan'208";a="142246648" 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 v4 2/7] ui/spice: Add an option for users to provide a preferred codec Date: Wed, 14 May 2025 19:45:40 -0700 Message-ID: <20250515024734.758335-3-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250515024734.758335-1-vivek.kasireddy@intel.com> References: <20250515024734.758335-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.16; envelope-from=vivek.kasireddy@intel.com; helo=mgamail.intel.com X-Spam_score_int: -60 X-Spam_score: -6.1 X-Spam_bar: ------ X-Spam_report: (-6.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.686, 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: 1747277451564019000 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 aab53bcfe8..97c63d9b31 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 Fri Dec 19 16:06:31 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=1747277451; cv=none; d=zohomail.com; s=zohoarc; b=SOObDqDfkQmekJOIJPIiUOSH93/A3H3Bqcvw1d0ecau6oRB7F/ZCXY3KjezTnfJcazQhOXLCEkEsyKrxmgA3ubecA+sfxvh1tMpRDteQUlySDcCTlCYhNvCK79kl6GPWHKX0Q94Lx+4Y77KVkMAUPak85jj4y7Nst/k54IilGW4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747277451; 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=DwDh5vCv9gb3awJboj5yYP3nwGAl5tA1nmTxUnhgiFo=; b=PawzAHIItjYOUlMokONASw7DSS913+P5QqwMHW4zsRSr8wR1+2OSQ+DmBPUCaXkZU7Xwuw7Og0mkBlFkb2djPKp7pU1TN4pVIKfSMu7Kr55CPc2WSJM+UT+H0BOZhY/wkCAJX9sY7O/+xbk6jU8zT2hVH52ob29k03Fm4Tqolns= 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 1747277451313628.9846004449653; Wed, 14 May 2025 19:50:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFOf5-0006io-Bz; Wed, 14 May 2025 22:49:31 -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 1uFOf2-0006Z3-9V for qemu-devel@nongnu.org; Wed, 14 May 2025 22:49:28 -0400 Received: from mgamail.intel.com ([192.198.163.16]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFOf0-0005hp-I0 for qemu-devel@nongnu.org; Wed, 14 May 2025 22:49:28 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2025 19:49:19 -0700 Received: from vkasired-desk2.fm.intel.com ([10.105.128.132]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2025 19:49:19 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1747277366; x=1778813366; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iJKqygNxurlqQkKd26/VkSuPTwdrNmwQkHQcW/WPHpQ=; b=Y3N8NLhSPM7SMNylcrn1G58fT2Ua7LtbyQh+dCURWwa+EKIMWPyOU5C0 Lw47Ab+zCMgvL4jg1wfiUXFkmqptaoGU3pyOrznmKfR8atIzdxXP1n4SU /wtb2AXH0s6ooCp2qWBCR709ItWUBIrLNA0LnXHDKzmcGN1uei3zHA6xA UA7JmGrp/81rs8aNZmpfLOfSCDW0t6CPuGyJEpzb3zzkSzFWrSFqI+EAN mrVgiJ2jw7FcBxLGAQWIaRu8BVVB1M/7EftWsc3TxFN8/UOYaN8BKLajV 2VDOlw9j6GNe4WZdO9GGA0OqOjBcF2uf+3NHSj9HVtbJCffLY9Yh7l+Ft w==; X-CSE-ConnectionGUID: s6BCVNXQR2qVtALzCE9e0w== X-CSE-MsgGUID: H9U0kRBbRN6qrhkNep/MEA== X-IronPort-AV: E=McAfee;i="6700,10204,11433"; a="36819301" X-IronPort-AV: E=Sophos;i="6.15,289,1739865600"; d="scan'208";a="36819301" X-CSE-ConnectionGUID: 72h0258bRS6gQKhKqBUVIQ== X-CSE-MsgGUID: MyxSDypIRYW29a3qtoming== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,289,1739865600"; d="scan'208";a="142246651" 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 v4 3/7] ui/spice: Enable gl=on option for non-local or remote clients Date: Wed, 14 May 2025 19:45:41 -0700 Message-ID: <20250515024734.758335-4-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250515024734.758335-1-vivek.kasireddy@intel.com> References: <20250515024734.758335-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.16; envelope-from=vivek.kasireddy@intel.com; helo=mgamail.intel.com X-Spam_score_int: -60 X-Spam_score: -6.1 X-Spam_bar: ------ X-Spam_report: (-6.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.686, 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: 1747277451857116600 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 9c39d2c5c8..9140169015 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -31,6 +31,7 @@ #include "standard-headers/drm/drm_fourcc.h" =20 bool spice_opengl; +bool remote_client; =20 int qemu_spice_rect_is_empty(const QXLRect* r) { --=20 2.49.0 From nobody Fri Dec 19 16:06:31 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=1747277456; cv=none; d=zohomail.com; s=zohoarc; b=JiV2fNv7fGvMkt+kC6sJhVZbY9+RqTp/ChddFidkTY147z7zRBPT4nWXnR/oYykgy2PJJUvKw7ooSLCaDWjL7p8MQAUswcJMq3h+eX/cPUchLdTnMc0Lgt9gc0SK7VampUAe8kSwtYJQoIhJcve8WmOeZcbhkPJeC9xjcXZ++S8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747277456; 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=+bqMuDwvKljnhNAJBjUVxdmQUfNUhI0uPVnUEaXjO9o=; b=jdyGOWgXXqW5EcHCWMu5eO2zRU1Sf4u3uU7FjC3wcGuBX+5UZfJmglVCo7grKv6IJ1ynx1Geqn0uPQL+29GoN61x+6qKrDDkhjJgp/iJkftyzIv8N5feTatxSTbDPhaJ0asD3/StqfVqYE4FuJQ/pgvzm4jTNQwAgvtcJ7Y614s= 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 1747277456651156.86084234045268; Wed, 14 May 2025 19:50:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFOf5-0006jT-Bk; Wed, 14 May 2025 22:49:31 -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 1uFOf3-0006c6-9I for qemu-devel@nongnu.org; Wed, 14 May 2025 22:49:29 -0400 Received: from mgamail.intel.com ([192.198.163.16]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFOf1-0005i5-88 for qemu-devel@nongnu.org; Wed, 14 May 2025 22:49:29 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2025 19:49:19 -0700 Received: from vkasired-desk2.fm.intel.com ([10.105.128.132]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2025 19:49:19 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1747277367; x=1778813367; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jAHEAbHiFLq8MUhdgOcsKXsxkzqIG2Nd8xcTMQXTV5k=; b=VzaI019lMqwwdEG/XdLiwnr+78U25IkKOk4rEZ4FAFbtByjwCnLbYPCZ FoVXDbkKY/YCeLdxRRDcH3/AdNKHBEsFtUmQWqmNrpk8oV00vbusLctf5 bYk9kL+Udkh0yEsZvM5p1dVL/0vR4UszDCdn/Et1/XUpzZrzkoREj9Qa4 aVvgOMbcZMiwpWnMC7OOeP1Li2Of4VBCOQ0MSYgY/s9b/iDuVIJo16scA /hOiVBy2nqwh3ULc3oO5+UP4vQIdjueJCrj95EzBaJZpuNLinI3hkOaum UtYEXfrfHWynGJ32JAVmi0HHIS49VRZh7enluP9y//7mJeT94o3B7N49P g==; X-CSE-ConnectionGUID: qOkAl+w/SVmHmD57vnT9uA== X-CSE-MsgGUID: 7hH+PGM5To+0pOgp/z2n9w== X-IronPort-AV: E=McAfee;i="6700,10204,11433"; a="36819305" X-IronPort-AV: E=Sophos;i="6.15,289,1739865600"; d="scan'208";a="36819305" X-CSE-ConnectionGUID: BepeKjNgQCqhVeNNULp++A== X-CSE-MsgGUID: uRm7qeGnQJGojuLfQAD4NQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,289,1739865600"; d="scan'208";a="142246654" 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 v4 4/7] ui/spice: Add an option to submit gl_draw requests at fixed rate Date: Wed, 14 May 2025 19:45:42 -0700 Message-ID: <20250515024734.758335-5-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250515024734.758335-1-vivek.kasireddy@intel.com> References: <20250515024734.758335-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.16; envelope-from=vivek.kasireddy@intel.com; helo=mgamail.intel.com X-Spam_score_int: -60 X-Spam_score: -6.1 X-Spam_bar: ------ X-Spam_report: (-6.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.686, 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: 1747277457645019000 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 (refresh rate) to a fixed value using the GUI refresh timer. Otherwise, the updates or gl_draw requests would be sent as soon as the Guest submits a new frame which is not optimal as it would lead to increased network traffic and wastage of GPU cycles if the frames get dropped. 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 + qemu-options.hx | 5 ++++ ui/spice-core.c | 11 ++++++++ ui/spice-display.c | 54 +++++++++++++++++++++++++++++++------- 4 files changed, 61 insertions(+), 10 deletions(-) diff --git a/include/ui/spice-display.h b/include/ui/spice-display.h index f4922dd74b..2fe524b59c 100644 --- a/include/ui/spice-display.h +++ b/include/ui/spice-display.h @@ -152,6 +152,7 @@ struct SimpleSpiceCursor { =20 extern bool spice_opengl; extern bool remote_client; +extern int max_refresh_rate; =20 int qemu_spice_rect_is_empty(const QXLRect* r); void qemu_spice_rect_union(QXLRect *dest, const QXLRect *r); diff --git a/qemu-options.hx b/qemu-options.hx index 97c63d9b31..4e9f4edfdc 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2282,6 +2282,7 @@ DEF("spice", HAS_ARG, QEMU_OPTION_spice, " [,disable-agent-file-xfer=3Don|off][,agent-mouse=3D[on|off]]\n" " [,playback-compression=3D[on|off]][,seamless-migration=3D[on|o= ff]]\n" " [,video-codecs=3D:\n" + " [,max-refresh-rate=3Drate\n" " [,gl=3D[on|off]][,rendernode=3D]\n" " enable spice\n" " at least one of {port, tls-port} is mandatory\n", @@ -2374,6 +2375,10 @@ SRST Provide the preferred codec the Spice server should use. Default would be spice:mjpeg. =20 + ``max-refresh-rate=3Drate`` + Provide the maximum refresh rate (or FPS) at which the encoding + requests should be sent to the Spice server. Default would be 30. + ``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 6c3bfe1d0f..d8925207b1 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -56,6 +56,8 @@ struct SpiceTimer { QEMUTimer *timer; }; =20 +#define MAX_REFRESH_RATE 30 + static SpiceTimer *timer_add(SpiceTimerFunc func, void *opaque) { SpiceTimer *timer; @@ -491,6 +493,9 @@ static QemuOptsList qemu_spice_opts =3D { },{ .name =3D "video-codecs", .type =3D QEMU_OPT_STRING, + },{ + .name =3D "max-refresh-rate", + .type =3D QEMU_OPT_NUMBER, },{ .name =3D "agent-mouse", .type =3D QEMU_OPT_BOOL, @@ -813,6 +818,12 @@ static void qemu_spice_init(void) } } =20 + max_refresh_rate =3D qemu_opt_get_number(opts, "max-refresh-rate", MAX= _REFRESH_RATE); + if (max_refresh_rate < 0) { + error_report("max refresh rate/fps is invalid"); + exit(1); + } + spice_server_set_agent_mouse (spice_server, qemu_opt_get_bool(opts, "agent-mouse", 1)); spice_server_set_playback_compression diff --git a/ui/spice-display.c b/ui/spice-display.c index 9140169015..ed91521ac2 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -32,6 +32,7 @@ =20 bool spice_opengl; bool remote_client; +int max_refresh_rate; =20 int qemu_spice_rect_is_empty(const QXLRect* r) { @@ -844,12 +845,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 update at 60 FPS, update_interval needs to be ~16.66 ms = */ + dcl->update_interval =3D 1000 / max_refresh_rate; + } return; } =20 @@ -857,11 +878,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; } } @@ -954,6 +972,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_server_gl_scanout(&ssd->qxl, NULL, 0, 0, NULL, NULL, 0, DRM_FORM= AT_INVALID, DRM_FORMAT_MOD_INVALID, false); qemu_spice_gl_monitor_config(ssd, 0, 0, 0, 0); @@ -1061,7 +1093,6 @@ static void qemu_spice_gl_update(DisplayChangeListene= r *dcl, EGLint fourcc =3D 0; bool render_cursor =3D false; bool y_0_top =3D false; /* FIXME */ - uint64_t cookie; uint32_t width, height, texture; =20 if (!ssd->have_scanout) { @@ -1159,8 +1190,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 Fri Dec 19 16:06:31 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=1747277450; cv=none; d=zohomail.com; s=zohoarc; b=RQ3GwkeB2Ibywu+cxZpkgBmUrkE1nMpuxf5c/IeG9PQ2vs94rh3vpwKhAimEbsET3ZMqJ8Ym0AgTpIuBKgRlDQeXawPZutccfTS/B2gaJdpSxSgshTDTKP45pjjv+cmOpBeW2E9ARMl/gOGK6zvxn1aVe5nwtRbgltab7rUieLc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747277450; 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=kqi89GXIIlAhJqe/gcg4+sJAqL70iIvHpFJQpVepTJI=; b=FmLk3xLPflJpW+JfJAPuw1n7NZDDwS7HgZxHtVF+iJFK4WsUYHTxLzxZaDAUtv68ZjXN4hSTfH0PWmnn4R5dqN+hoIDZd5phiJfKURsoGlZdDUX3fEpNQVV60iemgECLPh5w4MCJvmJSI9pHd3B/8Y1EkyCaPqC/E9pa8b23mZY= 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 17472774504730.45255222427749686; Wed, 14 May 2025 19:50:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFOf6-0006kX-Tc; Wed, 14 May 2025 22:49:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFOf5-0006jU-Bo for qemu-devel@nongnu.org; Wed, 14 May 2025 22:49:31 -0400 Received: from mgamail.intel.com ([192.198.163.16]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFOf3-0005iL-DS for qemu-devel@nongnu.org; Wed, 14 May 2025 22:49:31 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2025 19:49:19 -0700 Received: from vkasired-desk2.fm.intel.com ([10.105.128.132]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2025 19:49:19 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1747277369; x=1778813369; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=STthhcuiYFhtaPFn0z3oX1IbTphb/i1MPiWVLMqKqJI=; b=lvVbuurdjY/pj1QDTE0dsFNzC1s2u0ZsiHs19gHbMigJ6oGvg5tNvdt9 yiK8ugN4ugDVhepgafWGu8QqHsuMRjtpyU1iIl6zHA3vkugzz356pPrcS WRwutw/Zxk5xEglVHSMxvNvH4DnmeZ3/FyFoBuE8KSA0ub2wI1w62E83E kJJ5+fFHpvzCxWaTpIBIbyXIf87JsI9bKOi2se8h89E7vsmZIJl6FyW0i CVvsySJPQwhUY4dO17ZQcxedQFqeMtPwQKqYCkOqRCwOQ6io8JFIEuga4 Pm214+3Ujm3ThqMJVplaN1eMbS2ePzPBtV06SHkJYKQDBHpX/F2gaYFG8 Q==; X-CSE-ConnectionGUID: XD083olhSVu6ml71s8h6gw== X-CSE-MsgGUID: dwYHp72AQDy/GTrImhzA0Q== X-IronPort-AV: E=McAfee;i="6700,10204,11433"; a="36819309" X-IronPort-AV: E=Sophos;i="6.15,289,1739865600"; d="scan'208";a="36819309" X-CSE-ConnectionGUID: YImCxpjPTGKvLXh+wYKggw== X-CSE-MsgGUID: vCrJft5PR6S+vBrtvqknpg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,289,1739865600"; d="scan'208";a="142246658" 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 v4 5/7] ui/console-gl: Add a helper to create a texture with linear memory layout Date: Wed, 14 May 2025 19:45:43 -0700 Message-ID: <20250515024734.758335-6-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250515024734.758335-1-vivek.kasireddy@intel.com> References: <20250515024734.758335-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.16; envelope-from=vivek.kasireddy@intel.com; helo=mgamail.intel.com X-Spam_score_int: -60 X-Spam_score: -6.1 X-Spam_bar: ------ X-Spam_report: (-6.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.686, 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: 1747277451877116600 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 | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/include/ui/console.h b/include/ui/console.h index 46b3128185..5cfa6ae215 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); +bool 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..97f7989651 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,37 @@ void surface_gl_create_texture(QemuGLShader *gls, glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); } =20 +bool surface_gl_create_texture_from_fd(DisplaySurface *surface, + int fd, GLuint *texture) +{ + unsigned long size =3D surface_stride(surface) * surface_height(surfac= e); + GLenum err =3D glGetError(); + GLuint mem_obj; + + if (!epoxy_has_gl_extension("GL_EXT_memory_object") || + !epoxy_has_gl_extension("GL_EXT_memory_object_fd")) { + return false; + } + +#ifdef GL_EXT_memory_object_fd + glCreateMemoryObjectsEXT(1, &mem_obj); + glImportMemoryFdEXT(mem_obj, size, GL_HANDLE_TYPE_OPAQUE_FD_EXT, fd); + + err =3D glGetError(); + if (err !=3D GL_NO_ERROR) { + error_report("spice: cannot import memory object from fd"); + return false; + } + + 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 + return *texture > 0 && glGetError() =3D=3D GL_NO_ERROR; +} + void surface_gl_update_texture(QemuGLShader *gls, DisplaySurface *surface, int x, int y, int w, int h) --=20 2.49.0 From nobody Fri Dec 19 16:06:31 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=1747277451; cv=none; d=zohomail.com; s=zohoarc; b=Fgl/LRq34dIFm0cojnzSRIY7A0Hui+pDEms0V9HzY0OsWp25MBja/9rtK9GvncQiL6ecQ1+8lBNiIpmS2eafAV914yCg+VqP/TVE/i/ZuKJetu2jfpV3DG9G3ETUz34tFAJ+6mLV74M2zCV2lt+QCxB1KgXDmNaNLRIOd3lfcHs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747277451; 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=MY2bGNRvVhpBODXN2U3S5/yd9GKwG45f6VXLget3lHE=; b=eG15EEtnKuAse+peWZhuFmdpJjwzb1zc6Y+NDmjh+CGC8ibKd6ZT2H3WfDz1bQmdB/oLmg8PhjY1pygJrtbgZUtN0vb/kuOJUkV9sadp7M+vqjCVLU/4eYmERDYXjvw6YABe45mkAqB/5f/WBtvlhJvkzg4HzcXGOXzE3KEgsRU= 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 174727745165455.968392899703076; Wed, 14 May 2025 19:50:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFOfA-0006nY-NC; Wed, 14 May 2025 22:49: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 1uFOf6-0006kB-4G for qemu-devel@nongnu.org; Wed, 14 May 2025 22:49:32 -0400 Received: from mgamail.intel.com ([192.198.163.16]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFOf4-0005i5-2c for qemu-devel@nongnu.org; Wed, 14 May 2025 22:49:31 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2025 19:49:19 -0700 Received: from vkasired-desk2.fm.intel.com ([10.105.128.132]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2025 19:49:19 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1747277370; x=1778813370; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mvjg/ktKajg8f9d4j5dRKNxgmW9hH868BCrGCjM/hms=; b=bwuhKJH+Hi2Mj/KbzAuIdm2ByG3n/YQGLpRmPny29Mb1XzR7AHNCgnhT idj0X2uIcektpWctyQ0pXpYZlJ/uktGMKkvybgXKb0DwFzncYTBcCIq4h ilomTf3vPqU8YolaBxd72vzRk60km9pss2GZDd5pngQWiPlpnbZvfIJuK WluIwS1WAILNSh7kJ24HeYscOTq1sfmLQSFD+eLa3k6rzQhUVXhlN14v0 EfSaPXsfFfgSJlvtNT0oNCZ83MufYJtqrDwluOdfsf+LxcK612np2tls7 4o+nrbnn9rHY8L6xmCBz/1snf7RaTysnEWFq6hyXMPeQc02oQ+uakHcL+ Q==; X-CSE-ConnectionGUID: ppYI9U3ZTceC8faRqj59Dg== X-CSE-MsgGUID: yBDmQe5rSeyP707PGWIthA== X-IronPort-AV: E=McAfee;i="6700,10204,11433"; a="36819312" X-IronPort-AV: E=Sophos;i="6.15,289,1739865600"; d="scan'208";a="36819312" X-CSE-ConnectionGUID: hOEe7SKDQgupDhbR7E4/Lw== X-CSE-MsgGUID: Y5dbmWe/QJqkW4reyDzaxw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,289,1739865600"; d="scan'208";a="142246661" 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 v4 6/7] ui/spice: Create a new texture with linear layout when gl=on is enabled Date: Wed, 14 May 2025 19:45:44 -0700 Message-ID: <20250515024734.758335-7-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250515024734.758335-1-vivek.kasireddy@intel.com> References: <20250515024734.758335-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.16; envelope-from=vivek.kasireddy@intel.com; helo=mgamail.intel.com X-Spam_score_int: -60 X-Spam_score: -6.1 X-Spam_bar: ------ X-Spam_report: (-6.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.686, 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: 1747277453865116600 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 | 76 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/ui/spice-display.c b/ui/spice-display.c index ed91521ac2..fb56da4ab0 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -893,6 +893,75 @@ static void spice_gl_update(DisplayChangeListener *dcl, ssd->gl_updates++; } =20 +static bool spice_gl_replace_fd_texture(SimpleSpiceDisplay *ssd, + int *fds, uint64_t *modifier, + int *num_planes) +{ + uint32_t offsets[DMABUF_MAX_PLANES], strides[DMABUF_MAX_PLANES]; + GLuint texture =3D 0; + int fourcc; + bool ret; + + if (!remote_client) { + return true; + } + + if (*modifier =3D=3D DRM_FORMAT_MOD_LINEAR) { + return true; + } + + if (*num_planes > 1) { + error_report("spice: cannot replace texture with multiple planes"); + return false; + } + + /* + * We really want to ensure that the memory layout of the texture + * is linear; otherwise, the encoder's output may show corruption. + */ + if (!surface_gl_create_texture_from_fd(ssd->ds, fds[0], &texture)) { + error_report("spice: cannot create new texture from fd"); + return false; + } + + /* + * 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. + */ + ret =3D egl_dmabuf_export_texture(texture, + fds, + (EGLint *)offsets, + (EGLint *)strides, + &fourcc, + num_planes, + modifier); + if (!ret) { + glDeleteTextures(1, &texture); + + /* + * Since we couldn't export our newly create texture (or create, + * an fd associated with it) we need to backtrack and try to + * recreate the fd associated with the original texture. + */ + ret =3D egl_dmabuf_export_texture(ssd->ds->texture, + fds, + (EGLint *)offsets, + (EGLint *)strides, + &fourcc, + num_planes, + modifier); + if (!ret) { + surface_gl_destroy_texture(ssd->gls, ssd->ds); + warn_report("spice: no texture available to display"); + } + } else { + surface_gl_destroy_texture(ssd->gls, ssd->ds); + ssd->ds->texture =3D texture; + } + return ret; +} + static void spice_server_gl_scanout(QXLInstance *qxl, const int *fd, uint32_t width, uint32_t height, @@ -917,6 +986,7 @@ static void spice_gl_switch(DisplayChangeListener *dcl, struct DisplaySurface *new_surface) { SimpleSpiceDisplay *ssd =3D container_of(dcl, SimpleSpiceDisplay, dcl); + bool ret; =20 if (ssd->ds) { surface_gl_destroy_texture(ssd->gls, ssd->ds); @@ -939,6 +1009,12 @@ static void spice_gl_switch(DisplayChangeListener *dc= l, return; } =20 + ret =3D spice_gl_replace_fd_texture(ssd, fd, &modifier, &num_plane= s); + 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 Fri Dec 19 16:06:31 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=1747277471; cv=none; d=zohomail.com; s=zohoarc; b=Bl26IzgPZ1LzfqHx4dOaB8UHDDxScNcUiNSfKV+qDLDwgwASbSRWKcDAKIO+PFPActWtKCxJzQ3wS4VDj/1h7jgvY5tB/5Ugeit8PwzydVtqItuvKlQ6yk2uIw/sOOw1pTwj+CvZxNplnktZ5/J1HOj5Q+RqOOWazxtZFt1zKT4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747277471; 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=OKN4y02f4Jkr9qW1bWZINxl1aAzAHWQ2op1xCBlNG7w=; b=OnKWbRFcgkl6Oj4soB2bwA/ZkNChUpFDUUmctTyWhLciqycVJpvrT6JVxz8odf6YtzsUkIG/Pipu0ryFToFt5cHzmqV29d/YCpDHyIH27eTAsvGimncxou8H43Bo+4q9Bc5K+yeFOnI44gFhAzUHFHVhCeDXWO/GYQHIUGzE5T4= 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 174727747134443.27100618173324; Wed, 14 May 2025 19:51:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFOfA-0006ls-2M; Wed, 14 May 2025 22:49: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 1uFOf7-0006kp-RF for qemu-devel@nongnu.org; Wed, 14 May 2025 22:49:33 -0400 Received: from mgamail.intel.com ([192.198.163.16]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFOf5-0005iL-N2 for qemu-devel@nongnu.org; Wed, 14 May 2025 22:49:33 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2025 19:49:19 -0700 Received: from vkasired-desk2.fm.intel.com ([10.105.128.132]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2025 19:49:19 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1747277372; x=1778813372; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=usxTmhY4nCujjC/VS08WxnFRDiI6JXpAnvv0DvpfC/s=; b=hRa+Y3BVF+MxmiMG3YJ96xdY5jCgbSid08hZvpqyV324BHkXVwjruEha irOdfnHqn2I6JHFKbS/mY41egw5SNy125E8w/0rvWRm5ClTAqzRSPcJ3A lh3bV2yvQPqobDgmf9pPayUZ12QCukXhCF+TkDek8oUiT7dS0Ia4eVJZM ZShhGyg26tIdq/zpfoZe2knKgvgQnGT6u93zTI26Uh+FMjz9Z8lX9LRx2 O51xht4m+5kFtK7uVHPjCys5anZ2LJFNmHNvzVnxb6U2hfckdH2CqYyiV kkEdnK6ivrJr98QEu6betWDX5UA9SMbOlIVYyS+zua9lyzfEhBIooa/2R Q==; X-CSE-ConnectionGUID: H7Zd0YqEQ6OXDh8bgHDZFA== X-CSE-MsgGUID: BqhK27t2R3WqeOqcsn9EBA== X-IronPort-AV: E=McAfee;i="6700,10204,11433"; a="36819317" X-IronPort-AV: E=Sophos;i="6.15,289,1739865600"; d="scan'208";a="36819317" X-CSE-ConnectionGUID: 6adY1/DGTDm8Z+upKW4pnw== X-CSE-MsgGUID: g2lLd3hYSfKwaWy+iKjzXw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,289,1739865600"; d="scan'208";a="142246663" 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 v4 7/7] ui/spice: Blit the scanout texture if its memory layout is not linear Date: Wed, 14 May 2025 19:45:45 -0700 Message-ID: <20250515024734.758335-8-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250515024734.758335-1-vivek.kasireddy@intel.com> References: <20250515024734.758335-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.16; envelope-from=vivek.kasireddy@intel.com; helo=mgamail.intel.com X-Spam_score_int: -60 X-Spam_score: -6.1 X-Spam_bar: ------ X-Spam_report: (-6.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.686, 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: 1747277471850116600 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 | 81 +++++++++++++++++++++++++++++++++++--- 2 files changed, 78 insertions(+), 6 deletions(-) diff --git a/include/ui/spice-display.h b/include/ui/spice-display.h index 2fe524b59c..0f5e4e563b 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 fb56da4ab0..66b5cdd79e 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -1080,7 +1080,7 @@ static void qemu_spice_gl_scanout_texture(DisplayChan= geListener *dcl, { SimpleSpiceDisplay *ssd =3D container_of(dcl, SimpleSpiceDisplay, dcl); EGLint offset[DMABUF_MAX_PLANES], stride[DMABUF_MAX_PLANES], fourcc = =3D 0; - int fd[DMABUF_MAX_PLANES], num_planes; + int fd[DMABUF_MAX_PLANES], num_planes, i; uint64_t modifier; =20 assert(tex_id); @@ -1092,11 +1092,26 @@ static void qemu_spice_gl_scanout_texture(DisplayCh= angeListener *dcl, =20 trace_qemu_spice_gl_scanout_texture(ssd->qxl.id, w, h, fourcc); =20 - /* note: spice server will close the fd */ - spice_server_gl_scanout(&ssd->qxl, fd, backing_width, backing_height, - (uint32_t *)offset, (uint32_t *)stride, num_pl= anes, - fourcc, modifier, 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; + + for (i =3D 0; i < num_planes; i++) { + close(fd[i]); + } + } else { + /* note: spice server will close the fd */ + spice_server_gl_scanout(&ssd->qxl, fd, backing_width, backing_heig= ht, + (uint32_t *)offset, (uint32_t *)stride, nu= m_planes, + fourcc, modifier, y_0_top); + qemu_spice_gl_monitor_config(ssd, x, y, w, h); + } + ssd->have_surface =3D false; ssd->have_scanout =3D true; } @@ -1162,6 +1177,50 @@ 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, + egl_fb *scanout_tex_fb) +{ + uint32_t offsets[DMABUF_MAX_PLANES], strides[DMABUF_MAX_PLANES]; + int fds[DMABUF_MAX_PLANES], num_planes, fourcc; + uint64_t modifier; + bool ret; + + egl_fb_destroy(scanout_tex_fb); + egl_fb_setup_for_tex(scanout_tex_fb, + surface_width(ssd->ds), surface_height(ssd->ds), + ssd->ds->texture, false); + egl_fb_blit(scanout_tex_fb, &ssd->guest_fb, false); + glFlush(); + + if (!ssd->new_scanout_texture) { + return true; + } + + ret =3D egl_dmabuf_export_texture(ssd->ds->texture, + fds, + (EGLint *)offsets, + (EGLint *)strides, + &fourcc, + &num_planes, + &modifier); + if (!ret) { + error_report("spice: failed to get fd for texture"); + return false; + } + + spice_server_gl_scanout(&ssd->qxl, fds, + surface_width(ssd->ds), + surface_height(ssd->ds), + (uint32_t *)offsets, (uint32_t *)strides, + num_planes, fourcc, modifier, + 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) { @@ -1169,6 +1228,7 @@ static void qemu_spice_gl_update(DisplayChangeListene= r *dcl, EGLint fourcc =3D 0; bool render_cursor =3D false; bool y_0_top =3D false; /* FIXME */ + bool ret; uint32_t width, height, texture; =20 if (!ssd->have_scanout) { @@ -1263,6 +1323,15 @@ static void qemu_spice_gl_update(DisplayChangeListen= er *dcl, glFlush(); } =20 + if (remote_client && ssd->blit_scanout_texture) { + egl_fb scanout_tex_fb; + + ret =3D spice_gl_blit_scanout_texture(ssd, &scanout_tex_fb); + 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