From e972337dd8fa150d4a4525d626ce8b238f8a0da0 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Mon, 2 Nov 2026 01:49:26 -0800 Subject: [PATCH] Hold ASTC's 4x2 and 8x4 footprints in a carrier with a decoded twin What: the six ASTC formats of Apple's 4x2 and 8x4 footprints (LDR, sRGB, HDR), which no Vulkan format holds, are made on every device as the other ASTC formats are on a device without ASTC: their blocks in the 16-byte carrier (BC7, BC3, BC2, BC5, ETC2 or EAC; one ASTC block over 4 x 4 carrier texels whatever its footprint), their reads through a decoded twin of 8-bit codes (LDR, sRGB) or halves (HDR). `AstcDecode::of` takes every footprint from `metal::format::block_extent`; the format table maps them decoded-only (no direct format); the footprint module answers 26 formats now, and the heap size query takes the modelled ASTC block layout for them. Copies map regions in blocks (`copy_plan::block_bytes`), a partial last block as Metal rounds it. Why: plain Metal makes every such texture (2D, 2D array, cube, 3D; Shared and Private; read, write, render-target usage) and copies them in whole blocks, the last ending at the level's edge (probe `astc_passes_writes_footprints`). The orchestrator's brief suggested an uncompressed 16-byte-texel carrier; the existing compressed carrier already holds any 16-byte block per 4 x 4 carrier texels, so it serves every footprint with the decode passes, CPU decodes, second twins and copy paths the other ASTC formats use, with no new image kind. Tests that fail before: the translator's format tests (`astc_4x2_and_8x4_are_named_and_read_ through_their_twin`, counts and twins), the decode digests of 4x2 and 8x4 against Metal's (`astc_decode` tests, HDR coverage), the runtime's image-plan, heap and pixel-format tests, and the lane: `runtime_lane::astc_textures` and `astc_hdr_textures` now take every footprint (32 LDR and sRGB, 16 HDR), the round trip at every level and slice 4x2 and 8x4 (partial blocks at 37x23 and 29), the colour-space views 4x2 and 8x4. The conformance case `format-footprints-astc-4x2-and-8x4` now makes and round-trips them: its ledger row (the refusal) is gone and it declares the three notices the carrier announces. Verified: translator and runtime touched suites; MoltenVK lane (`runtime_lane::astc*`, 9 of 9 on the M3 Max); conformance replay on MoltenVK of the footprint case and the ASTC cases, compliant (the footprint case announced, every byte Metal's); lavapipe replay: every byte Metal's, the notices undeclared before this commit's declaration. (cherry picked from commit 2a8dd25c6b9d4cc62ff79816fa61d984969b3c22) --- .../metal2vulkan-conformance/known-gaps.tsv | 7 +- .../src/cases/format_footprints.rs | 34 ++++- crates/metal2vulkan-runtime/src/astc.rs | 43 +++--- crates/metal2vulkan-runtime/src/copy_plan.rs | 12 +- crates/metal2vulkan-runtime/src/image_plan.rs | 6 +- .../src/tests/heap_footprint_formats.rs | 28 ++-- .../src/tests/heap_tiled.rs | 11 +- .../src/tests/heap_tiled_blocks.rs | 12 +- .../src/tests/image_plan.rs | 79 +++++++--- .../src/tests/pixel_format_info.rs | 8 +- .../src/tests/view_plan.rs | 2 +- .../src/texture/heap_tiled.rs | 4 +- .../src/runtime_lane/astc_hdr_textures.rs | 9 +- .../src/runtime_lane/astc_textures.rs | 22 ++- crates/metal2vulkan/src/bind/astc_decode.rs | 144 ++++++++---------- .../src/bind/astc_decode/tests.rs | 36 +++-- .../src/bind/astc_decode/tests/hdr.rs | 22 ++- crates/metal2vulkan/src/bind/heap/tests.rs | 2 +- .../src/metal/format/footprint.rs | 30 +--- crates/metal2vulkan/src/metal/format/mod.rs | 37 ++--- crates/metal2vulkan/src/metal/format/tests.rs | 75 +++++---- .../src/tests/engine_graphics_binder.rs | 2 +- docs/API.md | 2 +- docs/FAST-PATHS.md | 22 +-- 24 files changed, 362 insertions(+), 287 deletions(-) diff --git a/crates/metal2vulkan-conformance/known-gaps.tsv b/crates/metal2vulkan-conformance/known-gaps.tsv index e4c1ea805..7c54d2c44 100644 --- a/crates/metal2vulkan-conformance/known-gaps.tsv +++ b/crates/metal2vulkan-conformance/known-gaps.tsv @@ -96,11 +96,10 @@ attribute-stride-buffer * divergent case/nine-strides 7 elements differ (U32), t attribute-stride-plural-buffers * divergent case/nine-strides 7 elements differ (U32), the largest difference 16 Metal's `MTLAttributeStrideStatic` on a `[[stage_in]]` layout of `MTLBufferLayoutStrideDynamic` is not "read at stride 0"; it fetches the element at the bind offset for the FIRST element and hands every element past it ZERO. Measured on this M3 Max (macOS 27.0.1) from these cases' own committed recordings: a dynamic layout over a buffer holding `0x10 + e` at element `e`, eight threads stepping by thread position in x at rate 1, bound with the constant, answered `0x110` and then `0x100` seven times (the fixture writes the attribute plus `0x100`), while a bind at stride 0 answered `0x110` eight times -- so the two are different answers and Metal's validation stops neither. The same shape at a bind offset of 8 answered `0x112` and then `0x100` seven times, which says the bind offset still reaches the first element. Ours answers the stride-0 reading: `attribute_stride` (crates/metal2vulkan-runtime/src/argument_table.rs:377) maps the constant to `None`, `None` removes the index's entry from `ArgumentTable::attribute_strides`, and every reader of that map takes a missing entry as 0 -- the binder's push constant `PushField::StageInStride` (crates/metal2vulkan/src/lower/stage_io/stage_in.rs:179, whose own module note at line 28 says "as 0 for a buffer bound without one") and the reach check (crates/metal2vulkan-runtime/src/fetch_reach.rs:112). So the fetch walks elements at stride 0 and every thread reads element 0, which is a silently wrong answer rather than a refusal. The runtime already knows the real behaviour for ONE of the four setters: `ComputeCommandEncoder::set_bytes_with_stride` (crates/metal2vulkan-runtime/src/compute.rs:607) documents "an M4 read element 0 of the bytes and zeros past it" and refuses that combination `NotImplemented(KernelStageIn)` rather than emulating it -- this oracle shows the buffer forms behave the same way, so the note on the buffer forms (argument_table.rs:377 and compute.rs:509, "one bound without a stride reads at stride 0") is what is wrong, not the inline-bytes one. The fix belongs in the fetch, not in the table: `PushField::StageInStride` needs to be able to say "the constant was bound" apart from "stride 0" -- a sentinel value or a flag beside it -- and the pulled read in crates/metal2vulkan/src/lower/stage_io/stage_in.rs must then select the element at the bind offset where the element index is 0 and a zero of the attribute's form otherwise, which is the same predicate the inline-bytes form would need and would let that refusal be dropped too. It is deliberately NOT done here: this stream's target is the conformance suite, the change is to a published crate's shader lowering and its push-constant ABI (so it moves `SEMANTICS_VERSION` and every stage-in recording), and it needs release-mode evidence this stream has not taken. Scoped to every venue because the gap is in the push constant and the fetch's own arithmetic, before any device behaviour -- measured on this M3 Max alone, so every other venue is expected and unaudited. Open: for whoever takes the runtime's stage-in fetch. attribute-stride-buffer-offset * divergent case/nine-strides-and-two-offsets 14 elements differ (U32), the largest difference 18 Metal's `MTLAttributeStrideStatic` on a `[[stage_in]]` layout of `MTLBufferLayoutStrideDynamic` is not "read at stride 0"; it fetches the element at the bind offset for the FIRST element and hands every element past it ZERO. Measured on this M3 Max (macOS 27.0.1) from these cases' own committed recordings: a dynamic layout over a buffer holding `0x10 + e` at element `e`, eight threads stepping by thread position in x at rate 1, bound with the constant, answered `0x110` and then `0x100` seven times (the fixture writes the attribute plus `0x100`), while a bind at stride 0 answered `0x110` eight times -- so the two are different answers and Metal's validation stops neither. The same shape at a bind offset of 8 answered `0x112` and then `0x100` seven times, which says the bind offset still reaches the first element. Ours answers the stride-0 reading: `attribute_stride` (crates/metal2vulkan-runtime/src/argument_table.rs:377) maps the constant to `None`, `None` removes the index's entry from `ArgumentTable::attribute_strides`, and every reader of that map takes a missing entry as 0 -- the binder's push constant `PushField::StageInStride` (crates/metal2vulkan/src/lower/stage_io/stage_in.rs:179, whose own module note at line 28 says "as 0 for a buffer bound without one") and the reach check (crates/metal2vulkan-runtime/src/fetch_reach.rs:112). So the fetch walks elements at stride 0 and every thread reads element 0, which is a silently wrong answer rather than a refusal. The runtime already knows the real behaviour for ONE of the four setters: `ComputeCommandEncoder::set_bytes_with_stride` (crates/metal2vulkan-runtime/src/compute.rs:607) documents "an M4 read element 0 of the bytes and zeros past it" and refuses that combination `NotImplemented(KernelStageIn)` rather than emulating it -- this oracle shows the buffer forms behave the same way, so the note on the buffer forms (argument_table.rs:377 and compute.rs:509, "one bound without a stride reads at stride 0") is what is wrong, not the inline-bytes one. The fix belongs in the fetch, not in the table: `PushField::StageInStride` needs to be able to say "the constant was bound" apart from "stride 0" -- a sentinel value or a flag beside it -- and the pulled read in crates/metal2vulkan/src/lower/stage_io/stage_in.rs must then select the element at the bind offset where the element index is 0 and a zero of the attribute's form otherwise, which is the same predicate the inline-bytes form would need and would let that refusal be dropped too. It is deliberately NOT done here: this stream's target is the conformance suite, the change is to a published crate's shader lowering and its push-constant ABI (so it moves `SEMANTICS_VERSION` and every stage-in recording), and it needs release-mode evidence this stream has not taken. Scoped to every venue because the gap is in the push constant and the fetch's own arithmetic, before any device behaviour -- measured on this M3 Max alone, so every other venue is expected and unaudited. Open: for whoever takes the runtime's stage-in fetch. attribute-stride-inline-bytes * refused case/outcome/step/16/dispatchThreadgroups Err(Error::Bind("the bind state was refused: Unsupported(Unsupported { feature: KernelStageIn, needs: NotImplemented, location: None, symbol: None })")) The runtime refuses a kernel's `[[stage_in]]` fetch of INLINE BYTES bound with `MTLAttributeStrideStatic`, where plain Metal answers. Measured on this M3 Max (macOS 27.0.1) from this case's own committed recording: `setBytes:length:attributeStride:atIndex:` of the source bytes with the constant, under a dynamic-stride layout, answered `0x110` and then `0x100` seven times -- the element at the bind offset for the first element and zero past it -- and the command buffer completed. Ours refuses at the dispatch, `Unsupported(KernelStageIn)`, from the bind state; `ComputeCommandEncoder::set_bytes_with_stride` (crates/metal2vulkan-runtime/src/compute.rs:607) documents exactly that refusal and exactly that measured Metal answer, saying the fetch does not emulate it. By the owner's standing rule that what Metal allows we must allow, the refusal is a gap and not a settled difference. It is the same gap as the three `attribute-stride-*` divergences beside it and has the same fix -- teach `PushField::StageInStride` to say "the constant was bound" apart from "stride 0" and have the pulled read in crates/metal2vulkan/src/lower/stage_io/stage_in.rs select the first element and zeros past it -- after which this refusal can be dropped. The buffer forms answer the wrong value instead of refusing, which is the worse half of the same bug; this form at least fails visibly. Scoped to every venue because the refusal is in the encoder's bind state, before any Vulkan call. Open: for whoever takes the runtime's stage-in fetch. -format-footprints-astc-4x2-and-8x4 * refused case/MTLPixelFormatASTC_4x2_sRGB/Type2D/64x64x1/levels-1/samples-1/slices-1/usage-0x1/shared/makes-texture Err(Error::Unsupported("unsupported: Unsupported { feature: Format, needs: NotImplemented, location: None, symbol: Some(\"MTLPixelFormatASTC_4x2_sRGB\") }")) The runtime answers Metal's heap footprint for ASTC's 4x2 and 8x4 footprints, which is arithmetic over a descriptor, but holds no image of any of them, so `newTextureWithDescriptor:` is refused `Unsupported(Format, NotImplemented)` out of the translator's format table (crates/metal2vulkan/src/metal/format/mod.rs, the `formats_named_not_held!` and `astc_without_a_vulkan_block!` patterns, whose `repr` is `NotImplemented`; the refusal reaches this site through `image_error` in crates/metal2vulkan-runtime/src/texture.rs). Measured on an Apple M3 Max under macOS 27.0.1, plain Metal, in a throwaway process forked per (format, texture type): Metal answers a size and an alignment for every descriptor of this case, makes a texture of every format in every texture type bar the ones the case's own module records, and takes a host round trip through each. The whole of Metal's answer is in this case's recording, which is what an implementation will be held to. The case STOPS at this first refusal by design: the runtime holds no image of any of the 33 formats of the family, so recording a refusal per site and going on would print some 2900 `Refused` rows and need a ledger row for each. So this one row stands for the family, and the open work -- an image for each format -- is on the orchestrator's todo list with the measurements. Scoped `*` and not to a venue: the refusal is decided by the format table before any device is consulted, so no device can change it; verified on MoltenVK over this M3 Max (2026-10-25), unverified elsewhere by execution. format-footprints-plain-stragglers * refused case/MTLPixelFormatARGB8Unorm_sRGB/Type2D/64x64x1/levels-1/samples-1/slices-1/usage-0x1/shared/makes-texture Err(Error::Unsupported("unsupported: Unsupported { feature: Format, needs: NotImplemented, location: None, symbol: Some(\"MTLPixelFormatARGB8Unorm_sRGB\") }")) Plain Metal makes a texture of `ARGB8Unorm_sRGB` in all eight non-multisample texture types and takes a host `replaceRegion:`/`getBytes:` round trip through each (an Apple M3 Max under macOS 27.0.1, in a throwaway process forked per (format, texture type); the whole of its answer is in this case's recording). The runtime refuses `newTextureWithDescriptor:` `Unsupported(Format, NotImplemented)` out of the translator's format table (crates/metal2vulkan/src/metal/format/mod.rs, the `formats_named_not_held!` pattern, whose `repr` is `NotImplemented`; the refusal reaches this site through `image_error` in crates/metal2vulkan-runtime/src/texture.rs). The cause is NOT that the bytes have no Vulkan format: they are `ARGB8Unorm`'s (alpha in byte 0, then red, green and blue), which this crate holds in `R8G8B8A8_UNORM` read through a rotating view, and `fill_value.rs` already states this format's own layout as a linear alpha byte and three sRGB bytes. It is that no Vulkan format applies the sRGB transfer function to the three channels Metal's does: every Vulkan `_SRGB` format encodes the word's low three components and leaves the fourth linear, so the function would land on Metal's alpha and miss Metal's blue. A view's component mapping cannot move it, because format conversion runs before the component swizzle, so `R8G8B8A8_SRGB` under `ARGB8Unorm`'s rotation would read Metal's alpha sRGB-decoded and Metal's blue linear -- two channels of four wrong, which is not a near-equivalent a precision note could carry. The exact form is the one a device that cannot sample an 8-bit sRGB format already takes: hold the codes in a UNORM image (here `ARGB8Unorm`'s `R8G8B8A8_UNORM` image through its rotating view) and decode them in the shader through Metal's twelve-bit table (`metal::format::srgb_raw_twin`, `metal::texel_format::srgb_twin_on`, `RuntimeFact::SrgbTexture`, `lower::arith::srgb`), here as the only read of the format on every device, since no view of this image decodes it, so a clear, a blit and a colour attachment of it must take the same route. That is not built. Open: translator and runtime work, in metal2vulkan's format table and the UNORM twin's format map with the runtime's image plan and binder. Its sibling straggler `BGRA4Unorm` is held, which is why the case reaches this format. Scoped `*` and not to a venue: the refusal is decided by the format table before any device is consulted, so no device can change it; verified on MoltenVK over this M3 Max (2026-10-25), unverified elsewhere by execution. -format-footprints-one-plane-ycbcr * refused case/MTLPixelFormatYCBCR8_422_1P/Type2D/64x64x1/levels-1/samples-1/slices-1/usage-0x1/shared/makes-texture Err(Error::Unsupported("unsupported: Unsupported { feature: Format, needs: NotImplemented, location: None, symbol: Some(\"MTLPixelFormatYCBCR8_422_1P\") }")) The runtime answers Metal's heap footprint for Apple's nine one-plane YCbCr formats, which is arithmetic over a descriptor, but holds no image of any of them, so `newTextureWithDescriptor:` is refused `Unsupported(Format, NotImplemented)` out of the translator's format table (crates/metal2vulkan/src/metal/format/mod.rs, the `formats_named_not_held!` and `astc_without_a_vulkan_block!` patterns, whose `repr` is `NotImplemented`; the refusal reaches this site through `image_error` in crates/metal2vulkan-runtime/src/texture.rs). Measured on an Apple M3 Max under macOS 27.0.1, plain Metal, in a throwaway process forked per (format, texture type): Metal answers a size and an alignment for every descriptor of this case, makes a texture of every format in every texture type bar the ones the case's own module records, and takes a host round trip through each. The whole of Metal's answer is in this case's recording, which is what an implementation will be held to. The case STOPS at this first refusal by design: the runtime holds no image of any of the 33 formats of the family, so recording a refusal per site and going on would print some 2900 `Refused` rows and need a ledger row for each. So this one row stands for the family, and the open work -- an image for each format -- is on the orchestrator's todo list with the measurements. Scoped `*` and not to a venue: the refusal is decided by the format table before any device is consulted, so no device can change it; verified on MoltenVK over this M3 Max (2026-10-25), unverified elsewhere by execution. -format-footprints-padded-wide-channels * refused case/MTLPixelFormatRGB10A2Unorm_PQ/Type2D/64x64x1/levels-1/samples-1/slices-1/usage-0x1/shared/makes-texture Err(Error::Unsupported("unsupported: Unsupported { feature: Format, needs: NotImplemented, location: None, symbol: Some(\"MTLPixelFormatRGB10A2Unorm_PQ\") }")) The runtime answers Metal's heap footprint for the ten padded 10- and 12-bit display formats, which is arithmetic over a descriptor, but holds no image of any of them, so `newTextureWithDescriptor:` is refused `Unsupported(Format, NotImplemented)` out of the translator's format table (crates/metal2vulkan/src/metal/format/mod.rs, the `formats_named_not_held!` and `astc_without_a_vulkan_block!` patterns, whose `repr` is `NotImplemented`; the refusal reaches this site through `image_error` in crates/metal2vulkan-runtime/src/texture.rs). Measured on an Apple M3 Max under macOS 27.0.1, plain Metal, in a throwaway process forked per (format, texture type): Metal answers a size and an alignment for every descriptor of this case, makes a texture of every format in every texture type bar the ones the case's own module records, and takes a host round trip through each. The whole of Metal's answer is in this case's recording, which is what an implementation will be held to. The case STOPS at this first refusal by design: the runtime holds no image of any of the 33 formats of the family, so recording a refusal per site and going on would print some 2900 `Refused` rows and need a ledger row for each. So this one row stands for the family, and the open work -- an image for each format -- is on the orchestrator's todo list with the measurements. Scoped `*` and not to a venue: the refusal is decided by the format table before any device is consulted, so no device can change it; verified on MoltenVK over this M3 Max (2026-10-25), unverified elsewhere by execution. -format-footprints-two-plane-ten-bit * refused case/MTLPixelFormatRGB10A8_2P/Type2D/64x64x1/levels-1/samples-1/slices-1/usage-0x1/shared/makes-texture Err(Error::Unsupported("unsupported: Unsupported { feature: Format, needs: NotImplemented, location: None, symbol: Some(\"MTLPixelFormatRGB10A8_2P\") }")) The runtime answers Metal's heap footprint for the four two-plane RGB10A8_2P formats, which is arithmetic over a descriptor, but holds no image of any of them, so `newTextureWithDescriptor:` is refused `Unsupported(Format, NotImplemented)` out of the translator's format table (crates/metal2vulkan/src/metal/format/mod.rs, the `formats_named_not_held!` and `astc_without_a_vulkan_block!` patterns, whose `repr` is `NotImplemented`; the refusal reaches this site through `image_error` in crates/metal2vulkan-runtime/src/texture.rs). Measured on an Apple M3 Max under macOS 27.0.1, plain Metal, in a throwaway process forked per (format, texture type): Metal answers a size and an alignment for every descriptor of this case, makes a texture of every format in every texture type bar the ones the case's own module records, and takes a host round trip through each. The whole of Metal's answer is in this case's recording, which is what an implementation will be held to. The case STOPS at this first refusal by design: the runtime holds no image of any of the 33 formats of the family, so recording a refusal per site and going on would print some 2900 `Refused` rows and need a ledger row for each. So this one row stands for the family, and the open work -- an image for each format -- is on the orchestrator's todo list with the measurements. Scoped `*` and not to a venue: the refusal is decided by the format table before any device is consulted, so no device can change it; verified on MoltenVK over this M3 Max (2026-10-25), unverified elsewhere by execution. +format-footprints-one-plane-ycbcr * refused case/MTLPixelFormatYCBCR8_422_1P/Type2D/64x64x1/levels-1/samples-1/slices-1/usage-0x1/shared/makes-texture Err(Error::Unsupported("unsupported: Unsupported { feature: Format, needs: NotImplemented, location: None, symbol: Some(\"MTLPixelFormatYCBCR8_422_1P\") }")) The runtime answers Metal's heap footprint for Apple's nine one-plane YCbCr formats, which is arithmetic over a descriptor, but holds no image of any of them, so `newTextureWithDescriptor:` is refused `Unsupported(Format, NotImplemented)` out of the translator's format table (crates/metal2vulkan/src/metal/format/mod.rs, the `formats_named_not_held!` pattern, whose `repr` is `NotImplemented`; the refusal reaches this site through `image_error` in crates/metal2vulkan-runtime/src/texture.rs). Measured on an Apple M3 Max under macOS 27.0.1, plain Metal, in a throwaway process forked per (format, texture type): Metal answers a size and an alignment for every descriptor of this case, makes a texture of every format in every texture type bar the ones the case's own module records, and takes a host round trip through each. The whole of Metal's answer is in this case's recording, which is what an implementation will be held to. The case STOPS at this first refusal by design: the runtime holds no image of any of the 33 formats of the family, so recording a refusal per site and going on would print some 2900 `Refused` rows and need a ledger row for each. So this one row stands for the family, and the open work -- an image for each format -- is on the orchestrator's todo list with the measurements. Scoped `*` and not to a venue: the refusal is decided by the format table before any device is consulted, so no device can change it; verified on MoltenVK over this M3 Max (2026-10-25), unverified elsewhere by execution. +format-footprints-padded-wide-channels * refused case/MTLPixelFormatRGB10A2Unorm_PQ/Type2D/64x64x1/levels-1/samples-1/slices-1/usage-0x1/shared/makes-texture Err(Error::Unsupported("unsupported: Unsupported { feature: Format, needs: NotImplemented, location: None, symbol: Some(\"MTLPixelFormatRGB10A2Unorm_PQ\") }")) The runtime answers Metal's heap footprint for the ten padded 10- and 12-bit display formats, which is arithmetic over a descriptor, but holds no image of any of them, so `newTextureWithDescriptor:` is refused `Unsupported(Format, NotImplemented)` out of the translator's format table (crates/metal2vulkan/src/metal/format/mod.rs, the `formats_named_not_held!` pattern, whose `repr` is `NotImplemented`; the refusal reaches this site through `image_error` in crates/metal2vulkan-runtime/src/texture.rs). Measured on an Apple M3 Max under macOS 27.0.1, plain Metal, in a throwaway process forked per (format, texture type): Metal answers a size and an alignment for every descriptor of this case, makes a texture of every format in every texture type bar the ones the case's own module records, and takes a host round trip through each. The whole of Metal's answer is in this case's recording, which is what an implementation will be held to. The case STOPS at this first refusal by design: the runtime holds no image of any of the 33 formats of the family, so recording a refusal per site and going on would print some 2900 `Refused` rows and need a ledger row for each. So this one row stands for the family, and the open work -- an image for each format -- is on the orchestrator's todo list with the measurements. Scoped `*` and not to a venue: the refusal is decided by the format table before any device is consulted, so no device can change it; verified on MoltenVK over this M3 Max (2026-10-25), unverified elsewhere by execution. +format-footprints-two-plane-ten-bit * refused case/MTLPixelFormatRGB10A8_2P/Type2D/64x64x1/levels-1/samples-1/slices-1/usage-0x1/shared/makes-texture Err(Error::Unsupported("unsupported: Unsupported { feature: Format, needs: NotImplemented, location: None, symbol: Some(\"MTLPixelFormatRGB10A8_2P\") }")) The runtime answers Metal's heap footprint for the four two-plane RGB10A8_2P formats, which is arithmetic over a descriptor, but holds no image of any of them, so `newTextureWithDescriptor:` is refused `Unsupported(Format, NotImplemented)` out of the translator's format table (crates/metal2vulkan/src/metal/format/mod.rs, the `formats_named_not_held!` pattern, whose `repr` is `NotImplemented`; the refusal reaches this site through `image_error` in crates/metal2vulkan-runtime/src/texture.rs). Measured on an Apple M3 Max under macOS 27.0.1, plain Metal, in a throwaway process forked per (format, texture type): Metal answers a size and an alignment for every descriptor of this case, makes a texture of every format in every texture type bar the ones the case's own module records, and takes a host round trip through each. The whole of Metal's answer is in this case's recording, which is what an implementation will be held to. The case STOPS at this first refusal by design: the runtime holds no image of any of the 33 formats of the family, so recording a refusal per site and going on would print some 2900 `Refused` rows and need a ledger row for each. So this one row stands for the family, and the open work -- an image for each format -- is on the orchestrator's todo list with the measurements. Scoped `*` and not to a venue: the refusal is decided by the format table before any device is consulted, so no device can change it; verified on MoltenVK over this M3 Max (2026-10-25), unverified elsewhere by execution. # # The texture-buffer creator's memoryless gap: plain Metal makes a `Memoryless` texture buffer # (its `storageMode` 3 on an M3 Max) and `new_buffer` refuses the mode, which no Vulkan buffer diff --git a/crates/metal2vulkan-conformance/src/cases/format_footprints.rs b/crates/metal2vulkan-conformance/src/cases/format_footprints.rs index bc57e8610..7f1df348a 100644 --- a/crates/metal2vulkan-conformance/src/cases/format_footprints.rs +++ b/crates/metal2vulkan-conformance/src/cases/format_footprints.rs @@ -144,10 +144,10 @@ //! //! # Why a case stops at its first refusal //! -//! The runtime holds **no image of 32 of the 33** (`BGRA4Unorm` is the one it holds, in the -//! Vulkan word of its bits): every other one is refused -//! `Unsupported { feature: Format, needs: NotImplemented }`, measured over every descriptor of -//! every case of this family. A case that recorded a refusal at each site and went on — which is +//! The runtime holds **no image of 26 of the 33** (it holds `BGRA4Unorm`, in the Vulkan word of +//! its bits, and ASTC's six 4x2 and 8x4 forms, whose blocks lie in a carrier with a decoded twin): +//! every other one is refused `Unsupported { feature: Format, needs: NotImplemented }`, measured +//! over every descriptor of every case of this family. A case that recorded a refusal at each site and went on — which is //! what `heap_metal_sizes` does, because the runtime answers all of its descriptors — would print //! some 2900 `Refused` rows and need a `known-gaps.tsv` row for each, which is a ledger nobody //! reads and therefore no ledger. So each case stops at the first site it is refused, and the @@ -163,10 +163,13 @@ //! the point: the gap was a number in a generated document and it is now a row of the report //! naming the format, the descriptor and both answers. +use crate::allowance::Allowance; use crate::case::{Abort, Case, Input, MetalSource, Side, TextureRole, TextureSpec}; use crate::texture_query::{HeapTextureQuery as Q, Storage}; use crate::transcript::{Aspect, ByteLayout, Element, Gaps, Node, Observed, Region, Sites, Value}; +use metal2vulkan::bind::AstcDecode; use metal2vulkan::metal::{PixelFormat, TextureType}; +use metal2vulkan_runtime::Degradation; /// The two storage modes every case of the family sweeps. const BOTH_STORAGE: [Storage; 2] = [Storage::Shared, Storage::Private]; @@ -548,6 +551,29 @@ impl Case for FootprintCase { MetalSource::Run } + fn allowances(&self) -> Vec { + // An ASTC 4x2 or 8x4 texture lies in a carrier image with a decoded twin on every device + // (no Vulkan format holds such a block), announced `carried-decoded-twin`; the round + // trip's `replaceRegion` decodes its blocks into the twin on the CPU (`cpu-block-decode`); + // an LDR form's twin holds 8-bit codes (`decoded-texel-precision`). Metal announces + // nothing, so the notices are declared by their codes. They loosen the notices site alone: + // the case reads bytes, every one compared with Metal's exactly. Measured: lavapipe + // announced all three, MoltenVK over an M3 Max the first and the last, and every other + // field was Metal's on both. + let astc = self.round_trips.iter().any(|&pf| AstcDecode::of(pf).is_some()); + if !astc { + return Vec::new(); + } + [ + Degradation::CarriedDecodedTwin, + Degradation::CpuBlockDecode, + Degradation::DecodedTexelPrecision, + ] + .into_iter() + .map(|kind| crate::replay::notice_allowance(kind.code())) + .collect() + } + fn inputs(&self) -> Result, String> { // The descriptors are the whole of what the case feeds, and the order it asks them in: a // table that gains, loses or re-points a row is a change to the case's inputs, so a diff --git a/crates/metal2vulkan-runtime/src/astc.rs b/crates/metal2vulkan-runtime/src/astc.rs index 4dc0d136e..c330995ff 100644 --- a/crates/metal2vulkan-runtime/src/astc.rs +++ b/crates/metal2vulkan-runtime/src/astc.rs @@ -1,24 +1,31 @@ -//! ASTC textures (LDR, sRGB and HDR) on a device without their ASTC block: their blocks held as -//! raw bytes in a carrier, which copies move, and their samples read a decoded twin. +//! ASTC textures (LDR, sRGB and HDR) on a device without their ASTC block, and Apple's 4x2 and +//! 8x4 footprints (which no Vulkan format holds) on every device: their blocks held as raw bytes +//! in a carrier, which copies move, and their samples read a decoded twin. //! -//! - **Metal's answers** (an Apple M3 Max under macOS 27.0.1, our own probes; the HDR formats' -//! `conformance/probes/astc_hdr_textures.m`): every ASTC format, LDR, sRGB and HDR, makes a +//! - **Metal's answers** (an Apple M3 Max under macOS 27.0.1, our own probes: +//! `conformance/probes/astc_hdr_textures.m` and `astc_passes_writes_footprints.m`): every ASTC +//! format, LDR, sRGB and HDR, of every footprint, the 4x2 and 8x4 ones among them, makes a //! texture, `Shared`, `Private` and memoryless, of every type but 1D and multisampled (which //! end the process), of `ShaderWrite` and `RenderTarget` usage too, and views as its other //! forms of the footprint (another footprint's view ends the process). `getBytes` and a blit out -//! of the texture hand back the blocks a write put there; a new texture's blocks are zeros, -//! which read magenta (an error block; an HDR texture's NaN). Its reads and samples are -//! `bind::AstcDecode`'s. An HDR format's render pipeline ends the process; a pass storing into -//! such a texture completes and leaves its blocks as they were, and a kernel's write completes -//! and leaves bytes no format defines: Metal's validation stops both. +//! of the texture hand back the blocks a write put there; a copy's region rounds out to whole +//! blocks, the 4x2 and 8x4 footprints' as the others', its last block ending at the level's +//! edge; a new texture's blocks are zeros, which read magenta (an error block; an HDR texture's +//! NaN). Its reads and samples are `bind::AstcDecode`'s. A render pipeline of any ASTC color +//! attachment ends the process. A pass with such a texture as a color attachment completes, +//! whatever its load and store actions, with a draw and without: the texture's blocks stay as +//! they were, and the pass's other attachments load, clear, draw and store as they would. A +//! kernel's `write` or `read_write` of one completes and stores bytes no format defines into its +//! blocks (the same for the same written value). //! - **The store.** Vulkan copies a compressed image's blocks as bytes. Such a texture holds its //! blocks in an image of a *carrier*: a compressed format whose blocks are also 16 bytes, over //! 4 x 4 texels, the first of [`CARRIERS`] the device copies (every Vulkan device has BC or ETC2, -//! which hold one). Each of the texture's blocks lies over 4 x 4 carrier texels, so a region of -//! the texture's blocks is a region of the carrier's ([`image_region`]). A level of the carrier -//! holds at least the blocks the texture's level holds ([`carrier_side`]): the carrier's side is -//! the least whose every level, halved as Vulkan halves it, keeps them (at most about the -//! texture's side in texels, 1 byte a texel), and a copy addresses the first of them. +//! which hold one). Each of the texture's blocks, of whatever footprint, lies over 4 x 4 carrier +//! texels, so a region of the texture's blocks is a region of the carrier's ([`image_region`]). +//! A level of the carrier holds at least the blocks the texture's level holds +//! ([`carrier_side`]): the carrier's side is the least whose every level, halved as Vulkan +//! halves it, keeps them (at most about the texture's side in texels, 1 byte a texel), and a +//! copy addresses the first of them. //! - **What it serves.** Copies between buffers and the texture and between textures (fills //! included), and the CPU's copies, move its blocks through the carrier, so `getBytes` and a //! blit out of it hand back the blocks written. Its sampled views present its decoded twin @@ -32,10 +39,10 @@ //! of that form's decode, made at the first such view. Refused: a heap's or a sparse heap's //! texture (`RuntimeGap::DecodedHeapTexture`) and a view of another decode (an LDR or sRGB //! texture's HDR form, an HDR texture's LDR or sRGB form, or another footprint; -//! `Feature::TextureView`). A shader write and an attachment take no such image (no more than -//! the device's own ASTC block, which Vulkan neither stores into nor renders into): a pass -//! rendering into one and a kernel's binding for writes are refused, typed, where Metal's -//! validation stops each. +//! `Feature::TextureView`). +//! - **Passes and shader writes.** No Vulkan format of a block is an attachment's or a storage +//! image's, the device's own ASTC block's included: a pass rendering into such a texture and a +//! kernel's binding of one for writes are refused, typed. use super::copy_plan::ImageRegion; use super::image_plan::{sample_count, ImageFacts, ImagePlan}; diff --git a/crates/metal2vulkan-runtime/src/copy_plan.rs b/crates/metal2vulkan-runtime/src/copy_plan.rs index 3a2679b0b..211d0c8e8 100644 --- a/crates/metal2vulkan-runtime/src/copy_plan.rs +++ b/crates/metal2vulkan-runtime/src/copy_plan.rs @@ -59,7 +59,7 @@ use super::chroma_pairs::{is_four_two_two, TEXEL_BYTES}; use super::host_bytes::HostBytes; use super::pvrtc::{is_pvrtc, BLOCK_BYTES}; use super::view_plan::ViewRecord; -use metal2vulkan::bind::YCbCrCodes; +use metal2vulkan::bind::{AstcDecode, YCbCrCodes}; use metal2vulkan::error::{Feature, Unsupported}; use metal2vulkan::metal::format::{ aspects, byte_format, is_depth_stencil, ycbcr_format, FormatMapping, @@ -204,12 +204,18 @@ pub(super) struct CopyUnit { pub(super) use metal2vulkan::metal::format::block_extent; /// The bytes of a block (a texel, uncompressed) of the colour format `pf`: its byte format's -/// (`metal::format::byte_format`, the format whose image holds Metal's bytes), and a PVRTC -/// block's 8, which the device may hold in a carrier of no PVRTC format (`pvrtc.rs`). +/// (`metal::format::byte_format`, the format whose image holds Metal's bytes), a PVRTC block's 8 +/// and an ASTC block's 16, which the device may hold in a carrier of no PVRTC or ASTC format +/// (`pvrtc.rs`, `astc.rs`). pub(super) fn block_bytes(pf: PixelFormat) -> Option { if is_pvrtc(pf) { return Some(BLOCK_BYTES); } + // An ASTC block is 16 bytes at every footprint, Apple's 4x2 and 8x4 among them, which no + // Vulkan format holds (their carrier does, `astc.rs`). + if AstcDecode::of(pf).is_some() { + return Some(AstcDecode::BLOCK_BYTES); + } // Plain Metal copies a 4:2:2 texture's 2-byte texels at any x, width, offset and pitch (its // validation asks for 2 x 1 blocks of 4 bytes), which its carrier holds // one to an image texel (`chroma_pairs.rs`). diff --git a/crates/metal2vulkan-runtime/src/image_plan.rs b/crates/metal2vulkan-runtime/src/image_plan.rs index 4c2ca1906..03ad30d85 100644 --- a/crates/metal2vulkan-runtime/src/image_plan.rs +++ b/crates/metal2vulkan-runtime/src/image_plan.rs @@ -340,7 +340,7 @@ pub(super) fn sample_count(samples: u32) -> Option { /// Metal's sRGB pairs: the linear format, then the format whose texels are the same bytes read /// through sRGB encoding. -const SRGB_PAIRS: [(PixelFormat, PixelFormat); 31] = [ +const SRGB_PAIRS: [(PixelFormat, PixelFormat); 33] = [ (PixelFormat::R8Unorm, PixelFormat::R8UnormSRGB), (PixelFormat::RG8Unorm, PixelFormat::RG8UnormSRGB), (PixelFormat::RGBA8Unorm, PixelFormat::RGBA8UnormSRGB), @@ -372,6 +372,8 @@ const SRGB_PAIRS: [(PixelFormat, PixelFormat); 31] = [ (PixelFormat::ASTC10x10LDR, PixelFormat::ASTC10x10SRGB), (PixelFormat::ASTC12x10LDR, PixelFormat::ASTC12x10SRGB), (PixelFormat::ASTC12x12LDR, PixelFormat::ASTC12x12SRGB), + (PixelFormat::ASTC4x2LDR, PixelFormat::ASTC4x2SRGB), + (PixelFormat::ASTC8x4LDR, PixelFormat::ASTC8x4SRGB), ]; /// The other member of `pf`'s sRGB pair (`RGBA8Unorm` and `RGBA8Unorm_sRGB`): Metal views a @@ -419,6 +421,8 @@ pub(super) fn block_family(pf: PixelFormat) -> PixelFormat { P::ASTC10x10HDR => P::ASTC10x10LDR, P::ASTC12x10HDR => P::ASTC12x10LDR, P::ASTC12x12HDR => P::ASTC12x12LDR, + P::ASTC4x2HDR => P::ASTC4x2LDR, + P::ASTC8x4HDR => P::ASTC8x4LDR, other => other, } } diff --git a/crates/metal2vulkan-runtime/src/tests/heap_footprint_formats.rs b/crates/metal2vulkan-runtime/src/tests/heap_footprint_formats.rs index e20c55b82..4e9d08b07 100644 --- a/crates/metal2vulkan-runtime/src/tests/heap_footprint_formats.rs +++ b/crates/metal2vulkan-runtime/src/tests/heap_footprint_formats.rs @@ -1,6 +1,8 @@ -//! `heapTextureSizeAndAlignWithDescriptor:` for the 32 formats this crate holds no image of -//! (`metal::format::footprint`): Metal's size and alignment against the runtime's, over two -//! declared descriptor spaces enumerated whole, plus the rows that name each family's rule. +//! `heapTextureSizeAndAlignWithDescriptor:` for the 26 formats this crate holds no image of +//! (`metal::format::footprint`) and ASTC's 4x2 and 8x4 formats, whose blocks the runtime holds +//! in a carrier and whose heap textures it answers Metal's model for (`heap_tiled::modelled_size`, +//! as for every ASTC texture in a carrier): Metal's size and alignment against the runtime's, over +//! two declared descriptor spaces enumerated whole, plus the rows that name each family's rule. //! //! **Measured** on an Apple M3 Max under macOS 27.0.1 (26A434), plain Metal with no API //! validation layer, by a probe that forks per (format, texture type) so a descriptor Metal's @@ -25,14 +27,18 @@ //! (`TextureDescriptor::check_made`, whose `Nil` is Metal's "no texture of this shape" and //! answers 0 bytes at [`no_texture_alignment`]) and then //! [`footprint_answer`](crate::texture::heap::footprint_answer). `Device::heap_texture_size_and_align` -//! calls exactly those two, in that order, before it plans any image. +//! calls exactly those two, in that order, before it plans any image; for an ASTC 4x2 or 8x4 +//! texture, whose heap texture the runtime refuses its making (`DecodedHeapTexture`), it then +//! answers [`modelled_size`](crate::texture::heap_tiled::modelled_size). use super::super::texture::heap::{footprint_answer, no_texture_alignment}; +use super::super::texture::heap_tiled::modelled_size; use super::super::texture_descriptor::{ effective_usage, Creator, Refused, TextureDescriptor, TextureRules, }; use super::super::values::{ResourceOptions, StorageMode}; use crate::heap::SizeAndAlign; +use metal2vulkan::bind::AstcDecode; use metal2vulkan::metal::{PixelFormat as P, TextureType as T, TextureUsage}; /// The device the probe ran on, as the descriptor rules see it: an Apple GPU. @@ -94,7 +100,7 @@ const fn row(format: PixelFormat, sides: (usize, u64), usages: (usize, u64)) -> } } -/// Metal's answers, by format: the six ASTC footprints, the two plain stragglers, the nine +/// Metal's answers, by format: ASTC's six 4x2 and 8x4 formats, the two plain stragglers, the nine /// one-plane YCbCr formats, the ten padded 10- and 12-bit display formats, the four two-plane /// ones and the two packed ones Metal makes no texture of. const ROWS: &[Row] = &[ @@ -297,11 +303,13 @@ fn answer(d: &TextureDescriptor) -> SizeAndAlign { align: no_texture_alignment(d.pixel_format, d.texture_type), }, Err(refused) => panic!("{:?} {:?}: {refused:?}", d.pixel_format, d.texture_type), - Ok(layout) => footprint_answer( - &layout, - effective_usage(d.usage), - d.allow_gpu_optimized_contents, - ) + Ok(layout) => { + let usage = effective_usage(d.usage); + let optimized = d.allow_gpu_optimized_contents; + let carried = AstcDecode::of(d.pixel_format).is_some(); + footprint_answer(&layout, usage, optimized) + .or_else(|| carried.then(|| modelled_size(&layout, usage, optimized))?) + } .unwrap_or_else(|| { panic!( "{:?} {:?} {}x{}: the footprint has no answer", diff --git a/crates/metal2vulkan-runtime/src/tests/heap_tiled.rs b/crates/metal2vulkan-runtime/src/tests/heap_tiled.rs index cfc6f401d..cb67b9d21 100644 --- a/crates/metal2vulkan-runtime/src/tests/heap_tiled.rs +++ b/crates/metal2vulkan-runtime/src/tests/heap_tiled.rs @@ -782,14 +782,15 @@ fn heap_textures_are_tiled_where_metal_s_layout_is_measured() { Some((3200, 128)) ); assert!(matches!(m4_pvrtc.layout, HeapLayout::Tiled(_))); - // ASTC 4 x 2: a family whose blocks' placement is not measured, untiled and unanswered. + // ASTC 4 x 2: Metal's answer, its family's placement (the footprint rows of + // `heap_footprint_formats`), untiled where no image holds its blocks (a carrier's do). let astc = texture(T::Type2D, PixelFormat::ASTC4x2LDR, [64, 64, 1], (1, 1, 1)); - let unmeasured = metal_heap_layout(&astc, read, true, Format::UNDEFINED); - assert_eq!(unmeasured.answer, None); - let HeapLayout::Untiled(untiled) = unmeasured.layout else { + let carried = metal_heap_layout(&astc, read, true, Format::UNDEFINED); + assert_eq!(carried.answer.map(|a| (a.size, a.align)), Some((8192, 128))); + let HeapLayout::Untiled(untiled) = carried.layout else { panic!("an ASTC 4 x 2 texture is tiled"); }; - assert_eq!(untiled.kind, D::HeapTextureBlockCompressedLayout); + assert_eq!(untiled.kind, D::HeapTextureUntiledLayout); let decoded = metal_heap_layout(&bc1, read, true, Format::R8G8B8A8_UNORM); assert_eq!(decoded.answer, blocks.answer); let HeapLayout::Untiled(untiled) = decoded.layout else { diff --git a/crates/metal2vulkan-runtime/src/tests/heap_tiled_blocks.rs b/crates/metal2vulkan-runtime/src/tests/heap_tiled_blocks.rs index 31197b729..31da96d14 100644 --- a/crates/metal2vulkan-runtime/src/tests/heap_tiled_blocks.rs +++ b/crates/metal2vulkan-runtime/src/tests/heap_tiled_blocks.rs @@ -11,6 +11,7 @@ use crate::copy_plan::{block_bytes, block_extent}; use crate::metal_release::heap_blocks; use crate::pvrtc::is_pvrtc; use crate::texture::heap_tiled::{BlockFamily, BlockPlacement, Elements, TiledLayout}; +use metal2vulkan::bind::AstcDecode; use metal2vulkan::metal::format::direct_format; use metal2vulkan::metal::{PixelFormat as P, TextureType as T}; @@ -935,15 +936,20 @@ fn the_rows_tell_the_placements_apart() { } /// Every block-compressed format the crate holds a texture of has a family, and every format of a -/// family but PVRTC's (`pvrtc_blocks_lie_where_the_release_places_them`) is among the rows. +/// family but PVRTC's (`pvrtc_blocks_lie_where_the_release_places_them`) and ASTC's 4x2 and 8x4 +/// (`heap_footprint_formats`) is among the rows. #[test] fn every_block_compressed_format_has_a_measured_family() { let measured: std::collections::BTreeSet

= rows(M4_ROWS).iter().map(|row| row.pf).collect(); for &pf in P::ALL { - let held = block_extent(pf).is_some() && (direct_format(pf).is_some() || is_pvrtc(pf)); + let carried = AstcDecode::of(pf).is_some(); + let held = + block_extent(pf).is_some() && (direct_format(pf).is_some() || is_pvrtc(pf) || carried); let family = BlockFamily::of(pf); assert_eq!(family.is_some(), held, "{pf:?}"); - if family.is_some() && !is_pvrtc(pf) { + // ASTC's 4x2 and 8x4 footprints, which no Vulkan block has, are measured by the footprint + // rows of `heap_footprint_formats`. + if family.is_some() && !is_pvrtc(pf) && direct_format(pf).is_some() { assert!(measured.contains(&pf), "{pf:?} not measured"); } } diff --git a/crates/metal2vulkan-runtime/src/tests/image_plan.rs b/crates/metal2vulkan-runtime/src/tests/image_plan.rs index 1088ef7d8..be9dcb132 100644 --- a/crates/metal2vulkan-runtime/src/tests/image_plan.rs +++ b/crates/metal2vulkan-runtime/src/tests/image_plan.rs @@ -1385,33 +1385,67 @@ fn compressed_formats_are_compatible_only_within_their_family() { assert_eq!(block_family(PixelFormat::R32Float), PixelFormat::R32Float); } -/// A texture of ASTC's 4x2 or 8x4 formats, which Metal makes and no Vulkan block holds, is -/// refused `NotImplemented(Format)` on every committed device, sampled or rendered to. +/// A texture of ASTC's 4x2 or 8x4 formats, which Metal makes and no Vulkan block holds, plans its +/// blocks in a carrier on every committed device that copies one (MoltenVK's among them), of +/// every type Metal makes of one and every usage (`ShaderWrite` and `RenderTarget` unavailable), +/// its decoded twin the profile's: 8-bit codes (`R8G8B8A8_UNORM`) for an LDR or sRGB form, halves +/// (`R16G16B16A16_SFLOAT`) for an HDR one. #[test] -fn astc_4x2_and_8x4_textures_are_refused_typed() { +fn astc_4x2_and_8x4_textures_plan_in_a_carrier() { + use super::super::astc::{decode_of, CARRIERS as ASTC_CARRIERS}; + use super::super::texture::decoded_twin::{twin_plan, TwinDecode}; + use metal2vulkan::bind::{AstcDecode, AstcTexels}; use PixelFormat as P; + let mut carried = 0; for (name, desc, device) in committed() { let facts = facts(&desc, &device); - for pf in [ - P::ASTC4x2LDR, - P::ASTC4x2SRGB, - P::ASTC4x2HDR, - P::ASTC8x4LDR, - P::ASTC8x4SRGB, - P::ASTC8x4HDR, + let copies = FormatFeatureFlags2::TRANSFER_SRC | FormatFeatureFlags2::TRANSFER_DST; + if !(ASTC_CARRIERS.iter()).any(|&f| facts.optimal(f).contains(copies)) { + continue; + } + for (pf, twin) in [ + (P::ASTC4x2LDR, Format::R8G8B8A8_UNORM), + (P::ASTC4x2SRGB, Format::R8G8B8A8_UNORM), + (P::ASTC4x2HDR, Format::R16G16B16A16_SFLOAT), + (P::ASTC8x4LDR, Format::R8G8B8A8_UNORM), + (P::ASTC8x4SRGB, Format::R8G8B8A8_UNORM), + (P::ASTC8x4HDR, Format::R16G16B16A16_SFLOAT), ] { - let l = layout(TextureType::Type2D, pf, 1, 1); - for usage in [TextureUsage::SHADER_READ, TextureUsage::RENDER_TARGET] { - match plan_image(&l, usage, false, &facts) { - Err(ImageRefusal::Unsupported(u)) => { - assert_eq!(u.feature, Feature::Format, "{name}: {pf:?}"); - assert_eq!(u.needs, Needs::NotImplemented, "{name}: {pf:?}: {u:?}"); - } - other => panic!("{name}: {pf:?} {usage:?}: {other:?}"), - } + let decode = AstcDecode::of(pf).expect("a decode"); + for ty in [ + TextureType::Type2D, + TextureType::Type2DArray, + TextureType::Cube, + TextureType::Type3D, + ] { + let what = format!("{name} {pf:?} {ty:?}"); + let l = layout(ty, pf, 1, 1); + let usage = TextureUsage::SHADER_READ + | TextureUsage::SHADER_WRITE + | TextureUsage::RENDER_TARGET; + let plan = plan_image(&l, usage, false, &facts).expect(&what); + assert!( + ASTC_CARRIERS.contains(&plan.format), + "{what}: {:?}", + plan.format + ); + assert_eq!(decode_of(&plan), Some(decode), "{what}"); + assert!( + plan.unavailable + .contains(TextureUsage::SHADER_WRITE | TextureUsage::RENDER_TARGET), + "{what}: {:?}", + plan.unavailable + ); + let texels = TwinDecode::Astc(decode, decode.form(AstcTexels::Unorm8)); + assert_eq!(twin_plan(&plan, &l, texels, false).format, twin, "{what}"); } } + carried += 1; } + assert!( + carried >= 5, + "{carried} committed devices hold them in a carrier" + ); } /// Apple's extended-range formats are held raw in the unsigned integer format of their bytes, @@ -2079,15 +2113,16 @@ fn astc_carriers_hold_each_level_s_blocks() { /// array, 3D) and every usage (`ShaderWrite` and `RenderTarget` too, unavailable), plans on every /// committed device that holds ASTC LDR in a carrier: in its own `SFLOAT` block where the device /// samples it (MoltenVK on the M3 Max, its `textureCompressionASTC_HDR`), else its blocks in a -/// carrier whose decoded twin holds Metal's halves (`R16G16B16A16_SFLOAT`) — the RTX 5080's among -/// them, which refused it before the decode. +/// carrier whose decoded twin holds Metal's halves (`R16G16B16A16_SFLOAT`), the RTX 5080's among +/// them. (ASTC's 4x2 and 8x4 HDR formats, which no Vulkan block has, lie in a carrier everywhere: +/// `astc_4x2_and_8x4_textures_plan_in_a_carrier`.) #[test] fn astc_hdr_textures_plan_natively_or_in_a_carrier() { use super::super::astc::{decode_of, CARRIERS as ASTC_CARRIERS}; use super::super::texture::decoded_twin::{twin_plan, TwinDecode}; use metal2vulkan::bind::{AstcDecode, AstcTexels}; let hdr: Vec = (PixelFormat::ALL.iter().copied()) - .filter(|&pf| AstcDecode::of(pf).is_some_and(|d| d.hdr)) + .filter(|&pf| AstcDecode::of(pf).is_some_and(|d| d.hdr) && direct_format(pf).is_some()) .collect(); assert_eq!(hdr.len(), 14); let (mut native, mut carried) = (Vec::new(), Vec::new()); diff --git a/crates/metal2vulkan-runtime/src/tests/pixel_format_info.rs b/crates/metal2vulkan-runtime/src/tests/pixel_format_info.rs index 777e4678e..145b712a0 100644 --- a/crates/metal2vulkan-runtime/src/tests/pixel_format_info.rs +++ b/crates/metal2vulkan-runtime/src/tests/pixel_format_info.rs @@ -243,9 +243,9 @@ fn extents_near_two_to_the_64_wrap_the_block_count() { } } -/// Every ASTC format of the fourteen 2D footprints, LDR, sRGB and HDR, is described as Metal -/// describes it whatever the device holds its blocks in (its ASTC format, or a carrier, -/// `astc.rs`): a format of blocks (flags +/// Every ASTC format, LDR, sRGB and HDR, of the fourteen 2D footprints Vulkan's ASTC formats have +/// and of Apple's 4x2 and 8x4, is described as Metal describes it whatever the device holds its +/// blocks in (its ASTC format, or a carrier, `astc.rs`): a format of blocks (flags /// bit 0x400) of 16 bytes, its footprint, depth 1; and a level's layout counts its blocks, a side /// no multiple of the block rounded up, rows of 16-byte blocks, an image of those rows. #[test] @@ -281,5 +281,5 @@ fn astc_formats_answer_metal_s_blocks_and_levels() { assert_eq!(answer.bytes_per_image, 16 * across * down, "{what}"); } } - assert_eq!(seen, 42); + assert_eq!(seen, 48); } diff --git a/crates/metal2vulkan-runtime/src/tests/view_plan.rs b/crates/metal2vulkan-runtime/src/tests/view_plan.rs index 7317faf1b..d0f45465c 100644 --- a/crates/metal2vulkan-runtime/src/tests/view_plan.rs +++ b/crates/metal2vulkan-runtime/src/tests/view_plan.rs @@ -200,7 +200,7 @@ fn view_formats_follow_metals_measured_verdicts() { ); match check_view( &source, - &ViewRequest::of_format(&source, P::ASTC4x2HDR), + &ViewRequest::of_format(&source, P::RGB8Unorm), device.profile(), ) { Err(ViewRefusal::Unsupported(u)) => assert_eq!(u.feature, Feature::Format), diff --git a/crates/metal2vulkan-runtime/src/texture/heap_tiled.rs b/crates/metal2vulkan-runtime/src/texture/heap_tiled.rs index 55eba6bd1..2c814807f 100644 --- a/crates/metal2vulkan-runtime/src/texture/heap_tiled.rs +++ b/crates/metal2vulkan-runtime/src/texture/heap_tiled.rs @@ -345,7 +345,9 @@ impl BlockFamily { | P::ASTC10x8LDR | P::ASTC10x10LDR | P::ASTC12x10LDR - | P::ASTC12x12LDR => BlockFamily::Astc, + | P::ASTC12x12LDR + | P::ASTC4x2LDR + | P::ASTC8x4LDR => BlockFamily::Astc, P::PVRTCRGB2BPP | P::PVRTCRGB4BPP | P::PVRTCRGBA2BPP | P::PVRTCRGBA4BPP => { BlockFamily::Pvrtc } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/astc_hdr_textures.rs b/crates/metal2vulkan-validation/src/runtime_lane/astc_hdr_textures.rs index 8402a4f6e..0594f45ba 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/astc_hdr_textures.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/astc_hdr_textures.rs @@ -16,7 +16,8 @@ //! a new texture's zero blocks NaN, then blocks a CPU copy wrote, a blit from a buffer, a fill of //! an HDR void-extent block and a copy from another texture, each decoded into a twin (a blit's by //! a GPU decode pass; a CPU copy's by a pass or on the CPU, counted in `WorkCounts`). The blocks -//! each wrote come back unchanged from `get_bytes` and a blit into a buffer. A pass rendering into +//! each wrote come back unchanged from `get_bytes` and a blit into a buffer. Apple's 4x2 and 8x4 +//! footprints, which no Vulkan format holds, lie in a carrier on every device. A pass rendering into //! one and a kernel's write of one, which Metal's validation stops (plain Metal's pass stores //! nothing, its write leaves bytes no format defines), are refused, typed //! ([`astc_hdr_textures_of_every_usage_are_made`]). @@ -39,13 +40,15 @@ use metal2vulkan_runtime::{ Texture, }; -/// Every ASTC HDR format of a Vulkan footprint. -const FORMATS: [PixelFormat; 14] = [ +/// Every ASTC HDR format. +const FORMATS: [PixelFormat; 16] = [ PixelFormat::ASTC4x4HDR, + PixelFormat::ASTC4x2HDR, PixelFormat::ASTC5x4HDR, PixelFormat::ASTC5x5HDR, PixelFormat::ASTC6x5HDR, PixelFormat::ASTC6x6HDR, + PixelFormat::ASTC8x4HDR, PixelFormat::ASTC8x5HDR, PixelFormat::ASTC8x6HDR, PixelFormat::ASTC8x8HDR, diff --git a/crates/metal2vulkan-validation/src/runtime_lane/astc_textures.rs b/crates/metal2vulkan-validation/src/runtime_lane/astc_textures.rs index 45bdd5025..38b2168bc 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/astc_textures.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/astc_textures.rs @@ -2,8 +2,9 @@ //! decode (`metal2vulkan::bind::AstcDecode`, matched bit for bit against an Apple M3 Max by its //! own tests). //! -//! On a device without a format's ASTC block ([`decodes_astc`]) the texture holds its blocks in a -//! carrier and its reads go through a decoded twin, announced `carried-decoded-twin` once and +//! On a device without a format's ASTC block ([`decodes_astc`]; on every device for Apple's 4x2 and +//! 8x4 footprints, which no Vulkan format holds) the texture holds its blocks in a carrier and its +//! reads go through a decoded twin, announced `carried-decoded-twin` once and //! `decoded-texel-precision` once ([`ASTC_TWINS`]). Every format's texels read as Metal's after //! every kind of write ([`astc_texels_read_as_metal_s`]): an LDR form's within 1/510, an sRGB //! form's as the device decodes its twin's 8-bit codes, Metal's own 8-bit codes (through Metal's @@ -58,12 +59,14 @@ pub(super) const ASTC_TWINS: [Degradation; 2] = [ pub(super) const CPU_DECODES: [Degradation; 1] = [Degradation::CpuBlockDecode]; /// Every ASTC LDR format, linear and sRGB. -const FORMATS: [PixelFormat; 28] = [ +const FORMATS: [PixelFormat; 32] = [ PixelFormat::ASTC4x4LDR, + PixelFormat::ASTC4x2LDR, PixelFormat::ASTC5x4LDR, PixelFormat::ASTC5x5LDR, PixelFormat::ASTC6x5LDR, PixelFormat::ASTC6x6LDR, + PixelFormat::ASTC8x4LDR, PixelFormat::ASTC8x5LDR, PixelFormat::ASTC8x6LDR, PixelFormat::ASTC8x8LDR, @@ -74,10 +77,12 @@ const FORMATS: [PixelFormat; 28] = [ PixelFormat::ASTC12x10LDR, PixelFormat::ASTC12x12LDR, PixelFormat::ASTC4x4SRGB, + PixelFormat::ASTC4x2SRGB, PixelFormat::ASTC5x4SRGB, PixelFormat::ASTC5x5SRGB, PixelFormat::ASTC6x5SRGB, PixelFormat::ASTC6x6SRGB, + PixelFormat::ASTC8x4SRGB, PixelFormat::ASTC8x5SRGB, PixelFormat::ASTC8x6SRGB, PixelFormat::ASTC8x8SRGB, @@ -642,6 +647,8 @@ fn astc_views_in_the_other_colour_space_read_as_metal_s() { PixelFormat::ASTC6x5LDR, PixelFormat::ASTC12x12SRGB, PixelFormat::ASTC8x8LDR, + PixelFormat::ASTC4x2SRGB, + PixelFormat::ASTC8x4LDR, ]; for (f, pf) in formats.into_iter().enumerate() { if decodes_astc(device, pf) { @@ -794,9 +801,9 @@ fn astc_views_in_the_other_colour_space_read_as_metal_s() { } /// Every level and slice of a mipmapped 2D array (two slices) and cube of sides no multiple of the -/// block, of a square, an oblong and an sRGB footprint: blocks blitted in from a buffer at the -/// level's texel size come back bit for bit from blits into a buffer and from `get_bytes` (the -/// module docs). +/// block, of square, oblong and sRGB footprints, Apple's 4x2 and 8x4 among them (one HDR): blocks +/// blitted in from a buffer at the level's texel size come back bit for bit from blits into a +/// buffer and from `get_bytes` (the module docs). #[test] fn astc_blocks_round_trip_at_every_level_and_slice() { on_device(|device, _messages| { @@ -806,6 +813,9 @@ fn astc_blocks_round_trip_at_every_level_and_slice() { PixelFormat::ASTC8x8LDR, PixelFormat::ASTC6x5LDR, PixelFormat::ASTC12x10SRGB, + PixelFormat::ASTC4x2LDR, + PixelFormat::ASTC8x4SRGB, + PixelFormat::ASTC8x4HDR, ]; for (f, pf) in formats.into_iter().enumerate() { let decode = AstcDecode::of(pf).unwrap(); diff --git a/crates/metal2vulkan/src/bind/astc_decode.rs b/crates/metal2vulkan/src/bind/astc_decode.rs index f2996a105..5f4c20773 100644 --- a/crates/metal2vulkan/src/bind/astc_decode.rs +++ b/crates/metal2vulkan/src/bind/astc_decode.rs @@ -9,9 +9,11 @@ //! for an `_sRGB` format; an HDR mode's 12-bit ones (an `_HDR` format's alone, `hdr.rs`) `e · 16`. //! //! **Metal's answers** (an Apple M3 Max under macOS 27.0.1, our own probe: 4096 blocks of each of -//! the fourteen footprints, about 70% valid blocks of random modes, void-extent blocks and error -//! blocks, every texel read as `float` and `half` and sampled at its centre, linear and sRGB, -//! every channel equal to this decode's): +//! the fourteen footprints Vulkan's ASTC formats have, about 70% valid blocks of random modes, +//! void-extent blocks and error blocks, every texel read as `float` and `half` and sampled at its +//! centre, linear and sRGB, every channel equal to this decode's; and Apple's 4x2 and 8x4 +//! footprints, which no Vulkan format has, in every profile, the probe +//! `astc_passes_writes_footprints`'s seeded blocks read alike): //! //! - **Linear:** each channel reads `(C >> 4) / 4095`, a 12-bit value, correctly rounded to `f32` //! (a `half` read rounds that to nearest even). @@ -112,24 +114,6 @@ pub enum AstcTexels { Half, } -/// The 2D footprints Vulkan's ASTC formats have, in Metal's raw-value order. -const FOOTPRINTS: [[u32; 2]; 14] = [ - [4, 4], - [5, 4], - [5, 5], - [6, 5], - [6, 6], - [8, 5], - [8, 6], - [8, 8], - [10, 5], - [10, 6], - [10, 8], - [10, 10], - [12, 10], - [12, 12], -]; - /// The most texels a block holds (12 x 12). const MOST_TEXELS: usize = 144; @@ -137,77 +121,73 @@ impl AstcDecode { /// The bytes of every block. pub const BLOCK_BYTES: u32 = 16; - /// The decode of `pf`'s blocks: the ASTC formats of the fourteen 2D footprints, LDR, `_sRGB` - /// and `_HDR`; `None` for every other format (Apple's 4x2 and 8x4 footprints included). + /// The decode of `pf`'s blocks: every ASTC format, LDR, `_sRGB` and `_HDR`, of the fourteen 2D + /// footprints Vulkan's ASTC formats have and of Apple's 4x2 and 8x4, which no Vulkan format + /// has; `None` for every other format. pub fn of(pf: PixelFormat) -> Option { - use PixelFormat as P; - if let Some(index) = Self::hdr_index(pf) { - let [width, height] = FOOTPRINTS[index]; - return Some(AstcDecode { - width, - height, - srgb: false, - hdr: true, - }); - } - let (srgb, index) = match pf { - P::ASTC4x4SRGB => (true, 0), - P::ASTC5x4SRGB => (true, 1), - P::ASTC5x5SRGB => (true, 2), - P::ASTC6x5SRGB => (true, 3), - P::ASTC6x6SRGB => (true, 4), - P::ASTC8x5SRGB => (true, 5), - P::ASTC8x6SRGB => (true, 6), - P::ASTC8x8SRGB => (true, 7), - P::ASTC10x5SRGB => (true, 8), - P::ASTC10x6SRGB => (true, 9), - P::ASTC10x8SRGB => (true, 10), - P::ASTC10x10SRGB => (true, 11), - P::ASTC12x10SRGB => (true, 12), - P::ASTC12x12SRGB => (true, 13), - P::ASTC4x4LDR => (false, 0), - P::ASTC5x4LDR => (false, 1), - P::ASTC5x5LDR => (false, 2), - P::ASTC6x5LDR => (false, 3), - P::ASTC6x6LDR => (false, 4), - P::ASTC8x5LDR => (false, 5), - P::ASTC8x6LDR => (false, 6), - P::ASTC8x8LDR => (false, 7), - P::ASTC10x5LDR => (false, 8), - P::ASTC10x6LDR => (false, 9), - P::ASTC10x8LDR => (false, 10), - P::ASTC10x10LDR => (false, 11), - P::ASTC12x10LDR => (false, 12), - P::ASTC12x12LDR => (false, 13), - _ => return None, - }; - let [width, height] = FOOTPRINTS[index]; + let (srgb, hdr) = Self::profile(pf)?; + let [width, height] = crate::metal::format::block_extent(pf)?; Some(AstcDecode { width, height, srgb, - hdr: false, + hdr, }) } - /// The footprint's place in [`FOOTPRINTS`] of an `_HDR` format of one. - fn hdr_index(pf: PixelFormat) -> Option { + /// Whether the ASTC format `pf` is an `_sRGB` one and whether an `_HDR` one; `None` for any + /// other format. + fn profile(pf: PixelFormat) -> Option<(bool, bool)> { use PixelFormat as P; Some(match pf { - P::ASTC4x4HDR => 0, - P::ASTC5x4HDR => 1, - P::ASTC5x5HDR => 2, - P::ASTC6x5HDR => 3, - P::ASTC6x6HDR => 4, - P::ASTC8x5HDR => 5, - P::ASTC8x6HDR => 6, - P::ASTC8x8HDR => 7, - P::ASTC10x5HDR => 8, - P::ASTC10x6HDR => 9, - P::ASTC10x8HDR => 10, - P::ASTC10x10HDR => 11, - P::ASTC12x10HDR => 12, - P::ASTC12x12HDR => 13, + P::ASTC4x2SRGB + | P::ASTC4x4SRGB + | P::ASTC5x4SRGB + | P::ASTC5x5SRGB + | P::ASTC6x5SRGB + | P::ASTC6x6SRGB + | P::ASTC8x4SRGB + | P::ASTC8x5SRGB + | P::ASTC8x6SRGB + | P::ASTC8x8SRGB + | P::ASTC10x5SRGB + | P::ASTC10x6SRGB + | P::ASTC10x8SRGB + | P::ASTC10x10SRGB + | P::ASTC12x10SRGB + | P::ASTC12x12SRGB => (true, false), + P::ASTC4x2LDR + | P::ASTC4x4LDR + | P::ASTC5x4LDR + | P::ASTC5x5LDR + | P::ASTC6x5LDR + | P::ASTC6x6LDR + | P::ASTC8x4LDR + | P::ASTC8x5LDR + | P::ASTC8x6LDR + | P::ASTC8x8LDR + | P::ASTC10x5LDR + | P::ASTC10x6LDR + | P::ASTC10x8LDR + | P::ASTC10x10LDR + | P::ASTC12x10LDR + | P::ASTC12x12LDR => (false, false), + P::ASTC4x2HDR + | P::ASTC4x4HDR + | P::ASTC5x4HDR + | P::ASTC5x5HDR + | P::ASTC6x5HDR + | P::ASTC6x6HDR + | P::ASTC8x4HDR + | P::ASTC8x5HDR + | P::ASTC8x6HDR + | P::ASTC8x8HDR + | P::ASTC10x5HDR + | P::ASTC10x6HDR + | P::ASTC10x8HDR + | P::ASTC10x10HDR + | P::ASTC12x10HDR + | P::ASTC12x12HDR => (false, true), _ => return None, }) } diff --git a/crates/metal2vulkan/src/bind/astc_decode/tests.rs b/crates/metal2vulkan/src/bind/astc_decode/tests.rs index 324b0585a..999954672 100644 --- a/crates/metal2vulkan/src/bind/astc_decode/tests.rs +++ b/crates/metal2vulkan/src/bind/astc_decode/tests.rs @@ -10,15 +10,15 @@ use crate::metal::PixelFormat; use crate::spirv::interp::{run, Buffer, Config, Order, Resources}; use crate::spirv::testing::{assert_valid, committed_profiles}; -/// The fourteen 2D footprints, linear, sRGB and HDR, decode, and no other format does (Apple's -/// 4x2 and 8x4 footprints among them). +/// Every ASTC format decodes, linear, sRGB and HDR, of the fourteen 2D footprints Vulkan's ASTC +/// formats have and of Apple's 4x2 and 8x4, and no other format does. #[test] -fn the_fourteen_footprints_of_every_profile_alone_decode() { +fn every_astc_format_of_every_profile_alone_decodes() { let decoded: Vec<(PixelFormat, AstcDecode)> = PixelFormat::ALL .iter() .filter_map(|&pf| AstcDecode::of(pf).map(|d| (pf, d))) .collect(); - assert_eq!(decoded.len(), 42); + assert_eq!(decoded.len(), 16 * 3); for (pf, d) in decoded { let name = pf.name(); let footprint = format!("_{}x{}_", d.width, d.height); @@ -28,10 +28,9 @@ fn the_fourteen_footprints_of_every_profile_alone_decode() { assert!(name.ends_with("_LDR") || d.srgb || d.hdr, "{name}"); } for pf in [ - PixelFormat::ASTC4x2HDR, - PixelFormat::ASTC4x2LDR, - PixelFormat::ASTC8x4SRGB, PixelFormat::BC7RGBAUnorm, + PixelFormat::PVRTCRGBA4BPP, + PixelFormat::RGBA8Unorm, ] { assert_eq!(AstcDecode::of(pf), None, "{pf:?}"); } @@ -145,13 +144,14 @@ fn fnv1a(bytes: &[u8]) -> u64 { } /// Every texel of 1024 seeded blocks (32 x 32 of them, seeded by the LDR form's raw value) of each -/// footprint, linear and sRGB, is Metal's read: the `float` texels' FNV-1a digest equals the -/// digest of what an Apple M3 Max (macOS 27.0.1) read of the same blocks (`texture.read` into -/// `float4`, our probe). Of each footprint 117 to 283 blocks are valid, the rest error blocks of -/// every kind; the probe's wider run (4096 valid-biased blocks a footprint) matched as well. +/// footprint, linear and sRGB, Apple's 4x2 and 8x4 among them, is Metal's read: the `float` +/// texels' FNV-1a digest equals the digest of what an Apple M3 Max (macOS 27.0.1) read of the same +/// blocks (`texture.read` into `float4`, our probes). Of each footprint 86 (Apple's 4x2) to 283 +/// blocks are valid, the rest error blocks of every kind; the probe's wider run (4096 valid-biased +/// blocks a footprint) matched as well. #[test] fn seeded_blocks_read_as_metal_read_them() { - const DIGESTS: [(u32, u64, u64); 14] = [ + const DIGESTS: [(u32, u64, u64); 16] = [ (204, 0x1ec2_3532_f7f1_3267, 0xeac0_f14e_3953_0337), (205, 0x8e4e_246a_e848_6e2a, 0xb1cf_2627_d93f_c546), (206, 0xc623_781c_7ea9_9899, 0xdfe3_b392_ea47_125d), @@ -166,6 +166,9 @@ fn seeded_blocks_read_as_metal_read_them() { (216, 0xe5eb_eef0_6b57_ea2c, 0x979d_0419_fa81_a371), (217, 0x3473_96ec_0297_8568, 0x4533_32fd_ec0e_d21b), (218, 0xa285_9133_6da5_5eff, 0x87a5_68d7_f82c_594a), + // Apple's 4x2 and 8x4 footprints (the probe `astc_passes_writes_footprints`, `digest`). + (203, 0x0ce8_1b3e_88fe_e772, 0x0e48_5529_95cd_c8c2), + (209, 0x5acd_5090_d21d_770b, 0x3663_c642_a5fa_92aa), ]; for (raw, linear, srgb) in DIGESTS { let blocks = seeded_blocks(u64::from(raw), 1024); @@ -181,7 +184,7 @@ fn seeded_blocks_read_as_metal_read_them() { .iter() .filter(|b| d.block_values(b).is_some()) .count(); - assert!(valid > 100, "{pf:?}: {valid} valid blocks"); + assert!(valid > 80, "{pf:?}: {valid} valid blocks"); } } } @@ -216,7 +219,12 @@ fn the_eight_bit_twin_holds_the_nearest_codes() { #[test] fn the_astc_decode_kernels_are_valid_on_every_committed_profile() { let profiles = committed_profiles().expect("profiles"); - for pf in [PixelFormat::ASTC4x4LDR, PixelFormat::ASTC12x12SRGB] { + for pf in [ + PixelFormat::ASTC4x4LDR, + PixelFormat::ASTC12x12SRGB, + PixelFormat::ASTC4x2LDR, + PixelFormat::ASTC8x4SRGB, + ] { let decode = AstcDecode::of(pf).expect("a decode"); for texels in [AstcTexels::Unorm8, AstcTexels::Float] { for (_, p) in &profiles { diff --git a/crates/metal2vulkan/src/bind/astc_decode/tests/hdr.rs b/crates/metal2vulkan/src/bind/astc_decode/tests/hdr.rs index 8d0ca3244..3d59342de 100644 --- a/crates/metal2vulkan/src/bind/astc_decode/tests/hdr.rs +++ b/crates/metal2vulkan/src/bind/astc_decode/tests/hdr.rs @@ -11,7 +11,7 @@ use crate::spirv::interp::Order; use crate::spirv::testing::{assert_valid, committed_profiles}; use crate::vk::Format; -/// The fourteen `_HDR` formats. +/// The sixteen `_HDR` formats. fn hdr_formats() -> Vec { (PixelFormat::ALL.iter().copied()) .filter(|&pf| AstcDecode::of(pf).is_some_and(|d| d.hdr)) @@ -57,7 +57,7 @@ const DOWN: u32 = 32; /// The FNV-1a digest of the `float` texels Metal read of `hdr_seeded_blocks(raw · 7919, 2048)`, /// 64 x 32 blocks of each `_HDR` format, row-major. -const DIGESTS: [(u32, u64); 14] = [ +const DIGESTS: [(u32, u64); 16] = [ (222, 0x6a09_0dd1_d708_385e), (223, 0x5133_22f1_31e3_5360), (224, 0xe57f_f92a_3ad4_6a73), @@ -72,11 +72,14 @@ const DIGESTS: [(u32, u64); 14] = [ (234, 0x7bed_6c2f_1759_6320), (235, 0x5952_aae3_8906_bbe0), (236, 0x57c9_02f4_a42a_e0d1), + // Apple's 4x2 and 8x4 footprints (the probe `astc_passes_writes_footprints`, `digest`). + (221, 0x4273_ba75_4057_14f4), + (227, 0xd465_4f44_6d5e_52ba), ]; -/// Every texel of 2048 seeded blocks of each footprint (340 to 629 of them valid, decoding -/// through every colour endpoint mode, two to four partitions and two planes; 1 in 16 an HDR -/// void-extent block and 1 in 16 an LDR one) reads as Metal read it, bit for bit. +/// Every texel of 2048 seeded blocks of each footprint (270, Apple's 4x2, to 629 of them valid, +/// decoding through every colour endpoint mode, two to four partitions and two planes; 1 in 16 an +/// HDR void-extent block and 1 in 16 an LDR one) reads as Metal read it, bit for bit. #[test] fn hdr_seeded_blocks_read_as_metal_read_them() { for (raw, digest) in DIGESTS { @@ -89,7 +92,7 @@ fn hdr_seeded_blocks_read_as_metal_read_them() { let valid = (blocks.as_chunks::<16>().0.iter()) .filter(|b| d.block_values(b).is_some()) .count(); - assert!(valid > 300, "{pf:?}: {valid} valid blocks"); + assert!(valid > 250, "{pf:?}: {valid} valid blocks"); } } @@ -350,7 +353,7 @@ fn the_astc_hdr_decode_kernels_are_valid_on_every_committed_profile() { fn covering_hdr_blocks(decode: AstcDecode, seed: u64, each: usize, invalid: usize) -> Vec { let (mut modes, mut partitions, mut planes, mut void) = ([0; 16], [0; 5], 0, [0; 2]); let (mut good, mut bad) = (Vec::new(), Vec::new()); - for block in hdr_seeded_blocks(seed, 8192).as_chunks::<16>().0 { + for block in hdr_seeded_blocks(seed, 32768).as_chunks::<16>().0 { if decode.block_values(block).is_none() { if bad.len() < invalid * 16 { bad.extend_from_slice(block); @@ -396,7 +399,10 @@ fn the_astc_hdr_kernel_is_the_decode_on_every_texel() { let (blocks, size) = two_layers(four, covering_hdr_blocks(four, 222, 2, 4), 8); assert_kernel_decodes(four, AstcTexels::Half, &blocks, size, &both); assert_kernel_decodes(four, AstcTexels::Float, &blocks, size, &both[..1]); - for pf in hdr_formats().into_iter().skip(1) { + for pf in hdr_formats() + .into_iter() + .filter(|&pf| pf != PixelFormat::ASTC4x4HDR) + { let decode = AstcDecode::of(pf).expect("a decode"); let mut blocks = covering_hdr_blocks(decode, u64::from(pf.as_raw()), 1, 1); blocks.drain(16 * 4..blocks.len() - 16); diff --git a/crates/metal2vulkan/src/bind/heap/tests.rs b/crates/metal2vulkan/src/bind/heap/tests.rs index a571c5be9..0ddb629e1 100644 --- a/crates/metal2vulkan/src/bind/heap/tests.rs +++ b/crates/metal2vulkan/src/bind/heap/tests.rs @@ -123,7 +123,7 @@ fn fit_is_shape_samples_numeric_type_usage_and_aspect() { // A format the table holds no representation of fits no class: the heap does not know which // of its textures the function reads, so a resident one it cannot view is the neutral, and // nothing is refused. - let unheld = PixelFormat::ASTC4x2HDR; + let unheld = PixelFormat::RGB8Unorm; assert_eq!(fit(&shape(T::Type2D, unheld, 1, READ), &f2d), Fit::No); assert_eq!( fit( diff --git a/crates/metal2vulkan/src/metal/format/footprint.rs b/crates/metal2vulkan/src/metal/format/footprint.rs index b13ba30e8..527cd0209 100644 --- a/crates/metal2vulkan/src/metal/format/footprint.rs +++ b/crates/metal2vulkan/src/metal/format/footprint.rs @@ -20,13 +20,9 @@ //! over all 33 formats, and the probe sweep these rules were fitted against, which the runtime's //! `tests::heap_footprint_formats` replays. -use super::block_extent; use super::packed_codes; use crate::metal::PixelFormat; -/// The bytes of one ASTC block, whatever its texel extent. -const ASTC_BLOCK: u32 = 16; - /// How Metal lays out the bytes `heapTextureSizeAndAlignWithDescriptor:` counts for a texture of /// a format whose footprint the format's own structure decides ([`footprint`]). /// @@ -42,7 +38,7 @@ pub enum Footprint { Tiled { /// The bytes of one element: a texel, or a compressed format's block. bytes: u32, - /// The texels one element covers ([`block_extent`]). + /// The texels one element covers ([`block_extent`](super::block_extent)). block: [u32; 2], }, /// One linear plane of `bytes`-byte texels, packed: no row padding, no tiles and no @@ -77,33 +73,15 @@ pub enum Footprint { } /// Metal's footprint layout of `pf`, where the format's own structure decides it and no image of -/// this crate does: the 32 formats Metal answers `heapTextureSizeAndAlignWithDescriptor:` for -/// that `repr` holds no Vulkan candidate of (`astc_without_a_vulkan_block!` and -/// `formats_named_not_held!`). `None` for every other format, whose footprint its image decides. +/// this crate does: the 26 formats Metal answers `heapTextureSizeAndAlignWithDescriptor:` for +/// that `repr` holds no Vulkan candidate of (`formats_named_not_held!`). `None` for every other +/// format, whose footprint its image decides. /// /// This is **not** support for the format. A texture, a view, a copy, a read and a write of one /// stay refused `NotImplemented(Format)`, because this crate holds no image of it; a footprint is /// counted bytes, which needs none. pub fn footprint(pf: PixelFormat) -> Option { use PixelFormat as P; - // ASTC's 4x2 and 8x4 footprints, LDR, sRGB and HDR: an ASTC block is 16 bytes whatever its - // texel extent, and `block_extent` already answers theirs, so their footprint is the block - // layout every other ASTC format's is. That no Vulkan ASTC block has either extent is why - // the crate holds no image of them, not a reason Metal cannot count their bytes. - if matches!( - pf, - P::ASTC4x2LDR - | P::ASTC4x2SRGB - | P::ASTC4x2HDR - | P::ASTC8x4LDR - | P::ASTC8x4SRGB - | P::ASTC8x4HDR - ) { - return Some(Footprint::Tiled { - bytes: ASTC_BLOCK, - block: block_extent(pf)?, - }); - } let tiled = |bytes| { Some(Footprint::Tiled { bytes, diff --git a/crates/metal2vulkan/src/metal/format/mod.rs b/crates/metal2vulkan/src/metal/format/mod.rs index 4b8484aa0..8ba35c994 100644 --- a/crates/metal2vulkan/src/metal/format/mod.rs +++ b/crates/metal2vulkan/src/metal/format/mod.rs @@ -1066,20 +1066,6 @@ fn decoded(block: vk::Format, twin: vk::Format) -> Repr { ]) } -/// The pattern of ASTC's 4x2 and 8x4 formats, LDR, sRGB and HDR: Metal makes a 2D texture of -/// each from a descriptor alone (an Apple M4 under macOS 27.0.1), and no Vulkan -/// ASTC block has either footprint, so this crate holds none of them (`repr`'s `NotImplemented`). -macro_rules! astc_without_a_vulkan_block { - () => { - PixelFormat::ASTC4x2LDR - | PixelFormat::ASTC4x2SRGB - | PixelFormat::ASTC4x2HDR - | PixelFormat::ASTC8x4LDR - | PixelFormat::ASTC8x4SRGB - | PixelFormat::ASTC8x4HDR - }; -} - /// The pattern of the formats Metal names that this crate holds no texture of yet (`repr`'s /// `NotImplemented`): every raw value from 0 to 1100 a texture descriptor's description names on /// an Apple M4 under macOS 27.0.1 that no format above takes. Every Vulkan format of each is @@ -1679,9 +1665,19 @@ fn make_repr(pf: PixelFormat) -> Repr { // Formats Metal makes no texture of from a descriptor alone; one over // an IOSurface plane is not modelled. P::RGBA16FloatXR | P::AnyDepth | P::AnyStencil => Repr::NotImplemented, - // ASTC's 4x2 and 8x4 footprints, which Metal makes textures of: no - // Vulkan ASTC block has them, and decoding their blocks is not built. - astc_without_a_vulkan_block!() => Repr::NotImplemented, + // ASTC's 4x2 and 8x4 footprints, which Metal makes textures of: no Vulkan ASTC block has + // them, so their blocks lie in a carrier on every device and a function reads the decoded + // twin's view (`FormatEmulation::Decoded`) alone. + P::ASTC4x2LDR | P::ASTC8x4LDR => { + color(vec![combined(F::R8G8B8A8_UNORM, FormatEmulation::Decoded)]) + } + P::ASTC4x2SRGB | P::ASTC8x4SRGB => { + color(vec![combined(F::R8G8B8A8_SRGB, FormatEmulation::Decoded)]) + } + P::ASTC4x2HDR | P::ASTC8x4HDR => color(vec![combined( + F::R16G16B16A16_SFLOAT, + FormatEmulation::Decoded, + )]), formats_named_not_held!() => Repr::NotImplemented, P::Depth16Unorm => Repr::Candidates(depth, vec![direct(F::D16_UNORM)]), P::Depth32Float => Repr::Candidates( @@ -2426,7 +2422,6 @@ pub(crate) fn out_of_bounds_alpha_one(pf: PixelFormat) -> Option { P::Invalid | P::Unspecialized => return None, // Formats of which this crate holds no texture (`repr`'s `NotImplemented`). P::RGBA16FloatXR | P::AnyDepth | P::AnyStencil => return None, - astc_without_a_vulkan_block!() => return None, formats_named_not_held!() => return None, // No alpha: a missing alpha reads 1. P::R10UnormX6 | P::RG10UnormX12 | P::R10UnormX6SRGB | P::RG10UnormX12SRGB => true, @@ -2551,6 +2546,12 @@ pub(crate) fn out_of_bounds_alpha_one(pf: PixelFormat) -> Option { | P::EACRGBA8SRGB | P::ETC2RGB8A1 | P::ETC2RGB8A1SRGB + | P::ASTC4x2SRGB + | P::ASTC8x4SRGB + | P::ASTC4x2LDR + | P::ASTC8x4LDR + | P::ASTC4x2HDR + | P::ASTC8x4HDR | P::ASTC4x4SRGB | P::ASTC5x4SRGB | P::ASTC5x5SRGB diff --git a/crates/metal2vulkan/src/metal/format/tests.rs b/crates/metal2vulkan/src/metal/format/tests.rs index 1fa07b08f..e9ce07f43 100644 --- a/crates/metal2vulkan/src/metal/format/tests.rs +++ b/crates/metal2vulkan/src/metal/format/tests.rs @@ -75,7 +75,6 @@ fn refused_formats_are_exactly_the_documented_set() { // The two-plane extended-range pair is held raw, the 4:2:2 pair through its decoded twin. // The 68 two-plane YCbCr formats but `YCBCR8_420_2P`, and the 3 others Metal makes no // texture of from a descriptor alone. - // + ASTC's 6 formats of a 4x2 or 8x4 footprint, which no Vulkan block has. // - `YCBCR10_420_2P`, `RGB10_420_2P` and the `_sRGB` twins of the 4:2:0 converted pair, made // over a surface. // - `RGB8_420_2P`, made over a surface. @@ -89,11 +88,10 @@ fn refused_formats_are_exactly_the_documented_set() { // - the three bfloat formats, held raw. // - `RGB10A2Unorm_sRGB`, held raw. // - `BGRA4Unorm`, held in the 4-bit word of its bits. - assert_eq!(count("not_implemented"), 45 + 3 + 6 + 60, "{refused:?}"); + assert_eq!(count("not_implemented"), 45 + 3 + 60, "{refused:?}"); assert!(refused["not_implemented"].iter().all(|&pf| { (ycbcr_format(pf).is_some() && !ycbcr(pf)) || matches!(pf, P::RGBA16FloatXR | P::AnyDepth | P::AnyStencil) - || matches!(pf, astc_without_a_vulkan_block!()) || matches!(pf, formats_named_not_held!()) })); } @@ -114,13 +112,15 @@ fn direct_formats_round_trip() { assert!(c.format.is_known(), "{pf:?} -> {:?}", c.format); assert_ne!(c.format, vk::Format::UNDEFINED, "{pf:?}"); } - // A PVRTC RGB or 4:2:2 format, held through its decoded twin's view alone, has no - // direct format: no Vulkan format holds its blocks as Metal reads them. + // A PVRTC RGB, 4:2:2 or ASTC 4x2 or 8x4 format, held through its decoded twin's view + // alone, has no direct format: no Vulkan format holds its blocks as Metal reads them. if candidates[0].emulation == FormatEmulation::Decoded { assert_eq!(direct_format(pf), None, "{pf:?}"); let pvrtc = crate::bind::PvrtcDecode::of(pf).is_some(); assert!( - pvrtc || crate::bind::ChromaDecode::of(pf).is_some(), + pvrtc + || crate::bind::ChromaDecode::of(pf).is_some() + || crate::bind::AstcDecode::of(pf).is_some(), "{pf:?}" ); continue; @@ -990,33 +990,38 @@ fn compressed_extension_formats_follow_exposure() { } /// ASTC's 4x2 and 8x4 formats take the raw values and names Metal gave them in our census, so a -/// consumer holds each, and every usage of each is refused `NotImplemented(Format)` on every -/// committed device: no Vulkan block has their footprints. +/// consumer holds each. No Vulkan block has their footprints, so on every committed device each is +/// sampled through its decoded twin's view alone (`R8G8B8A8_UNORM`, `_SRGB` for an sRGB form, +/// `R16G16B16A16_SFLOAT` for an HDR one), and an attachment or storage use of one is refused as +/// the device lacking the format: the runtime keeps its blocks in a carrier. #[test] -fn astc_4x2_and_8x4_are_named_and_refused_typed() { +fn astc_4x2_and_8x4_are_named_and_read_through_their_twin() { + use vk::Format as F; use FormatUsage as U; let named = [ - (185, "MTLPixelFormatASTC_4x2_sRGB"), - (191, "MTLPixelFormatASTC_8x4_sRGB"), - (203, "MTLPixelFormatASTC_4x2_LDR"), - (209, "MTLPixelFormatASTC_8x4_LDR"), - (221, "MTLPixelFormatASTC_4x2_HDR"), - (227, "MTLPixelFormatASTC_8x4_HDR"), + (185, "MTLPixelFormatASTC_4x2_sRGB", F::R8G8B8A8_SRGB), + (191, "MTLPixelFormatASTC_8x4_sRGB", F::R8G8B8A8_SRGB), + (203, "MTLPixelFormatASTC_4x2_LDR", F::R8G8B8A8_UNORM), + (209, "MTLPixelFormatASTC_8x4_LDR", F::R8G8B8A8_UNORM), + (221, "MTLPixelFormatASTC_4x2_HDR", F::R16G16B16A16_SFLOAT), + (227, "MTLPixelFormatASTC_8x4_HDR", F::R16G16B16A16_SFLOAT), ]; - for (raw, name) in named { + for (raw, name, twin) in named { let pf = PixelFormat::try_from(raw).unwrap_or_else(|e| panic!("{raw}: {e}")); assert_eq!(pf.name(), name); assert_eq!(PixelFormat::from_name(name), Some(pf)); - assert!(matches!(pf, astc_without_a_vulkan_block!()), "{name}"); + assert_eq!(direct_format(pf), None, "{name}"); for (stem, device) in committed_devices() { - for u in [ - U::SampledImage, - U::SampledImageFilterLinear, - U::ColorAttachment, - ] { - assert_eq!( - vk_format(pf, &usages(&[u]), device.profile()), - Err(Unsupported::not_implemented(Feature::Format).into()), + let sampled = vk_format(pf, &usages(&[U::SampledImage]), device.profile()) + .unwrap_or_else(|e| panic!("{name} on {stem}: {e:?}")); + assert_eq!( + (sampled.format, sampled.emulation), + (twin, FormatEmulation::Decoded), + "{name} on {stem}" + ); + for u in [U::ColorAttachment, U::StorageImage] { + assert!( + vk_format(pf, &usages(&[u]), device.profile()).is_err(), "{name} {u:?} on {stem}" ); } @@ -2213,7 +2218,6 @@ fn out_of_bounds_alpha_follows_the_measured_formats() { let placeholder = matches!(pf, P::Invalid | P::Unspecialized); let held_none = (ycbcr_format(pf).is_some() && !ycbcr(pf)) || matches!(pf, P::RGBA16FloatXR | P::AnyDepth | P::AnyStencil) - || matches!(pf, astc_without_a_vulkan_block!()) || matches!(pf, formats_named_not_held!()); assert_eq!( out_of_bounds_alpha_one(pf).is_none(), @@ -2863,7 +2867,6 @@ fn every_block_extent_is_the_vulkan_blocks() { for &pf in &unchecked { assert!( pvrtc(pf) - || matches!(pf, astc_without_a_vulkan_block!()) || matches!( repr(pf), Repr::Candidates(_, ref candidates) @@ -2921,29 +2924,21 @@ fn footprint_answers_where_no_image_does() { ); } } - // The 32 formats of which Metal answers `heapTextureSizeAndAlignWithDescriptor:` and this - // crate holds no image: the six ASTC footprints, `ARGB8Unorm_sRGB`, nine one-plane YCbCr - // formats, ten padded 10- and 12-bit display formats, four two-plane ones and two packed - // ones Metal makes no texture of. - assert_eq!(answered, 6 + 1 + 9 + 10 + 4 + 2); + // The 26 formats of which Metal answers `heapTextureSizeAndAlignWithDescriptor:` and this + // crate holds no image: `ARGB8Unorm_sRGB`, nine one-plane YCbCr formats, ten padded 10- and + // 12-bit display formats, four two-plane ones and two packed ones Metal makes no texture of. + assert_eq!(answered, 1 + 9 + 10 + 4 + 2); } /// Every byte count [`footprint`] states is the bytes of a format the crate **does** hold whose /// element is the same size: a padded 12-bit channel takes the 16-bit word a padded 10-bit one -/// takes, a transfer-function twin's is its base format's, a 4:2:2 texel is a luma byte and a chroma byte (`RG8Unorm`'s two), and an ASTC block -/// is 16 bytes at every footprint. So no number in the table is one nobody checked: each is held +/// takes, a transfer-function twin's is its base format's, and a 4:2:2 texel is a luma byte and a chroma byte (`RG8Unorm`'s two). So no number in the table is one nobody checked: each is held /// to a Vulkan block size the mapping already answers. #[test] fn footprint_bytes_match_a_held_twin() { use PixelFormat as P; // (the format with no image, the format the crate holds whose element is the same size). const TWINS: &[(PixelFormat, PixelFormat)] = &[ - (P::ASTC4x2LDR, P::ASTC4x4LDR), - (P::ASTC4x2SRGB, P::ASTC4x4SRGB), - (P::ASTC4x2HDR, P::ASTC4x4HDR), - (P::ASTC8x4LDR, P::ASTC4x4LDR), - (P::ASTC8x4SRGB, P::ASTC4x4SRGB), - (P::ASTC8x4HDR, P::ASTC4x4HDR), (P::ARGB8UnormSRGB, P::ARGB8Unorm), (P::R12UnormX4, P::R10UnormX6), (P::R12UnormX4PQ, P::R10UnormX6), diff --git a/crates/metal2vulkan/src/tests/engine_graphics_binder.rs b/crates/metal2vulkan/src/tests/engine_graphics_binder.rs index 21e22c0ef..036e2ad06 100644 --- a/crates/metal2vulkan/src/tests/engine_graphics_binder.rs +++ b/crates/metal2vulkan/src/tests/engine_graphics_binder.rs @@ -1555,7 +1555,7 @@ fn a_texture_without_a_representation_is_refused_only_where_its_function_reads_i ) else { return; }; - let unheld = || texture(TextureType::Type2D, PixelFormat::ASTC4x2HDR); + let unheld = || texture(TextureType::Type2D, PixelFormat::RGB8Unorm); let rgba = || texture(TextureType::Type2D, PixelFormat::RGBA8Unorm); let linear = || sampler(true, SamplerReductionMode::WeightedAverage); let refused = |r: &Result| matches!(r, Err(BindError::Unsupported(u)) if u.feature == Feature::Format); diff --git a/docs/API.md b/docs/API.md index be73ba46e..1866e836c 100644 --- a/docs/API.md +++ b/docs/API.md @@ -2367,7 +2367,7 @@ bound. level by a rule that differs by family and by release, measured at the release every device answers as (`MACOS_RELEASE`) for the BC, ETC2, EAC, ASTC and PVRTC families (an Apple M3 Max, and an Apple M4 alike but PVRTC), whose textures lie as Metal lays them out; a format of none of them - (ASTC's 4x2 and 8x4 footprints) lies in the runtime's layout. Cost: the texture's + lies in the runtime's layout. Cost: the texture's reads, writes and copies are Metal's, but its blocks lie in the heap's bytes in the runtime's layout, where Metal tiles them: a buffer or texture over them meets the blocks at other bytes than on Metal. diff --git a/docs/FAST-PATHS.md b/docs/FAST-PATHS.md index 83279b2be..94e968766 100644 --- a/docs/FAST-PATHS.md +++ b/docs/FAST-PATHS.md @@ -530,20 +530,20 @@ driver's. Each is open work. that does not render the format** (the RTX 5080). Its word view takes a `float` output's writes, clears and resolves; a `half` output and a color input are `NotImplemented(Format)`, and a blend or a mask of some of its channels is refused as the device lacking the format. -- **ASTC textures on a device without ASTC.** Making a heap's or a sparse heap's such texture - (`RuntimeGap::DecodedHeapTexture`) and a view of another decode (an LDR or sRGB texture's HDR - form, an HDR texture's LDR or sRGB form) are refused. The heap size query answers one: its - footprint is Metal's blocks, which no image of the device decides. A pass rendering into one, - and a kernel's write of one, are refused where Metal's validation stops them (plain Metal's pass - stores nothing, and its write leaves bytes no format defines). -- **The 32 formats this crate holds no image of** (`metal::format::footprint`: ASTC's 4x2 and 8x4 - footprints, `ARGB8Unorm_sRGB`, Apple's nine one-plane `YCBCR*` formats, the ten +- **ASTC textures on a device without ASTC** (and Apple's 4x2 and 8x4 footprints on every + device). Making a heap's or a sparse heap's such texture (`RuntimeGap::DecodedHeapTexture`) and + a view of another decode (an LDR or sRGB texture's HDR form, an HDR texture's LDR or sRGB form) + are refused. The heap size query answers one: its footprint is Metal's blocks, which no image of + the device decides. A pass rendering into one, and a kernel's write of one, are refused where + Metal's validation stops them (plain Metal's pass stores nothing, and its write leaves bytes no + format defines). +- **The 26 formats this crate holds no image of** (`metal::format::footprint`: + `ARGB8Unorm_sRGB`, Apple's nine one-plane `YCBCR*` formats, the ten padded 10- and 12-bit display formats, the four `RGB10A8_2P` ones and the two packed 10-bit ones). `heapTextureSizeAndAlignWithDescriptor:` answers Metal's exact size and alignment for every one, because the footprint is arithmetic over the descriptor and no image decides it. A - texture, a view, a copy, a read and a write of one stay refused `NotImplemented(Format)`: no - Vulkan format holds the bytes (an ASTC 4x2 or 8x4 block) or their reads and writes are not - measured yet. Plain Metal lays out no image storage for the two packed 10-bit + texture, a view, a copy, a read and a write of one stay refused `NotImplemented(Format)`: their + reads and writes are not measured yet. Plain Metal lays out no image storage for the two packed 10-bit ones and makes a texture from every creator that needs none -- a placement heap's offset, the shared creator in `Private`, a buffer's and an IOSurface plane's own bytes, and `Memoryless` -- so the refusal from each of those is this crate's own and not Metal's nil; the device's own