From nobody Sat Dec 6 23:32:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@getutm.app; 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=getutm.app ARC-Seal: i=1; a=rsa-sha256; t=1764734990; cv=none; d=zohomail.com; s=zohoarc; b=cCHjQF2/RBNe30o4r/hDRBAgWidMPK7OG32adB7W68iHPw/T9dJvBDkSW76BjNiRX46R+ldVO/u37FXo2tHMT53vtkKMNEgg3pRYkcswAsA7Rj12Z6smVEqO0eOSBbLmTXZA14Bfl9TJjcALkuKvphKJwcfSGUOZZWl0iK4SoGU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764734990; h=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=Q0rWBXh0v74nPYlqDvxdhFdl4JiMuFiyO+nCGeKih+Q=; b=jJuIhnVFIRbp4yRmV6IyMp8NUYE7ZxIxmfzqaMXL8IrsdcdhlBhmJKsYKwOXKjuKqVMPnO/6FeDT5GhYkKzusD7Epbb/+z6QRcXlSV0xML9EOyp61uDQUql1e8SRJlVuyHYVnQKCjcsPp3z1D53au91zpS3rQTMW2WRtnhXgQ9Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@getutm.app; 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 1764734990188483.88154420901003; Tue, 2 Dec 2025 20:09:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vQeAI-0002Fd-HN; Tue, 02 Dec 2025 23:08:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vQeAE-0002Em-Fx for qemu-devel@nongnu.org; Tue, 02 Dec 2025 23:08:28 -0500 Received: from a4i956.smtp2go.com ([158.120.83.188]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vQeAD-0000Tm-6O for qemu-devel@nongnu.org; Tue, 02 Dec 2025 23:08:26 -0500 Received: from [10.159.238.187] (helo=localhost.localdomain) by smtpcorp.com with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA512__CHACHA20_POLY1305:256) (Exim 4.98.1-S2G) (envelope-from ) id 1vQe9r-FnQW0hPv7oK-Vbf4; Wed, 03 Dec 2025 04:08:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=getutm.app; i=@getutm.app; q=dns/txt; s=s483429; t=1764734892; h=from : subject : to : message-id : date; bh=Q0rWBXh0v74nPYlqDvxdhFdl4JiMuFiyO+nCGeKih+Q=; b=mR/7m6ei9XkxMBciEDZTYaflaDH5JROIPnomMoC8lv7WPUQ4oCTBWAF1p5leBuRApbQAJ cSHvTXRFJ99NJW9iRKF6z7y20Sa0aQPJnP0YMwAQARwBQNOLSebMy55ghaA18T1NAa5+lT5 kwZVdA2OWA6BSxP+l0I7QWR8n9OgRREYln7DkKzZQ/cxqEx6ZWJXQGc/0wteG5LmxMmxdqA HJqOraYC58cUWRIWls2aYqrcO+PTKye1ftZUTpQ8xE5e8gjJ0K6I1LRlGTaH0GuFXmyk79q OC4Yjits4UjSI4h2hNiF+M6KKl94uxYeE6qjTBAG5p4wxPewyVvh102PMxrg== From: Joelle van Dyne To: qemu-devel@nongnu.org Cc: Joelle van Dyne , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Akihiko Odaki , Dmitry Osipenko , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH RFC 1/7] egl-helpers: store handle to native device Date: Tue, 2 Dec 2025 20:07:48 -0800 Message-ID: <20251203040754.94487-2-j@getutm.app> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20251203040754.94487-1-j@getutm.app> References: <20251203040754.94487-1-j@getutm.app> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Report-Abuse: Please forward a copy of this message, including all headers, to Feedback-ID: 483429m:483429abrvJvs:483429stcnh_z_wb X-smtpcorp-track: 68q7XsSCTGWE.y9JzzDj-leir.geuvvw6AcI_ 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=158.120.83.188; envelope-from=bounce.yuaz7qs5vfhjsv0=kllqm2owx64x=ksegn939lhphuv@em483429.getutm.app; helo=a4i956.smtp2go.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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 @getutm.app) X-ZM-MESSAGEID: 1764734991856019200 Content-Type: text/plain; charset="utf-8" Make way for other platforms by making the variable more general. Also we will be using the device in the future so let's save the pointer in the global instead of just a boolean flag. Signed-off-by: Joelle van Dyne --- include/ui/egl-helpers.h | 2 +- hw/display/virtio-gpu-virgl.c | 2 +- ui/egl-helpers.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/ui/egl-helpers.h b/include/ui/egl-helpers.h index acf993fcf5..c239d32317 100644 --- a/include/ui/egl-helpers.h +++ b/include/ui/egl-helpers.h @@ -12,7 +12,7 @@ extern EGLDisplay *qemu_egl_display; extern EGLConfig qemu_egl_config; extern DisplayGLMode qemu_egl_mode; -extern bool qemu_egl_angle_d3d; +extern void *qemu_egl_angle_native_device; =20 typedef struct egl_fb { int width; diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index 07f6355ad6..20c856c04e 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -1152,7 +1152,7 @@ int virtio_gpu_virgl_init(VirtIOGPU *g) } #endif #ifdef VIRGL_RENDERER_D3D11_SHARE_TEXTURE - if (qemu_egl_angle_d3d) { + if (qemu_egl_angle_native_device) { flags |=3D VIRGL_RENDERER_D3D11_SHARE_TEXTURE; } #endif diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c index e3f2872cc1..57bcf99498 100644 --- a/ui/egl-helpers.c +++ b/ui/egl-helpers.c @@ -28,7 +28,7 @@ EGLDisplay *qemu_egl_display; EGLConfig qemu_egl_config; DisplayGLMode qemu_egl_mode; -bool qemu_egl_angle_d3d; +void *qemu_egl_angle_native_device; =20 /* ------------------------------------------------------------------ */ =20 @@ -651,7 +651,7 @@ int qemu_egl_init_dpy_win32(EGLNativeDisplayType dpy, D= isplayGLMode mode) } =20 trace_egl_init_d3d11_device(device); - qemu_egl_angle_d3d =3D device !=3D NULL; + qemu_egl_angle_native_device =3D d3d11_device; } #endif =20 --=20 2.41.0 From nobody Sat Dec 6 23:32:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@getutm.app; 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=getutm.app ARC-Seal: i=1; a=rsa-sha256; t=1764734967; cv=none; d=zohomail.com; s=zohoarc; b=Ar3lr8OL5E9CrXLHdva9m9OVwxdj2MNMOX7gM4UR55/SlQKpZUblHqlmqa3HudHfeBAtSM62SZMdV+m1pmMfi1pMy3DULR0/05foNGh5juv41fI8aTTH0aEO3YPhr/Ra20FWTM64fKZe5EvhYOH0EJDfgVEXgl/Iz5WQvtsFQWs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764734967; h=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=rWlEgGNDGz8jZNA1IbIgK4EKjt9rl3oL/zBZZeAdEyo=; b=UzWGqemWFxbc5zbZcn1s0IidbML1bflim8RFiXgVXjm+QM9R70wafpMXO7wDj3HvD00x7aVNhXNjSsMy8d3TlrcLbCyNRKV9Y1wQV92L5yXQ6fw+sFh/ECwYvtHEqraG99KnnFJbQVUROe3UiCAR6AZ5mamf5LidSCCcTdyApc0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@getutm.app; 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 1764734967414446.0965872863752; Tue, 2 Dec 2025 20:09:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vQeAG-0002Eq-69; Tue, 02 Dec 2025 23:08:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vQeAB-0002EG-Q3 for qemu-devel@nongnu.org; Tue, 02 Dec 2025 23:08:24 -0500 Received: from a4i956.smtp2go.com ([158.120.83.188]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vQeAA-0000Tm-EM for qemu-devel@nongnu.org; Tue, 02 Dec 2025 23:08:23 -0500 Received: from [10.159.238.187] (helo=localhost.localdomain) by smtpcorp.com with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA512__CHACHA20_POLY1305:256) (Exim 4.98.1-S2G) (envelope-from ) id 1vQe9t-FnQW0hPv7oK-X2Ra; Wed, 03 Dec 2025 04:08:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=getutm.app; i=@getutm.app; q=dns/txt; s=s483429; t=1764734891; h=from : subject : to : message-id : date; bh=rWlEgGNDGz8jZNA1IbIgK4EKjt9rl3oL/zBZZeAdEyo=; b=V8AqVA8NvqW6yj9Dct3NU0lXdSDQr0m0Riw2+z5lLrLEUaXtBdRTfMmNfLstMcxM174Z8 xk8NZsDK0Jg/9054NplQQijL6jiEm0CClCjDomi04SU1MQezIVz0ee7ntTo5G5V5GYqFn5L IAtJTfrALyLb5VVPV8i3B3DMcJbsm1mQmOddHKvjLMMnabfXtFSPo1Qb+wyAO1EcqVtMvtg /4Vyk59FpovAxsLv5VBMZ8GmqkM28ahFqM2yqYztDOcb1g3GmVi+2dgVY7vipTTzm1c0VNj USBWyAYMMYiqfLfZnV8XWzZozIJUxlVXSvSp3/9VeyQSOKsfQ83wustT+IdQ== From: Joelle van Dyne To: qemu-devel@nongnu.org Cc: Joelle van Dyne , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Akihiko Odaki , Dmitry Osipenko , "Michael S. Tsirkin" Subject: [PATCH RFC 2/7] virtio-gpu-virgl: check page alignment of blob mapping Date: Tue, 2 Dec 2025 20:07:49 -0800 Message-ID: <20251203040754.94487-3-j@getutm.app> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20251203040754.94487-1-j@getutm.app> References: <20251203040754.94487-1-j@getutm.app> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Report-Abuse: Please forward a copy of this message, including all headers, to Feedback-ID: 483429m:483429abrvJvs:483429sxwTVGsyjK X-smtpcorp-track: bfYAnkvpnQLR.tR__meNI_Pt7.RevSPwiWvRs 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=158.120.83.188; envelope-from=bounce.29vafx79xran0f5=p85mwoxbn3wq=m9n7svzbgw7c67@em483429.getutm.app; helo=a4i956.smtp2go.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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 @getutm.app) X-ZM-MESSAGEID: 1764734970002019200 Content-Type: text/plain; charset="utf-8" Currently if a mapping is not page aligned, it will sliently fail and the guest, assuming it is mapped, will attempt to access the memory and fail. This is particularly an issue on macOS when the host page size is 16KiB and the guest page size is 4KiB. Signed-off-by: Joelle van Dyne --- hw/display/virtio-gpu-virgl.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index 20c856c04e..adf02ac22b 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -116,6 +116,20 @@ virtio_gpu_virgl_map_resource_blob(VirtIOGPU *g, return ret; } =20 + if (!QEMU_IS_ALIGNED((uintptr_t)data, qemu_real_host_page_size())) { + virgl_renderer_resource_unmap(res->base.resource_id); + qemu_log_mask(LOG_GUEST_ERROR, "%s: address %p is not aligned to p= age size\n", + __func__, data); + return -ENOMEM; + } + + if (!QEMU_IS_ALIGNED(size, qemu_real_host_page_size())) { + virgl_renderer_resource_unmap(res->base.resource_id); + qemu_log_mask(LOG_GUEST_ERROR, "%s: size 0x%llx is not aligned to = page size\n", + __func__, size); + return -ENOMEM; + } + vmr =3D g_new0(struct virtio_gpu_virgl_hostmem_region, 1); vmr->g =3D g; =20 --=20 2.41.0 From nobody Sat Dec 6 23:32:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@getutm.app; 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=getutm.app ARC-Seal: i=1; a=rsa-sha256; t=1764734975; cv=none; d=zohomail.com; s=zohoarc; b=DXpzNwPrX5HfqtRK4RFDcrYZ29+8utp9t/rfQXl8/R7cEUCc3ycUHedh97xuUxN/b+e8CD15Lct/4CODD8rYjXUe5A3vMApMJpQEr4e0FRqvROJ69QfCt2kSDYPHyvahromqoJBLcUUUztXYcpYd7c2QXtLBVEjoR5t/cWxdJ6M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764734975; h=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=t2hSA2aZm2p5K2v/2+0k+47nX6YefsgPefSG/xZ7xYQ=; b=SqbLePqqps7NhThwAk1yo05O3LNQhfCxBHBOyaJYTz9F5mCrz1AeApWcs3qTz6nfUbu8tlew/MQIk/EWFYzHgYag1/taiPI+NMYtBAHF+Ubl6XiNDVuKyQfZe2WjDKioI3+Y6N48bt0uinIWdHkGAoGwehXprYIupkol9aVmnx0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@getutm.app; 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 1764734975932576.2339550240156; Tue, 2 Dec 2025 20:09:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vQeAK-0002Gw-Dw; Tue, 02 Dec 2025 23:08:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vQeAI-0002FK-2v for qemu-devel@nongnu.org; Tue, 02 Dec 2025 23:08:30 -0500 Received: from a4i956.smtp2go.com ([158.120.83.188]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vQeAG-0000Tm-7R for qemu-devel@nongnu.org; Tue, 02 Dec 2025 23:08:29 -0500 Received: from [10.159.238.187] (helo=localhost.localdomain) by smtpcorp.com with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA512__CHACHA20_POLY1305:256) (Exim 4.98.1-S2G) (envelope-from ) id 1vQe9w-FnQW0hPv7oK-VRbB; Wed, 03 Dec 2025 04:08:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=getutm.app; i=@getutm.app; q=dns/txt; s=s483429; t=1764734897; h=from : subject : to : message-id : date; bh=t2hSA2aZm2p5K2v/2+0k+47nX6YefsgPefSG/xZ7xYQ=; b=IkDr0+AZSLWFzHu4fhcNqcbxqtM+XWloNtwBIf6y9tHT4TCzuUW/VNND6AWbqEj5G/8F0 ysr9ZBKoiMzkD3Jv/UgTsxu9duDkuljXP8AxosLrpbqIGuYaZFYOF466Xf/8GBEw/XsQTaA Dt3LEa2Uhy4fRCrGkMEE9qT1oxvssKoLCMP2O9sfShtlssejtVdLk3paGoE/VewZrRHScP7 fvVooJpiBwRBk2ocTR8+te0zjJclEX+pQO1rrKoDn2B1xA1sosQzuesGJQZC6aO/E0avq7r I7LFbHdV5H6gg+xNgWU0ZxE/Y0/QIFF/KejsrQws8GDlNTQgRji+LiVfElfQ== From: Joelle van Dyne To: qemu-devel@nongnu.org Cc: Joelle van Dyne , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Akihiko Odaki , Dmitry Osipenko , "Michael S. Tsirkin" , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH RFC 3/7] console: rename `d3d_tex2d` to `native` Date: Tue, 2 Dec 2025 20:07:50 -0800 Message-ID: <20251203040754.94487-4-j@getutm.app> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20251203040754.94487-1-j@getutm.app> References: <20251203040754.94487-1-j@getutm.app> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Report-Abuse: Please forward a copy of this message, including all headers, to Feedback-ID: 483429m:483429abrvJvs:483429spaCCUDkCQ X-smtpcorp-track: iJ4-QIeWLwFb.WD-PV-WpqZNw.70BfGwS9teO 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=158.120.83.188; envelope-from=bounce.s384pp0ozqvjgd6=vdkusp7nqj4f=i31w8pilfqsxvs@em483429.getutm.app; helo=a4i956.smtp2go.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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 @getutm.app) X-ZM-MESSAGEID: 1764734977363019200 Content-Type: text/plain; charset="utf-8" In order to support native texture scanout beyond D3D, we make this more generic allowing for multiple native texture handle types. Signed-off-by: Joelle van Dyne --- include/ui/console.h | 22 +++++++++++++++++++--- include/ui/gtk.h | 4 ++-- include/ui/sdl2.h | 2 +- hw/display/virtio-gpu-virgl.c | 10 +++++++--- ui/console.c | 8 ++++---- ui/dbus-console.c | 2 +- ui/dbus-listener.c | 8 ++++---- ui/egl-headless.c | 2 +- ui/gtk-egl.c | 2 +- ui/gtk-gl-area.c | 2 +- ui/sdl2-gl.c | 2 +- ui/spice-display.c | 2 +- 12 files changed, 43 insertions(+), 23 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index 98feaa58bd..25e45295d4 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -131,6 +131,22 @@ struct QemuConsoleClass { ObjectClass parent_class; }; =20 +typedef enum ScanoutTextureNativeType { + SCANOUT_TEXTURE_NATIVE_TYPE_NONE, + SCANOUT_TEXTURE_NATIVE_TYPE_D3D, +} ScanoutTextureNativeType; + +typedef struct ScanoutTextureNative { + ScanoutTextureNativeType type; + union { + void *d3d_tex2d; + } u; +} ScanoutTextureNative; + +#define NO_NATIVE_TEXTURE ((ScanoutTextureNative){ \ + .type =3D SCANOUT_TEXTURE_NATIVE_TYPE_NONE \ +}) + typedef struct ScanoutTexture { uint32_t backing_id; bool backing_y_0_top; @@ -140,7 +156,7 @@ typedef struct ScanoutTexture { uint32_t y; uint32_t width; uint32_t height; - void *d3d_tex2d; + ScanoutTextureNative native; } ScanoutTexture; =20 typedef struct QemuUIInfo { @@ -245,7 +261,7 @@ typedef struct DisplayChangeListenerOps { uint32_t backing_height, uint32_t x, uint32_t y, uint32_t w, uint32_t h, - void *d3d_tex2d); + ScanoutTextureNative native); /* optional (default to true if has dpy_gl_scanout_dmabuf) */ bool (*dpy_has_dmabuf)(DisplayChangeListener *dcl); /* optional */ @@ -329,7 +345,7 @@ void dpy_gl_scanout_texture(QemuConsole *con, uint32_t backing_id, bool backing_y_0_top, uint32_t backing_width, uint32_t backing_heigh= t, uint32_t x, uint32_t y, uint32_t w, uint32_t h, - void *d3d_tex2d); + ScanoutTextureNative native); void dpy_gl_scanout_dmabuf(QemuConsole *con, QemuDmaBuf *dmabuf); void dpy_gl_cursor_dmabuf(QemuConsole *con, QemuDmaBuf *dmabuf, diff --git a/include/ui/gtk.h b/include/ui/gtk.h index 3e6ce3cb48..f88e2b281d 100644 --- a/include/ui/gtk.h +++ b/include/ui/gtk.h @@ -178,7 +178,7 @@ void gd_egl_scanout_texture(DisplayChangeListener *dcl, uint32_t backing_height, uint32_t x, uint32_t y, uint32_t w, uint32_t h, - void *d3d_tex2d); + ScanoutTextureNative native); void gd_egl_scanout_dmabuf(DisplayChangeListener *dcl, QemuDmaBuf *dmabuf); void gd_egl_cursor_dmabuf(DisplayChangeListener *dcl, @@ -215,7 +215,7 @@ void gd_gl_area_scanout_texture(DisplayChangeListener *= dcl, uint32_t backing_height, uint32_t x, uint32_t y, uint32_t w, uint32_t h, - void *d3d_tex2d); + ScanoutTextureNative native); void gd_gl_area_scanout_disable(DisplayChangeListener *dcl); void gd_gl_area_scanout_flush(DisplayChangeListener *dcl, uint32_t x, uint32_t y, uint32_t w, uint32_t= h); diff --git a/include/ui/sdl2.h b/include/ui/sdl2.h index dbe6e3d973..fdefb88229 100644 --- a/include/ui/sdl2.h +++ b/include/ui/sdl2.h @@ -93,7 +93,7 @@ void sdl2_gl_scanout_texture(DisplayChangeListener *dcl, uint32_t backing_height, uint32_t x, uint32_t y, uint32_t w, uint32_t h, - void *d3d_tex2d); + ScanoutTextureNative native); void sdl2_gl_scanout_flush(DisplayChangeListener *dcl, uint32_t x, uint32_t y, uint32_t w, uint32_t h); =20 diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index adf02ac22b..d0e6ad4b17 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -434,14 +434,18 @@ static void virgl_cmd_set_scanout(VirtIOGPU *g, =20 if (ss.resource_id && ss.r.width && ss.r.height) { struct virgl_renderer_resource_info info; - void *d3d_tex2d =3D NULL; + ScanoutTextureNative native =3D { .type =3D SCANOUT_TEXTURE_NATIVE= _TYPE_NONE }; =20 #if VIRGL_VERSION_MAJOR >=3D 1 struct virgl_renderer_resource_info_ext ext; memset(&ext, 0, sizeof(ext)); ret =3D virgl_renderer_resource_get_info_ext(ss.resource_id, &ext); info =3D ext.base; - d3d_tex2d =3D ext.d3d_tex2d; + native =3D (ScanoutTextureNative){ + .type =3D ext.d3d_tex2d ? SCANOUT_TEXTURE_NATIVE_TYPE_D3D : + SCANOUT_TEXTURE_NATIVE_TYPE_NONE, + .u.d3d_tex2d =3D ext.d3d_tex2d, + }; #else memset(&info, 0, sizeof(info)); ret =3D virgl_renderer_resource_get_info(ss.resource_id, &info); @@ -461,7 +465,7 @@ static void virgl_cmd_set_scanout(VirtIOGPU *g, info.flags & VIRTIO_GPU_RESOURCE_FLAG_Y_0_TOP, info.width, info.height, ss.r.x, ss.r.y, ss.r.width, ss.r.height, - d3d_tex2d); + native); } else { dpy_gfx_replace_surface( g->parent_obj.scanout[ss.scanout_id].con, NULL); diff --git a/ui/console.c b/ui/console.c index 2d00828c53..9378afd53d 100644 --- a/ui/console.c +++ b/ui/console.c @@ -295,7 +295,7 @@ static void displaychangelistener_display_console(Displ= ayChangeListener *dcl, con->scanout.texture.y, con->scanout.texture.width, con->scanout.texture.height, - con->scanout.texture.d3d_tex2d); + con->scanout.texture.native); } } =20 @@ -1023,7 +1023,7 @@ void dpy_gl_scanout_texture(QemuConsole *con, uint32_t backing_height, uint32_t x, uint32_t y, uint32_t width, uint32_t height, - void *d3d_tex2d) + ScanoutTextureNative native) { DisplayState *s =3D con->ds; DisplayChangeListener *dcl; @@ -1031,7 +1031,7 @@ void dpy_gl_scanout_texture(QemuConsole *con, con->scanout.kind =3D SCANOUT_TEXTURE; con->scanout.texture =3D (ScanoutTexture) { backing_id, backing_y_0_top, backing_width, backing_height, - x, y, width, height, d3d_tex2d, + x, y, width, height, native, }; QLIST_FOREACH(dcl, &s->listeners, next) { if (con !=3D dcl->con) { @@ -1042,7 +1042,7 @@ void dpy_gl_scanout_texture(QemuConsole *con, backing_y_0_top, backing_width, backing_height, x, y, width, height, - d3d_tex2d); + native); } } } diff --git a/ui/dbus-console.c b/ui/dbus-console.c index 85e215ef23..651f0daeaf 100644 --- a/ui/dbus-console.c +++ b/ui/dbus-console.c @@ -99,7 +99,7 @@ dbus_gl_scanout_texture(DisplayChangeListener *dcl, uint32_t backing_height, uint32_t x, uint32_t y, uint32_t w, uint32_t h, - void *d3d_tex2d) + ScanoutTextureNative native) { DBusDisplayConsole *ddc =3D container_of(dcl, DBusDisplayConsole, dcl); =20 diff --git a/ui/dbus-listener.c b/ui/dbus-listener.c index 52e041edb0..a737752996 100644 --- a/ui/dbus-listener.c +++ b/ui/dbus-listener.c @@ -587,7 +587,7 @@ static void dbus_scanout_texture(DisplayChangeListener = *dcl, uint32_t backing_height, uint32_t x, uint32_t y, uint32_t w, uint32_t h, - void *d3d_tex2d) + ScanoutTextureNative native) { trace_dbus_scanout_texture(tex_id, backing_y_0_top, backing_width, backing_height, x, y, w, h); @@ -618,8 +618,8 @@ static void dbus_scanout_texture(DisplayChangeListener = *dcl, assert(surface_width(ddl->ds) =3D=3D w); assert(surface_height(ddl->ds) =3D=3D h); =20 - if (d3d_tex2d) { - dbus_scanout_share_d3d_texture(ddl, d3d_tex2d, backing_y_0_top, + if (native.type =3D=3D SCANOUT_TEXTURE_NATIVE_TYPE_D3d) { + dbus_scanout_share_d3d_texture(ddl, native.u.d3d_tex2d, backing_y_= 0_top, backing_width, backing_height, x, y= , w, h); } else { dbus_scanout_map(ddl); @@ -868,7 +868,7 @@ static void dbus_gl_gfx_switch(DisplayChangeListener *d= cl, =20 /* TODO: lazy send dmabuf (there are unnecessary sent otherwise) */ dbus_scanout_texture(&ddl->dcl, ddl->ds->texture, false, - width, height, 0, 0, width, height, NULL); + width, height, 0, 0, width, height, NO_NATIVE= _TEXTURE); } } #endif diff --git a/ui/egl-headless.c b/ui/egl-headless.c index 1f6b845500..e36778bd48 100644 --- a/ui/egl-headless.c +++ b/ui/egl-headless.c @@ -62,7 +62,7 @@ static void egl_scanout_texture(DisplayChangeListener *dc= l, uint32_t backing_height, uint32_t x, uint32_t y, uint32_t w, uint32_t h, - void *d3d_tex2d) + ScanoutTextureNative native) { egl_dpy *edpy =3D container_of(dcl, egl_dpy, dcl); =20 diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c index ae9239999c..7933237d45 100644 --- a/ui/gtk-egl.c +++ b/ui/gtk-egl.c @@ -239,7 +239,7 @@ void gd_egl_scanout_texture(DisplayChangeListener *dcl, uint32_t backing_width, uint32_t backing_heigh= t, uint32_t x, uint32_t y, uint32_t w, uint32_t h, - void *d3d_tex2d) + ScanoutTextureNative native) { VirtualConsole *vc =3D container_of(dcl, VirtualConsole, gfx.dcl); =20 diff --git a/ui/gtk-gl-area.c b/ui/gtk-gl-area.c index cd86022d26..f2ed543d6a 100644 --- a/ui/gtk-gl-area.c +++ b/ui/gtk-gl-area.c @@ -306,7 +306,7 @@ void gd_gl_area_scanout_texture(DisplayChangeListener *= dcl, uint32_t backing_height, uint32_t x, uint32_t y, uint32_t w, uint32_t h, - void *d3d_tex2d) + ScanoutTextureNative native) { VirtualConsole *vc =3D container_of(dcl, VirtualConsole, gfx.dcl); =20 diff --git a/ui/sdl2-gl.c b/ui/sdl2-gl.c index 3be17d1079..b15db86f24 100644 --- a/ui/sdl2-gl.c +++ b/ui/sdl2-gl.c @@ -206,7 +206,7 @@ void sdl2_gl_scanout_texture(DisplayChangeListener *dcl, uint32_t backing_height, uint32_t x, uint32_t y, uint32_t w, uint32_t h, - void *d3d_tex2d) + ScanoutTextureNative native) { struct sdl2_console *scon =3D container_of(dcl, struct sdl2_console, d= cl); =20 diff --git a/ui/spice-display.c b/ui/spice-display.c index db71e866f8..2a2285cb1f 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -1084,7 +1084,7 @@ static void qemu_spice_gl_scanout_texture(DisplayChan= geListener *dcl, uint32_t backing_height, uint32_t x, uint32_t y, uint32_t w, uint32_t h, - void *d3d_tex2d) + ScanoutTextureNative native) { SimpleSpiceDisplay *ssd =3D container_of(dcl, SimpleSpiceDisplay, dcl); EGLint offset[DMABUF_MAX_PLANES], stride[DMABUF_MAX_PLANES], fourcc = =3D 0; --=20 2.41.0 From nobody Sat Dec 6 23:32:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@getutm.app; 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=getutm.app ARC-Seal: i=1; a=rsa-sha256; t=1764734973; cv=none; d=zohomail.com; s=zohoarc; b=Z2RR2l7OtJW1XMNx6+CaTwdcDlh/5OnGriPCOoFXBaTwhr7ylIi8Yk2bLzgU8ZaCmQjrVBmwVXTCDl0VzSOSopjBx8crfSjEGLOUyV9wNCzqGisyNznVFx0K2n17Z8rSvKbsxZBHo8qa//DDifxVstlXUAwJpwY5UJKPphMh1vQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764734973; h=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=RKFSYaD5mWEuabGiWe4mUZY3p0G6tvHa9VipptsJ6dE=; b=jsroVdeCd5Q8e+zDN1zJAEN3RafWpenb0a+Ka/Ajl9hLkpymTR8ikMEfAE59KYwkzfvshjuRKcmCKzx6Ok2/I1m6Y+htou/ituGdePi4UXeYOl1s8iNUK+8tDIIyvUyebuvsKG8xLDxYWko9i9JrkAvRsJYnc++UoY7ApwZwegY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@getutm.app; 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 1764734973419584.4681349681341; Tue, 2 Dec 2025 20:09:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vQeAK-0002Gk-7m; Tue, 02 Dec 2025 23:08:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vQeAH-0002FI-K3 for qemu-devel@nongnu.org; Tue, 02 Dec 2025 23:08:30 -0500 Received: from a4i956.smtp2go.com ([158.120.83.188]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vQeAG-0000Wc-6s for qemu-devel@nongnu.org; Tue, 02 Dec 2025 23:08:29 -0500 Received: from [10.159.238.187] (helo=localhost.localdomain) by smtpcorp.com with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA512__CHACHA20_POLY1305:256) (Exim 4.98.1-S2G) (envelope-from ) id 1vQe9y-FnQW0hPv7oK-Wgtd; Wed, 03 Dec 2025 04:08:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=getutm.app; i=@getutm.app; q=dns/txt; s=s483429; t=1764734895; h=from : subject : to : message-id : date; bh=RKFSYaD5mWEuabGiWe4mUZY3p0G6tvHa9VipptsJ6dE=; b=WznVN0YgBBfFHLUwPEP+LR6xu5u8qSkRHr82ogai3VbzcOyjTbO4kpph2OSnRit+LJsOI O4SZaeiPz1qwdf89qsKhEtuHuDzoCAeqZbJPgYh+En14/zqlSS1cyS0Iqv/RzPR7EZ0Iy3c 4pCPXQLIG43U1fPufXtN2o/z6WQHBhDTCiAaAdh60Mi0Gp4iNqyvPUhNeUu3UaTCrDf29d5 1UlZj4wwwltFuWLqTvfyuRRY2q5XOuqlndO3L20RSbrN5mdRwGW6eaUv2O+xWYOhAHDXGhi 6p5+vfTJGkr9fsRLy7n6M/40syjhS0zLTq7iL/Va+FZ/X5W6wBBNSQpiNpNA== From: Joelle van Dyne To: qemu-devel@nongnu.org Cc: Joelle van Dyne , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Akihiko Odaki , Dmitry Osipenko Subject: [PATCH RFC 4/7] virtio-gpu-virgl: update virglrenderer defines Date: Tue, 2 Dec 2025 20:07:51 -0800 Message-ID: <20251203040754.94487-5-j@getutm.app> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20251203040754.94487-1-j@getutm.app> References: <20251203040754.94487-1-j@getutm.app> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Report-Abuse: Please forward a copy of this message, including all headers, to Feedback-ID: 483429m:483429abrvJvs:483429sXHaL01GIg X-smtpcorp-track: BB1kipmajpGZ.yIYh3lvklgbJ.4yKDEQpS5l- 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=158.120.83.188; envelope-from=bounce.35jm618ccjcdvl1=wd6m3wilz0s8=b87kiyyvfflxev@em483429.getutm.app; helo=a4i956.smtp2go.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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 @getutm.app) X-ZM-MESSAGEID: 1764734975879019200 Content-Type: text/plain; charset="utf-8" In order to support additional native texture types, we need to update the defines in virglrenderer. The changes are backwards compatible and so builds should work with either the new version or the old version. Signed-off-by: Joelle van Dyne --- hw/display/virtio-gpu-virgl.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index d0e6ad4b17..36c670f988 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -24,6 +24,8 @@ =20 #include =20 +#define SUPPORTED_VIRGL_INFO_EXT_VERSION (1) + struct virtio_gpu_virgl_resource { struct virtio_gpu_simple_resource base; MemoryRegion *mr; @@ -441,12 +443,30 @@ static void virgl_cmd_set_scanout(VirtIOGPU *g, memset(&ext, 0, sizeof(ext)); ret =3D virgl_renderer_resource_get_info_ext(ss.resource_id, &ext); info =3D ext.base; + /* fallback to older version */ native =3D (ScanoutTextureNative){ .type =3D ext.d3d_tex2d ? SCANOUT_TEXTURE_NATIVE_TYPE_D3D : SCANOUT_TEXTURE_NATIVE_TYPE_NONE, .u.d3d_tex2d =3D ext.d3d_tex2d, }; -#else +#if VIRGL_RENDERER_RESOURCE_INFO_EXT_VERSION >=3D SUPPORTED_VIRGL_INFO_EXT= _VERSION + if (ext.version >=3D VIRGL_RENDERER_RESOURCE_INFO_EXT_VERSION) { + switch (ext.native_type) { + case VIRGL_NATIVE_HANDLE_NONE: + case VIRGL_NATIVE_HANDLE_D3D_TEX2D: { + /* already handled above */ + break; + } + default: { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: unsupported native texture type %d\n", + __func__, ext.native_type); + break; + } + } + } +#endif +#else /* VIRGL_VERSION_MAJOR < 1 */ memset(&info, 0, sizeof(info)); ret =3D virgl_renderer_resource_get_info(ss.resource_id, &info); #endif @@ -1169,11 +1189,13 @@ int virtio_gpu_virgl_init(VirtIOGPU *g) virtio_gpu_3d_cbs.get_egl_display =3D virgl_get_egl_display; } #endif -#ifdef VIRGL_RENDERER_D3D11_SHARE_TEXTURE if (qemu_egl_angle_native_device) { +#if defined(VIRGL_RENDERER_NATIVE_SHARE_TEXTURE) + flags |=3D VIRGL_RENDERER_NATIVE_SHARE_TEXTURE; +#elif defined(VIRGL_RENDERER_D3D11_SHARE_TEXTURE) && defined(WIN32) flags |=3D VIRGL_RENDERER_D3D11_SHARE_TEXTURE; - } #endif + } #if VIRGL_VERSION_MAJOR >=3D 1 if (virtio_gpu_venus_enabled(g->parent_obj.conf)) { flags |=3D VIRGL_RENDERER_VENUS | VIRGL_RENDERER_RENDER_SERVER; --=20 2.41.0 From nobody Sat Dec 6 23:32:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@getutm.app; 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=getutm.app ARC-Seal: i=1; a=rsa-sha256; t=1764734954; cv=none; d=zohomail.com; s=zohoarc; b=N+hbZvGLJDtc4vz/pyOSOSYtsOq+YMP0orcRP5I2QDjffd9NmMoX/gQNNrHZLFQrlER8k6pwEftyNaN1sECPyCuFzjtWZeX8568IN8eQSiFcXeOGVUatA7jSnVCFzCUQ0zwPO73XJN+autPBZQCcrdo4DV2VHxhnHUazQZM68jE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764734954; h=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=y9kSlBF0XTESB4AkIAMB416dSilaCjGWrQ+4K3SRvfk=; b=oA4qEwknshgmpG3aNsh7YJz7B3TUfJBzPUJCGkpw94pQOF0PaCnrvkr0nmuS8tsuXbzOfPeKq2/IQfAnRuVhTdt1rxs1cYKe+cz794fNJi9cBjBnbJ90Vaoc4YaA44NdUUMjzB4ZS78TZbDa6+DKm7/tL3AIRzGHSqfjIy7zF98= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@getutm.app; 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 1764734954165270.9028901078334; Tue, 2 Dec 2025 20:09:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vQeAQ-0002Ja-Na; Tue, 02 Dec 2025 23:08:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vQeAM-0002Hq-Rn for qemu-devel@nongnu.org; Tue, 02 Dec 2025 23:08:35 -0500 Received: from a4i956.smtp2go.com ([158.120.83.188]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vQeAL-0000Tm-BL for qemu-devel@nongnu.org; Tue, 02 Dec 2025 23:08:34 -0500 Received: from [10.159.238.187] (helo=localhost.localdomain) by smtpcorp.com with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA512__CHACHA20_POLY1305:256) (Exim 4.98.1-S2G) (envelope-from ) id 1vQeA2-FnQW0hPv7oK-UTTy; Wed, 03 Dec 2025 04:08:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=getutm.app; i=@getutm.app; q=dns/txt; s=s483429; t=1764734904; h=from : subject : to : message-id : date; bh=y9kSlBF0XTESB4AkIAMB416dSilaCjGWrQ+4K3SRvfk=; b=B1ogOoXkO8Dg4uwBHeNS9EUCo+8cdmPYhNCbBA1BC4li30/H0salP249aXRuNHTZ3oQHH UlhPAf4Y/y5jwPJrsuz225JUCoMCHxvNKAHeX54+QgxeMFzfRN29MHg87YhFvANSzE8pDuJ m0e8cFySlMpRsYJjcCvCfTIS8Hfx0HVwwo4f39UXlbT3+wYuJJ5XUamv//TPWhDGMouYZK2 TqusXcReY9nWB+q4GirA0jrzFuysJfuJgzq6Rfgsg6949clHvRAUDoBtAvcIPkGtly3IvFt IfYyK6JSKN10yDHrdSP9RJ4qwjs7+hsGhkZaxlyMF8t8NrUuBbYnZ9zKtq5g== From: Joelle van Dyne To: qemu-devel@nongnu.org Cc: Joelle van Dyne , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Akihiko Odaki , Dmitry Osipenko , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH RFC 5/7] virtio-gpu-virgl: support scanout of Metal textures Date: Tue, 2 Dec 2025 20:07:52 -0800 Message-ID: <20251203040754.94487-6-j@getutm.app> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20251203040754.94487-1-j@getutm.app> References: <20251203040754.94487-1-j@getutm.app> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Report-Abuse: Please forward a copy of this message, including all headers, to Feedback-ID: 483429m:483429abrvJvs:483429sRlcTQnisq X-smtpcorp-track: dv_CflWhdwOb.innxFtf1XVAI.O0bLQAj_GoV 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=158.120.83.188; envelope-from=bounce.k4ef0d26m0hjpq5=lta69ff2eskf=qk5ki1l7zbdzhh@em483429.getutm.app; helo=a4i956.smtp2go.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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 @getutm.app) X-ZM-MESSAGEID: 1764734955894019200 Content-Type: text/plain; charset="utf-8" When supported, virglrenderer will return a MTLTexture handle that can be directly used for scanout. Signed-off-by: Joelle van Dyne --- meson.build | 4 ++++ include/ui/console.h | 2 ++ hw/display/virtio-gpu-virgl.c | 12 +++++++++++- hw/display/virtio-gpu.c | 2 ++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index d9293294d8..05bad66376 100644 --- a/meson.build +++ b/meson.build @@ -832,6 +832,7 @@ version_res =3D [] coref =3D [] iokit =3D [] pvg =3D not_found +metal =3D not_found emulator_link_args =3D [] midl =3D not_found widl =3D not_found @@ -859,6 +860,7 @@ elif host_os =3D=3D 'darwin' host_dsosuf =3D '.dylib' pvg =3D dependency('appleframeworks', modules: ['ParavirtualizedGraphics= ', 'Metal'], required: get_option('pvg')) + metal =3D dependency('appleframeworks', modules: 'Metal', required: fals= e) elif host_os =3D=3D 'sunos' socket =3D [cc.find_library('socket'), cc.find_library('nsl'), @@ -2591,6 +2593,7 @@ if xen.found() ('0' + xen_version[2]).substring(-2) config_host_data.set('CONFIG_XEN_CTRL_INTERFACE_VERSION', xen_ctrl_versi= on) endif +config_host_data.set('CONFIG_METAL', metal.found()) config_host_data.set('QEMU_VERSION', '"@0@"'.format(meson.project_version(= ))) config_host_data.set('QEMU_VERSION_MAJOR', meson.project_version().split('= .')[0]) config_host_data.set('QEMU_VERSION_MINOR', meson.project_version().split('= .')[1]) @@ -4874,6 +4877,7 @@ summary(summary_info, bool_yn: true, section: 'Crypto= ') summary_info =3D {} if host_os =3D=3D 'darwin' summary_info +=3D {'Cocoa support': cocoa} + summary_info +=3D {'Metal support': metal} endif summary_info +=3D {'D-Bus display': dbus_display} summary_info +=3D {'SDL support': sdl} diff --git a/include/ui/console.h b/include/ui/console.h index 25e45295d4..a45b524c57 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -134,12 +134,14 @@ struct QemuConsoleClass { typedef enum ScanoutTextureNativeType { SCANOUT_TEXTURE_NATIVE_TYPE_NONE, SCANOUT_TEXTURE_NATIVE_TYPE_D3D, + SCANOUT_TEXTURE_NATIVE_TYPE_METAL, } ScanoutTextureNativeType; =20 typedef struct ScanoutTextureNative { ScanoutTextureNativeType type; union { void *d3d_tex2d; + void *metal_texture; } u; } ScanoutTextureNative; =20 diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index 36c670f988..e091eb0c76 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -452,6 +452,13 @@ static void virgl_cmd_set_scanout(VirtIOGPU *g, #if VIRGL_RENDERER_RESOURCE_INFO_EXT_VERSION >=3D SUPPORTED_VIRGL_INFO_EXT= _VERSION if (ext.version >=3D VIRGL_RENDERER_RESOURCE_INFO_EXT_VERSION) { switch (ext.native_type) { +#ifdef CONFIG_METAL + case VIRGL_NATIVE_HANDLE_METAL_TEXTURE: { + native.type =3D SCANOUT_TEXTURE_NATIVE_TYPE_METAL; + native.u.metal_texture =3D ext.native_handle; + break; + } +#endif case VIRGL_NATIVE_HANDLE_NONE: case VIRGL_NATIVE_HANDLE_D3D_TEX2D: { /* already handled above */ @@ -1198,7 +1205,10 @@ int virtio_gpu_virgl_init(VirtIOGPU *g) } #if VIRGL_VERSION_MAJOR >=3D 1 if (virtio_gpu_venus_enabled(g->parent_obj.conf)) { - flags |=3D VIRGL_RENDERER_VENUS | VIRGL_RENDERER_RENDER_SERVER; + flags |=3D VIRGL_RENDERER_VENUS; +#ifndef CONFIG_METAL /* Metal does not support render server */ + flags |=3D VIRGL_RENDERER_RENDER_SERVER; +#endif } #endif =20 diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 43e88a4daf..9cf2c15a43 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1485,12 +1485,14 @@ void virtio_gpu_device_realize(DeviceState *qdev, E= rror **errp) VirtIOGPU *g =3D VIRTIO_GPU(qdev); =20 if (virtio_gpu_blob_enabled(g->parent_obj.conf)) { +#ifndef CONFIG_METAL if (!virtio_gpu_rutabaga_enabled(g->parent_obj.conf) && !virtio_gpu_virgl_enabled(g->parent_obj.conf) && !virtio_gpu_have_udmabuf()) { error_setg(errp, "need rutabaga or udmabuf for blob resources"= ); return; } +#endif =20 #ifdef VIRGL_VERSION_MAJOR #if VIRGL_VERSION_MAJOR < 1 --=20 2.41.0 From nobody Sat Dec 6 23:32:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@getutm.app; 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=getutm.app ARC-Seal: i=1; a=rsa-sha256; t=1764734972; cv=none; d=zohomail.com; s=zohoarc; b=en5/PtjVLJbW5ocWKF9ppT7UsRxQwlHa5diYbPFOCNZrxVGoF0OBOlutGDadmhlVohVkALlwpFUc5+phH7NWAEVREZbosT5HLigcAnsjBhicdQ/kITjrrhmNik/867m7b370dVNX0fJyOJiwh2Cy/CPhdamyLT/m4GSipkvD48g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764734972; h=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=XYbku66ggetTXXScTxzERv3tWMvWPJzx0u8sArlejVU=; b=ChUG/lgriZ8xGjyPfhBqCXYRWpVZQ9RI5u14TvbuBQEgCdf43MgydfdgjqkbI44/3Em7ecgh+jkJXN+Sy6zd46e5S3vAyZzCRIJ6kxf9mOrEpf8RJVxRq5nt9kAvu8N8bXWjt3sH8KQrEb0hxqnaCTOTDDjxBYY4nniR6v51NBs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@getutm.app; 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 1764734972721323.5790439675478; Tue, 2 Dec 2025 20:09:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vQeAO-0002IW-Rt; Tue, 02 Dec 2025 23:08:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vQeAM-0002Hp-LN for qemu-devel@nongnu.org; Tue, 02 Dec 2025 23:08:34 -0500 Received: from a4i956.smtp2go.com ([158.120.83.188]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vQeAL-0000X4-07 for qemu-devel@nongnu.org; Tue, 02 Dec 2025 23:08:34 -0500 Received: from [10.159.238.187] (helo=localhost.localdomain) by smtpcorp.com with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA512__CHACHA20_POLY1305:256) (Exim 4.98.1-S2G) (envelope-from ) id 1vQeA4-FnQW0hPv7oK-Vio3; Wed, 03 Dec 2025 04:08:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=getutm.app; i=@getutm.app; q=dns/txt; s=s483429; t=1764734901; h=from : subject : to : message-id : date; bh=XYbku66ggetTXXScTxzERv3tWMvWPJzx0u8sArlejVU=; b=frj/DBPeRIkTBpYxPlTg65JYGc4x2RlGcVnNwGRM3wqCewFb87jLPA7/zX21XX//l0m++ eqYaxGTmoR/vN+gLdbuz+qilHc3fFw801ti4bjC+5W5y30bwjYDL9TwQ+bKI48RAzCQ6v2n qV2atDaT1y0sN6AF5RdLb6gQGF1CETyrJ18bcFeOdCiBCy1OZ5LY3nb5Rf9TDHQu5/5pmyt UDntg+8d/C1a62gGeZCi9eJ/KdDPIrtPmbowISAF8Bgc2PWXR+2yBcxA8YnK6WdgeA1hk3y jRyrRJvVRvdLVJWHLL4a/87QK92zGKG7vSRevUQ/j0OW46bcw6QOS8APIOnQ== From: Joelle van Dyne To: qemu-devel@nongnu.org Cc: Joelle van Dyne , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Akihiko Odaki , Dmitry Osipenko , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH RFC 6/7] console: add cleanup callback for ScanoutTexture Date: Tue, 2 Dec 2025 20:07:53 -0800 Message-ID: <20251203040754.94487-7-j@getutm.app> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20251203040754.94487-1-j@getutm.app> References: <20251203040754.94487-1-j@getutm.app> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Report-Abuse: Please forward a copy of this message, including all headers, to Feedback-ID: 483429m:483429abrvJvs:483429sV8GMzK9wO X-smtpcorp-track: isIJ-mkK3n_R.fTP_atPLNlyE.W9qylQLHPyK 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=158.120.83.188; envelope-from=bounce.kdc83qoplvz4bg6=ssvilxbcuwhy=l7jdvdlr8nd3t7@em483429.getutm.app; helo=a4i956.smtp2go.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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 @getutm.app) X-ZM-MESSAGEID: 1764734975976019200 Content-Type: text/plain; charset="utf-8" Before we introduce changes that allow for QemuConsole to take ownership of a texture handle, we need scaffolding that will allow us to callback into a cleanup function any time the ScanoutTexture becomes invalid, which is whenever the `scanout.kind` or `scanout.texture` gets updated. The ordering is important: we need to first update the DisplayScanout, then we need to notify all the listeners, and once all the listeners have had the chance to finish using the previous native texture, we are safe to call the cleanup function. This means we need to hold on to the previous scanout native handle locally until all listeners are notified. Signed-off-by: Joelle van Dyne --- include/ui/console.h | 9 +++++- hw/display/virtio-gpu-virgl.c | 2 +- ui/console.c | 56 +++++++++++++++++++++++++++++++---- 3 files changed, 59 insertions(+), 8 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index a45b524c57..df9c083a16 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -149,6 +149,11 @@ typedef struct ScanoutTextureNative { .type =3D SCANOUT_TEXTURE_NATIVE_TYPE_NONE \ }) =20 +/** + * Cleanup callback function when ScanoutTexture is about to be destroyed + */ +typedef void (*dpy_cleanup_texture)(ScanoutTextureNative *native); + typedef struct ScanoutTexture { uint32_t backing_id; bool backing_y_0_top; @@ -159,6 +164,7 @@ typedef struct ScanoutTexture { uint32_t width; uint32_t height; ScanoutTextureNative native; + dpy_cleanup_texture cb_cleanup; } ScanoutTexture; =20 typedef struct QemuUIInfo { @@ -347,7 +353,8 @@ void dpy_gl_scanout_texture(QemuConsole *con, uint32_t backing_id, bool backing_y_0_top, uint32_t backing_width, uint32_t backing_heigh= t, uint32_t x, uint32_t y, uint32_t w, uint32_t h, - ScanoutTextureNative native); + ScanoutTextureNative native, + dpy_cleanup_texture cb_cleanup); void dpy_gl_scanout_dmabuf(QemuConsole *con, QemuDmaBuf *dmabuf); void dpy_gl_cursor_dmabuf(QemuConsole *con, QemuDmaBuf *dmabuf, diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index e091eb0c76..b7bc095676 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -492,7 +492,7 @@ static void virgl_cmd_set_scanout(VirtIOGPU *g, info.flags & VIRTIO_GPU_RESOURCE_FLAG_Y_0_TOP, info.width, info.height, ss.r.x, ss.r.y, ss.r.width, ss.r.height, - native); + native, NULL); } else { dpy_gfx_replace_surface( g->parent_obj.scanout[ss.scanout_id].con, NULL); diff --git a/ui/console.c b/ui/console.c index 9378afd53d..8271c36586 100644 --- a/ui/console.c +++ b/ui/console.c @@ -808,6 +808,41 @@ void dpy_gfx_update_full(QemuConsole *con) dpy_gfx_update(con, 0, 0, w, h); } =20 +struct scanout_change { + ScanoutTextureNative native; + dpy_cleanup_texture cb_cleanup; +}; + +#define SCANOUT_CHANGE_NONE ((struct scanout_change){ NO_NATIVE_TEXTURE }) + +static struct scanout_change dpy_change_scanout_kind(DisplayScanout *scano= ut, + enum display_scanout = kind) +{ + struct scanout_change change =3D SCANOUT_CHANGE_NONE; + + /** + * We cannot cleanup until the resource is no longer in use, so we rec= ord it + * You MUST call dpy_complete_scanout_change after all listeners are u= pdated + */ + if (scanout->kind =3D=3D SCANOUT_TEXTURE && scanout->texture.cb_cleanu= p) { + change.native =3D scanout->texture.native; + change.cb_cleanup =3D scanout->texture.cb_cleanup; + } + scanout->kind =3D kind; + + return change; +} + +static void dpy_complete_scanout_change(struct scanout_change *change) +{ + /** + * If we previously have a texture and cleanup is required, we call it= now + */ + if (change->native.type !=3D SCANOUT_TEXTURE_NATIVE_TYPE_NONE && chang= e->cb_cleanup) { + change->cb_cleanup(&change->native); + } +} + void dpy_gfx_replace_surface(QemuConsole *con, DisplaySurface *surface) { @@ -818,6 +853,7 @@ void dpy_gfx_replace_surface(QemuConsole *con, DisplayChangeListener *dcl; int width; int height; + struct scanout_change change =3D SCANOUT_CHANGE_NONE; =20 if (!surface) { if (old_surface) { @@ -833,7 +869,7 @@ void dpy_gfx_replace_surface(QemuConsole *con, =20 assert(old_surface !=3D new_surface); =20 - con->scanout.kind =3D SCANOUT_SURFACE; + change =3D dpy_change_scanout_kind(&con->scanout, SCANOUT_SURFACE); con->surface =3D new_surface; dpy_gfx_create_texture(con, new_surface); QLIST_FOREACH(dcl, &s->listeners, next) { @@ -844,6 +880,7 @@ void dpy_gfx_replace_surface(QemuConsole *con, } dpy_gfx_destroy_texture(con, old_surface); qemu_free_displaysurface(old_surface); + dpy_complete_scanout_change(&change); } =20 bool dpy_gfx_check_format(QemuConsole *con, @@ -1002,9 +1039,10 @@ void dpy_gl_scanout_disable(QemuConsole *con) { DisplayState *s =3D con->ds; DisplayChangeListener *dcl; + struct scanout_change change =3D SCANOUT_CHANGE_NONE; =20 if (con->scanout.kind !=3D SCANOUT_SURFACE) { - con->scanout.kind =3D SCANOUT_NONE; + change =3D dpy_change_scanout_kind(&con->scanout, SCANOUT_NONE); } QLIST_FOREACH(dcl, &s->listeners, next) { if (con !=3D dcl->con) { @@ -1014,6 +1052,7 @@ void dpy_gl_scanout_disable(QemuConsole *con) dcl->ops->dpy_gl_scanout_disable(dcl); } } + dpy_complete_scanout_change(&change); } =20 void dpy_gl_scanout_texture(QemuConsole *con, @@ -1023,15 +1062,17 @@ void dpy_gl_scanout_texture(QemuConsole *con, uint32_t backing_height, uint32_t x, uint32_t y, uint32_t width, uint32_t height, - ScanoutTextureNative native) + ScanoutTextureNative native, + dpy_cleanup_texture cb_cleanup) { DisplayState *s =3D con->ds; DisplayChangeListener *dcl; + struct scanout_change change =3D SCANOUT_CHANGE_NONE; =20 - con->scanout.kind =3D SCANOUT_TEXTURE; + change =3D dpy_change_scanout_kind(&con->scanout, SCANOUT_TEXTURE); con->scanout.texture =3D (ScanoutTexture) { backing_id, backing_y_0_top, backing_width, backing_height, - x, y, width, height, native, + x, y, width, height, native, cb_cleanup }; QLIST_FOREACH(dcl, &s->listeners, next) { if (con !=3D dcl->con) { @@ -1045,6 +1086,7 @@ void dpy_gl_scanout_texture(QemuConsole *con, native); } } + dpy_complete_scanout_change(&change); } =20 void dpy_gl_scanout_dmabuf(QemuConsole *con, @@ -1052,8 +1094,9 @@ void dpy_gl_scanout_dmabuf(QemuConsole *con, { DisplayState *s =3D con->ds; DisplayChangeListener *dcl; + struct scanout_change change =3D SCANOUT_CHANGE_NONE; =20 - con->scanout.kind =3D SCANOUT_DMABUF; + change =3D dpy_change_scanout_kind(&con->scanout, SCANOUT_DMABUF); con->scanout.dmabuf =3D dmabuf; QLIST_FOREACH(dcl, &s->listeners, next) { if (con !=3D dcl->con) { @@ -1063,6 +1106,7 @@ void dpy_gl_scanout_dmabuf(QemuConsole *con, dcl->ops->dpy_gl_scanout_dmabuf(dcl, dmabuf); } } + dpy_complete_scanout_change(&change); } =20 void dpy_gl_cursor_dmabuf(QemuConsole *con, QemuDmaBuf *dmabuf, --=20 2.41.0 From nobody Sat Dec 6 23:32:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@getutm.app; 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=getutm.app ARC-Seal: i=1; a=rsa-sha256; t=1764734992; cv=none; d=zohomail.com; s=zohoarc; b=iwRmXzyGM/jyDNVOttWKD4YcXRDmuXul95vSd4JuLVtOePV5hzEJLMVoS+3tD1q+lLAVIQUE6jtpx8bKgZr75Fx6tAVe5c2Dv7LD0L2CDhS4YaptLBHDYU5QU6S1z9MQD6n5yFPWwxMEqcPl/1pca9GKrbaaiO8AIX7x/IreLIA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764734992; h=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=suFTTcyRrb4wIFWQkIjPO8ClOthN7ZNFt0MXu8KCaK4=; b=ltAUdtYlhybi3m2MOB3dDMkVE9NknEixcOV4tgOTl4rbBF1uBlzeM0v+zG5gRKD+CQOyDWdSxKzJiAj06Mr3PbWIG+9KkPX+vdBETDRcQMoAmF0rzTWgYZp2/NTGgMQfX5Q2IQs5R6VnlskU8CRgqFdE2iXtZ11/C4+4Ss+z/x4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@getutm.app; 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 1764734992152520.9755834193858; Tue, 2 Dec 2025 20:09:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vQeAX-0002LW-CX; Tue, 02 Dec 2025 23:08:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vQeAV-0002LH-F1 for qemu-devel@nongnu.org; Tue, 02 Dec 2025 23:08:43 -0500 Received: from a4i956.smtp2go.com ([158.120.83.188]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vQeAT-0000Z2-T2 for qemu-devel@nongnu.org; Tue, 02 Dec 2025 23:08:43 -0500 Received: from [10.159.238.187] (helo=localhost.localdomain) by smtpcorp.com with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA512__CHACHA20_POLY1305:256) (Exim 4.98.1-S2G) (envelope-from ) id 1vQeA8-FnQW0hPv7oK-TUF2; Wed, 03 Dec 2025 04:08:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=getutm.app; i=@getutm.app; q=dns/txt; s=s483429; t=1764734918; h=from : subject : to : message-id : date; bh=suFTTcyRrb4wIFWQkIjPO8ClOthN7ZNFt0MXu8KCaK4=; b=dwkyVuQBH0Agd+f28KPBg4VGFrtQWdgXdzFwOoUXSU3pekvUXny1BmOsfEZTRHzfUA2FF vXFNeHs/MkzymALWvNw5OcFBPhgck74LbscC1jOkCuKxNWSLZqsicJ7PNyd94UW60HYu+3a ISzmWKIZBWDKtVx3E4oSuvx7UwQAzhMtuqv2ofNtQ4mCLvWDLcEVeCgXNi4d3pxV/P0l7gm FleHkiLJ2NGtzohDV4uCUN6D3QcP93/IVtjhr9aA5g9bC3Ne/v2awN3T0b3/knItuncUDih kEaRB+ZVKMfdE8s4izPA9Dbg/e1Fp6NmH8LT0L/IWhnBgFSRyvmucr5S2L5A== From: Joelle van Dyne To: qemu-devel@nongnu.org Cc: Joelle van Dyne , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Akihiko Odaki , Dmitry Osipenko , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH RFC 7/7] virtio-gpu-virgl: add support for native blob scanout Date: Tue, 2 Dec 2025 20:07:54 -0800 Message-ID: <20251203040754.94487-8-j@getutm.app> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20251203040754.94487-1-j@getutm.app> References: <20251203040754.94487-1-j@getutm.app> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Report-Abuse: Please forward a copy of this message, including all headers, to Feedback-ID: 483429m:483429abrvJvs:483429sk55hBs0o3 X-smtpcorp-track: dizaJlnuAy8G.7LaSsQcmtKZV.-aehGwppW8Y 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=158.120.83.188; envelope-from=bounce.0wkqiohjvv6lnp5=o30qfjovfq01=g4o3xh0oiya3c7@em483429.getutm.app; helo=a4i956.smtp2go.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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 @getutm.app) X-ZM-MESSAGEID: 1764734993553019200 Content-Type: text/plain; charset="utf-8" On macOS we do not have dmabuf and so we use MTLTexture as our scanout source. For blob scanout, the buffer is untyped and so we cannot get a MTLTexture until we pass more information to virglrenderer (surface size, pixel format, etc). The new API to do this is currently unstable so we need to define `VIRGL_RENDERER_UNSTABLE_APIS`. This should be removed after the ABI becomes stable. Signed-off-by: Joelle van Dyne --- meson.build | 5 +++ hw/display/virtio-gpu-virgl.c | 60 +++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/meson.build b/meson.build index 05bad66376..8917aff044 100644 --- a/meson.build +++ b/meson.build @@ -2549,6 +2549,11 @@ config_host_data.set('CONFIG_VNC', vnc.found()) config_host_data.set('CONFIG_VNC_JPEG', jpeg.found()) config_host_data.set('CONFIG_VNC_SASL', sasl.found()) if virgl.found() + config_host_data.set('HAVE_VIRGL_RENDERER_NATIVE_SCANOUT', + cc.has_function('virgl_renderer_create_handle_for_= scanout', + args: '-DVIRGL_RENDERER_UNSTABLE_A= PIS', + prefix: '#include ', + dependencies: virgl)) config_host_data.set('VIRGL_VERSION_MAJOR', virgl.version().split('.')[0= ]) endif config_host_data.set('CONFIG_VIRTFS', have_virtfs) diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index b7bc095676..3ef37645ca 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -22,6 +22,7 @@ =20 #include "ui/egl-helpers.h" =20 +#define VIRGL_RENDERER_UNSTABLE_APIS #include =20 #define SUPPORTED_VIRGL_INFO_EXT_VERSION (1) @@ -848,6 +849,59 @@ static void virgl_cmd_resource_unmap_blob(VirtIOGPU *g, } } =20 +#if defined(HAVE_VIRGL_RENDERER_NATIVE_SCANOUT) +static void virgl_scanout_native_blob_cleanup(ScanoutTextureNative *native) +{ + assert(native->type =3D=3D SCANOUT_TEXTURE_NATIVE_TYPE_METAL); + virgl_renderer_release_handle_for_scanout(VIRGL_NATIVE_HANDLE_METAL_TE= XTURE, + native->u.metal_texture); +} + +static bool virgl_scanout_native_blob(VirtIOGPU *g, + struct virtio_gpu_set_scanout_blob *= ss) +{ + struct virtio_gpu_scanout *scanout =3D &g->parent_obj.scanout[ss->scan= out_id]; + enum virgl_renderer_native_handle_type type; + virgl_renderer_native_handle handle; + ScanoutTextureNative native; + + type =3D virgl_renderer_create_handle_for_scanout(ss->resource_id, + ss->width, + ss->height, + ss->format, + ss->padding, + ss->strides[0], + ss->offsets[0], + &handle); +#ifdef CONFIG_METAL + if (type =3D=3D VIRGL_NATIVE_HANDLE_METAL_TEXTURE) { + native =3D (ScanoutTextureNative){ + .type =3D SCANOUT_TEXTURE_NATIVE_TYPE_METAL, + .u.metal_texture =3D handle, + }; + qemu_console_resize(scanout->con, + ss->r.width, ss->r.height); + dpy_gl_scanout_texture( + scanout->con, 0, + false, + ss->width, ss->height, + ss->r.x, ss->r.y, ss->r.width, ss->r.height, + native, virgl_scanout_native_blob_cleanup); + scanout->resource_id =3D ss->resource_id; + + return true; + } +#endif + + /* don't leak memory if handle type is unknown */ + if (type !=3D VIRGL_NATIVE_HANDLE_NONE) { + virgl_renderer_release_handle_for_scanout(type, handle); + } + + return false; +} +#endif + static void virgl_cmd_set_scanout_blob(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd) { @@ -886,6 +940,12 @@ static void virgl_cmd_set_scanout_blob(VirtIOGPU *g, return; } =20 +#if defined(HAVE_VIRGL_RENDERER_NATIVE_SCANOUT) + if (virgl_scanout_native_blob(g, &ss)) { + return; + } +#endif + res =3D virtio_gpu_virgl_find_resource(g, ss.resource_id); if (!res) { qemu_log_mask(LOG_GUEST_ERROR, "%s: resource does not exist %d\n", --=20 2.41.0