diff --git a/crates/metal2vulkan-conformance/src/rt_side/render.rs b/crates/metal2vulkan-conformance/src/rt_side/render.rs index 15ad3c7f9..0bb989bf5 100644 --- a/crates/metal2vulkan-conformance/src/rt_side/render.rs +++ b/crates/metal2vulkan-conformance/src/rt_side/render.rs @@ -456,9 +456,9 @@ impl RtSide<'_> { VisibilityResultType::Reset => rt::VisibilityResultType::Reset, VisibilityResultType::Accumulate => rt::VisibilityResultType::Accumulate, }; - if !pass.positions.is_empty() { - return Err(Failure::unavailable("setSamplePositions:count:")); - } + descriptor.sample_positions = (pass.positions.iter()) + .map(|p| rt::SamplePosition::new(p.x, p.y)) + .collect(); let mut encoder = (command_buffer.render_command_encoder(&descriptor)).map_err(of_rt)?; let encoded = (pass.steps.iter()).try_for_each(|step| self.step(&mut encoder, step)); encoder.end_encoding(); diff --git a/crates/metal2vulkan-runtime/README.md b/crates/metal2vulkan-runtime/README.md index 22a4e8ad3..f4cacae24 100644 --- a/crates/metal2vulkan-runtime/README.md +++ b/crates/metal2vulkan-runtime/README.md @@ -94,6 +94,13 @@ them over this crate's items: `Device::with_present_queue` runs the consumer's presents on the presenting queue under its lock (see "Presenting"). The runtime keeps owning every handle. - `Device::has_unified_memory` is true where Vulkan's device type is integrated or CPU. +- `Device::programmable_sample_positions_supported` answers `programmableSamplePositionsSupported`: + true where the device lists `VK_EXT_sample_locations` with locations at every sample count above + 1 that `Device::supports_texture_sample_count` answers, one set for every pixel, every sixteenth + of a pixel from 0 to 15/16, and `variableSampleLocations`. A pass then rasterizes at the + positions its descriptor sets (`RenderPassDescriptor::sample_positions`), each coordinate taken + to the nearest sixteenth (a tie up, at most 15/16) and each sample past the positions given at + the pixel's corner, as an Apple M4 takes them. - `Device::max_threadgroup_memory_length` answers `maxThreadgroupMemoryLength`: the device's `maxComputeSharedMemorySize` less the 4-byte vote word a kernel's partial-threadgroups variant may take beside its threadgroup memory, rounded down to 16, and at most Metal's 32,768. A kernel @@ -5182,14 +5189,23 @@ cache is answered compile-required on both. streams' passes render into one or two color attachments and a stencil attachment or a `Depth32Float` depth attachment, each a level of a 2D texture of one sample, with `Load`, `Clear` and `DontCare` loads and `Store`, `DontCare` and `Unknown` stores. -- Programmable sample positions are not built. The descriptor has no field for - `setSamplePositions:count:`, and the runtime answers no `programmableSamplePositionsSupported`. - Every multisample pass rasterizes at Vulkan's standard sample locations - (`standardSampleLocations`, under Floor), which are Metal's default positions at 1, 2 and 4 - samples. Metal rasterizes a pass at the positions the program sets; a pass whose set differs - from the defaults samples here at the defaults, with no refusal. A consumer that answers the - query YES owns counting and dropping a set that differs from the defaults. Vulkan's form for - such positions is `VK_EXT_sample_locations`, which device creation does not enable. +- Programmable sample positions (`RenderPassDescriptor::sample_positions`) are built through + `VK_EXT_sample_locations`, on a device whose properties hold Metal's grid at every sample count + it renders (`Device::programmable_sample_positions_supported`). A device without the extension, + or whose properties fall short of that (a sample count it renders missing from + `sampleLocationSampleCounts`, a coordinate range short of 15/16, fewer than 4 sub-pixel bits, + or no `variableSampleLocations`), answers no; a pass there that sets positions other than the + defaults is refused (`Refusal::SamplePositions` of `Unsupported`), as Metal refuses positions on + a device that does not support them, and a set that comes to the defaults rasterizes as none. + Two shapes are not built. A pass that sets other positions and has a depth attachment is + `Gap::RenderPass` of `SamplePositions`: Vulkan takes such a pass only into a depth image made + sample-locations-compatible, whose depth its layout transitions leave undefined unless each + names the locations the image was last rendered at. A draw in such a pass whose fragment + function interpolates at a sample (`interpolate_at_sample`, or a sample-qualified input read + per covered sample) is `Gap::Draw` of `SamplePositions`: Vulkan forbids `InterpolateAtSample` in + a pipeline drawn at custom sample locations. `getDefaultSamplePositions:count:` is not + answered; a pass that sets none rasterizes at Vulkan's standard sample locations + (`standardSampleLocations`, under Floor), which are Metal's defaults at 1, 2 and 4 samples. - Layered rendering refuses: in a pass of `renderTargetArrayLength` 2 or more, an attachment or a resolve texture with fewer slices from its own `slice` than the pass's length (`Refusal::AttachmentPlace`, naming the last slice the pass would render), a 3D texture's @@ -5665,6 +5681,7 @@ Presenting runs on the runtime's own device; nothing is exported or imported. | `VK_EXT_device_fault` | device, where listed | a lost device's fault report, read once at its first loss (`DeviceLoss::fault`), through the fault-report feature below | | `VK_EXT_pipeline_robustness` | device, where listed | a kernel's buffers bound as storage buffers of set 0, contained by its pipeline's robust buffer access 2, through the pipeline-robustness feature below (Bound kernel buffers) | | `VK_KHR_maintenance8` | device, where listed | a sample at a texel offset the shader computes, with the offset as the sample's own `Offset` operand, through the optional feature `maintenance8` below | +| `VK_EXT_sample_locations` | device, where listed | a render pass's sample positions (`RenderPassDescriptor::sample_positions`), as the dynamic sample locations of pipelines made for them, where its properties hold what `Device::programmable_sample_positions_supported` asks; it has no feature | | `VK_EXT_custom_border_color` | device, where reported from the image | Vulkan requires it of a device that enables the border swizzle below; none of its features is enabled | | `VK_EXT_border_color_swizzle` | device, where reported from the image | an opaque-black border sampled through a view whose component mapping is not the identity, defined and read through that mapping (Border swizzle, below) | | `VK_EXT_device_generated_commands` | device, with indirect command buffers | an indirect command buffer's execution, through `deviceGeneratedCommands`, enabled where the device reports it with the limits an execution needs (Indirect command buffers, above) | diff --git a/crates/metal2vulkan-runtime/src/device.rs b/crates/metal2vulkan-runtime/src/device.rs index 11dc14456..9827ac17c 100644 --- a/crates/metal2vulkan-runtime/src/device.rs +++ b/crates/metal2vulkan-runtime/src/device.rs @@ -293,6 +293,11 @@ pub(crate) struct Core { pub(crate) linear_attachments: bool, /// The depth and stencil resolve modes a render pass may resolve by. pub(crate) resolve_modes: ResolveModes, + /// `VK_EXT_sample_locations`' commands and sample counts, where device creation enabled it + /// and its properties hold what a pass's sample positions need + /// ([`Locations::offered`](crate::positions::Locations::offered)): the device answers + /// `programmableSamplePositionsSupported` yes. + pub(crate) sample_locations: Option, /// The longest block: the device's `maxMemoryAllocationSize` or `maxBufferSize`, whichever is /// less. pub(crate) max_block_len: u64, @@ -800,6 +805,28 @@ impl Device { .extensions .contains(&ash::ext::device_fault::NAME)) .then(|| ash::ext::device_fault::Device::new(vk_instance, &device)); + let sample_locations = (capabilities.extensions) + .contains(&ash::ext::sample_locations::NAME) + .then(|| { + let mut locations = vk::PhysicalDeviceSampleLocationsPropertiesEXT::default(); + { + let mut properties = + vk::PhysicalDeviceProperties2::default().push_next(&mut locations); + // SAFETY: as for the floor check; the device lists the extension, which + // defines the structure. + unsafe { vk_instance.get_physical_device_properties2(raw, &mut properties) }; + } + // The translator's flags are its own `vk`'s: the same bits. + let raster = translator.metal_properties().raster_sample_counts.as_raw(); + let raster = vk::SampleCountFlags::from_raw(raster); + crate::positions::Locations::offered(&locations, raster).then(|| { + crate::positions::Locations { + loader: ash::ext::sample_locations::Device::new(vk_instance, &device), + counts: locations.sample_location_sample_counts, + } + }) + }) + .flatten(); let indirect = (capabilities.indirect_commands).and_then(|limits| { // SAFETY: the device was made from `vk_instance`, with the extension, as the limits // are there. @@ -880,6 +907,7 @@ impl Device { linear_attachments: (capabilities.features.linear_attachment).linear_color_attachment == vk::TRUE, resolve_modes, + sample_locations, max_block_len, max_allocations, granularity, @@ -1022,6 +1050,21 @@ impl Device { count.is_power_of_two() && count <= 64 && counts.as_raw() & count != 0 } + /// `programmableSamplePositionsSupported`: whether a render pass rasterizes at the sample + /// positions its descriptor sets + /// ([`RenderPassDescriptor::sample_positions`](crate::RenderPassDescriptor::sample_positions)). + /// True where the device lists `VK_EXT_sample_locations` (one of the floor's + /// [`OPTIONAL_EXTENSIONS`](crate::floor::OPTIONAL_EXTENSIONS)) with locations at each sample + /// count above 1 that [`supports_texture_sample_count`](Device::supports_texture_sample_count) + /// answers, one set for every pixel, every sixteenth of a pixel from 0 to 15/16 (Metal's + /// grid), and locations that may differ between the pipelines of one command buffer + /// (`variableSampleLocations`). False elsewhere, where a pass whose positions differ from the + /// defaults is refused ([`Refusal::SamplePositions`](crate::Refusal::SamplePositions)), as + /// Metal refuses positions on a device that does not support them. + pub fn programmable_sample_positions_supported(&self) -> bool { + self.shared.core.sample_locations.is_some() + } + /// No Metal counterpart: the device extensions enabled: the floor's first, then each of the /// consumer's ([`DeviceOptions::extensions`]) the device offers with its features. pub fn extensions(&self) -> &[CString] { diff --git a/crates/metal2vulkan-runtime/src/error.rs b/crates/metal2vulkan-runtime/src/error.rs index f937a168a..4d4c0fe86 100644 --- a/crates/metal2vulkan-runtime/src/error.rs +++ b/crates/metal2vulkan-runtime/src/error.rs @@ -999,6 +999,28 @@ pub enum Refusal { /// `defaultRasterSampleCount`. samples: u32, }, + /// A render pass's sample positions (`setSamplePositions:count:`) other than the device's + /// own: more positions than the pass's samples; a coordinate outside `[0, 1)`; positions in a + /// pass of one sample; or positions on a device whose + /// [`programmable_sample_positions_supported`](crate::Device::programmable_sample_positions_supported) + /// answers no. A set that comes to the device's own positions is no such set + /// ([`RenderPassDescriptor::sample_positions`](crate::RenderPassDescriptor::sample_positions)). + /// + /// Basis: metal-documented (`MTLRenderPass.h`: the positions are "to be used in MSAA rendering + /// (i.e. when sample count > 1)" and the count "must be a valid sample count"; `MTLTypes.h`: + /// a position's range is "[0,1) for both x and y"; `MTLDevice.h`'s + /// `programmableSamplePositionsSupported`; Metal's validation stops a pass of more positions + /// than samples, a coordinate outside the pixel and positions in a pass of one sample, and one + /// position past the samples ends plain Metal's process on an Apple M4, the conformance + /// suite's `sample_positions` module). + SamplePositions { + /// Which of them. + kind: SamplePositionsKind, + /// The positions set. + count: u32, + /// The pass's samples. + samples: u32, + }, /// A draw whose vertex descriptor reads a vertex buffer at an offset at or past the buffer's /// length. /// @@ -1750,6 +1772,21 @@ pub enum StageInKind { IndexedStepRate, } +/// Which sample positions a render pass refuses ([`Refusal::SamplePositions`]). +#[non_exhaustive] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] +pub enum SamplePositionsKind { + /// The device answers no + /// [`programmable_sample_positions_supported`](crate::Device::programmable_sample_positions_supported). + Unsupported, + /// More positions than the pass's samples. + Count, + /// A coordinate outside `[0, 1)`, or NaN. + Coordinate, + /// Positions other than the device's own in a pass of one sample. + OneSample, +} + /// What a draw asks that the runtime does not build ([`Gap::Draw`]). #[non_exhaustive] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] @@ -1842,6 +1879,14 @@ pub enum DrawKind { /// segment, whose count each draw would add to. Metal tests and writes the stencil against the /// output in one draw. StencilOutput, + /// A draw in a pass of custom sample positions + /// ([`RenderPassDescriptor::sample_positions`](crate::RenderPassDescriptor::sample_positions)) + /// whose fragment function interpolates a varying at a sample (`interpolate_at_sample`, or a + /// sample-qualified varying read in the loop over its covered samples): its module uses + /// `InterpolateAtSample`, which Vulkan forbids in a pipeline drawn at custom sample locations + /// (`VUID-VkGraphicsPipelineCreateInfo-sampleLocationsEnable-01524`). Metal interpolates such a + /// varying at the sample's own position. + SamplePositions, } /// What a render pass asks that the runtime does not build ([`Gap::RenderPass`]). @@ -1928,6 +1973,16 @@ pub enum RenderPassKind { /// `Unknown` with a resolve texture: the rendering began resolving into the texture, as Vulkan /// fixes the resolve as the rendering begins. LateStore, + /// Custom sample positions + /// ([`RenderPassDescriptor::sample_positions`](crate::RenderPassDescriptor::sample_positions)) + /// at a sample count the device's `sampleLocationSampleCounts` lacks (a count past those + /// [`Device::supports_texture_sample_count`](crate::Device::supports_texture_sample_count) + /// answers), or in a pass with a multisample depth attachment: Vulkan draws such a pass only + /// into a depth image made sample-locations-compatible + /// (`VUID-vkCmdDraw-sampleLocationsEnable-02689`), whose depth reads with other locations than + /// its last writes', and whose layout transitions without those locations, leave it undefined, + /// which Metal's depth after a pass at custom positions is not. + SamplePositions, /// An attachment that is neither a level of a 2D texture, a 2D array, a cube, a cube array or a /// 2D multisample texture or array, nor a depth plane of a 3D texture's level that a color /// attachment renders in a pass of one layer: a 1D texture's; a 3D texture's in a layered pass @@ -2828,6 +2883,24 @@ impl fmt::Display for Refusal { f, "a pass with no attachment of {width} by {height} pixels at {samples} samples" ), + Refusal::SamplePositions { + kind, + count, + samples, + } => { + let why = match kind { + SamplePositionsKind::Unsupported => { + "the device has no programmable sample positions" + } + SamplePositionsKind::Count => "more positions than samples", + SamplePositionsKind::Coordinate => "a coordinate outside [0, 1)", + SamplePositionsKind::OneSample => "positions in a pass of one sample", + }; + write!( + f, + "{count} sample positions for a pass of {samples} samples: {why}" + ) + } Refusal::ResolveTexture => { write!(f, "a store action resolves an attachment with no resolve texture") } diff --git a/crates/metal2vulkan-runtime/src/error/basis.rs b/crates/metal2vulkan-runtime/src/error/basis.rs index faa5f95a1..00f1f5928 100644 --- a/crates/metal2vulkan-runtime/src/error/basis.rs +++ b/crates/metal2vulkan-runtime/src/error/basis.rs @@ -85,6 +85,7 @@ impl Refusal { Refusal::AttachmentPlace { .. } => RefusalBasis::Ours, Refusal::AttachmentFormat { .. } => RefusalBasis::MetalDocumented, Refusal::NoAttachmentPass { .. } => RefusalBasis::MetalMeasured, + Refusal::SamplePositions { .. } => RefusalBasis::MetalDocumented, Refusal::VertexBufferOffset { .. } => RefusalBasis::MetalDocumented, Refusal::IndexBufferOffset { .. } => RefusalBasis::MetalDocumented, Refusal::TessellationFactorOffset { .. } => RefusalBasis::MetalDocumented, diff --git a/crates/metal2vulkan-runtime/src/floor.rs b/crates/metal2vulkan-runtime/src/floor.rs index 4baf026e0..20a1b10e9 100644 --- a/crates/metal2vulkan-runtime/src/floor.rs +++ b/crates/metal2vulkan-runtime/src/floor.rs @@ -61,8 +61,10 @@ pub const TIME_DOMAINS: [vk::TimeDomainKHR; 2] = /// report is read once, at its first loss ([`DeviceLoss::fault`](crate::DeviceLoss::fault)), /// `VK_EXT_pipeline_robustness`, with its `pipelineRobustness` feature where the device reports it, /// through which a kernel's pipeline contains its buffer arguments' storage buffers by robust -/// buffer access 2, and `VK_KHR_maintenance8` ([`MAINTENANCE8`]), for the -/// optional feature of its own. +/// buffer access 2, `VK_KHR_maintenance8` ([`MAINTENANCE8`]), for the +/// optional feature of its own, and `VK_EXT_sample_locations`, which has no feature, through which +/// a render pass rasterizes at the sample positions its descriptor sets, where its properties +/// hold them ([`Device::programmable_sample_positions_supported`](crate::Device::programmable_sample_positions_supported)). pub const OPTIONAL_EXTENSIONS: &[&CStr] = &[ ash::khr::shader_maximal_reconvergence::NAME, ash::khr::shader_subgroup_uniform_control_flow::NAME, @@ -82,6 +84,7 @@ pub const OPTIONAL_EXTENSIONS: &[&CStr] = &[ ash::ext::device_fault::NAME, ash::ext::pipeline_robustness::NAME, MAINTENANCE8, + ash::ext::sample_locations::NAME, ]; /// `VK_KHR_maintenance8`, which ash 0.38 does not bind: one of [`OPTIONAL_EXTENSIONS`], for its @@ -232,6 +235,8 @@ pub(crate) fn shader_extension(name: &CStr) -> Option { Some(VkExtension::ExtExternalMemoryHost) } else if name == ash::ext::pipeline_robustness::NAME { Some(VkExtension::ExtPipelineRobustness) + } else if name == ash::ext::sample_locations::NAME { + Some(VkExtension::ExtSampleLocations) } else { None } diff --git a/crates/metal2vulkan-runtime/src/lib.rs b/crates/metal2vulkan-runtime/src/lib.rs index 30f04e9d0..2b5680466 100644 --- a/crates/metal2vulkan-runtime/src/lib.rs +++ b/crates/metal2vulkan-runtime/src/lib.rs @@ -89,8 +89,8 @@ pub use device::{Device, DeviceOptions, RawDevice}; pub use encoder::{ComputeCommandEncoder, Dispatch, DispatchType, Resource, ResourceUsage}; pub use error::{ DrawKind, Error, Gap, IndirectCommandsKind, KernelInputKind, Limit, PartialThreadgroupsSite, - Refusal, RefusalBasis, RenderPassKind, RenderPipelineKind, StageGap, StageInKind, - StorageElementCase, TextureBacking, TextureViewKind, + Refusal, RefusalBasis, RenderPassKind, RenderPipelineKind, SamplePositionsKind, StageGap, + StageInKind, StorageElementCase, TextureBacking, TextureViewKind, }; pub use event::{Event, SharedEvent}; pub use export::{Export, ExportHandle}; diff --git a/crates/metal2vulkan-runtime/src/pass.rs b/crates/metal2vulkan-runtime/src/pass.rs index b1e3c02b1..4d1508378 100644 --- a/crates/metal2vulkan-runtime/src/pass.rs +++ b/crates/metal2vulkan-runtime/src/pass.rs @@ -434,8 +434,20 @@ pub struct RenderPassDescriptor { pub visibility_result_type: VisibilityResultType, /// `setSamplePositions:count:` and `getSamplePositions:count:`: where the pass's samples lie /// in each pixel, sample `i` at position `i`, or empty, Metal's default, for the device's own - /// positions. Held, and not applied yet: every multisample pass rasterizes at Vulkan's - /// standard sample locations. + /// positions. The pass rasterizes at them, each coordinate taken to the nearest sixteenth of + /// a pixel (a tie up, at most 15/16) and each sample past them at the pixel's corner, as an + /// Apple M4 took them, through `VK_EXT_sample_locations` + /// ([`Device::programmable_sample_positions_supported`](crate::Device::programmable_sample_positions_supported)). + /// A set that comes to Metal's default positions at 1, 2 or 4 samples (Vulkan's standard + /// locations) rasterizes as an empty one, on every device. + /// + /// Refused ([`Refusal::SamplePositions`](crate::Refusal::SamplePositions)), as Metal's + /// validation stops the descriptor: more positions than the pass's samples, a coordinate + /// outside `[0, 1)`, other positions in a pass of one sample, or on a device that answers no. + /// Not built ([`RenderPassKind::SamplePositions`](crate::RenderPassKind::SamplePositions)): + /// other positions at a sample count whose locations the device does not offer, or in a pass + /// with a depth attachment. A draw whose fragment function interpolates at a sample in such a + /// pass is not built either ([`DrawKind::SamplePositions`](crate::DrawKind::SamplePositions)). pub sample_positions: Vec, } @@ -763,6 +775,10 @@ pub(crate) struct Pass { /// Whether any attachment resolves: a pass that resolves nothing walks no resolve as its /// encoder begins and ends ([`Pass::resolves`]). pub(crate) resolving: bool, + /// The sample locations the pass rasterizes at, where its descriptor sets positions other + /// than the defaults (`crate::positions::check`): its draws take pipelines made for them, and + /// the encoder records them before its first draw. + pub(crate) positions: Option, } #[cfg(test)] @@ -868,7 +884,8 @@ impl Pass { /// Err: [`Refusal::OtherDevice`] for another device's texture or visibility result buffer; /// [`Refusal::AttachmentUsage`]; [`Refusal::AttachmentPlace`]; [`Refusal::AttachmentFormat`]; /// [`Refusal::ResolveTexture`]; [`Refusal::ResolveFormat`]; [`Refusal::NoAttachmentPass`]; - /// [`Gap::RenderPass`]; what a marked plane's stand-in refuses (`TextureObject::stand_in`); + /// [`Refusal::SamplePositions`]; [`Gap::RenderPass`]; what a marked plane's stand-in refuses + /// (`TextureObject::stand_in`); /// [`Error::Vulkan`] where an attachment's view or a stand-in cannot be made. pub(crate) fn check(core: &Arc, d: &RenderPassDescriptor) -> Result { let gap = |kind| Error::Unsupported(Gap::RenderPass { kind }); @@ -1097,6 +1114,7 @@ impl Pass { samples: vk::SampleCountFlags::empty(), layers, resolving: any_resolve, + positions: None, }; let colors = pass.colors.iter().flatten(); let resolves = (any_resolve.then(|| colors.clone()).into_iter().flatten()) @@ -1168,6 +1186,12 @@ impl Pass { pass.area[axis] = area; pass.reach[axis] = area.next_multiple_of(REACH).min(level[axis]); } + pass.positions = crate::positions::check( + core.sample_locations.as_ref(), + &d.sample_positions, + pass.samples, + pass.depth.is_some(), + )?; Ok(pass) } } diff --git a/crates/metal2vulkan-runtime/src/positions.rs b/crates/metal2vulkan-runtime/src/positions.rs index bc57dcbb3..741e35cf5 100644 --- a/crates/metal2vulkan-runtime/src/positions.rs +++ b/crates/metal2vulkan-runtime/src/positions.rs @@ -1,5 +1,32 @@ //! Programmable sample positions: where a multisample pass's samples lie in each pixel //! (`MTLRenderPassDescriptor`'s `setSamplePositions:count:`). +//! +//! A device offers them through `VK_EXT_sample_locations` (one of the floor's +//! [`OPTIONAL_EXTENSIONS`](crate::floor::OPTIONAL_EXTENSIONS)), and answers +//! `programmableSamplePositionsSupported` yes only where its properties hold what a pass needs +//! ([`Locations::offered`]); a device that does not answers no, and a pass that sets other +//! positions there is refused, as Metal refuses positions a device does not support. +//! +//! A pass's positions ([`locations`]) are taken as Metal takes them: each coordinate to the nearest +//! sixteenth of a pixel, a tie up, at most 15/16 ([`on_grid`], the rule the conformance suite's +//! `sample_positions` rows measured on an Apple M4), and a sample past the positions given at the +//! pixel's corner, (0, 0), where plain Metal put them on the M4. Every coordinate the pass hands +//! Vulkan is then a sixteenth in `[0, 15/16]`, which every device with the extension represents +//! exactly: Vulkan requires `sampleLocationSubPixelBits` of 4 and a `sampleLocationCoordinateRange` +//! of `[0, 0.9375]` at least. A set that comes to Vulkan's standard locations for the pass's +//! samples (the floor's `standardSampleLocations`, Metal's defaults at 1, 2 and 4 samples) is the +//! device's own: the pass rasterizes as one that sets none. +//! +//! A pass of other positions draws with `VkPipeline`s made with `sampleLocationsEnable` and the +//! locations as dynamic state ([`Raster::positions`](crate::render::Raster)), and its encoder +//! records `vkCmdSetSampleLocationsEXT` before its first draw ([`PassPositions::record`]), so one +//! `VkPipeline` serves every set. Vulkan lets the locations differ between the pipelines of a +//! command buffer only on a device with `variableSampleLocations` +//! (`VUID-vkCmdSetSampleLocationsEXT-variableSampleLocations-01530` asks the rest for a render +//! pass's begin info, which a dynamic rendering has no place for), so the answer needs it. + +use crate::error::{Error, Gap, Refusal, RenderPassKind, SamplePositionsKind}; +use ash::vk; /// `MTLSamplePosition`: where a sample lies in its pixel, from the pixel's top-left corner, each /// coordinate in `[0, 1)`. @@ -17,3 +44,217 @@ impl SamplePosition { SamplePosition { x, y } } } + +/// Metal's grid: a coordinate lies on a sixteenth of a pixel. +const GRID: f32 = 16.0; + +/// The most sixteenths a coordinate takes: 15/16, the right or bottom edge's last. +const LAST: f32 = 15.0; + +/// `coordinate` as Metal takes it: to the nearest sixteenth of a pixel, a tie up, and at most +/// 15/16. An Apple M4 covered against an edge at 0.52 with positions at 0.51 and 0.53 and not +/// with 0.53125, 0.55, 0.5624 or 0.5625, and against one at 0.95 with 0.97 and 0.99 (the +/// conformance suite's `sample_positions` rows). +pub(crate) fn on_grid(coordinate: f32) -> f32 { + ((coordinate * GRID + 0.5).floor().min(LAST)) / GRID +} + +/// Vulkan's standard sample locations of `samples` samples (the Vulkan specification's +/// "Standard Sample Locations" table), sample `i` at `i`, which the floor's +/// `standardSampleLocations` makes the device's own: Metal's default positions at 1, 2 and 4 +/// samples. None for a count the table does not hold. +fn standard(samples: u32) -> Option<&'static [[f32; 2]]> { + Some(match samples { + 1 => &[[0.5, 0.5]], + 2 => &[[0.75, 0.75], [0.25, 0.25]], + 4 => &[ + [0.375, 0.125], + [0.875, 0.375], + [0.125, 0.625], + [0.625, 0.875], + ], + 8 => &[ + [0.5625, 0.3125], + [0.4375, 0.6875], + [0.8125, 0.5625], + [0.3125, 0.1875], + [0.1875, 0.8125], + [0.0625, 0.4375], + [0.6875, 0.9375], + [0.9375, 0.0625], + ], + 16 => &[ + [0.5625, 0.5625], + [0.4375, 0.3125], + [0.3125, 0.625], + [0.75, 0.4375], + [0.1875, 0.375], + [0.625, 0.8125], + [0.8125, 0.6875], + [0.6875, 0.1875], + [0.375, 0.875], + [0.5, 0.0625], + [0.25, 0.125], + [0.125, 0.75], + [0.0, 0.5], + [0.9375, 0.25], + [0.875, 0.9375], + [0.0625, 0.0], + ], + _ => return None, + }) +} + +/// The device's custom sample locations, where it answers `programmableSamplePositionsSupported` +/// yes ([`Locations::offered`]). +#[derive(Clone)] +pub(crate) struct Locations { + /// `VK_EXT_sample_locations`' commands. + pub(crate) loader: ash::ext::sample_locations::Device, + /// `sampleLocationSampleCounts`: the counts a pass may set positions at. + pub(crate) counts: vk::SampleCountFlags, +} + +impl Locations { + /// Whether a device whose `VK_EXT_sample_locations` properties are `properties` answers + /// `programmableSamplePositionsSupported` yes, where it renders `raster` (the sample counts + /// it answers `supportsTextureSampleCount:` for): positions at each of those counts above 1 + /// (`sampleLocationSampleCounts`), one set for every pixel (`maxSampleLocationGridSize` of at + /// least 1 x 1), every sixteenth from 0 to 15/16 (`sampleLocationCoordinateRange` and + /// `sampleLocationSubPixelBits` of 4 or more), and locations that differ between the + /// pipelines of one command buffer (`variableSampleLocations`). Vulkan requires all but the + /// counts past 4 and the last of every device that lists the extension. + pub(crate) fn offered( + properties: &vk::PhysicalDeviceSampleLocationsPropertiesEXT, + raster: vk::SampleCountFlags, + ) -> bool { + let multisample = vk::SampleCountFlags::from_raw(raster.as_raw() & !1); + let grid = properties.max_sample_location_grid_size; + let [low, high] = properties.sample_location_coordinate_range; + properties + .sample_location_sample_counts + .contains(multisample) + && grid.width >= 1 + && grid.height >= 1 + && low <= 0.0 + && high >= LAST / GRID + && properties.sample_location_sub_pixel_bits >= 4 + && properties.variable_sample_locations == vk::TRUE + } +} + +/// A pass's custom sample locations, checked ([`check`], placed by [`locations`]): Vulkan's, +/// sample `i`'s at `i`, for every pixel. +pub(crate) struct PassPositions { + loader: ash::ext::sample_locations::Device, + samples: vk::SampleCountFlags, + locations: Vec, +} + +impl PassPositions { + /// Records `vkCmdSetSampleLocationsEXT` of the pass's locations into `command`. + /// + /// # Safety + /// + /// `command` is recording, on the device whose extension `loader` is. + pub(crate) unsafe fn record(&self, command: vk::CommandBuffer) { + let info = vk::SampleLocationsInfoEXT::default() + .sample_locations_per_pixel(self.samples) + .sample_location_grid_size(vk::Extent2D { + width: 1, + height: 1, + }) + .sample_locations(&self.locations); + // SAFETY: as the caller states; the count is one of `sampleLocationSampleCounts` and the + // grid of 1 x 1 divides every count's (`locations`). + unsafe { self.loader.cmd_set_sample_locations(command, &info) }; + } +} + +/// The custom locations a pass of `samples` samples rasterizes at for `positions` +/// (`setSamplePositions:count:`), on a device whose locations are `device` (none where it answers +/// no), `depth` where the pass has a depth attachment, as [`locations`] places them, with the +/// device's command that sets them. +/// +/// Err: as [`locations`]. +pub(crate) fn check( + device: Option<&Locations>, + positions: &[SamplePosition], + samples: vk::SampleCountFlags, + depth: bool, +) -> Result, Error> { + let counts = device.map(|device| device.counts); + let placed = locations(counts, positions, samples, depth)?; + // A set placed is a device's: one that answers no refuses it above. + Ok( + (placed.zip(device)).map(|(locations, device)| PassPositions { + loader: device.loader.clone(), + samples, + locations, + }), + ) +} + +/// Vulkan's locations, sample `i`'s at `i`, a pass of `samples` samples rasterizes at for +/// `positions`, on a device whose `sampleLocationSampleCounts` are `counts` (none where it answers +/// `programmableSamplePositionsSupported` no), `depth` where the pass has a depth attachment. +/// `None` where it rasterizes at the device's own: `positions` is empty, or comes to Vulkan's +/// standard locations once each coordinate is on Metal's grid ([`on_grid`]) and each sample past +/// it at the pixel's corner. +/// +/// Err: [`Refusal::SamplePositions`], as Metal's validation stops the descriptor: more positions +/// than the pass's samples, a coordinate outside `[0, 1)`, other positions in a pass of one +/// sample, or on a device that answers no; [`Gap::RenderPass`] of +/// [`RenderPassKind::SamplePositions`]: other positions at a count `counts` lacks, or in a pass +/// with a depth attachment. +pub(crate) fn locations( + counts: Option, + positions: &[SamplePosition], + samples: vk::SampleCountFlags, + depth: bool, +) -> Result>, Error> { + if positions.is_empty() { + return Ok(None); + } + let count = samples.as_raw(); + let refused = |kind| { + Err(Error::Refused(Refusal::SamplePositions { + kind, + count: positions.len() as u32, + samples: count, + })) + }; + if positions.len() > count as usize { + return refused(SamplePositionsKind::Count); + } + let inside = |c: f32| (0.0..1.0).contains(&c); + if !positions.iter().all(|p| inside(p.x) && inside(p.y)) { + return refused(SamplePositionsKind::Coordinate); + } + let corner = vk::SampleLocationEXT { x: 0.0, y: 0.0 }; + let mut locations: Vec = (positions.iter()) + .map(|p| vk::SampleLocationEXT { + x: on_grid(p.x), + y: on_grid(p.y), + }) + .collect(); + locations.resize(count as usize, corner); + let own = standard(count).is_some_and(|table| { + (table.iter().zip(&locations)).all(|(&[x, y], at)| (at.x, at.y) == (x, y)) + }); + if own { + return Ok(None); + } + if count == 1 { + return refused(SamplePositionsKind::OneSample); + } + let Some(counts) = counts else { + return refused(SamplePositionsKind::Unsupported); + }; + if !counts.contains(samples) || depth { + return Err(Error::Unsupported(Gap::RenderPass { + kind: RenderPassKind::SamplePositions, + })); + } + Ok(Some(locations)) +} diff --git a/crates/metal2vulkan-runtime/src/render.rs b/crates/metal2vulkan-runtime/src/render.rs index ad1481255..9c689fc78 100644 --- a/crates/metal2vulkan-runtime/src/render.rs +++ b/crates/metal2vulkan-runtime/src/render.rs @@ -16,19 +16,21 @@ //! their compile does not read are two contents, each compiled. //! //! What a `VkPipeline` bakes is what Vulkan 1.3 cannot leave dynamic: the content, the topology -//! class (point, line or triangle) of the draws it serves, and the encoder's depth clip mode and -//! triangle fill mode ([`Raster`]). Everything Metal sets on the -//! encoder that Vulkan 1.3 makes dynamic without a feature is dynamic state: the viewports and -//! scissors with their count, -//! cull mode, front face, the primitive topology within its class and primitive restart, the -//! depth test, write and compare, the stencil test, operations, masks and reference, depth bias -//! and blend constants. Vertex buffer strides are the descriptor's, so the content's: they are -//! baked, and a layout whose stride is set per bind (`MTLBufferLayoutStrideDynamic`), which the -//! replay streams' never are, is refused. A draw under the depth clip mode `Clamp` or the triangle -//! fill mode `Lines` takes a `VkPipeline` of its class made for that raster state, by the first -//! such draw of the content, which waits for it, as a draw of a class not made yet does: Metal -//! sets both per encoder and compiles nothing for them. The fill mode is a triangle's -//! alone, in Metal and in Vulkan, so the line and point classes take the clip mode alone. +//! class (point, line or triangle) of the draws it serves, the encoder's depth clip mode and +//! triangle fill mode, and whether its pass sets sample positions ([`Raster`]). Everything Metal +//! sets on the encoder that Vulkan 1.3 makes dynamic without a feature is dynamic state: the +//! viewports and scissors with their count, cull mode, front face, the primitive topology within +//! its class and primitive restart, the depth test, write and compare, the stencil test, +//! operations, masks and reference, depth bias and blend constants; a pass's sample positions are +//! the dynamic state of the pipelines made for them. Vertex buffer strides are the descriptor's, +//! so the content's: they are baked, and a layout whose stride is set per bind +//! (`MTLBufferLayoutStrideDynamic`), which the replay streams' never are, is refused. A draw under +//! the depth clip mode `Clamp` or the triangle fill mode `Lines` takes a `VkPipeline` of its class +//! made for that raster state, by the first such draw of the content, which waits for it, as a +//! draw of a class not made yet does: Metal sets both per encoder and compiles nothing for them. +//! The fill mode is a triangle's alone, in Metal and in Vulkan, so the line and point classes take +//! the clip mode alone. A draw in a pass that sets sample positions of its own takes a `VkPipeline` +//! of its class made for custom locations the same way, one that serves every set of positions. //! //! What a draw supplies is the content's [`Draws`]: each function's slots with their accesses, //! its push fields (addresses, resource IDs and indices of the slots, in the floor's one push @@ -343,7 +345,7 @@ pub(crate) struct RenderCompiled { /// The content's other `VkPipeline`s, each by its class's list topology and its raster state, /// each made by the first draw that takes it: the line and the point class's at the default /// raster state where the descriptor names neither, and those under other raster states. At - /// most 7: the triangle or patch class's three other raster states, and two of each other + /// most 15: the triangle or patch class's seven other raster states, and four of each other /// class. later: Mutex>, /// Whether a draw of points rasterizes them: the vertex function writes `[[point_size]]`, or @@ -352,6 +354,11 @@ pub(crate) struct RenderCompiled { /// Metal rasterizes no point of such a function and runs its vertex function all the same /// (`metal2vulkan::pipeline::GraphicsState::writes_point_size`). rasterizes_points: bool, + /// Whether the fragment module interpolates an input at a sample + /// (`metal2vulkan::pipeline::GraphicsState::interpolates_at_sample`), which Vulkan does not + /// take in a pipeline that rasterizes at custom sample locations + /// (`VUID-VkGraphicsPipelineCreateInfo-sampleLocationsEnable-01524`). + interpolates_at_sample: bool, /// The translator's notes of where the pipeline's answers may differ from Metal's, and its /// functions' constexpr samplers' (`constexpr_notes`). notes: Vec, @@ -379,14 +386,20 @@ pub(crate) struct RenderCompiled { /// What the render encoder sets that a `VkPipeline` bakes: `setDepthClipMode:` and /// `setTriangleFillMode:`, in `VkPipelineRasterizationStateCreateInfo`, which only -/// `VK_EXT_extended_dynamic_state3` makes dynamic, and the floor does not require it. The default -/// is Metal's, `Clip` and `Fill`. +/// `VK_EXT_extended_dynamic_state3` makes dynamic, and the floor does not require it, and whether +/// its pass sets sample positions, which only a pipeline made with `sampleLocationsEnable` takes. +/// The default is Metal's, `Clip` and `Fill`, at the default positions. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] pub(crate) struct Raster { /// `MTLDepthClipModeClamp`: `depthClampEnable`. pub(crate) clamp: bool, /// `MTLTriangleFillModeLines`: `polygonMode` `LINE`. pub(crate) lines: bool, + /// The pass rasterizes at positions of its own (`crate::positions`): the pipeline chains + /// `VkPipelineSampleLocationsStateCreateInfoEXT` with `sampleLocationsEnable`, the locations + /// its dynamic state (`VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT`), which the encoder records + /// before the pass's first draw. + pub(crate) positions: bool, } /// One of a content's main `VkPipeline`s ([`RenderCompiled::primary`], @@ -1413,6 +1426,7 @@ impl RenderCompiled { later: Mutex::new(Vec::new()), rasterizes_points: pipeline.graphics.writes_point_size || lowered.input_primitive_topology == PrimitiveTopologyClass::Point, + interpolates_at_sample: pipeline.graphics.interpolates_at_sample, notes, digest: pipeline.content_digest(), draws, @@ -1484,18 +1498,26 @@ impl RenderCompiled { /// counted as a main pipeline's before its `finish_pipeline` made it, as the line or point /// class's at the default raster state, and as a raster state's otherwise. /// - /// Err: [`Error::Vulkan`] where the pipeline cannot be made. + /// Err: [`Gap::Draw`] of [`DrawKind::SamplePositions`](crate::DrawKind::SamplePositions) + /// where `raster` sets sample positions and the fragment module interpolates at a sample; + /// [`Error::Vulkan`] where the pipeline cannot be made. pub(crate) fn pipeline( &self, topology: vk::PrimitiveTopology, raster: Raster, ) -> Result { use vk::PrimitiveTopology as T; + if raster.positions && self.interpolates_at_sample { + return Err(Error::Unsupported(Gap::Draw { + kind: crate::DrawKind::SamplePositions, + })); + } let class = self.class(topology); let polygons = matches!(class, T::TRIANGLE_LIST | T::PATCH_LIST); let raster = Raster { clamp: raster.clamp, lines: raster.lines && polygons, + positions: raster.positions, }; let counters = &self.core.counters; if polygons && raster == Raster::default() { @@ -1649,6 +1671,25 @@ impl RenderCompiled { if let Some(words) = &words { multisample = multisample.sample_mask(&words[..count.min(words.len())]); } + // A pass's own positions: the locations are dynamic state, so the ones given here, each + // sample at the pixel's centre, are ignored, and the structure is valid all the same (the + // pass's count is one of the device's `sampleLocationSampleCounts`, `crate::positions`). + let centre = vk::SampleLocationEXT { x: 0.5, y: 0.5 }; + let centres = vec![centre; fixed.samples.as_raw() as usize]; + let mut locations = vk::PipelineSampleLocationsStateCreateInfoEXT::default() + .sample_locations_enable(true) + .sample_locations_info( + vk::SampleLocationsInfoEXT::default() + .sample_locations_per_pixel(fixed.samples) + .sample_location_grid_size(vk::Extent2D { + width: 1, + height: 1, + }) + .sample_locations(¢res), + ); + if raster.positions { + multisample = multisample.push_next(&mut locations); + } let depth_stencil = vk::PipelineDepthStencilStateCreateInfo::default(); let mut blend = vk::PipelineColorBlendStateCreateInfo::default().attachments(&fixed.blends); if let Some(op) = fixed.logic_op { @@ -1664,6 +1705,11 @@ impl RenderCompiled { .discard .then_some(vk::DynamicState::RASTERIZER_DISCARD_ENABLE), ) + .chain( + raster + .positions + .then_some(vk::DynamicState::SAMPLE_LOCATIONS_EXT), + ) .collect(); let dynamic_states = vk::PipelineDynamicStateCreateInfo::default().dynamic_states(&states); let mut rendering = vk::PipelineRenderingCreateInfo::default() diff --git a/crates/metal2vulkan-runtime/src/render_encoder.rs b/crates/metal2vulkan-runtime/src/render_encoder.rs index 94ee6b15f..dbcd89ed7 100644 --- a/crates/metal2vulkan-runtime/src/render_encoder.rs +++ b/crates/metal2vulkan-runtime/src/render_encoder.rs @@ -195,10 +195,10 @@ pub struct IndexBuffer<'a> { const MAX_VIEWPORTS: usize = 16; /// The dynamic state a draw records before it: the viewport and scissor, the cull mode, the -/// front face, the depth test, the stencil references, the blend constants, the depth bias and -/// the stencil test. A setter marks its state only where the value it sets differs from the one -/// it replaces, and a draw records of the depth and stencil tests only the fields that differ from -/// the ones the encoder last recorded. +/// front face, the depth test, the stencil references, the blend constants, the depth bias, the +/// stencil test and the pass's sample locations, where it sets its own. A setter marks its state +/// only where the value it sets differs from the one it replaces, and a draw records of the depth +/// and stencil tests only the fields that differ from the ones the encoder last recorded. const VIEWPORT: u32 = 1; const CULL: u32 = 2; const FRONT: u32 = 4; @@ -207,7 +207,8 @@ const REFERENCE: u32 = 16; const BLEND: u32 = 32; const BIAS: u32 = 64; const STENCIL: u32 = 128; -const ALL: u32 = 255; +const LOCATIONS: u32 = 256; +const ALL: u32 = 511; /// An image the pass moved whole to the feedback layout, which its second barrier moves home. struct Moved { @@ -767,7 +768,8 @@ pub struct RenderCommandEncoder { /// The line width `set_line_width` set last, Metal's 1 until set. line_width: f32, /// The depth clip mode and triangle fill mode set last, Metal's `Clip` and `Fill` until set, - /// which each draw's `VkPipeline` takes. + /// and whether the pass sets sample positions of its own, which each draw's `VkPipeline` + /// takes. raster: Raster, /// The depth bias's constant, slope scale and clamp, Metal's `depthBias`, `slopeScale` and /// `clamp`. @@ -841,6 +843,10 @@ impl CommandBuffer { match begin(&mut building, &core, descriptor) { Ok((pass, command, visibility)) => { let [width, height] = pass.area; + let raster = Raster { + positions: pass.positions.is_some(), + ..Raster::default() + }; Ok(RenderCommandEncoder { command_buffer: self.clone(), core, @@ -868,7 +874,7 @@ impl CommandBuffer { blend_color: [0.0; 4], alpha_test: alpha_test_code(1.0), line_width: 1.0, - raster: Raster::default(), + raster, depth_bias: [0.0; 3], biased: false, hidden: false, @@ -3749,6 +3755,15 @@ impl RenderCommandEncoder { device.cmd_set_primitive_restart_enable(command, restart); self.topology = Some((topology, restart)); } + // A pass's own sample locations, once, before its first draw: the dynamic state of + // every pipeline its draws take (`Raster::positions`), which no other pipeline's bind + // disturbs between them. The command buffer records on a device that enabled the + // extension, as the pass's positions are there. + if let Some(positions) = + (self.pass.positions.as_ref()).filter(|_| dirty & LOCATIONS != 0) + { + positions.record(command); + } } } diff --git a/crates/metal2vulkan-runtime/src/tests/indirect.rs b/crates/metal2vulkan-runtime/src/tests/indirect.rs index 84476b316..696e73549 100644 --- a/crates/metal2vulkan-runtime/src/tests/indirect.rs +++ b/crates/metal2vulkan-runtime/src/tests/indirect.rs @@ -1480,7 +1480,7 @@ mod on_device { // are queried with the execution's pipeline). let clamped = Raster { clamp: true, - lines: false, + ..Raster::default() }; let other = ok( name, diff --git a/crates/metal2vulkan-runtime/src/tests/sample_positions.rs b/crates/metal2vulkan-runtime/src/tests/sample_positions.rs index 14dfdae6c..d923c9cd9 100644 --- a/crates/metal2vulkan-runtime/src/tests/sample_positions.rs +++ b/crates/metal2vulkan-runtime/src/tests/sample_positions.rs @@ -1,32 +1,362 @@ //! Programmable sample positions (`setSamplePositions:count:`). //! -//! - Under a device cfg, on every device of the cfg's kind that offers them through -//! `VK_EXT_sample_locations` (its `sampleLocationSampleCounts` holding 4, `variableSampleLocations` -//! true): a white triangle covering what lies left of a vertical edge through column 4 of an 8 x -//! 8, 4-sample `RGBA8Unorm` target, resolved, covers that column's samples where the pass's -//! positions put them, as the conformance suite's `sample_positions` rows measured Metal on an -//! Apple M4: Metal's default positions cover 2 of 4 against an edge at the column's middle, four -//! positions at x 0.25 cover 4, at x 0.75 none, and one at 0.25 with three at 0.75 cover 1; a -//! coordinate is taken to the nearest sixteenth of a pixel, a tie up (0.53125 to 0.5625), and -//! to at most 15/16 (0.97); two positions in the pass of four put samples 2 and 3 at the pixel's -//! corner. The columns left of it are white and those right of it black. Each device prints -//! its extension's properties. +//! - Under a device cfg, on every device of the cfg's kind: the device's answer +//! (`programmableSamplePositionsSupported`) is yes exactly where it lists +//! `VK_EXT_sample_locations` with locations at every sample count above 1 it renders, a grid of +//! at least 1 x 1, every sixteenth of a pixel from 0 to 15/16 and variable locations; each +//! device prints its answer and the extension's properties. +//! - On each device that answers yes: a white triangle covering what lies left of a vertical edge +//! through column 4 of an 8 x 8, 4-sample `RGBA8Unorm` target, resolved, covers that column's +//! samples where the pass's positions put them, as the conformance suite's `sample_positions` +//! rows measured Metal on an Apple M4: Metal's default positions cover 2 of 4 against an edge at +//! the column's middle, set or not, four positions at x 0.25 cover 4, at x 0.75 none, and one at +//! 0.25 with three at 0.75 cover 1; a coordinate is taken to the nearest sixteenth of a pixel, a +//! tie up (0.53125 to 0.5625), and to at most 15/16 (0.97); two positions in the pass of four put +//! samples 2 and 3 at the pixel's corner. The columns left of it are white and those right of it +//! black. +//! - On every device: a pass is refused as Metal's validation stops it, with more positions than +//! samples, a coordinate outside `[0, 1)` (1, below 0, NaN), or a position other than the +//! centre in a pass of one sample; the default positions set, at 1 and at 4 samples, are taken +//! as none. A device that answers no refuses four other positions; one that answers yes takes +//! them, refuses them beside a depth attachment as a pass it does not build, and refuses a draw +//! among them whose fragment function interpolates at a sample (`pm_sample_id`), which it draws +//! in a pass at the default positions. +//! +//! With no device, on every build: +//! - The answer's gates (`Locations::offered`): a device answers yes only where its +//! `sampleLocationSampleCounts` hold every count above 1 it renders, each alone, its grid is 1 x +//! 1 or more, its coordinate range holds `[0, 15/16]`, its sub-pixel bits are 4 or more and its +//! locations vary; each property one short of that answers no. +//! - Placement (`positions::locations`): every coordinate in `[0, 1)` lands on a sixteenth from 0 +//! to 15/16, the nearest, a tie up (the rounding the conformance suite's rows measured on an +//! Apple M4), so no device that answers yes sees a location outside its range or finer than its +//! bits; a coordinate outside `[0, 1)` (1, below 0, NaN, infinite) is refused, as are more +//! positions than samples and positions other than the centre in a pass of one sample; samples +//! past the positions given lie at the pixel's corner; a set that comes to the standard +//! locations is none, on a device that answers no too, where any other set is refused; a count +//! the device's `sampleLocationSampleCounts` lacks, and a pass with a depth attachment, are the +//! runtime's gap. + +/// The placement and the answer's gates, with no device. +mod placed { + use crate::error::{Error, Gap, Refusal, RenderPassKind, SamplePositionsKind}; + use crate::positions::{locations, on_grid, Locations, SamplePosition}; + use ash::vk; + + const TWO: vk::SampleCountFlags = vk::SampleCountFlags::TYPE_2; + const FOUR: vk::SampleCountFlags = vk::SampleCountFlags::TYPE_4; + + /// A device's properties at the floor's minimum Vulkan requires of the extension, with + /// locations at `counts`. + fn at_minimum( + counts: vk::SampleCountFlags, + ) -> vk::PhysicalDeviceSampleLocationsPropertiesEXT<'static> { + vk::PhysicalDeviceSampleLocationsPropertiesEXT::default() + .sample_location_sample_counts(counts) + .max_sample_location_grid_size(vk::Extent2D { + width: 1, + height: 1, + }) + .sample_location_coordinate_range([0.0, 0.9375]) + .sample_location_sub_pixel_bits(4) + .variable_sample_locations(true) + } + + #[test] + fn the_answer_needs_every_count_it_renders_and_metal_s_grid() { + let renders = vk::SampleCountFlags::TYPE_1 | TWO | FOUR; + assert!(Locations::offered(&at_minimum(TWO | FOUR), renders)); + assert!(Locations::offered( + &at_minimum(FOUR), + vk::SampleCountFlags::TYPE_1 | FOUR + )); + // Each count above 1 is gated alone. + assert!(!Locations::offered(&at_minimum(FOUR), renders)); + assert!(!Locations::offered(&at_minimum(TWO), renders)); + let short: [fn(&mut vk::PhysicalDeviceSampleLocationsPropertiesEXT); 5] = [ + |p| p.max_sample_location_grid_size.width = 0, + |p| p.max_sample_location_grid_size.height = 0, + |p| p.sample_location_coordinate_range = [0.0, 0.875], + |p| p.sample_location_sub_pixel_bits = 3, + |p| p.variable_sample_locations = vk::FALSE, + ]; + for (at, cut) in short.iter().enumerate() { + let mut properties = at_minimum(TWO | FOUR); + cut(&mut properties); + assert!(!Locations::offered(&properties, renders), "property {at}"); + } + } + + #[test] + fn every_coordinate_lands_on_a_sixteenth_metal_takes() { + for (c, want) in [ + (0.0, 0.0), + (0.03, 0.0), + (0.03125, 0.0625), + (0.51, 0.5), + (0.53, 0.5), + (0.53125, 0.5625), + (0.55, 0.5625), + (0.5624, 0.5625), + (0.5625, 0.5625), + (0.9375, 0.9375), + (0.97, 0.9375), + (0.99, 0.9375), + (0.999_999_94, 0.9375), + ] { + assert_eq!(on_grid(c), want, "{c}"); + } + // Every coordinate in [0, 1) lands on k/16, k from 0 to 15: inside every device's range + // and on its grid of 4 bits or more. + for step in 0..100_000u32 { + let c = step as f32 / 100_000.0; + let sixteenths = on_grid(c) * 16.0; + assert!( + sixteenths.fract() == 0.0 && (0.0..=15.0).contains(&sixteenths), + "{c}: {sixteenths}" + ); + } + } + + fn at(x: f32, y: f32) -> SamplePosition { + SamplePosition::new(x, y) + } + + fn refused(kind: SamplePositionsKind, count: u32, samples: u32) -> String { + format!( + "{:?}", + Err::<(), _>(Error::Refused(Refusal::SamplePositions { + kind, + count, + samples + })) + ) + } + + /// `positions` placed for a pass of `samples`, as the debug text of the answer (the error has + /// no `PartialEq`), the locations as `(x, y)` pairs. + fn placed( + counts: Option, + positions: &[SamplePosition], + samples: vk::SampleCountFlags, + depth: bool, + ) -> String { + let pairs = + |l: Vec| l.iter().map(|l| (l.x, l.y)).collect::>(); + match locations(counts, positions, samples, depth) { + Ok(placed) => format!("{:?}", Ok::<_, ()>(placed.map(pairs))), + Err(error) => format!("{:?}", Err::<(), _>(error)), + } + } + + fn taken(pairs: Option>) -> String { + format!("{:?}", Ok::<_, ()>(pairs)) + } + + /// A case: its name, the device's counts, the positions, the pass's samples, whether it has a + /// depth attachment, and the answer's debug text. + type Case = ( + &'static str, + Option, + Vec, + vk::SampleCountFlags, + bool, + String, + ); + + #[test] + fn a_pass_s_positions_are_placed_as_metal_places_them_or_refused() { + let yes = Some(TWO | FOUR); + let standard = [ + at(0.375, 0.125), + at(0.875, 0.375), + at(0.125, 0.625), + at(0.625, 0.875), + ]; + let four = [at(0.25, 0.5); 4]; + let gap = format!( + "{:?}", + Err::<(), _>(Error::Unsupported(Gap::RenderPass { + kind: RenderPassKind::SamplePositions, + })) + ); + let one = vk::SampleCountFlags::TYPE_1; + let cases: Vec = vec![ + ("none", None, Vec::new(), FOUR, false, taken(None)), + ( + "the standard four, on a device that answers no", + None, + standard.to_vec(), + FOUR, + false, + taken(None), + ), + ( + "the standard four off the grid", + None, + vec![ + at(0.38, 0.13), + at(0.87, 0.37), + at(0.12, 0.63), + at(0.63, 0.87), + ], + FOUR, + false, + taken(None), + ), + ( + "the standard two", + None, + vec![at(0.75, 0.75), at(0.25, 0.25)], + TWO, + false, + taken(None), + ), + ( + "the centre of one", + None, + vec![at(0.53, 0.47)], + one, + false, + taken(None), + ), + ( + "four at 0.25", + yes, + four.to_vec(), + FOUR, + false, + taken(Some(vec![(0.25, 0.5); 4])), + ), + ( + "two of four, the rest at the corner", + yes, + vec![at(0.75, 0.5), at(0.97, 0.53125)], + FOUR, + false, + taken(Some(vec![ + (0.75, 0.5), + (0.9375, 0.5625), + (0.0, 0.0), + (0.0, 0.0), + ])), + ), + ( + "four on a device that answers no", + None, + four.to_vec(), + FOUR, + false, + refused(SamplePositionsKind::Unsupported, 4, 4), + ), + ( + "five in four", + yes, + vec![at(0.25, 0.5); 5], + FOUR, + false, + refused(SamplePositionsKind::Count, 5, 4), + ), + ( + "five in four, on a device that answers no", + None, + vec![at(0.25, 0.5); 5], + FOUR, + false, + refused(SamplePositionsKind::Count, 5, 4), + ), + ( + "x at 1", + yes, + vec![at(1.0, 0.5)], + FOUR, + false, + refused(SamplePositionsKind::Coordinate, 1, 4), + ), + ( + "y below 0", + yes, + vec![at(0.5, -0.0001)], + FOUR, + false, + refused(SamplePositionsKind::Coordinate, 1, 4), + ), + ( + "x NaN", + yes, + vec![at(f32::NAN, 0.5)], + FOUR, + false, + refused(SamplePositionsKind::Coordinate, 1, 4), + ), + ( + "y infinite", + yes, + vec![at(0.5, f32::INFINITY)], + FOUR, + false, + refused(SamplePositionsKind::Coordinate, 1, 4), + ), + ( + "off the centre of one", + yes, + vec![at(0.25, 0.25)], + one, + false, + refused(SamplePositionsKind::OneSample, 1, 1), + ), + ( + "two at a count the device lacks", + Some(FOUR), + vec![at(0.25, 0.5); 2], + TWO, + false, + gap.clone(), + ), + ( + "four beside a depth attachment", + yes, + four.to_vec(), + FOUR, + true, + gap.clone(), + ), + ( + "the standard four beside a depth attachment", + yes, + standard.to_vec(), + FOUR, + true, + taken(None), + ), + ]; + for (case, counts, positions, samples, depth, want) in cases { + assert_eq!(placed(counts, &positions, samples, depth), want, "{case}"); + } + } +} #[cfg(any(m2v_gpu, m2v_cpu_icd))] mod on_device { use crate::tests::command::on_device::each_device; use crate::tests::draw::on_device::{ - descriptor, examples, floats, pass, run, state, Buffers, SIDE, + descriptor, examples, floats, library, pass, run, state, Buffers, SIDE, }; use crate::{ - CullMode, Device, PixelFormat, PrimitiveType, Region, SamplePosition, StorageMode, - StoreAction, Texture, TextureDescriptor, TextureType, TextureUsage, + ColorAttachmentDescriptor, CullMode, Device, DrawKind, Error, FunctionDescriptor, Gap, + PixelFormat, PrimitiveType, Refusal, Region, RenderPassKind, RenderPipelineDescriptor, + SamplePosition, SamplePositionsKind, StageSource, StorageMode, StoreAction, Texture, + TextureDescriptor, TextureType, TextureUsage, }; use ash::vk; + use metal2vulkan_devtools::engine_dir; /// The device's `VK_EXT_sample_locations` properties, where it lists the extension, printed: /// its sample counts, grid, coordinate range, sub-pixel bits and variable locations. - fn properties(name: &str, device: &Device) -> Option<(vk::SampleCountFlags, bool)> { + fn properties( + name: &str, + device: &Device, + ) -> Option> { let raw = device.raw(); // SAFETY: the physical device is the instance's. let listed = @@ -40,11 +370,13 @@ mod on_device { return None; } let mut locations = vk::PhysicalDeviceSampleLocationsPropertiesEXT::default(); - let mut properties = vk::PhysicalDeviceProperties2::default().push_next(&mut locations); - // SAFETY: as above; the device lists the extension, which defines the structure. - unsafe { - (raw.instance).get_physical_device_properties2(raw.physical_device, &mut properties) - }; + { + let mut properties = vk::PhysicalDeviceProperties2::default().push_next(&mut locations); + // SAFETY: as above; the device lists the extension, which defines the structure. + unsafe { + (raw.instance).get_physical_device_properties2(raw.physical_device, &mut properties) + }; + } let l = &locations; println!( "{name}: VK_EXT_sample_locations sampleLocationSampleCounts {:#x}, \ @@ -58,18 +390,31 @@ mod on_device { l.sample_location_sub_pixel_bits, l.variable_sample_locations, ); - Some(( - l.sample_location_sample_counts, - l.variable_sample_locations == vk::TRUE, - )) + Some(locations) } - /// Whether the device offers custom positions for a pass of 4 samples: it lists the - /// extension, its counts hold 4 and its locations may vary within a command buffer. - fn offers_four(name: &str, device: &Device) -> bool { - properties(name, device).is_some_and(|(counts, variable)| { - counts.contains(vk::SampleCountFlags::TYPE_4) && variable - }) + /// The device's answer, printed, held to its properties: yes exactly where it lists the + /// extension with locations at each count above 1 it renders (`supportsTextureSampleCount:`), + /// a grid of at least 1 x 1, every sixteenth from 0 to 15/16, and variable locations. + fn answer(name: &str, device: &Device) -> bool { + let answer = device.programmable_sample_positions_supported(); + println!("{name}: programmableSamplePositionsSupported {answer}"); + let held = properties(name, device).is_some_and(|l| { + let [low, high] = l.sample_location_coordinate_range; + let grid = l.max_sample_location_grid_size; + let counts = l.sample_location_sample_counts.as_raw(); + (2..=64) + .filter(|&count| device.supports_texture_sample_count(count)) + .all(|count| counts & count != 0) + && grid.width >= 1 + && grid.height >= 1 + && low <= 0.0 + && high >= 0.9375 + && l.sample_location_sub_pixel_bits >= 4 + && l.variable_sample_locations == vk::TRUE + }); + assert_eq!(answer, held, "{name}: the answer and the properties"); + answer } /// Four positions at `(x, 0.5)`. @@ -77,12 +422,25 @@ mod on_device { vec![SamplePosition::new(x, 0.5); 4] } + /// Metal's default positions of 4 samples, Vulkan's standard locations. + fn defaults() -> Vec { + [ + [0.375, 0.125], + [0.875, 0.375], + [0.125, 0.625], + [0.625, 0.875], + ] + .map(|[x, y]| SamplePosition::new(x, y)) + .to_vec() + } + /// The pass's cases: a name, the edge's x in the target's pixels (column 4 spans 4 to 5), the /// positions, and the samples of column 4 they cover. fn cases() -> Vec<(&'static str, f32, Vec, u32)> { let middle = 4.5; vec![ ("Metal's defaults", middle, Vec::new(), 2), + ("Metal's defaults, set", middle, defaults(), 2), ("four at 0.25", middle, four(0.25), 4), ("four at 0.75", middle, four(0.75), 0), ( @@ -104,13 +462,13 @@ mod on_device { ] } - /// A 2D `RGBA8Unorm` texture `SIDE` a side of `samples` samples, for rendering alone. - fn color(device: &Device, samples: u32) -> Texture { + /// A 2D texture of `format`, `SIDE` a side, of `samples` samples, for rendering alone. + fn target(device: &Device, format: PixelFormat, samples: u32) -> Texture { let kind = match samples { 1 => TextureType::Type2D, _ => TextureType::Type2DMultisample, }; - let mut d = TextureDescriptor::new(kind, PixelFormat::RGBA8Unorm, SIDE, SIDE); + let mut d = TextureDescriptor::new(kind, format, SIDE, SIDE); d.sample_count = samples; d.usage = TextureUsage::RENDER_TARGET; d.storage_mode = match samples { @@ -120,6 +478,11 @@ mod on_device { (device.new_texture_for_views(&d)).expect("a target") } + /// A 2D `RGBA8Unorm` texture `SIDE` a side of `samples` samples, for rendering alone. + fn color(device: &Device, samples: u32) -> Texture { + target(device, PixelFormat::RGBA8Unorm, samples) + } + /// The red channel of row 0 of `texture`, `SIDE` texels. fn reds(texture: &Texture) -> Vec { let row = SIDE as usize * 4; @@ -133,7 +496,7 @@ mod on_device { bytes[..row].chunks(4).map(|texel| texel[0]).collect() } - /// The module's coverage at each case's positions, on each device that offers them. + /// The module's coverage at each case's positions, on each device that answers yes. #[test] fn every_device_rasterizes_a_pass_at_its_sample_positions() { let Some(library) = examples() else { @@ -142,8 +505,8 @@ mod on_device { let mut d = descriptor(&library, "colored_fragment", PixelFormat::RGBA8Unorm); d.raster_sample_count = 4; each_device("sample_positions", |name, _, device| { - if !offers_four(name, &device) { - println!("{name}: no custom positions at 4 samples; coverage not checked"); + if !answer(name, &device) { + println!("{name}: no custom positions; coverage not checked"); return; } let four_state = state(name, &device, &d); @@ -193,4 +556,195 @@ mod on_device { } }); } + + /// What a call answered: taken, refused, or not built. + #[derive(Debug, PartialEq)] + enum Outcome { + Taken, + Refused(Refusal), + Gap(Gap), + } + + /// `result` as an [`Outcome`]; any other error fails `what`. + fn outcome(what: &str, result: Result<(), Error>) -> Outcome { + match result { + Ok(()) => Outcome::Taken, + Err(Error::Refused(refusal)) => Outcome::Refused(refusal), + Err(Error::Unsupported(gap)) => Outcome::Gap(gap), + Err(other) => panic!("{what}: {other}"), + } + } + + /// The refusal of `count` positions in a pass of `samples` samples, of `kind`. + fn refused(kind: SamplePositionsKind, count: u32, samples: u32) -> Outcome { + Outcome::Refused(Refusal::SamplePositions { + kind, + count, + samples, + }) + } + + /// The pass of `positions` over `texture`, with `depth` as its depth attachment, begun and + /// ended on `queue`, and its command buffer run where it began. + fn begin( + what: &str, + queue: &crate::CommandQueue, + (texture, depth): (&Texture, Option<&Texture>), + positions: Vec, + ) -> Outcome { + let mut p = pass(texture, None); + p.depth_attachment.texture = depth.cloned(); + p.sample_positions = positions; + let command_buffer = queue.command_buffer().expect("a command buffer"); + let begun = command_buffer.render_command_encoder(&p).map(|encoder| { + encoder.end_encoding(); + run(what, &command_buffer); + }); + outcome(what, begun) + } + + /// What each device refuses of a pass's positions, and what it takes. + #[test] + fn every_device_refuses_the_positions_metal_refuses() { + each_device("sample_positions_refused", |name, _, device| { + let answer = answer(name, &device); + let one = color(&device, 1); + let four_samples = color(&device, 4); + let queue = device.new_command_queue(1).expect("a queue"); + let nan = SamplePosition::new(f32::NAN, 0.5); + let checks: Vec<(&str, &Texture, Vec, Outcome)> = vec![ + ( + "five in a pass of four", + &four_samples, + vec![SamplePosition::new(0.25, 0.5); 5], + refused(SamplePositionsKind::Count, 5, 4), + ), + ( + "x at 1", + &four_samples, + vec![SamplePosition::new(1.0, 0.5)], + refused(SamplePositionsKind::Coordinate, 1, 4), + ), + ( + "y below 0", + &four_samples, + vec![SamplePosition::new(0.5, -0.0625)], + refused(SamplePositionsKind::Coordinate, 1, 4), + ), + ( + "x NaN", + &four_samples, + vec![nan], + refused(SamplePositionsKind::Coordinate, 1, 4), + ), + ( + "one off the centre in a pass of one", + &one, + vec![SamplePosition::new(0.25, 0.25)], + refused(SamplePositionsKind::OneSample, 1, 1), + ), + ( + "the centre in a pass of one", + &one, + vec![SamplePosition::new(0.5, 0.5)], + Outcome::Taken, + ), + ( + "Metal's defaults of four", + &four_samples, + defaults(), + Outcome::Taken, + ), + ( + "four at 0.25", + &four_samples, + four(0.25), + match answer { + true => Outcome::Taken, + false => refused(SamplePositionsKind::Unsupported, 4, 4), + }, + ), + ]; + for (case, texture, positions, want) in checks { + let what = format!("{name}: {case}"); + let got = begin(&what, &queue, (texture, None), positions); + println!("{what}: {got:?}"); + assert_eq!(got, want, "{what}"); + } + if !answer { + return; + } + let depth = target(&device, PixelFormat::Depth32Float, 4); + let what = format!("{name}: four at 0.25 beside a depth attachment"); + let got = begin(&what, &queue, (&four_samples, Some(&depth)), four(0.25)); + println!("{what}: {got:?}"); + let gap = Outcome::Gap(Gap::RenderPass { + kind: RenderPassKind::SamplePositions, + }); + assert_eq!(got, gap, "{what}"); + let what = format!("{name}: the defaults beside a depth attachment"); + let got = begin(&what, &queue, (&four_samples, Some(&depth)), defaults()); + println!("{what}: {got:?}"); + assert_eq!(got, Outcome::Taken, "{what}"); + }); + } + + /// A draw whose fragment function interpolates at a sample (`pm_sample_id`) in a pass at + /// custom positions, on each device that answers yes: refused as a draw the runtime does not + /// build, where the same draw in a pass at the default positions draws. + #[test] + fn a_draw_that_interpolates_at_a_sample_is_refused_at_custom_positions() { + let Some(library) = library(&engine_dir().join("pull_model_interpolants.ll")) else { + return; + }; + let function = |name| { + StageSource::Function(FunctionDescriptor::new( + library.function(name).expect("the function"), + )) + }; + let mut d = RenderPipelineDescriptor::new(function("pm_place")); + d.fragment = Some(function("pm_sample_id")); + for slot in d.color_attachments.iter_mut().take(2) { + *slot = Some(ColorAttachmentDescriptor::new(PixelFormat::RGBA32Float)); + } + d.raster_sample_count = 4; + each_device("sample_positions_at_sample", |name, _, device| { + if !answer(name, &device) { + return; + } + let made = device.new_render_pipeline_state(&d, crate::tests::no_constexpr_samplers); + let state = match made { + Ok(state) => state, + Err(error) => { + println!("{name}: pm_sample_id not made: {error}"); + return; + } + }; + let targets = [0, 1].map(|_| target(&device, PixelFormat::RGBA32Float, 4)); + let queue = device.new_command_queue(1).expect("a queue"); + let gap = Outcome::Gap(Gap::Draw { + kind: DrawKind::SamplePositions, + }); + for (case, positions, want) in [ + ("at the defaults", Vec::new(), Outcome::Taken), + ("four at 0.25", four(0.25), gap), + ] { + let what = format!("{name}: pm_sample_id {case}"); + let mut p = pass(&targets[0], None); + p.color_attachments[1].texture = Some(targets[1].clone()); + p.sample_positions = positions; + let command_buffer = queue.command_buffer().expect("a command buffer"); + let mut encoder = (command_buffer.render_command_encoder(&p)) + .unwrap_or_else(|error| panic!("{what}: {error}")); + (encoder.set_render_pipeline_state(&state)) + .unwrap_or_else(|error| panic!("{what}: {error}")); + let drawn = encoder.draw_primitives(PrimitiveType::Triangle, 0, 3, 1, 0); + encoder.end_encoding(); + run(&what, &command_buffer); + let got = outcome(&what, drawn); + println!("{what}: {got:?}"); + assert_eq!(got, want, "{what}"); + } + }); + } } diff --git a/crates/metal2vulkan-runtime/src/tests/translator_fields.rs b/crates/metal2vulkan-runtime/src/tests/translator_fields.rs index 2e1a354a7..6095361bd 100644 --- a/crates/metal2vulkan-runtime/src/tests/translator_fields.rs +++ b/crates/metal2vulkan-runtime/src/tests/translator_fields.rs @@ -86,6 +86,13 @@ const GRAPHICS_STATE: &[(&str, Verdict)] = &[ "fragment_writes_memory", Fact("the runtime stands for no depth or stencil test by a state every fragment passes"), ), + ( + "interpolates_at_sample", + Refused( + "pipeline() refuses a draw of it in a pass of custom sample positions \ + (VUID-VkGraphicsPipelineCreateInfo-sampleLocationsEnable-01524)", + ), + ), ( "color_outputs", Fact("the runtime takes every attachment of a draw's pass as written"), diff --git a/crates/metal2vulkan-validation/src/replay/new_runtime/mod.rs b/crates/metal2vulkan-validation/src/replay/new_runtime/mod.rs index 46e46f09e..b6aba7424 100644 --- a/crates/metal2vulkan-validation/src/replay/new_runtime/mod.rs +++ b/crates/metal2vulkan-validation/src/replay/new_runtime/mod.rs @@ -625,7 +625,6 @@ pub struct NewRuntime { freed: faulted::Freed, substitutes: Substitutes, unrecorded_tessellation: render::UnrecordedTessellation, - other_positions: render::OtherPositions, /// Each open encoder's command buffer. owners: HashMap, /// How the recording's device kept Managed buffers; `None` where the player was not told, @@ -1082,7 +1081,6 @@ impl NewRuntime { freed: faulted::Freed::default(), substitutes: Substitutes::default(), unrecorded_tessellation: render::UnrecordedTessellation::default(), - other_positions: render::OtherPositions::default(), owners: HashMap::new(), managed: None, display: None, @@ -3599,7 +3597,6 @@ impl Backend for NewRuntime { if first.is_empty() { " -" } else { &first }, )); lines.push(self.unrecorded_tessellation.line()); - lines.push(self.other_positions.line()); lines.push(self.asides.line()); lines.push(self.places.line()); lines.push(self.unwritten.line()); diff --git a/crates/metal2vulkan-validation/src/replay/new_runtime/render.rs b/crates/metal2vulkan-validation/src/replay/new_runtime/render.rs index cd37d3816..276bea04e 100644 --- a/crates/metal2vulkan-validation/src/replay/new_runtime/render.rs +++ b/crates/metal2vulkan-validation/src/replay/new_runtime/render.rs @@ -18,10 +18,8 @@ //! `visibilityResultType`, and each `setVisibilityResultMode:offset:`, whose counts the runtime //! writes into the buffer at the pass's end. //! -//! `setSamplePositions:count:` plays as the runtime treats it: its descriptor has no field for -//! the positions, and every multisample pass rasterizes at Vulkan's standard sample locations, -//! with no refusal. A render encoder the runtime makes of a pass whose positions differ from -//! Metal's default positions for the pass's sample count is counted (`OtherPositions`). +//! `setSamplePositions:count:` sets the runtime's descriptor's `sample_positions`, at which the +//! pass rasterizes, or which the runtime refuses as Metal's validation does. use super::super::args::{arg, data, index, list, metal, refuse, uint, Fields}; use super::super::translator::{self, attachment_keys, LINKED_KEYS, PASS_KEYS}; @@ -86,63 +84,6 @@ impl UnrecordedTessellation { } } -/// Metal's default sample positions of 1, 2 and 4 samples, each `(x, y)` in the pixel, where a -/// pass that sets none rasterizes: Vulkan's standard sample locations of those counts (the Vulkan -/// specification, Multisampling, the "Standard Sample Locations" table), which the runtime's -/// floor requires (`standardSampleLocations`, under Floor in the runtime's README, whose known -/// gaps name them Metal's default positions at 1, 2 and 4 samples), and at which the conformance -/// suite's `sample-positions-default-4x` and `sample-positions-default-2x` rows of -/// `sample_positions` compare with Metal's. The tree holds Metal's defaults of no other count. -const METAL_DEFAULT_POSITIONS: [&[[f32; 2]]; 3] = [ - &[[0.5, 0.5]], - &[[0.75, 0.75], [0.25, 0.25]], - &[ - [0.375, 0.125], - [0.875, 0.375], - [0.125, 0.625], - [0.625, 0.875], - ], -]; - -/// Whether a pass of `samples` samples whose `setSamplePositions:count:` set `positions` -/// rasterizes at Metal's default positions, each coordinate equal as an `f32`: none set (a count -/// of 0 is Metal's defaults), or exactly the defaults of `samples` ([`METAL_DEFAULT_POSITIONS`]). -/// At a sample count whose defaults the tree does not hold, a set differs. -pub(super) fn at_metal_defaults(samples: u32, positions: &[[f32; 2]]) -> bool { - let defaults = match samples { - 1 => METAL_DEFAULT_POSITIONS[0], - 2 => METAL_DEFAULT_POSITIONS[1], - 4 => METAL_DEFAULT_POSITIONS[2], - _ => return positions.is_empty(), - }; - positions.is_empty() || positions == defaults -} - -/// The render encoders the runtime made of a pass whose sample positions differ from Metal's -/// defaults for its sample count ([`at_metal_defaults`]): the runtime rasterizes them at the -/// defaults, where Metal rasterizes them at the positions the program set. -#[derive(Default)] -pub(super) struct OtherPositions { - passes: u64, - /// The frame and call of the first. - first: Option<(u64, u64)>, -} - -impl OtherPositions { - /// The report's line: the passes counted, and the first. - pub(super) fn line(&self) -> String { - let first = match self.first { - Some((frame, at)) => format!("the first at frame {frame}, call {at}"), - None => "the first: -".into(), - }; - format!( - "passes at sample positions other than Metal's defaults {}: rasterized at the \ - defaults, Vulkan's standard locations; {first}", - self.passes - ) - } -} - /// The attachment index of the pass's own properties in [`Pass::unheld`]. const OWN: usize = usize::MAX; @@ -150,14 +91,12 @@ const OWN: usize = usize::MAX; /// each by its attachment (the colors' indices, then the depth and stencil attachments') or /// [`OWN`], and its key. The runtime makes an encoder of it only where there are none. Each /// attachment's texture as the stream names it, by attachment, for the surfaces' shapes a pass -/// writes (`surfaces`). The sample positions its last `setSamplePositions:count:` set, which the -/// runtime's descriptor does not hold and which change only what the report counts. +/// writes (`surfaces`). #[derive(Default)] pub(super) struct Pass { descriptor: rt::RenderPassDescriptor, unheld: HashSet<(usize, &'static str)>, textures: HashMap, - positions: Vec<[f32; 2]>, } impl Pass { @@ -174,33 +113,17 @@ impl Pass { false => self.unheld.insert((at, key)), }; } - - /// Whether its sample positions differ from Metal's defaults for its sample count: its - /// attachments' (Metal's attachments share one), or `defaultRasterSampleCount` where it has - /// none. - fn other_positions(&self) -> bool { - let d = &self.descriptor; - let colors = d.color_attachments.iter().map(|a| a.texture.as_ref()); - let attachments = colors.chain([ - d.depth_attachment.texture.as_ref(), - d.stencil_attachment.texture.as_ref(), - ]); - let samples = (attachments.flatten().next()).map_or(d.default_raster_sample_count, |t| { - t.descriptor().sample_count - }); - !at_metal_defaults(samples, &self.positions) - } } /// `setSamplePositions:count:`'s positions: its list of `MTLSamplePosition`s, `{x, y}` each. -fn sample_positions(call: &Call) -> Result, PlayError> { - let position = |value: &Value| -> Result<[f32; 2], PlayError> { +fn sample_positions(call: &Call) -> Result, PlayError> { + let position = |value: &Value| -> Result { let f = Fields::of(call, value, &["x", "y"])?; // The recorder writes each `float` as an f64 that holds it exactly. - Ok([ + Ok(rt::SamplePosition::new( f.required("x", Fields::float)? as f32, f.required("y", Fields::float)? as f32, - ]) + )) }; list(call, 0)?.iter().map(position).collect() } @@ -450,21 +373,15 @@ impl NewRuntime { } /// `renderCommandEncoderWithDescriptor:` of `command_buffer`: skipped and counted where the - /// pass holds what the runtime's descriptor does not, or the runtime answers a typed gap; - /// counted where the runtime makes it of a pass at other sample positions than Metal's - /// defaults ([`OtherPositions`]). + /// pass holds what the runtime's descriptor does not, or the runtime answers a typed gap. pub(super) fn render_encoder( &mut self, call: &Call, command_buffer: &rt::CommandBuffer, ) -> Result, PlayError> { - let mut other_positions = false; let descriptor = match self.get(call, Self::id(call, 0)?)? { Object::Pass(pass) => match pass.unheld.is_empty() { - true => { - other_positions = pass.other_positions(); - Ok(pass.descriptor.clone()) - } + true => Ok(pass.descriptor.clone()), false => { let mut keys: Vec<&str> = pass.unheld.iter().map(|&(_, key)| key).collect(); keys.sort_unstable(); @@ -479,19 +396,12 @@ impl NewRuntime { Err(unheld) => return self.skip_encoder(unheld), }; match command_buffer.render_command_encoder(&descriptor) { - Ok(encoder) => { - if other_positions { - let counted = &mut self.other_positions; - counted.passes += 1; - counted.first.get_or_insert(self.at); - } - unaddressed(Object::Render(Box::new(Render { - encoder, - skipped: HashSet::new(), - skipped_pipeline: false, - unrecorded_tessellation: false, - }))) - } + Ok(encoder) => unaddressed(Object::Render(Box::new(Render { + encoder, + skipped: HashSet::new(), + skipped_pipeline: false, + unrecorded_tessellation: false, + }))), Err(rt::Error::Unsupported(gap)) => self.skip_encoder(format!("{gap:?}")), Err(error) => Err(failed(call)(error)), } @@ -584,14 +494,12 @@ impl NewRuntime { /// A setter record of the render pass descriptor `call` is sent to: each property its map /// sets. `defaultColorSampleCount` and `defaultRasterSampleCount`, which change nothing a pass /// with an attachment shows (the runtime refuses one without), are not played; a rate map is - /// refused. `setSamplePositions:count:` sets nothing in the runtime's descriptor, which has no - /// field for it: the pass keeps its positions for the count of passes at other positions than - /// Metal's defaults ([`OtherPositions`]). + /// refused. `setSamplePositions:count:` sets the runtime's descriptor's `sample_positions`. pub(super) fn pass_call(&mut self, call: &Call) -> Result<(), PlayError> { match &*call.selector { "setSamplePositions:count:" => { let positions = sample_positions(call)?; - self.pass(call.receiver).positions = positions; + self.pass(call.receiver).descriptor.sample_positions = positions; } "m2v.setPass" => { let f = Fields::arg(call, 0, &PASS_KEYS)?; diff --git a/crates/metal2vulkan-validation/src/replay/new_runtime/tests.rs b/crates/metal2vulkan-validation/src/replay/new_runtime/tests.rs index da0f2cebc..eacd9ca30 100644 --- a/crates/metal2vulkan-validation/src/replay/new_runtime/tests.rs +++ b/crates/metal2vulkan-validation/src/replay/new_runtime/tests.rs @@ -265,55 +265,6 @@ fn a_fault_s_access_is_placed_among_the_stream_s_buffers_and_heaps() { assert_eq!(placed, " outside every buffer and heap of the stream"); } -/// A pass's sample positions are Metal's defaults where none are set, or where they are the -/// defaults of the pass's own sample count, each coordinate equal; any other set differs: one -/// position off, the defaults in another order, another count's defaults (fewer positions than -/// the pass's samples), and any set at a count whose defaults the tree does not hold (Vulkan's -/// standard locations of 8 samples among them). The report's line reads none counted as such. -#[test] -fn sample_positions_differ_from_metal_s_defaults_of_the_pass_s_count() { - use super::render::{at_metal_defaults, OtherPositions}; - let one = [[0.5, 0.5]]; - let two = [[0.75, 0.75], [0.25, 0.25]]; - let four = [ - [0.375, 0.125], - [0.875, 0.375], - [0.125, 0.625], - [0.625, 0.875], - ]; - let eight = [ - [0.5625, 0.3125], - [0.4375, 0.6875], - [0.8125, 0.5625], - [0.3125, 0.1875], - [0.1875, 0.8125], - [0.0625, 0.4375], - [0.6875, 0.9375], - [0.9375, 0.0625], - ]; - for samples in [0, 1, 2, 4, 8, 16] { - assert!(at_metal_defaults(samples, &[]), "{samples}"); - } - assert!(at_metal_defaults(1, &one)); - assert!(at_metal_defaults(2, &two)); - assert!(at_metal_defaults(4, &four)); - let mut off = four; - off[3][1] = 0.8125; - let reversed = [two[1], two[0]]; - assert!(!at_metal_defaults(4, &off)); - assert!(!at_metal_defaults(2, &reversed)); - assert!(!at_metal_defaults(4, &two)); - assert!(!at_metal_defaults(4, &[[0.25, 0.5]; 4])); - assert!(!at_metal_defaults(1, &[[0.25, 0.25]])); - assert!(!at_metal_defaults(8, &eight)); - assert!(!at_metal_defaults(0, &one)); - assert_eq!( - OtherPositions::default().line(), - "passes at sample positions other than Metal's defaults 0: rasterized at the defaults, \ - Vulkan's standard locations; the first: -" - ); -} - /// The `over copies by frame` line: each frame's over-copy bytes by the buffer's memory class and /// by cause, as the calls are located, their mean and the largest frame's, with the textures in /// an image of their own that frame's calls named, a view as its texture and a released one no diff --git a/crates/metal2vulkan-validation/src/replay/rt_replay.rs b/crates/metal2vulkan-validation/src/replay/rt_replay.rs index 5d891bbd1..c368fa366 100644 --- a/crates/metal2vulkan-validation/src/replay/rt_replay.rs +++ b/crates/metal2vulkan-validation/src/replay/rt_replay.rs @@ -14,9 +14,10 @@ //! - `setLineWidth:` plays: at width 1 a draw of lines after it plays; at width 2 a draw of //! triangles plays and one of lines is the runtime's gap, skipped and counted, and the report //! says the play is no verdict past it: its gap, frame and call. -//! - `setSamplePositions:count:` on a pass descriptor plays as the runtime treats it, nothing -//! refused or skipped: of two passes over a 4-sample target, the report counts the one whose -//! positions differ from Metal's defaults of 4 samples, and not the one at the defaults. +//! - `setSamplePositions:count:` on a pass descriptor plays through the runtime's descriptor: on +//! a device that answers `programmableSamplePositionsSupported` yes, two passes over a 4-sample +//! target, one at Metal's default positions and one at four others, play, nothing refused or +//! skipped. //! - A pass's visibility results play as the runtime's: in a `Reset` pass, `Counting` and //! `Boolean` modes before draws of the whole target write its 16 samples into their words, and //! a word no mode took keeps its bytes, nothing skipped; the backend's gauges read the one @@ -1060,12 +1061,19 @@ fn a_line_width_plays_and_a_line_drawn_at_another_width_is_skipped() { assert!(lines.iter().any(|l| l == line), "{lines:?}"); } -/// `setSamplePositions:count:` plays as the runtime treats it: two passes over a 4-sample target -/// (#3), one at Metal's default positions of 4 samples (#4) and one at four others (#5), each -/// set on the pass descriptor, play through with nothing refused or skipped, and the report -/// counts the second pass alone, at its encoder (call 12). +/// `setSamplePositions:count:` plays through the runtime's descriptor: on a device that answers +/// `programmableSamplePositionsSupported` yes, two passes over a 4-sample target (#3), one at +/// Metal's default positions of 4 samples (#4) and one at four others (#5), each set on the pass +/// descriptor, play with nothing refused or skipped. A device that answers no is printed, and +/// plays nothing. #[test] -fn sample_positions_play_and_a_pass_at_other_positions_is_counted() { +fn sample_positions_play_through_the_runtime_s_descriptor() { + let cache = ScratchCache::new().unwrap(); + let device = rt_device(&cache); + if !device.programmable_sample_positions_supported() { + eprintln!("REPLAY sample-positions the device has no programmable sample positions"); + return; + } let dir = ScratchDir::new("rt-replay-sample-positions").unwrap(); let path = written(&dir, |w| { w.call("MTLCreateSystemDefaultDevice", 0, 1, &[], &[])?; @@ -1130,16 +1138,13 @@ fn sample_positions_play_and_a_pass_at_other_positions_is_counted() { w.call("commit", 6, 0, &[], &[])?; w.call(WAIT_COMPLETED, 6, 0, &[], &[]) }); - let (report, lines) = play("sample-positions", &path); + let (report, _, ()) = play_on(device, "sample-positions", &path, |_| ()); let executed = &report.total.executed; for skipped in ["skipped_encoders", "skipped_calls", "skipped_objects"] { assert_eq!(executed[skipped], 0, "{skipped}: {executed:?}"); } assert!(executed["passes"] >= 2, "{executed:?}"); assert_eq!(report.first_skip, None); - let line = "passes at sample positions other than Metal's defaults 1: rasterized at the \ - defaults, Vulkan's standard locations; the first at frame 0, call 12"; - assert!(lines.iter().any(|l| l == line), "{lines:?}"); } /// A word of a visibility result buffer that no mode wrote: its bytes as made. diff --git a/crates/metal2vulkan/tests/api_signatures.tsv b/crates/metal2vulkan/tests/api_signatures.tsv index e2d224f69..a16b00274 100644 --- a/crates/metal2vulkan/tests/api_signatures.tsv +++ b/crates/metal2vulkan/tests/api_signatures.tsv @@ -413,7 +413,7 @@ const-value metal2vulkan-runtime::floor::DEVICE_EXTENSIONS &[ash::khr::swapchain const-value metal2vulkan-runtime::floor::INDIRECT_COMMANDS &[crate::dgc::NAME, ash::khr::maintenance5::NAME] const-value metal2vulkan-runtime::floor::INSTANCE_EXTENSIONS &[ash::khr::surface::NAME] const-value metal2vulkan-runtime::floor::MAINTENANCE8 c"VK_KHR_maintenance8" -const-value metal2vulkan-runtime::floor::OPTIONAL_EXTENSIONS &[ash::khr::shader_maximal_reconvergence::NAME, ash::khr::shader_subgroup_uniform_control_flow::NAME, ash::khr::shader_quad_control::NAME, ash::ext::fragment_shader_interlock::NAME, ash::ext::shader_stencil_export::NAME, ash::khr::portability_subset::NAME, ash::khr::vertex_attribute_divisor::NAME, ash::ext::vertex_attribute_divisor::NAME, ash::ext::external_memory_host::NAME, ash::khr::external_memory_fd::NAME, ash::ext::external_memory_dma_buf::NAME, ash::khr::external_memory_win32::NAME, ash::ext::queue_family_foreign::NAME, ash::ext::image_drm_format_modifier::NAME, ash::nv::linear_color_attachment::NAME, ash::ext::device_fault::NAME, ash::ext::pipeline_robustness::NAME, MAINTENANCE8] +const-value metal2vulkan-runtime::floor::OPTIONAL_EXTENSIONS &[ash::khr::shader_maximal_reconvergence::NAME, ash::khr::shader_subgroup_uniform_control_flow::NAME, ash::khr::shader_quad_control::NAME, ash::ext::fragment_shader_interlock::NAME, ash::ext::shader_stencil_export::NAME, ash::khr::portability_subset::NAME, ash::khr::vertex_attribute_divisor::NAME, ash::ext::vertex_attribute_divisor::NAME, ash::ext::external_memory_host::NAME, ash::khr::external_memory_fd::NAME, ash::ext::external_memory_dma_buf::NAME, ash::khr::external_memory_win32::NAME, ash::ext::queue_family_foreign::NAME, ash::ext::image_drm_format_modifier::NAME, ash::nv::linear_color_attachment::NAME, ash::ext::device_fault::NAME, ash::ext::pipeline_robustness::NAME, MAINTENANCE8, ash::ext::sample_locations::NAME] const-value metal2vulkan-runtime::floor::OPTIONAL_INSTANCE_EXTENSIONS &[ash::khr::portability_enumeration::NAME] const-value metal2vulkan-runtime::floor::TIME_DOMAINS [vk::TimeDomainKHR::DEVICE, crate::times::HOST_DOMAIN] const-value metal2vulkan-runtime::floor::VERSION vk::API_VERSION_1_3 @@ -603,6 +603,7 @@ enum metal2vulkan-runtime::RefusalBasis #[derive(Clone, Copy, Debug, PartialEq, enum metal2vulkan-runtime::RenderPassKind #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum RenderPassKind enum metal2vulkan-runtime::RenderPipelineKind #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum RenderPipelineKind enum metal2vulkan-runtime::Resource #[derive(Clone, Copy)] #[non_exhaustive] pub enum Resource<'a> +enum metal2vulkan-runtime::SamplePositionsKind #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum SamplePositionsKind enum metal2vulkan-runtime::Stage #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum Stage enum metal2vulkan-runtime::StageBreach #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum StageBreach enum metal2vulkan-runtime::StageFill #[derive(Clone, Copy, Debug, PartialEq, Eq)] #[non_exhaustive] pub enum StageFill @@ -6047,6 +6048,7 @@ method metal2vulkan-runtime::Device::new_shared_event pub fn new_shared_event(&s method metal2vulkan-runtime::Device::new_texture pub fn new_texture(&self, descriptor: &TextureDescriptor, index: Option) -> Result method metal2vulkan-runtime::Device::new_texture_for_views pub fn new_texture_for_views(&self, descriptor: &TextureDescriptor) -> Result method metal2vulkan-runtime::Device::pixel_format_info pub fn pixel_format_info(&self, raw: u64) -> PixelFormatInfo +method metal2vulkan-runtime::Device::programmable_sample_positions_supported pub fn programmable_sample_positions_supported(&self) -> bool method metal2vulkan-runtime::Device::quiesce pub fn quiesce(&self, timeout: Duration) -> bool method metal2vulkan-runtime::Device::raw pub fn raw(&self) -> RawDevice<'_> method metal2vulkan-runtime::Device::read_write_texture_support pub fn read_write_texture_support(&self) -> ReadWriteTextureTier @@ -8396,6 +8398,7 @@ variant metal2vulkan-runtime::DrawKind::FetchedAttachment FetchedAttachment variant metal2vulkan-runtime::DrawKind::FillMode FillMode variant metal2vulkan-runtime::DrawKind::LineWidth LineWidth variant metal2vulkan-runtime::DrawKind::PatchIndexBuffer PatchIndexBuffer +variant metal2vulkan-runtime::DrawKind::SamplePositions SamplePositions variant metal2vulkan-runtime::DrawKind::StencilOutput StencilOutput variant metal2vulkan-runtime::DrawKind::Viewport Viewport variant metal2vulkan-runtime::DrawKind::Viewports Viewports @@ -8668,6 +8671,7 @@ variant metal2vulkan-runtime::Refusal::PatchDraw PatchDraw variant metal2vulkan-runtime::Refusal::PointSizeTopology PointSizeTopology { class: PrimitiveTopologyClass } variant metal2vulkan-runtime::Refusal::ResolveFormat ResolveFormat { pixel_format: PixelFormat } variant metal2vulkan-runtime::Refusal::ResolveTexture ResolveTexture +variant metal2vulkan-runtime::Refusal::SamplePositions SamplePositions { kind: SamplePositionsKind, count: u32, samples: u32 } variant metal2vulkan-runtime::Refusal::SamplerArgumentIndex SamplerArgumentIndex { index: u32 } variant metal2vulkan-runtime::Refusal::SamplerIds SamplerIds { numbered: usize, given: usize } variant metal2vulkan-runtime::Refusal::StencilAttachment StencilAttachment @@ -8714,6 +8718,7 @@ variant metal2vulkan-runtime::RenderPassKind::Resolve Resolve variant metal2vulkan-runtime::RenderPassKind::ResolveFilter ResolveFilter variant metal2vulkan-runtime::RenderPassKind::ResolveUsage ResolveUsage variant metal2vulkan-runtime::RenderPassKind::SampleCounts SampleCounts +variant metal2vulkan-runtime::RenderPassKind::SamplePositions SamplePositions variant metal2vulkan-runtime::RenderPassKind::StoreAction StoreAction variant metal2vulkan-runtime::RenderPassKind::TextureType TextureType variant metal2vulkan-runtime::RenderPipelineKind::DepthStencilFormats DepthStencilFormats @@ -8728,6 +8733,10 @@ variant metal2vulkan-runtime::RenderPipelineKind::VertexAmplification VertexAmpl variant metal2vulkan-runtime::Resource::Buffer Buffer(&'a Buffer) variant metal2vulkan-runtime::Resource::IndirectCommandBuffer IndirectCommandBuffer(&'a IndirectCommandBuffer) variant metal2vulkan-runtime::Resource::Texture Texture(&'a Texture) +variant metal2vulkan-runtime::SamplePositionsKind::Coordinate Coordinate +variant metal2vulkan-runtime::SamplePositionsKind::Count Count +variant metal2vulkan-runtime::SamplePositionsKind::OneSample OneSample +variant metal2vulkan-runtime::SamplePositionsKind::Unsupported Unsupported variant metal2vulkan-runtime::Stage::Fragment Fragment variant metal2vulkan-runtime::Stage::Kernel Kernel variant metal2vulkan-runtime::Stage::Mesh Mesh diff --git a/docs/CONFORMANCE-COVERAGE.md b/docs/CONFORMANCE-COVERAGE.md index d821298c0..fc4014773 100644 --- a/docs/CONFORMANCE-COVERAGE.md +++ b/docs/CONFORMANCE-COVERAGE.md @@ -20,8 +20,9 @@ Its limits, measured rather than asserted: - **9 call sites resolve to no item although some Metal type binds the selector**: an instance send whose receiver this could not type, a message to a class that does not bind the name sent to it, or a selector sent by hand to a receiver whose Rust type is a **supertype** of the one that binds it — which is often why it is sent by hand, since `objc2` casts between two protocol objects nowhere. Each sent its selector to exactly one receiver, so each exercised one item; which one is what the typing could not say. **Every one of their selectors is bound by at least one item some other call site credits**, so none of these sites proves an item is missing from the count. That is not a proof that the count is complete: such a site may have sent its selector to a type other than the credited one, and this cannot tell. To rule it out, spell the receiver's type at the call site — a `let` with a type, rather than a `let` with none — and this re-derives with the item credited to the case that calls it. A pattern binding is not one of the shapes that costs a site: a tuple, a `for`, a `match` arm and a closure parameter are each typed from what made them. - **0 call sites typed to a receiver that does not bind the selector sent to it.** The generator fails rather than writing this document if any does, which is what keeps the typing from quietly counting the wrong item. - **82 of the map's implemented rows are a container's own**: the `class`, `protocol` and `category` rows, whose name is the container's and not a selector's. No call site can resolve to one, because `objc2-metal` binds no selector by that name, so these are credited by the suite **messaging** the type instead — a call whose receiver is the container or a subtype of it — under the same gate and the same family attribution as the selector it sends. -- **4 are the header's free functions**, which no container declares. `objc2-metal` binds these as Rust functions, so the receiver typing never sees one; the leg calls such a function by its own C name and the walk reads it as an edge of the call graph. -- **1 implemented items `objc2-metal` binds no name for at all**, so no case can call them whatever it is authored to do. They are counted apart from the gap below rather than folded into it, because a gap is work and these are not: +- **5 are the header's free functions**, which no container declares. `objc2-metal` binds these as Rust functions, so the receiver typing never sees one; the leg calls such a function by its own C name and the walk reads it as an edge of the call graph. +- **2 implemented items `objc2-metal` binds no name for at all**, so no case can call them whatever it is authored to do. They are counted apart from the gap below rather than folded into it, because a gap is work and these are not: + - `MTLDevice`'s `programmableSamplePositionsSupported` - `MTLFunctionReflection`'s `userAnnotation` - The unit a call is attributed to is the **case module**, not the case: a module's cases share one `run`, so which of them encodes which step is not a property of the text. Where a module holds one case the two are the same. - **No verdict is recorded here.** A verdict is what a replay on one venue measured, and a number like that in a generated document is a journal entry that rots. What is durable, and is here, is whether a case compares **exactly**: the allowances a module declares, and the rows of the suite's ledger. @@ -30,14 +31,14 @@ Its limits, measured rather than asserted: | | | |---|---| -| implemented Metal items | 638 | -| of those, unreachable: `objc2-metal` binds no name for them | 1 | -| so reachable by some case | 637 | -| of the reachable, exercised by the suite's Metal leg | 559 | -| of the reachable, not exercised | 78 | +| implemented Metal items | 642 | +| of those, unreachable: `objc2-metal` binds no name for them | 2 | +| so reachable by some case | 640 | +| of the reachable, exercised by the suite's Metal leg | 561 | +| of the reachable, not exercised | 79 | | share of the reachable exercised | 88% | -| of those exercised, no case reaching it loosens anything | 339 | -| of those exercised, a case reaching it loosens some site | 220 | +| of those exercised, no case reaching it loosens anything | 340 | +| of those exercised, a case reaching it loosens some site | 221 | | case modules | 191 | | committed recordings | 1339 | | distinct SDK items the Metal leg reaches, of any status | 812 | @@ -364,8 +365,8 @@ Every container with an implemented item, by how much of it the suite reaches. * | `MTLArgument` | 17 | 0 | 0 | 17 | | | `MTLRasterizationRateLayerDescriptor` | 9 | 0 | 2 | 7 | `rate_map_degenerate_forms`, `rate_map_sweeps`, `rate_maps` | | `MTLRenderCommandEncoder` | 64 | 0 | 58 | 6 | `alpha_coverage_pairs`, `blend_interactions`, `blend_sweeps`, `blit_indirect_commands`… | -| `MTLDevice` | 27 | 0 | 22 | 5 | `alpha_coverage_pairs`, `argument_encoder_crossings`, `argument_encoders`, `astc_textures`… | -| the header's free functions | 4 | 0 | 0 | 4 | | +| the header's free functions | 5 | 0 | 0 | 5 | | +| `MTLDevice` | 28 | 1 | 22 | 5 | `alpha_coverage_pairs`, `argument_encoder_crossings`, `argument_encoders`, `astc_textures`… | | `MTLComputeCommandEncoder` | 29 | 0 | 26 | 3 | `argument_encoders`, `astc_textures`, `attribute_formats`, `attribute_strides`… | | `MTLFunctionConstantValues` | 5 | 0 | 2 | 3 | `function_constants_half3`, `function_facts`, `library_facts` | | `MTLLibrary` | 10 | 0 | 7 | 3 | `alpha_coverage_pairs`, `argument_encoder_crossings`, `argument_encoders`, `astc_textures`… | @@ -421,7 +422,7 @@ Every container with an implemented item, by how much of it the suite reaches. * | `MTLRenderPassColorAttachmentDescriptor` | 2 | 0 | 2 | 0 | `alpha_coverage_pairs`, `blend_interactions`, `blend_sweeps`, `blit_indirect_commands`… | | `MTLRenderPassColorAttachmentDescriptorArray` | 3 | 0 | 3 | 0 | `alpha_coverage_pairs`, `blend_interactions`, `blend_sweeps`, `blit_indirect_commands`… | | `MTLRenderPassDepthAttachmentDescriptor` | 3 | 0 | 3 | 0 | `alpha_coverage_pairs`, `blend_interactions`, `blend_sweeps`, `blit_indirect_commands`… | -| `MTLRenderPassDescriptor` | 10 | 0 | 10 | 0 | `alpha_coverage_pairs`, `blend_interactions`, `blend_sweeps`, `blit_indirect_commands`… | +| `MTLRenderPassDescriptor` | 12 | 0 | 12 | 0 | `alpha_coverage_pairs`, `blend_interactions`, `blend_sweeps`, `blit_indirect_commands`… | | `MTLRenderPassStencilAttachmentDescriptor` | 3 | 0 | 3 | 0 | `alpha_coverage_pairs`, `blend_interactions`, `blend_sweeps`, `blit_indirect_commands`… | | `MTLRenderPipelineColorAttachmentDescriptor` | 10 | 0 | 10 | 0 | `alpha_coverage_pairs`, `binary_archives`, `blend_interactions`, `blend_sweeps`… | | `MTLRenderPipelineDescriptor` | 33 | 0 | 33 | 0 | `alpha_coverage_pairs`, `binary_archives`, `blend_interactions`, `blend_sweeps`… | @@ -454,7 +455,7 @@ A container is one Objective-C type; the SDK header it sits in is the family of |---|---|---|---| | `MTLArgument.h` | 77 | 59 | 18 | | `MTLRasterizationRate.h` | 25 | 12 | 13 | -| `MTLDevice.h` | 37 | 30 | 7 | +| `MTLDevice.h` | 38 | 31 | 7 | | `MTLRenderCommandEncoder.h` | 64 | 58 | 6 | | `MTLLibrary.h` | 40 | 35 | 5 | | `MTLRenderPipeline.h` | 102 | 97 | 5 | @@ -470,8 +471,9 @@ A container is one Objective-C type; the SDK header it sits in is the family of | `MTLEvent.h` | 6 | 5 | 1 | | `MTLFence.h` | 1 | 0 | 1 | | `MTLPipeline.h` | 5 | 4 | 1 | -| `MTLRenderPass.h` | 33 | 32 | 1 | +| `MTLRenderPass.h` | 35 | 34 | 1 | | `MTLTexture.h` | 39 | 38 | 1 | +| `MTLTypes.h` | 1 | 0 | 1 | | `MTLAllocation.h` | 1 | 1 | 0 | | `MTLBlitCommandEncoder.h` | 14 | 14 | 0 | | `MTLCommandEncoder.h` | 2 | 2 | 0 | @@ -484,7 +486,7 @@ A container is one Objective-C type; the SDK header it sits in is the family of | `MTLSampler.h` | 18 | 18 | 0 | | `MTLVisibleFunctionTable.h` | 7 | 7 | 0 | -1 of 31 headers have no exercised item at all, 1 implemented items between them: `MTLFence.h`. +2 of 32 headers have no exercised item at all, 2 implemented items between them: `MTLFence.h`, `MTLTypes.h`. ## Containers with no case at all @@ -492,14 +494,14 @@ An implemented container no case's Metal leg touches. These are the families of | container | implemented items | header | |---|---|---| -| the header's free functions | 4 | `MTLDevice.h` | +| the header's free functions | 5 | `MTLDevice.h` | | `MTLArgument` | 17 | `MTLArgument.h` | | `MTLDepthStencilState` | 1 | `MTLDepthStencil.h` | | `MTLFence` | 1 | `MTLFence.h` | | `MTLFunctionReflection` | 3 | `MTLLibrary.h` | | `MTLRasterizationRateSampleArray` | 3 | `MTLRasterizationRate.h` | -6 containers, 29 implemented items. +6 containers, 30 implemented items. ## The suite's shape @@ -535,7 +537,7 @@ Each case module: the cases it holds, the `Side` methods it calls, and how many | family | cases | Metal ran | compared | items reached | |---|---|---|---|---| -| `alpha_coverage_pairs` | 17 | 17 | 1 tolerance(s): `Degradation` | 116 | +| `alpha_coverage_pairs` | 17 | 17 | 1 tolerance(s): `Degradation` | 117 | | `argument_encoder_crossings` | 4 | 4 | every field | 41 | | `argument_encoders` | 5 | 5 | every field | 57 | | `astc_textures` | 42 | 42 | 1 tolerance(s): `Degradation` | 39 | @@ -543,20 +545,20 @@ Each case module: the cases it holds, the `Side` methods it calls, and how many | `attribute_strides` | 4 | 4 | every field | 46 | | `bicubic_texel_classes` | 1 | 1 | every field | 31 | | `binary_archives` | 6 | 6 | every field | 27 | -| `blend_interactions` | 4 | 4 | every field | 120 | -| `blend_sweeps` | 12 | 12 | every field | 120 | +| `blend_interactions` | 4 | 4 | every field | 121 | +| `blend_sweeps` | 12 | 12 | every field | 121 | | `blit_encoder_commands` | 11 | 11 | every field | 46 | -| `blit_indirect_commands` | 3 | 3 | every field | 98 | +| `blit_indirect_commands` | 3 | 3 | every field | 99 | | `border_swizzles` | 8 | 8 | every field | 56 | | `buffer_bind_off_alignment` | 1 | 1 | every field | 22 | | `buffer_blits` | 4 | 4 | every field | 21 | | `buffer_depth_samples` | 5 | 5 | every field | 57 | | `buffer_tails` | 2 | 2 | every field | 49 | -| `buffer_target_clears` | 6 | 6 | 1 tolerance(s): `AcceptedDifference` | 61 | +| `buffer_target_clears` | 6 | 6 | 1 tolerance(s): `AcceptedDifference` | 62 | | `buffer_texture_blits` | 2 | 2 | every field | 37 | | `buffer_textures` | 3 | 2 | every field | 43 | | `chroma_pairs` | 6 | 6 | every field | 64 | -| `color_write_masks` | 5 | 5 | every field | 117 | +| `color_write_masks` | 5 | 5 | every field | 118 | | `command_buffer_facts` | 1 | 1 | every field | 23 | | `command_queues` | 1 | 1 | every field | 5 | | `compressed_blits` | 4 | 4 | every field | 39 | @@ -567,39 +569,39 @@ Each case module: the cases it holds, the `Side` methods it calls, and how many | `compute_encoder_commands` | 8 | 8 | every field | 62 | | `compute_heap_residency` | 1 | 1 | every field | 43 | | `compute_pipeline_descriptors` | 3 | 3 | 1 tolerance(s): `AcceptedDifference` | 22 | -| `compute_render_chains` | 3 | 3 | every field | 144 | +| `compute_render_chains` | 3 | 3 | every field | 145 | | `compute_threadgroups` | 2 | 1 | every field | 27 | | `copy_out_strides` | 1 | 1 | every field | 36 | | `denormal_word_fetches` | 1 | 1 | every field | 39 | -| `depth_resolve_pairs` | 2 | 2 | every field | 134 | +| `depth_resolve_pairs` | 2 | 2 | every field | 135 | | `depth_stencil_copies` | 1 | 1 | every field | 37 | -| `depth_stencil_space` | 8 | 8 | every field | 137 | +| `depth_stencil_space` | 8 | 8 | every field | 138 | | `depth_texel_reads` | 1 | 1 | every field | 48 | | `device_queries` | 5 | 5 | every field | 3 | -| `discard_hoist` | 1 | 1 | 1 tolerance(s): `Degradation` | 138 | -| `draw_state_changes` | 1 | 1 | every field | 140 | +| `discard_hoist` | 1 | 1 | 1 tolerance(s): `Degradation` | 139 | +| `draw_state_changes` | 1 | 1 | every field | 141 | | `dynamic_libraries` | 3 | 3 | every field | 6 | | `empty_command_buffers` | 1 | 1 | every field | 20 | | `etc_textures` | 10 | 10 | every field | 39 | | `event_orders` | 5 | 5 | 4 tolerance(s): `AcceptedDifference` | 27 | -| `extended_range_blends` | 18 | 18 | every field | 127 | -| `extended_range_gamut` | 39 | 39 | every field | 118 | -| `extended_range_gradients` | 8 | 8 | every field | 119 | +| `extended_range_blends` | 18 | 18 | every field | 128 | +| `extended_range_gamut` | 39 | 39 | every field | 119 | +| `extended_range_gradients` | 8 | 8 | every field | 120 | | `extended_range_planes` | 4 | 4 | every field | 28 | -| `extended_range_targets` | 22 | 22 | every field | 124 | +| `extended_range_targets` | 22 | 22 | every field | 125 | | `extended_range_two_planes` | 2 | 2 | every field | 32 | | `extended_swizzles` | 15 | 15 | every field | 56 | | `fence_orders` | 6 | 6 | 1 tolerance(s): `AcceptedDifference` | 27 | -| `fetch_ordered` | 6 | 6 | every field | 119 | +| `fetch_ordered` | 6 | 6 | every field | 120 | | `format_copies` | 16 | 16 | every field | 37 | | `format_footprints` | 6 | 6 | 1 tolerance(s): `AcceptedDifference` | 19 | | `fragment_imageblock_reflection` | 1 | 1 | every field | 74 | -| `frame_chains` | 1 | 1 | every field | 141 | +| `frame_chains` | 1 | 1 | every field | 142 | | `fresh_contents` | 87 | 87 | every field | 40 | | `function_bindings` | 15 | 15 | every field | 64 | | `function_constants_half3` | 1 | 1 | every field | 27 | | `function_facts` | 15 | 15 | every field | 32 | -| `half_output_blends` | 6 | 6 | every field | 120 | +| `half_output_blends` | 6 | 6 | every field | 121 | | `half_read_nans` | 6 | 6 | every field | 48 | | `half_storage_writes` | 9 | 9 | every field | 32 | | `half_texel_nans` | 8 | 8 | every field | 31 | @@ -608,14 +610,14 @@ Each case module: the cases it holds, the `Side` methods it calls, and how many | `heap_facts` | 5 | 5 | every field | 5 | | `heap_metal_sizes` | 7 | 7 | 1 tolerance(s): `AcceptedDifference` | 14 | | `host_detach` | 1 | 1 | every field | 18 | -| `host_page_writes` | 4 | 4 | every field | 126 | +| `host_page_writes` | 4 | 4 | every field | 127 | | `imageblock_sizes` | 1 | 1 | every field | 24 | -| `indirect_command_depth` | 6 | 6 | every field | 164 | -| `indirect_commands` | 9 | 9 | every field | 166 | +| `indirect_command_depth` | 6 | 6 | every field | 165 | +| `indirect_commands` | 9 | 9 | every field | 167 | | `indirect_private_types` | 1 | 0 | every field | 0 | | `indirect_ranges` | 3 | 3 | every field | 69 | -| `int_attributes` | 1 | 1 | every field | 105 | -| `layered_targets` | 5 | 5 | every field | 134 | +| `int_attributes` | 1 | 1 | every field | 106 | +| `layered_targets` | 5 | 5 | every field | 135 | | `level_sizes` | 2 | 2 | every field | 39 | | `library_facts` | 9 | 9 | every field | 38 | | `math_routines` | 2 | 2 | every field | 25 | @@ -628,15 +630,15 @@ Each case module: the cases it holds, the `Side` methods it calls, and how many | `nan_integer_conversions` | 1 | 1 | 1 tolerance(s): `AcceptedDifference` | 56 | | `nearest_positions` | 1 | 1 | every field | 48 | | `norm_storage_writes` | 7 | 7 | every field | 41 | -| `padded_blends` | 17 | 17 | every field | 119 | -| `padded_fetch` | 11 | 11 | every field | 119 | -| `pass_attachment_pairs` | 2 | 2 | every field | 119 | -| `pass_bound_pairs` | 1 | 1 | every field | 120 | +| `padded_blends` | 17 | 17 | every field | 120 | +| `padded_fetch` | 11 | 11 | every field | 120 | +| `pass_attachment_pairs` | 2 | 2 | every field | 120 | +| `pass_bound_pairs` | 1 | 1 | every field | 121 | | `pass_bytes` | 4 | 4 | every field | 25 | -| `pass_sequence_actions` | 2 | 2 | 1 tolerance(s): `AcceptedDifference` | 135 | -| `pass_start_reads` | 14 | 14 | 2 tolerance(s): `AcceptedDifference` | 125 | -| `pass_unattached_between` | 1 | 1 | every field | 114 | -| `pass_unattached_colors` | 1 | 1 | every field | 117 | +| `pass_sequence_actions` | 2 | 2 | 1 tolerance(s): `AcceptedDifference` | 136 | +| `pass_start_reads` | 14 | 14 | 2 tolerance(s): `AcceptedDifference` | 126 | +| `pass_unattached_between` | 1 | 1 | every field | 115 | +| `pass_unattached_colors` | 1 | 1 | every field | 118 | | `pipeline_descriptors` | 3 | 3 | every field | 75 | | `pipeline_facts` | 9 | 9 | every field | 67 | | `pipeline_functions` | 8 | 8 | every field | 5 | @@ -646,83 +648,83 @@ Each case module: the cases it holds, the `Side` methods it calls, and how many | `pipeline_options` | 21 | 21 | every field | 76 | | `pixel_downscales` | 7 | 7 | every field | 51 | | `pixel_samplers` | 20 | 20 | every field | 51 | -| `primitive_type_crossings` | 1 | 1 | every field | 118 | +| `primitive_type_crossings` | 1 | 1 | every field | 119 | | `pvrtc_cpu_order` | 6 | 6 | every field | 37 | | `pvrtc_rows` | 8 | 8 | every field | 37 | -| `quad_helpers` | 1 | 1 | 1 tolerance(s): `Degradation` | 118 | +| `quad_helpers` | 1 | 1 | 1 tolerance(s): `Degradation` | 119 | | `rate_map_degenerate_forms` | 3 | 3 | every field | 19 | | `rate_map_sweeps` | 9 | 9 | every field | 19 | | `rate_maps` | 2 | 2 | every field | 14 | | `read_through` | 13 | 13 | every field | 59 | | `read_write_tiers` | 7 | 7 | every field | 45 | -| `reconvergence` | 2 | 2 | every field | 124 | -| `render_chains` | 3 | 3 | every field | 138 | -| `render_depth_stencil_state` | 3 | 3 | every field | 138 | -| `render_draw_forms` | 4 | 4 | every field | 125 | -| `render_pass_descriptors` | 12 | 12 | every field | 31 | -| `render_residency` | 2 | 2 | every field | 132 | -| `render_state` | 3 | 3 | every field | 158 | -| `resolve_then_load` | 1 | 1 | every field | 126 | +| `reconvergence` | 2 | 2 | every field | 125 | +| `render_chains` | 3 | 3 | every field | 139 | +| `render_depth_stencil_state` | 3 | 3 | every field | 139 | +| `render_draw_forms` | 4 | 4 | every field | 126 | +| `render_pass_descriptors` | 12 | 12 | every field | 33 | +| `render_residency` | 2 | 2 | every field | 133 | +| `render_state` | 3 | 3 | every field | 159 | +| `resolve_then_load` | 1 | 1 | every field | 127 | | `resource_facts` | 4 | 4 | every field | 21 | | `rgb10a2_srgb` | 8 | 8 | every field | 76 | -| `rotated_planes` | 20 | 20 | every field | 117 | -| `rotated_targets` | 14 | 14 | every field | 120 | +| `rotated_planes` | 20 | 20 | every field | 118 | +| `rotated_targets` | 14 | 14 | every field | 121 | | `sample_fills` | 17 | 0 | every field | 0 | -| `sample_positions` | 19 | 16 | every field | 118 | -| `sampler_bind_clamps` | 2 | 2 | every field | 152 | +| `sample_positions` | 19 | 16 | every field | 119 | +| `sampler_bind_clamps` | 2 | 2 | every field | 153 | | `sampler_crossings` | 8 | 8 | every field | 57 | | `sampler_filtering` | 15 | 15 | every field | 57 | | `scheduled_handlers` | 1 | 1 | every field | 16 | -| `shader_stencil` | 2 | 2 | every field | 134 | +| `shader_stencil` | 2 | 2 | every field | 135 | | `shared_creator_formats` | 2 | 2 | every field | 23 | | `shared_events` | 2 | 2 | every field | 13 | | `shared_exponent_storage` | 5 | 5 | every field | 40 | | `signed_remainders` | 1 | 1 | every field | 25 | | `simdgroup_lockstep` | 2 | 2 | every field | 25 | -| `snorm_tile_store` | 7 | 7 | 1 tolerance(s): `Degradation` | 117 | +| `snorm_tile_store` | 7 | 7 | 1 tolerance(s): `Degradation` | 118 | | `sparse_heaps` | 6 | 6 | every field | 15 | | `sparse_mappings` | 14 | 14 | every field | 32 | | `sparse_tiles` | 4 | 4 | every field | 1 | -| `srgb_fetch` | 2 | 2 | every field | 133 | +| `srgb_fetch` | 2 | 2 | every field | 134 | | `srgb_storage_writes` | 1 | 1 | every field | 39 | | `stage_in_regions` | 1 | 1 | every field | 49 | | `stage_in_unread` | 1 | 1 | every field | 48 | -| `stencil_resolve_pairs` | 2 | 2 | every field | 135 | -| `stencil_resolved_sample` | 1 | 1 | every field | 135 | +| `stencil_resolve_pairs` | 2 | 2 | every field | 136 | +| `stencil_resolved_sample` | 1 | 1 | every field | 136 | | `surface_fills` | 1 | 0 | every field | 0 | | `surface_textures` | 10 | 10 | every field | 29 | | `swizzled_storage` | 6 | 6 | every field | 41 | -| `tessellation_crossings` | 6 | 6 | every field | 105 | -| `tessellation_rendered` | 1 | 1 | every field | 121 | -| `tessellation_sweeps` | 7 | 7 | every field | 106 | +| `tessellation_crossings` | 6 | 6 | every field | 106 | +| `tessellation_rendered` | 1 | 1 | every field | 122 | +| `tessellation_sweeps` | 7 | 7 | every field | 107 | | `texel_swizzles` | 6 | 6 | every field | 39 | | `texture_accesses` | 1 | 1 | every field | 20 | | `texture_buffer_fills` | 3 | 0 | every field | 0 | | `texture_buffer_tails` | 1 | 1 | every field | 48 | | `texture_descriptor_pairs` | 5 | 5 | 1 tolerance(s): `AcceptedDifference` | 27 | | `texture_fills` | 54 | 2 | every field | 40 | -| `texture_view_casts` | 5 | 5 | every field | 78 | +| `texture_view_casts` | 5 | 5 | every field | 79 | | `texture_views` | 4 | 4 | every field | 35 | | `textures` | 76 | 76 | every field | 10 | | `threadgroup_start` | 1 | 1 | every field | 24 | | `tile_pipeline_descriptors` | 3 | 3 | every field | 31 | | `tile_pipeline_reflection` | 1 | 1 | every field | 77 | | `tile_threadgroups` | 8 | 8 | every field | 49 | -| `topology_classes` | 2 | 2 | every field | 116 | +| `topology_classes` | 2 | 2 | every field | 117 | | `two_plane_copies` | 3 | 1 | every field | 40 | | `two_plane_heap_blits` | 1 | 1 | every field | 38 | | `two_plane_samples` | 16 | 16 | every field | 48 | | `vector_word_phases` | 5 | 5 | every field | 23 | -| `vertex_attribute_strides` | 2 | 2 | every field | 105 | -| `vertex_constant_step` | 1 | 1 | every field | 106 | -| `vertex_fetch_reach` | 1 | 1 | every field | 106 | -| `vertex_formats` | 4 | 4 | every field | 105 | -| `vertex_step_rate` | 1 | 1 | every field | 105 | -| `viewport_cuts` | 2 | 2 | every field | 121 | -| `visibility` | 16 | 16 | 1 tolerance(s): `AcceptedDifference` | 131 | +| `vertex_attribute_strides` | 2 | 2 | every field | 106 | +| `vertex_constant_step` | 1 | 1 | every field | 107 | +| `vertex_fetch_reach` | 1 | 1 | every field | 107 | +| `vertex_formats` | 4 | 4 | every field | 106 | +| `vertex_step_rate` | 1 | 1 | every field | 106 | +| `viewport_cuts` | 2 | 2 | every field | 122 | +| `visibility` | 16 | 16 | 1 tolerance(s): `AcceptedDifference` | 132 | | `visible_tables` | 18 | 18 | every field | 49 | -| `wide_int_attributes` | 2 | 2 | every field | 105 | -| `wide_points` | 1 | 1 | every field | 119 | +| `wide_int_attributes` | 2 | 2 | every field | 106 | +| `wide_points` | 1 | 1 | every field | 120 | | `ycbcr_gathers` | 4 | 4 | every field | 50 | | `ycbcr_minify` | 2 | 2 | every field | 50 | | `ycbcr_textures` | 2 | 2 | 1 tolerance(s): `AcceptedDifference` | 39 | @@ -739,6 +741,7 @@ One row per implemented item of the SDK, in the coverage map's order. *exercised | `MTLCopyAllDevices` | no | — | — | | `MTLClearColorMake` | no | — | — | | `MTLTextureSwizzleChannelsMake` | no | — | — | +| `MTLSamplePositionMake` | no | — | — | ### `MTLAllocation` @@ -1052,6 +1055,7 @@ One row per implemented item of the SDK, in the coverage map's order. *exercised | `minimumLinearTextureAlignmentForPixelFormat:` | yes | `device_queries` | 5 | | `minimumTextureBufferAlignmentForPixelFormat:` | no | — | — | | `maxThreadgroupMemoryLength` | no | — | — | +| `programmableSamplePositionsSupported` | no | — | — | | `newIndirectCommandBufferWithDescriptor:maxCommandCount:options:` | yes | `blit_indirect_commands`, `indirect_command_depth`, `indirect_commands`, `indirect_ranges`, `mesh_commands` | 23 | | `newEvent` | yes | `event_orders` | 5 | | `newSharedEvent` | yes | `event_orders`, `fence_orders`, `shared_events` | 13 | @@ -1411,6 +1415,8 @@ One row per implemented item of the SDK, in the coverage map's order. *exercised | `renderTargetArrayLength` | yes | `alpha_coverage_pairs`, `blend_interactions`, `blend_sweeps`, `blit_indirect_commands`, `buffer_target_clears`, `color_write_masks`, `compute_render_chains`, `depth_resolve_pairs`, `depth_stencil_space`, `discard_hoist`, `draw_state_changes`, `extended_range_blends`, `extended_range_gamut`, `extended_range_gradients`, `extended_range_targets`, `fetch_ordered`, `frame_chains`, `half_output_blends`, `host_page_writes`, `indirect_command_depth`, `indirect_commands`, `int_attributes`, `layered_targets`, `padded_blends`, `padded_fetch`, `pass_attachment_pairs`, `pass_bound_pairs`, `pass_sequence_actions`, `pass_start_reads`, `pass_unattached_between`, `pass_unattached_colors`, `primitive_type_crossings`, `quad_helpers`, `reconvergence`, `render_chains`, `render_depth_stencil_state`, `render_draw_forms`, `render_pass_descriptors`, `render_residency`, `render_state`, `resolve_then_load`, `rotated_planes`, `rotated_targets`, `sample_positions`, `sampler_bind_clamps`, `shader_stencil`, `snorm_tile_store`, `srgb_fetch`, `stencil_resolve_pairs`, `stencil_resolved_sample`, `tessellation_crossings`, `tessellation_rendered`, `tessellation_sweeps`, `texture_view_casts`, `topology_classes`, `vertex_attribute_strides`, `vertex_constant_step`, `vertex_fetch_reach`, `vertex_formats`, `vertex_step_rate`, `viewport_cuts`, `visibility`, `wide_int_attributes`, `wide_points` | 385 | | `renderTargetWidth` | yes | `alpha_coverage_pairs`, `blend_interactions`, `blend_sweeps`, `blit_indirect_commands`, `buffer_target_clears`, `color_write_masks`, `compute_render_chains`, `depth_resolve_pairs`, `depth_stencil_space`, `discard_hoist`, `draw_state_changes`, `extended_range_blends`, `extended_range_gamut`, `extended_range_gradients`, `extended_range_targets`, `fetch_ordered`, `frame_chains`, `half_output_blends`, `host_page_writes`, `indirect_command_depth`, `indirect_commands`, `int_attributes`, `layered_targets`, `padded_blends`, `padded_fetch`, `pass_attachment_pairs`, `pass_bound_pairs`, `pass_sequence_actions`, `pass_start_reads`, `pass_unattached_between`, `pass_unattached_colors`, `primitive_type_crossings`, `quad_helpers`, `reconvergence`, `render_chains`, `render_depth_stencil_state`, `render_draw_forms`, `render_pass_descriptors`, `render_residency`, `render_state`, `resolve_then_load`, `rotated_planes`, `rotated_targets`, `sample_positions`, `sampler_bind_clamps`, `shader_stencil`, `snorm_tile_store`, `srgb_fetch`, `stencil_resolve_pairs`, `stencil_resolved_sample`, `tessellation_crossings`, `tessellation_rendered`, `tessellation_sweeps`, `texture_view_casts`, `topology_classes`, `vertex_attribute_strides`, `vertex_constant_step`, `vertex_fetch_reach`, `vertex_formats`, `vertex_step_rate`, `viewport_cuts`, `visibility`, `wide_int_attributes`, `wide_points` | 385 | | `renderTargetHeight` | yes | `alpha_coverage_pairs`, `blend_interactions`, `blend_sweeps`, `blit_indirect_commands`, `buffer_target_clears`, `color_write_masks`, `compute_render_chains`, `depth_resolve_pairs`, `depth_stencil_space`, `discard_hoist`, `draw_state_changes`, `extended_range_blends`, `extended_range_gamut`, `extended_range_gradients`, `extended_range_targets`, `fetch_ordered`, `frame_chains`, `half_output_blends`, `host_page_writes`, `indirect_command_depth`, `indirect_commands`, `int_attributes`, `layered_targets`, `padded_blends`, `padded_fetch`, `pass_attachment_pairs`, `pass_bound_pairs`, `pass_sequence_actions`, `pass_start_reads`, `pass_unattached_between`, `pass_unattached_colors`, `primitive_type_crossings`, `quad_helpers`, `reconvergence`, `render_chains`, `render_depth_stencil_state`, `render_draw_forms`, `render_pass_descriptors`, `render_residency`, `render_state`, `resolve_then_load`, `rotated_planes`, `rotated_targets`, `sample_positions`, `sampler_bind_clamps`, `shader_stencil`, `snorm_tile_store`, `srgb_fetch`, `stencil_resolve_pairs`, `stencil_resolved_sample`, `tessellation_crossings`, `tessellation_rendered`, `tessellation_sweeps`, `texture_view_casts`, `topology_classes`, `vertex_attribute_strides`, `vertex_constant_step`, `vertex_fetch_reach`, `vertex_formats`, `vertex_step_rate`, `viewport_cuts`, `visibility`, `wide_int_attributes`, `wide_points` | 385 | +| `setSamplePositions:count:` | yes | `alpha_coverage_pairs`, `blend_interactions`, `blend_sweeps`, `blit_indirect_commands`, `buffer_target_clears`, `color_write_masks`, `compute_render_chains`, `depth_resolve_pairs`, `depth_stencil_space`, `discard_hoist`, `draw_state_changes`, `extended_range_blends`, `extended_range_gamut`, `extended_range_gradients`, `extended_range_targets`, `fetch_ordered`, `frame_chains`, `half_output_blends`, `host_page_writes`, `indirect_command_depth`, `indirect_commands`, `int_attributes`, `layered_targets`, `padded_blends`, `padded_fetch`, `pass_attachment_pairs`, `pass_bound_pairs`, `pass_sequence_actions`, `pass_start_reads`, `pass_unattached_between`, `pass_unattached_colors`, `primitive_type_crossings`, `quad_helpers`, `reconvergence`, `render_chains`, `render_depth_stencil_state`, `render_draw_forms`, `render_pass_descriptors`, `render_residency`, `render_state`, `resolve_then_load`, `rotated_planes`, `rotated_targets`, `sample_positions`, `sampler_bind_clamps`, `shader_stencil`, `snorm_tile_store`, `srgb_fetch`, `stencil_resolve_pairs`, `stencil_resolved_sample`, `tessellation_crossings`, `tessellation_rendered`, `tessellation_sweeps`, `texture_view_casts`, `topology_classes`, `vertex_attribute_strides`, `vertex_constant_step`, `vertex_fetch_reach`, `vertex_formats`, `vertex_step_rate`, `viewport_cuts`, `visibility`, `wide_int_attributes`, `wide_points` | 385 | +| `getSamplePositions:count:` | yes | `render_pass_descriptors` | 12 | | `visibilityResultType` | yes | `alpha_coverage_pairs`, `blend_interactions`, `blend_sweeps`, `blit_indirect_commands`, `buffer_target_clears`, `color_write_masks`, `compute_render_chains`, `depth_resolve_pairs`, `depth_stencil_space`, `discard_hoist`, `draw_state_changes`, `extended_range_blends`, `extended_range_gamut`, `extended_range_gradients`, `extended_range_targets`, `fetch_ordered`, `frame_chains`, `half_output_blends`, `host_page_writes`, `indirect_command_depth`, `indirect_commands`, `int_attributes`, `layered_targets`, `padded_blends`, `padded_fetch`, `pass_attachment_pairs`, `pass_bound_pairs`, `pass_sequence_actions`, `pass_start_reads`, `pass_unattached_between`, `pass_unattached_colors`, `primitive_type_crossings`, `quad_helpers`, `reconvergence`, `render_chains`, `render_depth_stencil_state`, `render_draw_forms`, `render_residency`, `render_state`, `resolve_then_load`, `rotated_planes`, `rotated_targets`, `sample_positions`, `sampler_bind_clamps`, `shader_stencil`, `snorm_tile_store`, `srgb_fetch`, `stencil_resolve_pairs`, `stencil_resolved_sample`, `tessellation_crossings`, `tessellation_rendered`, `tessellation_sweeps`, `texture_view_casts`, `topology_classes`, `vertex_attribute_strides`, `vertex_constant_step`, `vertex_fetch_reach`, `vertex_formats`, `vertex_step_rate`, `viewport_cuts`, `visibility`, `wide_int_attributes`, `wide_points` | 373 | ### `MTLRenderPassStencilAttachmentDescriptor` @@ -1983,10 +1989,8 @@ An item the suite's Metal leg calls whose coverage-map status is not implemented | `MTLRenderCommandEncoder` `setVertexBytes:length:attributeStride:atIndex:` | missing | a bind with a per-bind stride, which stage-in and vertex fetch read | `vertex_attribute_strides` | | `MTLRenderPassAttachmentDescriptor` `storeActionOptions` | missing | store action options, whose one option needs more than one sample | `alpha_coverage_pairs`, `blend_interactions`, `blend_sweeps`, `blit_indirect_commands`, `buffer_target_clears`, `color_write_masks`, `compute_render_chains`, `depth_resolve_pairs`, `depth_stencil_space`, `discard_hoist`, `draw_state_changes`, `extended_range_blends`, `extended_range_gamut`, `extended_range_gradients`, `extended_range_targets`, `fetch_ordered`, `frame_chains`, `half_output_blends`, `host_page_writes`, `indirect_command_depth`, `indirect_commands`, `int_attributes`, `layered_targets`, `padded_blends`, `padded_fetch`, `pass_attachment_pairs`, `pass_bound_pairs`, `pass_sequence_actions`, `pass_start_reads`, `pass_unattached_between`, `pass_unattached_colors`, `primitive_type_crossings`, `quad_helpers`, `reconvergence`, `render_chains`, `render_depth_stencil_state`, `render_draw_forms`, `render_pass_descriptors`, `render_residency`, `render_state`, `resolve_then_load`, `rotated_planes`, `rotated_targets`, `sample_positions`, `sampler_bind_clamps`, `shader_stencil`, `snorm_tile_store`, `srgb_fetch`, `stencil_resolve_pairs`, `stencil_resolved_sample`, `tessellation_crossings`, `tessellation_rendered`, `tessellation_sweeps`, `texture_view_casts`, `topology_classes`, `vertex_attribute_strides`, `vertex_constant_step`, `vertex_fetch_reach`, `vertex_formats`, `vertex_step_rate`, `viewport_cuts`, `visibility`, `wide_int_attributes`, `wide_points` | | `MTLRenderPassDescriptor` `defaultRasterSampleCount` | missing | a pass with no attachment, which is refused (`RenderPassKind::NoAttachment`) | `alpha_coverage_pairs`, `blend_interactions`, `blend_sweeps`, `blit_indirect_commands`, `buffer_target_clears`, `color_write_masks`, `compute_render_chains`, `depth_resolve_pairs`, `depth_stencil_space`, `discard_hoist`, `draw_state_changes`, `extended_range_blends`, `extended_range_gamut`, `extended_range_gradients`, `extended_range_targets`, `fetch_ordered`, `frame_chains`, `half_output_blends`, `host_page_writes`, `indirect_command_depth`, `indirect_commands`, `int_attributes`, `layered_targets`, `padded_blends`, `padded_fetch`, `pass_attachment_pairs`, `pass_bound_pairs`, `pass_sequence_actions`, `pass_start_reads`, `pass_unattached_between`, `pass_unattached_colors`, `primitive_type_crossings`, `quad_helpers`, `reconvergence`, `render_chains`, `render_depth_stencil_state`, `render_draw_forms`, `render_pass_descriptors`, `render_residency`, `render_state`, `resolve_then_load`, `rotated_planes`, `rotated_targets`, `sample_positions`, `sampler_bind_clamps`, `shader_stencil`, `snorm_tile_store`, `srgb_fetch`, `stencil_resolve_pairs`, `stencil_resolved_sample`, `tessellation_crossings`, `tessellation_rendered`, `tessellation_sweeps`, `texture_view_casts`, `topology_classes`, `vertex_attribute_strides`, `vertex_constant_step`, `vertex_fetch_reach`, `vertex_formats`, `vertex_step_rate`, `viewport_cuts`, `visibility`, `wide_int_attributes`, `wide_points` | -| `MTLRenderPassDescriptor` `getSamplePositions:count:` | missing | programmable sample positions | `render_pass_descriptors` | | `MTLRenderPassDescriptor` `imageblockSampleLength` | missing | a pass's imageblock memory, which tile functions use | `render_pass_descriptors` | | `MTLRenderPassDescriptor` `rasterizationRateMap` | missing | rasterization rate maps | `render_pass_descriptors` | -| `MTLRenderPassDescriptor` `setSamplePositions:count:` | missing | programmable sample positions | `alpha_coverage_pairs`, `blend_interactions`, `blend_sweeps`, `blit_indirect_commands`, `buffer_target_clears`, `color_write_masks`, `compute_render_chains`, `depth_resolve_pairs`, `depth_stencil_space`, `discard_hoist`, `draw_state_changes`, `extended_range_blends`, `extended_range_gamut`, `extended_range_gradients`, `extended_range_targets`, `fetch_ordered`, `frame_chains`, `half_output_blends`, `host_page_writes`, `indirect_command_depth`, `indirect_commands`, `int_attributes`, `layered_targets`, `padded_blends`, `padded_fetch`, `pass_attachment_pairs`, `pass_bound_pairs`, `pass_sequence_actions`, `pass_start_reads`, `pass_unattached_between`, `pass_unattached_colors`, `primitive_type_crossings`, `quad_helpers`, `reconvergence`, `render_chains`, `render_depth_stencil_state`, `render_draw_forms`, `render_pass_descriptors`, `render_residency`, `render_state`, `resolve_then_load`, `rotated_planes`, `rotated_targets`, `sample_positions`, `sampler_bind_clamps`, `shader_stencil`, `snorm_tile_store`, `srgb_fetch`, `stencil_resolve_pairs`, `stencil_resolved_sample`, `tessellation_crossings`, `tessellation_rendered`, `tessellation_sweeps`, `texture_view_casts`, `topology_classes`, `vertex_attribute_strides`, `vertex_constant_step`, `vertex_fetch_reach`, `vertex_formats`, `vertex_step_rate`, `viewport_cuts`, `visibility`, `wide_int_attributes`, `wide_points` | | `MTLRenderPassDescriptor` `threadgroupMemoryLength` | missing | a pass's threadgroup memory, which tile functions use | `render_pass_descriptors` | | `MTLRenderPassDescriptor` `tileHeight` | missing | tile render pipelines; metal2vulkan-runtime makes none | `render_pass_descriptors`, `tile_threadgroups` | | `MTLRenderPassDescriptor` `tileWidth` | missing | tile render pipelines; metal2vulkan-runtime makes none | `render_pass_descriptors`, `tile_threadgroups` | diff --git a/docs/METAL-COVERAGE.md b/docs/METAL-COVERAGE.md index 930de230f..c72339d7e 100644 --- a/docs/METAL-COVERAGE.md +++ b/docs/METAL-COVERAGE.md @@ -10,12 +10,12 @@ Every public item of the macOS 27.2 SDK (Xcode 27.2, 27B52)'s Metal headers, by | Status | Items | Of which deprecated | |---|---|---| -| implemented | 639 | 29 | -| missing | 1072 | 34 | +| implemented | 643 | 29 | +| missing | 1068 | 34 | | out of scope | 424 | 5 | | all | 2135 | 68 | -Implemented by the runtime: 282; by the translator's values: 357. Missing by size: S 181, M 202, L 313, XL 376. +Implemented by the runtime: 286; by the translator's values: 357. Missing by size: S 179, M 200, L 313, XL 376. ## Missing, in build order @@ -28,11 +28,11 @@ 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 | 70 | `MTLAllocation.allocatedSize`, `MTLBuffer.sparseBufferTier`, `MTLCommandBuffer.device`, ... | -| plain-value constructors (`MTLOriginMake` and the rest) | S | 7 | `MTLOriginMake`, `MTLSizeMake`, `MTLRegionMake1D`, ... | +| device, state and resource queries | S | 69 | `MTLAllocation.allocatedSize`, `MTLBuffer.sparseBufferTier`, `MTLCommandBuffer.device`, ... | +| plain-value constructors (`MTLOriginMake` and the rest) | S | 6 | `MTLOriginMake`, `MTLSizeMake`, `MTLRegionMake1D`, ... | | a buffer made with bytes | S | 1 | `MTLDevice.newBufferWithBytes:length:options:` | | pipeline creation forms (from a function, with a completion handler) | S | 6 | `MTLDevice.newRenderPipelineStateWithDescriptor:options:completionHandler:`, `MTLDevice.newComputePipelineStateWithFunction:error:`, `MTLDevice.newComputePipelineStateWithFunction:options:reflection:error:`, ... | -| render pass descriptor fields | S/M/L | 7 | `MTLRenderPassAttachmentDescriptor.storeActionOptions`, `MTLRenderPassDescriptor.imageblockSampleLength`, `MTLRenderPassDescriptor.threadgroupMemoryLength`, ... | +| render pass descriptor fields | S/M/L | 5 | `MTLRenderPassAttachmentDescriptor.storeActionOptions`, `MTLRenderPassDescriptor.imageblockSampleLength`, `MTLRenderPassDescriptor.threadgroupMemoryLength`, ... | | encoder calls (stride setters, indirect draws, store action options, a render encoder's heap uses) | S/M/L | 23 | `MTLBlitCommandEncoder.synchronizeTexture:slice:level:`, `MTLBlitCommandEncoder.copyFromTexture:sourceSlice:sourceLevel:toTexture:destinationSlice:destinationLevel:sliceCount:levelCount:`, `MTLBlitCommandEncoder.copyFromTexture:toTexture:`, ... | | `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` | @@ -1454,7 +1454,7 @@ Cheap items a plain app calls first, then medium pieces by how often a plain app | `MTLDevice.newRenderPipelineStateWithMeshDescriptor:options:completionHandler:` | method | missing | L: mesh render pipelines; metal2vulkan-runtime makes none | | `MTLDevice.maxThreadgroupMemoryLength` | property | implemented | `Device::max_threadgroup_memory_length` (runtime) | | `MTLDevice.maxArgumentBufferSamplerCount` | property | missing | S: a query or call metal2vulkan-runtime does not answer | -| `MTLDevice.programmableSamplePositionsSupported` | property | missing | S: a query or call metal2vulkan-runtime does not answer | +| `MTLDevice.programmableSamplePositionsSupported` | property | implemented | `Device::programmable_sample_positions_supported` (runtime) | | `MTLDevice.getDefaultSamplePositions:count:` | method | missing | S: the standard positions a pass without `sample_positions` rasterizes at | | `MTLDevice.newArgumentEncoderWithArguments:` | method | missing | M: argument encoders | | `MTLDevice.supportsRasterizationRateMapWithLayerCount:` | method | missing | L: rasterization rate maps; the render pass descriptor has no field for one | @@ -2187,8 +2187,8 @@ Cheap items a plain app calls first, then medium pieces by how often a plain app | `MTLRenderPassDescriptor.defaultRasterSampleCount` | property | missing | M: a pass with no attachment, which is refused (`RenderPassKind::NoAttachment`) | | `MTLRenderPassDescriptor.renderTargetWidth` | property | implemented | `RenderPassDescriptor.render_target_width` (runtime) | | `MTLRenderPassDescriptor.renderTargetHeight` | property | implemented | `RenderPassDescriptor.render_target_height` (runtime) | -| `MTLRenderPassDescriptor.setSamplePositions:count:` | method | missing | M: programmable sample positions | -| `MTLRenderPassDescriptor.getSamplePositions:count:` | method | missing | M: programmable sample positions | +| `MTLRenderPassDescriptor.setSamplePositions:count:` | method | implemented | `RenderPassDescriptor.sample_positions` (runtime) | +| `MTLRenderPassDescriptor.getSamplePositions:count:` | method | implemented | `RenderPassDescriptor.sample_positions` (runtime) | | `MTLRenderPassDescriptor.rasterizationRateMap` | property | missing | L: rasterization rate maps | | `MTLRenderPassDescriptor.sampleBufferAttachments` | property | missing | M: counter sample buffers | | `MTLRenderPassDescriptor.visibilityResultType` | property | implemented | `RenderPassDescriptor.visibility_result_type` (runtime) | @@ -2627,7 +2627,7 @@ Cheap items a plain app calls first, then medium pieces by how often a plain app | `MTLRegionMake1D` | function | missing | S: a plain value's constructor | | `MTLRegionMake2D` | function | missing | S: a plain value's constructor | | `MTLRegionMake3D` | function | missing | S: a plain value's constructor | -| `MTLSamplePositionMake` | function | missing | S: a plain value's constructor | +| `MTLSamplePositionMake` | function | implemented | `SamplePosition::new` (runtime) | | `MTLCoordinate2DMake` | function | missing | S: a plain value's constructor | ### MTLVertexDescriptor.h diff --git a/docs/REFUSALS.md b/docs/REFUSALS.md index 4b47a3238..4188ace62 100644 --- a/docs/REFUSALS.md +++ b/docs/REFUSALS.md @@ -31,7 +31,7 @@ Columns: | Rate maps the compile layer does not compile | 5 | 5 | 0 | 0 | 4 | 1 | 0 | | The translation deadline | 1 | 1 | 0 | 0 | 0 | 1 | 0 | | Devices below the runtime's floor | 8 | 8 | 0 | 0 | 0 | 0 | 0 | -| The runtime's `Refusal` | 86 | 86 | 0 | 0 | 0 | 0 | 0 | +| The runtime's `Refusal` | 87 | 87 | 0 | 0 | 0 | 0 | 0 | | The runtime's `Limit` | 21 | 21 | 0 | 0 | 0 | 0 | 0 | | The runtime's `Gap` | 31 | 31 | 0 | 0 | 0 | 0 | 0 | @@ -44,7 +44,7 @@ Columns: | Rate maps the compile layer does not compile | 0 | 0 | 0 | 0 | 5 | 0 | 0 | 0 | | The translation deadline | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | | Devices below the runtime's floor | 0 | 0 | 0 | 8 | 0 | 0 | 0 | 0 | -| The runtime's `Refusal` | 23 | 25 | 0 | 0 | 38 | 0 | 0 | 0 | +| The runtime's `Refusal` | 23 | 26 | 0 | 0 | 38 | 0 | 0 | 0 | | The runtime's `Limit` | 0 | 0 | 0 | 15 | 6 | 0 | 0 | 0 | | The runtime's `Gap` | 0 | 0 | 0 | 2 | 29 | 0 | 0 | 0 | @@ -304,6 +304,7 @@ Columns: | `AttachmentPlace` | A render pass attachment or resolve texture of a level or slice past its texture's | every device (a public call's own check of its arguments) | `ours`: no texel of the texture is there to render into | 4: `crates/metal2vulkan-runtime/src/texture.rs (attachment_view, 3 sites)`, `crates/metal2vulkan-runtime/src/texture.rs (resolve_attachment)` | `-` | | `AttachmentFormat` | A render pass color attachment of a depth or stencil pixel format, a depth attachment of a format without depth, or a stencil attachment of a... | every device (a public call's own check of its arguments) | `metal-documented`: a color attachment takes a color-renderable format, a depth attachment a format with depth and a stencil attachment a format with stencil; Metal's validation stops the descriptor | 3: `crates/metal2vulkan-runtime/src/pass.rs (check, 3 sites)` | `-` | | `NoAttachmentPass` | A render pass with no attachment whose `renderTargetWidth` or `renderTargetHeight` is 0, or whose `defaultRasterSampleCount` is 0, Metal's default | every device (a public call's own check of its arguments) | `metal-measured`: an Apple M3 Max, macOS 27.0.1, the API validation layer off, m3-max-62174, `probes/no_attachment_passes.m`: a side of 0 makes no encoder, nil, and a count of 0 ends the process at the encoder, SIGABRT, where 64 by 64 pixels at 1 sample makes one | 1: `crates/metal2vulkan-runtime/src/pass.rs (check)` | `-` | +| `SamplePositions` | A render pass's sample positions (`setSamplePositions:count:`) other than the device's own | every device (a public call's own check of its arguments) | `metal-documented`: `MTLRenderPass.h`: the positions are "to be used in MSAA rendering (i.e. when sample count > 1)" and the count "must be a valid sample count"; `MTLTypes.h`: a position's range is "[0,1) for both x and y"; `MTLDevice.h`'s `programmableSamplePositionsSupported`; Metal's validation stops a pass of more positions than samples, a coordinate outside the pixel and positions in a pass of one sample, and one position past the samples ends plain Metal's process on an Apple M4, the conformance suite's `sample_positions` module | 1: `crates/metal2vulkan-runtime/src/positions.rs (locations)` | `-` | | `VertexBufferOffset` | A draw whose vertex descriptor reads a vertex buffer at an offset at or past the buffer's length | every device (a public call's own check of its arguments) | `metal-documented`: a buffer's offset lies inside it; Metal's validation stops the bind | 1: `crates/metal2vulkan-runtime/src/render_encoder.rs (vertex_range)` | `-` | | `IndexBufferOffset` | An indexed draw whose index buffer offset is not a multiple of the index size, or whose indices leave the buffer | every device (a public call's own check of its arguments) | `metal-documented`: the offset is a multiple of the index size and the indices lie in the buffer; Metal's validation stops the draw | 1: `crates/metal2vulkan-runtime/src/render_encoder.rs (draw)` | `-` | | `TessellationFactorOffset` | A tessellation factor buffer whose factors, at its address plus the offset, start at an odd byte | every device (a public call's own check of its arguments) | `metal-documented`: `setTessellationFactorBuffer:offset:instanceStride:`'s offset is a multiple of 4; Metal's validation stops a patch draw with any other | 1: `crates/metal2vulkan-runtime/src/render_encoder.rs (set_tessellation_factor_buffer)` | `-` | @@ -372,8 +373,8 @@ Columns: | `StorageElement` | A draw or dispatch whose function writes a texture slot, or reads one through its storage image (`access::read_write`), bound to a texture made... | every device (a public call's own check of its arguments) | `ours`: the storage element through a view of the nearest format whose storage Vulkan requires of every device, with the translator's conversion, is the form to build | 4: `crates/metal2vulkan-runtime/src/encoder.rs (dispatch, 2 sites)`, `crates/metal2vulkan-runtime/src/render_encoder.rs (find, 2 sites)` | `-` | | `BicubicTexels` | A dispatch or a draw whose function samples texture slot `slot` through a constexpr sampler with Metal's bicubic filter (`filter::bicubic`), where... | every device (a public call's own check of its arguments) | `ours`: each refused format's treatment is built when a guest binds one | 2: `crates/metal2vulkan-runtime/src/encoder.rs (dispatch)`, `crates/metal2vulkan-runtime/src/render_encoder.rs (find)` | `-` | | `TextureView` | `Texture::new_texture_view` of a kind Metal makes and the runtime does not build | every device (a public call's own check of its arguments) | `ours`: the replay streams' views that compute binds are same-format views of every slice, 2D views of one slice of a 2D array, and level subranges, swizzled or not; each other kind is built when a replay stream binds one | 1: `crates/metal2vulkan-runtime/src/texture.rs (view)` | `-` | -| `RenderPass` | A render pass of something the runtime does not build yet (`CommandBuffer::render_command_encoder`) | every device (a public call's own check of its arguments) | `ours`: the replay streams' passes render into one to two color attachments and a stencil or a depth attachment, each a level of a 2D texture of one sample, with no resolve and a clear depth of 1, none naming two textures for its depth and stencil; each other kind is built when a replay stream makes one; `DepthStencilViews` and `ClearDepth` are what Vulkan's rendering under the floor takes no form of | 7: `crates/metal2vulkan-runtime/src/pass.rs (check)`, `crates/metal2vulkan-runtime/src/pass.rs (ops)` (+5) | `-` | -| `Draw` | A draw or render encoder state the runtime does not build yet (`RenderCommandEncoder`) | every device (a public call's own check of its arguments) | `ours`: the replay streams draw lines and triangles through one viewport Vulkan's is, with pipeline states of their pass's formats, filled and clipped; each other kind is built when a replay stream draws one), and device for [`DrawKind::DividedBaseInstance`] (a device that does not report `supportsNonZeroFirstInstance` | 15: `crates/metal2vulkan-runtime/src/render.rs (for_pass)`, `crates/metal2vulkan-runtime/src/render_encoder.rs (attachment_reads, 4 sites)` (+10) | `-` | +| `RenderPass` | A render pass of something the runtime does not build yet (`CommandBuffer::render_command_encoder`) | every device (a public call's own check of its arguments) | `ours`: the replay streams' passes render into one to two color attachments and a stencil or a depth attachment, each a level of a 2D texture of one sample, with no resolve and a clear depth of 1, none naming two textures for its depth and stencil; each other kind is built when a replay stream makes one; `DepthStencilViews` and `ClearDepth` are what Vulkan's rendering under the floor takes no form of | 8: `crates/metal2vulkan-runtime/src/pass.rs (check)`, `crates/metal2vulkan-runtime/src/pass.rs (ops)` (+6) | `-` | +| `Draw` | A draw or render encoder state the runtime does not build yet (`RenderCommandEncoder`) | every device (a public call's own check of its arguments) | `ours`: the replay streams draw lines and triangles through one viewport Vulkan's is, with pipeline states of their pass's formats, filled and clipped; each other kind is built when a replay stream draws one), and device for [`DrawKind::DividedBaseInstance`] (a device that does not report `supportsNonZeroFirstInstance` | 16: `crates/metal2vulkan-runtime/src/render.rs (for_pass)`, `crates/metal2vulkan-runtime/src/render.rs (pipeline)` (+11) | `-` | | `StageSize` | A pipeline the device does not make for its heaviest stage's weight, for what `cause` names | at the device's limit | `device`: on the Iris Xe of RPL-P, ANV, Mesa 26.2.6, the consumer's helper compiles of entry weights 186,065 to 424,132 passed its 3 GiB cap, job m3-max-65807; a driver whose helper's compile met its cap or time, or that keeps no pipeline cache data, gives no data to make the pipeline from | 3: `crates/metal2vulkan-runtime/src/pipeline.rs (past_stage_bound)`, `crates/metal2vulkan-runtime/src/render.rs (of)` (+1) | `-` | ## Appendix: every site @@ -602,6 +603,7 @@ Each refusal's sites, with the function that builds it. - `rt:Refusal::AttachmentPlace`: `crates/metal2vulkan-runtime/src/texture.rs (attachment_view, 3 sites)`; `crates/metal2vulkan-runtime/src/texture.rs (resolve_attachment)` - `rt:Refusal::AttachmentFormat`: `crates/metal2vulkan-runtime/src/pass.rs (check, 3 sites)` - `rt:Refusal::NoAttachmentPass`: `crates/metal2vulkan-runtime/src/pass.rs (check)` +- `rt:Refusal::SamplePositions`: `crates/metal2vulkan-runtime/src/positions.rs (locations)` - `rt:Refusal::VertexBufferOffset`: `crates/metal2vulkan-runtime/src/render_encoder.rs (vertex_range)` - `rt:Refusal::IndexBufferOffset`: `crates/metal2vulkan-runtime/src/render_encoder.rs (draw)` - `rt:Refusal::TessellationFactorOffset`: `crates/metal2vulkan-runtime/src/render_encoder.rs (set_tessellation_factor_buffer)` @@ -660,7 +662,7 @@ Each refusal's sites, with the function that builds it. - `rt:Gap::StorageElement`: `crates/metal2vulkan-runtime/src/encoder.rs (dispatch, 2 sites)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (find, 2 sites)` - `rt:Gap::BicubicTexels`: `crates/metal2vulkan-runtime/src/encoder.rs (dispatch)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (find)` - `rt:Gap::TextureView`: `crates/metal2vulkan-runtime/src/texture.rs (view)` -- `rt:Gap::RenderPass`: `crates/metal2vulkan-runtime/src/pass.rs (check)`; `crates/metal2vulkan-runtime/src/pass.rs (ops)`; `crates/metal2vulkan-runtime/src/pass.rs (resolve)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (later_store)`; `crates/metal2vulkan-runtime/src/texture.rs (attachment_view)`; `crates/metal2vulkan-runtime/src/texture.rs (resolve_attachment)`; `crates/metal2vulkan-runtime/src/texture.rs (stand_in)` -- `rt:Gap::Draw`: `crates/metal2vulkan-runtime/src/render.rs (for_pass)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (attachment_reads, 4 sites)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (checked)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (draw)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (draw_patches)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (draw_patches_indirect)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (interrupt_refused)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_scissor_rects)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_triangle_fill_mode)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_viewports)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_visibility_result_mode)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (shadow_copies)` +- `rt:Gap::RenderPass`: `crates/metal2vulkan-runtime/src/pass.rs (check)`; `crates/metal2vulkan-runtime/src/pass.rs (ops)`; `crates/metal2vulkan-runtime/src/pass.rs (resolve)`; `crates/metal2vulkan-runtime/src/positions.rs (locations)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (later_store)`; `crates/metal2vulkan-runtime/src/texture.rs (attachment_view)`; `crates/metal2vulkan-runtime/src/texture.rs (resolve_attachment)`; `crates/metal2vulkan-runtime/src/texture.rs (stand_in)` +- `rt:Gap::Draw`: `crates/metal2vulkan-runtime/src/render.rs (for_pass)`; `crates/metal2vulkan-runtime/src/render.rs (pipeline)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (attachment_reads, 4 sites)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (checked)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (draw)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (draw_patches)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (draw_patches_indirect)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (interrupt_refused)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_scissor_rects)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_triangle_fill_mode)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_viewports)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (set_visibility_result_mode)`; `crates/metal2vulkan-runtime/src/render_encoder.rs (shadow_copies)` - `rt:Gap::StageSize`: `crates/metal2vulkan-runtime/src/pipeline.rs (past_stage_bound)`; `crates/metal2vulkan-runtime/src/render.rs (of)`; `crates/metal2vulkan-runtime/src/stage.rs (gap)` diff --git a/docs/REPLAY-STREAM.md b/docs/REPLAY-STREAM.md index 648458136..1dc7ad2a6 100644 --- a/docs/REPLAY-STREAM.md +++ b/docs/REPLAY-STREAM.md @@ -790,14 +790,11 @@ contract (below) where the surface is made, and each check matches where the sta Visibility results play as the runtime's: a pass's `visibilityResultBuffer` and `visibilityResultType`, and each `setVisibilityResultMode:offset:` (`[mode, offset]`), whose counts the runtime writes into the buffer at the pass's end. - `setSamplePositions:count:` plays as the runtime treats it, with no refusal: the runtime's - descriptor has no field for it, and every multisample pass rasterizes at Vulkan's standard - sample locations, which are Metal's default positions at 1, 2 and 4 samples. The report's - `passes at sample positions other than Metal's defaults N` line counts the render encoders the - runtime made of a pass whose positions differ from Metal's defaults for the pass's sample count - (its attachments'), each coordinate compared as an `f32`, with the first one's frame and call. A - set at a sample count whose Metal defaults the player does not hold (any but 1, 2 and 4) - counts as differing. + `setSamplePositions:count:` sets the runtime's descriptor's `sample_positions`: the pass + rasterizes at them on a device that answers `programmableSamplePositionsSupported` yes. A set + the runtime refuses, as Metal's validation does or on a device that answers no, ends the play + with that refusal at the render encoder; a pass at custom positions the runtime does not build + (beside a depth attachment) is a skipped encoder, counted by its gap. What the runtime does not build yet it skips and counts, and never fakes: - objects: libraries from source, and whatever a call makes of a skipped object (`skipped_objects`). A call that makes an object on a skipped receiver or naming a skipped diff --git a/scripts/metal-coverage/coverage.tsv b/scripts/metal-coverage/coverage.tsv index cde6a26e5..2000ec992 100644 --- a/scripts/metal-coverage/coverage.tsv +++ b/scripts/metal-coverage/coverage.tsv @@ -1118,7 +1118,7 @@ MTLDevice.h MTLDevice method newRenderPipelineStateWithMeshDescriptor:options:re MTLDevice.h MTLDevice method newRenderPipelineStateWithMeshDescriptor:options:completionHandler: M mesh render pipelines; metal2vulkan-runtime makes none L mesh MTLDevice.h MTLDevice property maxThreadgroupMemoryLength I runtime Device::max_threadgroup_memory_length MTLDevice.h MTLDevice property maxArgumentBufferSamplerCount M a query or call metal2vulkan-runtime does not answer S queries -MTLDevice.h MTLDevice property programmableSamplePositionsSupported M a query or call metal2vulkan-runtime does not answer S queries +MTLDevice.h MTLDevice property programmableSamplePositionsSupported I runtime Device::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: M argument encoders M argument-encoders MTLDevice.h MTLDevice method supportsRasterizationRateMapWithLayerCount: M rasterization rate maps; the render pass descriptor has no field for one L rasterization @@ -1726,8 +1726,8 @@ MTLRenderPass.h MTLRenderPassDescriptor property tileHeight M tile render pip MTLRenderPass.h MTLRenderPassDescriptor property defaultRasterSampleCount M a pass with no attachment, which is refused (`RenderPassKind::NoAttachment`) M render-pass MTLRenderPass.h MTLRenderPassDescriptor property renderTargetWidth I runtime RenderPassDescriptor.render_target_width MTLRenderPass.h MTLRenderPassDescriptor property renderTargetHeight I runtime RenderPassDescriptor.render_target_height -MTLRenderPass.h MTLRenderPassDescriptor method setSamplePositions:count: M programmable sample positions M render-pass -MTLRenderPass.h MTLRenderPassDescriptor method getSamplePositions:count: M programmable sample positions M render-pass +MTLRenderPass.h MTLRenderPassDescriptor method setSamplePositions:count: I runtime RenderPassDescriptor.sample_positions +MTLRenderPass.h MTLRenderPassDescriptor method getSamplePositions:count: I runtime RenderPassDescriptor.sample_positions MTLRenderPass.h MTLRenderPassDescriptor property rasterizationRateMap M rasterization rate maps L render-pass MTLRenderPass.h MTLRenderPassDescriptor property sampleBufferAttachments M counter sample buffers M counters MTLRenderPass.h MTLRenderPassDescriptor property visibilityResultType I runtime RenderPassDescriptor.visibility_result_type @@ -2106,7 +2106,7 @@ MTLTypes.h function MTLSizeMake M a plain value's constructor S values MTLTypes.h function MTLRegionMake1D M a plain value's constructor S values MTLTypes.h function MTLRegionMake2D M a plain value's constructor S values MTLTypes.h function MTLRegionMake3D M a plain value's constructor S values -MTLTypes.h function MTLSamplePositionMake M a plain value's constructor S values +MTLTypes.h function MTLSamplePositionMake I runtime SamplePosition::new MTLTypes.h function MTLCoordinate2DMake M a plain value's constructor S values MTLVertexDescriptor.h MTLVertexBufferLayoutDescriptor class MTLVertexBufferLayoutDescriptor I translator VertexBufferLayoutDescriptor MTLVertexDescriptor.h MTLVertexBufferLayoutDescriptor property stride I translator VertexBufferLayoutDescriptor.stride