From nobody Sat Nov 15 19:03:54 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=1748495829; cv=none; d=zohomail.com; s=zohoarc; b=VDTIHcrXzpIHf/nLAOrsslhuWln6nQXkmXWBpqHrgify0FEZiny+rWBTieGmKuP7NAWH3C85zugpVADUvqZkm88a/A2M/ALqWfVjFPBvO6g1yCY9MIJ24tR0vmuX5LUYlgpyE9mVsXO5RNcAMLiS/cdxu3GTJ89QmpDfsOteoEA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748495829; 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=Gj9AzNANB5mc70yH+VANlmLvdt4Xr/8WAr5Z2QrpiFs=; b=gqGyem3SbLyL+pN58kPRRx5wd0Ce2DgZg9pbnVI/9hfZ80657XLYxLf7XP6i5rOMUkV13HnKHex04kU/tAhRjH4AjHapWA7+/biqegxWen9zP7E0uP+kBqIUnK8maf0zIcxChTYnutDu26eZH/eAd2GhzNpufOFOjbG4SZHWfMk= 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 1748495829851491.37193507459904; Wed, 28 May 2025 22:17:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uKVca-0007w4-JE; Thu, 29 May 2025 01:16:04 -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 1uKVcY-0007vr-SE for qemu-devel@nongnu.org; Thu, 29 May 2025 01:16:02 -0400 Received: from mgamail.intel.com ([198.175.65.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uKVcV-0008Dw-4a for qemu-devel@nongnu.org; Thu, 29 May 2025 01:16:01 -0400 Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2025 22:15:26 -0700 Received: from vkasired-desk2.fm.intel.com ([10.105.128.132]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2025 22:15:26 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1748495759; x=1780031759; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Yc17k8wpWISIogACctnSyw91kp14hKgKC9OUBV5WR2c=; b=eTFk40SWex2UR7GiyGn8FTyC6KR+i2HO6/uwDcemE0OQE0rC1q/KqAIj FXzA44oNX3QFuO2CzyoCM5qiCDeHr3IUFj1B9CfUA+7EmzW8qyVUpCaWh In6S4d8ydX1p3rI/Wbm0bI4ef+UGNZImZPILyX1hwW2NnNglQ5vLSZufn WjOCed0RqYEywBu28mKJK9kYSdS+xbI3z+e+Z+niWx5HZQw4ZF/D1gL7i OvesehMhjqma0lv3Ka+DFTx65bRq2AwDqst175mJrHkJ7Yt2K2nyWrnWJ 15PedcYvor9geh+fHQHQ3fMbA6EuD7/vx6ze63UB1MImr09BWiZHRMX4U g==; X-CSE-ConnectionGUID: RkNQ1a+ySzSeJTlET5mExg== X-CSE-MsgGUID: l3B4MD63TEuDoxueYouOlg== X-IronPort-AV: E=McAfee;i="6700,10204,11447"; a="50241883" X-IronPort-AV: E=Sophos;i="6.15,323,1739865600"; d="scan'208";a="50241883" X-CSE-ConnectionGUID: xKV80PK/Q6WqCD5NfZBdLg== X-CSE-MsgGUID: 64KBo6hqSOKbyEkG1YOJbA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,323,1739865600"; d="scan'208";a="174455333" 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 , Michael Scherle Subject: [PATCH v5 1/7] ui/egl-helpers: Error check the fds in egl_dmabuf_export_texture() Date: Wed, 28 May 2025 22:11:12 -0700 Message-ID: <20250529051352.1409904-2-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250529051352.1409904-1-vivek.kasireddy@intel.com> References: <20250529051352.1409904-1-vivek.kasireddy@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.20; envelope-from=vivek.kasireddy@intel.com; helo=mgamail.intel.com X-Spam_score_int: -72 X-Spam_score: -7.3 X-Spam_bar: ------- X-Spam_report: (-7.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.904, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1748495831836116600 While trying to export and obtain fds associated with a texture, it is possible that the fds returned after eglExportDMABUFImageMESA() call have error values. Therefore, we need to evaluate the value of all fds and return false if any of them are negative. Cc: Gerd Hoffmann Cc: Marc-Andr=C3=A9 Lureau Cc: Dmitry Osipenko Cc: Frediano Ziglio Cc: Dongwon Kim Cc: Michael Scherle Signed-off-by: Vivek Kasireddy Reviewed-by: Marc-Andr=C3=A9 Lureau --- ui/egl-helpers.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c index 5503a795e4..e3f2872cc1 100644 --- a/ui/egl-helpers.c +++ b/ui/egl-helpers.c @@ -295,6 +295,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, @@ -314,6 +315,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 Sat Nov 15 19:03:54 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=1748495864; cv=none; d=zohomail.com; s=zohoarc; b=kC1cy/S0ND4Xwwch+GHbwvqCh43QgTLV5Cn7c+DNz4oAijpaiaTUYzLr4UnC6+X8OtLqBveHzlVHBJoisAlmMUdhxI81rl5yDx5S0eOkAG7J7szw7RdtaNkKjb3PrEZkYtjJsEbc3+72W4JiBW2TP1pS3cMIfdn/4Gz0FOW+vf4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748495864; 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=wRj66Av1iq7e7OFBJP7b9pVXsxYtksf04rUFqTp0Emw=; b=hOveCOpkThFodaNVCO2axVg+OBUB7DPU7cNCit3pRDWIkSuEjGvkR4cPUFoflkq0wFprUs0LCHbXdUlzzFcOrl0jvEsWiDmE20aK4UY/zSoUIVHmqRR25KxQ/8EZ/oMivwjmLXNOYJkQfYo4WnJ8Vl/rXRWlHg3N8xqFqzrRkMw= 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 1748495864213835.409391493869; Wed, 28 May 2025 22:17:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uKVcu-0007zx-Q7; Thu, 29 May 2025 01:16:24 -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 1uKVce-0007wk-QL for qemu-devel@nongnu.org; Thu, 29 May 2025 01:16:09 -0400 Received: from mgamail.intel.com ([198.175.65.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uKVcX-0008Fu-0W for qemu-devel@nongnu.org; Thu, 29 May 2025 01:16:08 -0400 Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2025 22:15:26 -0700 Received: from vkasired-desk2.fm.intel.com ([10.105.128.132]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2025 22:15:26 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1748495761; x=1780031761; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4X+tc/ZfuwXxOMlHJnBOXl0SCmRCGqp36mjmnOyLU04=; b=UHlTTEVHEnugNtoryBG/XsQ4ZsaVWCIm/lOEFNV1bCS9Q1ln6nu+HjJI orvY0CrspW/LtdzJcoOyKHr9KVxQ3DOUQSLWV60qus62VaOOM7ADQrLtX DFcyn5Z/WKcp+HBXsDFB9eoyIsqfLqfXyg8UJgw78DtwLppnPQ9N7iQb9 Tv7SisekFFpAjppaY9WH0JjIdRrHwvxnp1uUV8ec7ajuHG/rGeaOiWe4v ekr0pgccdc4qgIcdpgYZsdlWHnjh9wmzg3mwHQJh6a5QEG3IQJ6ui7Nrp 8l73wYS6EACc2m9LOmlNpAfV4MSEXCR9hrVWZOr+2pDooFuzWOZrzVSqh Q==; X-CSE-ConnectionGUID: FELxNTD7S7mx9lR2/7H4QQ== X-CSE-MsgGUID: moX06uvPQ5KV71ZWC9eqkg== X-IronPort-AV: E=McAfee;i="6700,10204,11447"; a="50241888" X-IronPort-AV: E=Sophos;i="6.15,323,1739865600"; d="scan'208";a="50241888" X-CSE-ConnectionGUID: JsMBluJcQvmaq7hYFWigHg== X-CSE-MsgGUID: diIZT5E2SJu+XcNWYvr75Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,323,1739865600"; d="scan'208";a="174455336" 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 , Michael Scherle Subject: [PATCH v5 2/7] ui/spice: Add an option for users to provide a preferred codec Date: Wed, 28 May 2025 22:11:13 -0700 Message-ID: <20250529051352.1409904-3-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250529051352.1409904-1-vivek.kasireddy@intel.com> References: <20250529051352.1409904-1-vivek.kasireddy@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.20; envelope-from=vivek.kasireddy@intel.com; helo=mgamail.intel.com X-Spam_score_int: -72 X-Spam_score: -7.3 X-Spam_bar: ------- X-Spam_report: (-7.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.904, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1748495866484116600 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 Cc: Michael Scherle Signed-off-by: Vivek Kasireddy Reviewed-by: Marc-Andr=C3=A9 Lureau --- 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 7eb8e02b4b..fcddb583c9 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2281,6 +2281,7 @@ DEF("spice", HAS_ARG, QEMU_OPTION_spice, " [,streaming-video=3D[off|all|filter]][,disable-copy-paste=3Don= |off]\n" " [,disable-agent-file-xfer=3Don|off][,agent-mouse=3D[on|off]]\n" " [,playback-compression=3D[on|off]][,seamless-migration=3D[on|o= ff]]\n" + " [,video-codecs=3D:\n" " [,gl=3D[on|off]][,rendernode=3D]\n" " enable spice\n" " at least one of {port, tls-port} is mandatory\n", @@ -2369,6 +2370,10 @@ SRST ``seamless-migration=3D[on|off]`` Enable/disable spice seamless migration. Default is off. =20 + ``video-codecs=3D:`` + Provide the preferred codec the Spice server should use. + Default would be spice:mjpeg. + ``gl=3D[on|off]`` Enable/disable OpenGL context. Default is off. =20 diff --git a/ui/spice-core.c b/ui/spice-core.c index 0326c63bec..907b0e9a81 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -488,6 +488,9 @@ static QemuOptsList qemu_spice_opts =3D { },{ .name =3D "streaming-video", .type =3D QEMU_OPT_STRING, + },{ + .name =3D "video-codecs", + .type =3D QEMU_OPT_STRING, },{ .name =3D "agent-mouse", .type =3D QEMU_OPT_BOOL, @@ -662,6 +665,7 @@ static void qemu_spice_init(void) char *x509_key_file =3D NULL, *x509_cert_file =3D NULL, *x509_cacert_file =3D NULL; + const char *video_codecs =3D NULL; int port, tls_port, addr_flags; spice_image_compression_t compression; spice_wan_compression_t wan_compr; @@ -801,6 +805,14 @@ static void qemu_spice_init(void) spice_server_set_streaming_video(spice_server, SPICE_STREAM_VIDEO_= OFF); } =20 + video_codecs =3D qemu_opt_get(opts, "video-codecs"); + if (video_codecs) { + if (spice_server_set_video_codecs(spice_server, video_codecs)) { + error_report("invalid video codecs"); + exit(1); + } + } + spice_server_set_agent_mouse (spice_server, qemu_opt_get_bool(opts, "agent-mouse", 1)); spice_server_set_playback_compression --=20 2.49.0 From nobody Sat Nov 15 19:03:54 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=1748495855; cv=none; d=zohomail.com; s=zohoarc; b=Q/SvJvZqWZneS809553NlKhZdSIx5CKzYgTl8I/sJ9BeM8oK+zYM0O847K0MXUEsTntoF9uEUYUmRs8Zqs1e+jGFpo5DMsoF4Dm/OPDhnl4rZoJ5sl6Qw8aSWTJZb4XbicQgseSyQDIrlElXYycUF+YXePUWCTS5ygxGCKVHtlM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748495855; 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=U25jNlePdtNEzH9ZttM5jZ+34xHj9QqlmvBho653PCI=; b=OjCPiG9VNwYuWljPXCgQcWarsAttV33EmfC8t3Kr4K0U97PmIzv/D8CLyRXuuP8yJLZ0tFY8DEfkH+oIsG/dzFlplLZCTuoeiE9XPrxgkBpmbQVFHBtZF54x77EXCf+aWnfwUJ9N4lQ0hiezNZNBdRsvs65lf5YURBDmgKKJb0I= 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 1748495855006761.4112751099675; Wed, 28 May 2025 22:17:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uKVcl-0007x0-8C; Thu, 29 May 2025 01:16:15 -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 1uKVcd-0007wS-2o for qemu-devel@nongnu.org; Thu, 29 May 2025 01:16:07 -0400 Received: from mgamail.intel.com ([198.175.65.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uKVcZ-0008Dw-Bp for qemu-devel@nongnu.org; Thu, 29 May 2025 01:16:06 -0400 Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2025 22:15:26 -0700 Received: from vkasired-desk2.fm.intel.com ([10.105.128.132]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2025 22:15:26 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1748495763; x=1780031763; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aW7kRDP25+lv2HiCRNargvEymgnLi11KpxE9EQ5BBs0=; b=JPowpbUGU//IuAgbLAj18yMiuveS71ulz60nbmwAH5a7ETGqfpa76bDw POHhwz7PdkQRYjf9aKr6iq+hLz19c8bjIiPUEhtCsEBiFUFqzxQaJXmrX vmWbTmWnbsdfbYRa6EwQyU05sxvSQ2fZTe96XvGPwnH7CMDlaNWPPpC8e HT34JgSM79qZ5llaja/naoK7V5IzSEjMN9dn7vlLneRQdNJ9kPQ71Wuno Txs2kMbgGh0Yz1fKSZIcqS3jjI7ZQYAdz5vTqUjYArow77s4sZSPehT6Y a/0x6cmXmxPpkaYBJEbzedyAuY8wDt0obdbkDr1K0hPwMNyTCT9+jLr+f g==; X-CSE-ConnectionGUID: nXEi8z1CSxaT02E6cc2jPg== X-CSE-MsgGUID: mSxrHPZgRcqx5BsuHkQA9g== X-IronPort-AV: E=McAfee;i="6700,10204,11447"; a="50241893" X-IronPort-AV: E=Sophos;i="6.15,323,1739865600"; d="scan'208";a="50241893" X-CSE-ConnectionGUID: nJ1bGDZhTKKrDBWmHtibVw== X-CSE-MsgGUID: 6KQOh+WdQ82nkhTK6aTcuQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,323,1739865600"; d="scan'208";a="174455339" 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 , Michael Scherle Subject: [PATCH v5 3/7] ui/spice: Enable gl=on option for non-local or remote clients Date: Wed, 28 May 2025 22:11:14 -0700 Message-ID: <20250529051352.1409904-4-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250529051352.1409904-1-vivek.kasireddy@intel.com> References: <20250529051352.1409904-1-vivek.kasireddy@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.20; envelope-from=vivek.kasireddy@intel.com; helo=mgamail.intel.com X-Spam_score_int: -72 X-Spam_score: -7.3 X-Spam_bar: ------- X-Spam_report: (-7.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.904, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1748495856164116600 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 Cc: Michael Scherle Signed-off-by: Vivek Kasireddy Reviewed-by: Marc-Andr=C3=A9 Lureau --- 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..6c55f38c8b 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 spice_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..f92dd55392 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 */ + spice_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..0fb72f6d6f 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 spice_remote_client; =20 int qemu_spice_rect_is_empty(const QXLRect* r) { --=20 2.49.0 From nobody Sat Nov 15 19:03:54 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=1748495816; cv=none; d=zohomail.com; s=zohoarc; b=ZtmqOCf0lCKaP296A6aZuRLt/5qn3Bqcol+ND18I5tdd85QxSCii0LUxZ56U1qSrWV+HRfGBEFG+XkJOiyc4TWcc7teHiKOU2J/IZcBKZo4dNEr/P2UlvYdO/CseO+TSrqSRE8Eg6qrE7Nz04NyafXUAXbLSf8VES3g9gyw7Ra4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748495816; 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=nhTSwK4uuPGNZXGux8Gv4mSyrajPACjTPsXbHcBW6Qw=; b=S02MLoL0+zNoOx4DTwDNjZQdgH+8XL9RC/lbOKC5icn/kRf7d1JeemTjCeZyKrUvtGir1P8DkT0OFWvWFXEGWBYao72h5r2vWW33uKpG6oTZWTabruX9O2dCqet/PLig8yRpmfRUGreEvyJBY94y8avHWPQumRoVty60oLYPOoU= 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 1748495816284234.34575847639474; Wed, 28 May 2025 22:16:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uKVcr-0007ym-20; Thu, 29 May 2025 01:16:21 -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 1uKVcg-0007wv-D5 for qemu-devel@nongnu.org; Thu, 29 May 2025 01:16:13 -0400 Received: from mgamail.intel.com ([198.175.65.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uKVca-0008GJ-Pz for qemu-devel@nongnu.org; Thu, 29 May 2025 01:16:10 -0400 Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2025 22:15:26 -0700 Received: from vkasired-desk2.fm.intel.com ([10.105.128.132]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2025 22:15:26 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1748495765; x=1780031765; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cT3Vr4u3LFYtemGbo8vgKnjPHY2jUHGA9ai8u8i8k0s=; b=Fx+yoVw2byopd1/pHyi76PX2T1bmiQ/As0NimAHIY25ZYWF2TWbtYqua +aIwPZW8yPlv/gsrl8bVpBn9RBsYfNUojed3pTbDmjnxSohX+2ymB+FgL P8PjySWb7Zz379zxc3xR99uKaxIxxq2LE3vGDPzLR1PxWu/R45f1SR4SC nHtslPYLUncKqdHCXE5LjIAtvLCleHMEh2gsSbdMyrvhqnxPmgat1rgm8 h0mMqiIw9d4jLsa2aVCwM1Bk3tpmixhMUslG6L/L91oaZ1EUgwYrLWH5T lQ8KI1jZoOsc0+Fh/9GJMeHK9L78sc/nF8l9zmNXwhBbc4GDpOc7+MLTv A==; X-CSE-ConnectionGUID: gYH0UoCDTGC4WAeyxKFSfA== X-CSE-MsgGUID: Lj6Lf7jaQUCMnTVM681OlQ== X-IronPort-AV: E=McAfee;i="6700,10204,11447"; a="50241898" X-IronPort-AV: E=Sophos;i="6.15,323,1739865600"; d="scan'208";a="50241898" X-CSE-ConnectionGUID: Q++Bj9mbQOmYB0eyGLfh1w== X-CSE-MsgGUID: Q3Ra1WtlS5CMq0idtxhp3Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,323,1739865600"; d="scan'208";a="174455344" 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 , Michael Scherle Subject: [PATCH v5 4/7] ui/spice: Add an option to submit gl_draw requests at fixed rate Date: Wed, 28 May 2025 22:11:15 -0700 Message-ID: <20250529051352.1409904-5-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250529051352.1409904-1-vivek.kasireddy@intel.com> References: <20250529051352.1409904-1-vivek.kasireddy@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.20; envelope-from=vivek.kasireddy@intel.com; helo=mgamail.intel.com X-Spam_score_int: -72 X-Spam_score: -7.3 X-Spam_bar: ------- X-Spam_report: (-7.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.904, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1748495818170116600 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 Cc: Michael Scherle Signed-off-by: Vivek Kasireddy Reviewed-by: Marc-Andr=C3=A9 Lureau --- include/ui/spice-display.h | 1 + qemu-options.hx | 5 +++ ui/spice-core.c | 12 ++++++++ ui/spice-display.c | 62 ++++++++++++++++++++++++++++++++------ 4 files changed, 70 insertions(+), 10 deletions(-) diff --git a/include/ui/spice-display.h b/include/ui/spice-display.h index 6c55f38c8b..9bdde78266 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 spice_remote_client; +extern int spice_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 fcddb583c9..98af43953d 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 f92dd55392..6576bfd20d 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -56,6 +56,8 @@ struct SpiceTimer { QEMUTimer *timer; }; =20 +#define DEFAULT_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,13 @@ static void qemu_spice_init(void) } } =20 + spice_max_refresh_rate =3D qemu_opt_get_number(opts, "max-refresh-rate= ", + DEFAULT_MAX_REFRESH_RATE); + if (spice_max_refresh_rate <=3D 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 0fb72f6d6f..e409b6bdb2 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -32,6 +32,7 @@ =20 bool spice_opengl; bool spice_remote_client; +int spice_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 (spice_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; + /* E.g, to achieve 60 FPS, update_interval needs to be ~16.66 = ms */ + dcl->update_interval =3D 1000 / spice_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 (spice_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,19 @@ 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); + + /* + * In the case of remote clients, the submission of gl_draw request is + * deferred here, so that it can be submitted later (to spice server) + * from spice_gl_refresh() timer callback. This is done to ensure that + * Guest updates are submitted at a steady rate (e.g. 60 FPS) instead + * of submitting them arbitrarily. + */ + if (spice_remote_client) { + ssd->gl_updates++; + } else { + spice_gl_draw(ssd, x, y, w, h); + } } =20 static const DisplayChangeListenerOps display_listener_gl_ops =3D { --=20 2.49.0 From nobody Sat Nov 15 19:03:54 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=1748495853; cv=none; d=zohomail.com; s=zohoarc; b=lgly0T7k/rKL8kDJNlY6YVQDmrE2+LNaFJFMU1BVaGl+yQ9OGYOtK67v7FYg5wMt3V4SxAZwVFfur9uHI6GZriczLzLHp+aXbQeF3e8ayiZ5hn+Jgu9QlvUFdUlEVb8N2h1hTp6fmdiJb79C9j2iPBORvq2npAfj3wdrQFkE5UE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748495853; 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=NFWKD6AkJZ+TA5DuCcgPsXa3F++T+kFSb41Hx9zWuR0=; b=LcnjPRZVPjhBtDWKdIOG5crQcp46KF0PYTQ6VKo5k8znPnw2N49SqrwkrKLlHOrtJKNZa+i19jS3t5OG4pR03bBYd4XgdsIuaW5oQ1nsfst2TTUsp6DROXxD2kZ2J4X0DB5awUo2qDntfEDqs3umlhZZf9DC0MgV7iJeVN3dAns= 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 1748495853150521.0054168536965; Wed, 28 May 2025 22:17:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uKVct-0007zD-RR; Thu, 29 May 2025 01:16:24 -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 1uKVck-0007xN-2e for qemu-devel@nongnu.org; Thu, 29 May 2025 01:16:15 -0400 Received: from mgamail.intel.com ([198.175.65.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uKVcd-0008Dw-Hq for qemu-devel@nongnu.org; Thu, 29 May 2025 01:16:13 -0400 Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2025 22:15:27 -0700 Received: from vkasired-desk2.fm.intel.com ([10.105.128.132]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2025 22:15:27 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1748495768; x=1780031768; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Lsr8UAMbL2vZZ9fnM7rkXFZ/rXRs+2OC9E+0A+zHKCk=; b=gK6CznboU9Ci4DgQVDNj0axvp4a6mbeixyVutCWfuX4PYMTaWO913S2E V+eUr1DT/CZuCkc98rvrMyHJNwz6n3gRl3bv5JxQYQdfqACcMBF7/s78M 2PBYO1c6xJcnixCPuOxqgl5XRQxib+aKp9R9sN6XCmS6/jGRqbP7500Jj yaWxsE/RmVCXtVxOyH6UIzean50k1NbNvGSTys1hqn7zWTUXN/nMIsyMW f4DBxQG1D1Cf1K3oFXk5AbLHgPTTfk60ym7F4bHU1m2rD1e324gv/fKlL FERtla0NEAUu1PUgE4jFLSNLuQPHygGNIkyXnGEMNeiScB8Wr0BW04OYB g==; X-CSE-ConnectionGUID: 0EUzf+QDQK2bZ/Lop8iayQ== X-CSE-MsgGUID: VH4/15ZaQBeltlFUNcvZIA== X-IronPort-AV: E=McAfee;i="6700,10204,11447"; a="50241903" X-IronPort-AV: E=Sophos;i="6.15,323,1739865600"; d="scan'208";a="50241903" X-CSE-ConnectionGUID: 8D/hxm1VQbyPljwCjttiug== X-CSE-MsgGUID: wae3CeirRpunBH125GXkZw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,323,1739865600"; d="scan'208";a="174455347" 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 , Michael Scherle Subject: [PATCH v5 5/7] ui/console-gl: Add a helper to create a texture with linear memory layout Date: Wed, 28 May 2025 22:11:16 -0700 Message-ID: <20250529051352.1409904-6-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250529051352.1409904-1-vivek.kasireddy@intel.com> References: <20250529051352.1409904-1-vivek.kasireddy@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.20; envelope-from=vivek.kasireddy@intel.com; helo=mgamail.intel.com X-Spam_score_int: -72 X-Spam_score: -7.3 X-Spam_bar: ------- X-Spam_report: (-7.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.904, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1748495854427116600 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 Co-developed-by: Michael Scherle Signed-off-by: Vivek Kasireddy Reviewed-by: Marc-Andr=C3=A9 Lureau --- include/ui/console.h | 3 +++ ui/console-gl.c | 48 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/include/ui/console.h b/include/ui/console.h index 46b3128185..98feaa58bd 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -422,6 +422,9 @@ 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, + GLuint *mem_obj); 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..afb36dba64 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,53 @@ 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, + GLuint *mem_obj) +{ + unsigned long size =3D surface_stride(surface) * surface_height(surfac= e); + GLenum err =3D glGetError(); + *texture =3D 0; + *mem_obj =3D 0; + + if (!epoxy_has_gl_extension("GL_EXT_memory_object") || + !epoxy_has_gl_extension("GL_EXT_memory_object_fd")) { + error_report("spice: required OpenGL extensions not supported: " + "GL_EXT_memory_object and 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"); + goto cleanup_mem; + } + + 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); + err =3D glGetError(); + if (err !=3D GL_NO_ERROR) { + error_report("spice: cannot create texture from memory object"); + goto cleanup_tex_and_mem; + } + return true; + +cleanup_tex_and_mem: + glDeleteTextures(1, texture); +cleanup_mem: + glDeleteMemoryObjectsEXT(1, mem_obj); + +#endif + return false; +} + void surface_gl_update_texture(QemuGLShader *gls, DisplaySurface *surface, int x, int y, int w, int h) --=20 2.49.0 From nobody Sat Nov 15 19:03:54 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=1748495813; cv=none; d=zohomail.com; s=zohoarc; b=XHSMD1uJ0pLOVG/P81A0ySYJ1zM2vNV1WkSLyG1fZYZ0gmlDhOZ3FS3todWintMAnTGEsjnPLCpLvGvT1yyS3el1lJT0AKikeDRtttcaShqA09PJ+0gZhrTtiJUSGyFKe4hSp/I6z6T/O6m9johfQl/VlkwZt8DsLm+wvmkgLIk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748495813; 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=XWBP2lWccG53B/ikkYuR/MO8uxCfiV4bMHENampuTLE=; b=MzcgXysKRWOavemgZ3Oknek3bU4DFNeLTqDSLefqwIhZG8/bnxMV8lrZDTrqQtk7pmS+RccBtZd2/0qe/GgmCqNT7reYBmh2TIECdHm6EnbwjXpbdG/DkxDjE/6ff8OfvLcYYAGUERHs+B8nOGqBTpCD9PqlI5YSo09zgoLZfhc= 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 1748495813061781.5445876580835; Wed, 28 May 2025 22:16:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uKVd0-00083I-13; Thu, 29 May 2025 01:16:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uKVcj-0007xL-1a for qemu-devel@nongnu.org; Thu, 29 May 2025 01:16:15 -0400 Received: from mgamail.intel.com ([198.175.65.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uKVcg-0008Fu-7L for qemu-devel@nongnu.org; Thu, 29 May 2025 01:16:12 -0400 Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2025 22:15:27 -0700 Received: from vkasired-desk2.fm.intel.com ([10.105.128.132]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2025 22:15:27 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1748495770; x=1780031770; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6VUKXpsstW0XE7bKFNzDprqA8fNOQNb6P7sCPRKQKow=; b=huSTiPpRVJFkiWYYtkBtIB604jXMuZsU4w0newVmyepQ5/q1jMOTn1qb zfqPuggsO0uxLpgaXSh0lRAp+ER+o+6tcdh0/LaOMVsiuJKcQCLw16FgH /5TdPGffzhltEv0RG+nwA3S1RJOhj0hxC+zLM9cgLYFixG/Dznfuvt7zQ SeRM7iyvzVZRXGL2OMfQf6/WPqKriNkcnUWDftDL2zNMGfq/KyHLQ3pIp 18qB5ffOc+kuvQVVR4Ngevicpd3GTSwtTaYOEXlMzm/ianPmuzhZTNo+s Hpx3pexSB7BDnSgxo3RjF0hlN5GpMc+L+TkBFh205xNuUuCRGVJSGf5Ma g==; X-CSE-ConnectionGUID: wKxB+ZiwSYaE6O6j3H0yAA== X-CSE-MsgGUID: 3HIIgfiWRzON9CL+vABODw== X-IronPort-AV: E=McAfee;i="6700,10204,11447"; a="50241908" X-IronPort-AV: E=Sophos;i="6.15,323,1739865600"; d="scan'208";a="50241908" X-CSE-ConnectionGUID: c+KpmBDQRzOIwsJl3nIljg== X-CSE-MsgGUID: 7uuH15ykRA6CfB0mfjsWSQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,323,1739865600"; d="scan'208";a="174455350" 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 , Michael Scherle Subject: [PATCH v5 6/7] ui/spice: Create a new texture with linear layout when gl=on is enabled Date: Wed, 28 May 2025 22:11:17 -0700 Message-ID: <20250529051352.1409904-7-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250529051352.1409904-1-vivek.kasireddy@intel.com> References: <20250529051352.1409904-1-vivek.kasireddy@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.20; envelope-from=vivek.kasireddy@intel.com; helo=mgamail.intel.com X-Spam_score_int: -72 X-Spam_score: -7.3 X-Spam_bar: ------- X-Spam_report: (-7.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.904, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1748495815908116600 Since most encoders/decoders (invoked by Spice) may not work properly 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 Co-developed-by: Michael Scherle Signed-off-by: Vivek Kasireddy Reviewed-by: Marc-Andr=C3=A9 Lureau --- include/ui/surface.h | 1 + ui/console-gl.c | 6 ++++ ui/spice-display.c | 82 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+) diff --git a/include/ui/surface.h b/include/ui/surface.h index f16f7be8be..006b1986bb 100644 --- a/include/ui/surface.h +++ b/include/ui/surface.h @@ -22,6 +22,7 @@ typedef struct DisplaySurface { GLenum glformat; GLenum gltype; GLuint texture; + GLuint mem_obj; #endif qemu_pixman_shareable share_handle; uint32_t share_handle_offset; diff --git a/ui/console-gl.c b/ui/console-gl.c index afb36dba64..403fc36fbd 100644 --- a/ui/console-gl.c +++ b/ui/console-gl.c @@ -184,6 +184,12 @@ void surface_gl_destroy_texture(QemuGLShader *gls, } glDeleteTextures(1, &surface->texture); surface->texture =3D 0; +#ifdef GL_EXT_memory_object_fd + if (surface->mem_obj) { + glDeleteMemoryObjectsEXT(1, &surface->mem_obj); + surface->mem_obj =3D 0; + } +#endif } =20 void surface_gl_setup_viewport(QemuGLShader *gls, diff --git a/ui/spice-display.c b/ui/spice-display.c index e409b6bdb2..854a97c198 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -893,6 +893,81 @@ 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; + GLuint mem_obj; + int fourcc; + bool ret; + + if (!spice_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, + &mem_obj)) { + 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); +#ifdef GL_EXT_memory_object_fd + glDeleteMemoryObjectsEXT(1, &mem_obj); +#endif + + /* + * 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; + ssd->ds->mem_obj =3D mem_obj; + } + return ret; +} + static void spice_server_gl_scanout(QXLInstance *qxl, const int *fd, uint32_t width, uint32_t height, @@ -917,6 +992,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 +1015,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 Sat Nov 15 19:03:54 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=1748495852; cv=none; d=zohomail.com; s=zohoarc; b=iAh4vjya98F1ZgtAsk/CZccz3ZENon1UL2wvIdmhfoIbFAakhl3vNx9VI1wCKmhOhkDgXI8bdJ+lb1bT9jESFgWaGIQAu7SUBs9TZxv63KszTirzb8wShBlvzPcnf4Mx+Edn/08WmYxuG//FqOPB/tthtFjzZjLc8jaL2Fgzwkg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748495852; 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=pVw2SYbQ5efFehSfnlePP30F/kAmuazMp6MtkTeQ39E=; b=LAPXLUacQvDEvBH9LeiCkHzGwmM8Dkn77H3+I9efjK0tsYouRCZ0Nm1nT/3PWMJAwNLSfpxXh7sTlBDznhmQ5snA4MvyxxW5bjTcP7e9kEXNrB/kDAEaYOUPrr0BpxEXXvwjpQP6z90PNV2Zj53o46zdkSVzoJTZ+BC7GvdCmvo= 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 1748495852343719.0720282153993; Wed, 28 May 2025 22:17:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uKVct-0007zF-RK; Thu, 29 May 2025 01:16:24 -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 1uKVck-0007xQ-MS for qemu-devel@nongnu.org; Thu, 29 May 2025 01:16:15 -0400 Received: from mgamail.intel.com ([198.175.65.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uKVci-0008GJ-0E for qemu-devel@nongnu.org; Thu, 29 May 2025 01:16:14 -0400 Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2025 22:15:27 -0700 Received: from vkasired-desk2.fm.intel.com ([10.105.128.132]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2025 22:15:27 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1748495772; x=1780031772; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cxAatodOAORzZ95kPaQtugcUFXjQS+idcd+I3ZMbUoI=; b=axZ7UMVvlgtUbpWqF4AFT8L+GCfsjpV/BUcgGQ2G18lIZ/wpvXMrRAYu hMCMi+PyVJMjB2zaQ1xg9eUMPu0CaWSmMh/ElTG7FoY5ULF36OVm0cj+m uLn7PBWtvAfxTAbcsxZyPTsGdhJtr1pgN0otoyL1gmTFTee26AOgCpcIW GPFC18AzV7HHdHbSlKM9wBLyzh3IFwNcuZAUApJWgG6nCZrgykzD0UG6i Jz//D5vmLGRrIEnf+tr/soft2PpZpxWuchGaS4wtw+fZEILyvfOK41fYD iq6a/9zz2goGcZqd2yqGVZVEDYN4BwVR9Sq9eJ0fL1M3B6xfiy7JlxCq2 A==; X-CSE-ConnectionGUID: oT4qYxZaTWKD4T+a1asieg== X-CSE-MsgGUID: Od/0aaYTSnuaCM9ZKU2E6w== X-IronPort-AV: E=McAfee;i="6700,10204,11447"; a="50241913" X-IronPort-AV: E=Sophos;i="6.15,323,1739865600"; d="scan'208";a="50241913" X-CSE-ConnectionGUID: A91srPbvSLeJwLUQxkZsBQ== X-CSE-MsgGUID: wh7Vo0hxR2GYXoXXa20tvA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,323,1739865600"; d="scan'208";a="174455354" 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 , Michael Scherle Subject: [PATCH v5 7/7] ui/spice: Blit the scanout texture if its memory layout is not linear Date: Wed, 28 May 2025 22:11:18 -0700 Message-ID: <20250529051352.1409904-8-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250529051352.1409904-1-vivek.kasireddy@intel.com> References: <20250529051352.1409904-1-vivek.kasireddy@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.20; envelope-from=vivek.kasireddy@intel.com; helo=mgamail.intel.com X-Spam_score_int: -72 X-Spam_score: -7.3 X-Spam_bar: ------- X-Spam_report: (-7.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.904, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1748495854473116600 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 Cc: Michael Scherle Signed-off-by: Vivek Kasireddy Reviewed-by: Marc-Andr=C3=A9 Lureau --- 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 9bdde78266..690ece7380 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 854a97c198..9ce622cefc 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -1086,7 +1086,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); @@ -1098,11 +1098,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 (spice_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, + num_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; } @@ -1168,6 +1183,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) { @@ -1175,6 +1234,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) { @@ -1269,6 +1329,15 @@ static void qemu_spice_gl_update(DisplayChangeListen= er *dcl, glFlush(); } =20 + if (spice_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