From nobody Sun Dec 7 00:30:45 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