conformance: eight case modules state their facts without lane history
fresh_contents, half_output_blends, compressed_moves, extended_swizzles,
chroma_pairs, half_texel_nans, compressed_views and visibility said
where each rule, table and seed came from: the deleted runtime's test
lanes ("the lane's order", "the cross-check the port owes the lane",
"Not ported, and why"). Each now states the fact alone: what the case
asks, the chip and macOS a measurement was taken on (an Apple M3 Max
under macOS 27.0.1, an Apple M4 for the byte models' digests and the
visibility table), and what the cross-check holds the recordings to.
"Not ported" sections are "Not a case" and keep their reasons.
fresh_contents' venue paragraph also named DeviceProperties::
lossless_compression and an RTX 5080 presenting compression; it now says
the runtime presents a Mac keeping none (Venue::lossless_compression
false) and that a texture it places reads zero until written, so the
Private rows' fresh site is the declared one there. chroma_pairs no
longer says the runtime answers Error::Invalid, an error it does not
have.
Four test functions named for the lane are renamed: metals_texels_are_
the_rules_expectation, every_recorded_move_is_the_byte_model,
every_recorded_view_move_is_the_byte_model and the_recorded_results_are_
the_tables_words. A lane that means a GPU thread or a vector channel is
unchanged. Comments, docs and test panic messages only; no string a
recording stores.
This commit is contained in:
1 parent
8d85d4d4ca
commit
218c2c2e4e
8 files changed
+269
-308
No files matched your search
@@ -13,14 +13,13 @@
|
||||
//! Metal's `read()` of these formats is a defined operation, not a guess, and the model's rule
|
||||
//! stands on a real measurement.
|
||||
//!
|
||||
//! What that probe does not leave behind is a re-runnable artifact: it was thrown away, it covered
|
||||
//! 64 texels rather than the lane's own 256, and nothing mechanical ties the lane's expectation to
|
||||
//! it. These cases take Metal's answer over the lane's own pattern and commit it, so a new macOS
|
||||
//! is one `conformance record` from saying whether Apple changed it.
|
||||
//! That probe covered 64 texels and is not re-runnable. These cases take Metal's answer over 256
|
||||
//! texels of a fixed pattern and commit it, so a new macOS is one `conformance record` from saying
|
||||
//! whether Apple changed it.
|
||||
//!
|
||||
//! # The three families
|
||||
//!
|
||||
//! [`ChromaCopies`] is the lane's copy sweep as one declarative program ([`crate::work`]): a whole blit
|
||||
//! [`ChromaCopies`] is a copy sweep as one declarative program ([`crate::work`]): a whole blit
|
||||
//! in and out, the host's whole `replaceRegion:`/`getBytes:`, seven blits in of regions whose x
|
||||
//! and width fall off the 2-texel pairs at buffer offsets and pitches of 34 and 30 bytes, six
|
||||
//! blits out of such regions, four host copies in and four host reads out, three copies between
|
||||
@@ -29,8 +28,8 @@
|
||||
//! that names the row and the texel, so a diff says which texel of which sub-case moved. Every
|
||||
//! byte compares exactly; the case's allowances are on the notices site alone.
|
||||
//!
|
||||
//! [`ChromaTexels`] is the lane's texel table, over a 16 x 16 texture of the format holding the
|
||||
//! lane's pattern, reached two ways through the owned fixture `fpv_swizzled_reads`:
|
||||
//! [`ChromaTexels`] is a texel table, over a 16 x 16 texture of the format holding the case's
|
||||
//! pattern, reached two ways through the owned fixture `fpv_swizzled_reads`:
|
||||
//! `read()` at the 256 integer texel positions, and `sample()` at the 256 texel centres through a
|
||||
//! nearest clamp-to-edge sampler. Both answer 256 `float4`s, recorded whole. The two are separate
|
||||
//! cases because Metal defines them differently: a chroma-pair format is **filterable**, so
|
||||
@@ -42,11 +41,11 @@
|
||||
//! # Why nothing here can fault a GPU
|
||||
//!
|
||||
//! Every program is a handful of 16 x 16 textures, blits of regions inside them, and one compute
|
||||
//! dispatch of 256 threads, with at most one sampler state. The two descriptors the lane finds
|
||||
//! Metal's **validation** aborts plain too — a mipmapped 4:2:2 texture, and a view of one in another format — are left out by
|
||||
//! construction: the runtime spells that outcome `Error::Invalid`, "Metal's validation stops it,
|
||||
//! ending the process", and the suite's standing rule is that no case may end Metal's process. So
|
||||
//! is the render-target half of the lane, whose pipeline Metal's validation aborts plain too.
|
||||
//! dispatch of 256 threads, with at most one sampler state. Two descriptors whose call Metal's
|
||||
//! **validation** aborts plain too, a mipmapped 4:2:2 texture and a view of one in another format,
|
||||
//! are left out by construction, as the suite's standing rule is that no case may end Metal's
|
||||
//! process. So is a render target of these formats, whose pipeline Metal's validation aborts plain
|
||||
//! too.
|
||||
|
||||
use crate::case::{
|
||||
made, Abort, Bindings, Case, Failure, Input, MetalSource, SamplerSpec, Side, TextureRole,
|
||||
@@ -58,7 +57,7 @@ use crate::transcript::{ByteLayout, Digest, Element, Gaps, Node, Observed, Regio
|
||||
use crate::work::{Plane, Rect, Resource, Step, TextureSpec as WorkTexture, Work};
|
||||
use metal2vulkan::metal::{PixelFormat, SamplerAddressMode, SamplerMinMagFilter};
|
||||
|
||||
/// The textures' side, as the lane makes them.
|
||||
/// The textures' side.
|
||||
const SIDE: u64 = 16;
|
||||
|
||||
/// Bytes a row of a [`SIDE`]-wide 4:2:2 texture takes: two a texel.
|
||||
@@ -82,12 +81,12 @@ const GROUP: u32 = 64;
|
||||
/// The byte the read-back buffer holds before the dispatch.
|
||||
const BLANK: u8 = 0xab;
|
||||
|
||||
/// `n` bytes from `base`, byte `i` of them `base + i` (wrapping): the lane's `seq`.
|
||||
/// `n` bytes from `base`, byte `i` of them `base + i` (wrapping).
|
||||
fn seq(n: u64, base: u8) -> Vec<u8> {
|
||||
(0..n).map(|i| base.wrapping_add(i as u8)).collect()
|
||||
}
|
||||
|
||||
/// The 512 bytes the lane fills a whole texture with.
|
||||
/// The 512 bytes the case fills a whole texture with.
|
||||
fn pattern() -> Vec<u8> {
|
||||
seq(WHOLE, 0)
|
||||
}
|
||||
@@ -145,8 +144,8 @@ pub fn all() -> Vec<Box<dyn Case>> {
|
||||
///
|
||||
/// Both exist because Metal defines them differently. A chroma-pair texture is a **filterable**
|
||||
/// format: `sample` is the operation Metal's own feature tables grant it, and a nearest sample at
|
||||
/// a texel's centre is defined to be that texel. `read()` is what the runtime lane uses and what a
|
||||
/// decoder does, and whether Metal defines it for these formats is exactly the question a
|
||||
/// a texel's centre is defined to be that texel. `read()` is what a decoder does, and whether
|
||||
/// Metal defines it for these formats is exactly the question a
|
||||
/// recording answers rather than assumes — so the two are separate cases, and the sampling one is
|
||||
/// the control.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
@@ -209,7 +208,7 @@ impl Access {
|
||||
}
|
||||
}
|
||||
|
||||
/// One blit of a region of a buffer into a texture, as the lane sweeps them: the texel the region
|
||||
/// One blit of a region of a buffer into a texture, as the case sweeps them: the texel the region
|
||||
/// starts at, its texels and rows, the buffer offset the bytes come from, and the row pitch.
|
||||
const BLITS_IN: [(u64, u64, u64, u64, u64); 7] = [
|
||||
(1, 2, 1, 0, ROW),
|
||||
@@ -271,7 +270,7 @@ impl ChromaCopies {
|
||||
/// The program the case runs, and the name of each read it asks for, in order.
|
||||
///
|
||||
/// The two are built together because a read's meaning is its place in the program: naming
|
||||
/// them apart is how a port drifts into comparing the wrong row.
|
||||
/// them apart is how a case drifts into comparing the wrong row.
|
||||
fn program(&self) -> (Work, Vec<ReadSite>) {
|
||||
let mut work = Work::new();
|
||||
let mut reads = Vec::new();
|
||||
@@ -305,7 +304,7 @@ impl ChromaCopies {
|
||||
reads.push(self.get_bytes(&mut work, "host-whole", shared, whole, ROW, WHOLE as usize));
|
||||
|
||||
// Blits in of regions off the texel pairs, at buffer offsets and row pitches of their
|
||||
// own. Each gets a texture of its own, as the lane makes one, so the bytes outside the
|
||||
// own. Each gets a texture of its own, so the bytes outside the
|
||||
// region are the ones the fill left.
|
||||
for (x, texels, rows, offset, pitch) in BLITS_IN {
|
||||
let target = work.add(self.texture(true));
|
||||
@@ -470,7 +469,7 @@ impl ChromaCopies {
|
||||
slice: 0,
|
||||
region,
|
||||
bytes_per_row: pitch,
|
||||
// Metal's host calls take 0 for a 2D texture's image pitch, which is what the lane
|
||||
// Metal's host calls take 0 for a 2D texture's image pitch, which is what the case
|
||||
// passes; a 2D region has one image, so there is nothing for it to say.
|
||||
bytes_per_image: 0,
|
||||
length,
|
||||
@@ -510,7 +509,7 @@ fn replace(texture: usize, region: Rect, bytes: Vec<u8>, pitch: u64) -> Step {
|
||||
// An uncompressed format's rows are its texel rows.
|
||||
rows: region.size[1],
|
||||
bytes_per_row: pitch,
|
||||
// 0, as Metal's host call takes for a 2D texture and as the lane passes.
|
||||
// 0, as Metal's host call takes for a 2D texture.
|
||||
bytes_per_image: 0,
|
||||
}
|
||||
}
|
||||
@@ -746,7 +745,7 @@ impl Case for ChromaTexels {
|
||||
self.format,
|
||||
[SIDE as u32, SIDE as u32],
|
||||
ROW as u32,
|
||||
// Shader-read usage alone, as the lane's read test makes it: these formats are
|
||||
// Shader-read usage alone: these formats are
|
||||
// sampled and read, and asking for write usage as well would be asking a
|
||||
// different question of Metal.
|
||||
TextureRole::Read,
|
||||
@@ -819,7 +818,7 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// The copy program asks for one read a sub-case of the lane's tables, and every read the
|
||||
/// The copy program asks for one read a sub-case of the tables, and every read the
|
||||
/// program asks for has a site: a read with no name would compare against the wrong row.
|
||||
#[test]
|
||||
fn every_read_of_the_copy_program_has_a_site() {
|
||||
@@ -831,7 +830,7 @@ mod tests {
|
||||
};
|
||||
let (work, reads) = case.program();
|
||||
assert_eq!(work.reads(), reads.len(), "{word}");
|
||||
// The lane's rows: two whole copies, seven blits in, six out, four host puts, four
|
||||
// The rows: two whole copies, seven blits in, six out, four host puts, four
|
||||
// host gets, three texture copies and four copies into another format.
|
||||
assert_eq!(reads.len(), 2 + 7 + 6 + 4 + 4 + 3 + 4);
|
||||
let names: BTreeSet<&str> = reads.iter().map(|read| read.name.as_str()).collect();
|
||||
|
||||
@@ -18,30 +18,24 @@
|
||||
//! - `t2t`: the first texture copied whole into a third, then a block-aligned region of the second
|
||||
//! copied over part of it, then the third blitted out tight.
|
||||
//!
|
||||
//! **What the port changes, and why it is the point.** The lane compares our bytes with a byte
|
||||
//! model written in Rust ([`Model`]), and ties that model to Metal by a **single SHA-256 of a line
|
||||
//! transcript** — 350 lines of `"<format> <shape> <step>: <n> bytes, sha <six bytes>"`, measured by
|
||||
//! our own probe on an Apple **M4**. So the lane could say that our bytes and the model disagree,
|
||||
//! never which of the two had moved, and its one Metal fact was a six-byte digest per step from a
|
||||
//! machine we no longer have. Here record mode runs the same steps on **this M3 Max** and each
|
||||
//! recording holds Metal's own bytes, padding included, per level and per slice. The model stays as
|
||||
//! a cross-check (the test `every_recorded_move_is_the_lanes_byte_model`), which is the one direction in
|
||||
//! which a difference says something: either Apple's copies moved between the chips or the releases,
|
||||
//! or the model was never Metal's.
|
||||
//! **Metal's own bytes.** Record mode runs the steps on an Apple **M3 Max** and each recording
|
||||
//! holds Metal's bytes, padding included, per level and per slice. A byte model written in Rust
|
||||
//! ([`Model`]) stays as a cross-check (the test `every_recorded_move_is_the_byte_model`); its other
|
||||
//! tie to Metal is a **single SHA-256 of a line transcript**, 350 lines of
|
||||
//! `"<format> <shape> <step>: <n> bytes, sha <six bytes>"` an Apple **M4** printed. A difference
|
||||
//! says one of two things: Apple's copies moved between the chips or the releases, or the model was
|
||||
//! never Metal's.
|
||||
//!
|
||||
//! **One case per format**, so a venue that holds no texture of one answers its typed refusal there
|
||||
//! and the suite counts that format as [`LacksFeature`](crate::verdict::Verdict::LacksFeature). The
|
||||
//! lane walks fourteen formats in one test, where a device missing one would take the whole lane
|
||||
//! down. The port also covers BC6H and BC7, which no other case in the suite reaches.
|
||||
//! family covers BC6H and BC7, which no other case in the suite reaches.
|
||||
//!
|
||||
//! Every byte of every read-back is compared, the padding between the rows included
|
||||
//! ([`Gaps::Compared`]): the lane asserts the bytes past each row's blocks stay `0xcd`, and here
|
||||
//! that is the recorded value rather than an assertion beside it.
|
||||
//! ([`Gaps::Compared`]): the bytes past each row's blocks staying `0xcd` is a recorded value.
|
||||
//!
|
||||
//! **Not ported, and why.** The lane's second test adds a 2D texture of 1030 x 520 and all eleven
|
||||
//! levels, whose level 0 alone is over 500 KiB of blocks — past the recording's whole-value ceiling,
|
||||
//! so it wants the digest-plus-window form no case has exercised yet. Its other three shapes'
|
||||
//! worth is covered by [`crate::cases::compressed_views`]. Stated here rather than left implicit.
|
||||
//! **Not a case, and why.** A 2D texture of 1030 x 520 and all eleven levels: its level 0 alone is
|
||||
//! over 500 KiB of blocks, past the recording's whole-value ceiling, so it wants the
|
||||
//! digest-plus-window form no case has exercised yet.
|
||||
//!
|
||||
//! Nothing here can fault a GPU: host copies and blit copies between textures the program makes, no
|
||||
//! dispatch, no draw, no loop, and every region block-aligned and inside its level.
|
||||
@@ -69,8 +63,8 @@ struct Format {
|
||||
block: u64,
|
||||
}
|
||||
|
||||
/// Every BC format, in the lane's order, because a shape's seed is its place in that order and the
|
||||
/// bytes must stay the bytes the lane measured.
|
||||
/// Every BC format, in a fixed order, because a shape's seed is its place in that order and the
|
||||
/// bytes must stay the bytes the recordings hold.
|
||||
const FORMATS: [Format; 14] = [
|
||||
Format {
|
||||
name: "compressed-moves-bc1-rgba",
|
||||
@@ -145,8 +139,8 @@ const FORMATS: [Format; 14] = [
|
||||
];
|
||||
|
||||
/// A texture's shape: its kind, its size in texels (the third axis a 3D texture's depth), its array
|
||||
/// length and its levels. The lane's five, unchanged, because a shape's bytes come from a seeded
|
||||
/// stream keyed to its place.
|
||||
/// length and its levels. Five, fixed, because a shape's bytes come from a seeded stream keyed to
|
||||
/// its place.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct Shape {
|
||||
pub name: &'static str,
|
||||
@@ -157,7 +151,7 @@ pub struct Shape {
|
||||
pub levels: u64,
|
||||
}
|
||||
|
||||
/// The lane's five shapes, in its order.
|
||||
/// The five shapes, in order.
|
||||
pub const SHAPES: [Shape; 5] = [
|
||||
Shape {
|
||||
name: "2d-13x7",
|
||||
@@ -222,7 +216,7 @@ impl Shape {
|
||||
[w.div_ceil(4), h.div_ceil(4), d]
|
||||
}
|
||||
|
||||
/// Every (level, slice), levels outermost, as the lane walks them.
|
||||
/// Every (level, slice), levels outermost.
|
||||
pub fn each(&self) -> Vec<(u64, u64)> {
|
||||
(0..self.levels)
|
||||
.flat_map(|l| (0..self.slices()).map(move |s| (l, s)))
|
||||
@@ -258,7 +252,7 @@ impl Shape {
|
||||
}
|
||||
}
|
||||
|
||||
/// A splitmix64 stream of bytes: the lane's own, so a shape's blocks are the lane's blocks.
|
||||
/// A splitmix64 stream of bytes, so a shape's blocks are the same on every run.
|
||||
pub struct Rng(pub u64);
|
||||
|
||||
impl Rng {
|
||||
@@ -278,8 +272,7 @@ impl Rng {
|
||||
|
||||
/// A texture's blocks as Metal's copies leave them: `(level, slice, z, y, x)` to the block's bytes.
|
||||
///
|
||||
/// It is the lane's model, kept whole, because the whole point of the port is to hold Metal's own
|
||||
/// recorded bytes against it.
|
||||
/// It is kept whole, because the cross-check holds Metal's own recorded bytes against it.
|
||||
#[derive(Clone, Default)]
|
||||
pub struct Model(std::collections::BTreeMap<(u64, u64, u64, u64, u64), Vec<u8>>);
|
||||
|
||||
@@ -347,7 +340,7 @@ impl Model {
|
||||
}
|
||||
}
|
||||
|
||||
/// The steps, in the lane's order, each naming the site its read-backs sit under.
|
||||
/// The steps, in order, each naming the site its read-backs sit under.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
enum Step {
|
||||
Put,
|
||||
@@ -425,7 +418,7 @@ fn texture_layout(
|
||||
}
|
||||
}
|
||||
|
||||
/// The plan for `format` in `shape`, seeded as the lane seeds it: the whole five-step program and
|
||||
/// The plan for `format` in `shape`, seeded by its place: the whole five-step program and
|
||||
/// the model's bytes for each read.
|
||||
///
|
||||
/// The one function builds both, so the program's offsets and the model's offsets cannot drift
|
||||
@@ -523,7 +516,7 @@ fn plan(format: u32, block: u64, shape: &Shape, seed: u64) -> Plan {
|
||||
bytes_per_row: row,
|
||||
bytes_per_image: image,
|
||||
length: total as usize,
|
||||
// The lane reads into bytes of 0xcd, so the bytes past each row's blocks are recorded
|
||||
// The case reads into bytes of 0xcd, so the bytes past each row's blocks are recorded
|
||||
// as a value Metal would never write: that is what makes "the padding stayed as it
|
||||
// was" a question with an answer.
|
||||
before: BEFORE,
|
||||
@@ -568,7 +561,7 @@ fn plan(format: u32, block: u64, shape: &Shape, seed: u64) -> Plan {
|
||||
bytes_per_row: row,
|
||||
bytes_per_image: image,
|
||||
length: total as usize,
|
||||
// The lane reads into bytes of 0xcd, so the bytes past each row's blocks are recorded
|
||||
// The case reads into bytes of 0xcd, so the bytes past each row's blocks are recorded
|
||||
// as a value Metal would never write: that is what makes "the padding stayed as it
|
||||
// was" a question with an answer.
|
||||
before: BEFORE,
|
||||
@@ -751,7 +744,7 @@ struct Moved {
|
||||
to_at: (u64, u64),
|
||||
}
|
||||
|
||||
/// The lane's region for `shape`, each chosen so the copy is block-aligned and reaches a level's
|
||||
/// The region for `shape`, each chosen so the copy is block-aligned and reaches a level's
|
||||
/// edge in at least one axis.
|
||||
fn region(shape: &Shape) -> Moved {
|
||||
let (from, to, size, from_at, to_at) = match shape.name {
|
||||
@@ -778,7 +771,7 @@ fn region(shape: &Shape) -> Moved {
|
||||
/// Every level and slice of `texture` blitted out tight, one after another from byte 0, into a
|
||||
/// buffer of [`BEFORE`], with the model's bytes recorded for it under `step`.
|
||||
///
|
||||
/// It is the lane's `out_tight`, which both compressed families use as their one way of reading a
|
||||
/// It is `out_tight`, which both compressed families use as their one way of reading a
|
||||
/// private texture's blocks back.
|
||||
pub fn out_tight(
|
||||
work: &mut Work,
|
||||
@@ -857,7 +850,7 @@ pub struct CompressedMoves {
|
||||
at: usize,
|
||||
}
|
||||
|
||||
/// Every format's case, in the lane's order.
|
||||
/// Every format's case, in [`FORMATS`] order.
|
||||
pub fn all() -> Vec<CompressedMoves> {
|
||||
(0..FORMATS.len())
|
||||
.map(|at| CompressedMoves { at })
|
||||
@@ -870,8 +863,8 @@ impl CompressedMoves {
|
||||
&FORMATS[self.at]
|
||||
}
|
||||
|
||||
/// The plans of every shape, in the lane's order, each seeded as the lane seeds it: the block
|
||||
/// size and the shape's place, so the bytes are the bytes the lane measured.
|
||||
/// The plans of every shape, in order, each seeded by the block size and the shape's place, so
|
||||
/// the bytes are the bytes the recordings hold.
|
||||
pub fn plans(&self) -> Vec<(&'static Shape, Plan)> {
|
||||
let format = self.format();
|
||||
SHAPES
|
||||
@@ -1287,19 +1280,19 @@ mod tests {
|
||||
assert!(specs >= 150, "only {specs} texture specs reached the guard");
|
||||
}
|
||||
|
||||
/// Every one of Metal's recorded read-backs is the lane's byte model's, byte for byte, padding
|
||||
/// Every one of Metal's recorded read-backs is the byte model's, byte for byte, padding
|
||||
/// included.
|
||||
///
|
||||
/// This is the cross-check the port exists for. The recordings hold what Metal answered on this
|
||||
/// M3 Max; the model was tied to Metal only by a six-byte digest per step, measured by our own
|
||||
/// probe on an Apple M4. A difference means one of two things, and either is a finding rather
|
||||
/// The recordings hold what Metal answered on an Apple M3 Max; the model's other tie to Metal
|
||||
/// is a six-byte digest per step an Apple M4 printed. A difference means one of two things, and
|
||||
/// either is a finding rather
|
||||
/// than something to edit away: Apple's copies moved between the chips or the releases, or the
|
||||
/// model was never Metal's.
|
||||
///
|
||||
/// A case with no recording yet is named, so a missing recording is record mode's work and not
|
||||
/// a silent pass.
|
||||
#[test]
|
||||
fn every_recorded_move_is_the_lanes_byte_model() {
|
||||
fn every_recorded_move_is_the_byte_model() {
|
||||
let mut unrecorded = Vec::new();
|
||||
let mut differ = Vec::new();
|
||||
let mut checked = 0usize;
|
||||
@@ -1352,8 +1345,7 @@ mod tests {
|
||||
}
|
||||
assert!(
|
||||
differ.is_empty(),
|
||||
"{checked} bytes checked; Metal's recorded copies differ from the lane's byte \
|
||||
model:\n{}",
|
||||
"{checked} bytes checked; Metal's recorded copies differ from the byte model:\n{}",
|
||||
differ.join("\n")
|
||||
);
|
||||
assert!(
|
||||
|
||||
@@ -13,26 +13,23 @@
|
||||
//! - `putsub`: `replaceRegion:` of an interior region of level 0, slice 0, from texel (4, 4) to its
|
||||
//! edges, then the texture out tight.
|
||||
//!
|
||||
//! **What the port changes.** As with the first lane, the lane's own expectation is a byte model in
|
||||
//! Rust tied to Metal by one SHA-256 over 336 lines of six-byte digests, measured by our own probe
|
||||
//! on an Apple **M4**. Here record mode runs the same steps on this M3 Max and each recording holds
|
||||
//! Metal's own bytes; the model becomes a cross-check (the test
|
||||
//! `every_recorded_view_move_is_the_lanes_byte_model`), which is the only direction in which a
|
||||
//! difference says something.
|
||||
//! **Metal's own bytes.** Record mode runs the steps on an Apple M3 Max and each recording holds
|
||||
//! Metal's own bytes. A byte model in Rust stays as a cross-check (the test
|
||||
//! `every_recorded_view_move_is_the_byte_model`); its other tie to Metal is one SHA-256 over 336
|
||||
//! lines of six-byte digests an Apple **M4** printed.
|
||||
//!
|
||||
//! **A view is a resource, not a step**, so the suite's interpreters make it before the first step
|
||||
//! runs — which is exactly the lane's "made before the texture held anything" and needs no special
|
||||
//! vocabulary. A signed or float pair's view needs `MTLTextureUsagePixelFormatView`, which the sRGB
|
||||
//! runs, so the view is made before the texture holds anything, with no special vocabulary. A
|
||||
//! signed or float pair's view needs `MTLTextureUsagePixelFormatView`, which the sRGB
|
||||
//! twins do not ([`sibling`]), and the case states the usage bits rather than letting either side
|
||||
//! infer them.
|
||||
//!
|
||||
//! **One case per format**, as the rest of the compressed families: a venue with no texture of one
|
||||
//! answers its typed refusal there and counts as lacking that format.
|
||||
//!
|
||||
//! **Not ported:** the lane's 1030 x 520 texture of all eleven levels, whose level 0 alone is over
|
||||
//! 500 KiB of blocks, so a whole-value recording of its four steps would be several MiB. It wants
|
||||
//! the recording's digest-plus-window form, which no case has exercised yet, and it is its own
|
||||
//! packet.
|
||||
//! **Not a case:** a 1030 x 520 texture of all eleven levels, whose level 0 alone is over 500 KiB
|
||||
//! of blocks, so a whole-value recording of its four steps would be several MiB. It wants the
|
||||
//! recording's digest-plus-window form, which no case has exercised yet.
|
||||
//!
|
||||
//! Nothing here can fault a GPU: host copies and blit copies between textures the program makes, no
|
||||
//! dispatch, no draw, no loop, and every region block-aligned and inside its level.
|
||||
@@ -56,9 +53,9 @@ struct Format {
|
||||
sibling: (u32, bool),
|
||||
}
|
||||
|
||||
/// Every BC format, in the lane's order, because a shape's seed is its place in that order.
|
||||
/// Every BC format, in a fixed order, because a shape's seed is its place in that order.
|
||||
///
|
||||
/// The siblings are the lane's: an sRGB twin either way (no `PixelFormatView` usage, since Metal
|
||||
/// The siblings: an sRGB twin either way (no `PixelFormatView` usage, since Metal
|
||||
/// counts the twins as one layout), and the other member of a signed or a float pair (which needs
|
||||
/// it).
|
||||
const FORMATS: [Format; 14] = [
|
||||
@@ -149,7 +146,7 @@ const FORMATS: [Format; 14] = [
|
||||
];
|
||||
|
||||
/// The sibling format of the raw `MTLPixelFormat` `raw`, and whether viewing it needs
|
||||
/// `MTLTextureUsagePixelFormatView`, as the lane names them.
|
||||
/// `MTLTextureUsagePixelFormatView`.
|
||||
pub fn sibling(raw: u32) -> Option<(u32, bool)> {
|
||||
FORMATS
|
||||
.iter()
|
||||
@@ -175,7 +172,7 @@ pub struct Plan {
|
||||
pub expected: Vec<Expected>,
|
||||
}
|
||||
|
||||
/// The plan for `format` in `shape`, seeded as the lane seeds it.
|
||||
/// The plan for `format` in `shape`, seeded by its place.
|
||||
///
|
||||
/// The one function builds the program and the expectation together, so their offsets cannot drift
|
||||
/// apart.
|
||||
@@ -186,7 +183,7 @@ fn plan(format: &Format, shape: &Shape, seed: u64) -> Plan {
|
||||
let mut expected = Vec::new();
|
||||
let three_d = shape.three_d();
|
||||
let (view_format, needs_usage) = format.sibling;
|
||||
// A signed or float pair's view needs `PixelFormatView`; the sRGB twins do not, and the lane
|
||||
// A signed or float pair's view needs `PixelFormatView`; the sRGB twins do not, and the case
|
||||
// separates the two because a texture that may be viewed in another format is laid out
|
||||
// differently from one that may not.
|
||||
let usage = if needs_usage {
|
||||
@@ -197,7 +194,7 @@ fn plan(format: &Format, shape: &Shape, seed: u64) -> Plan {
|
||||
let first = work.add(Resource::Texture {
|
||||
spec: shape.spec(format.format, false).used(usage),
|
||||
});
|
||||
// Made before any step runs, which is the lane's "before the texture held anything": the
|
||||
// Made before any step runs, before the texture holds anything: the
|
||||
// interpreters make every resource first, so the view cannot have taken a copy of what was
|
||||
// there.
|
||||
let view = work.add(Resource::View {
|
||||
@@ -369,7 +366,7 @@ pub struct CompressedViews {
|
||||
at: usize,
|
||||
}
|
||||
|
||||
/// Every format's case, in the lane's order.
|
||||
/// Every format's case, in [`FORMATS`] order.
|
||||
pub fn all() -> Vec<CompressedViews> {
|
||||
(0..FORMATS.len())
|
||||
.map(|at| CompressedViews { at })
|
||||
@@ -382,8 +379,8 @@ impl CompressedViews {
|
||||
&FORMATS[self.at]
|
||||
}
|
||||
|
||||
/// The plans of every shape, seeded as the lane seeds them: the lane's second seed base, the
|
||||
/// block size and the shape's place.
|
||||
/// The plans of every shape, seeded by the second seed base, the block size and the shape's
|
||||
/// place.
|
||||
pub fn plans(&self) -> Vec<(&'static Shape, Plan)> {
|
||||
let format = self.format();
|
||||
SHAPES
|
||||
@@ -479,7 +476,7 @@ mod tests {
|
||||
}
|
||||
|
||||
/// Every format's sibling is another format of the same block size, and the relation is its own
|
||||
/// inverse: the lane's pairs, held to shape rather than taken on trust.
|
||||
/// inverse: the pairs, held to shape rather than taken on trust.
|
||||
#[test]
|
||||
fn every_sibling_is_a_pair_of_one_block_size() {
|
||||
for format in &FORMATS {
|
||||
@@ -551,14 +548,13 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// Every one of Metal's recorded read-backs is the lane's byte model's, byte for byte.
|
||||
/// Every one of Metal's recorded read-backs is the byte model's, byte for byte.
|
||||
///
|
||||
/// This is the cross-check the port exists for: the recordings hold what Metal answered on this
|
||||
/// M3 Max, where the lane tied its model to Metal by one digest per step measured on an Apple
|
||||
/// M4. A difference is a finding either way — Apple's copies moved, or the model was never
|
||||
/// Metal's — and never something to edit away.
|
||||
/// The recordings hold what Metal answered on an Apple M3 Max; the model's other tie to Metal
|
||||
/// is one digest per step an Apple M4 printed. A difference is a finding either way — Apple's
|
||||
/// copies moved, or the model was never Metal's — and never something to edit away.
|
||||
#[test]
|
||||
fn every_recorded_view_move_is_the_lanes_byte_model() {
|
||||
fn every_recorded_view_move_is_the_byte_model() {
|
||||
let mut unrecorded = Vec::new();
|
||||
let mut differ = Vec::new();
|
||||
let mut checked = 0usize;
|
||||
@@ -611,8 +607,7 @@ mod tests {
|
||||
}
|
||||
assert!(
|
||||
differ.is_empty(),
|
||||
"{checked} bytes checked; Metal's recorded view copies differ from the lane's byte \
|
||||
model:\n{}",
|
||||
"{checked} bytes checked; Metal's recorded view copies differ from the byte model:\n{}",
|
||||
differ.join("\n")
|
||||
);
|
||||
assert!(
|
||||
|
||||
@@ -5,17 +5,16 @@
|
||||
//! view's component mapping hands a channel's codes to another channel's lane. Metal applies the
|
||||
//! texture's swizzle to the texel it reads — each channel the source its swizzle names, `Zero` 0 and
|
||||
//! `One` 1.0, border texels included — and a gather of a component gathers the swizzle's source of
|
||||
//! it. The lane asked whether our swizzled reads, samples and gathers of such a texture are its
|
||||
//! unswizzled ones swizzled, as Metal's are, and compared them against the **unswizzled texture on
|
||||
//! the same device**, because for the extended-range formats it held no Metal rule at all.
|
||||
//! it. So a swizzled read, sample and gather of such a texture is its unswizzled one swizzled; for
|
||||
//! the extended-range formats there is no computed Metal rule, so a cross-check holds the swizzled
|
||||
//! answers to the **unswizzled texture's**.
|
||||
//!
|
||||
//! **The port records Metal's own words for every swizzle**, which is strictly more than the lane
|
||||
//! had: comparison is then exact against Metal rather than against our own unswizzled leg. The
|
||||
//! lane's two claims survive as committed cross-checks over the recordings —
|
||||
//! `every_recorded_swizzle_is_the_unswizzled_texture_swizzled`, which is the lane's whole subject,
|
||||
//! and `every_recorded_packed_read_is_metals_rule`, the code-to-value rule the lane did hold for the
|
||||
//! four packed formats (each channel's code `c` of `b` bits reads `c / (2^b - 1)`, correctly
|
||||
//! rounded, and an alpha the format lacks reads 1).
|
||||
//! **The case records Metal's own words for every swizzle**, so comparison is exact against Metal.
|
||||
//! Two cross-checks hold the recordings to rules —
|
||||
//! `every_recorded_swizzle_is_the_unswizzled_texture_swizzled`, and
|
||||
//! `every_recorded_packed_read_is_metals_rule`, the code-to-value rule of the four packed formats
|
||||
//! (each channel's code `c` of `b` bits reads `c / (2^b - 1)`, correctly rounded, and an alpha the
|
||||
//! format lacks reads 1).
|
||||
//!
|
||||
//! The kernels are the owned fixture `fpv_swizzled_reads`'s, all binding the texture at
|
||||
//! `[[texture(0)]]`, writing `o[i]` (buffer 0) from position `p[i]` (buffer 1): `fpv_swz_read`
|
||||
@@ -23,20 +22,18 @@
|
||||
//! sampler at `[[sampler(0)]]`, and `fpv_swz_gather_x` through `_w` gather one component of the
|
||||
//! footprint.
|
||||
//!
|
||||
//! **The positions are a stated reduction of the lane's**, and this is the one place the port is
|
||||
//! narrower than the lane. The lane sweeps three offsets on each axis independently, nine points in
|
||||
//! each of the 60 cells of the texture and the ring of cells around it: 540 positions, which at
|
||||
//! six sampled operations and five swizzles would put each format's recording well past the
|
||||
//! **The positions are a stated reduction.** Three offsets on each axis independently, nine points
|
||||
//! in each of the 60 cells of the texture and the ring of cells around it, are 540 positions, which
|
||||
//! at six sampled operations and five swizzles would put each format's recording well past the
|
||||
//! recording ceiling. The case keeps [`OFFSETS`] on the cell's **diagonal**, three points a cell
|
||||
//! and 180 in all: a point below the half-texel line on both axes, the texel centre where a linear
|
||||
//! sample reduces to the texel itself, and a point above it on both axes. Between them every tap of
|
||||
//! a 2 by 2 linear footprint is reached, in the cells inside the texture and in the ring outside it
|
||||
//! where the footprint holds only border texels. The six points the lane also takes are the mixed
|
||||
//! ones (below on one axis, above on the other), and they are not here.
|
||||
//! where the footprint holds only border texels. The six mixed points (below on one axis, above on
|
||||
//! the other) are not here.
|
||||
//!
|
||||
//! One case per format, so a venue that holds no texture of one answers its typed refusal at that
|
||||
//! row rather than leaving the other fourteen sweeps uncompared — which is what the lane does when
|
||||
//! it prints `EXT-SWIZZLE-REFUSED` and moves on.
|
||||
//! row rather than leaving the other fourteen sweeps uncompared.
|
||||
//!
|
||||
//! The output buffer holds a fill byte before each dispatch (`BLANK`), so a lane the kernel did
|
||||
//! not write is a recorded value rather than whatever was there.
|
||||
@@ -77,13 +74,13 @@ pub struct Format {
|
||||
/// Bytes one texel takes, which the case states because no `MTLTexture` answers it.
|
||||
pub texel_bytes: u32,
|
||||
/// Each channel's `(shift, bits)` in the texel's 16-bit word, red first, `None` where the
|
||||
/// format lacks the channel: the packed-normalized formats, whose code-to-value rule the lane
|
||||
/// held. `None` for a format whose codes the lane had no rule for.
|
||||
/// format lacks the channel: the packed-normalized formats, whose code-to-value rule the case
|
||||
/// holds. `None` for a format whose codes have no such rule here.
|
||||
pub packed: Option<[Option<(u32, u32)>; 4]>,
|
||||
}
|
||||
|
||||
/// The one-plane extended-range formats, the padded 10-bit ones, their `_sRGB` twins, the bfloat
|
||||
/// formats, and the four packed normalized ones whose rule the lane held.
|
||||
/// formats, and the four packed normalized ones whose code-to-value rule the case holds.
|
||||
///
|
||||
/// The packed fields are the Vulkan formats' that hold them (`R5G6B5_UNORM_PACK16`,
|
||||
/// `R5G5B5A1_UNORM_PACK16`, `A1R5G5B5_UNORM_PACK16`, `R4G4B4A4_UNORM_PACK16`).
|
||||
@@ -180,7 +177,7 @@ pub const FORMATS: [Format; 15] = [
|
||||
},
|
||||
];
|
||||
|
||||
/// The swizzles, the default first, as the lane made them.
|
||||
/// The swizzles, the default first.
|
||||
pub fn swizzles() -> [(&'static str, TextureSwizzleChannels); 5] {
|
||||
use TextureSwizzle::{Alpha, Blue, Green, One, Red, Zero};
|
||||
let s = |red, green, blue, alpha| TextureSwizzleChannels {
|
||||
@@ -278,7 +275,7 @@ fn sample_coords() -> Vec<u8> {
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The sampler of `filter`, at clamp-to-border opaque white on both axes, as the lane made it.
|
||||
/// The sampler of `filter`, at clamp-to-border opaque white on both axes.
|
||||
fn sampler_spec(filter: SamplerMinMagFilter) -> SamplerSpec {
|
||||
let mut spec = SamplerSpec::filtered(filter);
|
||||
spec = spec.addressed(SamplerAddressMode::ClampToBorderColor);
|
||||
@@ -638,10 +635,8 @@ mod tests {
|
||||
/// Every swizzled read, sample and gather Metal recorded is the **unswizzled** texture's
|
||||
/// recorded answer swizzled.
|
||||
///
|
||||
/// This is the lane's whole subject, now checked against Metal's own words on both sides of the
|
||||
/// equation rather than against our own unswizzled leg: for the extended-range and bfloat
|
||||
/// formats the lane held no Metal rule at all, so it could only ask whether *we* were
|
||||
/// self-consistent. Here both terms are Metal's.
|
||||
/// Both sides of the equation are Metal's own words: for the extended-range and bfloat formats
|
||||
/// there is no computed Metal rule, so the swizzled reads are held to the unswizzled ones.
|
||||
#[test]
|
||||
fn every_recorded_swizzle_is_the_unswizzled_texture_swizzled() {
|
||||
let mut unrecorded = Vec::new();
|
||||
@@ -777,12 +772,12 @@ mod tests {
|
||||
}
|
||||
|
||||
/// Every unswizzled read, nearest sample and gather of a **packed normalized** texture that
|
||||
/// Metal recorded is the lane's code-to-value rule's.
|
||||
/// Metal recorded is the code-to-value rule's.
|
||||
///
|
||||
/// The four packed formats are the only ones of the fifteen the lane held a Metal rule for, so
|
||||
/// this is where the recordings can be held to a computed answer rather than to each other. A
|
||||
/// linear sample and an access past the edges are not here: the rule covers neither, which is
|
||||
/// exactly why the lane compared those against the unswizzled texture instead.
|
||||
/// The four packed formats are the only ones of the fifteen with a computed Metal rule, so this
|
||||
/// is where the recordings can be held to a computed answer rather than to each other. A linear
|
||||
/// sample and an access past the edges are not here: the rule covers neither, so those are held
|
||||
/// to the unswizzled texture instead.
|
||||
#[test]
|
||||
fn every_recorded_packed_read_is_metals_rule() {
|
||||
let mut unrecorded = Vec::new();
|
||||
@@ -820,8 +815,8 @@ mod tests {
|
||||
assert_eq!(families, 4, "the four packed normalized formats");
|
||||
assert!(
|
||||
differ.is_empty(),
|
||||
"{checked} results checked; Metal's recorded texels differ from the lane's \
|
||||
code-to-value rule:\n{}",
|
||||
"{checked} results checked; Metal's recorded texels differ from the code-to-value \
|
||||
rule:\n{}",
|
||||
differ.join("\n")
|
||||
);
|
||||
assert!(
|
||||
|
||||
@@ -26,39 +26,35 @@
|
||||
//! a row that reads zero has also proved its copy ran: zero is otherwise indistinguishable from a
|
||||
//! read-back that never happened.
|
||||
//!
|
||||
//! The `fresh-pattern-*` rows are the one group with no release in them, because the lane's own
|
||||
//! per-format probe made each texture first: what they pin is Metal's compressed-texture pattern
|
||||
//! per format, and their prefilled destination is what makes the read honest.
|
||||
//! The `fresh-pattern-*` rows are the one group with no release in them: each makes its texture
|
||||
//! once, what they pin is Metal's compressed-texture pattern per format, and their prefilled
|
||||
//! destination is what makes the read honest.
|
||||
//!
|
||||
//! # What the rows are held to, and the one branch of the lane that is not exercised
|
||||
//! # What the rows are held to
|
||||
//!
|
||||
//! **One site of one kind of row is loosened, and only on one kind of venue.** Every row's bytes
|
||||
//! are Metal's own on MoltenVK and on lavapipe, which present the recordings' Apple silicon Mac's
|
||||
//! lossless compression, so there the only field that may differ is the set of degrade notices
|
||||
//! our side announced. The depth row's on lavapipe, which cannot hold Metal's denormal depths
|
||||
//! (`depth-denormals`), is the device's own answer, which the suite declares for every case
|
||||
//! ([`crate::replay::NATIVE_NOTES`]). On a device that presents a Mac keeping no texture
|
||||
//! compressed (`DeviceProperties::lossless_compression` false, as an RTX 5080 Laptop presents
|
||||
//! today), a new `Private` texture holds what its memory held and nothing writes it, so the
|
||||
//! `fresh` site of every `Private` texture row and every pattern row reads zero, the released
|
||||
//! texture's [`OLD`] bytes or whatever else the memory held; that site alone is declared, by
|
||||
//! [`crate::replay::without_compression`], which justifies nothing on a venue that presents the
|
||||
//! compression. The `written` site, the statuses and every `Shared` and `Managed` row still compare
|
||||
//! exactly there.
|
||||
//! **One site of one kind of row is loosened, and only on one kind of venue.** The runtime
|
||||
//! presents a Mac keeping no texture compressed ([`crate::case::Venue::lossless_compression`]
|
||||
//! false), and a texture it places reads zero until written (its README, Textures), so the `fresh`
|
||||
//! site of every `Private` texture row and every pattern row reads zero where Metal reads its
|
||||
//! pattern; that site alone is declared, by [`crate::replay::without_compression`], which
|
||||
//! justifies nothing on a venue that presents the compression. The `written` site, the statuses
|
||||
//! and every `Shared` and `Managed` row still compare exactly. The depth row's bytes on a device
|
||||
//! that cannot hold Metal's denormal depths (`depth-denormals`, lavapipe's) are the device's own
|
||||
//! answer, which the suite declares for every case ([`crate::replay::NATIVE_NOTES`]).
|
||||
//!
|
||||
|
||||
//! # Why one process is the right place for this, and more than the lane had
|
||||
//! # Why one process is the right place for this
|
||||
//!
|
||||
//! The lane's header describes a probe across *three fresh processes* and one after 768 MiB of
|
||||
//! written and released memory. That probe's job was to show the answer does **not** vary with how
|
||||
//! much a process has allocated, and it has done it. Nothing in these cases depends on being first:
|
||||
//! each row makes, fills, releases and remakes inside its own program.
|
||||
//! Metal's answer does **not** vary with how much a process has allocated: a probe across three
|
||||
//! fresh processes and one after 768 MiB of written and released memory read the same. Nothing in
|
||||
//! these cases depends on being first: each row makes, fills, releases and remakes inside its own
|
||||
//! program.
|
||||
//!
|
||||
//! `conformance replay` runs every case in **one** process, where nextest gives each lane test its
|
||||
//! own, so these rows run in a **dirtier** process than the lane's — hundreds of cases' allocations
|
||||
//! have come and gone before them. That cuts one way only: a warm process can hand back more
|
||||
//! soiled memory, never less, so it cannot manufacture a green row, only expose a dirty one. Do not
|
||||
//! "fix" this family by giving its cases a process each; the shared process is the stronger test.
|
||||
//! `conformance replay` runs every case in **one** process, so these rows run in a **dirty**
|
||||
//! process — hundreds of cases' allocations have come and gone before them. That cuts one way
|
||||
//! only: a warm process can hand back more soiled memory, never less, so it cannot manufacture a
|
||||
//! green row, only expose a dirty one. Do not "fix" this family by giving its cases a process each;
|
||||
//! the shared process is the stronger test.
|
||||
//!
|
||||
//! # The record shape
|
||||
//!
|
||||
@@ -74,15 +70,15 @@
|
||||
//! is not one byte repeated — `RGBA8Unorm` reads `ff00ffff` — so runs of equal bytes made 8,193
|
||||
//! runs of one 16 KiB level and a 3.5 MB recording for a row whose answer is one sentence.
|
||||
//!
|
||||
//! # What is not ported, and why
|
||||
//! # What is not a case, and why
|
||||
//!
|
||||
//! - **The 3D and cube rows.** [`crate::work::TextureKind`] describes no 3D and no cube texture and
|
||||
//! [`crate::work::TextureSpec`] carries no depth, so porting them means growing the shared
|
||||
//! vocabulary for two rows. They stay in the lane.
|
||||
//! - **The multisampled rows** (the 4x colour targets, the NaN pattern copied from a scratch, and
|
||||
//! the depth target loaded, cleared and read by a shader). The Metal side of a copy-and-fill
|
||||
//! program builds no clearing render pass and no per-sample read-back, so those rows have no
|
||||
//! Metal leg to record; they stay in the lane.
|
||||
//! - **3D and cube textures.** [`crate::work::TextureKind`] describes no 3D and no cube texture and
|
||||
//! [`crate::work::TextureSpec`] carries no depth, so such a row means growing the shared
|
||||
//! vocabulary for two rows.
|
||||
//! - **Multisampled textures** (4x colour targets, the NaN pattern copied from a scratch, and a
|
||||
//! depth target loaded, cleared and read by a shader). The Metal side of a copy-and-fill program
|
||||
//! builds no clearing render pass and no per-sample read-back, so such rows have no Metal leg to
|
||||
//! record.
|
||||
//! - **The two-plane `RGB10A8_2P_XR10` row**, whose planes are read by a fixture's kernels rather
|
||||
//! than by a copy.
|
||||
//! - **The host's own read of a `Shared` buffer's `contents`.** Every read here is a copy into a
|
||||
@@ -98,7 +94,7 @@ use crate::transcript::{Node, Observed, Sites, Value};
|
||||
use crate::work::{Done, Plane, Resource, Step, Storage, TextureKind, TextureSpec, Work};
|
||||
|
||||
/// The byte a resource is filled with before it is released, so the memory the row's second
|
||||
/// allocation may be handed held something nothing else would produce. The lane's own byte.
|
||||
/// allocation may be handed held something nothing else would produce.
|
||||
pub const OLD: u8 = 0xa5;
|
||||
|
||||
/// The byte every read-back buffer holds before its copy. Neither zero nor [`OLD`], so a site that
|
||||
@@ -169,8 +165,7 @@ fn statuses_site(done: &[String]) -> Node {
|
||||
// Buffers
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
/// The buffer lengths each storage mode is swept at: the lane's own, from one 16-byte buffer to
|
||||
/// 16 MiB.
|
||||
/// The buffer lengths each storage mode is swept at, from one 16-byte buffer to 16 MiB.
|
||||
const LENGTHS: [u64; 5] = [16, 4096, 65536, 1 << 20, 16 << 20];
|
||||
|
||||
/// The program one buffer row runs at one length: fill a buffer of this shape with [`OLD`], read it
|
||||
@@ -632,7 +627,7 @@ const BUFFERS: [(&str, Storage); 3] = [
|
||||
// Textures of their own memory
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
/// A texture shape the lane sweeps: the descriptor's facts, the bytes its blocks take, what the
|
||||
/// A texture shape the case sweeps: the descriptor's facts, the bytes its blocks take, what the
|
||||
/// [`OLD`] write puts in each block, and what Metal reads in a `Private` one of this shape.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
struct Shape {
|
||||
@@ -646,8 +641,8 @@ struct Shape {
|
||||
/// The raw `MTLTextureUsage` bits, stated because Metal refuses some pairings and because the
|
||||
/// usage decides the layout.
|
||||
usage: u32,
|
||||
/// Whether `allowGPUOptimizedContents` is **off**, which is how the lane picks out a `Private`
|
||||
/// texture Metal keeps uncompressed.
|
||||
/// Whether `allowGPUOptimizedContents` is **off**, which picks out a `Private` texture Metal
|
||||
/// keeps uncompressed.
|
||||
plain: bool,
|
||||
/// The bytes the [`OLD`] write puts in each block: one block's worth.
|
||||
old: &'static [u8],
|
||||
@@ -693,11 +688,11 @@ impl Shape {
|
||||
spec
|
||||
}
|
||||
|
||||
/// What the lane expects a fresh texture of this shape in `storage` to read, level by level and
|
||||
/// What a fresh texture of this shape in `storage` reads by Metal's rule, level by level and
|
||||
/// slice by slice: Metal's pattern in a `Private` one's patterned levels, zero everywhere else.
|
||||
///
|
||||
/// Nothing in the suite compares against this: it is what the port's cross-check holds the
|
||||
/// recorded Metal answer to, which is why it is the tests' alone.
|
||||
/// Nothing in the suite compares against this: it is what the cross-check holds the recorded
|
||||
/// Metal answer to, which is why it is the tests' alone.
|
||||
#[cfg(test)]
|
||||
fn expected_fresh(&self, storage: Storage) -> Vec<u8> {
|
||||
let mut all = Vec::new();
|
||||
@@ -804,7 +799,7 @@ const RGBA8_PLAIN: Shape = Shape {
|
||||
/// A 64-square `Depth32Float` render target. Metal's pattern for it is all ones, a NaN depth.
|
||||
///
|
||||
/// The [`OLD`] write puts a depth of 0.5 in it rather than [`OLD`] bytes: a value every depth image
|
||||
/// holds as it is, which is the lane's own reason.
|
||||
/// holds as it is.
|
||||
const DEPTH32FLOAT: Shape = Shape {
|
||||
old: &[0x00, 0x00, 0x00, 0x3f],
|
||||
pattern: Some((&[0xff; 4], 1)),
|
||||
@@ -1095,18 +1090,17 @@ impl Case for FreshTexture {
|
||||
// Metal's pattern, format by format
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
/// The side of every [`PATTERNS`] texture, in texels: the lane's own, and wide enough that Metal
|
||||
/// compresses it.
|
||||
/// The side of every [`PATTERNS`] texture, in texels: wide enough that Metal compresses it.
|
||||
const PATTERN_SIDE: u64 = 64;
|
||||
|
||||
/// One format whose `Private` pattern the lane's probe read.
|
||||
/// One format whose `Private` pattern the case reads.
|
||||
struct Pattern {
|
||||
case: &'static str,
|
||||
format: u32,
|
||||
/// Metal's pattern: the bytes of one texel, which every texel of a new `Private` texture of
|
||||
/// this format holds.
|
||||
texel: &'static [u8],
|
||||
/// The raw `MTLTextureUsage` bits the lane makes the texture with.
|
||||
/// The raw `MTLTextureUsage` bits the case makes the texture with.
|
||||
usage: u32,
|
||||
}
|
||||
|
||||
@@ -1123,9 +1117,8 @@ const fn pattern(case: &'static str, format: u32, texel: &'static [u8], usage: u
|
||||
/// Metal's pattern of each format its probes read: a new `Private` 64-square texture of the format
|
||||
/// reads these bytes in every texel.
|
||||
///
|
||||
/// The table is the lane's, transcribed with each format's raw `MTLPixelFormat` so a case can name
|
||||
/// one with no public name as readily as a public one. Each row records Metal's own answer, so what
|
||||
/// the lane kept as a literal is now measured.
|
||||
/// The table names each format by its raw `MTLPixelFormat`, so a case can name one with no public
|
||||
/// name as readily as a public one. Each row records Metal's own answer.
|
||||
const PATTERNS: &[Pattern] = &[
|
||||
pattern("fresh-pattern-1", 1, &[0xff], READ), // MTLPixelFormatA8Unorm
|
||||
pattern("fresh-pattern-10", 10, &[0xff], READ), // MTLPixelFormatR8Unorm
|
||||
@@ -1274,8 +1267,8 @@ impl Pattern {
|
||||
}
|
||||
}
|
||||
|
||||
/// The bytes a read of the whole texture answers. The cross-check against the lane's table is
|
||||
/// what reads it, so it is the tests' alone.
|
||||
/// The bytes a read of the whole texture answers. The cross-check against [`PATTERNS`] is what
|
||||
/// reads it, so it is the tests' alone.
|
||||
#[cfg(test)]
|
||||
fn total(&self) -> u64 {
|
||||
self.shape().total()
|
||||
@@ -1283,7 +1276,7 @@ impl Pattern {
|
||||
|
||||
/// The program the row runs: make the texture and read every texel of it, writing nothing.
|
||||
///
|
||||
/// Nothing is released here, because the lane's own per-format probe made each texture first.
|
||||
/// Nothing is released here: the case makes each texture once.
|
||||
/// What makes the read honest is the destination: it holds [`BEFORE`] before the copy, so the
|
||||
/// recorded answer is the texture's own bytes and not a copy that never ran.
|
||||
fn program(&self) -> Work {
|
||||
@@ -1354,7 +1347,7 @@ impl Case for FreshPattern {
|
||||
// Textures over a new buffer
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
/// The extent and the row pitch of a texture over a buffer: the lane's own.
|
||||
/// The extent and the row pitch of a texture over a buffer.
|
||||
const OVER_BUFFER: (u64, u64) = (64, 256);
|
||||
|
||||
/// A row of a texture over a new buffer, in one storage mode.
|
||||
@@ -1363,7 +1356,7 @@ pub struct FreshOverBuffer {
|
||||
storage: Storage,
|
||||
}
|
||||
|
||||
/// The two rows of a texture over a new buffer: the storage modes the lane sweeps there.
|
||||
/// The two rows of a texture over a new buffer: the storage modes swept there.
|
||||
const OVER_BUFFERS: [(&str, Storage); 2] = [
|
||||
("fresh-texture-over-buffer-shared", Storage::Shared),
|
||||
("fresh-texture-over-buffer-private", Storage::Private),
|
||||
@@ -2079,7 +2072,7 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// The geometry of a shape is the lane's: a level's extent halves and stops at one, and a
|
||||
/// The geometry of a shape: a level's extent halves and stops at one, and a
|
||||
/// block-compressed level's rows are whole blocks.
|
||||
#[test]
|
||||
fn a_levels_geometry_is_the_lanes() {
|
||||
@@ -2097,7 +2090,7 @@ mod tests {
|
||||
assert_eq!(chain([100, 40], 7, 2).level(2).0, [25, 10]);
|
||||
}
|
||||
|
||||
/// The lane's expectation, as this family states it: zero in every `Shared` and `Managed`
|
||||
/// The expectation, as this family states it: zero in every `Shared` and `Managed`
|
||||
/// texture, Metal's pattern in a `Private` one's patterned levels and zero in the rest.
|
||||
#[test]
|
||||
fn the_expectation_is_the_lanes_rule() {
|
||||
@@ -2121,14 +2114,14 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// **The cross-check the port owes the lane.** Metal's own bytes, as the committed recordings
|
||||
/// hold them, are the bytes the lane expects: the old bytes come back out of the written
|
||||
/// resource, and the fresh one reads zero or Metal's pattern by the lane's rule.
|
||||
/// **The cross-check of the recordings.** Metal's own bytes, as the committed recordings hold
|
||||
/// them, are the bytes the rule expects: the old bytes come back out of the written resource,
|
||||
/// and the fresh one reads zero or Metal's pattern ([`Shape::expected_fresh`]).
|
||||
///
|
||||
/// Without this the port would be a set of recordings nobody had compared with the lane that
|
||||
/// justified writing them.
|
||||
/// Without this the recordings would be bytes nobody had compared with the rule that justified
|
||||
/// writing them.
|
||||
#[test]
|
||||
fn metals_texels_are_the_lanes_expectation() {
|
||||
fn metals_texels_are_the_rules_expectation() {
|
||||
// A buffer of every storage mode and every length: the old bytes come back out of the
|
||||
// written one, and the one made after it was released reads zero.
|
||||
for (case, _) in BUFFERS {
|
||||
@@ -2146,8 +2139,8 @@ mod tests {
|
||||
);
|
||||
}
|
||||
}
|
||||
// A texture of every shape: the old bytes come back, and the fresh one reads the lane's
|
||||
// rule — zero, or Metal's pattern in a `Private` one's patterned levels.
|
||||
// A texture of every shape: the old bytes come back, and the fresh one reads the rule —
|
||||
// zero, or Metal's pattern in a `Private` one's patterned levels.
|
||||
for row in TEXTURES {
|
||||
assert_eq!(
|
||||
recorded_bytes(row.case, "written"),
|
||||
@@ -2162,7 +2155,7 @@ mod tests {
|
||||
row.case
|
||||
);
|
||||
}
|
||||
// Each format's pattern: every texel of a new `Private` texture holds the lane's bytes.
|
||||
// Each format's pattern: every texel of a new `Private` texture holds the table's bytes.
|
||||
for row in PATTERNS {
|
||||
let texels = row.total() as usize / row.texel.len();
|
||||
assert_eq!(
|
||||
|
||||
@@ -27,20 +27,19 @@
|
||||
//! The `one-zero` site is also the **source** read back: a source factor of one and a destination
|
||||
//! factor of zero writes the `half4` the function returned through the attachment's own conversion
|
||||
//! and nothing else, so the case does not need a separate unblended draw to know what the device
|
||||
//! computed for the source — which is the property the lane's own extra draw was there for.
|
||||
//! computed for the source.
|
||||
//!
|
||||
//! **The lane's twenty-two blends, less its `off` row, are all here.** The one it has and this
|
||||
//! family does not is blending disabled, and the `one-zero` site stands for it for the reason
|
||||
//! above. The four whose factors read the **blend colour** (`BlendColor`, `OneMinusBlendColor`,
|
||||
//! `BlendAlpha`, `OneMinusBlendAlpha`) are `bc-1mbc`, `1mbc-zero`, `ba-1mba` and `bc-1msa`, and
|
||||
//! every pass sets the lane's own blend colour, `(0.3, 0.6, 0.9, 0.45)`, not one channel of which
|
||||
//! is exact in `half`.
|
||||
//! **Twenty-one blends.** Blending disabled is not one of them: the `one-zero` site stands for it
|
||||
//! for the reason above. The four whose factors read the **blend colour** (`BlendColor`,
|
||||
//! `OneMinusBlendColor`, `BlendAlpha`, `OneMinusBlendAlpha`) are `bc-1mbc`, `1mbc-zero`, `ba-1mba`
|
||||
//! and `bc-1msa`, and every pass sets the blend colour `(0.3, 0.6, 0.9, 0.45)`, not one channel of
|
||||
//! which is exact in `half`.
|
||||
//!
|
||||
//! # The finding those four rows were ported for, now measured
|
||||
//! # Whether Metal rounds the blend colour before its one minus
|
||||
//!
|
||||
//! They are the rows behind the lane's claim that Metal reads the blend colour's `half`
|
||||
//! **before** its one minus (`h(1 - h(c))`), a rule the lane fitted from one lane of one format
|
||||
//! and whose numbers went to a terminal. **On this chip and this OS it is the other way round.**
|
||||
//! Those four rows ask whether Metal reads the blend colour's `half` **before** its one minus
|
||||
//! (`h(1 - h(c))`) or takes the complement first (`h(1 - c)`). **On this chip and this OS it takes
|
||||
//! the complement first.**
|
||||
//!
|
||||
//! Measured over all 1,792 words of `1mbc-zero` in the three 16-bit float formats, on an Apple M3
|
||||
//! Max under macOS 27.0.1 (26A434): **252 words can tell the two rules apart, and every one of
|
||||
@@ -53,14 +52,13 @@
|
||||
//!
|
||||
//! **All 252 of them are `RGBA16Float`'s blue channel**, whose blend colour is 0.9. At 0.3, 0.6 and
|
||||
//! 0.45 the two rules give the same factor at every source value of the sweep, so the one- and
|
||||
//! two-channel formats cannot reach the question — which is why the lane's fit rested on the blue
|
||||
//! lane, and why these rows need the four-channel format rather than asking one question six
|
||||
//! times. A float target cannot reach it either: at `f32` the complement of the colour is the same
|
||||
//! number both ways round, which is the structural reason the lane's finding never showed in
|
||||
//! `blend_sweeps`.
|
||||
//! two-channel formats cannot reach the question, and these rows need the four-channel format
|
||||
//! rather than asking one question six times. A float target cannot reach it either: at `f32` the
|
||||
//! complement of the colour is the same number both ways round, which is why `blend_sweeps` cannot
|
||||
//! show it.
|
||||
//!
|
||||
//! The lane's header dates its fit to macOS 26.7. The live M3 is the oracle, so the 27.0.1 answer
|
||||
//! recorded here is what this family states, and nothing in it asserts the older rule.
|
||||
//! The live M3 is the oracle, so the 27.0.1 answer recorded here is what this family states, and
|
||||
//! nothing in it asserts the other rule.
|
||||
//!
|
||||
//! **What Metal does, measured over every word.** Into each format Metal rounds the **source**
|
||||
//! product to the attachment's precision and carries the **destination** product into the sum
|
||||
@@ -114,8 +112,8 @@ const PIXELS: usize = (WIDTH * HEIGHT) as usize;
|
||||
/// The source halves, as exact codes: `k / 16 - 2` for `k` in 0 to 63, which is every sixteenth
|
||||
/// between -2 and 2 and is exact in `half` at every one of them.
|
||||
///
|
||||
/// It holds both of the lane's sweeps between them: its -0.25 to 1.25 and its -2 to 2, with 0, both
|
||||
/// unit values and the values past one that a `1 - x` factor turns negative.
|
||||
/// It holds two sweeps between them: -0.25 to 1.25 and -2 to 2, with 0, both unit values and the
|
||||
/// values past one that a `1 - x` factor turns negative.
|
||||
const SOURCES: usize = 64;
|
||||
|
||||
/// How far apart two channels of one pixel are in the sweep, so each source value lands at every
|
||||
@@ -200,7 +198,7 @@ impl Rng {
|
||||
/// the attachment holds exactly could not tell a factor that rounds the colour before its one minus
|
||||
/// from one that does not.
|
||||
///
|
||||
/// Every pass sets it, not only the four rows whose factors read it, as the lane's every draw did.
|
||||
/// Every pass sets it, not only the four rows whose factors read it.
|
||||
/// Once a pass and never twice: Metal's own API validation layer stops a pass that sets the blend
|
||||
/// colour and then sets it again ([`super::blend_sweeps`] records that), and a second call here
|
||||
/// would cost all six cases their validated leg.
|
||||
@@ -212,10 +210,10 @@ struct Sweep {
|
||||
blend: Blend,
|
||||
}
|
||||
|
||||
/// The twenty-one blends of the lane's twenty-two that a pipeline of this family states.
|
||||
/// The twenty-one blends a pipeline of this family states.
|
||||
///
|
||||
/// The one the lane has and this family does not is its `off` row, blending disabled, and
|
||||
/// [`Sweep::name`]'s `one-zero` is what stands for it: a source factor of one and a destination
|
||||
/// Blending disabled is not one of them, and [`Sweep::name`]'s `one-zero` is what stands for it: a
|
||||
/// source factor of one and a destination
|
||||
/// factor of zero stores the `half` the function returned through the attachment's own conversion
|
||||
/// and nothing else, which is what an unblended draw would say.
|
||||
fn blends() -> Vec<Sweep> {
|
||||
@@ -253,8 +251,8 @@ fn blends() -> Vec<Sweep> {
|
||||
O::ReverseSubtract,
|
||||
),
|
||||
under("one-one-sub", F::One, F::One, O::Subtract),
|
||||
// The four whose factors read the blend colour. They are the rows that reach the lane's
|
||||
// finding about `1 - c`: `1mbc-zero` isolates the factor (its destination term is zero, so
|
||||
// The four whose factors read the blend colour. They are the rows that reach the question
|
||||
// of `1 - c`: `1mbc-zero` isolates the factor (its destination term is zero, so
|
||||
// the stored code is one rounding of the factor times the source) and the other three put
|
||||
// the same colour through a sum, an alpha channel and a mixed pair.
|
||||
added("bc-1mbc", F::BlendColor, F::OneMinusBlendColor),
|
||||
@@ -270,12 +268,12 @@ pub struct HalfOutputBlends {
|
||||
format: PixelFormat,
|
||||
/// The channels the format's texel holds, which is how many of the `half4` reach it.
|
||||
channels: u32,
|
||||
/// Whether a channel is a 32-bit float, where the lane fitted a multiply-add in `float`
|
||||
/// rather than a blend in `half`.
|
||||
/// Whether a channel is a 32-bit float, where Metal blends as a multiply-add in `float` rather
|
||||
/// than a blend in `half`.
|
||||
wide: bool,
|
||||
}
|
||||
|
||||
/// Every format the lane blends into.
|
||||
/// Every format the family blends into.
|
||||
pub fn all() -> Vec<HalfOutputBlends> {
|
||||
let case = |name, format, channels, wide| HalfOutputBlends {
|
||||
name,
|
||||
@@ -317,8 +315,8 @@ impl HalfOutputBlends {
|
||||
/// The destination value of channel `channel` of pixel `pixel`, as the format stores it: a
|
||||
/// value in `[0, 1]` off the generator, exact in the format's own channel.
|
||||
///
|
||||
/// The lane's destinations were random halves and random `float`s in `[0, 1]`; these are the
|
||||
/// same shape from a generator the case states, so a host with no Metal builds the same bytes.
|
||||
/// The destinations are random halves and random `float`s in `[0, 1]`, from a generator the
|
||||
/// case states, so a host with no Metal builds the same bytes.
|
||||
fn destination_bytes(&self) -> Vec<u8> {
|
||||
let mut generator = Rng::new(u64::from(self.format.as_raw()));
|
||||
let mut bytes = Vec::with_capacity(self.level_bytes());
|
||||
@@ -342,7 +340,7 @@ impl HalfOutputBlends {
|
||||
}
|
||||
|
||||
/// The target each pass blends into: shared, so the destination codes go in through
|
||||
/// `replaceRegion:`, and shader-read beside its render-target usage, as the lane's were.
|
||||
/// `replaceRegion:`, and shader-read beside its render-target usage.
|
||||
fn target(&self) -> TargetSpec {
|
||||
TargetSpec::read(self.format, [WIDTH, HEIGHT]).shared()
|
||||
}
|
||||
@@ -475,7 +473,7 @@ impl Case for HalfOutputBlends {
|
||||
&format!("target/{}", sweep.name),
|
||||
side.target(&self.target()),
|
||||
)?;
|
||||
// The destination codes go in before the pass, as the lane's probe put them there: a
|
||||
// The destination codes go in before the pass: a
|
||||
// blend's answer depends on them, and no clear or kernel write can set an arbitrary
|
||||
// code.
|
||||
call(
|
||||
@@ -552,7 +550,7 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// Every source value is exact in `half` and the sweep spans both of the lane's ranges, so the
|
||||
/// Every source value is exact in `half` and the sweep spans both ranges, so the
|
||||
/// function's `half4` carries the case's own numbers and the blend's rounding is the only
|
||||
/// rounding in the answer.
|
||||
#[test]
|
||||
@@ -604,7 +602,7 @@ mod tests {
|
||||
/// blend, or one name for two, would record two answers to one question.
|
||||
///
|
||||
/// And each of `MTLBlendFactor`'s four blend-colour factors is in some row, so a row that lost
|
||||
/// its factor fails here rather than leaving the lane's finding unreachable again.
|
||||
/// its factor fails here rather than leaving the blend colour's question unreachable.
|
||||
#[test]
|
||||
fn the_blends_are_distinct_by_name_and_by_state() {
|
||||
let sweeps = blends();
|
||||
@@ -678,7 +676,7 @@ mod tests {
|
||||
assert_eq!(formats.len(), all().len());
|
||||
}
|
||||
|
||||
/// The three blends whose answer the lane's rule pins with no rounding to argue about, held
|
||||
/// The three blends whose answer a rule pins with no rounding to argue about, held
|
||||
/// against Metal's own recorded codes for every pixel and every channel of every format:
|
||||
///
|
||||
/// - `one-zero` stores the source through the attachment's conversion and nothing else;
|
||||
@@ -686,9 +684,8 @@ mod tests {
|
||||
/// the source's and the destination's own values.
|
||||
///
|
||||
/// The other fourteen blends involve a product and a sum whose rounding is the subject, so
|
||||
/// their answer is Metal's recording and not a model. This is the part of the fit that can be
|
||||
/// checked rather than believed, and it is the strongest thing the port can say without
|
||||
/// restating the lane's whole model.
|
||||
/// their answer is Metal's recording and not a model. This is the part of the rule that can be
|
||||
/// checked rather than believed without a whole model of the blend's rounding.
|
||||
#[test]
|
||||
fn metals_recorded_codes_hold_the_three_blends_the_rule_pins() {
|
||||
for case in all() {
|
||||
@@ -849,19 +846,16 @@ mod tests {
|
||||
/// `1 - c`. On this chip and this OS it does not**, held against Metal's own recorded codes at
|
||||
/// every word where the two candidate rules disagree.
|
||||
///
|
||||
/// This is what the four blend-colour rows were ported for. The lane fitted `h(1 - h(c))` from
|
||||
/// one lane of one format and printed the numbers to a terminal, and this is the first
|
||||
/// committed measurement of it: over all 1,792 words of `1mbc-zero` in the three 16-bit float
|
||||
/// formats, on an Apple M3 Max under macOS 27.0.1 (26A434), **252 words can tell the two rules
|
||||
/// apart and every one of them stores the complement-first value** -- `h(1 - c)`, the
|
||||
/// complement taken in the `float` the colour arrived as and rounded once. None stores
|
||||
/// `h(1 - h(c))`, and no word fits neither rule.
|
||||
/// This is the question the four blend-colour rows ask. Over all 1,792 words of `1mbc-zero` in
|
||||
/// the three 16-bit float formats, on an Apple M3 Max under macOS 27.0.1 (26A434), **252 words
|
||||
/// can tell the two rules apart and every one of them stores the complement-first value** --
|
||||
/// `h(1 - c)`, the complement taken in the `float` the colour arrived as and rounded once. None
|
||||
/// stores `h(1 - h(c))`, and no word fits neither rule.
|
||||
///
|
||||
/// So the lane's rule is not this OS's. The lane's own header dates its fit to macOS 26.7, and
|
||||
/// the live M3 is the oracle, so what stands is the 27.0.1 answer recorded here; nothing in
|
||||
/// this family asserts the older one.
|
||||
/// The live M3 is the oracle, so what stands is the 27.0.1 answer recorded here; nothing in
|
||||
/// this family asserts the other rule.
|
||||
///
|
||||
/// **`1mbc-zero` is the site that can answer it and the reason it was ported.** Its
|
||||
/// **`1mbc-zero` is the site that can answer it.** Its
|
||||
/// destination factor is `Zero`, so the destination term is exactly zero whatever the sum's
|
||||
/// rounding does, and the stored code is one rounding of the factor times the source: the
|
||||
/// factor is the only thing in the answer. Every other blend-colour row puts the colour
|
||||
@@ -869,9 +863,8 @@ mod tests {
|
||||
///
|
||||
/// **All 252 separating words are `RGBA16Float`'s blue channel**, whose blend colour is 0.9.
|
||||
/// At 0.3, 0.6 and 0.45 the two rules give the same factor at every source value of the sweep,
|
||||
/// so the one-channel and two-channel formats cannot answer the question at all. That is why
|
||||
/// the lane's fit rested on the blue lane, and it is why the ported rows need the
|
||||
/// four-channel format rather than being the same question six times.
|
||||
/// so the one-channel and two-channel formats cannot answer the question at all, and the rows
|
||||
/// need the four-channel format rather than being the same question six times.
|
||||
///
|
||||
#[test]
|
||||
fn metals_recorded_codes_round_the_blend_colour_before_its_one_minus() {
|
||||
@@ -914,8 +907,7 @@ mod tests {
|
||||
for channel in 0..case.channels {
|
||||
let colour = exact(BLEND_COLOR[channel as usize]);
|
||||
let value = exact(source((pixel + STRIDE * channel as usize) % SOURCES));
|
||||
// The colour rounded to the attachment first, then its complement rounded:
|
||||
// the lane's fitted rule.
|
||||
// The colour rounded to the attachment first, then its complement rounded.
|
||||
let before = round(one - round(colour));
|
||||
// The complement taken in the `float` the colour arrived as, rounded once.
|
||||
let after = round(one - colour);
|
||||
@@ -964,8 +956,7 @@ mod tests {
|
||||
);
|
||||
// And all of them are one channel of one format: `RGBA16Float`'s blue, whose blend colour
|
||||
// is 0.9. The other three channels never separate the rules at this source sweep, which is
|
||||
// why the lane's own fit rested on that one lane and why this family needs the four-channel
|
||||
// format to ask the question at all.
|
||||
// why this family needs the four-channel format to ask the question at all.
|
||||
assert_eq!(
|
||||
breakdown,
|
||||
std::collections::BTreeMap::from([(("half-output-blends-rgba16f", 2), 252)]),
|
||||
|
||||
@@ -29,15 +29,13 @@
|
||||
//! bytes by construction and a difference between those two columns cannot be a difference of
|
||||
//! input.
|
||||
//!
|
||||
//! **What recording the three accesses together found, which the lane could not say.** One source
|
||||
//! value in the whole sweep makes them disagree: a 32-bit float texel holding the largest finite
|
||||
//! `float` (`0x7f7fffff`) comes back as `0x7c00`, the infinity of its sign, through both `read()`s
|
||||
//! and as `0x7bff`, the largest `half`, through the nearest sample. The lane allowed either value
|
||||
//! for a lane past `half`'s range -- its own words are "infinity of its sign, or 65504 where the
|
||||
//! device's conversion rounds toward zero" -- but it compared one access at a time, so it never
|
||||
//! said that Metal itself answers both, on the same texel, in the same kernel. Nothing else in the
|
||||
//! sweep separates a fetch from a nearest sample on this chip, which the cross-check below asserts
|
||||
//! rather than observes.
|
||||
//! **What recording the three accesses together found.** One source value in the whole sweep makes
|
||||
//! them disagree: a 32-bit float texel holding the largest finite `float` (`0x7f7fffff`) comes back
|
||||
//! as `0x7c00`, the infinity of its sign, through both `read()`s and as `0x7bff`, the largest
|
||||
//! `half`, through the nearest sample. So Metal itself answers both bounds of a native conversion
|
||||
//! past `half`'s range (the infinity of its sign, or 65504 where the conversion rounds toward
|
||||
//! zero), on the same texel, in the same kernel. Nothing else in the sweep separates a fetch from a
|
||||
//! nearest sample on this chip, which the cross-check below asserts rather than observes.
|
||||
//!
|
||||
//! **Where our side differs from Metal, measured over every word.** On this round's MoltenVK
|
||||
//! (Apple M3 Max, API 1.2) the three 16-bit float formats are `divergent` and the other five are
|
||||
@@ -112,7 +110,7 @@ const LANE_BYTES: usize = 48;
|
||||
/// The byte every output word holds before the dispatch.
|
||||
pub const BLANK: u8 = 0xab;
|
||||
|
||||
/// The halves of the 16-bit float formats, in the lane's own order: quiet and signalling NaNs of
|
||||
/// The halves of the 16-bit float formats, in order: quiet and signalling NaNs of
|
||||
/// both signs and both payload edges, then the infinities, the denormals, the zeros and the
|
||||
/// normals.
|
||||
const V: [u16; 24] = [
|
||||
@@ -183,7 +181,7 @@ pub struct HalfTexelNans {
|
||||
kind: Kind,
|
||||
}
|
||||
|
||||
/// Every format the lane reads: the three 16-bit float widths, the three 32-bit float widths, and
|
||||
/// Every format the case reads: the three 16-bit float widths, the three 32-bit float widths, and
|
||||
/// the two packed ones.
|
||||
pub fn all() -> Vec<HalfTexelNans> {
|
||||
let case = |name, format, channels, kind| HalfTexelNans {
|
||||
@@ -282,12 +280,12 @@ impl HalfTexelNans {
|
||||
}
|
||||
}
|
||||
|
||||
/// `RG11B10Float`'s texel `index`, as the lane packs one.
|
||||
/// `RG11B10Float`'s texel `index`.
|
||||
fn small_float(index: usize) -> u32 {
|
||||
R11[index % 12] | R11[(index + 5) % 12] << 11 | B10[(index + 3) % 12] << 22
|
||||
}
|
||||
|
||||
/// `RGB9E5Float`'s texel `index`, as the lane packs one.
|
||||
/// `RGB9E5Float`'s texel `index`.
|
||||
fn shared_exponent(index: usize) -> u32 {
|
||||
let at = index as u32;
|
||||
let (red, green, blue) = ((at * 37) & 511, (at * 101 + 7) & 511, (at * 13 + 300) & 511);
|
||||
@@ -491,10 +489,10 @@ mod tests {
|
||||
/// The `half` word Metal's rule gives channel `channel` of texel `index` for a one-texel
|
||||
/// access, or `None` where the rule names no exact word.
|
||||
///
|
||||
/// The rule is the lane's: a 16-bit float texel's NaN keeps its own bits; every other NaN is
|
||||
/// `0x7e00`; a missing green or blue reads 0 and a missing alpha 1. A finite channel of a
|
||||
/// format whose conversion to `half` the lane never pinned has no exact word here, and the
|
||||
/// cross-check only asks that it is not a NaN.
|
||||
/// The rule: a 16-bit float texel's NaN keeps its own bits; every other NaN is `0x7e00`; a
|
||||
/// missing green or blue reads 0 and a missing alpha 1. A finite channel of a format whose
|
||||
/// conversion to `half` the rule does not pin has no exact word here, and the cross-check only
|
||||
/// asks that it is not a NaN.
|
||||
fn metal_half(case: &HalfTexelNans, index: usize, channel: usize) -> Option<u16> {
|
||||
if channel >= case.channels {
|
||||
return Some(if channel == 3 { 0x3c00 } else { 0x0000 });
|
||||
@@ -606,19 +604,16 @@ mod tests {
|
||||
assert!(E5.contains(&31));
|
||||
}
|
||||
|
||||
/// Metal's recorded `half` words are the rule the lane measured: a 16-bit float texel's NaN
|
||||
/// keeps its bits, every other NaN is `0x7e00`, and `RGB9E5Float` holds no NaN at all.
|
||||
/// Metal's recorded `half` words are the rule: a 16-bit float texel's NaN keeps its bits, every
|
||||
/// other NaN is `0x7e00`, and `RGB9E5Float` holds no NaN at all.
|
||||
///
|
||||
/// This is the cross-check the port exists for. The lane holds its rule in a function and
|
||||
/// asserts a live device against it, which says nothing on a host with no Metal; here the rule
|
||||
/// is held against Metal's own recorded answer, so a release that changes Metal's conversion
|
||||
/// shows as the texel that moved.
|
||||
/// The rule is held against Metal's own recorded answer, so a release that changes Metal's
|
||||
/// conversion shows as the texel that moved.
|
||||
///
|
||||
/// It also pins the one place the three accesses **disagree**, which recording them found:
|
||||
/// a 32-bit float texel beyond `half`'s range reads as the infinity of its sign through the
|
||||
/// two `read()`s and as 65504 through the nearest sample. The lane allowed either value
|
||||
/// without saying which access gave which, because it only ever compared one access at a time.
|
||||
/// So the accesses are compared here where the rule names a word and the disagreement is
|
||||
/// It also pins the one place the three accesses **disagree**, which recording them found: a
|
||||
/// 32-bit float texel beyond `half`'s range reads as the infinity of its sign through the two
|
||||
/// `read()`s and as 65504 through the nearest sample. Either is a bound of a native conversion,
|
||||
/// so the accesses are compared here where the rule names a word and the disagreement is
|
||||
/// counted where it does not, rather than asserted away in either direction.
|
||||
#[test]
|
||||
fn metals_recorded_halves_are_the_rule_the_lane_measured() {
|
||||
@@ -672,15 +667,15 @@ mod tests {
|
||||
assert_eq!(
|
||||
lanes[at], want,
|
||||
"{} {access} texel {index} channel {channel}: Metal recorded \
|
||||
{:#06x}, the lane's rule is {want:#06x}",
|
||||
{:#06x}, the rule is {want:#06x}",
|
||||
case.name, lanes[at]
|
||||
);
|
||||
}
|
||||
}
|
||||
// A channel the lane pinned no word for: every access must still answer
|
||||
// A channel the rule pins no word for: every access must still answer
|
||||
// something that is not a NaN, and a value beyond `half`'s range must be
|
||||
// the infinity of its sign or the largest half of its sign -- the two
|
||||
// answers the lane recorded as the bound of a native conversion.
|
||||
// bounds of a native conversion.
|
||||
None => {
|
||||
for (access, lanes) in ACCESS_SITES.iter().zip(&halves) {
|
||||
let got = lanes[at];
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
//! that were there rather than as a zero nobody can tell from a result; an `Accumulate` shape's
|
||||
//! starts as the words it adds to.
|
||||
//!
|
||||
//! The lane's own table was measured on an M4, and its comment says so. Metal's answer here is
|
||||
//! **run**, not copied: record mode takes it on this M3 Max, and this module's tests cross-check
|
||||
//! the recordings against the lane's words, which is the evidence the port owes the lane. A fresh
|
||||
//! answer that disagrees with the lane is a finding about one of the two chips, not a nuisance.
|
||||
//! The table of words this module's tests hold was measured on an Apple M4. Metal's answer here is
|
||||
//! **run**, not copied: record mode takes it on an M3 Max, and the tests cross-check the
|
||||
//! recordings against the table. A fresh answer that disagrees with the table is a finding about
|
||||
//! one of the two chips, not a nuisance.
|
||||
//!
|
||||
//! Every word compares exactly, a `Boolean` result's included: the M3 Max writes 1 where a sample
|
||||
//! passed.
|
||||
@@ -73,13 +73,13 @@ use crate::values::{StoreAction, VisibilityResultMode, VisibilityResultType};
|
||||
use metal2vulkan::metal::state::DepthStencilDescriptor;
|
||||
use metal2vulkan::metal::{CompareFunction, PixelFormat, PrimitiveType};
|
||||
|
||||
/// The owned fixture the lane draws with: `rt6_full` takes a depth and a slope as one `float2` at
|
||||
/// The owned fixture the case draws with: `rt6_full` takes a depth and a slope as one `float2` at
|
||||
/// vertex buffer 0, and `rt6_white` returns white.
|
||||
const FIXTURE: &str = "rt6_render_state";
|
||||
const VERTEX: &str = "rt6_full";
|
||||
const FRAGMENT: &str = "rt6_white";
|
||||
|
||||
/// The lane's target: a 4 by 4 `RGBA8Unorm` render target, whose 16 pixels are the 16 samples a
|
||||
/// The target: a 4 by 4 `RGBA8Unorm` render target, whose 16 pixels are the 16 samples a
|
||||
/// covering draw passes at 1x.
|
||||
const SIDE: u32 = 4;
|
||||
const COLOR: PixelFormat = PixelFormat::RGBA8Unorm;
|
||||
@@ -87,10 +87,10 @@ const COLOR: PixelFormat = PixelFormat::RGBA8Unorm;
|
||||
/// The byte every visibility buffer starts as, so a word Metal never wrote is readable as itself.
|
||||
const UNWRITTEN: u8 = 0xaa;
|
||||
|
||||
/// The depth the lane's draws take unless the shape says otherwise.
|
||||
/// The depth the draws take unless the shape says otherwise.
|
||||
const DEPTH: f32 = 0.5;
|
||||
|
||||
/// One command a case encodes into a pass, in the lane's own vocabulary.
|
||||
/// One command a case encodes into a pass.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
enum Act {
|
||||
/// `setVisibilityResultMode:offset:`.
|
||||
@@ -103,12 +103,12 @@ enum Act {
|
||||
instances: u32,
|
||||
},
|
||||
/// `drawPrimitives:indirectBuffer:indirectBufferOffset:` of three vertices and **no**
|
||||
/// instances, which the lane's arguments buffer holds.
|
||||
/// instances, which the arguments buffer holds.
|
||||
DrawIndirect,
|
||||
}
|
||||
|
||||
impl Act {
|
||||
/// The fullscreen triangle at the lane's depth, covering every pixel.
|
||||
/// The fullscreen triangle at [`DEPTH`], covering every pixel.
|
||||
const fn draw() -> Self {
|
||||
Act::Draw {
|
||||
z: DEPTH,
|
||||
@@ -143,10 +143,10 @@ struct Shape {
|
||||
/// 64-bit words the case's visibility buffer holds.
|
||||
words: usize,
|
||||
/// The passes, in order, each over its own fresh color target and all over **one** visibility
|
||||
/// buffer, as the lane runs them.
|
||||
/// buffer.
|
||||
passes: &'static [&'static [Act]],
|
||||
depth: Option<Depth>,
|
||||
/// `rasterSampleCount` and the attachment's samples: 1, or 4 for the lane's 4x pass.
|
||||
/// `rasterSampleCount` and the attachment's samples: 1, or 4 for the 4x pass.
|
||||
samples: u32,
|
||||
/// Every pass's `visibilityResultType`.
|
||||
kind: VisibilityResultType,
|
||||
@@ -157,7 +157,7 @@ struct Shape {
|
||||
joined: bool,
|
||||
}
|
||||
|
||||
/// `Boolean`, `Counting` and `Disabled`, as short as the lane writes them.
|
||||
/// `Boolean`, `Counting` and `Disabled`, short.
|
||||
const BOOL: VisibilityResultMode = VisibilityResultMode::Boolean;
|
||||
const COUNT: VisibilityResultMode = VisibilityResultMode::Counting;
|
||||
const OFF: VisibilityResultMode = VisibilityResultMode::Disabled;
|
||||
@@ -967,7 +967,7 @@ struct Held<'a> {
|
||||
}
|
||||
|
||||
impl Visibility {
|
||||
/// Pass `index` of the shape: a fresh target, as the lane makes one a pass, so no pass reads
|
||||
/// Pass `index` of the shape: a fresh target, so no pass reads
|
||||
/// what another left in the color attachment, its acts as steps, and its depth attachment
|
||||
/// where the shape has one.
|
||||
fn pass(
|
||||
@@ -1077,7 +1077,8 @@ mod tests {
|
||||
/// A word Metal never wrote, as a 64-bit value.
|
||||
const U: u64 = u64::from_le_bytes([UNWRITTEN; 8]);
|
||||
|
||||
/// The lane's words, by case: what Metal wrote after each command buffer, in order.
|
||||
/// The table, measured on an Apple M4, by case: what Metal wrote after each command buffer, in
|
||||
/// order.
|
||||
const TABLE: &[(&str, &[&[u64]])] = &[
|
||||
(
|
||||
"visibility-boolean-offsets",
|
||||
@@ -1095,7 +1096,7 @@ mod tests {
|
||||
("visibility-counting-revisit", &[&[32, 16]]),
|
||||
("visibility-counting-revisit-after-disabled", &[&[32, U]]),
|
||||
("visibility-counting-four-samples", &[&[64]]),
|
||||
// The `Accumulate` rows, the lane's too: a count is added to the word's low 32 bits,
|
||||
// The `Accumulate` rows: a count is added to the word's low 32 bits,
|
||||
// which wrap, and its high 32 bits stay.
|
||||
(
|
||||
"visibility-counting-accumulate",
|
||||
@@ -1113,7 +1114,7 @@ mod tests {
|
||||
"visibility-boolean-accumulate",
|
||||
&[&[1, 3, 3, 0, 2, 3, 9], &[1, 3, 3, 1, 2, 3, 9]],
|
||||
),
|
||||
// Not the lane's: no mode writes nothing, under either type (an M3 Max, macOS 27.0.1).
|
||||
// Taken on an M3 Max, macOS 27.0.1, not the M4: no mode writes nothing, under either type.
|
||||
("visibility-disabled-reset", &[&[U, U], &[U, U]]),
|
||||
("visibility-disabled-accumulate", &[&[100, 7], &[100, 7]]),
|
||||
];
|
||||
@@ -1149,13 +1150,13 @@ mod tests {
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Metal's own visibility results on this M3 Max are the lane's words, pass by pass.
|
||||
/// Metal's own visibility results on the M3 Max are the table's words, pass by pass.
|
||||
///
|
||||
/// Every case the table names must have a recording, so a case that was never recorded fails
|
||||
/// here rather than being skipped: the table is the claim, and a claim with no run behind it
|
||||
/// is the thing this suite exists to stop.
|
||||
#[test]
|
||||
fn the_recorded_results_are_the_lanes_words() {
|
||||
fn the_recorded_results_are_the_tables_words() {
|
||||
for (name, passes) in TABLE {
|
||||
let shape = SHAPES
|
||||
.iter()
|
||||
@@ -1189,7 +1190,7 @@ mod tests {
|
||||
for case in all() {
|
||||
assert!(
|
||||
TABLE.iter().any(|(name, _)| *name == case.name()),
|
||||
"{}: no row in the lane's table",
|
||||
"{}: no row in the table",
|
||||
case.name()
|
||||
);
|
||||
let inputs = case.inputs().unwrap();
|
||||
|
||||
Reference in new issue
Block a user