diff --git a/crates/metal2vulkan-runtime/src/capabilities.rs b/crates/metal2vulkan-runtime/src/capabilities.rs index 4260e983c..f2fc1fd55 100644 --- a/crates/metal2vulkan-runtime/src/capabilities.rs +++ b/crates/metal2vulkan-runtime/src/capabilities.rs @@ -31,6 +31,7 @@ use super::device::DeviceKind; use super::driver_defects; use super::error::{invalid, Error, Problem, RuntimeGap}; use super::linear_plan::linear_alignment; +use super::sampler::argument_buffer_sampler_count; use super::texture_descriptor::TextureRules; use super::values::Size; use metal2vulkan::device::{DeviceDescription, DriverFact, VkFeature}; @@ -127,6 +128,29 @@ pub struct DeviceProperties { /// `argumentBuffersSupport`: `Tier2` where buffers are reached by device address and texture /// and sampler handles through the descriptor heap (descriptor indexing), else `Tier1`. pub argument_buffers_support: ArgumentBuffersTier, + /// `maxArgumentBufferSamplerCount`: the most live sampler states functions can read through + /// argument buffers, one fewer than the smaller of two counts, each with a slot the states do + /// not take: + /// - the elements of a set-1 sampler array, which holds each live state at an element of its + /// own and the neutral sampler at element 0 + /// ([`heap_sampler_capacity`](metal2vulkan::pipeline::heap_sampler_capacity): the least of + /// the handle table's 65536 entries, `maxDescriptorSetUpdateAfterBindSamplers` and + /// `maxPerStageDescriptorUpdateAfterBindSamplers`, 0 where no function can read one); + /// - `maxSamplerAllocationCount`, the Vulkan samplers the device holds live at once, one past + /// them refused (`Error::SamplerLimit`): the array's neutral sampler and a sampler of each + /// state it holds are among them. + /// + /// It is the most any pipeline reads: fewer are read where a pipeline's heap has more arrays + /// or its set 0 counts samplers (a smaller array), where other Vulkan samplers live (another + /// use's array, a slot's bind, a pipeline's constexpr samplers), or where other holders of + /// sampler IDs (the device's own sampler, a pipeline state's numbered samplers) hold IDs the + /// device's sampler tables reach, which are IDs 1 to 65535 under plain allocation. A state + /// left out reads the neutral sampler through an argument buffer, announced + /// (`Degradation::UnlistedArgumentSampler`). Every live state counts, with or without + /// `supportArgumentBuffers`, since Metal reads one without it through an argument buffer too; + /// Metal's count is of the states with it. Metal answers 500000 on an Apple M3 Max (macOS + /// 27.0.1), where the runtime answers 65535 on MoltenVK, the handle table's reach. + pub max_argument_buffer_sampler_count: u64, /// `readWriteTextureSupport`: the highest tier whose every format has a storage-image form /// on the device. pub read_write_texture_support: ReadWriteTextureTier, @@ -198,6 +222,10 @@ pub(crate) struct DeviceIdentity { pub api_version: ApiVersion, /// `VkPhysicalDeviceLimits::maxViewports`. pub max_viewports: u32, + /// `VkPhysicalDeviceLimits::maxSamplerAllocationCount`: the device's live samplers are held + /// to it (`SamplerCount`), and it bounds + /// [`DeviceProperties::max_argument_buffer_sampler_count`]. + pub max_sampler_allocation_count: u32, /// The GPU's cores as its driver reports them ([`DeviceProperties::gpu_core_count`]). pub gpu_core_count: Option, /// The sample counts every color and depth image can be sampled at: @@ -307,6 +335,10 @@ impl DeviceProperties { max_threads_per_threadgroup: Size::new(width, height, depth), max_threadgroup_memory_length: u64::from(metal.max_threadgroup_memory_length), argument_buffers_support: metal.argument_buffers_tier, + max_argument_buffer_sampler_count: argument_buffer_sampler_count( + metal2vulkan::pipeline::heap_sampler_capacity(compile.profile()), + identity.max_sampler_allocation_count, + ), read_write_texture_support: metal.read_write_texture_tier, supports_32bit_float_filtering: metal.supports_32bit_float_filtering, max_viewports: identity.max_viewports, diff --git a/crates/metal2vulkan-runtime/src/device/mod.rs b/crates/metal2vulkan-runtime/src/device/mod.rs index 84e726d92..f73a754bf 100644 --- a/crates/metal2vulkan-runtime/src/device/mod.rs +++ b/crates/metal2vulkan-runtime/src/device/mod.rs @@ -1704,6 +1704,9 @@ impl Device { // device exists, so the description's version passed the floor). let (identity, max_allocation) = unsafe { properties::query(&instance.raw, physical, instance.api_version) }; + // The limit the device's live samplers are held to, the one + // `DeviceProperties::max_argument_buffer_sampler_count` is derived from. + let sampler_limit = identity.max_sampler_allocation_count; let properties = DeviceProperties::new(identity, description, &compile, mac_class); // SAFETY: as above. let memory_properties = @@ -1963,7 +1966,7 @@ impl Device { identifiers: Arc::default(), sampler_ids, samplers: Mutex::default(), - sampler_count: SamplerCount::new(limits.max_sampler_allocation_count), + sampler_count: SamplerCount::new(sampler_limit), allocations, frees, sampler_sets: Mutex::default(), diff --git a/crates/metal2vulkan-runtime/src/device/properties.rs b/crates/metal2vulkan-runtime/src/device/properties.rs index f9bb84e84..1fa531d8b 100644 --- a/crates/metal2vulkan-runtime/src/device/properties.rs +++ b/crates/metal2vulkan-runtime/src/device/properties.rs @@ -175,6 +175,7 @@ pub(super) unsafe fn query( api_version: metal2vulkan::vk::ApiVersion::from_packed(core.api_version) .min(instance_api_version), max_viewports: core.limits.max_viewports, + max_sampler_allocation_count: core.limits.max_sampler_allocation_count, // SAFETY: the caller's contract. gpu_core_count: unsafe { gpu_core_count(instance, physical) }, sampled_sample_counts: metal2vulkan::vk::SampleCountFlags::from_raw( diff --git a/crates/metal2vulkan-runtime/src/resource_ids.rs b/crates/metal2vulkan-runtime/src/resource_ids.rs index 28cf27ab3..5d7791d0c 100644 --- a/crates/metal2vulkan-runtime/src/resource_ids.rs +++ b/crates/metal2vulkan-runtime/src/resource_ids.rs @@ -1365,20 +1365,11 @@ impl Device { [sampled, storage] } - /// The most elements a set-1 sampler array can have on the device, and the limit that - /// bounds it. - pub(super) fn sampler_array(&self) -> (u64, VkLimit) { - let l = self.compile_device().profile().limits(); - least(&[ - ( - l.max_descriptor_set_update_after_bind_samplers, - VkLimit::MaxDescriptorSetUpdateAfterBindSamplers, - ), - ( - l.max_per_stage_descriptor_update_after_bind_samplers, - VkLimit::MaxPerStageDescriptorUpdateAfterBindSamplers, - ), - ]) + /// The most elements a set-1 sampler array can have on the device: link's count for a + /// pipeline's (`metal2vulkan::pipeline::heap_sampler_capacity`), 0 where no function reads + /// one. + pub(super) fn sampler_array(&self) -> u32 { + metal2vulkan::pipeline::heap_sampler_capacity(self.compile_device().profile()) } /// Say `text`, a general warning `code` names: through the device's message sink, else on diff --git a/crates/metal2vulkan-runtime/src/sampler.rs b/crates/metal2vulkan-runtime/src/sampler.rs index 102a75b3c..a8d57b107 100644 --- a/crates/metal2vulkan-runtime/src/sampler.rs +++ b/crates/metal2vulkan-runtime/src/sampler.rs @@ -264,6 +264,18 @@ impl SamplerCount { } } +/// Metal's `maxArgumentBufferSamplerCount` on a device whose set-1 sampler arrays have at most +/// `elements` elements (`metal2vulkan::pipeline::heap_sampler_capacity`, which link sizes every +/// heap array by, and [`Device::sampler_array`] answers) and whose live Vulkan samplers are held +/// to `limit` (`maxSamplerAllocationCount`, the [`SamplerCount`] the device makes): one fewer +/// than the smaller, since an array's element 0 and one of the device's samplers are the neutral +/// sampler's, and each state the array holds takes an element and a sampler of its own +/// ([`DeviceProperties::max_argument_buffer_sampler_count`](crate::DeviceProperties::max_argument_buffer_sampler_count)). +/// 0 where `elements` is: no function reads a set-1 sampler array there. +pub(super) fn argument_buffer_sampler_count(elements: u32, limit: u32) -> u64 { + u64::from(elements.min(limit).saturating_sub(1)) +} + /// The Vulkan samplers a sampler state made for its binds, each by its description. /// /// Every bind of the state asks it for the sampler of one description --- a separate sampler @@ -702,16 +714,18 @@ impl Device { super::heap_sets::place_sampler(self, &state); let id = hold.id().0; let element = state.heap_element(); - let (available, limit) = self.sampler_array(); - if element >= available { + // A device with no set-1 sampler array refuses every function reading one, so no array + // leaves the state out. + let available = u64::from(self.sampler_array()); + if available > 0 && element >= available { self.degrade(Degradation::UnlistedArgumentSampler, || { ( format!("sampler state at resource ID {id}"), format!( "more sampler states live than a set-1 sampler array of the device \ - holds ({limit:?} is {available}), so none holds its element {element}, \ - and a function reading it through an argument buffer while it lives \ - reads the neutral sampler" + holds ({available} elements, the neutral sampler's among them), so none \ + holds its element {element}, and a function reading it through an \ + argument buffer while it lives reads the neutral sampler" ), ) }); diff --git a/crates/metal2vulkan-runtime/src/tests/argument_sampler_count.rs b/crates/metal2vulkan-runtime/src/tests/argument_sampler_count.rs new file mode 100644 index 000000000..176acff0e --- /dev/null +++ b/crates/metal2vulkan-runtime/src/tests/argument_sampler_count.rs @@ -0,0 +1,153 @@ +//! `maxArgumentBufferSamplerCount` on the device the cfg selects +//! (`DeviceProperties::max_argument_buffer_sampler_count`): one fewer than the smaller of the +//! elements of a set-1 sampler array and the limit the device's live samplers are held to, each +//! read where the runtime uses it. The array is the one link gives a kernel reading a sampler from +//! an argument buffer on the device's profile, which is the device's own count +//! (`Device::sampler_array`, which each sampler state is checked against as it is made); the limit +//! is the driver's `maxSamplerAllocationCount`, which `SamplerCount` refuses past +//! (`Error::SamplerLimit`). The states that count as they are made: as many as the array holds +//! beside its neutral are made with no notice, and the next is announced +//! (`Degradation::UnlistedArgumentSampler`). +//! +//! A device test: compiled only under the validation crate's GPU safety cfgs (`m2v_gpu`, +//! `m2v_cpu_icd`), on the kind of device the cfg selects. The kernel is `argument_sampler_sample` +//! of the owned fixture `validation/fixtures/public/engine/tail_argument_samplers.ll` +//! (`llvm-as`). + +use super::blit_holds::Scratch; +use crate::{ + Degradation, DegradeNotice, Device, DeviceKind, DeviceOptions, IdPlacement, MessageSink, + ResourceId, SamplerState, SamplerStateOptions, ShaderCacheOptions, +}; +use metal2vulkan::bind::SamplerDescriptor; +use metal2vulkan::pipeline::{ComputePipelineDescriptor, FunctionDescriptor, StageSource}; +use metal2vulkan::vk; +use metal2vulkan::Budget; +use std::path::Path; +use std::sync::{Arc, Mutex}; + +/// The notices a device announced. +type Heard = Arc>>; + +/// The notices of a set-1 array leaving a sampler state out that `heard` holds, emptied. +fn unlisted(heard: &Heard) -> Vec { + (heard.lock().unwrap().drain(..)) + .filter(|notice| notice.degradation == Degradation::UnlistedArgumentSampler) + .collect() +} + +/// A device of the kind the cfg selects, its notices into `heard`. +fn device(cache: &Path, heard: &Heard) -> Device { + let heard = Arc::clone(heard); + let options = DeviceOptions { + kinds: match cfg!(m2v_cpu_icd) { + true => vec![DeviceKind::Cpu], + false => vec![ + DeviceKind::Discrete, + DeviceKind::Integrated, + DeviceKind::Virtual, + ], + }, + shader_cache: ShaderCacheOptions { + directory: Some(cache.to_owned()), + ..ShaderCacheOptions::default() + }, + messages: Some(MessageSink::new(move |message| { + if let Some(notice) = &message.degradation { + heard.lock().unwrap().push(notice.clone()); + } + })), + ..DeviceOptions::default() + }; + Device::system_default_with(&options).unwrap() +} + +/// The element count of the set-1 sampler array of the kernel's pipeline on `device`'s profile. +fn kernel_sampler_array(device: &Device) -> u32 { + let ll = Path::new(env!("CARGO_MANIFEST_DIR")) + .join("../metal2vulkan-validation/fixtures/public/engine/tail_argument_samplers.ll"); + let bitcode = metal2vulkan_devtools::llvm_assemble(&ll).unwrap(); + let function = metal2vulkan::library::Library::from_air(&bitcode) + .unwrap() + .function("argument_sampler_sample") + .unwrap(); + let descriptor = + ComputePipelineDescriptor::new(StageSource::Function(FunctionDescriptor::new(function))); + let pipeline = device + .compile_device() + .compile_compute_pipeline(&descriptor, &Budget::standard()) + .unwrap(); + let arrays: Vec = (pipeline.layout.sets.iter()) + .filter(|set| set.set == 1) + .flat_map(|set| &set.bindings) + .filter(|binding| binding.ty == vk::DescriptorType::SAMPLER) + .map(|binding| binding.count) + .collect(); + assert_eq!(arrays.len(), 1, "one set-1 sampler array: {arrays:?}"); + arrays[0] +} + +/// The answer is one fewer than the smaller of the kernel's set-1 sampler array, which is the +/// device's own count of its elements, and the driver's `maxSamplerAllocationCount`, which the +/// device's live samplers are held to. Sampler states made one after another take elements 1, 2, +/// ...: those up to one fewer than the array's elements are made with no notice, and the one at +/// the array's count is announced as left out of it. Every state is placed at one ID of the +/// sampler tables' low window, so no state is left out of them for its ID, and the device makes no +/// set-1 array, so none takes a Vulkan sampler. +#[test] +fn the_argument_buffer_sampler_count_is_the_set_1_sampler_array_and_the_sampler_limit() { + let scratch = Scratch::new("argument-sampler-count"); + let heard = Heard::default(); + let device = device(&scratch.0, &heard); + let shared = device.shared(); + let p = device.properties(); + let array = kernel_sampler_array(&device); + let elements = device.sampler_array(); + let limit = shared.sampler_count.limit(); + // SAFETY: the physical device is the live instance's. + let driver = unsafe { (shared.instance.raw).get_physical_device_properties(shared.physical) }; + println!( + "ARGUMENT SAMPLERS {}: maxArgumentBufferSamplerCount {}, set-1 sampler array {array} \ + (the device's {elements}), maxSamplerAllocationCount {limit} (the driver's {})", + p.name, p.max_argument_buffer_sampler_count, driver.limits.max_sampler_allocation_count + ); + assert_eq!(array, elements, "the kernel's array and the device's count"); + assert_eq!(limit, driver.limits.max_sampler_allocation_count); + assert_eq!( + p.max_argument_buffer_sampler_count, + u64::from(elements.min(limit)) - 1 + ); + assert_eq!(unlisted(&heard), []); + let options = { + let mut options = SamplerStateOptions::default(); + options.support_argument_buffers = true; + options.placement = IdPlacement::At(ResourceId(5)); + options + }; + let state = |n: u32| -> SamplerState { + let mut descriptor = SamplerDescriptor::new(); + descriptor.lod_min_clamp = n as f32 / 65536.0; + let state = device + .new_sampler_state_with_options(&descriptor, options) + .unwrap(); + assert_eq!(state.heap_element(), u64::from(n), "state {n}'s element"); + state + }; + let mut states: Vec = (1..elements).map(state).collect(); + assert_eq!(unlisted(&heard), [], "{} states", states.len()); + states.push(state(elements)); + let notices = unlisted(&heard); + assert_eq!(notices.len(), 1, "{notices:?}"); + assert!( + notices[0].reason.contains(&format!("{elements} elements")), + "{}", + notices[0].reason + ); + println!( + "ARGUMENT SAMPLERS {}: {} states made with no notice, the next announced: {}", + p.name, + elements - 1, + notices[0].reason + ); + drop(states); +} diff --git a/crates/metal2vulkan-runtime/src/tests/capabilities.rs b/crates/metal2vulkan-runtime/src/tests/capabilities.rs index 4f1af2e11..c7ae3793c 100644 --- a/crates/metal2vulkan-runtime/src/tests/capabilities.rs +++ b/crates/metal2vulkan-runtime/src/tests/capabilities.rs @@ -17,7 +17,9 @@ use metal2vulkan::device::{ }; use metal2vulkan::error::{Feature, Unsupported}; use metal2vulkan::metal::PixelFormat; +use metal2vulkan::pipeline::heap_sampler_capacity; use metal2vulkan::vk::{ApiVersion, Format, SampleCountFlags}; +use std::collections::BTreeMap; /// Every committed profile's description: (file stem, description), sorted by stem. pub(super) fn committed_descriptions() -> Vec<(String, DeviceDescription)> { @@ -38,9 +40,9 @@ pub(super) fn committed_descriptions() -> Vec<(String, DeviceDescription)> { out } -/// The sample counts the profile `stem` states under the `VkPhysicalDeviceLimits` member `key`; -/// none where it states none (the roadmap profiles), as the description reads its own counts. -pub(super) fn profile_counts(stem: &str, key: &str) -> SampleCountFlags { +/// The value the profile `stem` states under the member `key`, the first in its file; `None` +/// where it states none. +fn profile_value(stem: &str, key: &str) -> Option { fn find<'a>(value: &'a serde_json::Value, key: &str) -> Option<&'a serde_json::Value> { match value { serde_json::Value::Object(map) => map @@ -55,7 +57,13 @@ pub(super) fn profile_counts(stem: &str, key: &str) -> SampleCountFlags { let text = std::fs::read_to_string(&path).unwrap_or_else(|e| panic!("{stem}: {e}")); let json: serde_json::Value = serde_json::from_str(&text).unwrap_or_else(|e| panic!("{stem}: {e}")); - let Some(list) = find(&json, key) else { + find(&json, key).cloned() +} + +/// The sample counts the profile `stem` states under the `VkPhysicalDeviceLimits` member `key`; +/// none where it states none (the roadmap profiles), as the description reads its own counts. +pub(super) fn profile_counts(stem: &str, key: &str) -> SampleCountFlags { + let Some(list) = profile_value(stem, key) else { return SampleCountFlags::empty(); }; list.as_array() @@ -78,6 +86,7 @@ fn identity(stem: &str) -> DeviceIdentity { drm_render: None, api_version: ApiVersion::V1_3, max_viewports: 16, + max_sampler_allocation_count: sampler_allocation_count(stem), gpu_core_count: None, sampled_sample_counts: profile_counts(stem, "sampledImageColorSampleCounts") & profile_counts(stem, "sampledImageDepthSampleCounts"), @@ -85,6 +94,15 @@ fn identity(stem: &str) -> DeviceIdentity { } } +/// The profile `stem`'s `maxSamplerAllocationCount`, or Vulkan's least, 4000, where it states none +/// (the roadmap profile). +fn sampler_allocation_count(stem: &str) -> u32 { + profile_value(stem, "maxSamplerAllocationCount").map_or(4000, |count| { + let count = count.as_u64().unwrap_or_else(|| panic!("{stem}: {count}")); + u32::try_from(count).unwrap_or_else(|e| panic!("{stem}: {e}")) + }) +} + /// The properties of a device created from `desc` as the runtime creates one: the recommended /// enables for the untrusted policy, the description restricted to them, and the compile device /// built from that. @@ -423,6 +441,45 @@ fn the_venue_devices_answer_as_pinned() { } } +/// `maxArgumentBufferSamplerCount` is one fewer than the smaller of a set-1 sampler array's +/// elements (`heap_sampler_capacity` of the device's profile) and the device's +/// `maxSamplerAllocationCount`, on every committed profile. Pinned: the handle table's 65536 +/// entries bound it on MoltenVK (whose driver takes 500000 samplers, as Metal's answer on the M3 +/// Max is 500000), RADV and ANV (65536 samplers); lavapipe's 32768 samplers and NVIDIA's 4000 bound +/// it there; the desktop baseline's 16 update-after-bind samplers a stage bound it there; and on +/// the floor, which has no descriptor indexing, no function reads a set-1 array. +#[test] +fn argument_buffer_samplers_are_one_fewer_than_the_array_and_the_sampler_limit() { + let pinned = [ + ("moltenvk-m3", 65535), + ("amd-780m-radv", 65535), + ("intel-irisxe-rplp-anv", 65535), + ("intel-uhd770-rpls-anv", 65535), + ("lavapipe", 32767), + ("gate-lavapipe", 32767), + ("gate-lavapipe-x86_64", 32767), + ("nvidia-rtx5080-laptop", 3999), + ("lunarg-desktop-baseline-2023", 15), + ("vk12-floor", 0), + ]; + let mut answers = BTreeMap::new(); + for (stem, desc) in &committed_descriptions() { + let (enabled, p) = created(stem, desc); + let compile = Device::new(enabled, DevicePolicy::UNTRUSTED).unwrap(); + let elements = heap_sampler_capacity(compile.profile()); + let limit = sampler_allocation_count(stem); + assert_eq!( + p.max_argument_buffer_sampler_count, + u64::from(elements.min(limit).saturating_sub(1)), + "{stem}: {elements} elements, {limit} samplers" + ); + answers.insert(stem.as_str(), p.max_argument_buffer_sampler_count); + } + for (stem, answer) in pinned { + assert_eq!(answers.get(stem), Some(&answer), "{stem}: {answers:?}"); + } +} + /// A sample count is supported only when it is a Vulkan sample count the flags hold. #[test] fn sample_counts_are_the_flags_bits() { diff --git a/crates/metal2vulkan-runtime/src/tests/device.rs b/crates/metal2vulkan-runtime/src/tests/device.rs index de79adc03..58c96bdb3 100644 --- a/crates/metal2vulkan-runtime/src/tests/device.rs +++ b/crates/metal2vulkan-runtime/src/tests/device.rs @@ -37,6 +37,7 @@ fn identity( drm_render, api_version: ApiVersion::V1_3, max_viewports: 16, + max_sampler_allocation_count: 4000, gpu_core_count: None, sampled_sample_counts: SampleCountFlags::empty(), device_local_heap: None, diff --git a/crates/metal2vulkan-runtime/src/tests/mod.rs b/crates/metal2vulkan-runtime/src/tests/mod.rs index ebea28ba2..f10855538 100644 --- a/crates/metal2vulkan-runtime/src/tests/mod.rs +++ b/crates/metal2vulkan-runtime/src/tests/mod.rs @@ -12,6 +12,8 @@ mod amplification; mod apple_only; mod argument_buffers; mod argument_encoder; +#[cfg(any(m2v_gpu, m2v_cpu_icd))] +mod argument_sampler_count; #[cfg(debug_assertions)] mod argument_table; mod attachmentless; diff --git a/crates/metal2vulkan/src/pipeline/link.rs b/crates/metal2vulkan/src/pipeline/link.rs index 45f17b5d8..82f67c2aa 100644 --- a/crates/metal2vulkan/src/pipeline/link.rs +++ b/crates/metal2vulkan/src/pipeline/link.rs @@ -1034,48 +1034,24 @@ fn heap_set( if heap.is_empty() { return Ok(None); } - let d = &p.fields().descriptors; // The layout's own features (the module states its indexing features); `select` refuses a // function whose heap the profile cannot hold, so a miss here is a function compiled for // another profile. let mut missing = Vec::new(); - let mut need = |has: bool, f: VkFeature| { - if !has && !missing.contains(&Capability::Feature(f)) { - missing.push(Capability::Feature(f)); - } - }; - need( - d.runtime_descriptor_array, - VkFeature::RuntimeDescriptorArray, - ); - need( - d.partially_bound, - VkFeature::DescriptorBindingPartiallyBound, - ); // The feature a missing capability is refused as: the function tables' where only their array // needs it, else the textures'. let mut feature = Feature::DynamicCall; for h in heap.values() { - match h.ty { - vk::DescriptorType::SAMPLER | vk::DescriptorType::SAMPLED_IMAGE => { - feature = Feature::ArgumentBufferTextures; - need( - d.update_after_bind_sampled_image, - VkFeature::DescriptorBindingSampledImageUpdateAfterBind, - ) + if h.ty != vk::DescriptorType::STORAGE_BUFFER { + feature = Feature::ArgumentBufferTextures; + } + let Some(lacks) = heap_layout_lacks(p, h.ty) else { + return Err(Unsupported::not_implemented(Feature::ArgumentBufferTextures).into()); + }; + for f in lacks { + if !missing.contains(&Capability::Feature(f)) { + missing.push(Capability::Feature(f)); } - vk::DescriptorType::STORAGE_IMAGE => { - feature = Feature::ArgumentBufferTextures; - need( - d.update_after_bind_storage_image, - VkFeature::DescriptorBindingStorageImageUpdateAfterBind, - ) - } - vk::DescriptorType::STORAGE_BUFFER => need( - d.update_after_bind_storage_buffer, - VkFeature::DescriptorBindingStorageBufferUpdateAfterBind, - ), - _ => return Err(Unsupported::not_implemented(Feature::ArgumentBufferTextures).into()), } } if !missing.is_empty() { @@ -1114,6 +1090,75 @@ fn heap_set( })) } +/// The features a set-1 array of descriptor type `ty` needs in its layout that `p` lacks (the +/// module docs), in the order they are refused: `runtimeDescriptorArray`, +/// `descriptorBindingPartiallyBound`, then the type's update-after-bind feature. `None` for a type +/// no heap array has. +fn heap_layout_lacks(p: &DeviceProfile, ty: vk::DescriptorType) -> Option> { + let d = &p.fields().descriptors; + let typed = match ty { + vk::DescriptorType::SAMPLER | vk::DescriptorType::SAMPLED_IMAGE => ( + d.update_after_bind_sampled_image, + VkFeature::DescriptorBindingSampledImageUpdateAfterBind, + ), + vk::DescriptorType::STORAGE_IMAGE => ( + d.update_after_bind_storage_image, + VkFeature::DescriptorBindingStorageImageUpdateAfterBind, + ), + vk::DescriptorType::STORAGE_BUFFER => ( + d.update_after_bind_storage_buffer, + VkFeature::DescriptorBindingStorageBufferUpdateAfterBind, + ), + _ => return None, + }; + let needs = [ + ( + d.runtime_descriptor_array, + VkFeature::RuntimeDescriptorArray, + ), + ( + d.partially_bound, + VkFeature::DescriptorBindingPartiallyBound, + ), + typed, + ]; + Some( + needs + .into_iter() + .filter(|(has, _)| !has) + .map(|(_, f)| f) + .collect(), + ) +} + +/// The most elements a set-1 sampler array has on `p`. Element 0 holds the neutral sampler, so +/// the array holds at most one sampler state fewer. +/// +/// It is the heap capacity (the module docs) of a pipeline whose heap is one sampler array and +/// whose set 0 counts no sampler, which no pipeline's exceeds: the least of the handle table's +/// reach (`memory::handles::TABLE_CAPACITY`, 65536), `maxDescriptorSetUpdateAfterBindSamplers` +/// and `maxPerStageDescriptorUpdateAfterBindSamplers`, by the same limits and arithmetic link +/// sizes every heap array with. A pipeline whose heap has more arrays of a kind, or whose set 0 +/// counts descriptors of a kind its heap has, has fewer elements. 0 where `p` lacks a feature a +/// function reading a set-1 sampler array needs, so no pipeline has one: the layout's +/// (`runtimeDescriptorArray`, `descriptorBindingPartiallyBound`, +/// `descriptorBindingSampledImageUpdateAfterBind`) or the module's, which indexes the array by an +/// element it loads (`shaderSampledImageArrayNonUniformIndexing`). +pub fn heap_sampler_capacity(p: &DeviceProfile) -> u32 { + let readable = heap_layout_lacks(p, vk::DescriptorType::SAMPLER) + .is_some_and(|lacks| lacks.is_empty()) + && p.fields().descriptors.non_uniform_sampled_image; + if !readable { + return 0; + } + let capacity = heap_limits(&p.fields().limits, SAMPLERS) + .into_iter() + .map(|(_, available)| room(available, 0, 1)) + .fold(u64::from(crate::memory::handles::TABLE_CAPACITY), u64::min); + // At most the table's reach, a `u32`. + capacity as u32 +} + /// Whether set 1's heap arrays are `UPDATE_UNUSED_WHILE_PENDING` on `p`: where the profile has /// `descriptorBindingUpdateUnusedWhilePending`, so a consumer keeping one heap set for every /// command buffer can write an element no pending command buffer reads. A function that declares @@ -1137,55 +1182,26 @@ fn heap_capacity( vk::DescriptorType::STORAGE_BUFFER => STORAGE, _ => SAMPLED, }; - let kinds = [ - ( - SAMPLERS, - VkLimit::MaxDescriptorSetUpdateAfterBindSamplers, - l.max_descriptor_set_update_after_bind_samplers, - VkLimit::MaxPerStageDescriptorUpdateAfterBindSamplers, - l.max_per_stage_descriptor_update_after_bind_samplers, - ), - ( - SAMPLED, - VkLimit::MaxDescriptorSetUpdateAfterBindSampledImages, - l.max_descriptor_set_update_after_bind_sampled_images, - VkLimit::MaxPerStageDescriptorUpdateAfterBindSampledImages, - l.max_per_stage_descriptor_update_after_bind_sampled_images, - ), - ( - IMAGES, - VkLimit::MaxDescriptorSetUpdateAfterBindStorageImages, - l.max_descriptor_set_update_after_bind_storage_images, - VkLimit::MaxPerStageDescriptorUpdateAfterBindStorageImages, - l.max_per_stage_descriptor_update_after_bind_storage_images, - ), - ( - STORAGE, - VkLimit::MaxDescriptorSetUpdateAfterBindStorageBuffers, - l.max_descriptor_set_update_after_bind_storage_buffers, - VkLimit::MaxPerStageDescriptorUpdateAfterBindStorageBuffers, - l.max_per_stage_descriptor_update_after_bind_storage_buffers, - ), - ]; let mut capacity = u64::from(crate::memory::handles::TABLE_CAPACITY); - // `limit` holds `used + arrays · capacity`. + // `limit` holds `used + arrays · capacity` ([`room`]). let mut bound = |limit: VkLimit, available: u32, used: u64, arrays: u64| -> Result<(), Error> { if arrays == 0 { return Ok(()); } - let room = u64::from(available).saturating_sub(used) / arrays; - if room == 0 { + let each = room(available, used, arrays); + if each == 0 { return Err(limit_error( limit, used.saturating_add(arrays), u64::from(available), )); } - capacity = capacity.min(room); + capacity = capacity.min(each); Ok(()) }; let all = kind_counts(set0.iter())?; - for (k, set_limit, set_max, _, _) in kinds { + for k in HEAP_KINDS { + let [(set_limit, set_max), _] = heap_limits(l, k); let arrays = heap.values().filter(|h| kind(h.ty) == k).count() as u64; bound(set_limit, set_max, all[k], arrays)?; } @@ -1193,7 +1209,8 @@ fn heap_capacity( let flags = i.vk_stage().flags(); let own = kind_counts(set0.iter().filter(|b| b.stages.contains(flags)))?; let in_stage = |h: &&HeapDecl| h.stages.contains(flags); - for (k, _, _, stage_limit, stage_max) in kinds { + for k in HEAP_KINDS { + let [_, (stage_limit, stage_max)] = heap_limits(l, k); let arrays = heap .values() .filter(in_stage) @@ -1232,6 +1249,63 @@ fn heap_capacity( }) } +/// The kinds of heap arrays, in the order [`heap_capacity`] bounds them. +const HEAP_KINDS: [usize; 4] = [SAMPLERS, SAMPLED, IMAGES, STORAGE]; + +/// The update-after-bind limits on `l` of heap arrays of kind `k`, one of [`HEAP_KINDS`]: the +/// set's (`maxDescriptorSetUpdateAfterBind*`), then a stage's +/// (`maxPerStageDescriptorUpdateAfterBind*`), each with its value. +fn heap_limits(l: &crate::device::profile::Limits, k: usize) -> [(VkLimit, u32); 2] { + match k { + SAMPLERS => [ + ( + VkLimit::MaxDescriptorSetUpdateAfterBindSamplers, + l.max_descriptor_set_update_after_bind_samplers, + ), + ( + VkLimit::MaxPerStageDescriptorUpdateAfterBindSamplers, + l.max_per_stage_descriptor_update_after_bind_samplers, + ), + ], + SAMPLED => [ + ( + VkLimit::MaxDescriptorSetUpdateAfterBindSampledImages, + l.max_descriptor_set_update_after_bind_sampled_images, + ), + ( + VkLimit::MaxPerStageDescriptorUpdateAfterBindSampledImages, + l.max_per_stage_descriptor_update_after_bind_sampled_images, + ), + ], + IMAGES => [ + ( + VkLimit::MaxDescriptorSetUpdateAfterBindStorageImages, + l.max_descriptor_set_update_after_bind_storage_images, + ), + ( + VkLimit::MaxPerStageDescriptorUpdateAfterBindStorageImages, + l.max_per_stage_descriptor_update_after_bind_storage_images, + ), + ], + _ => [ + ( + VkLimit::MaxDescriptorSetUpdateAfterBindStorageBuffers, + l.max_descriptor_set_update_after_bind_storage_buffers, + ), + ( + VkLimit::MaxPerStageDescriptorUpdateAfterBindStorageBuffers, + l.max_per_stage_descriptor_update_after_bind_storage_buffers, + ), + ], + } +} + +/// The most elements each of `arrays` heap arrays can have under a limit of `available` that +/// already counts `used` descriptors: `limit` holds `used + arrays · room`. +fn room(available: u32, used: u64, arrays: u64) -> u64 { + u64::from(available).saturating_sub(used) / arrays +} + fn limit_error(limit: VkLimit, required: u64, available: u64) -> Error { Unsupported::needs( Feature::DescriptorCount, diff --git a/crates/metal2vulkan/src/pipeline/mod.rs b/crates/metal2vulkan/src/pipeline/mod.rs index 86c759fe4..03b408882 100644 --- a/crates/metal2vulkan/src/pipeline/mod.rs +++ b/crates/metal2vulkan/src/pipeline/mod.rs @@ -131,7 +131,7 @@ pub use interface::{ pub use layout::{ BindingSource, DescriptorBinding, DescriptorSetLayout, PipelineLayout, PushConstantRange, }; -pub use link::heap_unused_while_pending; +pub use link::{heap_sampler_capacity, heap_unused_while_pending}; pub use lower_inputs::{ AliasView, AmplificationDraws, BlendEquation, ChannelWrite, ColorGroup, ExtendedRangeColor, FactorLane, FetchedAttachment, FramebufferFetchInputs, LoweringInputs, RotatedBlendForm, diff --git a/crates/metal2vulkan/src/tests/engine_handles.rs b/crates/metal2vulkan/src/tests/engine_handles.rs index 5950e0529..cf6b4ce7b 100644 --- a/crates/metal2vulkan/src/tests/engine_handles.rs +++ b/crates/metal2vulkan/src/tests/engine_handles.rs @@ -54,10 +54,11 @@ use crate::pipeline::testing::{ storage_buffers, typed_module, AssembleError, StatusReach, }; use crate::pipeline::{ - ComputePipelineDescriptor, FunctionDescriptor, RenderPipelineDescriptor, StageSource, + heap_sampler_capacity, ComputePipelineDescriptor, FunctionDescriptor, RenderPipelineDescriptor, + StageSource, }; use crate::spirv::interp::{run_with_images, Buffer, Config, Image, Resources}; -use crate::spirv::testing::committed_profiles; +use crate::spirv::testing::{committed_descriptions, committed_profiles}; use crate::vk; const DATALAYOUT: &str = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024-n8:16:32"; @@ -4364,6 +4365,83 @@ fn argument_buffer_samplers_are_heap_lookups() { } } +/// A kernel reading a texture and its sampler from an argument buffer has one set-1 sampler +/// array, of `heap_sampler_capacity` elements, on every committed profile that compiles it: the +/// handle table's 65536 where the update-after-bind sampler limits pass it (MoltenVK's 500000, +/// lavapipe's, NVIDIA's), the per-stage limit's 16 on the desktop baseline. On the M3's profile +/// with its per-stage update-after-bind sampler limit lowered to 100, or its set's to 200, the +/// array and the answer follow it. A profile that refuses the kernel answers 0, and so does the +/// M3's without `descriptorBindingPartiallyBound` or `shaderSampledImageArrayNonUniformIndexing`, +/// which refuses it. +#[test] +fn an_argument_sampler_array_has_the_heap_sampler_capacity() { + let Some(bc) = argument_samplers_fixture() else { + return; + }; + let library = Library::from_air(&bc).expect("library"); + // The answer on `desc`, and the element count of the kernel's set-1 sampler array or the + // kernel's refusal. + let array = |desc: DeviceDescription| -> (u32, Result) { + let dev = Device::new(desc, DevicePolicy::default()).expect("device"); + let f = library.function("argument_sampler_sample").expect("entry"); + let d = ComputePipelineDescriptor::new(StageSource::Function(FunctionDescriptor::new(f))); + let count = dev + .compile_compute_pipeline(&d, &Budget::standard()) + .map(|pipe| { + let samplers: Vec = (pipe.layout.sets.iter()) + .filter(|set| set.set == 1) + .flat_map(|set| &set.bindings) + .filter(|b| b.ty == vk::DescriptorType::SAMPLER) + .map(|b| b.count) + .collect(); + assert_eq!(samplers.len(), 1, "one set-1 sampler array: {samplers:?}"); + samplers[0] + }); + (heap_sampler_capacity(dev.profile()), count) + }; + let mut compiled = Vec::new(); + for (stem, desc) in committed_descriptions().expect("descriptions") { + match array(desc.clone()) { + (capacity, Ok(count)) => { + assert_eq!(count, capacity, "{stem}"); + compiled.push((stem.as_str(), count)); + } + (capacity, Err(e)) => assert_eq!(capacity, 0, "{stem}: refused ({e})"), + } + } + eprintln!("set-1 sampler arrays: {compiled:?}"); + for stem in ["moltenvk-m3", "lavapipe", "nvidia-rtx5080-laptop"] { + assert!(compiled.contains(&(stem, 65536)), "{stem}: {compiled:?}"); + } + assert!(compiled.contains(&("lunarg-desktop-baseline-2023", 16))); + let m3 = || { + (committed_descriptions().expect("descriptions").iter()) + .find(|(stem, _)| stem == "moltenvk-m3") + .map(|(_, desc)| desc.clone()) + .expect("moltenvk-m3") + }; + let mut stage = m3(); + stage + .limits + .max_per_stage_descriptor_update_after_bind_samplers = 100; + let (capacity, count) = array(stage); + assert_eq!((capacity, count.ok()), (100, Some(100)), "per stage"); + let mut set = m3(); + set.limits.max_descriptor_set_update_after_bind_samplers = 200; + let (capacity, count) = array(set); + assert_eq!((capacity, count.ok()), (200, Some(200)), "per set"); + for lacking in [ + VkFeature::DescriptorBindingPartiallyBound, + VkFeature::ShaderSampledImageArrayNonUniformIndexing, + ] { + let mut desc = m3(); + desc.features.remove(&lacking); + let (capacity, count) = array(desc); + assert_eq!(capacity, 0, "{lacking:?}"); + assert!(count.is_err(), "{lacking:?}: {count:?}"); + } +} + /// A sample through an argument buffer's sampler tests the sampler's entry for a cubic filter /// (`RuntimeFact::CubicArgumentSampler`) in a kernel on every profile with the heap, marking the /// status by address where the device addresses buffers and through the kernel's binding of it diff --git a/crates/metal2vulkan/tests/api_signatures.tsv b/crates/metal2vulkan/tests/api_signatures.tsv index dcfb033c4..143d3f0a4 100644 --- a/crates/metal2vulkan/tests/api_signatures.tsv +++ b/crates/metal2vulkan/tests/api_signatures.tsv @@ -2069,6 +2069,7 @@ field metal2vulkan-runtime::DeviceProperties.gpu_core_count pub gpu_core_count: field metal2vulkan-runtime::DeviceProperties.has_unified_memory pub has_unified_memory: bool field metal2vulkan-runtime::DeviceProperties.kind pub kind: DeviceKind field metal2vulkan-runtime::DeviceProperties.lossless_compression pub lossless_compression: bool +field metal2vulkan-runtime::DeviceProperties.max_argument_buffer_sampler_count pub max_argument_buffer_sampler_count: u64 field metal2vulkan-runtime::DeviceProperties.max_buffer_length pub max_buffer_length: u64 field metal2vulkan-runtime::DeviceProperties.max_threadgroup_memory_length pub max_threadgroup_memory_length: u64 field metal2vulkan-runtime::DeviceProperties.max_threads_per_threadgroup pub max_threads_per_threadgroup: Size @@ -4868,6 +4869,7 @@ fn metal2vulkan::metal::state::stencil_op pub fn stencil_op(op: StencilOperation fn metal2vulkan::metal::vertex::attribute_fetch pub fn attribute_fetch(format: VertexFormat, step: VertexStepFunction, step_rate: u32, profile: &DeviceProfile) -> Result fn metal2vulkan::metal::vertex::vertex_alignment pub fn vertex_alignment(format: VertexFormat) -> Result fn metal2vulkan::metal::vertex::vk_vertex_format pub fn vk_vertex_format(format: VertexFormat) -> Result +fn metal2vulkan::pipeline::heap_sampler_capacity pub fn heap_sampler_capacity(p: &DeviceProfile) -> u32 fn metal2vulkan::pipeline::heap_unused_while_pending pub fn heap_unused_while_pending(p: &DeviceProfile) -> bool macro-decl metal2vulkan-air::ir::ArgIdx ir_id! ArgIdx macro-decl metal2vulkan-air::ir::BlockId id_type! BlockId diff --git a/crates/metal2vulkan/tests/api_surface.rs b/crates/metal2vulkan/tests/api_surface.rs index 69fa3be4f..f7b73d9f5 100644 --- a/crates/metal2vulkan/tests/api_surface.rs +++ b/crates/metal2vulkan/tests/api_surface.rs @@ -318,6 +318,7 @@ surface! { struct UnwrittenFragmentInputs N; } "pipeline" => metal2vulkan::pipeline { + fn heap_sampler_capacity; fn heap_unused_while_pending; struct ComputePipeline N; struct ComputePipelineMetalInfo N; diff --git a/docs/API.md b/docs/API.md index eee3ca11d..cfdb015ca 100644 --- a/docs/API.md +++ b/docs/API.md @@ -903,7 +903,8 @@ for dependency in &pipeline.dependencies { says whether Metal binds a buffer, a visible-function table or an intersection function table there. - The layout numbers set 0 densely, in `ResourceSlot` order. Set 1 holds the heap arrays (the - resources reached through argument buffers and resource IDs). Push constants carry the values the + resources reached through argument buffers and resource IDs); `pipeline::heap_sampler_capacity` + is the most elements a set-1 sampler array has on a profile. Push constants carry the values the binder writes per command. A stage that writes the command buffer's `ExecutionStatus` (an absent argument's read, a `seq_cst` fence, an argument buffer's cubic sampler) reaches it by device address, a push hole, where the device addresses buffers (`bufferDeviceAddress` and @@ -3883,6 +3884,13 @@ each item named states the rule in full. - **The device counts the sampler IDs it holds** (`Device::sampler_ids_live`, `Device::sampler_id_pool_size`), runtime extensions for a consumer that models Metal's sampler heap. +- **`maxArgumentBufferSamplerCount` is the device's set-1 sampler array less its neutral** + (`DeviceProperties::max_argument_buffer_sampler_count`): one fewer than the smaller of the + array's elements (`pipeline::heap_sampler_capacity`: at most the handle table's 65536 entries + and the update-after-bind sampler limits) and `maxSamplerAllocationCount`. Metal answers 500000 + on an M3 Max; MoltenVK there answers 65535. It counts every live sampler state, with or without + `supportArgumentBuffers`. A state past it reads the neutral sampler through an argument buffer + (`unlisted-argument-sampler`). - **A texture can take no resource ID** (`IdPlacement::Outside`), for a consumer's helper textures and its textures over its own images (`Device::new_texture_with_vk_image`), such as swapchain images. diff --git a/docs/CONFORMANCE-COVERAGE.md b/docs/CONFORMANCE-COVERAGE.md index e798d0c21..0f1c5436a 100644 --- a/docs/CONFORMANCE-COVERAGE.md +++ b/docs/CONFORMANCE-COVERAGE.md @@ -32,11 +32,11 @@ Its limits, measured rather than asserted: | | | |---|---| -| implemented Metal items | 976 | +| implemented Metal items | 977 | | of those, unreachable: `objc2-metal` binds no name for them | 3 | -| so reachable by some case | 973 | +| so reachable by some case | 974 | | of the reachable, exercised by the suite's Metal leg | 794 | -| of the reachable, not exercised | 179 | +| of the reachable, not exercised | 180 | | share of the reachable exercised | 82% | | of those exercised, no case reaching it loosens anything | 574 | | of those exercised, a case reaching it loosens some site | 220 | @@ -364,8 +364,8 @@ Every container with an implemented item, by how much of it the suite reaches. * |---|---|---|---|---|---| | `MTLRenderCommandEncoder` | 119 | 0 | 69 | 50 | `alpha_coverage_pairs`, `blend_interactions`, `blend_sweeps`, `blit_indirect_commands`… | | `MTLArgument` | 17 | 0 | 0 | 17 | | +| `MTLDevice` | 66 | 2 | 51 | 13 | `alpha_coverage_pairs`, `argument_encoder_crossings`, `argument_encoders`, `astc_textures`… | | the header's free functions | 12 | 0 | 0 | 12 | | -| `MTLDevice` | 65 | 2 | 51 | 12 | `alpha_coverage_pairs`, `argument_encoder_crossings`, `argument_encoders`, `astc_textures`… | | `MTLRenderPipelineState` | 22 | 0 | 11 | 11 | `pipeline_facts`, `pipeline_handlers`, `tile_threadgroups`, `visible_tables` | | `MTLMeshRenderPipelineDescriptor` | 27 | 0 | 18 | 9 | `binary_archives`, `indirect_commands`, `mesh_barriers`, `mesh_commands`… | | `MTLRasterizationRateLayerDescriptor` | 9 | 0 | 2 | 7 | `rate_map_degenerate_forms`, `rate_map_sweeps`, `rate_maps` | @@ -469,7 +469,7 @@ A container is one Objective-C type; the SDK header it sits in is the family of | `MTLRenderCommandEncoder.h` | 119 | 69 | 50 | | `MTLRenderPipeline.h` | 130 | 105 | 25 | | `MTLArgument.h` | 77 | 59 | 18 | -| `MTLDevice.h` | 75 | 61 | 14 | +| `MTLDevice.h` | 76 | 61 | 15 | | `MTLRasterizationRate.h` | 36 | 23 | 13 | | `MTLComputePipeline.h` | 34 | 27 | 7 | | `MTLTypes.h` | 7 | 0 | 7 | @@ -1141,6 +1141,7 @@ One row per implemented item of the SDK, in the coverage map's order. *exercised | `newRenderPipelineStateWithMeshDescriptor:options:reflection:error:` | yes | `indirect_commands`, `mesh_barriers`, `mesh_commands`, `mesh_draws`, `mesh_pipeline_reflection`, `pipeline_handlers` | 45 | | `newRenderPipelineStateWithMeshDescriptor:options:completionHandler:` | yes | `pipeline_handlers` | 24 | | `maxThreadgroupMemoryLength` | no | — | — | +| `maxArgumentBufferSamplerCount` | no | — | — | | `programmableSamplePositionsSupported` | no | — | — | | `newArgumentEncoderWithArguments:` | yes | `argument_encoder_crossings`, `argument_encoders` | 9 | | `supportsRasterizationRateMapWithLayerCount:` | yes | `device_queries` | 5 | diff --git a/docs/METAL-COVERAGE.md b/docs/METAL-COVERAGE.md index 42db5912d..ada206945 100644 --- a/docs/METAL-COVERAGE.md +++ b/docs/METAL-COVERAGE.md @@ -10,12 +10,12 @@ Every public item of the macOS 27.0 SDK (Xcode 27.0, 27A266a)'s Metal headers, b | Status | Items | Of which deprecated | |---|---|---| -| implemented | 977 | 36 | -| missing | 809 | 27 | +| implemented | 978 | 36 | +| missing | 808 | 27 | | out of scope | 349 | 5 | | all | 2135 | 68 | -Implemented by the runtime: 645; by the translator's values: 332. Missing by size: S 126, M 147, L 160, XL 376. +Implemented by the runtime: 646; by the translator's values: 332. Missing by size: S 125, M 147, L 160, XL 376. ## Missing, in build order @@ -28,7 +28,7 @@ Cheap items a plain app calls first, then medium pieces by how often a plain app | command queue descriptor | S | 3 | `MTLCommandQueueDescriptor`, `MTLCommandQueueDescriptor.maxCommandBufferCount`, `MTLDevice.newCommandQueueWithDescriptor:` | | compute, blit and resource-state pass descriptors | S | 10 | `MTLBlitPassDescriptor`, `MTLBlitPassDescriptor.blitPassDescriptor`, `MTLCommandBuffer.computeCommandEncoderWithDescriptor:`, ... | | libraries from a file path or URL | S | 2 | `MTLDevice.newLibraryWithFile:error:`, `MTLDevice.newLibraryWithURL:error:` | -| device, state and resource queries | S | 45 | `MTLAllocation.allocatedSize`, `MTLBuffer.sparseBufferTier`, `MTLArchitecture`, ... | +| device, state and resource queries | S | 44 | `MTLAllocation.allocatedSize`, `MTLBuffer.sparseBufferTier`, `MTLArchitecture`, ... | | `textureBarrier` and queue-stage barriers | S/M | 2 | `MTLCommandEncoder.barrierAfterQueueStages:beforeStages:`, `MTLRenderCommandEncoder.textureBarrier` | | a pipeline state's reflection after creation | S | 2 | `MTLComputePipelineState.reflection`, `MTLRenderPipelineState.reflection` | | function handles by name, and a handle's type and ID | S | 4 | `MTLComputePipelineState.functionHandleWithName:`, `MTLFunctionHandle.functionType`, `MTLFunctionHandle.gpuResourceID`, ... | @@ -1440,7 +1440,7 @@ Cheap items a plain app calls first, then medium pieces by how often a plain app | `MTLDevice.newRenderPipelineStateWithMeshDescriptor:options:reflection:error:` | method | implemented | `Device::new_mesh_render_pipeline_state_with_reflection` (runtime) | | `MTLDevice.newRenderPipelineStateWithMeshDescriptor:options:completionHandler:` | method | implemented | `Device::new_mesh_render_pipeline_state_with_reflection` (runtime): handler form | | `MTLDevice.maxThreadgroupMemoryLength` | property | implemented | `DeviceProperties.max_threadgroup_memory_length` (runtime) | -| `MTLDevice.maxArgumentBufferSamplerCount` | property | missing | S: capability query (the runtime's live sampler limit) | +| `MTLDevice.maxArgumentBufferSamplerCount` | property | implemented | `DeviceProperties.max_argument_buffer_sampler_count` (runtime) | | `MTLDevice.programmableSamplePositionsSupported` | property | implemented | `DeviceProperties::are_programmable_sample_positions_supported` (runtime) | | `MTLDevice.getDefaultSamplePositions:count:` | method | missing | S: the standard positions a pass without `sample_positions` rasterizes at | | `MTLDevice.newArgumentEncoderWithArguments:` | method | implemented | `Device::new_argument_encoder_with_arguments` (runtime) | diff --git a/scripts/metal-coverage/coverage.tsv b/scripts/metal-coverage/coverage.tsv index c3a7cd902..57253f8ed 100644 --- a/scripts/metal-coverage/coverage.tsv +++ b/scripts/metal-coverage/coverage.tsv @@ -1117,7 +1117,7 @@ MTLDevice.h MTLDevice method newRenderPipelineStateWithTileDescriptor:options:co MTLDevice.h MTLDevice method newRenderPipelineStateWithMeshDescriptor:options:reflection:error: I runtime Device::new_mesh_render_pipeline_state_with_reflection MTLDevice.h MTLDevice method newRenderPipelineStateWithMeshDescriptor:options:completionHandler: I runtime Device::new_mesh_render_pipeline_state_with_reflection handler form MTLDevice.h MTLDevice property maxThreadgroupMemoryLength I runtime DeviceProperties.max_threadgroup_memory_length -MTLDevice.h MTLDevice property maxArgumentBufferSamplerCount M capability query (the runtime's live sampler limit) S queries +MTLDevice.h MTLDevice property maxArgumentBufferSamplerCount I runtime DeviceProperties.max_argument_buffer_sampler_count MTLDevice.h MTLDevice property programmableSamplePositionsSupported I runtime DeviceProperties::are_programmable_sample_positions_supported MTLDevice.h MTLDevice method getDefaultSamplePositions:count: M the standard positions a pass without `sample_positions` rasterizes at S queries MTLDevice.h MTLDevice method newArgumentEncoderWithArguments: I runtime Device::new_argument_encoder_with_arguments