One work packet, landed as 9 commits (62c7d7a9f5..378d636d2f on archive/development-linear-2026-10-28), in order:
* Keep the device's copy for blits through a texture Metal compresses
Metal's GPU blit into or out of a texture it keeps losslessly compressed
writes three families' texels in its compressor's canonical encoding:
BGRA10_XR (and its sRGB twin) with each field's low six bits cleared and
the alpha code clamped, RG11B10Float with a NaN made the quiet NaN, and
RGB9E5Float with the shared exponent lowered. The runtime reproduced that
with a crate-owned compute rewrite of the copied rows (bind::CompressedBlit
and its module) after every such blit.
That is Metal's compressor's encoding, not the format's: Metal's own
uncompressed texture of the format keeps the bytes through the same blit,
and every rewritten texel reads the same value either way. The device's
copy, which keeps the bytes, is now the only form. A blit through such a
texture announces the note of the encoding it keeps, once per device:
extended-range-bits-kept (BGRA10_XR), device-nan-encoding (RG11B10Float)
and shared-exponent-kept (RGB9E5Float), each existing kinds; no new kind.
Where the device's own copy already writes Metal's encoding (MoltenVK,
RuntimeDriverDefect::CompressedImageCopiesRewriteTexels) nothing is
announced; the defect's PixelFormatView usage, which keeps CPU copies
byte-exact there, stays.
Removed public items: bind::CompressedBlit, bind::CompressedBlitModule,
bind::compressed_blit_module, WorkCounts::compressed_rows_rewritten.
RUNTIME_VERSION 1740. The conformance recordings' runtime cost records
that count compressed_rows_rewritten (compressed-blits-*, fresh-pattern-*,
xr-clear-routes-*, xr-draw-*) move at the next re-bless.
The compressed-blits lane now asserts the bytes are kept and each format's
note is announced; the conformance case declares the note where it is not
one of the suite's native notes.
Verified: cargo clippy --workspace --all-targets --all-features -D warnings;
RUSTFLAGS='--cfg m2v_gpu' cargo check of runtime and validation; nextest
of blit_plan, degradation, degradation_catalogue, conformance
compressed_blits, unused_bits, fast_paths, owned_divisions, api_surface,
api_signatures and refusal_surface (77 passed). Device lanes and replay
run after the whole series.
* Resolve a fetching pass's sample planes by the device's average
A color attachment whose sample planes held its samples as the pass ended
(framebuffer fetch in the pixel interlock on a device without multisampled
storage images: ANV, MoltenVK) was resolved from the planes by the
crate-owned resolve, which computes Metal's closed rules for every unorm,
snorm, sRGB, 32-bit float, half, packed 16-bit, RG11B10Float and
RGB9E5Float format. Every other color attachment resolves by the device's
AVERAGE. The average is the device's native answer, so it is now the only
form here too: the planes merge back and one more instance of no draws
resolves the attachment, announced device-rounded-resolve where the
driver's average is not measured to be Metal's (on MoltenVK it is,
DriverFact::ColorResolveAverageIsMetals, so nothing is announced there).
The crate-owned resolve keeps the two resolves no device's average writes:
into the attachment's format's sRGB twin (the 8-bit unorm and sRGB rules)
and of an extended-range attachment. Its rules for every other format, and
their tests, are deleted. ColorResolveFormat::of names the twin's eight
formats; sample planes are read only for an extended-range form, and a
module of a twin format from planes is refused.
Removed public items: ResolveRule::{HalfUnorm, Snorm, Float32, Float16,
SmallFloat, SharedExponent}, ResolveRule::bits, ResolveRule::resolves,
ColorResolveFormat::resolves; ResolveRule::Unorm loses its bits field.
Cost: such a pass now merges its planes back and resolves in one more
render pass instance, where it drew one resolve pass from the planes; a
memoryless attachment the pass only fetches and resolves needs a backing.
The ColorResolveAverageIsMetals docs, the shader-resolve and
device-rounded-resolve entries (degradation.rs, docs/API.md) now say what
resolves where. The fetch lanes expect no shader-resolve for a fetched
attachment.
Verified: cargo check --workspace --all-targets --all-features; the GPU
cfg check of runtime and validation; nextest of color_resolve,
sample_planes, degradation, driver_facts, fast_paths, api_surface,
api_signatures, refusal_surface (84 passed). Device lanes run after the
series.
* Clear a float attachment to the clear color as the device converts it
A render pass's Clear of a normalized, sRGB, packed 16-bit, half, float or
small-float color attachment computed Metal's texel on the CPU (its
rounding, its trip through half for the packed 16-bit formats, its
truncated small-float and shared-exponent mantissas) and handed the device
a value that converts back to it; a Depth16Unorm clear took a quarter step
above Metal's truncated code. The conversion is the device's native
answer, so the clear value is now the color (or depth) as a float, which
the device converts.
Where the device's conversion can stand a code from Metal's it is
announced, once per device: device-color-conversion where a normalized
channel's scaled value lies within 1/1024 of a midpoint between two codes
(a packed 16-bit channel's within Metal's half step too), an sRGB channel
lies inside (0, 1), or a half, small float or shared exponent does not
hold the value exactly; unorm-depth-rounding where a Depth16Unorm depth's
scaled value lies at or above a midpoint, which Metal truncates and a
device rounding to nearest takes up. Vulkan asks for rounding to nearest
and leaves ties, sRGB encodes and float rounding to the device. A NaN in a
normalized or RGB9E5Float channel still clears as 0 (Vulkan states no such
conversion); integer, extended-range, word and YCbCr attachments keep
Metal's conversion, which no device makes for them.
Metal's measured conversion moves into the tests as the model they compare
with. The renders lane accepts a device texel a code from Metal's where
the note is announced and prints it; the cleared sRGB resolve lane
compares the resolve with the device's own 1x clear.
UnormDepthRounding's docs and cost, PrecisionNote::DeviceColorConversion's
docs and both docs/API.md entries say so.
Verified: cargo clippy --workspace --all-targets --all-features -D
warnings; the GPU cfg check of validation; nextest of clear_value,
heap_tiled, fresh, nan_clear and degradation (55 passed). Device lanes and
replay run after the series.
* Expect the device's clear conversion in the lanes that clear at a tie
Since 5925c303f8 a clear converts the clear color (and a 16-bit depth)
the device's way, announcing device-color-conversion where a channel
lies at a rounding question (0.5 on an 8-bit unorm channel is 127.5
codes, a tie; any sRGB channel's encode) and unorm-depth-rounding where
a Depth16Unorm clear's fraction reaches the midpoint (Metal truncates).
Lanes that hold exact notice sets or Metal's truncated depth codes now
expect them:
- dont_care_stores: every pass clears through color_pass or earlier()
at 0.5; clear_tie() adds the note to each expected set (MoltenVK's
pipelines record no color-conversion note, so it showed there first).
- resolves: the depth stand-in clears Depth16Unorm to 0.5 (32767.5
codes): Metal's 0x7fff or the device's 0x8000, and the note announced
exactly for that format.
- buffer_depth_samples: the 16-bit clear to 0.25 (16383.75 codes)
announces unorm-depth-rounding.
- buffer_texture_blits: the planar depth clears (0.375, 0.625, 0.875)
hold Metal's truncated code or the one above it, the note's bound.
Verified: the four lanes' failing tests on lavapipe (linux-gate
halfnative) failed before these edits; on MoltenVK (Apple M3 Max,
maclock) dont_care_stores, resolves' depth stand-in,
buffer_depth_samples and the planar depth lane pass with them.
* Merge a fetched attachment's sample planes back before its twin resolve
A pass whose last draws fetch a multisampled attachment through sample
planes (the pixel interlock without multisampled storage images: ANV,
MoltenVK) left the planes unmerged after it under MultisampleResolve
wherever the crate-owned resolve drew the attachment's resolve, on the
reading that that resolve reads the planes. A resolve into the
attachment's sRGB twin is crate-owned but reads the attachment itself
(color_resolve.rs filters its planes out), so it resolved samples the
pass never wrote: on MoltenVK a 4x RGBA8Unorm attachment cleared to 0,
fetched once and resolved into RGBA8Unorm_sRGB read all zeros, where
the same pass stored too resolves (255, 225, 0, 0).
The planes steps now skip the merge only for a resolve that reads the
planes, an extended-range attachment's (the flag is renamed
planes_resolve to say so); a twin resolve merges first, as a stored
attachment does.
Test: runtime_lane::framebuffer_fetch::planes::
a_twin_resolve_of_a_fetched_attachment_reads_its_samples holds the
MultisampleResolve answer to the StoreAndMultisampleResolve one.
Verified on MoltenVK (Apple M3 Max, maclock): the test failed without
the fix (zeros) and passes with it, beside the planes, memoryless,
kept_resolves and twin-resolve lanes (18 passed); the runtime's
sample_planes unit tests pass.
* Expect the clear note in color_reformat's passes, through one helper
color_reformat's passes clear to (0.5, 0.25, 0.75, 1.0), whose red is a
tie in an 8-bit unorm channel, so the device's conversion of the clear
announces device-color-conversion at the device's first such pass.
Lavapipe's pipelines record the note already; MoltenVK's record none
(VkProperty::MetalColorWrites), so its exact notice sets failed there.
degrade_notices::tie_cleared() names that note for every lane whose
passes clear at a tie; dont_care_stores' local helper moves there.
Verified on MoltenVK (Apple M3 Max, maclock): color_reformat and
dont_care_stores pass (they failed in the full runtime_lane run before
this change).
* Hold the kept compressed-blit encodings to the ledger, and declare their notes
Since 01f733c6f0 a blit through a texture Metal keeps losslessly
compressed is the device's copy, which keeps the bytes Metal's
compression rewrites into the canonical encoding. The lavapipe replay
then read 46 rows the ledger did not expect:
- 28 value sites of compressed-blits-{bgra10xr,bgra10xr-srgb,rg11b10f,
rgb9e5f}: the device's bytes against Metal's canonical encoding. Each
is now a known-gaps.tsv row (venue llvmpipe) naming the note that
records it: extended-range-bits-kept, device-nan-encoding,
shared-exponent-kept, whose bound (the same value, another encoding)
covers it. Nothing is open: rule 1 rules out writing Metal's encoding.
- 18 notice sites of fresh-pattern-{552,553,93}, xr-draw-bgra10xr*
and xr-clear-routes-bgra10xr*: their read-backs blit out of such a
texture and announce the note, every value exact. They now declare
it through compressed_blits::kept_encoding_notice, the one table of
which format announces which note (device-nan-encoding is native and
declared for every case already). fresh_contents' row-notice test
counts the three pattern rows' second allowance.
docs/CONFORMANCE-COVERAGE.md regenerated (the ledger's row count).
Verified: conformance replay --cpu on lavapipe (linux-gate halfnative,
arm64): exit 0, 751 rows, exactly the ledger's (723 before the series
plus these 28), 0 unlisted and 0 stale; cargo nextest -p
metal2vulkan-conformance (1005 passed); clippy -D warnings.
* Format owned_divisions' bind import after the rebase
The rebase onto development dropped both CompressedBlit (this series)
and BlockDecode (development's BC twin removal) from the import, which
rustfmt now joins onto one line. No behaviour changes.
Verified: cargo fmt --all --check.
* Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no
longer described the sources and `the_runtime_sources_are_the_committed_ones`
would fail. Recomputed over the same inputs and committed by land-pkt.sh.
207 lines
8.3 KiB
Rust
207 lines
8.3 KiB
Rust
//! The order of a pass's sample-planes steps (`sample_planes.rs`): which copies run before each
|
|
//! render pass instance and after the last, from the instances' left-out attachments and the
|
|
//! attachments' load and store actions; which attachment the fetching draws' subpass keeps as
|
|
//! its anchor (`render_target.rs`); and which formats' copy views keep their components.
|
|
|
|
use super::image_plan::committed;
|
|
use crate::color_list::ColorList;
|
|
use crate::framebuffer_fetch::{through_multisampled_storage, through_planes};
|
|
use crate::render_target::PassShape;
|
|
use crate::render_values::{LoadAction, StoreAction};
|
|
use crate::sample_planes::{ordered_steps, PlanesAttachment, PlanesStep};
|
|
use crate::view_plan::keeps_components;
|
|
use metal2vulkan::bind::PlanesCopy;
|
|
use metal2vulkan::vk::Format;
|
|
use PlanesStep::{Clear, Merge, Split};
|
|
|
|
/// Color attachment `index` with sample planes, loaded and stored by `load` and `store`, which
|
|
/// the device resolves.
|
|
fn attachment(index: u32, load: LoadAction, store: StoreAction) -> PlanesAttachment {
|
|
PlanesAttachment {
|
|
index,
|
|
load,
|
|
store,
|
|
planes_resolve: false,
|
|
}
|
|
}
|
|
|
|
/// A pass of fetching draws alone: its first instance runs the load action on the planes (a
|
|
/// split, a clear, or nothing for `DontCare`), and the merge after the last runs for every store
|
|
/// action but `DontCare`.
|
|
#[test]
|
|
fn the_first_instance_loads_the_planes_and_the_last_stores_them() {
|
|
for (load, before) in [
|
|
(LoadAction::Load, vec![Split(0)]),
|
|
(LoadAction::Clear, vec![Clear(0)]),
|
|
(LoadAction::DontCare, vec![]),
|
|
] {
|
|
for (store, after) in [
|
|
(StoreAction::Store, vec![Merge(0)]),
|
|
(StoreAction::MultisampleResolve, vec![Merge(0)]),
|
|
(StoreAction::StoreAndMultisampleResolve, vec![Merge(0)]),
|
|
(StoreAction::DontCare, vec![]),
|
|
] {
|
|
let steps = ordered_steps(&[attachment(0, load, store)], &[&[0]]);
|
|
assert_eq!(steps, vec![before.clone(), after], "{load:?} {store:?}");
|
|
}
|
|
}
|
|
}
|
|
|
|
/// An attachment the crate-owned resolve reads from the planes merges after the last instance
|
|
/// only where Metal keeps its samples: not for `MultisampleResolve`, for
|
|
/// `StoreAndMultisampleResolve`. Where the last instance draws it, nothing merges after.
|
|
#[test]
|
|
fn a_resolve_from_the_planes_reads_them_without_a_merge() {
|
|
for (store, after) in [
|
|
(StoreAction::MultisampleResolve, vec![]),
|
|
(StoreAction::StoreAndMultisampleResolve, vec![Merge(0)]),
|
|
] {
|
|
let from_planes = PlanesAttachment {
|
|
planes_resolve: true,
|
|
..attachment(0, LoadAction::Clear, store)
|
|
};
|
|
let steps = ordered_steps(&[from_planes], &[&[0]]);
|
|
assert_eq!(steps, vec![vec![Clear(0)], after], "{store:?}");
|
|
let steps = ordered_steps(&[from_planes], &[&[0], &[]]);
|
|
assert_eq!(
|
|
steps,
|
|
vec![vec![Clear(0)], vec![Merge(0)], vec![]],
|
|
"{store:?}"
|
|
);
|
|
}
|
|
}
|
|
|
|
/// An attachment moves into the planes before each instance that leaves it out after one that
|
|
/// did not, and back before each that includes it after one that left it out; only the first
|
|
/// instance's load action applies, and the last instance's steps after it.
|
|
#[test]
|
|
fn the_planes_follow_the_instances_that_leave_their_attachment_out() {
|
|
let fetched = attachment(0, LoadAction::Clear, StoreAction::MultisampleResolve);
|
|
// Fetch, draw, fetch twice: the 4x memoryless pass of `runtime_lane::framebuffer_fetch`.
|
|
let steps = ordered_steps(&[fetched], &[&[0], &[], &[0]]);
|
|
assert_eq!(
|
|
steps,
|
|
vec![
|
|
vec![Clear(0)],
|
|
vec![Merge(0)],
|
|
vec![Split(0)],
|
|
vec![Merge(0)]
|
|
]
|
|
);
|
|
// Draw, then fetch: the first instance's clear is its own load operation.
|
|
let steps = ordered_steps(&[fetched], &[&[], &[0]]);
|
|
assert_eq!(steps, vec![vec![], vec![Split(0)], vec![Merge(0)]]);
|
|
// Fetch, then draw: the last instance stores the attachment itself.
|
|
let steps = ordered_steps(&[fetched], &[&[0], &[]]);
|
|
assert_eq!(steps, vec![vec![Clear(0)], vec![Merge(0)], vec![]]);
|
|
}
|
|
|
|
/// Each attachment's steps follow its own index among the instances' left-out attachments, in
|
|
/// attachment order at each position.
|
|
#[test]
|
|
fn each_attachment_has_its_own_steps() {
|
|
let first = attachment(0, LoadAction::Load, StoreAction::Store);
|
|
let second = attachment(2, LoadAction::DontCare, StoreAction::DontCare);
|
|
let steps = ordered_steps(&[first, second], &[&[0, 2], &[2], &[0]]);
|
|
assert_eq!(
|
|
steps,
|
|
vec![
|
|
vec![Split(0)],
|
|
vec![Merge(0)],
|
|
vec![Split(0), Merge(2)],
|
|
vec![Merge(0)],
|
|
]
|
|
);
|
|
// An attachment no instance leaves out has no step.
|
|
let steps = ordered_steps(&[first, second], &[&[0], &[0]]);
|
|
assert_eq!(steps, vec![vec![Split(0)], vec![], vec![Merge(0)]]);
|
|
}
|
|
|
|
/// A pass of `samples` samples with `colors`, and a depth/stencil attachment where `depth`, whose
|
|
/// draws' subpass leaves out `storage`.
|
|
fn shape(samples: u32, colors: &[Option<Format>], depth: bool, storage: &[u32]) -> PassShape {
|
|
PassShape {
|
|
colors: ColorList::of(colors.iter().copied()).unwrap(),
|
|
depth_stencil: depth.then_some(Format::D32_SFLOAT),
|
|
samples,
|
|
color_resolves: ColorList::of(colors.iter().map(|_| None)).unwrap(),
|
|
depth_stencil_resolve: None,
|
|
fetch_inputs: false,
|
|
no_inputs: ColorList::new(),
|
|
storage: ColorList::of(storage.iter().copied()).unwrap(),
|
|
view_mask: 0,
|
|
locations: ColorList::new(),
|
|
}
|
|
}
|
|
|
|
/// A multisampled subpass that leaves out every attachment it has keeps the first as its anchor
|
|
/// where they are sample planes (a device without multisampled storage images); one with another
|
|
/// attachment, of one sample, or reading input attachments keeps none, and so does one whose
|
|
/// draws write the attachments' own multisampled images (a device with multisampled storage
|
|
/// images), on every committed profile.
|
|
#[test]
|
|
fn a_subpass_left_without_attachments_keeps_its_first_planes() {
|
|
let float = Some(Format::R32_SFLOAT);
|
|
let quad = Some(Format::R8G8B8A8_UNORM);
|
|
let (mut planes, mut own) = (0, 0);
|
|
for (name, _, device) in committed() {
|
|
let profile = device.profile();
|
|
let anchors = through_planes(profile, 4);
|
|
planes += usize::from(anchors);
|
|
own += usize::from(through_multisampled_storage(profile, 4));
|
|
let first = |index: u32| anchors.then_some(index);
|
|
let anchor = |shape: PassShape| shape.anchor(profile);
|
|
assert_eq!(anchor(shape(4, &[float], false, &[0])), first(0), "{name}");
|
|
assert_eq!(
|
|
anchor(shape(4, &[None, float, quad], false, &[1, 2])),
|
|
first(1),
|
|
"{name}"
|
|
);
|
|
assert_eq!(
|
|
anchor(shape(4, &[float, quad], false, &[1])),
|
|
None,
|
|
"{name}"
|
|
);
|
|
assert_eq!(anchor(shape(4, &[float], true, &[0])), None, "{name}");
|
|
assert_eq!(anchor(shape(1, &[float], false, &[0])), None, "{name}");
|
|
assert_eq!(anchor(shape(4, &[float], false, &[])), None, "{name}");
|
|
let inputs = PassShape {
|
|
fetch_inputs: true,
|
|
..shape(4, &[float], false, &[0])
|
|
};
|
|
assert_eq!(anchor(inputs), None, "{name}");
|
|
}
|
|
assert!(planes > 0, "a planes profile");
|
|
assert!(own > 0, "a profile with multisampled storage images");
|
|
}
|
|
|
|
/// The copies' views keep the components of a format of one 8-, 16- or 32-bit component, or of
|
|
/// two or four 32-bit ones, and reinterpret every other's, whose planes a device without view
|
|
/// reinterpretation refuses (`sample_planes.rs`).
|
|
#[test]
|
|
fn the_copy_views_keep_the_components_of_one_component_or_of_32_bit_ones() {
|
|
let keeps = |format: Format| {
|
|
let copy = PlanesCopy::for_format(format).expect("a copy format");
|
|
keeps_components(format, copy.format())
|
|
};
|
|
for format in [
|
|
Format::R8_UNORM,
|
|
Format::R16_SFLOAT,
|
|
Format::R32_SFLOAT,
|
|
Format::R32G32_SFLOAT,
|
|
Format::R32G32B32A32_SFLOAT,
|
|
] {
|
|
assert!(keeps(format), "{format:?}");
|
|
}
|
|
for format in [
|
|
Format::R8G8_UNORM,
|
|
Format::R8G8B8A8_UNORM,
|
|
Format::R16G16_SFLOAT,
|
|
Format::R16G16B16A16_SFLOAT,
|
|
Format::A2B10G10R10_UNORM_PACK32,
|
|
Format::B10G11R11_UFLOAT_PACK32,
|
|
] {
|
|
assert!(!keeps(format), "{format:?}");
|
|
}
|
|
}
|