From f692b4de080a8a8bf0750b3e5ce38ccec30b6d74 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Sun, 1 Nov 2026 12:29:07 -0800 Subject: [PATCH] :bug: Answer the device's feature profile and FP configs from the host WindowServer asks our device featureProfile at start (boot 3 logged it ten times). SkyLight also names halfFPConfig, singleFPConfig, doubleFPConfig and gpuCoreCount. The device's catch-all answered 0 for each; Metal's device answers the GPU's own values (the M3 Max: 10, 0xe, 0x54, 0 and 40). The device info now carries the four MTLDeviceSPI values as identity sizes, taken by calling the API: - Metal platform: the host device's own answers, asked after respondsToSelector:. - Vulkan platform: on macOS, Metal's answers for the GPU Metal's registry ID names. Everywhere else, the M3 Max's measured values, the one device they are measured on, since no Vulkan query reports them. The bundle's device answers the four from the blob, and gpuCoreCount, as unsigned int, from the count the blob already held. The blob grows by 32 bytes, so its version goes to 3. The kext copies sizeof(RgfxDeviceInfo), so the host, kext and bundle ship together. --- .../include/reims_graphics_wire.h | 10 ++-- crates/reims-graphics/src/wire.rs | 20 ++++---- crates/reims-vgpu-core/src/platform/caps.rs | 8 ++- .../src/testkit/impls/device.rs | 4 ++ crates/reims-vgpu-metal/src/gpu/device.rs | 38 +++++++++++++- crates/reims-vgpu-metal/src/spi/methods.rs | 12 +++++ .../reims-vgpu-metal/tests/spi_encodings.rs | 6 ++- crates/reims-vgpu-vulkan/src/gpu/identity.rs | 49 +++++++++++++++++++ crates/reims-vgpu-vulkan/src/os.rs | 4 +- crates/reims-vgpu-vulkan/src/os/linux.rs | 6 +++ crates/reims-vgpu-vulkan/src/os/macos.rs | 19 +++++++ crates/reims-vgpu/src/graphics/device_info.rs | 8 ++- guest/bundle/src/RgfxCaps.hpp | 6 ++- guest/bundle/src/RgfxMetalDevice.mm | 30 ++++++++++++ guest/bundle/src/RgfxWireLayout.cpp | 8 +-- guest/bundle/tools/window_probe.m | 2 +- 16 files changed, 202 insertions(+), 28 deletions(-) diff --git a/crates/reims-graphics/include/reims_graphics_wire.h b/crates/reims-graphics/include/reims_graphics_wire.h index cc0789610..56a52491f 100644 --- a/crates/reims-graphics/include/reims_graphics_wire.h +++ b/crates/reims-graphics/include/reims_graphics_wire.h @@ -1140,7 +1140,7 @@ #define RGFX_LIBRARY_FLAG_KEYED 1 // The version of the [`RgfxDeviceInfo`] layout the host writes. -#define RGFX_DEVICE_INFO_VERSION 2 +#define RGFX_DEVICE_INFO_VERSION 3 // The most bytes of a device name [`RgfxDeviceInfo`] carries: Vulkan's // `VK_MAX_PHYSICAL_DEVICE_NAME_SIZE`, so no host GPU's name is cut short. @@ -1156,7 +1156,7 @@ #define RGFX_DEVICE_INFO_FEATURE_SETS 32 // The integer identity answers [`RgfxDeviceInfo::sizes`] holds. -#define RGFX_DEVICE_INFO_SIZES 15 +#define RGFX_DEVICE_INFO_SIZES 19 // The `BOOL` identity answers [`RgfxDeviceInfo::identity_flags`] holds. #define RGFX_DEVICE_INFO_IDENTITY_FLAGS 19 @@ -2475,8 +2475,8 @@ typedef struct { // last); the host fills them in that order. uint64_t limits[27]; // The integer identity answers, in the host `IdentitySizes` field order - // (`recommended_max_working_set_size` first, - // `largest_rasterization_rate_map_layer_count` last); 0 on a gap. + // (`recommended_max_working_set_size` first, `double_fp_config` last); 0 + // on a gap. uint64_t sizes[RGFX_DEVICE_INFO_SIZES]; // The raw `MTLGPUFamily` values `family_answers` answers, by position. int64_t family_values[RGFX_DEVICE_INFO_FAMILIES]; @@ -2506,7 +2506,7 @@ typedef struct { // boundaries by position; a gap reads 0. uint8_t counter_sampling[RGFX_DEVICE_INFO_COUNTER_POINTS]; // Zero. - uint8_t reserved_431[7]; + uint8_t reserved_451[7]; // The device `name`, UTF-8, `name_len` bytes used, the rest 0. uint8_t name[RGFX_DEVICE_NAME_LEN]; // The device's `architecture.name`, UTF-8, `architecture_name_len` bytes diff --git a/crates/reims-graphics/src/wire.rs b/crates/reims-graphics/src/wire.rs index 70f400614..5518d3e40 100644 --- a/crates/reims-graphics/src/wire.rs +++ b/crates/reims-graphics/src/wire.rs @@ -1709,7 +1709,7 @@ pub struct RgfxLibraryLookup { } /// The version of the [`RgfxDeviceInfo`] layout the host writes. -pub const RGFX_DEVICE_INFO_VERSION: u32 = 2; +pub const RGFX_DEVICE_INFO_VERSION: u32 = 3; /// The most bytes of a device name [`RgfxDeviceInfo`] carries: Vulkan's /// `VK_MAX_PHYSICAL_DEVICE_NAME_SIZE`, so no host GPU's name is cut short. @@ -1725,7 +1725,7 @@ pub const RGFX_DEVICE_INFO_FAMILIES: usize = 32; pub const RGFX_DEVICE_INFO_FEATURE_SETS: usize = 32; /// The integer identity answers [`RgfxDeviceInfo::sizes`] holds. -pub const RGFX_DEVICE_INFO_SIZES: usize = 15; +pub const RGFX_DEVICE_INFO_SIZES: usize = 19; /// The `BOOL` identity answers [`RgfxDeviceInfo::identity_flags`] holds. pub const RGFX_DEVICE_INFO_IDENTITY_FLAGS: usize = 19; @@ -1802,8 +1802,8 @@ pub struct RgfxDeviceInfo { /// last); the host fills them in that order. pub limits: [u64; 27], /// The integer identity answers, in the host `IdentitySizes` field order - /// (`recommended_max_working_set_size` first, - /// `largest_rasterization_rate_map_layer_count` last); 0 on a gap. + /// (`recommended_max_working_set_size` first, `double_fp_config` last); 0 + /// on a gap. pub sizes: [u64; RGFX_DEVICE_INFO_SIZES], /// The raw `MTLGPUFamily` values `family_answers` answers, by position. pub family_values: [i64; RGFX_DEVICE_INFO_FAMILIES], @@ -1833,7 +1833,7 @@ pub struct RgfxDeviceInfo { /// boundaries by position; a gap reads 0. pub counter_sampling: [u8; RGFX_DEVICE_INFO_COUNTER_POINTS], /// Zero. - pub reserved_431: [u8; 7], + pub reserved_451: [u8; 7], /// The device `name`, UTF-8, `name_len` bytes used, the rest 0. pub name: [u8; RGFX_DEVICE_NAME_LEN], /// The device's `architecture.name`, UTF-8, `architecture_name_len` bytes @@ -2247,10 +2247,10 @@ const _: () = { assert!(size_of::() == 32); assert!(RGFX_LIBRARY_BYTES_OFFSET as usize == size_of::()); assert!(size_of::() == 64); - assert!(size_of::() == 1400 + 64 * RGFX_DEVICE_INFO_FORMATS); - assert!(core::mem::offset_of!(RgfxDeviceInfo, formats) == 1400); - assert!(core::mem::offset_of!(RgfxDeviceInfo, family_answers) == 944); - assert!(core::mem::offset_of!(RgfxDeviceInfo, name) == 1080); + assert!(size_of::() == 1432 + 64 * RGFX_DEVICE_INFO_FORMATS); + assert!(core::mem::offset_of!(RgfxDeviceInfo, formats) == 1432); + assert!(core::mem::offset_of!(RgfxDeviceInfo, family_answers) == 976); + assert!(core::mem::offset_of!(RgfxDeviceInfo, name) == 1112); // The device-info blob sits past the completion ring and before the allocations. assert!( RGFX_DEVICE_INFO_OFFSET @@ -2431,7 +2431,7 @@ mod tests { info.format_count = 1; info.formats[0].format = 80; info.formats[0].sparse_tiles[0] = [64, 64, 1]; - assert_eq!(info.as_bytes().len(), 1400 + 64 * RGFX_DEVICE_INFO_FORMATS); + assert_eq!(info.as_bytes().len(), 1432 + 64 * RGFX_DEVICE_INFO_FORMATS); assert_eq!( RgfxDeviceInfo::read_from_bytes(info.as_bytes()).unwrap(), info diff --git a/crates/reims-vgpu-core/src/platform/caps.rs b/crates/reims-vgpu-core/src/platform/caps.rs index 12f837226..fdec340a4 100644 --- a/crates/reims-vgpu-core/src/platform/caps.rs +++ b/crates/reims-vgpu-core/src/platform/caps.rs @@ -225,7 +225,9 @@ pub struct FormatAnswers { caps_struct! { /// The device's identity and size answers [`IdentityCaps`] holds, one field per selector: - /// `None` where the platform has no answer of its own. + /// `None` where the platform has no answer of its own. The last four are `MTLDeviceSPI`'s + /// `featureProfile`, `halfFPConfig`, `singleFPConfig` and `doubleFPConfig`, which SkyLight + /// asks (measured on the M3 Max, macOS 27: 10, 0xe, 0x54 and 0). IdentitySizes: Option; recommended_max_working_set_size, location, @@ -242,6 +244,10 @@ caps_struct! { maximum_concurrent_compilation_task_count, largest_vertex_amplification_count, largest_rasterization_rate_map_layer_count, + feature_profile, + half_fp_config, + single_fp_config, + double_fp_config, } caps_struct! { diff --git a/crates/reims-vgpu-core/src/testkit/impls/device.rs b/crates/reims-vgpu-core/src/testkit/impls/device.rs index 568271591..984e5b2dd 100644 --- a/crates/reims-vgpu-core/src/testkit/impls/device.rs +++ b/crates/reims-vgpu-core/src/testkit/impls/device.rs @@ -947,6 +947,10 @@ pub fn fake_identity_caps() -> IdentityCaps { maximum_concurrent_compilation_task_count: Some(16), largest_vertex_amplification_count: Some(8), largest_rasterization_rate_map_layer_count: Some(2), + feature_profile: Some(10), + half_fp_config: Some(0xe), + single_fp_config: Some(0x54), + double_fp_config: Some(0), }, flags: IdentityFlags { is_low_power: Some(false), diff --git a/crates/reims-vgpu-metal/src/gpu/device.rs b/crates/reims-vgpu-metal/src/gpu/device.rs index 91a59b4b4..3581a35b9 100644 --- a/crates/reims-vgpu-metal/src/gpu/device.rs +++ b/crates/reims-vgpu-metal/src/gpu/device.rs @@ -23,7 +23,7 @@ use std::sync::{Arc, LazyLock}; use block2::{Block, RcBlock}; use dispatch2::{DispatchData, DispatchRetained, dispatch_block_t}; use objc2::rc::Retained; -use objc2::runtime::{AnyObject, NSObjectProtocol, ProtocolObject}; +use objc2::runtime::{AnyObject, NSObjectProtocol, ProtocolObject, Sel}; use objc2::{AnyThread as _, Message, sel}; use objc2_foundation::{NSData, NSError}; use objc2_metal::{MTLDevice, MTLGPUFamily, MTLPixelFormat, MTLResourceOptions}; @@ -931,6 +931,17 @@ fn gpu_core_count(d: &ProtocolObject) -> Option { Some(u64::from(n)) } +/// An `MTLDeviceSPI` getter answering `Q@:`, sent as `get` where the device responds to `sel`; +/// `None` where it does not, and then only `respondsToSelector:` is called. +fn spi_size( + d: &ProtocolObject, + sel: Sel, + name: &'static str, + get: impl FnOnce() -> u64, +) -> Option { + msg::get("respondsToSelector:", || d.respondsToSelector(sel)).then(|| msg::get(name, get)) +} + /// `heapBufferSizeAndAlignWithLength:options:`. fn heap_buffer_size_and_align( d: &ProtocolObject, @@ -1114,7 +1125,8 @@ fn format_answers(d: &ProtocolObject, format: u64) -> FormatAnswe } /// Every identity and capability answer of `device` [`IdentityCaps`] holds, each Metal's getter -/// or query, sent once. Metal answers each of them, so none is `None`. +/// or query, sent once. Metal answers each of them, so none is `None`, but for the +/// `MTLDeviceSPI` getters a device may not respond to. #[allow(deprecated)] // `supportsFeatureSet:`, `location` and the peer getters, deprecated in the SDK fn read_identity_caps(device: &MetalDevice) -> IdentityCaps { let d = device.get(); @@ -1183,6 +1195,16 @@ fn read_identity_caps(device: &MetalDevice) -> IdentityCaps { d.supportsRasterizationRateMapWithLayerCount(count) }) })), + feature_profile: spi_size(d, sel!(featureProfile), "featureProfile", || { + d.featureProfile() + }), + half_fp_config: spi_size(d, sel!(halfFPConfig), "halfFPConfig", || d.halfFPConfig()), + single_fp_config: spi_size(d, sel!(singleFPConfig), "singleFPConfig", || { + d.singleFPConfig() + }), + double_fp_config: spi_size(d, sel!(doubleFPConfig), "doubleFPConfig", || { + d.doubleFPConfig() + }), }, flags: IdentityFlags { is_low_power: Some(get!(isLowPower)), @@ -1794,6 +1816,18 @@ pub(crate) mod tests { // BC1_RGBA (130), which Metal asserts on, is not asked. let bc1 = identity.formats.iter().find(|f| f.format == 130).unwrap(); assert_eq!(bc1.texture_buffer_alignment, None); + // The driver's feature profile and FP configs, as the device answers them. + assert_eq!( + identity.sizes.feature_profile, + Some(d.get().featureProfile()) + ); + assert!(identity.sizes.feature_profile.is_some_and(|p| p >= 8)); + assert_eq!(identity.sizes.half_fp_config, Some(d.get().halfFPConfig())); + assert_eq!( + identity.sizes.single_fp_config, + Some(d.get().singleFPConfig()) + ); + assert_eq!(identity.sizes.double_fp_config, Some(0)); } /// Garbage is the NSError; a compiled metallib (the suite's one-kernel fixture) is a library diff --git a/crates/reims-vgpu-metal/src/spi/methods.rs b/crates/reims-vgpu-metal/src/spi/methods.rs index a67539486..e1042aafe 100644 --- a/crates/reims-vgpu-metal/src/spi/methods.rs +++ b/crates/reims-vgpu-metal/src/spi/methods.rs @@ -71,10 +71,19 @@ pub unsafe trait DeviceSpi: Message { fn deviceLinearTextureAlignmentBytes(&self) -> u64 { unsafe { msg_send![self, deviceLinearTextureAlignmentBytes] } } + fn doubleFPConfig(&self) -> u64 { + unsafe { msg_send![self, doubleFPConfig] } + } + fn featureProfile(&self) -> u64 { + unsafe { msg_send![self, featureProfile] } + } /// `unsigned int`, as the runtime answers (`I@:`). fn gpuCoreCount(&self) -> u32 { unsafe { msg_send![self, gpuCoreCount] } } + fn halfFPConfig(&self) -> u64 { + unsafe { msg_send![self, halfFPConfig] } + } fn iosurfaceReadOnlyTextureAlignmentBytes(&self) -> u64 { unsafe { msg_send![self, iosurfaceReadOnlyTextureAlignmentBytes] } } @@ -162,6 +171,9 @@ pub unsafe trait DeviceSpi: Message { fn maxViewportCount(&self) -> u64 { unsafe { msg_send![self, maxViewportCount] } } + fn singleFPConfig(&self) -> u64 { + unsafe { msg_send![self, singleFPConfig] } + } fn supportsBufferWithAddressRanges(&self) -> bool { unsafe { msg_send![self, supportsBufferWithAddressRanges] } } diff --git a/crates/reims-vgpu-metal/tests/spi_encodings.rs b/crates/reims-vgpu-metal/tests/spi_encodings.rs index b4848e7df..b889b3345 100644 --- a/crates/reims-vgpu-metal/tests/spi_encodings.rs +++ b/crates/reims-vgpu-metal/tests/spi_encodings.rs @@ -347,7 +347,10 @@ MTLRasterizationRateLayerDescriptor initWithSampleCount: @@:{?=QQQ} MTLResourceAddressRangeArray initWithRanges:count: @@:^{MTLAddressRange=QQ}Q MTLDevice allowLibrariesFromOtherPlatforms v@: MTLDevice deviceLinearTextureAlignmentBytes Q@: +MTLDevice doubleFPConfig Q@: +MTLDevice featureProfile Q@: MTLDevice gpuCoreCount I@: +MTLDevice halfFPConfig Q@: MTLDevice iosurfaceReadOnlyTextureAlignmentBytes Q@: MTLDevice iosurfaceTextureAlignmentBytes Q@: MTLDevice isFramebufferReadSupported B@: @@ -395,6 +398,7 @@ MTLDevice newSharedTextureWithHandle:withResourceIndex: @@:@Q MTLDevice newTextureWithDescriptor:iosurface:plane: @@:@^{__IOSurface=}Q MTLDevice newTileRenderPipelineDescriptorWithSerializedData:deserializationContext: @@:@@ MTLDevice reserveResourceIndicesForResourceType:indices:indexCount: v@:Q^QQ +MTLDevice singleFPConfig Q@: MTLDevice supportsBufferWithAddressRanges B@: MTLDevice supportsBufferWithIOSurface B@: MTLDevice supportsCommandBufferJump B@: @@ -685,7 +689,7 @@ fn every_spi_declaration_matches_the_runtime() { } } assert!(failures.is_empty(), "{}", failures.join("\n")); - assert_eq!(rows.len(), 254); + assert_eq!(rows.len(), 258); } /// The render-encoder SPI the host's AGX render encoder does not implement stays unimplemented diff --git a/crates/reims-vgpu-vulkan/src/gpu/identity.rs b/crates/reims-vgpu-vulkan/src/gpu/identity.rs index 1af26c7de..dc3ac4df6 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/identity.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/identity.rs @@ -238,9 +238,39 @@ fn pipeline_cache_uuid(device: &rt::Device) -> [u8; vk::UUID_SIZE] { } } +/// `featureProfile`, `halfFPConfig`, `singleFPConfig` and `doubleFPConfig` measured on the M3 Max +/// (macOS 27), the one device they are measured on. +const M3_MAX_DRIVER_SIZES: [u64; 4] = [10, 0xe, 0x54, 0]; + +/// `featureProfile`, `halfFPConfig`, `singleFPConfig` and `doubleFPConfig` (private; SkyLight asks +/// them) of the device this platform answers registry ID `registry_id` for: +/// - on macOS, for the device this platform answers Metal's registry ID for, Metal's own answers +/// for that GPU ([`crate::os::default_driver_sizes`]); +/// - else the M3 Max's ([`M3_MAX_DRIVER_SIZES`]). No Vulkan query reports them, and what Metal +/// answers for a family other than the M3 Max's is not measured, so every other device answers +/// the one measured device's values (a gap, in the graphics lane's selector sweep). +fn driver_sizes(registry_id: u64) -> [Option; 4] { + let metals = if crate::os::default_registry_id() == Some(registry_id) { + crate::os::default_driver_sizes() + } else { + [None; 4] + }; + let mut sizes = [None; 4]; + for ((size, metal), m3) in sizes.iter_mut().zip(metals).zip(M3_MAX_DRIVER_SIZES) { + *size = Some(metal.unwrap_or(m3)); + } + sizes +} + /// Every identity answer of `device`, whose `DeviceCaps` are `caps`, read once. pub fn read(device: &rt::Device, caps: &DeviceCaps) -> IdentityCaps { let props = device.properties(); + let [ + feature_profile, + half_fp_config, + single_fp_config, + double_fp_config, + ] = driver_sizes(caps.registry_id); let families = families(device, caps); let [ lod, @@ -278,6 +308,10 @@ pub fn read(device: &rt::Device, caps: &DeviceCaps) -> IdentityCaps { largest_rasterization_rate_map_layer_count: Some(largest(|count| { props.supports_rasterization_rate_map_with_layer_count(count) })), + feature_profile, + half_fp_config, + single_fp_config, + double_fp_config, ..IdentitySizes::default() }, flags: IdentityFlags { @@ -305,6 +339,21 @@ mod tests { use super::*; use crate::gpu::device::tests::dev; + /// A device no Metal device stands for answers the M3 Max's feature profile and FP configs; + /// the one Metal's registry ID names, Metal's own (on macOS) + #[test] + fn driver_sizes_are_metals_or_the_m3_maxs() { + let elsewhere = crate::os::default_registry_id().map_or(1, |id| id ^ 1); + assert_eq!(driver_sizes(elsewhere), M3_MAX_DRIVER_SIZES.map(Some)); + if let Some(id) = crate::os::default_registry_id() { + let metals = crate::os::default_driver_sizes(); + let answered = driver_sizes(id); + for ((answer, metal), m3) in answered.iter().zip(metals).zip(M3_MAX_DRIVER_SIZES) { + assert_eq!(*answer, Some(metal.unwrap_or(m3))); + } + } + } + /// A claimed family claims every family Metal documents it contains, and nothing more: Apple9 /// claims Apple1 to Apple8, the Common families, Mac1, Mac2 and Metal3, but not Apple10, /// Apple11, the Mac Catalyst families or Metal4 diff --git a/crates/reims-vgpu-vulkan/src/os.rs b/crates/reims-vgpu-vulkan/src/os.rs index a0921aefd..07c116d29 100644 --- a/crates/reims-vgpu-vulkan/src/os.rs +++ b/crates/reims-vgpu-vulkan/src/os.rs @@ -52,8 +52,8 @@ pub(crate) use host_os::{ host_memory, import_view, plane_shape, shown_at, surface_memory_hold, }; pub use host_os::{ - GuestMemoryLease, OsClock, OsSurface, OsSurfaces, OsThreads, OsVm, default_gpu_core_count, - default_registry_id, install_process_services, lease_guest_memory, + GuestMemoryLease, OsClock, OsSurface, OsSurfaces, OsThreads, OsVm, default_driver_sizes, + default_gpu_core_count, default_registry_id, install_process_services, lease_guest_memory, }; #[cfg(test)] pub(crate) use host_os::{PAGE, mapped, writable}; diff --git a/crates/reims-vgpu-vulkan/src/os/linux.rs b/crates/reims-vgpu-vulkan/src/os/linux.rs index 6686fef4c..1ef4244e7 100644 --- a/crates/reims-vgpu-vulkan/src/os/linux.rs +++ b/crates/reims-vgpu-vulkan/src/os/linux.rs @@ -135,3 +135,9 @@ pub fn default_registry_id() -> Option { pub fn default_gpu_core_count() -> Option { None } + +/// The feature profile and FP configs Metal answers for the device [`default_registry_id`] +/// names: none, as there is no Metal here to ask. +pub fn default_driver_sizes() -> [Option; 4] { + [None; 4] +} diff --git a/crates/reims-vgpu-vulkan/src/os/macos.rs b/crates/reims-vgpu-vulkan/src/os/macos.rs index fdef89b2d..72234375f 100644 --- a/crates/reims-vgpu-vulkan/src/os/macos.rs +++ b/crates/reims-vgpu-vulkan/src/os/macos.rs @@ -113,6 +113,25 @@ pub fn default_gpu_core_count() -> Option { *COUNT.get_or_init(|| count) } +/// `featureProfile`, `halfFPConfig`, `singleFPConfig` and `doubleFPConfig` of the system default +/// `MTLDevice`, asked of Metal once: the answers of the GPU's own driver for the device +/// [`default_registry_id`] names, which no Vulkan query reports. `None` for each where Metal has +/// no device, or its device does not respond to it. +pub fn default_driver_sizes() -> [Option; 4] { + static SIZES: std::sync::OnceLock<[Option; 4]> = std::sync::OnceLock::new(); + *SIZES.get_or_init(|| { + MetalPlatform::system_default_device().map_or([None; 4], |d| { + let z = d.identity_caps().sizes; + [ + z.feature_profile, + z.half_fp_config, + z.single_fp_config, + z.double_fp_config, + ] + }) + }) +} + /// What a device holds of the guest's RAM while it lives: nothing, as Mach makes a view of any /// memory by remapping its addresses (`mach_vm_remap`), with no file behind it. #[derive(Debug)] diff --git a/crates/reims-vgpu/src/graphics/device_info.rs b/crates/reims-vgpu/src/graphics/device_info.rs index a084e9e7b..af0e983b8 100644 --- a/crates/reims-vgpu/src/graphics/device_info.rs +++ b/crates/reims-vgpu/src/graphics/device_info.rs @@ -362,6 +362,10 @@ pub fn device_info( z.maximum_concurrent_compilation_task_count, z.largest_vertex_amplification_count, z.largest_rasterization_rate_map_layer_count, + z.feature_profile, + z.half_fp_config, + z.single_fp_config, + z.double_fp_config, ]; info.sizes = sizes.map(|size| size.unwrap_or(0)); @@ -702,7 +706,8 @@ mod tests { assert_eq!(info.identity_flags[13], 0); assert_eq!(info.identity_flags[18], 0); assert_eq!(info.counter_sampling, [0; 5]); - // recommended_max_working_set_size first, the rate maps' layers last (the lane's 0). + // recommended_max_working_set_size first, the rate maps' layers at 14 (the lane's 0), the + // driver's feature profile and FP configs last, the platform's. assert_eq!( info.sizes[0], identity.sizes.recommended_max_working_set_size.unwrap() @@ -712,6 +717,7 @@ mod tests { assert_eq!(info.sizes[12], 4); assert_eq!(info.sizes[13], 8); assert_eq!(info.sizes[14], 0); + assert_eq!(info.sizes[15..], [10, 0xe, 0x54, 0]); // Every SDK format, each the platform's: BGRA8Unorm (80) 16-byte texture buffers and // 64x64 tiles; BC1_RGBA (130) no texture buffers. assert_eq!(info.format_count as usize, SDK_PIXEL_FORMATS.len()); diff --git a/guest/bundle/src/RgfxCaps.hpp b/guest/bundle/src/RgfxCaps.hpp index 86b028222..bb34d4ad9 100644 --- a/guest/bundle/src/RgfxCaps.hpp +++ b/guest/bundle/src/RgfxCaps.hpp @@ -86,7 +86,7 @@ enum RgfxFlag { kRgfxFlagCount }; -/// The 15 integer identity answers, in the host `IdentitySizes` field order. +/// The 19 integer identity answers, in the host `IdentitySizes` field order. enum RgfxSize { kRgfxSizeRecommendedMaxWorkingSetSize = 0, kRgfxSizeLocation, @@ -103,6 +103,10 @@ enum RgfxSize { kRgfxSizeMaximumConcurrentCompilationTaskCount, kRgfxSizeLargestVertexAmplificationCount, kRgfxSizeLargestRasterizationRateMapLayerCount, + kRgfxSizeFeatureProfile, + kRgfxSizeHalfFpConfig, + kRgfxSizeSingleFpConfig, + kRgfxSizeDoubleFpConfig, kRgfxSizeCount }; diff --git a/guest/bundle/src/RgfxMetalDevice.mm b/guest/bundle/src/RgfxMetalDevice.mm index 249435458..be54bbd4e 100644 --- a/guest/bundle/src/RgfxMetalDevice.mm +++ b/guest/bundle/src/RgfxMetalDevice.mm @@ -902,6 +902,36 @@ RGFX_LOG_UNRECOGNIZED // SkyLight, Core Image and MPS send these; each answers what Metal's device answers, measured // on the M3 Max (macOS 27), unless it says otherwise. +// The host's answers, from the device info: its Metal device's own, or, where no Metal device +// stands for its GPU, the M3 Max's (the Vulkan platform's), and 0 for a Metal device that does +// not respond to one. Measured on the M3 Max (macOS 27): feature profile 10, FP configs 0xe +// (half), 0x54 (single) and 0 (double), 40 cores. +- (NSUInteger)featureProfile +{ + return _caps.size(kRgfxSizeFeatureProfile); +} + +- (NSUInteger)halfFPConfig +{ + return _caps.size(kRgfxSizeHalfFpConfig); +} + +- (NSUInteger)singleFPConfig +{ + return _caps.size(kRgfxSizeSingleFpConfig); +} + +- (NSUInteger)doubleFPConfig +{ + return _caps.size(kRgfxSizeDoubleFpConfig); +} + +// `unsigned int`, as Metal's (`I16@0:8`). +- (unsigned int)gpuCoreCount +{ + return static_cast(_caps.gpuCoreCount()); +} + // As supportsTextureSampleCount: (the same for each count from 1 to 16). - (BOOL)supportsSampleCount:(NSUInteger)sampleCount { diff --git a/guest/bundle/src/RgfxWireLayout.cpp b/guest/bundle/src/RgfxWireLayout.cpp index 41c7ef564..e3079e578 100644 --- a/guest/bundle/src/RgfxWireLayout.cpp +++ b/guest/bundle/src/RgfxWireLayout.cpp @@ -46,11 +46,11 @@ static_assert(RGFX_LIBRARY_BYTES_OFFSET == sizeof(RgfxLibraryCreate), "library b static_assert(sizeof(RgfxLibraryFromRegion) == 112, "RgfxLibraryFromRegion"); static_assert(sizeof(RgfxLibraryLookup) == 64, "RgfxLibraryLookup"); static_assert(sizeof(RgfxFormatAnswers) == 64, "RgfxFormatAnswers"); -static_assert(sizeof(RgfxDeviceInfo) == 1400 + 64 * RGFX_DEVICE_INFO_FORMATS, "RgfxDeviceInfo"); -static_assert(__builtin_offsetof(RgfxDeviceInfo, formats) == 1400, "RgfxDeviceInfo formats"); -static_assert(__builtin_offsetof(RgfxDeviceInfo, family_answers) == 944, +static_assert(sizeof(RgfxDeviceInfo) == 1432 + 64 * RGFX_DEVICE_INFO_FORMATS, "RgfxDeviceInfo"); +static_assert(__builtin_offsetof(RgfxDeviceInfo, formats) == 1432, "RgfxDeviceInfo formats"); +static_assert(__builtin_offsetof(RgfxDeviceInfo, family_answers) == 976, "RgfxDeviceInfo family_answers"); -static_assert(__builtin_offsetof(RgfxDeviceInfo, name) == 1080, "RgfxDeviceInfo name"); +static_assert(__builtin_offsetof(RgfxDeviceInfo, name) == 1112, "RgfxDeviceInfo name"); // Stage-3 pipeline creates and reflection. static_assert(sizeof(RgfxFunctionConstant) == 40, "RgfxFunctionConstant"); diff --git a/guest/bundle/tools/window_probe.m b/guest/bundle/tools/window_probe.m index 338f68bc1..390567b5c 100644 --- a/guest/bundle/tools/window_probe.m +++ b/guest/bundle/tools/window_probe.m @@ -60,7 +60,7 @@ enum { static const uint64_t kHead = 0x400000; // RGFX_ALLOCATIONS_OFFSET static const uint64_t kDeviceInfoAt = 0x18100; // RGFX_DEVICE_INFO_OFFSET #define RGFX_PROBE_SCANOUT_SPAN 0x8000000ull // RGFX_SCANOUT_SPAN -static const size_t kDeviceInfoSize = 11640; // sizeof(RgfxDeviceInfo) +static const size_t kDeviceInfoSize = 11672; // sizeof(RgfxDeviceInfo) static const uint64_t kBlock = 0x10000; // The accelerator's IOAccel surface client (kIOAccelSurfaceClientType), and IOGraphics' memory // type for a framebuffer's VRAM range on its user clients (kIOFBVRAMMemory, in IOGraphics' open