From 766ba91b30f1dcbbc33ec5e2a7212c8e8e55e9f6 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Thu, 22 Oct 2026 18:58:08 +0300 Subject: [PATCH] Keep a heap's two-plane array and mipmapped texture in the heap's bytes The steps this packet landed as, in order: - Give the 3D two-plane heap texture test a Private descriptor - Lay a heap's depth and stencil textures out in Metal's tiles on MoltenVK - Answer Metal's heap size for PVRTC textures and tile them under 27.0.1 - Lay a heap's Depth32Float_Stencil8 texture out in Metal's two tiled planes - Make a host heap's uncompressed multisample texture in memory of its own - List the two-plane array fixture in the engine inventory, with its printout - Let the no-copy heap lane find a compressed texture's texels in Metal's tiles - Name the depth heap lane's aspect list type for clippy - Announce a device heap's textures whose bytes are not Metal's layout - Lay a heap's X32_Stencil8 texture out in a Stencil8 texture's tiles Content: the tree of `development` at b3c694ad82, unchanged. --- .../metal2vulkan-runtime/src/degradation.rs | 96 ++-- crates/metal2vulkan-runtime/src/error.rs | 17 +- .../metal2vulkan-runtime/src/metal_level.rs | 8 +- crates/metal2vulkan-runtime/src/shadow.rs | 12 +- .../src/tests/degradation_codes.txt | 1 + crates/metal2vulkan-runtime/src/tests/heap.rs | 52 +- .../src/tests/heap_tiled.rs | 90 +++- .../src/tests/heap_tiled_blocks.rs | 239 ++++++++- crates/metal2vulkan-runtime/src/texture.rs | 21 +- .../metal2vulkan-runtime/src/texture/heap.rs | 408 +++++++++++---- .../src/texture/heap_tiled.rs | 350 ++++++++++--- .../src/texture/heap_two_planes.rs | 215 ++++++-- .../src/texture/surface_depth.rs | 4 +- .../metal2vulkan-runtime/src/work_counts.rs | 20 +- .../fixtures/public/engine/TOOLCHAIN | 1 + .../public/engine/xr_two_plane_arrays.air.ll | 123 +++++ .../public/engine/xr_two_plane_arrays.ll | 121 +++++ .../public/engine/xr_two_plane_arrays.metal | 26 + .../src/runtime_lane/degrade_notices.rs | 7 +- .../runtime_lane/extended_range_two_planes.rs | 286 +++++++++- .../src/runtime_lane/heap_layouts.rs | 114 ++-- .../src/runtime_lane/heap_metal_sizes.rs | 29 +- .../src/runtime_lane/heap_textures.rs | 494 ++++++++++++++++-- .../src/runtime_lane/no_copy_heaps.rs | 27 +- .../src/runtime_lane/texture_fills.rs | 21 +- .../metal2vulkan/src/device/driver_facts.rs | 20 + .../tests/air_input/xr_two_plane_arrays.txt | 156 ++++++ .../public_fixture_expectations_engine.tsv | 4 + docs/API.md | 65 ++- docs/REFUSALS.md | 162 +++--- scripts/refusal-surface/reach.tsv | 1 - 31 files changed, 2616 insertions(+), 574 deletions(-) create mode 100644 crates/metal2vulkan-validation/fixtures/public/engine/xr_two_plane_arrays.air.ll create mode 100644 crates/metal2vulkan-validation/fixtures/public/engine/xr_two_plane_arrays.ll create mode 100644 crates/metal2vulkan-validation/fixtures/public/engine/xr_two_plane_arrays.metal create mode 100644 crates/metal2vulkan/tests/air_input/xr_two_plane_arrays.txt diff --git a/crates/metal2vulkan-runtime/src/degradation.rs b/crates/metal2vulkan-runtime/src/degradation.rs index 3fe59fbd3..a53a97afd 100644 --- a/crates/metal2vulkan-runtime/src/degradation.rs +++ b/crates/metal2vulkan-runtime/src/degradation.rs @@ -995,13 +995,14 @@ degradations! { /// A depth or stencil texture with `allowGPUOptimizedContents` off sized or made in a heap /// (never a device's own texture, whose layout nothing shows), on a device whose driver /// keeps depth and stencil images GPU-optimized whatever their create info - /// ([`metal2vulkan::device::DriverFact::DepthStencilImagesStayGpuOptimized`]): Metal lays - /// the texture out without its compression metadata, and the runtime's image keeps it. + /// ([`metal2vulkan::device::DriverFact::DepthStencilImagesStayGpuOptimized`]), that no + /// shadow of Metal's tiles in the heap's bytes serves (a multisample texture, a depth twin, + /// a format whose layout is not measured; `texture/heap.rs`): Metal lays the texture out + /// without its compression metadata, and the runtime's image keeps it. OptimizedDepthStencilTexture = "optimized-depth-stencil-texture", Precision, "the texture keeps its GPU-optimized layout: heap_texture_size_and_align answers \ - Metal's size for the texture with the property on, larger than Metal's with it off \ - (16512 bytes for a 64x64 Depth32Float texture, where Metal answers 16384), so a \ - heap sized by Metal's answers holds fewer such textures"; + Metal's size for the texture with the property on, larger than Metal's with it off, \ + so a heap sized by Metal's answers holds fewer such textures"; /// A texture of an IOSurface plane of more than one row under 16 bytes a row /// (`Buffer::new_texture_with_iosurface_plane`, `linear_plan.rs`): Metal's GPU writes its /// rows 16 bytes apart and reads every row past the first as memory-dependent bytes @@ -1135,15 +1136,31 @@ degradations! { UndeclaredUsageShadow = "undeclared-usage-shadow", Performance, "its texels are copied into an image of its own before each command that binds it \ beyond its declared usage, and back after each write through it"; - /// A texture of `RGB10A8_2P_XR10` or its sRGB twin made in a heap - /// (`texture/heap.rs`) other than a 2D texture of one level, whose planes the heap's - /// bytes keep: its one image holds each texel's colour word and alpha byte side by side, - /// more than Metal's two planes take in the heap, so it lies in memory of its own. + /// A texture of `RGB10A8_2P_XR10` or its sRGB twin made in a heap (`texture/heap.rs`) + /// whose planes no shadow of the heap's bytes holds: a 3D texture of more than one depth + /// slice (Metal's writes lay its depth slices over one another), or one whose moves pass + /// the device's limits (`texture/heap_two_planes.rs`). Its one image holds each texel's + /// colour word and alpha byte side by side, more than Metal's two planes take in the + /// heap, so it lies in memory of its own. HeapTwoPlaneTexture = "heap-two-plane-texture", Precision, "the texture's size and alignment answers are Metal's and its reads, writes and \ copies as outside a heap, but its texels lie in memory of its own, apart from the \ heap's bytes: a buffer or texture over its range of the heap neither sees nor \ changes them, where Metal's texture keeps its two planes there"; + /// A texture of `RGB10A8_2P_XR10` or its sRGB twin made in a heap whose first level's + /// planes lie in the heap's bytes (`texture/heap_two_planes.rs`), of more than one level, + /// or a 1D array: Metal's paths address the texture's levels past the first at bytes that + /// differ by path (its CPU copies at its first level's rows from past that level, its + /// blits and an array's GPU writes over the first level's bytes, a 2D texture's GPU + /// writes nowhere, its GPU reads at other bytes again), and a 1D array's GPU reads every + /// texel at the texture's first word. The runtime keeps the first level's slices in the + /// heap's bytes, as Metal's CPU copies and GPU writes lay them, and the other levels in the + /// texture's image alone. + HeapTwoPlaneLayout = "heap-two-plane-layout", Precision, + "the first level's texels lie in the heap's bytes as Metal's CPU copies and GPU \ + writes lay them, and read as written; the later levels' texels lie apart from the \ + heap's bytes, and a 1D array's GPU reads read each texel, where Metal's paths \ + address those texels at bytes that differ by path"; /// A MoltenVK device at a release whose `pipelineCacheUUID` layout the runtime has not /// read (`device/argument_buffers.rs`): whether MoltenVK binds through Metal argument /// buffers is unknown, so a device without them is not refused (as at a read release). @@ -1413,13 +1430,17 @@ degradations! { ZeroLayerMapAfterRelease = "zero-layer-map-after-release", Precision, "the draws write nothing, where Metal draws rows of the pass (a 64-pixel map's rows 0 \ to 15, at the positions of a pass with no map)"; - /// A texture made in a heap over host pages (`new_heap_with_bytes_no_copy`) that Metal - /// keeps losslessly compressed (`allowGPUOptimizedContents`, the shorter side of level - /// 0 16 texels or more, and a colour format of neither `ShaderWrite` nor - /// `PixelFormatView` usage, or a depth or stencil format): its bytes - /// on Metal are no layout of its texels, so the runtime lays them out as its own - /// (`texture/heap_tiled.rs`). A multisample texture so (its sample grid's shorter side - /// 16 or more) lies in memory of its own, the heap's bytes keeping what they held. + /// A texture made in a heap over host pages (`new_heap_with_bytes_no_copy`), or a depth + /// or stencil texture made in any heap as a shadow of Metal's tiles (on a driver that + /// lays such images apart from their memory or keeps them GPU-optimized: MoltenVK), that + /// Metal keeps losslessly compressed (`allowGPUOptimizedContents`, the shorter side of + /// level 0 16 texels or more, and a colour format of neither `ShaderWrite` nor + /// `PixelFormatView` usage, or a depth or stencil format): its bytes on Metal are no + /// layout of its texels, so the runtime lays them out as its own, its uncompressed tiles + /// where it tiles them (`texture/heap_tiled.rs`). A multisample texture so (its sample + /// grid's shorter side 16 or more) lies in memory of its own, the heap's bytes keeping + /// what they held. Also such a texture whose image lies in a heap over the device's + /// memory: the image, of the runtime's usage, need not be compressed as Metal's. /// Announced once per device, in the call that made the first such texture, with its ID /// ([`DegradeNotice::object_id`]), or for each texture where `DeviceOptions::announce_each` /// asks; each texture counted @@ -1432,12 +1453,12 @@ degradations! { bytes than Metal's would"; /// A texture of a block-compressed format made in a heap over host pages whose /// placement the device's Metal level does not measure: Metal places a format family's - /// blocks in each level by a rule that differs by family and by machine - /// (`texture/heap_tiled.rs`), measured for BC, ETC2, EAC and ASTC on an Apple M4 under - /// macOS 27.0.1 and an Apple M3 Max under 26.7 (whether the GPU or the release makes - /// their difference is not known), where those lie as Metal lays them out, and not for - /// PVRTC at any level, whose blocks lie in the runtime's layout. Its size and alignment - /// answers are its device's. Announced once per device, in the call that made the first such + /// blocks in each level by a rule that differs by family and by release + /// (`texture/heap_tiled.rs`), measured for BC, ETC2, EAC and ASTC under macOS 27.0.1 (an + /// Apple M3 Max and an Apple M4 alike) and 26.7 (an Apple M3 Max), and for PVRTC under + /// 27.0.1 (an Apple M3 Max), where those lie as Metal lays them out, and not for PVRTC + /// under 26.7, whose blocks lie in the runtime's layout. Its size and alignment answers + /// are its device's. Announced once per device, in the call that made the first such /// texture, with its ID ([`DegradeNotice::object_id`]), or for each texture where /// `DeviceOptions::announce_each` asks; each texture counted /// ([`Device::degraded_objects`](crate::Device::degraded_objects)). @@ -1446,12 +1467,18 @@ degradations! { 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"; /// A texture made in a heap over host pages that Metal lays out tiled where the runtime - /// does not (`texture/heap_tiled.rs`): a layout not measured (a two-aspect depth and - /// stencil format, a PVRTC format), an image that holds other - /// bytes than Metal's elements, or moves past the device's limits. The notice's reason - /// names which (the first texture's). Announced once per device, in the call that made - /// the first such texture, with its ID ([`DegradeNotice::object_id`]), or for each - /// texture where `DeviceOptions::announce_each` asks; each texture counted + /// does not (`texture/heap_tiled.rs`): a layout not measured (a format whose layout in + /// Metal's heaps is not probed), an image that holds other bytes than Metal's elements, or + /// moves past the device's limits. Also a texture made in any other heap (over the device's + /// memory) whose bytes there are not Metal's layout (`texture/heap.rs`): its image bound + /// there in the driver's layout, on a driver whose colour images are not measured to lie as + /// Metal's heap textures + /// ([`metal2vulkan::device::DriverFact::ColorImagesLieAsMetalHeapTextures`]) or of a depth + /// or stencil texture there; its image a shadow of the bytes in rows; a multisample + /// texture; or a layout not measured. The notice's reason names which (the first + /// texture's). Announced once per device, in the call that made the first such texture, + /// with its ID ([`DegradeNotice::object_id`]), or for each texture where + /// `DeviceOptions::announce_each` asks; each texture counted /// ([`Device::degraded_objects`](crate::Device::degraded_objects)). HeapTextureUntiledLayout = "heap-texture-untiled-layout", Precision, "the texture's reads, writes and copies are Metal's, but its texels lie in the \ @@ -2911,10 +2938,11 @@ impl Device { self.deliver_placed(kind, notice.message(), misplaced); } - /// Count the texture of `texture`, made in a heap over host pages in this program call, as - /// laid out otherwise than Metal tiles it, for `untiled`'s reason (`heap-texture-*-layout`, - /// `texture/heap_tiled.rs`), and announce it, with its ID, where it is the first of its kind - /// (or at each texture, where the device's options ask). + /// Count the texture of `texture`, made in a heap in this program call, as laid out + /// otherwise than Metal lays it in the heap's bytes, for `untiled`'s reason + /// (`heap-texture-*-layout`, `texture/heap_tiled.rs`, `texture/heap.rs`), and announce it, with + /// its ID, where it is the first of its kind (or at each texture, where the device's options + /// ask). pub(super) fn degrade_heap_layout(&self, untiled: Untiled, texture: ObjectId) { let shared = self.shared(); let kind = untiled.kind; @@ -2934,8 +2962,8 @@ impl Device { /// How many objects this device met as `kind` so far, for a kind it meets once per object /// and announces once (naming the first object, [`DegradeNotice::object_id`]), so that a - /// census counts them without a notice each: the textures made in heaps over host pages laid - /// out otherwise than Metal tiles them ([`Degradation::HeapTextureLosslessLayout`], + /// census counts them without a notice each: the textures made in heaps laid out otherwise + /// than Metal lays them in the heap's bytes ([`Degradation::HeapTextureLosslessLayout`], /// [`Degradation::HeapTextureBlockCompressedLayout`] and /// [`Degradation::HeapTextureUntiledLayout`], each counted as it is made), and the textures /// over detached bytes a command buffer could reach unnamed diff --git a/crates/metal2vulkan-runtime/src/error.rs b/crates/metal2vulkan-runtime/src/error.rs index 2b6c8ded4..fc3f429bb 100644 --- a/crates/metal2vulkan-runtime/src/error.rs +++ b/crates/metal2vulkan-runtime/src/error.rs @@ -1131,9 +1131,8 @@ pub enum RuntimeGap { /// the heap's. Memory of its own would lose the heap's aliasing. (A texture whose linear image /// needs extended usage is checked format by format, not refused with it.) In a heap over host /// pages, also a texture no linear image over the pages serves and no shadow of the heap's - /// bytes holds, and one with a depth twin. A multisample texture there that Metal keeps - /// compressed is made in memory of its own, and any other is - /// [`RuntimeGap::HostHeapUncompressedMultisample`]. + /// bytes holds, and one with a depth twin. A multisample texture there is made in memory of + /// its own. HeapTextureMemory, /// A visible-function table of more entries than one buffer of the device's /// `max_buffer_length` holds words for, or than its size word holds: the runtime keeps a @@ -1500,18 +1499,6 @@ pub enum RuntimeGap { /// The descriptor's pixel format. pixel_format: PixelFormat, }, - /// A multisample texture in a heap over host pages (`Device::new_heap_with_bytes_no_copy`) - /// that Metal keeps uncompressed: without `allowGPUOptimizedContents`, of `ShaderWrite` or - /// `PixelFormatView` usage (a colour format), or whose sample grid (`width x 2·height` at 2 - /// samples, `2·width x 2·height` at 4) is under 16 on its shorter side. Metal makes it and lays - /// its samples out in the heap's bytes (each pixel's samples side by side in Metal's tiles, - /// measured on an Apple M4 under macOS 27.0.1 and an M3 Max under 26.7, alike), which a - /// buffer over them reads and writes; no route of the runtime's holds them there yet. Also a - /// sample count Apple's GPUs do not make (8), whose layout is not measured, and an - /// uncompressed `Depth32Float_Stencil8` texture's, also not measured. One Metal keeps - /// compressed is made, in memory of its own (`heap-texture-lossless-layout`). The heap size - /// query answers Metal's size and alignment for it. - HostHeapUncompressedMultisample, /// An unbalanced command-predication record (`ComputeCommandEncoder::encode_end_if` and the /// other ends, or `encode_start_else`, with no block open; `encode_start_if` on a nil buffer /// with none) that is its unit's first record, after dispatches of the unit (of this encoder, diff --git a/crates/metal2vulkan-runtime/src/metal_level.rs b/crates/metal2vulkan-runtime/src/metal_level.rs index d90d02aab..7d60f1a51 100644 --- a/crates/metal2vulkan-runtime/src/metal_level.rs +++ b/crates/metal2vulkan-runtime/src/metal_level.rs @@ -94,6 +94,7 @@ struct HeapBlocks { bc: Option, etc: Option, astc: Option, + pvrtc: Option, /// How its GPU counts a level's tiles a row, every family alike. gpu_rows: GpuRows, } @@ -112,6 +113,7 @@ const MACOS_26_7: Row = Row { bc: Some(BlockPlacement::Halved), etc: Some(BlockPlacement::Halved), astc: Some(BlockPlacement::Halved), + pvrtc: None, gpu_rows: GpuRows::Own, }, // The package share-cblit on the consumer's M3 Max (25G229): every line of the predicate, @@ -136,11 +138,14 @@ const MACOS_27_0_1: Row = Row { unknown: &[], // Every BC, ETC2, EAC and ASTC format, every element of every level of 815 textures on an // Apple M4; the M3 Max answers the 809 of `tests/heap_tiled_blocks.rs` alike, each one's size, - // alignment, CPU span and GPU span. + // alignment, CPU span and GPU span. PVRTC on the M3 Max: 320 answers and every block of six + // textures' levels (a PVRTC texture is square, its side a power of two, which both placements + // place alike). heap_blocks: HeapBlocks { bc: Some(BlockPlacement::Narrow), etc: Some(BlockPlacement::Narrow), astc: Some(BlockPlacement::Halved), + pvrtc: Some(BlockPlacement::Halved), gpu_rows: GpuRows::AsCpu, }, // Each rule matched every texel of its formats' blits through a texture Metal compresses @@ -209,6 +214,7 @@ impl MetalLevel { BlockFamily::Bc => blocks.bc, BlockFamily::Etc => blocks.etc, BlockFamily::Astc => blocks.astc, + BlockFamily::Pvrtc => blocks.pvrtc, } } diff --git a/crates/metal2vulkan-runtime/src/shadow.rs b/crates/metal2vulkan-runtime/src/shadow.rs index 96d933a83..d196a9ba6 100644 --- a/crates/metal2vulkan-runtime/src/shadow.rs +++ b/crates/metal2vulkan-runtime/src/shadow.rs @@ -578,10 +578,14 @@ impl ShadowCopies { && a.image_extent == b.image_extent } - /// Whether the shadow is a heap's two-plane texture's, whose truth is its two planes in the - /// heap's bytes ([`ShadowTarget::Planes`]). - pub(super) fn holds_planes(&self) -> bool { - matches!(self.target(), Some(ShadowTarget::Planes { .. })) + /// Whether the shadow is a heap's one-level 2D two-plane texture's, whose truth is its two + /// planes in the heap's bytes ([`ShadowTarget::Planes`]) where Metal's blits address them + /// (`HeapPlaneCopies::layout`, `TwoPlaneHeapLayout::blit_rows`). + pub(super) fn holds_blit_rows(&self) -> bool { + matches!( + self.target(), + Some(ShadowTarget::Planes { planes, .. }) if planes.layout().blit_rows() + ) } /// The truth's identity and the range of it the shadow copies. diff --git a/crates/metal2vulkan-runtime/src/tests/degradation_codes.txt b/crates/metal2vulkan-runtime/src/tests/degradation_codes.txt index e57864001..ba9836454 100644 --- a/crates/metal2vulkan-runtime/src/tests/degradation_codes.txt +++ b/crates/metal2vulkan-runtime/src/tests/degradation_codes.txt @@ -96,6 +96,7 @@ metal2vulkan-degrade-heap-texture-larger-than-metal metal2vulkan-degrade-heap-texture-linear metal2vulkan-degrade-heap-texture-lossless-layout metal2vulkan-degrade-heap-texture-untiled-layout +metal2vulkan-degrade-heap-two-plane-layout metal2vulkan-degrade-heap-two-plane-texture metal2vulkan-degrade-helper-branch-drops-simdgroup-stores metal2vulkan-degrade-host-deallocator-delayed diff --git a/crates/metal2vulkan-runtime/src/tests/heap.rs b/crates/metal2vulkan-runtime/src/tests/heap.rs index a3cc6a6cb..d8b07141b 100644 --- a/crates/metal2vulkan-runtime/src/tests/heap.rs +++ b/crates/metal2vulkan-runtime/src/tests/heap.rs @@ -668,10 +668,8 @@ fn a_heap_shadow_lays_colour_compressed_and_3d_levels_out_tightly() { /// 300 x 70, 118797 for 333 x 61); its CPU copies move plane 0's words at those rows. #[test] fn a_heap_two_plane_texture_lays_its_planes_out_as_metal_does() { - use crate::texture::heap::heap_plane_layout; use crate::texture::heap_two_planes::TwoPlaneHeapLayout; - use metal2vulkan::metal::PixelFormat as P; - use metal2vulkan::vk::Format as F; + use metal2vulkan::metal::TextureType as T; for ([w, h], color, alpha, alpha_row, span) in [ ([16, 12], 64, 16384, 16, 16576), ([37, 5], 160, 16384, 48, 16613), @@ -691,20 +689,48 @@ fn a_heap_two_plane_texture_lays_its_planes_out_as_metal_does() { (color, alpha, alpha_row, span), "{w} x {h}" ); - for pf in [P::RGB10A82PXR10, P::RGB10A82PXR10SRGB] { - let extent = [w as u32, h as u32, 1]; - let (planes, end) = heap_plane_layout(F::R32G32_UINT, pf, extent, 1, 1); - assert_eq!(end, span); - assert_eq!(planes.len(), 1); - assert_eq!((planes[0].unit, planes[0].pitch), (4, color)); - assert_eq!( - planes[0].row(0, h - 1, w - 1), - (h - 1) * color + 4 * (w - 1) - ); + // A mipmapped texture's first level, and a 3D one's first depth slice, lie alike. + for ty in [T::Type2D, T::Type3D] { + assert_eq!(TwoPlaneHeapLayout::of_texture(ty, [w, h], 1), layout); } + let plane = layout.color_plane(); + assert_eq!((plane.unit, plane.pitch, plane.images), (4, color, 1)); + assert_eq!(plane.row(0, h - 1, w - 1), (h - 1) * color + 4 * (w - 1)); } } +/// A heap's two-plane array keeps its first level's slices' color words in the heap's bytes as an +/// Apple M3 Max under macOS 27.0.1 lays them (CPU copies and GPU writes alike): each slice's rows +/// as a 2D texture's, the slices `align(h · align(4 w, 16), 128)` bytes apart (0x380 for 37 x 5, +/// 0x200 for 16 x 8, 0x100 for a 1D array of 37), and no alpha plane, which Metal's GPU neither +/// writes nor reads (its alpha reads 0). A 1D texture lays its row out as a 2D one of one row, +/// plane 1 at 16 KiB. +#[test] +fn a_heap_two_plane_array_lays_its_slices_out_as_metal_does() { + use crate::texture::heap_two_planes::TwoPlaneHeapLayout; + use metal2vulkan::metal::TextureType as T; + for (ty, [w, h], slices, slice, span) in [ + (T::Type2DArray, [37, 5], 2, 0x380, 0x380 + 4 * 160 + 148), + (T::Type2DArray, [16, 8], 3, 0x200, 2 * 0x200 + 7 * 64 + 64), + (T::Type1DArray, [37, 1], 3, 0x100, 2 * 0x100 + 148), + ] { + let layout = TwoPlaneHeapLayout::of_texture(ty, [w, h], slices); + assert!( + !layout.alpha_kept && !layout.blit_rows(), + "{ty:?} {w} x {h}" + ); + assert_eq!((layout.color_slice, layout.span()), (slice, span), "{ty:?}"); + let plane = layout.color_plane(); + assert_eq!((plane.images, plane.image_pitch), (slices, slice)); + assert_eq!(plane.row(slices - 1, h - 1, w - 1), span - 4); + } + let one = TwoPlaneHeapLayout::of_texture(T::Type1D, [37, 1], 1); + assert_eq!( + (one.alpha_at, one.span(), one.blit_rows()), + (0x4000, 0x4025, true) + ); +} + /// A heap numbers its textures in the order it makes them: an encoder that made the textures /// before number `n` resident takes those from `n` on as it encodes its next command. #[test] diff --git a/crates/metal2vulkan-runtime/src/tests/heap_tiled.rs b/crates/metal2vulkan-runtime/src/tests/heap_tiled.rs index 4efda3ff0..d0df90c28 100644 --- a/crates/metal2vulkan-runtime/src/tests/heap_tiled.rs +++ b/crates/metal2vulkan-runtime/src/tests/heap_tiled.rs @@ -8,12 +8,12 @@ use crate::metal_level::MetalLevel; use crate::texture::heap_tiled::{ fresh_pattern, level_bytes, lossless_answer, metal_compresses, metal_heap_layout, - pattern_levels, sample_grid, BlockPlacement, Elements, FreshDepth, FreshPattern, GpuRows, - HeapLayout, TiledLayout, Untiled, + pattern_levels, sample_grid, shadow_tiles, BlockPlacement, Elements, FreshDepth, FreshPattern, + GpuRows, HeapLayout, TiledLayout, Untiled, }; use crate::texture_descriptor::TextureLayout; use metal2vulkan::metal::{PixelFormat, TextureType as T, TextureUsage}; -use metal2vulkan::vk::Format; +use metal2vulkan::vk::{Format, ImageAspectFlags}; /// One L row: its id, element bytes, block, type, level-0 extent, levels (0 the full chain) and /// array length, Metal's size, alignment and chain stride (an array's, cube's or 3D texture's), @@ -732,9 +732,9 @@ fn texture( } /// How the runtime lays a heap texture out over host pages, by its format, usage and shape: a -/// plain or block-compressed format whose image holds Metal's bytes tiled; a compressed, PVRTC, -/// multisample or two-aspect texture, or one whose image holds other bytes, untiled, each with -/// its kind, and the answers Metal's where measured. +/// plain or block-compressed format whose image holds Metal's bytes tiled (PVRTC under 27.0.1); a +/// compressed, multisample or two-aspect texture, a PVRTC one under 26.7, or one whose image holds +/// other bytes, untiled, each with its kind, and the answers Metal's where measured. #[test] fn heap_textures_are_tiled_where_metal_s_layout_is_measured() { use crate::degradation::Degradation as D; @@ -780,15 +780,20 @@ fn heap_textures_are_tiled_where_metal_s_layout_is_measured() { [64, 64, 1], (7, 1, 1), ); - for level in [M3, M4] { - let format = Format::PVRTC1_4BPP_UNORM_BLOCK_IMG; - let pvrtc = metal_heap_layout(&pvrtc, read, true, format, level); - assert_eq!(pvrtc.answer, None, "{level}"); - let HeapLayout::Untiled(untiled) = pvrtc.layout else { - panic!("{level}: a PVRTC texture is tiled"); - }; - assert_eq!(untiled.kind, D::HeapTextureBlockCompressedLayout, "{level}"); - } + // PVRTC: Metal's answer and its tiles under 27.0.1, untiled and unanswered under 26.7. + let format = Format::PVRTC1_4BPP_UNORM_BLOCK_IMG; + let m3_pvrtc = metal_heap_layout(&pvrtc, read, true, format, M3); + assert_eq!(m3_pvrtc.answer, None); + let HeapLayout::Untiled(untiled) = m3_pvrtc.layout else { + panic!("a PVRTC texture is tiled at 26.7's level"); + }; + assert_eq!(untiled.kind, D::HeapTextureBlockCompressedLayout); + let m4_pvrtc = metal_heap_layout(&pvrtc, read, true, format, M4); + assert_eq!( + m4_pvrtc.answer.map(|a| (a.size, a.align)), + Some((3200, 128)) + ); + assert!(matches!(m4_pvrtc.layout, HeapLayout::Tiled(_))); let decoded = metal_heap_layout(&bc1, read, true, Format::R8G8B8A8_UNORM, M4); assert_eq!(decoded.answer, blocks.answer); let HeapLayout::Untiled(untiled) = decoded.layout else { @@ -817,20 +822,67 @@ fn heap_textures_are_tiled_where_metal_s_layout_is_measured() { panic!("a multisample texture is tiled"); }; assert_eq!(untiled.kind, D::HeapTextureUntiledLayout); - // Two-aspect: its depth plane at 16 KiB, then its stencil plane, untiled. + // Two-aspect: its depth plane's tiles at 0, then its stencil plane's at 16 KiB; kept + // compressed, its depth plane is, and a shadow's stencil plane lies past the depth plane's + // compressed answer (`shadow_tiles`). let ds = texture( T::Type2D, PixelFormat::Depth32FloatStencil8, [64, 64, 1], (1, 1, 1), ); - let two = metal_heap_layout(&ds, write, false, Format::D32_SFLOAT_S8_UINT, M4); + let format = Format::D32_SFLOAT_S8_UINT; + let two = metal_heap_layout(&ds, write, false, format, M4); assert_eq!(two.answer.map(|a| (a.size, a.align)), Some((0x5000, 128))); - assert!(matches!(two.layout, HeapLayout::Untiled(_))); + let HeapLayout::Tiled(tiles) = &two.layout else { + panic!("a two-aspect texture is untiled"); + }; + let parts: Vec<_> = (tiles.parts.iter()) + .map(|part| (part.aspect, part.at, part.layout.unit, part.layout.size)) + .collect(); + let (depth, stencil) = ( + Some(ImageAspectFlags::DEPTH), + Some(ImageAspectFlags::STENCIL), + ); + assert_eq!(parts, [(depth, 0, 4, 0x4000), (stencil, 0x4000, 1, 0x1000)]); + let kept = metal_heap_layout(&ds, write, true, format, M4); + assert_eq!(kept.answer.map(|a| (a.size, a.align)), Some((0x9080, 128))); + let HeapLayout::Untiled(untiled) = kept.layout else { + panic!("a compressed two-aspect texture is tiled"); + }; + assert_eq!(untiled.kind, D::HeapTextureLosslessLayout); + let shadow = shadow_tiles(&ds, format, M4, &kept.layout); + let Some(HeapLayout::Uncompressed(tiles)) = shadow else { + panic!("a compressed two-aspect texture has no shadow's tiles"); + }; + let ats: Vec<_> = tiles.parts.iter().map(|part| part.at).collect(); + assert_eq!((ats, tiles.size), (vec![0, 0x8000], 0x9000)); + let other = metal_heap_layout(&ds, write, false, Format::D32_SFLOAT, M4); + assert!(matches!(other.layout, HeapLayout::Untiled(_))); // A depth texture without GPU-optimized contents: tiled. let depth = texture(T::Type2D, PixelFormat::Depth32Float, [64, 64, 1], (1, 1, 1)); let tiled_depth = metal_heap_layout(&depth, read, false, Format::D32_SFLOAT, M4); assert!(matches!(tiled_depth.layout, HeapLayout::Tiled(_))); + // A stencil view: a `Stencil8` texture's tiles and answers (the M3 Max under 27.0.1), the + // tiles its image's stencil aspect's; kept compressed, a shadow's uncompressed tiles alike. + let view = texture(T::Type2D, PixelFormat::X32Stencil8, [100, 70, 1], (1, 1, 1)); + let x32 = metal_heap_layout(&view, read, false, format, M4); + assert_eq!(x32.answer.map(|a| (a.size, a.align)), Some((0x4000, 128))); + let HeapLayout::Tiled(tiles) = &x32.layout else { + panic!("a stencil view is untiled"); + }; + let parts: Vec<_> = (tiles.parts.iter()) + .map(|part| (part.aspect, part.at, part.layout.unit, part.layout.size)) + .collect(); + assert_eq!(parts, [(stencil, 0, 1, 0x4000)]); + let kept = metal_heap_layout(&view, read, true, format, M4); + assert_eq!(kept.answer.map(|a| (a.size, a.align)), Some((0x4200, 128))); + let shadow = shadow_tiles(&view, format, M4, &kept.layout); + let Some(HeapLayout::Uncompressed(tiles)) = shadow else { + panic!("a compressed stencil view has no shadow's tiles"); + }; + assert_eq!(tiles.parts.len(), 1); + assert_eq!((tiles.parts[0].aspect, tiles.size), (stencil, 0x4000)); } /// A multisample texture's answers and layout kind (on an Apple M4 under macOS 27.0.1; the M3 Max @@ -839,7 +891,7 @@ fn heap_textures_are_tiled_where_metal_s_layout_is_measured() { /// all their samples in Metal's tiles, a multisample array's slices an array's; compressed, that /// plus metadata over the sample grid for each slice. A `Depth32Float_Stencil8` texture answers /// neither (its device's); a compressed one is held in memory of its own -/// (`Untiled::LOSSLESS_MULTISAMPLE`), any other refused over host pages. +/// (`Untiled::LOSSLESS_MULTISAMPLE`), and over host pages any other too, announced untiled. #[test] fn multisample_answers_are_metal_s() { use crate::degradation::Degradation as D; diff --git a/crates/metal2vulkan-runtime/src/tests/heap_tiled_blocks.rs b/crates/metal2vulkan-runtime/src/tests/heap_tiled_blocks.rs index 80aca6f11..fed35014c 100644 --- a/crates/metal2vulkan-runtime/src/tests/heap_tiled_blocks.rs +++ b/crates/metal2vulkan-runtime/src/tests/heap_tiled_blocks.rs @@ -1850,19 +1850,248 @@ fn the_gpu_rows_tell_the_counts_apart() { } } -/// Every block-compressed format the crate holds a texture of but PVRTC's has a family, and every -/// format of a family is among each level's rows. +/// 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_27_0_1_places_them`) is among each level's rows. #[test] fn every_block_compressed_format_has_a_measured_family() { for (level, rows, _) in levels() { let measured: std::collections::BTreeSet

= rows.iter().map(|row| row.pf).collect(); for &pf in P::ALL { - let held = block_extent(pf).is_some() && direct_format(pf).is_some(); + let held = block_extent(pf).is_some() && (direct_format(pf).is_some() || is_pvrtc(pf)); let family = BlockFamily::of(pf); - assert_eq!(family.is_some(), held && !is_pvrtc(pf), "{pf:?}"); - if family.is_some() { + assert_eq!(family.is_some(), held, "{pf:?}"); + if family.is_some() && !is_pvrtc(pf) { assert!(measured.contains(&pf), "{level} {pf:?} not measured"); } } } } + +/// Metal's answers for PVRTC textures of 2 bits a pixel under macOS 27.0.1 (an Apple M3 Max, +/// `Private`, `ShaderRead`; our probe), each format of them alike: the side (square), levels, +/// array length (3: a 2D array), size and alignment. +const PVRTC_2BPP_ROWS: &str = " +4 1 1 128 128 +4 1 3 384 128 +4 3 1 384 128 +4 3 3 1152 128 +8 1 1 128 128 +8 1 3 384 128 +8 4 1 512 128 +8 4 3 1536 128 +16 1 1 128 128 +16 1 3 384 128 +16 5 1 640 128 +16 5 3 1920 128 +32 1 1 256 128 +32 1 3 768 128 +32 6 1 896 128 +32 6 3 2688 128 +64 1 1 1024 128 +64 1 3 3072 128 +64 7 1 1920 128 +64 7 3 5760 128 +128 1 1 4096 128 +128 1 3 12288 128 +128 8 1 6016 128 +128 8 3 18048 128 +256 1 1 16384 128 +256 1 3 49152 16384 +256 9 1 22400 128 +256 9 3 98304 16384 +512 1 1 65536 128 +512 1 3 196608 16384 +512 10 1 87936 128 +512 10 3 294912 16384 +1024 1 1 262144 128 +1024 1 3 786432 16384 +1024 11 1 350080 128 +1024 11 3 1081344 16384 +2048 1 1 1048576 128 +2048 1 3 3145728 16384 +2048 12 1 1398656 128 +2048 12 3 4227072 16384 +"; + +/// Metal's answers for PVRTC textures of 4 bits a pixel, as [`PVRTC_2BPP_ROWS`]. +const PVRTC_4BPP_ROWS: &str = " +4 1 1 128 128 +4 1 3 384 128 +4 3 1 384 128 +4 3 3 1152 128 +8 1 1 128 128 +8 1 3 384 128 +8 4 1 512 128 +8 4 3 1536 128 +16 1 1 128 128 +16 1 3 384 128 +16 5 1 640 128 +16 5 3 1920 128 +32 1 1 512 128 +32 1 3 1536 128 +32 6 1 1152 128 +32 6 3 3456 128 +64 1 1 2048 128 +64 1 3 6144 128 +64 7 1 3200 128 +64 7 3 9600 128 +128 1 1 8192 128 +128 1 3 24576 128 +128 8 1 11392 128 +128 8 3 34176 128 +256 1 1 32768 128 +256 1 3 98304 16384 +256 9 1 44160 128 +256 9 3 147456 16384 +512 1 1 131072 128 +512 1 3 393216 16384 +512 10 1 175232 128 +512 10 3 540672 16384 +1024 1 1 524288 128 +1024 1 3 1572864 16384 +1024 11 1 699520 128 +1024 11 3 2113536 16384 +2048 1 1 2097152 128 +2048 1 3 6291456 16384 +2048 12 1 2796672 128 +2048 12 3 8404992 16384 +"; + +/// Where Metal under macOS 27.0.1 placed the blocks of six PVRTC textures (an Apple M3 Max; our +/// probe: each level of a `Shared` placement heap's texture written by a row-linear blit of blocks +/// naming themselves, found in a buffer over the heap): the format, side and levels, and each +/// level's first byte from the texture's and the bytes from it of its first 12 blocks in row +/// order (fewer where the level has fewer), every other block of each level at the Morton index +/// of its tile. +const PVRTC_PLACES: [(P, u64, u32, &[(u64, &[u64])]); 6] = { + const BIG: &[u64] = &[0, 8, 32, 40, 128, 136, 160, 168, 512, 520, 544, 552]; + const MID: &[u64] = &[0, 8, 32, 40, 128, 136, 160, 168, 16, 24, 48, 56]; + const SMALL: &[u64] = &[0, 8, 32, 40, 16, 24, 48, 56, 64, 72, 96, 104]; + const TWO: &[u64] = &[0, 8, 16, 24]; + const TALL: &[u64] = &[0, 8, 16, 24, 32, 40, 48, 56]; + const PAIR: &[u64] = &[0, 8]; + const ONE: &[u64] = &[0]; + [ + (P::PVRTCRGB4BPP, 64, 1, &[(0, BIG)]), + (P::PVRTCRGBA2BPP, 64, 1, &[(0, MID)]), + ( + P::PVRTCRGBA4BPP, + 256, + 9, + &[ + (0, BIG), + (0x8000, BIG), + (0xa000, BIG), + (0xa800, MID), + (0xaa00, SMALL), + (0xaa80, TWO), + (0xab00, ONE), + (0xab80, ONE), + (0xac00, ONE), + ], + ), + ( + P::PVRTCRGBA2BPP, + 128, + 8, + &[ + (0, BIG), + (0x1000, MID), + (0x1400, SMALL), + (0x1500, TALL), + (0x1580, PAIR), + (0x1600, ONE), + (0x1680, ONE), + (0x1700, ONE), + ], + ), + ( + P::PVRTCRGBA4BPP, + 16, + 5, + &[ + (0, SMALL), + (0x80, TWO), + (0x100, ONE), + (0x180, ONE), + (0x200, ONE), + ], + ), + ( + P::PVRTCRGB2BPP, + 32, + 6, + &[ + (0, SMALL), + (0x100, TALL), + (0x180, PAIR), + (0x200, ONE), + (0x280, ONE), + (0x300, ONE), + ], + ), + ] +}; + +/// A PVRTC texture's tiled layout at `level`: its family's placement there. +fn pvrtc_layout(level: MetalLevel, pf: P, side: u64, levels: u32, array: u64) -> TiledLayout { + let unit = u64::from(block_bytes(pf).unwrap()); + let block = block_extent(pf).unwrap().map(u64::from); + let elements = Elements::Blocks { + block, + placement: placement(level, pf), + gpu_rows: level.heap_block_gpu_rows(), + }; + let ty = if array > 1 { T::Type2DArray } else { T::Type2D }; + TiledLayout::of(unit, elements, ty, [side, side, 1], levels, array).unwrap() +} + +/// Every PVRTC format's answer under macOS 27.0.1 is the tiled layout's of its family's placement +/// there (`Halved`), its blocks of 8 bytes (`PVRTC_2BPP_ROWS`, `PVRTC_4BPP_ROWS`), and each block of +/// the probe's six textures lies where the layout places it (`PVRTC_PLACES`); under 26.7 the +/// family's placement is not measured. +#[test] +fn pvrtc_blocks_lie_where_27_0_1_places_them() { + let level = MetalLevel::MacOS27_0_1; + assert_eq!(MetalLevel::MacOS26_7.heap_blocks(BlockFamily::Pvrtc), None); + let pvrtc: Vec

= P::ALL.iter().copied().filter(|&pf| is_pvrtc(pf)).collect(); + assert_eq!(pvrtc.len(), 8); + for pf in pvrtc { + let wide = block_extent(pf).unwrap()[0] == 8; + let table = if wide { + PVRTC_2BPP_ROWS + } else { + PVRTC_4BPP_ROWS + }; + for line in table.lines().filter(|line| !line.is_empty()) { + let fields: Vec = line.split(' ').map(|f| f.parse().unwrap()).collect(); + let [side, levels, array, size, align] = fields[..] else { + panic!("a row of five fields: {line}"); + }; + let layout = pvrtc_layout(level, pf, side, levels as u32, array); + let what = format!("{pf:?} {side} {levels} {array}"); + assert_eq!((layout.size, layout.align), (size, align), "{what}"); + } + } + for (pf, side, levels, places) in PVRTC_PLACES { + let layout = pvrtc_layout(level, pf, side, levels, 1); + let [bw, bh] = block_extent(pf).unwrap().map(u64::from); + for (l, &(first, offsets)) in places.iter().enumerate() { + let s = (side >> l).max(1); + let across = s.div_ceil(bw); + let count = across * s.div_ceil(bh); + assert_eq!( + offsets.len() as u64, + count.min(12), + "{pf:?} {side} level {l}" + ); + let what = format!("{pf:?} {side} level {l}"); + assert_eq!(layout.element(0, l, 0, 0), first, "{what}"); + for (i, &offset) in offsets.iter().enumerate() { + let i = i as u64; + let at = layout.element(0, l, i % across, i / across); + assert_eq!(at - first, offset, "{what} block {i}"); + } + } + } +} diff --git a/crates/metal2vulkan-runtime/src/texture.rs b/crates/metal2vulkan-runtime/src/texture.rs index 9a548c1dd..85066e3d7 100644 --- a/crates/metal2vulkan-runtime/src/texture.rs +++ b/crates/metal2vulkan-runtime/src/texture.rs @@ -4166,13 +4166,14 @@ impl Texture { } } - /// Where the texture's two planes lie in its heap's bytes, as Metal lays them (a heap's - /// one-level 2D two-plane texture, `texture/heap_two_planes.rs`): the heap, and the - /// texture's first byte in it; `None` for any other texture, a view among them. + /// Where the texture's two planes lie in its heap's bytes, as Metal's blits address them (a + /// heap's one-level 2D two-plane texture, `texture/heap_two_planes.rs`): the heap, and the + /// texture's first byte in it; `None` for any other texture, a view and a two-plane texture + /// of more levels or slices among them. pub(super) fn heap_planes(&self) -> Option<(&Heap, u64)> { match &self.0.storage { Storage::Image(image) if self.0.parent.is_none() => match &image.owner { - Owner::HeapShadow(shadow) if shadow.copies.holds_planes() => { + Owner::HeapShadow(shadow) if shadow.copies.holds_blit_rows() => { Some((self.0.heap.as_ref()?, shadow.place.offset)) } _ => None, @@ -5212,9 +5213,11 @@ impl Texture { return texels.write(CALL, &image_region, &host, bytes) } }; - // A heap shadow's texels are the heap's bytes. + // A heap shadow's texels are the heap's bytes (but a two-plane texture's later levels'). if let Owner::HeapShadow(shadow) = &image.owner { - return shadow.write(CALL, image.plan(), &image_region, &host, bytes); + if shadow.holds(image.plan(), &image_region) { + return shadow.write(CALL, image.plan(), &image_region, &host, bytes); + } } // A two-plane texture's color words over its texels as they are, the alpha words kept. if planes { @@ -5494,9 +5497,11 @@ impl Texture { return texels.read(call, image_region, host, bytes) } }; - // A heap shadow's texels are the heap's bytes. + // A heap shadow's texels are the heap's bytes (but a two-plane texture's later levels'). if let Owner::HeapShadow(shadow) = &image.owner { - return shadow.read(call, image.plan(), image_region, host, bytes); + if shadow.holds(image.plan(), image_region) { + return shadow.read(call, image.plan(), image_region, host, bytes); + } } // A shadowed view's texels are its texture's (`texture/view_shadow.rs`). let truth = view_shadow::truth(image); diff --git a/crates/metal2vulkan-runtime/src/texture/heap.rs b/crates/metal2vulkan-runtime/src/texture/heap.rs index 9338047c0..671a5f0ad 100644 --- a/crates/metal2vulkan-runtime/src/texture/heap.rs +++ b/crates/metal2vulkan-runtime/src/texture/heap.rs @@ -29,8 +29,10 @@ //! (`AliasRoute::Lossless`), holding what that memory held, as a heap's texture holds what its //! bytes held; the heap's bytes keep what they held, where Metal's compressed bytes change as the //! texture is written (no layout of its samples either way; `heap-texture-lossless-layout` per -//! texture). One Metal keeps uncompressed lays its samples out in the heap's bytes, which no -//! route holds yet: `NotImplemented(HostHeapUncompressedMultisample)`. A compressed one takes +//! texture). One Metal keeps uncompressed, which lays its samples out in the heap's bytes (each +//! pixel's samples side by side in Metal's tiles), takes that route too, its samples apart from +//! the heap's bytes (`heap-texture-untiled-layout` per texture), as does one of a sample count +//! whose layout is not measured. A compressed one takes //! that route in any heap whose memory its optimal image does not take where the device's linear //! images cannot hold it (an NVIDIA GPU's `Shared` heap), announced alike, where it was refused //! `HeapTextureTiling` as the device's lack. So does an uncompressed one there (a depth texture @@ -47,7 +49,8 @@ //! Where the device's image needs more bytes or a coarser alignment than that answer, and for //! every 4:2:2 texture, the texture is a shadow of the heap's bytes in memory of its own //! (`AliasRoute::MemoryShadow`): its planes fit the answer (an `X32_Stencil8` texture's stencil -//! alone, packed; a 4:2:2 texture's rows where Metal lays them, so a buffer over them reads +//! alone, in a `Stencil8` texture's tiles where they serve, as Metal lays it, `heap_tiled.rs`, +//! else packed; a 4:2:2 texture's rows where Metal lays them, so a buffer over them reads //! Metal's bytes; `heap_plane_layout`), so two textures side by side at the answer keep their //! texels on every device. //! - **Two-plane extended-range textures** (`RGB10A8_2P_XR10` and its sRGB twin; the consumer's @@ -56,20 +59,26 @@ //! bytes, rows at a multiple of 16, the last unpadded; a 2D or 1D array's slices at multiples of //! 128 in each plane; the first level and slice of a mipmapped or 3D texture alone; an alignment //! of 16 (128 for a 2D array). Its image, one `R32G32_UINT` texel a texel -//! (`ExtendedRange::Planes`), is larger than that answer, so it lies in memory of its own. A -//! one-level 2D texture's image is a shadow of its two planes in the heap's bytes, where Metal -//! lays them (`AliasRoute::Planes`, `heap_two_planes.rs`): a buffer or texture over them meets -//! its texels as on Metal, and the device announces `shadowed-texture`. Any other's aliases none -//! of the heap's bytes (`AliasRoute::Unaliased`): two textures side by side at the answer keep -//! their texels, which Metal's mipmapped ones do not (its levels lie past its answer), and the -//! device announces `heap-two-plane-texture`. Metal answers a cube or cube array 0 bytes at 16 -//! and makes neither. +//! (`ExtendedRange::Planes`), is larger than that answer, so it lies in memory of its own, a +//! shadow of its first level's planes in the heap's bytes, where Metal lays them +//! (`AliasRoute::Planes`, `heap_two_planes.rs`): a one-level 2D or 1D texture's two planes, an +//! array's slices of color words (Metal keeps no alpha byte of an array's, and reads its alpha +//! as 0), a mipmapped texture's first level as a one-level one's. A buffer or texture over them +//! meets its texels as on Metal, and the device announces `shadowed-texture`. A mipmapped +//! texture's later levels lie in its image alone, and a 1D array's GPU reads read each texel, +//! where Metal's paths address those at bytes that differ by path (`heap-two-plane-layout`). A +//! 3D texture of more than one depth slice, whose depth slices Metal's GPU writes lay over one +//! another, and one whose moves pass the device's limits alias none of the heap's bytes +//! (`AliasRoute::Unaliased`, `heap-two-plane-texture`). Metal answers a cube or cube array 0 +//! bytes at 16 and makes neither. //! - **`allowGPUOptimizedContents`**. A descriptor with it off plans its image as one of //! `PixelFormatView` usage (`TextureDescriptor::image_usage`): Metal lays a color texture out //! alike either way (16384 bytes for the 64x64 `RGBA8Unorm` texture only read), and MoltenVK //! sizes that image as Metal's `PixelFormatView` texture, so its answer is Metal's. Metal also //! drops a depth or stencil texture's metadata with it off, which no Vulkan request reaches on -//! MoltenVK ([`DriverFact::DepthStencilImagesStayGpuOptimized`]): there the answer stays the +//! MoltenVK ([`DriverFact::DepthStencilImagesStayGpuOptimized`]): there the texture is a shadow +//! of Metal's tiles in the heap's bytes (below) and answers Metal's size; where no such shadow +//! serves it (a multisample texture, a depth twin, a layout not measured), the answer stays the //! optimized texture's, larger than Metal's, and the device announces //! `optimized-depth-stencil-texture` once. //! - **The heap's memory.** A heap's buffer lies at a multiple of [`HEAP_BASE_ALIGNMENT`] of its @@ -111,8 +120,31 @@ //! tracking, and `depth-twin` is announced as for `new_texture`. //! - **Depth and stencil images apart**. On a driver that lays depth and stencil images apart from //! the memory they are bound to ([`DriverFact::DepthStencilImagesLieApart`]: MoltenVK, measured), -//! a heap's texture with such an image (its own or its twin) aliases none of the heap's other -//! resources, and the device announces `heap-depth-stencil-apart` once when it makes one. +//! a heap's single-sample depth or stencil texture of a format whose layout is measured +//! (`Depth16Unorm`, `Depth32Float`, `Stencil8`, and `Depth32Float_Stencil8` in two planes) is a +//! shadow of its elements in Metal's tiles in the heap's bytes (`AliasRoute::Tiled`, +//! `heap_tiled.rs`), at Metal's size and alignment: a Metal probe on the M3 Max under macOS +//! 27.0.1 found every texel of such textures with `allowGPUOptimizedContents` off where the +//! tiles place it (37 x 5 to 300 x 200), and Metal's +//! compressed bytes with it on no layout of the texels, which the shadow holds in its +//! uncompressed tiles, announced `heap-texture-lossless-layout` per texture. So is one whose +//! image the heap's memory takes none of, as below, and one whose image the driver keeps +//! GPU-optimized where Metal's is not. Any other such image, its own or its twin, is a shadow of +//! the heap's bytes in rows (`AliasRoute::Shadow`), or, where no shadow serves (a multisample +//! texture, a depth twin), aliases none of the heap's other resources, and the device announces +//! `heap-depth-stencil-apart` once when it makes one. +//! - **Heaps over the device's memory**. A texture whose image is bound in such a heap's memory +//! lies there in the driver's layout. On a driver whose single-sample colour images lie as Metal +//! lays out a heap texture of the image's usage +//! ([`DriverFact::ColorImagesLieAsMetalHeapTextures`]: MoltenVK 1.4.2 on the M3 Max, measured) +//! such a texture Metal tiles is Metal's bytes there. Every other texture whose bytes there are +//! not Metal's layout is counted (`Device::degraded_objects`), each kind announced at its first +//! texture, with its ID: its image in the driver's layout on any other driver, or of a depth or +//! stencil texture, `heap-texture-untiled-layout`; its image a shadow of the bytes in rows, +//! alike; a multisample texture, alike; one Metal may keep losslessly compressed, +//! `heap-texture-lossless-layout` (the runtime's image need not be compressed as Metal's); one +//! whose layout is not measured, by its kind (`device_heap_layout`). A texture apart from the +//! heap's bytes, and a two-plane one, announce their own routes. //! - **Compressed images**. On a driver whose compressed images may keep their texels apart from //! the memory they are bound to ([`DriverFact::CompressedImagesHideAliasedWrites`]: ANV on //! Intel's GPUs, measured), a heap's colour texture whose optimal image takes the heap's memory @@ -147,8 +179,8 @@ use super::first_move::FirstMove; use super::heap_tiled::{ - metal_compresses_layout, metal_heap_layout, modelled_size, HeapLayout, HeapTiledCopies, - TiledLayout, Untiled, UNMEASURED_FORMAT, + metal_compresses_layout, metal_heap_layout, modelled_size, shadow_tiles, HeapLayout, + HeapTiledCopies, TiledTexture, Untiled, }; use super::heap_two_planes::{HeapPlaneCopies, TwoPlaneHeapLayout}; use super::stand_in::StandIn; @@ -185,7 +217,7 @@ use crate::Device; use ash::vk; use metal2vulkan::device::{DriverFact, HeapCompressionPolicy}; use metal2vulkan::error::{Feature, LinearNeed, Unsupported}; -use metal2vulkan::metal::format::ycbcr_format; +use metal2vulkan::metal::format::{is_depth_stencil, ycbcr_format}; use metal2vulkan::metal::{PixelFormat, TextureType, TextureUsage}; use metal2vulkan::vk::{ Format, FormatFeatureFlags2, ImageAspectFlags, ImageUsageFlags, SampleCountFlags, @@ -277,6 +309,37 @@ pub(crate) struct HeapUnaliased { } impl HeapShadow { + /// The plane of the heap's bytes that holds `region` of the shadowed image of `plan`, where + /// one does (not a tiled texture's, whose elements `pieces` places itself): a two-plane + /// texture's color words of its first level (`heap_two_planes.rs`), or the plane of the + /// region's aspect and level ([`heap_plane_layout`]). + fn plane(&self, plan: &ImagePlan, region: &ImageRegion) -> Option { + if let Some(ShadowTarget::Planes { planes, .. }) = self.copies.target() { + let plane = planes.layout().color_plane(); + let held = plane.aspect == region.aspect && plane.level == region.level; + return held.then_some(plane); + } + let (planes, _) = heap_plane_layout( + plan.format, + plan.pixel_format, + plan.extent, + plan.levels, + plan.layers, + ); + planes + .into_iter() + .find(|plane| plane.aspect == region.aspect && plane.level == region.level) + } + + /// Whether a CPU copy of `region` of the shadowed image of `plan` moves the heap's bytes: a + /// region of a tiled texture, or one a plane of the heap's bytes holds + /// ([`plane`](Self::plane)); not one of a two-plane texture's levels past its first, which lie + /// in its image alone. + pub(super) fn holds(&self, plan: &ImagePlan, region: &ImageRegion) -> bool { + matches!(self.copies.target(), Some(ShadowTarget::Tiled { .. })) + || self.plane(plan, region).is_some() + } + /// The heap's mapped bytes, from its first, which a CPU copy reaches: the texture copying /// keeps the heap (the place holds it weakly). fn contents(&self, call: &'static str) -> Result, Error> { @@ -293,7 +356,7 @@ impl HeapShadow { /// image at its first use and back at its end (`shadow.rs`), so `replaceRegion` and /// `getBytes` reach them, laid out as [`heap_plane_layout`] says, a row of blocks a piece; /// or, for a texture Metal tiles there (`ShadowTarget::Tiled`), as its tiles lay them out - /// (`TiledLayout::element`), an element a piece. + /// (`TiledLayout::element`, the part of the region's aspect), an element a piece. fn pieces( &self, plan: &ImagePlan, @@ -303,7 +366,9 @@ impl HeapShadow { ) -> Result<(), Error> { let [x, y, z] = region.origin.map(u64::from); if let Some(ShadowTarget::Tiled { tiles, .. }) = self.copies.target() { - let tiled = &tiles.layout; + let part = (tiles.tiles.part(region.aspect)) + .ok_or_else(|| internal("a tiled heap texture has no part of a copy's aspect"))?; + let tiled = &part.layout; let level = region.level as usize; let depth = tiled .levels @@ -316,7 +381,7 @@ impl HeapShadow { for image in 0..host.images { for row in 0..host.rows { for column in 0..across { - let at = tiled.element(base + image, level, x + column, y + row); + let at = part.at + tiled.element(base + image, level, x + column, y + row); let packed = (image * host.rows + row) * host.row_bytes + column * unit; each( (self.place.offset + at) as usize, @@ -328,16 +393,8 @@ impl HeapShadow { } return Ok(()); } - let (planes, _) = heap_plane_layout( - plan.format, - plan.pixel_format, - plan.extent, - plan.levels, - plan.layers, - ); - let plane = planes - .iter() - .find(|plane| plane.aspect == region.aspect && plane.level == region.level) + let plane = self + .plane(plan, region) .ok_or_else(|| internal("a heap shadow has no plane of a copy's aspect and level"))?; let [bw, bh] = plane.block.map(u64::from); let depth = u64::from(plane.extent[2]); @@ -435,16 +492,21 @@ enum AliasRoute { /// (`shadowed-texture`). MemoryShadow, /// A two-plane extended-range texture's image, larger than Metal's answer - /// (`two_plane_heap_answer`), in memory of its own: it aliases none of the heap's bytes, and - /// no copy moves texels between them (`heap-two-plane-texture`). + /// (`two_plane_heap_answer`), in memory of its own, that no shadow of its planes serves (a 3D + /// texture of more than one depth slice, or moves past the device's limits): it aliases none + /// of the heap's bytes, and no copy moves texels between them (`heap-two-plane-texture`). Unaliased, - /// A one-level 2D two-plane extended-range texture's image, in memory of its own, whose - /// texels the encoders move from its two planes in the heap's bytes, as Metal lays them, and - /// back (`heap_two_planes.rs`): a shadow of them (`shadowed-texture`). + /// A two-plane extended-range texture's image, in memory of its own, whose first level's + /// texels the encoders move from its planes in the heap's bytes, as Metal lays them, and back + /// (`heap_two_planes.rs`): a shadow of them (`shadowed-texture`; `heap-two-plane-layout` for + /// a mipmapped one, whose later levels lie in the image alone, and a 1D array). Planes, - /// A texture of a plain format in a heap over host pages: its optimal image in memory of its - /// own, whose elements the encoders move from Metal's tiles in the heap's bytes and back - /// (`heap_tiled.rs`): a shadow of them (`shadowed-texture`). + /// A texture Metal tiles in the heap's bytes (`heap_tiled.rs`) in a heap over host pages, or + /// in any heap one that no image bound there serves as Metal's (a depth or stencil image the + /// driver lays apart from its memory or keeps GPU-optimized, one the heap's memory takes no + /// image of): its optimal image in memory of its own, whose elements the encoders move from + /// Metal's tiles in the heap's bytes and back (a texture Metal keeps losslessly compressed, + /// its uncompressed tiles), a shadow of them (`shadowed-texture`). Tiled, /// A multisample texture's optimal image in memory of its own, apart from the heap's bytes, /// which keep what they held; no copy moves samples between them (Vulkan copies no @@ -622,18 +684,22 @@ pub(crate) struct HeapPlane { /// The bytes from one row of blocks to the next: a row's, tightly packed, but for a 4:2:2 /// texture's, which Metal lays at a multiple of 16 bytes (`FOUR_TWO_TWO_ALIGNMENT`). pub(crate) pitch: u64, + /// The bytes from one image to the next: its rows', but for a two-plane array's, whose + /// slices Metal lays at a multiple of 128 bytes (`heap_two_planes.rs`). + pub(crate) image_pitch: u64, } impl HeapPlane { /// The bytes from one image to the next. fn image_bytes(&self) -> u64 { - self.pitch * self.blocks[1] + self.image_pitch } /// The bytes the plane spans: its images, the last one's last row unpadded. fn span(&self) -> u64 { - let rows = self.images * self.blocks[1]; - rows.saturating_sub(1) * self.pitch + self.blocks[0] * self.unit + self.images.saturating_sub(1) * self.image_pitch + + self.blocks[1].saturating_sub(1) * self.pitch + + self.blocks[0] * self.unit } /// Where row `row` of blocks of image `image` lies, from block column `column`, counted @@ -659,24 +725,6 @@ pub(crate) fn heap_plane_layout( levels: u32, layers: u32, ) -> (Vec, u64) { - // A two-plane texture's CPU copies move plane 0's color words, at Metal's rows - // (`heap_two_planes.rs`; a one-level, one-slice texture's). - if two_planes::holds_planes(pf) { - let [width, height, _] = extent.map(u64::from); - let metal = TwoPlaneHeapLayout::of([width, height]); - let plane = HeapPlane { - aspect: ImageAspectFlags::COLOR, - level: 0, - offset: 0, - extent, - blocks: [width, height], - images: 1, - unit: two_planes::UNIT.bytes.into(), - block: [1, 1], - pitch: metal.color_pitch, - }; - return (vec![plane], metal.span()); - } let mut planes = Vec::new(); let mut end = 0u64; for (aspect, bytes, [bw, bh]) in copy_units(format, pf) { @@ -696,16 +744,18 @@ pub(crate) fn heap_plane_layout( } else { packed }; + let down = u64::from(height.div_ceil(bh.max(1))); let plane = HeapPlane { aspect, level, offset: end.next_multiple_of(align.max(1)), extent: level_extent, - blocks: [across, u64::from(height.div_ceil(bh.max(1)))], + blocks: [across, down], images: u64::from(depth) * u64::from(layers), unit, block: [bw.max(1), bh.max(1)], pitch, + image_pitch: pitch * down, }; end = plane.offset + plane.span(); planes.push(plane); @@ -1143,8 +1193,8 @@ impl Device { /// stencil one `Invalid`, as every creator does. Metal's private usage 0x8 alone is one it /// compresses, where its texture is of `Unknown` usage: the descriptor keeps it /// ([`TextureUsage::DROPPED`]), so the answer is Metal's. A descriptor whose layout in Metal's - /// heaps the runtime does not model (a format or sample count not measured: a PVRTC format, 8 - /// samples) answers its device's image's size, announced `unmeasured-heap-texture-size` (a + /// heaps the runtime does not model (a format or sample count not measured: a PVRTC format at + /// a Metal level of macOS 26.7, 8 samples) answers its device's image's size, announced `unmeasured-heap-texture-size` (a /// mipmapped texture Metal compresses and a `Depth32Float_Stencil8` one answer Metal's). pub fn heap_texture_size_and_align( &self, @@ -1172,7 +1222,8 @@ impl Device { /// Metal's own answer to `heapTextureSizeAndAlignWithDescriptor:` for `descriptor`, as the /// runtime models it (`texture/heap_tiled.rs`), whatever this device's images need: the same /// on every device at the same Metal level (`DeviceProperties::metal_level`). `None` where the - /// model has no answer (a PVRTC format, 8 samples, any other layout not measured), where + /// model has no answer (a PVRTC format at macOS 26.7's level, 8 samples, any other layout not + /// measured), where /// [`Device::heap_texture_size_and_align`] announces `unmeasured-heap-texture-size`. No Metal /// counterpart: Metal answers its own GPU's. /// @@ -1374,10 +1425,12 @@ impl Device { // texture's bytes there, in memory of its own. A 4:2:2 texture is always a shadow: its // bytes then lie where Metal's linear rows do (`heap_plane_layout`). A two-plane // texture's image lies apart from the heap's bytes (above). - let special = self.metal_heap_answer(call, descriptor, &layout)?; + let special = self.metal_heap_answer(call, descriptor, &layout, image.plan.format)?; // Metal's modelled answer where the texture takes the larger of it and its image's. let mut modelled = None; - let metal_layout = match &special { + // Metal's answer, where the runtime knows it. + let mut metal_answer = special.as_ref().map(|(metal, _)| *metal); + let mut metal_layout = match &special { Some((_, metal_layout)) => metal_layout.clone(), None => { let usage = effective_usage(descriptor.usage); @@ -1388,6 +1441,7 @@ impl Device { if measured.answer.is_none() { self.degrade_unmeasured_size(call, &layout); } + metal_answer = measured.answer; if let Some(metal) = measured.answer { size_and_align = match image.route { // An image in memory of its own takes none of the heap's bytes: the @@ -1429,9 +1483,33 @@ impl Device { } size_and_align = metal; } + // A texture whose image lies in memory of its own as a shadow of the heap's bytes (the + // driver lays depth and stencil images apart from their memory, or the heap's memory + // takes no image of it), or whose image the driver keeps GPU-optimized where Metal's + // texture is not, is a shadow of its elements in Metal's tiles there where Metal's layout + // is measured and the moves fit (`heap_tiled.rs`): its bytes are Metal's (a texture Metal + // keeps losslessly compressed, its uncompressed tiles), and it takes Metal's answer. + let shadowed = matches!(image.route, AliasRoute::Shadow | AliasRoute::MemoryShadow) + || self.keeps_optimized_layout(descriptor, &layout); + if shadowed && twin.is_none() { + let level = self.properties().metal_level; + let tiles = shadow_tiles(&layout, image.plan.format, level, &metal_layout); + if let (Some(tiles), Some(answer)) = (tiles, metal_answer) { + let serves = (tiles.tiles()) + .is_some_and(|tiled| self.tiles_serve(&image.plan, tiled, answer.size)); + if serves { + image.route = AliasRoute::Tiled; + size_and_align = answer; + metal_layout = tiles; + } + } + } check_heap_base(size_and_align.align)?; - // The size answered is the optimized texture's where the driver keeps the layout. - self.degrade_optimized_layout(descriptor, &layout); + // The size answered is the optimized texture's where the driver keeps the layout, but for + // a shadow of Metal's tiles. + if image.route != AliasRoute::Tiled { + self.degrade_optimized_layout(descriptor, &layout); + } if let Some(metal) = modelled { let past = size_and_align.size > metal.size || size_and_align.align > metal.align; if past && !self.keeps_optimized_layout(descriptor, &layout) { @@ -1510,13 +1588,16 @@ impl Device { /// /// With each answer, Metal's layout of the texture's bytes as the runtime holds it over host /// pages: a 4:2:2 or two-plane texture's, as its route lays it (`HeapLayout::Measured`); an - /// `X32_Stencil8` texture's, not measured; a `BlockWritesOnly` texture's, the descriptor's - /// without it. + /// `X32_Stencil8` texture's, a `Stencil8` texture's tiles of its image's (of `format`) stencil + /// aspect (`metal_heap_layout`; an M3 Max under macOS 27.0.1: every texel of one-level 8 x 8 + /// to 300 x 200 textures, both ways, where a `Stencil8` texture's lie, and 1720 answers equal + /// a `Stencil8` texture's); a `BlockWritesOnly` texture's, the descriptor's without it. fn metal_heap_answer( &self, call: &'static str, descriptor: &TextureDescriptor, layout: &TextureLayout, + format: Format, ) -> Result, Error> { if let Some(answer) = planes_answer(layout) { return Ok(Some((answer, HeapLayout::Measured))); @@ -1524,10 +1605,15 @@ impl Device { let Some(other) = sized_as(descriptor) else { return Ok(None); }; - let layout = self.heap_layout(call, &other, Creator::SizeQuery)?; - let p = self.heap_plan(call, &other, layout)?; + let other_layout = self.heap_layout(call, &other, Creator::SizeQuery)?; + let p = self.heap_plan(call, &other, other_layout)?; let metal_layout = match descriptor.pixel_format { - PixelFormat::X32Stencil8 => HeapLayout::Untiled(Untiled::other(UNMEASURED_FORMAT)), + PixelFormat::X32Stencil8 => { + let usage = effective_usage(descriptor.usage); + let optimized = descriptor.allow_gpu_optimized_contents; + let level = self.properties().metal_level; + metal_heap_layout(layout, usage, optimized, format, level).layout + } _ => p.metal_layout, }; Ok(Some((p.size_and_align, metal_layout))) @@ -1870,6 +1956,7 @@ impl Device { | AliasRoute::Unaliased | AliasRoute::Planes | AliasRoute::Lossless + | AliasRoute::Tiled ); if !own_memory && image.requirements.memory_type_bits & (1 << type_index) == 0 { return Err(image.memory_refusal()); @@ -1907,10 +1994,10 @@ impl Device { /// image takes copies and the moves fit the device; elsewhere it takes the routes above, /// announced untiled when it is made. /// - /// A multisample texture Metal keeps losslessly compressed (`Untiled::LOSSLESS_MULTISAMPLE`) is - /// its optimal image in memory of its own (`AliasRoute::Lossless`); any other, whose samples - /// Metal lays out in the heap's bytes or whose layout is not measured, - /// `NotImplemented(HostHeapUncompressedMultisample)`. + /// A multisample texture is its optimal image in memory of its own (`AliasRoute::Lossless`): + /// one Metal keeps losslessly compressed (`Untiled::LOSSLESS_MULTISAMPLE`), and one whose + /// samples Metal lays out in the heap's bytes or whose layout is not measured, announced + /// untiled when it is made. fn host_heap_plan( &self, call: &'static str, @@ -1922,11 +2009,6 @@ impl Device { return Err(Error::NotImplemented(RuntimeGap::HeapTextureMemory)); } if p.layout.samples > 1 { - if p.metal_layout != HeapLayout::Untiled(Untiled::LOSSLESS_MULTISAMPLE) { - return Err(Error::NotImplemented( - RuntimeGap::HostHeapUncompressedMultisample, - )); - } let facts = self .shared() .textures @@ -1941,6 +2023,10 @@ impl Device { }; return Ok(HeapPlan { image, ..p }); } + // A shadow of Metal's tiles serves it over host pages as in any heap. + if p.image.route == AliasRoute::Tiled { + return Ok(p); + } if let HeapLayout::Tiled(tiled) = &p.metal_layout { match self.tiled_heap_image(call, &p, tiled, descriptor)? { Some(image) => return Ok(HeapPlan { image, ..p }), @@ -2179,7 +2265,7 @@ impl Device { &self, call: &'static str, p: &HeapPlan, - tiled: &TiledLayout, + tiled: &TiledTexture, descriptor: &TextureDescriptor, ) -> Result, Error> { let facts = self @@ -2189,18 +2275,7 @@ impl Device { let (plan, _) = plan_texture_images(&p.layout, descriptor.image_usage(), false, &facts) .map_err(|refusal| image_error(call, refusal))?; let optimal = self.with_free_usage(plan, p.layout.texture_type)?; - let copies = ImageUsageFlags::TRANSFER_SRC | ImageUsageFlags::TRANSFER_DST; - let (planes, tight_len) = heap_plane_layout( - optimal.format, - optimal.pixel_format, - optimal.extent, - optimal.levels, - optimal.layers, - ); - let serves = optimal.samples == SampleCountFlags::COUNT_1 - && optimal.usage.contains(copies) - && tiled.size <= p.size_and_align.size - && HeapTiledCopies::fit(self, tiled, &planes, tight_len); + let serves = self.tiles_serve(&optimal, tiled, p.size_and_align.size); Ok(serves.then_some(HeapImage { plan: optimal, tiling: vk::ImageTiling::OPTIMAL, @@ -2209,6 +2284,66 @@ impl Device { })) } + /// How a texture of `layout` on `route`, laid out by Metal as `metal`, in a heap not over host + /// pages lies otherwise than Metal lays it in the heap's bytes, where it does: Metal's own + /// layout the runtime does not hold (Metal may keep it compressed, its samples, a layout not + /// measured: `metal`'s reason; `Untiled::LOSSLESS` for one whose uncompressed tiles a shadow + /// would hold), a multisample texture's samples (`Untiled::MULTISAMPLE`), its image a shadow + /// of the bytes in rows (`Untiled::ROWS`), or its image bound there in the driver's layout + /// (`Untiled::DRIVER`; not a single-sample colour image bound there on a driver whose such + /// images lie as Metal's heap textures, `DriverFact::ColorImagesLieAsMetalHeapTextures`, where + /// Metal tiles the texture). `None` for a route whose own notice says where it lies (apart, a + /// two-plane texture's planes) and a layout a measured route holds. + fn device_heap_layout( + &self, + layout: &TextureLayout, + route: AliasRoute, + metal: &HeapLayout, + ) -> Option { + if matches!( + route, + AliasRoute::Apart | AliasRoute::Unaliased | AliasRoute::Planes + ) { + return None; + } + match metal { + HeapLayout::Measured => return None, + HeapLayout::Untiled(untiled) => return Some(*untiled), + HeapLayout::Uncompressed(_) => return Some(Untiled::LOSSLESS), + HeapLayout::Tiled(_) => {} + } + if layout.samples > 1 { + return Some(Untiled::MULTISAMPLE); + } + let facts = &self.properties().driver_facts; + let as_metal = route == AliasRoute::Direct + && !is_depth_stencil(layout.pixel_format) + && facts.contains(&DriverFact::ColorImagesLieAsMetalHeapTextures); + match route { + _ if as_metal => None, + AliasRoute::Shadow | AliasRoute::MemoryShadow => Some(Untiled::ROWS), + _ => Some(Untiled::DRIVER), + } + } + + /// Whether a shadow of Metal's tiles `tiled` serves an image of `plan` whose texture takes + /// `size` bytes of its heap: an image of one sample that takes copies, whose tiles fit those + /// bytes, and whose moves fit the device (`HeapTiledCopies::fit`). + fn tiles_serve(&self, plan: &ImagePlan, tiled: &TiledTexture, size: u64) -> bool { + let copies = ImageUsageFlags::TRANSFER_SRC | ImageUsageFlags::TRANSFER_DST; + let (planes, tight_len) = heap_plane_layout( + plan.format, + plan.pixel_format, + plan.extent, + plan.levels, + plan.layers, + ); + plan.samples == SampleCountFlags::COUNT_1 + && plan.usage.contains(copies) + && tiled.size <= size + && HeapTiledCopies::fit(self, tiled, &planes, tight_len) + } + /// The memory requirements of a linear image of `plan` made for host allocations, in the /// `UNDEFINED` layout as Vulkan has such an image made; `None` where the device imports no /// host memory for such an image (`VkExternalImageFormatProperties`), makes none within its @@ -2555,7 +2690,8 @@ impl Device { let twin_route = twin.as_ref().map(|(twin, _)| twin.route); let host = binding.host; let metal_layout = p.metal_layout; - let image = if let (AliasRoute::Tiled, HeapLayout::Tiled(tiled)) = (route, &metal_layout) { + let tiles = metal_layout.tiles().filter(|_| route == AliasRoute::Tiled); + let image = if let Some(tiled) = tiles { let made = (place, options, descriptor); self.heap_tiled_image(bytes, p.image, &p.layout, tiled.clone(), made)? } else if matches!(route, AliasRoute::Shadow | AliasRoute::MemoryShadow) { @@ -2670,12 +2806,21 @@ impl Device { texture.decode_whole()?; // Over host pages, each texture laid out otherwise than Metal tiles it is announced, in // the program's call that made it, with its ID; and in any heap a multisample texture whose - // image lies in memory of its own. - if host || route == AliasRoute::Lossless { + // image lies in memory of its own, and a shadow of the uncompressed tiles of a texture + // Metal keeps compressed. In any other heap, a texture whose bytes there are not Metal's + // layout (`device_heap_layout`). + if !host && !matches!(route, AliasRoute::Lossless | AliasRoute::Tiled) { + if let Some(untiled) = self.device_heap_layout(&p.layout, route, &metal_layout) { + self.degrade_heap_layout(untiled, texture.object_id()); + } + } else { match metal_layout { HeapLayout::Tiled(_) if route == AliasRoute::Tiled => { self.shared().counts.heap_texture_tiled(); } + HeapLayout::Uncompressed(_) => { + self.degrade_heap_layout(Untiled::LOSSLESS, texture.object_id()); + } HeapLayout::Untiled(untiled) => { self.degrade_heap_layout(untiled, texture.object_id()); } @@ -2788,24 +2933,33 @@ impl Device { } /// Metal's layout of the planes of a heap's two-plane texture of `layout` whose image is of - /// `plan`, where it is measured and the runtime holds the image as a shadow of them - /// (`heap_two_planes.rs`): a 2D texture of one level, one slice and one sample whose image - /// takes copies, whose moves fit the device. `None` for any other, which lies apart from the - /// heap's bytes. + /// `plan` (its first level's, `heap_two_planes.rs`), where the runtime holds the image as a + /// shadow of them: a 1D, 2D, 1D array or 2D array texture of any level count, or a 3D one of + /// one depth slice, of one sample, whose image takes copies, whose moves fit the device. + /// `None` for any other (a 3D texture of more depth slices, whose depth slices Metal's writes + /// lay over one another, or one past the device's limits), which lies apart from the heap's + /// bytes. fn two_plane_heap_layout( &self, layout: &TextureLayout, plan: &ImagePlan, ) -> Option { + use TextureType as T; let copies = ImageUsageFlags::TRANSFER_SRC | ImageUsageFlags::TRANSFER_DST; - let one = layout.texture_type == TextureType::Type2D - && layout.levels == 1 - && layout.layers == 1 - && plan.samples == SampleCountFlags::COUNT_1 - && plan.usage.contains(copies); - let [width, height, _] = layout.extent.map(u64::from); - let planes = TwoPlaneHeapLayout::of([width, height]); - (one && HeapPlaneCopies::fit(self, &planes)).then_some(planes) + let [width, height, depth] = layout.extent.map(u64::from); + let shape = match layout.texture_type { + T::Type1D | T::Type2D | T::Type1DArray | T::Type2DArray => true, + T::Type3D => depth == 1, + _ => false, + }; + let held = + shape && plan.samples == SampleCountFlags::COUNT_1 && plan.usage.contains(copies); + let planes = TwoPlaneHeapLayout::of_texture( + layout.texture_type, + [width, height], + u64::from(layout.layers), + ); + (held && HeapPlaneCopies::fit(self, &planes)).then_some(planes) } /// The image of a heap's two-plane texture on [`AliasRoute::Planes`]: `image`'s plan in @@ -2834,10 +2988,11 @@ impl Device { let hazard = options.hazard_tracking_mode()?; let staging = HeapPlaneCopies::staging(self, &planes, start, hazard)?; let moves = Box::new(HeapPlaneCopies::new(self, &staging, &planes, hazard)?); + // The first level's slices; any later level lies in the image alone. let shadow_range = UseRange::Image { aspects: image_aspects(plan.format).into(), levels: 0..1, - layers: 0..1, + layers: 0..planes.slices as u32, }; let identity = Identity { key: ResourceKey::new(), @@ -2886,7 +3041,7 @@ impl Device { bytes: &Buffer, image: HeapImage, layout: &TextureLayout, - tiled: TiledLayout, + tiled: TiledTexture, (place, options, descriptor): (HeapPlace, ResourceOptions, &TextureDescriptor), ) -> Result { let plan = image.plan; @@ -2993,17 +3148,44 @@ impl Device { return self.degrade(Degradation::ShadowedTexture, || { let [width, height, depth] = layout.extent; let object = format!( - "a {} {:?} texture of {width}x{height}x{depth} in a heap over host pages", + "a {} {:?} texture of {width}x{height}x{depth} in a heap", layout.pixel_format.name(), layout.texture_type ); let why = "Metal tiles its elements in the heap's bytes, which no image of \ - the device lays out: its image is a shadow of them" + the device bound there lays out: its image is a shadow of them" .to_owned(); (object, why) }); } AliasRoute::Planes => { + let levels = layout.levels > 1; + if levels || layout.texture_type == TextureType::Type1DArray { + self.degrade(Degradation::HeapTwoPlaneLayout, || { + let [width, height, depth] = layout.extent; + let object = format!( + "a {} {:?} texture of {width}x{height}x{depth}, {} levels, {} slices \ + in a heap", + layout.pixel_format.name(), + layout.texture_type, + layout.levels, + layout.layers + ); + let why = match levels { + true => { + "Metal's paths address its levels past the first at bytes \ + that differ by path: its first level's planes lie in the \ + heap's bytes, its other levels apart from them" + } + false => { + "Metal's GPU reads every texel of a 1D array at its first \ + word: its texels lie in the heap's bytes as Metal's CPU \ + copies and GPU writes lay them, and read as written" + } + }; + (object, why.to_owned()) + }); + } return self.degrade(Degradation::ShadowedTexture, || { let [width, height, depth] = layout.extent; let object = format!( diff --git a/crates/metal2vulkan-runtime/src/texture/heap_tiled.rs b/crates/metal2vulkan-runtime/src/texture/heap_tiled.rs index b5820e9a4..88e536ebb 100644 --- a/crates/metal2vulkan-runtime/src/texture/heap_tiled.rs +++ b/crates/metal2vulkan-runtime/src/texture/heap_tiled.rs @@ -51,8 +51,12 @@ //! `tests/heap_tiled_blocks.rs` as the M4 does, its CPU's spans and its GPU's. The device's Metal //! level names each family's placement and its GPU's count (`MetalLevel::heap_blocks`, //! `MetalLevel::heap_block_gpu_rows`): the CPU copies place blocks by `TiledLevel::across`, the -//! kernel's moves by `TiledLevel::gpu_across`, as Metal's own two paths do. A PVRTC texture stays -//! untiled (`heap-texture-block-compressed-layout`), its answer its device's. +//! kernel's moves by `TiledLevel::gpu_across`, as Metal's own two paths do. PVRTC's blocks lie +//! so too, `Halved`, under 27.0.1 (an Apple M3 Max: 320 answers, every PVRTC format square from +//! 4 to 2048 texels, one level and full chains, one slice and three; every block of each level of +//! six textures, written by a row-linear blit; `tests/heap_tiled_blocks.rs`); under 26.7 they +//! are not measured, so a PVRTC texture there stays untiled +//! (`heap-texture-block-compressed-layout`), its answer its device's. //! - **Lossless compression** (14174 answers of every plain format, type, shape, usage and storage //! mode). Metal keeps a texture losslessly compressed where `allowGPUOptimizedContents` holds and //! the shorter side of its level 0 is 16 texels or more (16 x 16 compressed; 16 x 8, 6 x 43 and @@ -100,13 +104,28 @@ //! the consumer's report), and so does a one-sample one, of every type and level count, //! compressed or not (every one of 14552 answers each on the M4 and the M3 Max, 2D, and 12330 on //! the M4, 2D arrays, cubes and cube arrays). Over host pages a compressed one lies in memory of -//! its own and is announced `heap-texture-lossless-layout`; an uncompressed one is refused -//! (`RuntimeGap::HostHeapUncompressedMultisample`, `heap.rs`). In any +//! its own and is announced `heap-texture-lossless-layout`; an uncompressed one lies in memory +//! of its own too, its samples apart from the heap's bytes (`heap-texture-untiled-layout`, +//! `heap.rs`). In any //! heap one whose image the heap's memory or Metal's answer cannot hold lies in memory of its own //! too. -//! - **Not measured**: a two-aspect depth and stencil format's layout (`Depth32Float_Stencil8`'s -//! answer is, above) and a PVRTC format's; the runtime holds them untiled -//! (`heap-texture-untiled-layout`), a PVRTC texture at its device's answer. +//! - **Two aspects.** A single-sample `Depth32Float_Stencil8` texture lies in two planes, its depth +//! elements as a `Depth32Float` texture of its shape lies, from its first byte, and its stencil +//! elements as a `Stencil8` one lies, from the `Depth32Float` answer rounded up to 16 KiB +//! (`TiledTexture`; an Apple M3 Max under macOS 27.0.1, `allowGPUOptimizedContents` off: every +//! texel of each aspect of one-level 16 x 16 to 300 x 200 textures, of 7-level 64 x 64 and +//! 100 x 70 ones and of arrays of 2 and 3 slices, 1 to 4 levels, written by blits and found in +//! the heap's bytes, and the bytes written there read back by blits). With it on Metal keeps the +//! depth plane compressed, and a shadow holds its uncompressed tiles, the stencil plane past the +//! compressed answer (`heap-texture-lossless-layout`). +//! - **A stencil view.** An `X32_Stencil8` texture lies as a `Stencil8` texture of its shape lies, +//! compressed or not, and answers as one (an Apple M3 Max under macOS 27.0.1: 1720 answers, 1 to +//! 1024 texels a side, 1 to 3 levels, 1 and 3 slices, allowGPUOptimizedContents off and on; every +//! texel of one-level 8 x 8 to 300 x 200 textures written by blits and found where a `Stencil8` +//! texture's lie, and the bytes written there read back by blits). Its image's tiles are its +//! stencil aspect's; the image's depth holds none of its texels. +//! - **Not measured**: a PVRTC format's layout under macOS 26.7; the runtime holds it untiled +//! (`heap-texture-block-compressed-layout`) at its device's answer. //! //! **Held** as the texture's image in memory of its own, a shadow of the heap's bytes //! (`shadow.rs`, `ShadowTarget::Tiled`): into the image, the texture's bytes copied into a @@ -287,10 +306,12 @@ pub(crate) enum BlockFamily { Etc, /// ASTC of every block size, LDR, sRGB and HDR. Astc, + /// PVRTC of 2 and 4 bits a pixel, RGB and RGBA, linear and sRGB. + Pvrtc, } impl BlockFamily { - /// The family of `pf`; `None` for a format of none (PVRTC's and every plain format). + /// The family of `pf`; `None` for a format of none (every plain format). pub(crate) fn of(pf: PixelFormat) -> Option { use PixelFormat as P; Some(match block_family(pf) { @@ -318,6 +339,9 @@ impl BlockFamily { | P::ASTC10x10LDR | P::ASTC12x10LDR | P::ASTC12x12LDR => BlockFamily::Astc, + P::PVRTCRGB2BPP | P::PVRTCRGB4BPP | P::PVRTCRGBA2BPP | P::PVRTCRGBA4BPP => { + BlockFamily::Pvrtc + } _ => return None, }) } @@ -759,6 +783,53 @@ fn depth_stencil_planes(depth: SizeAndAlign, stencil: SizeAndAlign) -> SizeAndAl } } +/// A single-sample `Depth32Float_Stencil8` texture of `layout`'s two planes in Metal's tiles +/// (the module docs), its image of `format`: the depth plane's elements laid out as a +/// `Depth32Float` texture of its shape is, from the texture's first byte, and the stencil plane's +/// as a `Stencil8` one's, from the depth plane's answer (kept compressed where `compressed`, its +/// metadata counted) rounded up to 16 KiB. `None` where the image holds other elements than +/// those planes' or a plane has no layout. +fn depth_stencil_tiles( + layout: &TextureLayout, + format: Format, + compressed: bool, +) -> Option { + let holds = matches!( + copy_units(format, layout.pixel_format)[..], + [ + (ImageAspectFlags::DEPTH, 4, [1, 1]), + (ImageAspectFlags::STENCIL, 1, [1, 1]) + ] + ); + if !holds || layout.samples > 1 { + return None; + } + let extent = layout.extent.map(u64::from); + let (ty, levels, slices) = (layout.texture_type, layout.levels, u64::from(layout.layers)); + let plane = |unit| TiledLayout::of(unit, Elements::Texels, ty, extent, levels, slices); + let (depth, stencil) = (plane(4)?, plane(1)?); + let depth_bytes = match compressed { + true => lossless_answer(&depth)?.size, + false => depth.size, + }; + let at = depth_bytes.next_multiple_of(PAGE); + Some(TiledTexture { + size: at + stencil.size, + parts: vec![ + TiledPart { + aspect: Some(ImageAspectFlags::DEPTH), + at: 0, + layout: depth, + }, + TiledPart { + aspect: Some(ImageAspectFlags::STENCIL), + at, + layout: stencil, + }, + ], + }) +} + /// The answer of a texture laid out uncompressed as `layout`, kept compressed with `metadata` /// bytes for each chain. fn with_metadata(layout: &TiledLayout, metadata: u64) -> SizeAndAlign { @@ -823,7 +894,7 @@ pub(crate) struct Untiled { impl Untiled { /// A texture Metal may keep losslessly compressed (`heap-texture-lossless-layout`). - const LOSSLESS: Untiled = Untiled { + pub(crate) const LOSSLESS: Untiled = Untiled { kind: Degradation::HeapTextureLosslessLayout, reason: "Metal may keep it losslessly compressed (allowGPUOptimizedContents, 256 texels \ or more, and none of ShaderWrite, PixelFormatView and ShaderAtomic usage, or a \ @@ -839,6 +910,21 @@ impl Untiled { stencil format), whose bytes in the heap are no layout of its samples: its \ image lies in memory of its own, and the heap's bytes keep what they held", }; + /// A texture of a heap over the device's memory whose image lies in the heap's bytes in the + /// driver's layout (`heap-texture-untiled-layout`, `heap.rs`). + pub(crate) const DRIVER: Untiled = Untiled::other( + "its image lies in the heap's bytes in the device driver's layout, which no driver fact \ + measures as Metal's tiles (DriverFact::ColorImagesLieAsMetalHeapTextures)", + ); + /// A texture of a heap over the device's memory whose image is a shadow of the heap's bytes + /// in rows, where Metal tiles its elements (`heap-texture-untiled-layout`, `heap.rs`). + pub(crate) const ROWS: Untiled = Untiled::other( + "its image is a shadow of the heap's bytes in rows, where Metal tiles its elements", + ); + /// A multisample texture whose image lies in the heap's bytes, where Metal lays its samples + /// out by a layout no image of the runtime's is measured to hold + /// (`heap-texture-untiled-layout`, `heap.rs`). + pub(crate) const MULTISAMPLE: Untiled = Untiled::other(MULTISAMPLE_SAMPLES); /// A block-compressed texture whose placement the device's Metal level does not measure /// (`heap-texture-block-compressed-layout`). const BLOCK_COMPRESSED: Untiled = Untiled { @@ -868,17 +954,106 @@ const MULTISAMPLE_SAMPLES: &str = "Metal lays the multisample texture's samples bytes, which no route of the runtime's holds yet, or their \ layout is not measured"; +/// A texture's elements in Metal's tiles: one layout of all of them ([`TiledTexture::one`]), or a +/// `Depth32Float_Stencil8` texture's two planes, each one aspect's elements laid out as a texture +/// of that aspect's format and the texture's shape is (the module docs). +#[derive(Clone, Debug, PartialEq, Eq)] +pub(crate) struct TiledTexture { + /// Its parts, in the order of their bytes. + pub(crate) parts: Vec, + /// The bytes from the texture's first to past its last part's last. + pub(crate) size: u64, +} + +/// One part of a [`TiledTexture`]. +#[derive(Clone, Debug, PartialEq, Eq)] +pub(crate) struct TiledPart { + /// The aspect of the image whose elements it lays out; `None` for each of the image's. + pub(crate) aspect: Option, + /// Its first byte, from the texture's. + pub(crate) at: u64, + /// Its elements' layout, from its first byte. + pub(crate) layout: TiledLayout, +} + +impl TiledTexture { + /// A texture whose elements lie as `layout` says, from its first byte. + pub(crate) fn one(layout: TiledLayout) -> TiledTexture { + TiledTexture { + size: layout.size, + parts: vec![TiledPart { + aspect: None, + at: 0, + layout, + }], + } + } + + /// The part that lays out `aspect`'s elements. + pub(crate) fn part(&self, aspect: ImageAspectFlags) -> Option<&TiledPart> { + (self.parts.iter()).find(|part| part.aspect.is_none_or(|own| own == aspect)) + } +} + /// What the runtime holds of Metal's layout of a heap texture's bytes (the module docs). #[derive(Clone, Debug, PartialEq, Eq)] pub(crate) enum HeapLayout { /// Its elements as Metal lays them: over host pages a shadow of them /// (`HeapTiledCopies`). - Tiled(TiledLayout), + Tiled(TiledTexture), /// Not laid out as Metal's: over host pages, announced once per texture. Untiled(Untiled), /// Laid out as a measured route of its own lays it (a 4:2:2 texture's rows, a two-plane /// texture's planes; `heap.rs`). Measured, + /// A texture Metal keeps losslessly compressed, whose bytes are no layout of its texels + /// ([`Untiled::LOSSLESS`]), held by a shadow of its elements in the tiles Metal lays it in + /// uncompressed (`heap.rs`): announced once per texture as `heap-texture-lossless-layout`. + Uncompressed(TiledTexture), +} + +impl HeapLayout { + /// The tiles a shadow of the texture's bytes lays its elements in: Metal's + /// ([`HeapLayout::Tiled`]), or its uncompressed ones ([`HeapLayout::Uncompressed`]). + pub(crate) fn tiles(&self) -> Option<&TiledTexture> { + match self { + HeapLayout::Tiled(tiled) | HeapLayout::Uncompressed(tiled) => Some(tiled), + HeapLayout::Untiled(_) | HeapLayout::Measured => None, + } + } +} + +/// The layout a shadow of the heap's bytes holds a single-sample texture of `layout` (its image of +/// `format`, at the Metal level `level`) in, where Metal lays it out as `metal`: Metal's tiles +/// where it tiles the texture ([`HeapLayout::Tiled`]); where it keeps the texture losslessly +/// compressed ([`Untiled::LOSSLESS`]), the tiles it lays the texture in uncompressed +/// ([`HeapLayout::Uncompressed`]); `None` for any other (a layout not measured, or an image that +/// holds other bytes than Metal's elements). +pub(crate) fn shadow_tiles( + layout: &TextureLayout, + format: Format, + level: MetalLevel, + metal: &HeapLayout, +) -> Option { + if layout.samples > 1 { + return None; + } + match metal { + HeapLayout::Tiled(_) => Some(metal.clone()), + HeapLayout::Untiled(untiled) if *untiled == Untiled::LOSSLESS => { + // A two-aspect texture's depth plane kept compressed, its stencil plane after it. + if layout.pixel_format == PixelFormat::Depth32FloatStencil8 { + return depth_stencil_tiles(layout, format, true).map(HeapLayout::Uncompressed); + } + // With `allowGPUOptimizedContents` off Metal keeps every texture uncompressed. + let plain = metal_heap_layout(layout, TextureUsage::SHADER_READ, false, format, level); + match plain.layout { + HeapLayout::Tiled(tiled) => Some(HeapLayout::Uncompressed(tiled)), + _ => None, + } + } + _ => None, + } } /// Metal's answer for a heap texture where the runtime knows it, and the runtime's layout of it. @@ -907,6 +1082,13 @@ fn image_element(pf: PixelFormat, format: Format) -> Option<(u64, [u64; 2])> { .find(|(aspect, _, _)| *aspect == ImageAspectFlags::STENCIL) .filter(|_| units.len() == 1) .map(|&(_, bytes, block)| (bytes, block)), + // A stencil view's image holds a depth aspect it does not name (`heap_plane_layout`). + PixelFormat::X32Stencil8 => match units[..] { + [(ImageAspectFlags::DEPTH, _, _), (ImageAspectFlags::STENCIL, bytes, block)] => { + Some((bytes, block)) + } + _ => None, + }, PixelFormat::Depth16Unorm | PixelFormat::Depth32Float => match units[..] { [(ImageAspectFlags::DEPTH, bytes, block)] => { (depth_bytes(format) == Some(bytes)).then_some((bytes, block)) @@ -936,7 +1118,7 @@ fn metal_element(pf: PixelFormat) -> Option { match pf { PixelFormat::Depth16Unorm => Some(2), PixelFormat::Depth32Float => Some(4), - PixelFormat::Stencil8 => Some(1), + PixelFormat::Stencil8 | PixelFormat::X32Stencil8 => Some(1), pf if is_depth_stencil(pf) => None, pf => block_bytes(pf).map(u64::from), } @@ -974,9 +1156,9 @@ pub(crate) fn metal_heap_layout( answer, layout: HeapLayout::Untiled(why), }; - // Block-compressed formats: Metal's allocations are its blocks' (every BC, ETC2, EAC and ASTC - // format), alike under both placements, so a placement the level does not measure answers - // `Halved`'s; PVRTC's are not measured. + // Block-compressed formats: Metal's allocations are its blocks' (every BC, ETC2, EAC, ASTC + // and PVRTC format), alike under both placements, so a placement the level does not measure + // answers `Halved`'s; PVRTC's are measured only where its placement is. if let Some([bw, bh]) = block_extent(pf) { let block = [u64::from(bw), u64::from(bh)]; let family = BlockFamily::of(pf); @@ -987,7 +1169,8 @@ pub(crate) fn metal_heap_layout( gpu_rows: level.heap_block_gpu_rows(), }; let unit = block_bytes(pf).map(u64::from); - let tiled = unit.filter(|_| family.is_some()).and_then(|unit| { + let measured = placement.is_some() || family.is_some_and(|f| f != BlockFamily::Pvrtc); + let tiled = unit.filter(|_| measured).and_then(|unit| { let ty = layout.texture_type; let extent = [width, height, depth]; TiledLayout::of(unit, elements, ty, extent, layout.levels, slices) @@ -1007,7 +1190,7 @@ pub(crate) fn metal_heap_layout( } return MetalHeapLayout { answer, - layout: HeapLayout::Tiled(tiled), + layout: HeapLayout::Tiled(TiledTexture::one(tiled)), }; } if layout.samples > 1 { @@ -1019,8 +1202,8 @@ pub(crate) fn metal_heap_layout( let colour = !is_depth_stencil(pf); let compressed = metal_compresses(colour, usage, allow_gpu_optimized_contents, level0); // `Depth32Float_Stencil8`: its two planes, `Depth32Float`'s and `Stencil8`'s answers for the - // descriptor, the depth plane rounded up to 16 KiB; their layout is not measured, so a heap - // over host pages holds it untiled as before. + // descriptor, the depth plane rounded up to 16 KiB, each laid out as a texture of its format + // (`depth_stencil_tiles`); Metal may keep the depth plane compressed. if pf == PixelFormat::Depth32FloatStencil8 { let plane = |pixel_format| { let one = TextureLayout { @@ -1032,7 +1215,19 @@ pub(crate) fn metal_heap_layout( let answer = plane(PixelFormat::Depth32Float) .zip(plane(PixelFormat::Stencil8)) .map(|(depth, stencil)| depth_stencil_planes(depth, stencil)); - return untiled(answer, Untiled::other(UNMEASURED_FORMAT)); + if compressed { + return untiled(answer, Untiled::LOSSLESS); + } + return match depth_stencil_tiles(layout, format, false) { + Some(tiles) => MetalHeapLayout { + answer, + layout: HeapLayout::Tiled(tiles), + }, + None => untiled( + answer, + Untiled::other("its image holds other bytes than Metal's elements"), + ), + }; } let Some(unit) = metal_element(pf) else { return untiled(None, Untiled::other(UNMEASURED_FORMAT)); @@ -1062,9 +1257,14 @@ pub(crate) fn metal_heap_layout( Untiled::other("its image holds other bytes than Metal's elements"), ); } + // A stencil view's tiles are its image's stencil aspect's. + let mut tiles = TiledTexture::one(tiled); + if pf == PixelFormat::X32Stencil8 { + tiles.parts[0].aspect = Some(ImageAspectFlags::STENCIL); + } MetalHeapLayout { answer: plain, - layout: HeapLayout::Tiled(tiled), + layout: HeapLayout::Tiled(tiles), } } @@ -1076,7 +1276,8 @@ pub(crate) fn metal_heap_layout( /// two planes: the depth plane (`Depth32Float`'s answer) rounded up to 16 KiB, then the stencil /// plane (`Stencil8`'s), at the depth plane's alignment. A sample count Apple's GPUs do not make /// is not measured. Metal's compression decides how a heap over host pages holds it -/// ([`Untiled::LOSSLESS_MULTISAMPLE`], in memory of its own; any other is refused, `heap.rs`). +/// ([`Untiled::LOSSLESS_MULTISAMPLE`]; any other, its samples apart from the heap's bytes): in +/// memory of its own (`heap.rs`). fn multisample_heap_layout( layout: &TextureLayout, usage: TextureUsage, @@ -1085,12 +1286,12 @@ fn multisample_heap_layout( let pf = layout.pixel_format; let [width, height, _] = layout.extent.map(u64::from); let samples = layout.samples; - let refused = |answer| MetalHeapLayout { + let apart = |answer| MetalHeapLayout { answer, layout: HeapLayout::Untiled(Untiled::other(MULTISAMPLE_SAMPLES)), }; let Some(grid) = sample_grid(samples, [width, height]) else { - return refused(None); + return apart(None); }; let colour = !is_depth_stencil(pf); let compressed = metal_compresses(colour, usage, allow_gpu_optimized_contents, grid); @@ -1123,7 +1324,7 @@ fn multisample_heap_layout( layout: HeapLayout::Untiled(Untiled::LOSSLESS_MULTISAMPLE), }; } - refused(answer) + apart(answer) } /// One direction of the kernel's moves: its shape, where it lies in the shape buffer, and the @@ -1139,7 +1340,7 @@ struct Move { /// (into the image, then back). pub(crate) struct HeapTiledCopies { /// Metal's layout of the texture's elements. - pub(crate) layout: TiledLayout, + pub(crate) tiles: TiledTexture, /// The image's elements, each level's from its plane's offset; held for the texture's life. /// No command's uses name it: every copy writes the image or the heap's bytes, so the /// tracker orders it after every other copy of the texture, and each records a full barrier @@ -1163,36 +1364,40 @@ impl HeapTiledCopies { &self.regions } - /// The kernel's levels of a texture of `layout` whose image's elements lie in the tight - /// buffer as `planes` say (`heap_plane_layout`, one plane a level); `None` where a byte the - /// moves name lies past `u32`, or the planes are not the levels'. - fn levels(layout: &TiledLayout, planes: &[HeapPlane]) -> Option> { - if planes.len() != layout.levels.len() { - return None; - } + /// The kernel's levels of a texture of `tiles` whose image's elements lie in the tight + /// buffer as `planes` say (`heap_plane_layout`, one plane a level of each aspect), each + /// part's levels its aspect's planes'; `None` where a byte the moves name lies past `u32`, or + /// the planes are not the levels'. + fn levels(tiles: &TiledTexture, planes: &[HeapPlane]) -> Option> { let narrow = |v: u64| u32::try_from(v).ok(); - layout - .levels - .iter() - .zip(planes) - .map(|(level, plane)| { - let images = plane.images; + let mut moves = Vec::new(); + for part in &tiles.parts { + let layout = &part.layout; + let own: Vec<&HeapPlane> = (planes.iter()) + .filter(|plane| part.aspect.is_none_or(|aspect| aspect == plane.aspect)) + .collect(); + if own.len() != layout.levels.len() { + return None; + } + for (level, plane) in layout.levels.iter().zip(own) { if plane.blocks != level.extent || plane.unit != layout.unit { return None; } - Some(TiledLevelMove::new( + moves.push(TiledLevelMove::new( narrow(layout.unit)?, [narrow(level.extent[0])?, narrow(level.extent[1])?], - narrow(images)?, + narrow(plane.images)?, [narrow(level.tile[0])?, narrow(level.tile[1])?], narrow(level.gpu_across)?, - narrow(level.base)?, + narrow(part.at + level.base)?, narrow(layout.stride)?, narrow(plane.offset)?, narrow(level.bytes)?, - )) - }) - .collect() + )); + } + } + // Every plane is a part's. + (moves.len() == planes.len()).then_some(moves) } /// The workgroups of a dispatch of `invocations` within `device`'s counts, or `None`. @@ -1206,13 +1411,13 @@ impl HeapTiledCopies { fits.then_some([across as u32, down as u32]) } - /// Whether the moves of a texture of `layout`, its tight buffer laid out as `planes` and + /// Whether the moves of a texture of `tiles`, its tight buffer laid out as `planes` and /// `tight_len` bytes long, fit `device`: every byte they name within `u32`, at most - /// `TiledTexelsModule::MAX_LEVELS` levels, each buffer within `maxStorageBufferRange`, and - /// each dispatch within `maxComputeWorkGroupCount`. + /// `TiledTexelsModule::MAX_LEVELS` levels of all its parts, each buffer within + /// `maxStorageBufferRange`, and each dispatch within `maxComputeWorkGroupCount`. pub(crate) fn fit( device: &Device, - layout: &TiledLayout, + tiles: &TiledTexture, planes: &[HeapPlane], tight_len: u64, ) -> bool { @@ -1223,7 +1428,7 @@ impl HeapTiledCopies { .limits .max_storage_buffer_range, ); - let Some(levels) = Self::levels(layout, planes) else { + let Some(levels) = Self::levels(tiles, planes) else { return false; }; let moves = [true, false].iter().all(|&into| { @@ -1234,36 +1439,39 @@ impl HeapTiledCopies { u32::try_from(invocations).is_ok() && Self::grid(device, invocations).is_some() }); levels.len() <= TiledTexelsModule::MAX_LEVELS as usize - && layout.size <= range - && u32::try_from(layout.size).is_ok() + && tiles.size <= range + && u32::try_from(tiles.size).is_ok() && tight_len.next_multiple_of(4) <= range && u32::try_from(tight_len).is_ok() && moves } - /// The staging buffer of a texture of `layout` whose first byte lies at `at` of the heap's + /// The staging buffer of a texture of `tiles` whose first byte lies at `at` of the heap's /// `VkBuffer`: the texture's bytes, from its first to its last, at its start, of the - /// texture's `hazard` tracking; each level's bytes of each chain copied back. + /// texture's `hazard` tracking; each level's bytes of each chain of each part copied back. pub(crate) fn staging( device: &Device, - layout: &TiledLayout, + tiles: &TiledTexture, at: u64, hazard: HazardTrackingMode, ) -> Result { let options = ResourceOptions::new(StorageMode::Private, CpuCacheMode::DefaultCache, hazard); - let buffer = device.own_buffer(layout.size, options)?; + let buffer = device.own_buffer(tiles.size, options)?; let (_, start) = buffer.at(0); - let back = (0..layout.chains) - .flat_map(|chain| { - layout.levels.iter().filter_map(move |level| { - // A 3D level lies in the chains of its depth slices alone. - let used = !layout.volume || chain < level.depth; - let first = chain * layout.stride + level.base; - used.then_some(vk::BufferCopy { - src_offset: start + first, - dst_offset: at + first, - size: level.bytes, + let back = (tiles.parts.iter()) + .flat_map(|part| { + let layout = &part.layout; + (0..layout.chains).flat_map(move |chain| { + layout.levels.iter().filter_map(move |level| { + // A 3D level lies in the chains of its depth slices alone. + let used = !layout.volume || chain < level.depth; + let first = part.at + chain * layout.stride + level.base; + used.then_some(vk::BufferCopy { + src_offset: start + first, + dst_offset: at + first, + size: level.bytes, + }) }) }) }) @@ -1272,14 +1480,14 @@ impl HeapTiledCopies { into: vk::BufferCopy { src_offset: at, dst_offset: start, - size: layout.size, + size: tiles.size, }, back, buffer, }) } - /// The moves of a texture of `layout` through `staging` (its `staging`), + /// The moves of a texture of `tiles` through `staging` (its `staging`), /// whose image's elements lie in its tight buffer as `planes` say, `tight_len` bytes, copied /// to and from the image by `regions` (offsets in that buffer), of the texture's `hazard` /// tracking. Refused as `new_buffer` refuses the tight and shape buffers; the caller checked @@ -1287,12 +1495,12 @@ impl HeapTiledCopies { pub(crate) fn new( device: &Device, staging: &ShadowStaging, - layout: TiledLayout, + tiles: TiledTexture, (planes, tight_len): (&[HeapPlane], u64), regions: &[vk::BufferImageCopy], hazard: HazardTrackingMode, ) -> Result { - let levels = Self::levels(&layout, planes) + let levels = Self::levels(&tiles, planes) .ok_or_else(|| internal("a tiled heap texture's moves past u32"))?; let options = ResourceOptions::new(StorageMode::Private, CpuCacheMode::DefaultCache, hazard); @@ -1326,7 +1534,7 @@ impl HeapTiledCopies { .map(|step| { vec![ (tight_raw, tight_at, tight_bytes), - (staging_raw, staging_at, layout.size), + (staging_raw, staging_at, tiles.size), (shapes_raw, step.at, shape_bytes), ] }) @@ -1340,7 +1548,7 @@ impl HeapTiledCopies { }) .collect(); Ok(HeapTiledCopies { - layout, + tiles, _tight: tight, tight_raw, regions, diff --git a/crates/metal2vulkan-runtime/src/texture/heap_two_planes.rs b/crates/metal2vulkan-runtime/src/texture/heap_two_planes.rs index ee63eac01..d2d63f66a 100644 --- a/crates/metal2vulkan-runtime/src/texture/heap_two_planes.rs +++ b/crates/metal2vulkan-runtime/src/texture/heap_two_planes.rs @@ -14,19 +14,32 @@ //! `align(h · align(4 w, 16), 16384)` bytes past it, in rows `align(w, 16)` bytes apart //! ([`TwoPlaneHeapLayout`]): `heapTextureSizeAndAlignWithDescriptor:`'s answer is the span to //! plane 1's last texel. A write lands on those bytes alone (the bytes between the rows stay), -//! with bits 30 and 31 of each color word 0. The sRGB twin lays its planes out alike. A 2D -//! array's plane 0 slices lie `align(h · align(4 w, 16), 128)` bytes apart, but its alpha reads -//! 0 and its alpha writes land in none of the 1 MiB measured; a mipmapped texture's levels are -//! not laid out in rows. Both stay held apart from the heap's bytes (`heap.rs`, -//! `heap-two-plane-texture`). +//! with bits 30 and 31 of each color word 0. The sRGB twin lays its planes out alike. +//! +//! **Other shapes** (an Apple M3 Max under macOS 27.0.1, plain; a `Shared` placement heap, a +//! buffer over its 4 MiB; kernel writes and reads of every texel of each level and slice, and +//! `replaceRegion` and `getBytes` of each, over 1D, 2D, 1D and 2D array and 3D textures of 1 to 7 +//! levels): a 1D texture lays its row out as a 2D texture of one row. A 2D or 1D array's slices of +//! color words lie `align(h · align(4 w, 16), 128)` bytes apart, each as a 2D texture's plane 0 +//! (kernel writes and reads, CPU copies alike), and it has no plane 1: its alpha writes land +//! nowhere and its alpha reads 0 (a 1D array's GPU reads read every texel at the texture's first +//! word, its writes and CPU copies as above). A mipmapped texture's first level lies as a +//! one-level one's for its CPU copies; its later levels' bytes differ by path (CPU copies at the +//! first level's rows from past it, an array's GPU writes over the first level's bytes, a 2D +//! texture's GPU writes nowhere, its GPU reads at other bytes again), and the GPU writes of a +//! first level land only at some extents (16 x 8, not 37 x 5 nor 64 x 64). A 3D texture's GPU +//! writes of every depth slice land over the first's bytes ([`TwoPlaneHeapLayout::of_texture`]; +//! `heap.rs` holds the shapes apart that no layout serves). //! //! **Held** as the texture's one `R32G32_UINT` image (each texel's color word, then its alpha -//! byte), in memory of its own, a shadow of the heap's bytes (`shadow.rs`, -//! `ShadowTarget::Planes`): into the image, the texture's bytes copied into a staging buffer, -//! one dispatch of `bind::two_plane_texels_module` moving them into a tight buffer of the image's -//! texels, and that buffer copied into the image; back, the image into the tight buffer, the -//! kernel into the staging buffer, and each row of each plane on into the heap's bytes, so the -//! bytes between the rows stay. Each step is ordered after the one before by a full barrier, and +//! byte), in memory of its own, a shadow of its first level's slices in the heap's bytes +//! (`shadow.rs`, `ShadowTarget::Planes`): into the image, the texture's bytes copied into a staging +//! buffer, one dispatch of `bind::two_plane_texels_module` moving them into a tight buffer of the +//! image's texels, and that buffer copied into the image; back, the image into the tight buffer, +//! the kernel into the staging buffer, and each row of each plane on into the heap's bytes, so the +//! bytes between the rows stay. An array's texels take their alpha bytes from zeros in the staging +//! buffer past its words, cleared before each move in, which the move back writes and no copy +//! takes on. A mipmapped texture's later levels lie in the image alone. Each step is ordered after the one before by a full barrier, and //! the buffers are the texture's for its life. A buffer or texture over the texture's bytes, the //! CPU's writes through the heap's pages and the texture's own CPU copies (plane 0's color words //! at Metal's rows, `heap_plane_layout`) then meet the same bytes as on Metal. @@ -39,20 +52,26 @@ use super::super::shadow::{self, ShadowStaging}; use super::super::tracker::Barrier; use super::super::values::{CpuCacheMode, HazardTrackingMode, ResourceOptions, StorageMode}; use super::super::Device; +use super::heap::HeapPlane; use crate::device::functions::Vk; +use crate::two_planes; use ash::vk; use metal2vulkan::bind::{PlaneLayout, TwoPlaneTexelsModule}; +use metal2vulkan::metal::TextureType; +use metal2vulkan::vk::ImageAspectFlags; /// The multiple of bytes past plane 0's start that plane 1 starts at. const ALPHA_PAGE: u64 = 16 << 10; /// The multiple of bytes both planes' rows lie at. const ROW_ALIGNMENT: u64 = 16; +/// The multiple of bytes an array's plane-0 slices lie at. +const SLICE_ALIGNMENT: u64 = 128; /// Where a shape lies in the shape buffer, per direction: a multiple of every /// `minStorageBufferOffsetAlignment`. const SHAPE_SLOT: u64 = 256; -/// Metal's layout of a heap's one-level 2D two-plane texture of `width x height` texels, from -/// its first byte (the module docs). +/// Metal's layout of a heap's two-plane texture's first level, its slices of `width x height` +/// texels, from its first byte (the module docs). #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub(crate) struct TwoPlaneHeapLayout { pub(crate) width: u64, @@ -63,10 +82,18 @@ pub(crate) struct TwoPlaneHeapLayout { pub(crate) alpha_at: u64, /// Plane 1's rows apart: `align(w, 16)`. pub(crate) alpha_pitch: u64, + /// The slices of the first level that lie in the bytes: an array's every one, 1 for any other + /// texture. + pub(crate) slices: u64, + /// Plane 0's slices apart: `align(h · color_pitch, 128)`. + pub(crate) color_slice: u64, + /// Whether plane 1 lies in the bytes: not an array's, whose alpha bytes Metal keeps nowhere + /// and reads as 0. + pub(crate) alpha_kept: bool, } impl TwoPlaneHeapLayout { - /// The layout of a `[width, height]` texture. + /// The layout of a one-level 2D `[width, height]` texture. pub(crate) fn of([width, height]: [u64; 2]) -> TwoPlaneHeapLayout { let color_pitch = (4 * width).next_multiple_of(ROW_ALIGNMENT); TwoPlaneHeapLayout { @@ -75,6 +102,52 @@ impl TwoPlaneHeapLayout { color_pitch, alpha_at: (height * color_pitch).next_multiple_of(ALPHA_PAGE), alpha_pitch: width.next_multiple_of(ROW_ALIGNMENT), + slices: 1, + color_slice: (height * color_pitch).next_multiple_of(SLICE_ALIGNMENT), + alpha_kept: true, + } + } + + /// The layout of the first level of a texture of `texture_type`, its level 0 of `[width, + /// height]` texels (a 1D texture's height 1) and `layers` slices (the module docs): an + /// array's slices `color_slice` apart without plane 1; any other texture's (a mipmapped one's + /// first level, a 3D one's first depth slice) as a one-level 2D texture's. + pub(crate) fn of_texture( + texture_type: TextureType, + [width, height]: [u64; 2], + layers: u64, + ) -> TwoPlaneHeapLayout { + let one = TwoPlaneHeapLayout::of([width, height]); + match texture_type { + TextureType::Type2DArray | TextureType::Type1DArray => TwoPlaneHeapLayout { + slices: layers, + alpha_kept: false, + ..one + }, + _ => one, + } + } + + /// Whether Metal's blits address the texture's planes as `two_planes/heap_bytes.rs` models + /// them: a one-level 2D texture's (one slice, plane 1 kept). + pub(crate) fn blit_rows(&self) -> bool { + self.slices == 1 && self.alpha_kept + } + + /// Plane 0, its color words, as a heap shadow's CPU copies move them: the first level's + /// slices of 4-byte texels, rows `color_pitch` and slices `color_slice` bytes apart. + pub(crate) fn color_plane(&self) -> HeapPlane { + HeapPlane { + aspect: ImageAspectFlags::COLOR, + level: 0, + offset: 0, + extent: [self.width as u32, self.height as u32, 1], + blocks: [self.width, self.height], + images: self.slices, + unit: two_planes::UNIT.bytes.into(), + block: [1, 1], + pitch: self.color_pitch, + image_pitch: self.color_slice, } } @@ -92,18 +165,51 @@ impl TwoPlaneHeapLayout { color_pitch, alpha_at, alpha_pitch, + slices: 1, + color_slice: height * color_pitch, + alpha_kept: true, } } - /// The bytes the planes span: to plane 1's last texel, Metal's answer. + /// The bytes the planes span: to plane 1's last texel, Metal's answer for a one-level 2D + /// texture; to plane 0's last texel where plane 1 is not kept. pub(crate) fn span(&self) -> u64 { - self.alpha_at + (self.height - 1) * self.alpha_pitch + self.width + match self.alpha_kept { + true => self.alpha_at + (self.height - 1) * self.alpha_pitch + self.width, + false => { + (self.slices - 1) * self.color_slice + + (self.height - 1) * self.color_pitch + + 4 * self.width + } + } } - /// Each row of each plane, as (its first byte, its bytes), plane 0's first. + /// Where the staging buffer holds the zero alpha bytes of a texture whose plane 1 is not kept, + /// past the planes' words: every texel reads its alpha there, and the move back writes its + /// alpha words there, which no copy takes on. + fn zeros_at(&self) -> u64 { + self.span().next_multiple_of(4) + } + + /// The staging buffer's bytes: the planes' words, then the zero alpha bytes where plane 1 is + /// not kept. + fn staged_bytes(&self) -> u64 { + match self.alpha_kept { + true => self.span().next_multiple_of(4), + false => self.zeros_at() + 4 * self.width.div_ceil(4), + } + } + + /// Each row of each plane, as (its first byte, its bytes), plane 0's first, slice after + /// slice. fn rows(&self) -> impl Iterator + '_ { - let color = (0..self.height).map(|y| (y * self.color_pitch, 4 * self.width)); - let alpha = (0..self.height).map(|y| (self.alpha_at + y * self.alpha_pitch, self.width)); + let color = (0..self.slices).flat_map(move |s| { + (0..self.height) + .map(move |y| (s * self.color_slice + y * self.color_pitch, 4 * self.width)) + }); + let alpha = (0..self.height) + .filter(|_| self.alpha_kept) + .map(|y| (self.alpha_at + y * self.alpha_pitch, self.width)); color.chain(alpha) } } @@ -133,26 +239,39 @@ pub(crate) struct HeapPlaneCopies { moves: [Move; 2], kernel: OwnedKernel, sets: OwnedSets, + /// Where plane 1 is not kept, the staging buffer's zero alpha bytes, cleared before each + /// move in (its `dst_offset` and `size`). + zeros: Option, + /// The planes' layout. + layout: TwoPlaneHeapLayout, } impl HeapPlaneCopies { + /// The planes' layout. + pub(crate) fn layout(&self) -> &TwoPlaneHeapLayout { + &self.layout + } + /// Whether the moves of `layout` fit `device`: each buffer within `maxStorageBufferRange` /// and each dispatch within `maxComputeWorkGroupCount`. pub(crate) fn fit(device: &Device, layout: &TwoPlaneHeapLayout) -> bool { let limits = &device.properties().description.limits; let range = u64::from(limits.max_storage_buffer_range); - let texels = layout.width * layout.height; - let invocations = texels + layout.width.div_ceil(4) * layout.height; + let texels = layout.width * layout.height * layout.slices; + let invocations = texels + layout.width.div_ceil(4) * layout.height * layout.slices; let groups = invocations.div_ceil(u64::from(TwoPlaneTexelsModule::LOCAL_SIZE)); let across = groups.min(u64::from(limits.max_compute_work_group_count[0])); 8 * texels <= range - && layout.span().next_multiple_of(4) <= range + && layout.staged_bytes() <= range + && u32::try_from(layout.staged_bytes()).is_ok() + && u32::try_from(invocations).is_ok() && groups.div_ceil(across.max(1)) <= u64::from(limits.max_compute_work_group_count[1]) } /// The staging buffer of a texture of `layout` whose first byte lies at `at` of the heap's - /// `VkBuffer`: the texture's bytes, from its first to plane 1's last, at its start, of the - /// texture's `hazard` tracking, in whole 4-byte words; each row of each plane copied back. + /// `VkBuffer`: the texture's bytes, from its first to plane 1's last (plane 0's where plane 1 + /// is not kept, then the zero alpha bytes), at its start, of the texture's `hazard` tracking, + /// in whole 4-byte words; each row of each plane copied back. pub(crate) fn staging( device: &Device, layout: &TwoPlaneHeapLayout, @@ -162,7 +281,7 @@ impl HeapPlaneCopies { let span = layout.span(); let options = ResourceOptions::new(StorageMode::Private, CpuCacheMode::DefaultCache, hazard); - let buffer = device.own_buffer(span.next_multiple_of(4), options)?; + let buffer = device.own_buffer(layout.staged_bytes(), options)?; let (_, start) = buffer.at(0); let back = layout .rows() @@ -196,8 +315,9 @@ impl HeapPlaneCopies { |v: u64| u32::try_from(v).map_err(|_| internal("a two-plane texture past u32")); let limits = &device.properties().description.limits; let [width, height] = [narrow(layout.width)?, narrow(layout.height)?]; - let tight_bytes = 8 * layout.width * layout.height; - let staged_bytes = layout.span().next_multiple_of(4); + let slices = narrow(layout.slices)?; + let tight_bytes = 8 * layout.width * layout.height * layout.slices; + let staged_bytes = layout.staged_bytes(); let options = ResourceOptions::new(StorageMode::Private, CpuCacheMode::DefaultCache, hazard); let tight = device.own_buffer(tight_bytes, options)?; @@ -212,21 +332,35 @@ impl HeapPlaneCopies { let across = groups.min(limits.max_compute_work_group_count[0]); [across, groups.div_ceil(across)] }; - let texels = width * height; + let texels = width * height * slices; let into_groups = grid(texels); - let back_groups = grid(texels + TwoPlaneTexelsModule::alpha_words([width, height], 1)); - let color = PlaneLayout::new(0, narrow(layout.color_pitch / 4)?, 0); - let alpha = PlaneLayout::new( - narrow(layout.alpha_at / 4)?, - narrow(layout.alpha_pitch / 4)?, + let back_groups = grid(texels + TwoPlaneTexelsModule::alpha_words([width, height], slices)); + let color = PlaneLayout::new( 0, + narrow(layout.color_pitch / 4)?, + narrow(layout.color_slice / 4)?, ); + // Where plane 1 is not kept, every texel reads its alpha byte from the zero bytes, and + // the move back writes there (`TwoPlaneHeapLayout::zeros_at`). + let alpha = match layout.alpha_kept { + true => PlaneLayout::new( + narrow(layout.alpha_at / 4)?, + narrow(layout.alpha_pitch / 4)?, + 0, + ), + false => PlaneLayout::new(narrow(layout.zeros_at() / 4)?, 0, 0), + }; + let zeros = (!layout.alpha_kept).then(|| vk::BufferCopy { + src_offset: 0, + dst_offset: staging.into.dst_offset + layout.zeros_at(), + size: staged_bytes - layout.zeros_at(), + }); let moves = [true, false].map(|into| { let groups = if into { into_groups } else { back_groups }; Move { shape: TwoPlaneTexelsModule::shape( [width, height], - 1, + slices, color, alpha, into, @@ -261,7 +395,7 @@ impl HeapPlaneCopies { aspect_mask: vk::ImageAspectFlags::COLOR, mip_level: 0, base_array_layer: 0, - layer_count: 1, + layer_count: slices, }, image_offset: vk::Offset3D::default(), image_extent: vk::Extent3D { @@ -279,6 +413,8 @@ impl HeapPlaneCopies { moves, kernel, sets, + zeros, + layout: *layout, }) } @@ -311,6 +447,15 @@ impl HeapPlaneCopies { Barrier::everything().record(device, command_buffer); if into { device.cmd_copy_buffer(command_buffer, bytes, staging.raw(), &[staging.into]); + if let Some(zeros) = self.zeros { + device.cmd_fill_buffer( + command_buffer, + staging.raw(), + zeros.dst_offset, + zeros.size, + 0, + ); + } } else { device.cmd_copy_image_to_buffer( command_buffer, diff --git a/crates/metal2vulkan-runtime/src/texture/surface_depth.rs b/crates/metal2vulkan-runtime/src/texture/surface_depth.rs index aaf6139f1..375077339 100644 --- a/crates/metal2vulkan-runtime/src/texture/surface_depth.rs +++ b/crates/metal2vulkan-runtime/src/texture/surface_depth.rs @@ -35,7 +35,7 @@ use super::super::tracker::UseRange; use super::super::values::ResourceOptions; use super::super::view_plan::ViewRecord; use super::heap::{heap_plane_layout, heap_planes}; -use super::heap_tiled::{Elements, HeapTiledCopies, TiledLayout}; +use super::heap_tiled::{Elements, HeapTiledCopies, TiledLayout, TiledTexture}; use super::{image_error, IdUse, Image, Storage, Texture}; use ash::vk; use metal2vulkan::metal::format::aspects; @@ -126,6 +126,8 @@ impl Texture { .into_iter() .filter(|region| region.image_subresource.aspect_mask == aspect) .collect(); + // The plane's aspect alone: one part, of the planes given. + let tiled = TiledTexture::one(tiled); if !HeapTiledCopies::fit(device, &tiled, &planes, tight_len) { return Err(gap()); } diff --git a/crates/metal2vulkan-runtime/src/work_counts.rs b/crates/metal2vulkan-runtime/src/work_counts.rs index b8c4f7339..4e6937f92 100644 --- a/crates/metal2vulkan-runtime/src/work_counts.rs +++ b/crates/metal2vulkan-runtime/src/work_counts.rs @@ -2178,8 +2178,7 @@ impl Counters { (self.heap_slot_writes_deferred).fetch_add(1, Ordering::Relaxed); } - /// A texture in a heap over host pages was made tiled as Metal lays it out - /// (`texture/heap_tiled.rs`). + /// A heap's texture was made tiled as Metal lays it out (`texture/heap_tiled.rs`). pub(crate) fn heap_texture_tiled(&self) { self.heap_textures_tiled.fetch_add(1, Ordering::Relaxed); } @@ -2608,8 +2607,10 @@ pub struct WorkCounts { /// bytes meet (`host_aliases.rs`): a use of a range met by no more ranges than the classes of /// length that lookup visits reads those its range keeps instead. pub host_range_lookups: u64, - /// Textures made in heaps over host pages laid out as Metal tiles them, each a shadow of its - /// elements in the heap's bytes (`texture/heap_tiled.rs`). + /// Textures made in heaps laid out as Metal tiles them, each a shadow of its elements in the + /// heap's bytes (`texture/heap_tiled.rs`): in a heap over host pages, and a depth or stencil + /// texture in any heap on a driver that lays such images apart from their memory or keeps + /// them GPU-optimized (MoltenVK). pub heap_textures_tiled: u64, /// The images heap textures' plans made only to ask their memory requirements, destroyed at /// once: none for a plan and tiling asked before on a device that enables `maintenance4`, @@ -2623,14 +2624,15 @@ pub struct WorkCounts { /// had room (`descriptor_arena.rs`): those of commands' set 0 and of the runtime's own /// kernels' sets (`owned_kernel.rs`). pub arena_pools_made: u64, - /// Textures made in heaps over host pages that Metal keeps losslessly compressed - /// (`Degradation::HeapTextureLosslessLayout`). + /// Textures made in heaps that Metal keeps losslessly compressed, where the runtime's image + /// lies in or holds the heap's bytes (`Degradation::HeapTextureLosslessLayout`). pub heap_texture_lossless_layouts: u64, - /// Block-compressed textures made in heaps over host pages whose placement is not measured + /// Block-compressed textures made in heaps whose placement is not measured /// (`Degradation::HeapTextureBlockCompressedLayout`). pub heap_texture_block_compressed_layouts: u64, - /// Other textures made in heaps over host pages laid out otherwise than Metal tiles them - /// (`Degradation::HeapTextureUntiledLayout`). + /// Other textures made in heaps laid out otherwise than Metal lays them in the heap's bytes + /// (`Degradation::HeapTextureUntiledLayout`): over host pages, and over the device's memory + /// in the driver's layout, in rows or as a multisample image (`texture/heap.rs`). pub heap_texture_untiled_layouts: u64, /// Fills recorded as `vkCmdFillBuffer` (`word_fill.rs`): every fill but on a driver measured /// to compile its fill per command pool. diff --git a/crates/metal2vulkan-validation/fixtures/public/engine/TOOLCHAIN b/crates/metal2vulkan-validation/fixtures/public/engine/TOOLCHAIN index c25a2ed70..5e1b7cea2 100644 --- a/crates/metal2vulkan-validation/fixtures/public/engine/TOOLCHAIN +++ b/crates/metal2vulkan-validation/fixtures/public/engine/TOOLCHAIN @@ -324,6 +324,7 @@ fixture wrg_sampler_positions: metal: Apple metal version 32023.921 (metalfe-320 fixture xr_bicubic: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) fixture xr_planes: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) fixture xr_samples: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) +fixture xr_two_plane_arrays: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) fixture xr_two_planes: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) fixture xrb_color2: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) fixture xrb_computed: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) diff --git a/crates/metal2vulkan-validation/fixtures/public/engine/xr_two_plane_arrays.air.ll b/crates/metal2vulkan-validation/fixtures/public/engine/xr_two_plane_arrays.air.ll new file mode 100644 index 000000000..85d5da611 --- /dev/null +++ b/crates/metal2vulkan-validation/fixtures/public/engine/xr_two_plane_arrays.air.ll @@ -0,0 +1,123 @@ +; Generated by scripts/regen-air-fixtures from xr_two_plane_arrays.metal (typed pointers; xcrun metal-as reassembles it). Do not edit. +; ModuleID = '-' +source_filename = "-" +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024-n8:16:32" +target triple = "air64_v28-apple-macosx26.0.0" + +%struct._texture_2d_array_t = type opaque +%struct.Slice = type { i32, i32 } +%struct._sampler_t = type opaque + +; Function Attrs: mustprogress nounwind willreturn +define void @xr2pa_write_float(%struct._texture_2d_array_t addrspace(1)* %0, <4 x float> addrspace(1)* nocapture noundef readonly "air-buffer-no-alias" %1, %struct.Slice addrspace(2)* nocapture noundef readonly align 4 dereferenceable(8) "air-buffer-no-alias" %2, <2 x i32> noundef %3) local_unnamed_addr #0 { + %5 = extractelement <2 x i32> %3, i64 1 + %6 = getelementptr inbounds %struct.Slice, %struct.Slice addrspace(2)* %2, i64 0, i32 0 + %7 = load i32, i32 addrspace(2)* %6, align 4, !tbaa !27, !alias.scope !32, !noalias !35 + %8 = mul i32 %7, %5 + %9 = extractelement <2 x i32> %3, i64 0 + %10 = add i32 %8, %9 + %11 = zext i32 %10 to i64 + %12 = getelementptr inbounds <4 x float>, <4 x float> addrspace(1)* %1, i64 %11 + %13 = load <4 x float>, <4 x float> addrspace(1)* %12, align 16, !tbaa !38, !alias.scope !39, !noalias !40 + %14 = getelementptr inbounds %struct.Slice, %struct.Slice addrspace(2)* %2, i64 0, i32 1 + %15 = load i32, i32 addrspace(2)* %14, align 4, !tbaa !41, !alias.scope !32, !noalias !35 + tail call void @air.write_texture_2d_array.v4f32(%struct._texture_2d_array_t addrspace(1)* nocapture %0, <2 x i32> %3, i32 %15, <4 x float> %13, i32 0, i32 2) #5, !alias.scope !42, !noalias !43 + ret void +} + +; Function Attrs: mustprogress nofree nounwind willreturn +define void @xr2pa_read_float(%struct._texture_2d_array_t addrspace(1)* nocapture readonly %0, <4 x float> addrspace(1)* nocapture noundef writeonly "air-buffer-no-alias" %1, %struct.Slice addrspace(2)* nocapture noundef readonly align 4 dereferenceable(8) "air-buffer-no-alias" %2, <2 x i32> noundef %3) local_unnamed_addr #1 { + %5 = getelementptr inbounds %struct.Slice, %struct.Slice addrspace(2)* %2, i64 0, i32 1 + %6 = load i32, i32 addrspace(2)* %5, align 4, !tbaa !41, !alias.scope !44, !noalias !47 + %7 = tail call %struct._sampler_t addrspace(2)* @air.get_read_sampler() #6 + %8 = tail call { <4 x float>, i8 } @air.read_texture_2d_array.v4f32(%struct._texture_2d_array_t addrspace(1)* nocapture readonly %0, %struct._sampler_t addrspace(2)* %7, <2 x i32> %3, i32 %6, <2 x i32> zeroinitializer, i32 0, i32 1) #7 + %9 = extractvalue { <4 x float>, i8 } %8, 0 + %10 = extractelement <2 x i32> %3, i64 1 + %11 = getelementptr inbounds %struct.Slice, %struct.Slice addrspace(2)* %2, i64 0, i32 0 + %12 = load i32, i32 addrspace(2)* %11, align 4, !tbaa !27, !alias.scope !44, !noalias !47 + %13 = mul i32 %12, %10 + %14 = extractelement <2 x i32> %3, i64 0 + %15 = add i32 %13, %14 + %16 = zext i32 %15 to i64 + %17 = getelementptr inbounds <4 x float>, <4 x float> addrspace(1)* %1, i64 %16 + store <4 x float> %9, <4 x float> addrspace(1)* %17, align 16, !tbaa !38, !alias.scope !50, !noalias !51 + ret void +} + +; Function Attrs: argmemonly mustprogress nounwind willreturn +declare void @air.write_texture_2d_array.v4f32(%struct._texture_2d_array_t addrspace(1)* nocapture, <2 x i32>, i32, <4 x float>, i32, i32) local_unnamed_addr #2 + +; Function Attrs: inaccessiblememonly mustprogress nofree nounwind readonly willreturn +declare %struct._sampler_t addrspace(2)* @air.get_read_sampler() local_unnamed_addr #3 + +; Function Attrs: argmemonly mustprogress nofree nounwind readonly willreturn +declare { <4 x float>, i8 } @air.read_texture_2d_array.v4f32(%struct._texture_2d_array_t addrspace(1)* nocapture readonly, %struct._sampler_t addrspace(2)*, <2 x i32>, i32, <2 x i32>, i32, i32) local_unnamed_addr #4 + +attributes #0 = { mustprogress nounwind willreturn "approx-func-fp-math"="true" "frame-pointer"="all" "min-legal-vector-width"="128" "no-builtins" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" } +attributes #1 = { mustprogress nofree nounwind willreturn "approx-func-fp-math"="true" "frame-pointer"="all" "min-legal-vector-width"="128" "no-builtins" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" } +attributes #2 = { argmemonly mustprogress nounwind willreturn } +attributes #3 = { inaccessiblememonly mustprogress nofree nounwind readonly willreturn } +attributes #4 = { argmemonly mustprogress nofree nounwind readonly willreturn } +attributes #5 = { argmemonly nounwind willreturn } +attributes #6 = { inaccessiblememonly nounwind readonly willreturn } +attributes #7 = { argmemonly nounwind readonly willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!air.kernel = !{!9, !17} +!air.compile_options = !{!21, !22, !23} +!llvm.ident = !{!24} +!air.version = !{!25} +!air.language_version = !{!26} + +!0 = !{i32 2, !"SDK Version", [2 x i32] [i32 27, i32 0]} +!1 = !{i32 1, !"wchar_size", i32 4} +!2 = !{i32 7, !"frame-pointer", i32 2} +!3 = !{i32 7, !"air.max_device_buffers", i32 31} +!4 = !{i32 7, !"air.max_constant_buffers", i32 31} +!5 = !{i32 7, !"air.max_threadgroup_buffers", i32 31} +!6 = !{i32 7, !"air.max_textures", i32 128} +!7 = !{i32 7, !"air.max_read_write_textures", i32 8} +!8 = !{i32 7, !"air.max_samplers", i32 16} +!9 = !{void (%struct._texture_2d_array_t addrspace(1)*, <4 x float> addrspace(1)*, %struct.Slice addrspace(2)*, <2 x i32>)* @xr2pa_write_float, !10, !11} +!10 = !{} +!11 = !{!12, !13, !14, !16} +!12 = !{i32 0, !"air.texture", !"air.location_index", i32 0, i32 1, !"air.write", !"air.arg_type_name", !"texture2d_array", !"air.arg_name", !"t"} +!13 = !{i32 1, !"air.buffer", !"air.location_index", i32 0, i32 1, !"air.read", !"air.address_space", i32 1, !"air.arg_type_size", i32 16, !"air.arg_type_align_size", i32 16, !"air.arg_type_name", !"float4", !"air.arg_name", !"in"} +!14 = !{i32 2, !"air.buffer", !"air.buffer_size", i32 8, !"air.location_index", i32 1, i32 1, !"air.read", !"air.address_space", i32 2, !"air.struct_type_info", !15, !"air.arg_type_size", i32 8, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"Slice", !"air.arg_name", !"s"} +!15 = !{i32 0, i32 4, i32 0, !"uint", !"w", i32 4, i32 4, i32 0, !"uint", !"slice"} +!16 = !{i32 3, !"air.thread_position_in_grid", !"air.arg_type_name", !"uint2", !"air.arg_name", !"g"} +!17 = !{void (%struct._texture_2d_array_t addrspace(1)*, <4 x float> addrspace(1)*, %struct.Slice addrspace(2)*, <2 x i32>)* @xr2pa_read_float, !10, !18} +!18 = !{!19, !20, !14, !16} +!19 = !{i32 0, !"air.texture", !"air.location_index", i32 0, i32 1, !"air.read", !"air.arg_type_name", !"texture2d_array", !"air.arg_name", !"t"} +!20 = !{i32 1, !"air.buffer", !"air.location_index", i32 0, i32 1, !"air.read_write", !"air.address_space", i32 1, !"air.arg_type_size", i32 16, !"air.arg_type_align_size", i32 16, !"air.arg_type_name", !"float4", !"air.arg_name", !"out"} +!21 = !{!"air.compile.denorms_disable"} +!22 = !{!"air.compile.fast_math_enable"} +!23 = !{!"air.compile.framebuffer_fetch_enable"} +!24 = !{!"Apple metal version 32023.921 (metalfe-32023.921.6)"} +!25 = !{i32 2, i32 8, i32 0} +!26 = !{!"Metal", i32 4, i32 0, i32 0} +!27 = !{!28, !29, i64 0} +!28 = !{!"_ZTS5Slice", !29, i64 0, !29, i64 4} +!29 = !{!"int", !30, i64 0} +!30 = !{!"omnipotent char", !31, i64 0} +!31 = !{!"Simple C++ TBAA"} +!32 = !{!33} +!33 = distinct !{!33, !34, !"air-alias-scope-arg(2)"} +!34 = distinct !{!34, !"air-alias-scopes(xr2pa_write_float)"} +!35 = !{!36, !37} +!36 = distinct !{!36, !34, !"air-alias-scope-textures"} +!37 = distinct !{!37, !34, !"air-alias-scope-arg(1)"} +!38 = !{!30, !30, i64 0} +!39 = !{!37} +!40 = !{!36, !33} +!41 = !{!28, !29, i64 4} +!42 = !{!36} +!43 = !{!37, !33} +!44 = !{!45} +!45 = distinct !{!45, !46, !"air-alias-scope-arg(2)"} +!46 = distinct !{!46, !"air-alias-scopes(xr2pa_read_float)"} +!47 = !{!48, !49} +!48 = distinct !{!48, !46, !"air-alias-scope-textures"} +!49 = distinct !{!49, !46, !"air-alias-scope-arg(1)"} +!50 = !{!49} +!51 = !{!48, !45} diff --git a/crates/metal2vulkan-validation/fixtures/public/engine/xr_two_plane_arrays.ll b/crates/metal2vulkan-validation/fixtures/public/engine/xr_two_plane_arrays.ll new file mode 100644 index 000000000..992b53aa1 --- /dev/null +++ b/crates/metal2vulkan-validation/fixtures/public/engine/xr_two_plane_arrays.ll @@ -0,0 +1,121 @@ +; Generated by scripts/regen-air-fixtures from xr_two_plane_arrays.metal (llvm-dis of xr_two_plane_arrays.air). Do not edit. +; ModuleID = '' +source_filename = "-" +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024-n8:16:32" +target triple = "air64_v28-apple-macosx26.0.0" + +%struct.Slice = type { i32, i32 } + +; Function Attrs: mustprogress nounwind willreturn +define void @xr2pa_write_float(ptr addrspace(1) %0, ptr addrspace(1) noundef readonly captures(none) "air-buffer-no-alias" %1, ptr addrspace(2) noundef readonly align 4 captures(none) dereferenceable(8) "air-buffer-no-alias" %2, <2 x i32> noundef %3) local_unnamed_addr #0 { + %5 = extractelement <2 x i32> %3, i64 1 + %6 = getelementptr inbounds %struct.Slice, ptr addrspace(2) %2, i64 0, i32 0 + %7 = load i32, ptr addrspace(2) %6, align 4, !tbaa !27, !alias.scope !32, !noalias !35 + %8 = mul i32 %7, %5 + %9 = extractelement <2 x i32> %3, i64 0 + %10 = add i32 %8, %9 + %11 = zext i32 %10 to i64 + %12 = getelementptr inbounds <4 x float>, ptr addrspace(1) %1, i64 %11 + %13 = load <4 x float>, ptr addrspace(1) %12, align 16, !tbaa !38, !alias.scope !39, !noalias !40 + %14 = getelementptr inbounds %struct.Slice, ptr addrspace(2) %2, i64 0, i32 1 + %15 = load i32, ptr addrspace(2) %14, align 4, !tbaa !41, !alias.scope !32, !noalias !35 + tail call void @air.write_texture_2d_array.v4f32(ptr addrspace(1) captures(none) %0, <2 x i32> %3, i32 %15, <4 x float> %13, i32 0, i32 2) #5, !alias.scope !42, !noalias !43 + ret void +} + +; Function Attrs: mustprogress nofree nounwind willreturn +define void @xr2pa_read_float(ptr addrspace(1) readonly captures(none) %0, ptr addrspace(1) noundef writeonly captures(none) "air-buffer-no-alias" %1, ptr addrspace(2) noundef readonly align 4 captures(none) dereferenceable(8) "air-buffer-no-alias" %2, <2 x i32> noundef %3) local_unnamed_addr #1 { + %5 = getelementptr inbounds %struct.Slice, ptr addrspace(2) %2, i64 0, i32 1 + %6 = load i32, ptr addrspace(2) %5, align 4, !tbaa !41, !alias.scope !44, !noalias !47 + %7 = tail call ptr addrspace(2) @air.get_read_sampler() #6 + %8 = tail call { <4 x float>, i8 } @air.read_texture_2d_array.v4f32(ptr addrspace(1) readonly captures(none) %0, ptr addrspace(2) %7, <2 x i32> %3, i32 %6, <2 x i32> zeroinitializer, i32 0, i32 1) #7 + %9 = extractvalue { <4 x float>, i8 } %8, 0 + %10 = extractelement <2 x i32> %3, i64 1 + %11 = getelementptr inbounds %struct.Slice, ptr addrspace(2) %2, i64 0, i32 0 + %12 = load i32, ptr addrspace(2) %11, align 4, !tbaa !27, !alias.scope !44, !noalias !47 + %13 = mul i32 %12, %10 + %14 = extractelement <2 x i32> %3, i64 0 + %15 = add i32 %13, %14 + %16 = zext i32 %15 to i64 + %17 = getelementptr inbounds <4 x float>, ptr addrspace(1) %1, i64 %16 + store <4 x float> %9, ptr addrspace(1) %17, align 16, !tbaa !38, !alias.scope !50, !noalias !51 + ret void +} + +; Function Attrs: mustprogress nounwind willreturn memory(argmem: readwrite) +declare void @air.write_texture_2d_array.v4f32(ptr addrspace(1) captures(none), <2 x i32>, i32, <4 x float>, i32, i32) local_unnamed_addr #2 + +; Function Attrs: mustprogress nofree nounwind willreturn memory(inaccessiblemem: read) +declare ptr addrspace(2) @air.get_read_sampler() local_unnamed_addr #3 + +; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read) +declare { <4 x float>, i8 } @air.read_texture_2d_array.v4f32(ptr addrspace(1) readonly captures(none), ptr addrspace(2), <2 x i32>, i32, <2 x i32>, i32, i32) local_unnamed_addr #4 + +attributes #0 = { mustprogress nounwind willreturn "approx-func-fp-math"="true" "frame-pointer"="all" "min-legal-vector-width"="128" "no-builtins" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" } +attributes #1 = { mustprogress nofree nounwind willreturn "approx-func-fp-math"="true" "frame-pointer"="all" "min-legal-vector-width"="128" "no-builtins" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" } +attributes #2 = { mustprogress nounwind willreturn memory(argmem: readwrite) } +attributes #3 = { mustprogress nofree nounwind willreturn memory(inaccessiblemem: read) } +attributes #4 = { mustprogress nofree nounwind willreturn memory(argmem: read) } +attributes #5 = { nounwind willreturn memory(argmem: readwrite) } +attributes #6 = { nounwind willreturn memory(inaccessiblemem: read) } +attributes #7 = { nounwind willreturn memory(argmem: read) } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!air.kernel = !{!9, !17} +!air.compile_options = !{!21, !22, !23} +!llvm.ident = !{!24} +!air.version = !{!25} +!air.language_version = !{!26} + +!0 = !{i32 2, !"SDK Version", [2 x i32] [i32 27, i32 0]} +!1 = !{i32 1, !"wchar_size", i32 4} +!2 = !{i32 7, !"frame-pointer", i32 2} +!3 = !{i32 7, !"air.max_device_buffers", i32 31} +!4 = !{i32 7, !"air.max_constant_buffers", i32 31} +!5 = !{i32 7, !"air.max_threadgroup_buffers", i32 31} +!6 = !{i32 7, !"air.max_textures", i32 128} +!7 = !{i32 7, !"air.max_read_write_textures", i32 8} +!8 = !{i32 7, !"air.max_samplers", i32 16} +!9 = !{ptr @xr2pa_write_float, !10, !11} +!10 = !{} +!11 = !{!12, !13, !14, !16} +!12 = !{i32 0, !"air.texture", !"air.location_index", i32 0, i32 1, !"air.write", !"air.arg_type_name", !"texture2d_array", !"air.arg_name", !"t"} +!13 = !{i32 1, !"air.buffer", !"air.location_index", i32 0, i32 1, !"air.read", !"air.address_space", i32 1, !"air.arg_type_size", i32 16, !"air.arg_type_align_size", i32 16, !"air.arg_type_name", !"float4", !"air.arg_name", !"in"} +!14 = !{i32 2, !"air.buffer", !"air.buffer_size", i32 8, !"air.location_index", i32 1, i32 1, !"air.read", !"air.address_space", i32 2, !"air.struct_type_info", !15, !"air.arg_type_size", i32 8, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"Slice", !"air.arg_name", !"s"} +!15 = !{i32 0, i32 4, i32 0, !"uint", !"w", i32 4, i32 4, i32 0, !"uint", !"slice"} +!16 = !{i32 3, !"air.thread_position_in_grid", !"air.arg_type_name", !"uint2", !"air.arg_name", !"g"} +!17 = !{ptr @xr2pa_read_float, !10, !18} +!18 = !{!19, !20, !14, !16} +!19 = !{i32 0, !"air.texture", !"air.location_index", i32 0, i32 1, !"air.read", !"air.arg_type_name", !"texture2d_array", !"air.arg_name", !"t"} +!20 = !{i32 1, !"air.buffer", !"air.location_index", i32 0, i32 1, !"air.read_write", !"air.address_space", i32 1, !"air.arg_type_size", i32 16, !"air.arg_type_align_size", i32 16, !"air.arg_type_name", !"float4", !"air.arg_name", !"out"} +!21 = !{!"air.compile.denorms_disable"} +!22 = !{!"air.compile.fast_math_enable"} +!23 = !{!"air.compile.framebuffer_fetch_enable"} +!24 = !{!"Apple metal version 32023.921 (metalfe-32023.921.6)"} +!25 = !{i32 2, i32 8, i32 0} +!26 = !{!"Metal", i32 4, i32 0, i32 0} +!27 = !{!28, !29, i64 0} +!28 = !{!"_ZTS5Slice", !29, i64 0, !29, i64 4} +!29 = !{!"int", !30, i64 0} +!30 = !{!"omnipotent char", !31, i64 0} +!31 = !{!"Simple C++ TBAA"} +!32 = !{!33} +!33 = distinct !{!33, !34, !"air-alias-scope-arg(2)"} +!34 = distinct !{!34, !"air-alias-scopes(xr2pa_write_float)"} +!35 = !{!36, !37} +!36 = distinct !{!36, !34, !"air-alias-scope-textures"} +!37 = distinct !{!37, !34, !"air-alias-scope-arg(1)"} +!38 = !{!30, !30, i64 0} +!39 = !{!37} +!40 = !{!36, !33} +!41 = !{!28, !29, i64 4} +!42 = !{!36} +!43 = !{!37, !33} +!44 = !{!45} +!45 = distinct !{!45, !46, !"air-alias-scope-arg(2)"} +!46 = distinct !{!46, !"air-alias-scopes(xr2pa_read_float)"} +!47 = !{!48, !49} +!48 = distinct !{!48, !46, !"air-alias-scope-textures"} +!49 = distinct !{!49, !46, !"air-alias-scope-arg(1)"} +!50 = !{!49} +!51 = !{!48, !45} diff --git a/crates/metal2vulkan-validation/fixtures/public/engine/xr_two_plane_arrays.metal b/crates/metal2vulkan-validation/fixtures/public/engine/xr_two_plane_arrays.metal new file mode 100644 index 000000000..8bb61ccc7 --- /dev/null +++ b/crates/metal2vulkan-validation/fixtures/public/engine/xr_two_plane_arrays.metal @@ -0,0 +1,26 @@ +// Owned fixture (written for this repository): kernel writes and reads of one slice of a +// `texture2d_array` of Apple's two-plane extended-range format (`RGB10A8_2P_XR10` or its sRGB +// twin) as `float`, one thread per texel of the slice, the grid's rows `w` texels apart. Loop-free. +#include +using namespace metal; + +struct Slice { + uint w; + uint slice; +}; + +// Writes `in[g.y * w + g.x]` to texel `g` of slice `s.slice`. +kernel void xr2pa_write_float(texture2d_array t [[texture(0)]], + device const float4 *in [[buffer(0)]], constant Slice &s [[buffer(1)]], + uint2 g [[thread_position_in_grid]]) +{ + t.write(in[g.y * s.w + g.x], g, s.slice); +} + +// Reads texel `g` of slice `s.slice` into `out[g.y * w + g.x]`. +kernel void xr2pa_read_float(texture2d_array t [[texture(0)]], + device float4 *out [[buffer(0)]], constant Slice &s [[buffer(1)]], + uint2 g [[thread_position_in_grid]]) +{ + out[g.y * s.w + g.x] = t.read(g, s.slice); +} diff --git a/crates/metal2vulkan-validation/src/runtime_lane/degrade_notices.rs b/crates/metal2vulkan-validation/src/runtime_lane/degrade_notices.rs index 33716e917..f94945a82 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/degrade_notices.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/degrade_notices.rs @@ -32,7 +32,8 @@ //! argument-buffer state is unread ([`ARGUMENT_BUFFERS`]), a device answering at a Metal level //! below its host's macOS release here ([`METAL_LEVELS`]), mipmaps within Metal's //! spread ([`MIPMAPS`]), a heap's depth or stencil texture laid apart from the heap ([`APART`]), -//! a depth or stencil texture without GPU-optimized contents that stays optimized ([`OPTIMIZED`]), +//! a multisample depth or stencil texture without GPU-optimized contents that stays optimized +//! ([`OPTIMIZED`]), //! a heap's colour texture on a driver whose compressed images hide aliased writes ([`ALIASES`]), //! one Metal compresses that keeps the driver's compression there ([`COMPRESSED`]), //! sparse textures on a device without strict residency ([`SPARSE`]), overlapping copies between textures over @@ -98,8 +99,8 @@ //! command buffers whose named uses of a buffer rebound before their first submission fail in //! `rebind_reach` ([`REBOUND_USES`]), textures over bytes detached after they were resident, //! and writable ones whose writes their stand-ins' sinks keep, reached unnamed in -//! `detach_textures` ([`DETACHED_REACHES`]), textures in heaps over host pages laid out otherwise -//! than Metal's tiles in `heap_layouts` ([`HEAP_LAYOUTS`]), fetches under a written depth test +//! `detach_textures` ([`DETACHED_REACHES`]), textures in heaps laid out otherwise than Metal's +//! tiles in `heap_layouts` and `heap_textures` ([`HEAP_LAYOUTS`]), fetches under a written depth test //! run in the shader in `framebuffer_fetch::shader_depth` ([`SHADER_DEPTH`]), //! heap textures whose layout in Metal's heaps the runtime does not model in `heap_metal_sizes` //! ([`UNMODELLED_SIZES`]) and those whose images take more of a heap than Metal's answer there diff --git a/crates/metal2vulkan-validation/src/runtime_lane/extended_range_two_planes.rs b/crates/metal2vulkan-validation/src/runtime_lane/extended_range_two_planes.rs index 15bf9031c..80b317426 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/extended_range_two_planes.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/extended_range_two_planes.rs @@ -651,14 +651,19 @@ fn two_plane_textures_read_and_write_as_metal_does() { }); } -/// The kind a heap's two-plane texture announces where it lies apart from the heap's bytes: a -/// mipmapped or array one. -pub(super) const HEAP_PLANES: [Degradation; 1] = [Degradation::HeapTwoPlaneTexture]; +/// The kinds a heap's two-plane texture announces: where it lies apart from the heap's bytes (a 3D +/// one of more than one depth slice), and where its first level's planes lie in them and its later +/// levels apart (a mipmapped one). +pub(super) const HEAP_PLANES: [Degradation; 2] = [ + Degradation::HeapTwoPlaneTexture, + Degradation::HeapTwoPlaneLayout, +]; /// A texture of each two-plane format in an automatic and a placement heap of each storage mode, /// at the size and alignment the device answers, reads back Metal's values in the consumer's -/// shape as a device texture does: a one-level 2D one, a shadow of its planes in the heap's -/// bytes, announces `shadowed-texture`, and a mipmapped one, apart from them, +/// shape as a device texture does: a one-level 2D one and a mipmapped one, shadows of their first +/// level's planes in the heap's bytes, announce `shadowed-texture`, the mipmapped one +/// `heap-two-plane-layout` once too; a 3D one of two depth slices, apart from them, /// `heap-two-plane-texture` once. #[test] fn two_plane_heap_textures_read_and_write_as_metal_does() { @@ -718,8 +723,9 @@ fn two_plane_heap_textures_read_and_write_as_metal_does() { } report(device, &wrong); let notices = counts(&messages.take_notices()); + assert_eq!(notices.get(&HEAP_PLANES[0]), None, "{notices:?}"); assert_eq!( - notices.get(&HEAP_PLANES[0]).copied(), + notices.get(&HEAP_PLANES[1]).copied(), Some(1), "{notices:?}" ); @@ -727,6 +733,27 @@ fn two_plane_heap_textures_read_and_write_as_metal_does() { notices.contains_key(&Degradation::ShadowedTexture), "{notices:?}" ); + // A 3D texture of two depth slices lies apart from the heap's bytes. + let mut volume = TextureDescriptor::texture_2d(PixelFormat::RGB10A82PXR10, 16, 8, false); + volume.texture_type = TextureType::Type3D; + volume.depth = 2; + volume.usage = TextureUsage::SHADER_READ; + volume.resource_options = ResourceOptions::private(); + let answer = device.heap_texture_size_and_align(&volume).unwrap(); + let heap = device + .new_heap(&HeapDescriptor::new( + HeapType::Placement, + answer.size, + ResourceOptions::private(), + )) + .unwrap(); + heap.new_texture_at_offset(&volume, 0).unwrap(); + let notices = counts(&messages.take_notices()); + assert_eq!( + notices.get(&HEAP_PLANES[0]).copied(), + Some(1), + "{notices:?}" + ); }); } @@ -781,8 +808,8 @@ pub(super) fn get(device: &Device, queue: &CommandQueue, buffer: &Buffer, length /// color word with bits 30 and 31 clear, and on no other byte; bytes written into the planes /// reach the texture's reads; and its CPU copies move plane 0's words there. A texture of the /// device's own, written alike, holds the same color words and alpha bytes, and, given the same -/// color words, reads the same colors. The device announces `shadowed-texture`, and not -/// `heap-two-plane-texture`. +/// color words, reads the same colors. The device announces `shadowed-texture`, and neither +/// `heap-two-plane-texture` nor `heap-two-plane-layout`. #[test] fn two_plane_heap_textures_keep_their_texels_in_the_heap_s_bytes() { on_device(|device, messages| { @@ -904,8 +931,249 @@ fn two_plane_heap_textures_keep_their_texels_in_the_heap_s_bytes() { notices.contains_key(&Degradation::ShadowedTexture), "{notices:?}" ); + for kind in HEAP_PLANES { + assert!(!notices.contains_key(&kind), "{notices:?}"); + } + }); +} + +/// The fixture `xr_two_plane_arrays`'s kernel `name`. +fn array_state(device: &Device, name: &str) -> ComputePipelineState { + let bitcode = llvm_assemble(&engine_dir().join("xr_two_plane_arrays.ll")).unwrap(); + let library = device.new_library_with_air(&bitcode).unwrap(); + let function = library.new_function_with_name(name).unwrap(); + device + .new_compute_pipeline_state( + &ComputePipelineDescriptor::new(StageSource::Function(function.function_descriptor())), + &PipelineOptions::default(), + ) + .unwrap_or_else(|e| panic!("{name}: {e}")) +} + +/// Runs the array kernel `state` over slice `slice` of `texture`, a `[w, h]` texture array, with +/// `buffer` at 0, one thread per texel. +fn run_slice( + device: &Device, + queue: &CommandQueue, + state: &ComputePipelineState, + (texture, buffer): (&Texture, &Buffer), + [w, h]: [u64; 2], + slice: u64, +) { + let shape: Vec = [w as u32, slice as u32] + .iter() + .flat_map(|word| word.to_le_bytes()) + .collect(); + let shape = buffer_with(device, &shape).unwrap(); + let command_buffer = queue.command_buffer().unwrap(); + let mut encoder = command_buffer.compute_command_encoder().unwrap(); + encoder.set_compute_pipeline_state(state).unwrap(); + encoder.set_texture(Some(texture), 0).unwrap(); + encoder.set_buffer(Some(buffer), 0, 0).unwrap(); + encoder.set_buffer(Some(&shape), 0, 1).unwrap(); + encoder + .dispatch_threads(Size::new(w, h, 1), Size::new(32, 32, 1)) + .unwrap(); + encoder.end_encoding().unwrap(); + command_buffer.commit().unwrap(); + command_buffer.wait_until_completed_for(WAIT).unwrap(); + assert_eq!(command_buffer.status(), CommandBufferStatus::Completed); + assert_eq!(command_buffer.error(), None); +} + +/// The extent, slices and offset of the arrays of +/// [`two_plane_heap_arrays_keep_their_slices_in_the_heap_s_bytes`], and their slices apart in the +/// heap's bytes: `align(h · align(4 w, 16), 128)`. +const ARRAY_EXTENT: [u64; 2] = [37, 5]; +const ARRAY_SLICES: u64 = 2; +const ARRAY_AT: u64 = 128; +const ARRAY_SLICE: u64 = 0x380; + +/// A 2D array of each two-plane format in a placement heap of each storage mode keeps its slices' +/// color words in the heap's bytes as Metal does (an Apple M3 Max under macOS 27.0.1, a probe of +/// kernel writes and reads, `replaceRegion` and `getBytes` through a buffer over the heap's bytes): +/// slice `s`'s rows as a 2D texture's, `align(h · align(4 w, 16), 128)` bytes past slice `s - 1`'s, +/// and no alpha plane. A kernel's writes of a slice land on that slice's color words alone, as a +/// texture of the device's own written alike holds them, and no other byte; words written there +/// reach the texture's reads, whose alpha reads 0; the CPU copies move each slice's words there. +/// The device announces `shadowed-texture` and neither `heap-two-plane-texture` nor +/// `heap-two-plane-layout`. +#[test] +fn two_plane_heap_arrays_keep_their_slices_in_the_heap_s_bytes() { + on_device(|device, messages| { + let queue = device.new_command_queue().unwrap(); + let write = array_state(device, "xr2pa_write_float"); + let read = array_state(device, "xr2pa_read_float"); + let kernels = Kernels::new(device); + let [w, h] = ARRAY_EXTENT; + let texels = (w * h) as usize; + let color = (4 * w).next_multiple_of(16); + let at = |s: u64, x: u64, y: u64| (ARRAY_AT + s * ARRAY_SLICE + y * color + 4 * x) as usize; + for format in [PixelFormat::RGB10A82PXR10, PixelFormat::RGB10A82PXR10SRGB] { + let reference = texture(device, format, w, h); + for options in [ResourceOptions::shared(), ResourceOptions::private()] { + let what = format!("{format:?} {:?}", options.storage_mode().unwrap()); + let mut descriptor = TextureDescriptor::texture_2d(format, w, h, false); + descriptor.texture_type = TextureType::Type2DArray; + descriptor.array_length = ARRAY_SLICES; + descriptor.usage = TextureUsage::SHADER_READ | TextureUsage::SHADER_WRITE; + descriptor.resource_options = options; + let answer = device.heap_texture_size_and_align(&descriptor).unwrap(); + // Metal's answer: plane 0's slices rounded up to 16 KiB, then plane 1's, at 128. + assert_eq!((answer.size, answer.align), (0x4200, 128), "{what}"); + let heap: Heap = device + .new_heap(&HeapDescriptor::new( + HeapType::Placement, + PLANES_HEAP, + options, + )) + .unwrap(); + let t = heap + .new_texture_at_offset(&descriptor, ARRAY_AT) + .unwrap_or_else(|e| panic!("{what}: {e}")); + let bytes = heap.new_buffer_at_offset(PLANES_HEAP, options, 0).unwrap(); + for slice in 0..ARRAY_SLICES { + // A kernel's writes of the slice land on its color words alone. + put(device, &queue, &bytes, &vec![0xee; PLANES_HEAP as usize]); + let values = floats(texels, 37 + 11 * slice as usize); + let input = buffer_with(device, &values).unwrap(); + run_slice(device, &queue, &write, (&t, &input), [w, h], slice); + super::extended_range_two_planes::write( + device, + &queue, + &kernels, + &reference, + (&values, false), + Dispatch::Texels(w, h), + ); + let mut words = vec![0; 4 * texels]; + reference + .get_bytes(&mut words, 4 * w, 0, Region::new_2d(0, 0, w, h), 0, 0) + .unwrap(); + let mut want = vec![0xee; PLANES_HEAP as usize]; + for y in 0..h { + for x in 0..w { + let i = (y * w + x) as usize; + let o = at(slice, x, y); + want[o..o + 4].copy_from_slice(&words[4 * i..4 * i + 4]); + } + } + let got = get(device, &queue, &bytes, PLANES_HEAP); + let differ = (0..got.len()).filter(|&k| got[k] != want[k]).count(); + assert_eq!(differ, 0, "{what}: slice {slice}: {differ} bytes differ"); + // Words written there reach the slice's reads, its alpha 0. + let pattern: Vec = (0..PLANES_HEAP) + .map(|k| (k * 131 + 7 + slice) as u8) + .collect(); + put(device, &queue, &bytes, &pattern); + let out = buffer_with(device, &vec![0xab; 16 * texels]).unwrap(); + run_slice(device, &queue, &read, (&t, &out), [w, h], slice); + let got = read_buffer(&out, 0, 16 * texels as u64).unwrap(); + let mut words = vec![0; 4 * texels]; + for y in 0..h { + for x in 0..w { + let i = (y * w + x) as usize; + let o = at(slice, x, y); + words[4 * i..4 * i + 4].copy_from_slice(&pattern[o..o + 4]); + } + } + reference + .replace_region(Region::new_2d(0, 0, w, h), 0, 0, &words, 4 * w, 0) + .unwrap(); + let [_, colors] = + reads(device, &queue, &kernels, &reference, Dispatch::Texels(w, h)); + for i in 0..texels { + assert_eq!( + got[16 * i..16 * i + 12], + colors[16 * i..16 * i + 12], + "{what}: slice {slice}: colors of texel {i}" + ); + assert_eq!( + got[16 * i + 12..16 * i + 16], + 0f32.to_le_bytes(), + "{what}: slice {slice}: alpha of texel {i}" + ); + } + // The CPU copies the slice's words where they lie in the heap. + if options.storage_mode().unwrap() == StorageMode::Shared { + let mut read = vec![0; 4 * texels]; + let region = Region::new_2d(0, 0, w, h); + t.get_bytes(&mut read, 4 * w, 0, region, 0, slice).unwrap(); + assert_eq!(read, words, "{what}: slice {slice}: get_bytes"); + let replaced: Vec = + (0..4 * texels).map(|k| (k * 7 + 1) as u8).collect(); + t.replace_region(region, 0, slice, &replaced, 4 * w, 0) + .unwrap(); + let got = read_buffer(&bytes, 0, PLANES_HEAP).unwrap(); + let mut want = pattern.clone(); + for y in 0..h { + for x in 0..w { + let i = (y * w + x) as usize; + let o = at(slice, x, y); + want[o..o + 4].copy_from_slice(&replaced[4 * i..4 * i + 4]); + } + } + assert!(got == want, "{what}: slice {slice}: replace_region"); + } + } + } + } + let notices = counts(&messages.take_notices()); assert!( - !notices.contains_key(&Degradation::HeapTwoPlaneTexture), + notices.contains_key(&Degradation::ShadowedTexture), + "{notices:?}" + ); + for kind in HEAP_PLANES { + assert!(!notices.contains_key(&kind), "{notices:?}"); + } + }); +} + +/// A mipmapped two-plane texture in a placement heap keeps its first level's color words in the +/// heap's bytes where Metal's CPU copies lay them (an Apple M3 Max under macOS 27.0.1: level 0's +/// rows as a one-level texture's), and its second level apart from them: a CPU copy of level 1 +/// reads back what it wrote and changes none of the heap's bytes. The device announces +/// `heap-two-plane-layout` once. +#[test] +fn a_mipmapped_two_plane_heap_texture_keeps_its_first_level_in_the_heap_s_bytes() { + on_device(|device, messages| { + let [w, h] = [16u64, 8]; + let mut descriptor = TextureDescriptor::texture_2d(PixelFormat::RGB10A82PXR10, w, h, true); + descriptor.mipmap_level_count = 2; + descriptor.usage = TextureUsage::SHADER_READ; + descriptor.resource_options = ResourceOptions::shared(); + let options = ResourceOptions::shared(); + let heap = device + .new_heap(&HeapDescriptor::new( + HeapType::Placement, + PLANES_HEAP, + options, + )) + .unwrap(); + let t = heap.new_texture_at_offset(&descriptor, 0).unwrap(); + let bytes = heap.new_buffer_at_offset(PLANES_HEAP, options, 0).unwrap(); + let before = read_buffer(&bytes, 0, PLANES_HEAP).unwrap(); + let level0: Vec = (0..4 * w * h).map(|k| (k * 3 + 1) as u8).collect(); + t.replace_region(Region::new_2d(0, 0, w, h), 0, 0, &level0, 4 * w, 0) + .unwrap(); + let mut want = before.clone(); + want[..(4 * w * h) as usize].copy_from_slice(&level0); + let got = read_buffer(&bytes, 0, PLANES_HEAP).unwrap(); + assert!(got == want, "level 0's words at its rows (64 bytes apart)"); + let level1: Vec = (0..w * h).map(|k| (k * 5 + 9) as u8).collect(); + let region = Region::new_2d(0, 0, w / 2, h / 2); + t.replace_region(region, 1, 0, &level1, 2 * w, 0).unwrap(); + assert!( + read_buffer(&bytes, 0, PLANES_HEAP).unwrap() == want, + "level 1 changes none of the heap's bytes" + ); + let mut read = vec![0; (w * h) as usize]; + t.get_bytes(&mut read, 2 * w, 0, region, 1, 0).unwrap(); + assert_eq!(read, level1, "level 1 reads back"); + let notices = counts(&messages.take_notices()); + assert_eq!( + notices.get(&HEAP_PLANES[1]).copied(), + Some(1), "{notices:?}" ); }); diff --git a/crates/metal2vulkan-validation/src/runtime_lane/heap_layouts.rs b/crates/metal2vulkan-validation/src/runtime_lane/heap_layouts.rs index b0e9a8dc0..452c33cec 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/heap_layouts.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/heap_layouts.rs @@ -22,7 +22,8 @@ //! writes of the CPU's bytes. //! - **Layouts the runtime does not follow** ([`HEAP_LAYOUTS`]). A texture Metal keeps //! losslessly compressed (`heap-texture-lossless-layout`), one of a block-compressed format -//! whose placement no level measures (PVRTC, `heap-texture-block-compressed-layout`) and one +//! whose placement its device's Metal level does not measure (PVRTC at macOS 26.7's, +//! `heap-texture-block-compressed-layout`) and one //! of a format whose layout is not measured //! (`heap-texture-untiled-layout`, a two-aspect depth and stencil format) are each counted //! (`Device::degraded_objects`, and its kind's `WorkCounts` field) and usable: the notice is @@ -31,8 +32,8 @@ //! - **Multisample textures**. One Metal keeps losslessly compressed lies in memory of its own: //! counted and announced `heap-texture-lossless-layout`, usable (a pass clears and resolves it), //! the heap's bytes keeping every byte they held; the heap's detach is refused while it lives (no -//! stand-in zeroes samples). One Metal keeps uncompressed is refused -//! `NotImplemented(HostHeapUncompressedMultisample)`. The size query answers at least Metal's +//! stand-in zeroes samples). One Metal keeps uncompressed lies in memory of its own too: counted +//! and announced `heap-texture-untiled-layout`, usable. The size query answers at least Metal's //! for both. use super::degrade_notices::{counts, on_device, on_device_with}; @@ -621,14 +622,17 @@ fn a_command_writing_a_tiled_texture_two_ways_keeps_both_writes() { }); } -/// A texture Metal keeps losslessly compressed, one of a block-compressed format whose placement -/// no level measures (PVRTC) and one of a two-aspect depth and stencil format, each in a heap -/// over host pages, are counted in their kind's field and `Device::degraded_objects`, and the -/// first of each kind is announced in the call that made it, with its ID; each is usable after. -/// Two compressed textures, one notice, a count of two. +/// A texture Metal keeps losslessly compressed (a colour one, a `Depth32Float_Stencil8` one and an +/// `X32_Stencil8` one), one of a block-compressed format whose placement its device's Metal level +/// does not measure (PVRTC at macOS 26.7's, `DeviceOptions::metal_level`) and one whose samples +/// Metal lays out in the heap's bytes (an uncompressed multisample one, which lies apart from +/// them), each in a heap over host pages, are counted in their kind's field and +/// `Device::degraded_objects`, and the first of each kind is announced in the call that made it, +/// with its ID; each is usable after. Four compressed textures, one notice, a count of four. #[test] fn heap_textures_laid_out_otherwise_than_metal_s_tiles_are_counted_and_announced_once() { - on_device(|device, messages| { + let at_26_7 = |options: &mut DeviceOptions| options.metal_level = Some(MetalLevel::MacOS26_7); + on_device_with(at_26_7, |device, messages| { let mapping = Mapping::anonymous(HEAP); let Some(heap) = heap_over(device, &mapping) else { return; @@ -645,6 +649,15 @@ fn heap_textures_laid_out_otherwise_than_metal_s_tiles_are_counted_and_announced TextureDescriptor::texture_2d(PixelFormat::Depth32FloatStencil8, 32, 32, false); aspects.resource_options = shared(); aspects.usage = read | TextureUsage::RENDER_TARGET; + let mut stencil = TextureDescriptor::texture_2d(PixelFormat::X32Stencil8, 32, 32, false); + stencil.resource_options = shared(); + stencil.usage = read; + let mut samples = TextureDescriptor::texture_2d(PixelFormat::RGBA8Unorm, 32, 32, false); + samples.resource_options = shared(); + samples.texture_type = TextureType::Type2DMultisample; + samples.sample_count = 4; + samples.usage = TextureUsage::RENDER_TARGET; + samples.allow_gpu_optimized_contents = false; // Metal's answer for the compressed shape (`heap_textures`): its // metadata included. let answer = device.heap_texture_size_and_align(&compressed).unwrap(); @@ -653,7 +666,9 @@ fn heap_textures_laid_out_otherwise_than_metal_s_tiles_are_counted_and_announced (compressed, Degradation::HeapTextureLosslessLayout, 1), (compressed, Degradation::HeapTextureLosslessLayout, 1), (blocks, Degradation::HeapTextureBlockCompressedLayout, 2), - (aspects, Degradation::HeapTextureUntiledLayout, 3), + (aspects, Degradation::HeapTextureLosslessLayout, 1), + (stencil, Degradation::HeapTextureLosslessLayout, 1), + (samples, Degradation::HeapTextureUntiledLayout, 3), ]; let mut offset = 0u64; let mut kept = Vec::new(); @@ -697,10 +712,10 @@ fn heap_textures_laid_out_otherwise_than_metal_s_tiles_are_counted_and_announced Some(objects + 1), "{what}: counted" ); - // Usable: its texels round-trip. - let (row, rows) = match descriptor.pixel_format { - PixelFormat::PVRTCRGBA4BPP => (16 * 8, 16), - PixelFormat::RGBA8Unorm => (64 * 4, 64), + // Usable: its texels round-trip (a single-sample texture's, which the CPU copies). + let (row, rows) = match (descriptor.pixel_format, descriptor.sample_count) { + (PixelFormat::PVRTCRGBA4BPP, _) => (16 * 8, 16), + (PixelFormat::RGBA8Unorm, 1) => (64 * 4, 64), _ => (0, 0), }; if row > 0 { @@ -1178,13 +1193,15 @@ fn block_rows_lie_as_their_level_lays_them_out( /// counted and announced (`heap-texture-lossless-layout`, the first of its kind, with its ID); the /// heap's detach refused while it lives (`NotImplemented(DetachTextures)`); a pass clears it and /// resolves it into a texture that reads the clear colour in every texel, and the heap's bytes -/// keep every byte they held. Without it, which Metal keeps uncompressed, refused -/// `NotImplemented(HostHeapUncompressedMultisample)`. The size query answers at least Metal's for +/// keep every byte they held. Without it, which Metal keeps uncompressed (its samples side by side +/// in Metal's tiles in the heap's bytes), made in memory of its own too, counted and announced +/// `heap-texture-untiled-layout` with its ID; a pass clears and resolves it alike, the heap's +/// bytes kept. The size query answers at least Metal's for /// each on every device (66048 and 65536 bytes at 128; and measured for the /// uncompressed one where the device cannot hold its samples in the heap's bytes, an NVIDIA GPU's: /// no optimal image in host-visible memory, no multisample linear image). #[test] -fn a_host_heap_s_compressed_multisample_texture_lies_apart_from_its_bytes() { +fn a_host_heap_s_multisample_textures_lie_apart_from_its_bytes() { on_device(|device, messages| { if device.properties().supports_texture_sample_count(4) != Ok(true) { eprintln!("HEAPLAYOUT multisample: the device takes no 4-sample texture"); @@ -1208,10 +1225,6 @@ fn a_host_heap_s_compressed_multisample_texture_lies_apart_from_its_bytes() { Err(error) => panic!("the size query: {error:?}"), } } - match heap.new_texture_at_offset(&plain, OFFSET) { - Err(Error::NotImplemented(RuntimeGap::HostHeapUncompressedMultisample)) => {} - other => panic!("an uncompressed multisample texture: {other:?}"), - } let before = named(HEAP, 11); mapping.write(0, &before); let kind = Degradation::HeapTextureLosslessLayout; @@ -1235,37 +1248,50 @@ fn a_host_heap_s_compressed_multisample_texture_lies_apart_from_its_bytes() { Err(Error::NotImplemented(RuntimeGap::DetachTextures)) => {} other => panic!("a detach with a multisample texture: {other:?}"), } + // Without it: made apart too, its samples' layout announced. + let untiled = Degradation::HeapTextureUntiledLayout; + let untiled_objects = device + .degraded_objects(untiled) + .expect("a kind counted per texture"); + let uncompressed = heap.new_texture_at_offset(&plain, 3 * OFFSET).unwrap(); + assert_eq!( + layout_notices(messages), + [(untiled, Some(uncompressed.object_id()))] + ); + assert_eq!(device.degraded_objects(untiled), Some(untiled_objects + 1)); let mut target = TextureDescriptor::texture_2d(PixelFormat::RGBA8Unorm, 64, 64, false); target.usage = TextureUsage::RENDER_TARGET; target.resource_options = shared(); let resolved = device.new_texture(&target).unwrap(); - let mut pass = RenderPassDescriptor::new(); - let color = &mut pass.color_attachments[0]; - color.texture = Some(texture.clone()); - color.load_action = LoadAction::Clear; - color.clear_color = ClearColor::new(0.2, 0.4, 0.6, 1.0); - color.store_action = StoreAction::MultisampleResolve; - color.resolve_texture = Some(resolved.clone()); let queue = device.new_command_queue().unwrap(); - let command_buffer = queue.command_buffer().unwrap(); - let encoder = command_buffer.render_command_encoder(&pass).unwrap(); - encoder.end_encoding().unwrap(); - run(&command_buffer); - let mut texels = vec![0u8; 64 * 64 * 4]; - let region = Region::new_2d(0, 0, 64, 64); - resolved - .get_bytes(&mut texels, 64 * 4, 0, region, 0, 0) - .unwrap(); - assert!( - texels.chunks(4).all(|texel| texel == [51, 102, 153, 255]), - "resolved: {:?}", - &texels[..16] - ); + for source in [&texture, &uncompressed] { + let mut pass = RenderPassDescriptor::new(); + let color = &mut pass.color_attachments[0]; + color.texture = Some(source.clone()); + color.load_action = LoadAction::Clear; + color.clear_color = ClearColor::new(0.2, 0.4, 0.6, 1.0); + color.store_action = StoreAction::MultisampleResolve; + color.resolve_texture = Some(resolved.clone()); + let command_buffer = queue.command_buffer().unwrap(); + let encoder = command_buffer.render_command_encoder(&pass).unwrap(); + encoder.end_encoding().unwrap(); + run(&command_buffer); + let mut texels = vec![0u8; 64 * 64 * 4]; + let region = Region::new_2d(0, 0, 64, 64); + resolved + .get_bytes(&mut texels, 64 * 4, 0, region, 0, 0) + .unwrap(); + assert!( + texels.chunks(4).all(|texel| texel == [51, 102, 153, 255]), + "resolved: {:?}", + &texels[..16] + ); + } let after = mapping.read(0..HEAP); let differ = (0..HEAP).filter(|&i| after[i] != before[i]).count(); assert_eq!(differ, 0, "the heap's bytes changed"); - drop((texture, resolved, heap)); + drop((texture, uncompressed, resolved, heap)); drop(mapping); - eprintln!("HEAPLAYOUT multisample: compressed made apart, uncompressed refused"); + eprintln!("HEAPLAYOUT multisample: compressed and uncompressed made apart"); }); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/heap_metal_sizes.rs b/crates/metal2vulkan-validation/src/runtime_lane/heap_metal_sizes.rs index 3ee90bc8c..1485a8ea5 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/heap_metal_sizes.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/heap_metal_sizes.rs @@ -873,8 +873,10 @@ pub(super) const UNMODELLED_SIZES: [Degradation; 1] = [Degradation::UnmeasuredHe /// A heap texture whose layout in Metal's heaps the runtime does not model answers its device's /// size and announces `unmeasured-heap-texture-size` once a device: an 8-sample `RGBA8Unorm` /// texture, where the device takes 8 samples (Apple's GPUs take 2 and 4, so Metal's layout of 8 is -/// not measured), or else a PVRTC texture, where the device has the format (its placement is not -/// measured); a device with neither announces nothing. One-level and mipmapped textures Metal +/// not measured), or else a PVRTC texture, where the device has the format and its Metal level is +/// macOS 26.7's (whose PVRTC placement is not measured; under 27.0.1 it answers Metal's 2048 bytes +/// for 64x64 `PVRTC_RGBA_4BPP`, announcing nothing); a device with neither announces nothing. +/// One-level and mipmapped textures Metal /// compresses announce nothing, their answers Metal's model's (the consumer's boot's three-level /// 224 x 928 `RGBA16Float` texture of `ShaderRead | RenderTarget | BlockWritesOnly` usage and a /// seven-level 64 x 64 x 64 3D one). @@ -918,8 +920,16 @@ fn an_unmodelled_heap_size_is_announced_once() { eight.texture_type = TextureType::Type2DMultisample; eight.sample_count = 8; let pvrtc = TextureDescriptor::texture_2d(PixelFormat::PVRTCRGBA4BPP, 64, 64, false); + let modelled = device.properties().metal_level >= MetalLevel::MacOS27_0_1; + if modelled { + if let Ok(answer) = device.heap_texture_size_and_align(&private(pvrtc)) { + assert_eq!(kinds(messages), [], "PVRTC"); + assert!(answer.size >= 2048, "PVRTC: {answer:?}: at least Metal's"); + } + } + let unmodelled = [("8 samples", private(eight)), ("PVRTC", private(pvrtc))]; let mut announced = false; - for (what, d) in [("8 samples", private(eight)), ("PVRTC", private(pvrtc))] { + for (what, d) in unmodelled.into_iter().take(if modelled { 1 } else { 2 }) { let Ok(answer) = device.heap_texture_size_and_align(&d) else { println!("UNMODELLED {what}: refused by the device"); continue; @@ -1008,8 +1018,9 @@ fn a_heap_size_past_metal_s_is_announced_once() { /// and stencil textures with `allowGPUOptimizedContents` off, `Depth32Float_Stencil8` ones). The /// device's own answer, where it makes one, is at least Metal's; each pair is printed /// (`METAL-MODEL`), with the count of shapes whose device answer is coarser -/// (every one on NVIDIA). No model answers a PVRTC texture or an 8-sample one (or the device's -/// rules stop it); a texture buffer and a format plain Metal makes no texture of answer as the size +/// (every one on NVIDIA). No model answers an 8-sample texture (or the device's rules stop it), nor +/// a PVRTC one at macOS 26.7's level (at 27.0.1's, Metal's 2048 bytes for 64x64 +/// `PVRTC_RGBA_4BPP`); a texture buffer and a format plain Metal makes no texture of answer as the size /// query does. #[test] fn metal_s_heap_answer_is_the_same_on_every_device() { @@ -1134,7 +1145,8 @@ fn metal_s_heap_answer_is_the_same_on_every_device() { "METAL-MODEL {coarser} of {answered} device answers coarser than Metal's, of {} shapes", rows.len() ); - // No model: a PVRTC texture; an 8-sample one, where the device's rules take it. + // No model: a PVRTC texture at 26.7's level; an 8-sample one, where the device's rules + // take it. let private = |mut d: TextureDescriptor| { d.usage = TextureUsage::SHADER_READ; d.resource_options = ResourceOptions::private(); @@ -1142,7 +1154,10 @@ fn metal_s_heap_answer_is_the_same_on_every_device() { }; let pvrtc = TextureDescriptor::texture_2d(PixelFormat::PVRTCRGBA4BPP, 64, 64, false); let answer = device.metal_heap_texture_size_and_align(&private(pvrtc)); - assert_eq!(answer.ok(), Some(None), "PVRTC"); + let answer = answer.ok().map(|answer| answer.map(|a| (a.size, a.align))); + let pvrtc = + (device.properties().metal_level >= MetalLevel::MacOS27_0_1).then_some((2048, 128)); + assert_eq!(answer, Some(pvrtc), "PVRTC"); let mut eight = TextureDescriptor::texture_2d(PixelFormat::RGBA8Unorm, 64, 64, false); eight.texture_type = TextureType::Type2DMultisample; eight.sample_count = 8; diff --git a/crates/metal2vulkan-validation/src/runtime_lane/heap_textures.rs b/crates/metal2vulkan-validation/src/runtime_lane/heap_textures.rs index dea46b936..cc5d88cea 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/heap_textures.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/heap_textures.rs @@ -25,6 +25,7 @@ //! layout), so the test asserts the change, not the bytes. use super::degrade_notices::counts; +use super::heap_layouts::HEAP_LAYOUTS; use super::heap_metal_sizes::stacked_nil_alignment; use super::host_memory::{gpu_fill, gpu_read, on_device, run}; use super::presenting::Adopted; @@ -276,30 +277,6 @@ fn rgba8(side: u64, options: ResourceOptions) -> TextureDescriptor { descriptor } -/// Metal's answer for `shape` with `allowGPUOptimizedContents` on: its twin's among `shapes`. -fn metal_optimized(shapes: &[Shape], shape: &Shape) -> (u64, u64) { - shapes - .iter() - .find(|twin| { - twin.optimized - && ( - twin.texture_type, - twin.pixel_format, - twin.extent, - twin.usage, - ) == ( - shape.texture_type, - shape.pixel_format, - shape.extent, - shape.usage, - ) - && (twin.array_length, twin.levels, twin.samples) - == (shape.array_length, shape.levels, shape.samples) - }) - .map(|twin| twin.metal) - .unwrap_or_else(|| panic!("{}: no optimized twin", shape.name)) -} - /// A heap of `heap_type`, `size` bytes, and `options`. fn heap(device: &Device, heap_type: HeapType, size: u64, options: ResourceOptions) -> Heap { device @@ -309,8 +286,8 @@ fn heap(device: &Device, heap_type: HeapType, size: u64, options: ResourceOption /// The kinds a heap texture's size answer announces where it is not Metal's: more bytes or a /// coarser alignment than Metal's modelled answer, which its device's image needs; a depth or -/// stencil texture whose driver keeps it GPU-optimized; a shape whose Metal answer the runtime does -/// not model. +/// stencil texture whose driver keeps it GPU-optimized and no shadow of Metal's tiles serves; a +/// shape whose Metal answer the runtime does not model. const SIZE_NOTICES: [Degradation; 3] = [ Degradation::HeapTextureLargerThanMetal, Degradation::OptimizedDepthStencilTexture, @@ -319,7 +296,9 @@ const SIZE_NOTICES: [Degradation; 3] = [ /// The answers for each probe shape, printed beside Metal's, each answered alike twice, a /// power-of-two alignment and a size holding the texels, with `allowGPUOptimizedContents` off the -/// answer for the shape of `PixelFormatView` usage too: Metal's own on MoltenVK. On every device +/// answer for the shape of `PixelFormatView` usage too: Metal's own on MoltenVK (a depth texture's +/// a shadow of Metal's tiles there, `heap_depth_textures_keep_their_texels_in_metal_s_tiles`). On +/// every device /// each answer is Metal's, announcing nothing, or more bytes or a coarser alignment than Metal's /// with one of [`SIZE_NOTICES`] announced for it (the device announces each occurrence). Then the /// placement and automatic heaps' rules. @@ -390,15 +369,22 @@ fn heap_textures_answer_and_place_as_metal_s_do() { // the driver may compress one of `ALIASES`; a depth or stencil texture's image // the driver lays apart from its memory a shadow of the heap's bytes // (`shadowed-texture`, as the heap depth lane measures on MoltenVK) or, where no - // shadow serves it, `heap-depth-stencil-apart`. + // shadow serves it, `heap-depth-stencil-apart`; and one of [`HEAP_LAYOUTS`] for a + // texture whose bytes in the heap the driver is not measured to lay out as Metal's + // (a multisample texture, a depth or stencil one, any on a driver without + // `DriverFact::ColorImagesLieAsMetalHeapTextures`). let facts = &device.properties().driver_facts; let apart = is_depth_stencil(shape.pixel_format) && facts.contains(&DriverFact::DepthStencilImagesLieApart); + let as_metal = shape.samples == 1 + && !is_depth_stencil(shape.pixel_format) + && facts.contains(&DriverFact::ColorImagesLieAsMetalHeapTextures); let routes = facts .contains(&DriverFact::CompressedImagesHideAliasedWrites) .then_some(&ALIASES[..]) .into_iter() .chain(apart.then_some(&DEPTH_STENCIL_ROUTES[..])) + .chain((!as_metal).then_some(&HEAP_LAYOUTS[..])) .flatten(); let allowed: BTreeSet = SIZE_NOTICES.iter().chain(routes).copied().collect(); @@ -418,14 +404,9 @@ fn heap_textures_answer_and_place_as_metal_s_do() { ); // MoltenVK makes a `PixelFormatView` Metal texture of a color texture's image with // `allowGPUOptimizedContents` off, laid out as Metal lays out the texture. A depth or - // stencil texture's it makes optimized (no Vulkan request reaches the property), so its - // answer is Metal's for the texture with it on (`metal_optimized`). - let expected = if shape.optimized || !is_depth_stencil(shape.pixel_format) { - shape.metal - } else { - metal_optimized(&shapes, shape) - }; - if (size, align) != expected { + // stencil texture's it makes optimized (no Vulkan request reaches the property), so + // such a texture is a shadow of Metal's tiles at Metal's answer. + if (size, align) != shape.metal { differ.push(shape.name); } // Metal's answer for the shape announces nothing; any other is past it, with its @@ -1048,9 +1029,11 @@ pub(super) const APART: [Degradation; 1] = [Degradation::HeapDepthStencilApart]; /// The kinds a heap's depth or stencil texture announces where the driver lays such images apart /// from their memory (`DriverFact::DepthStencilImagesLieApart`): its image a shadow of the heap's -/// bytes (one sample, its texels inside its bytes), else laid apart. -const DEPTH_STENCIL_ROUTES: [Degradation; 2] = [ +/// bytes (one sample, its texels inside its bytes; a texture Metal keeps losslessly compressed, a +/// shadow of its uncompressed tiles), else laid apart. +const DEPTH_STENCIL_ROUTES: [Degradation; 3] = [ Degradation::ShadowedTexture, + Degradation::HeapTextureLosslessLayout, Degradation::HeapDepthStencilApart, ]; @@ -1058,14 +1041,16 @@ const DEPTH_STENCIL_ROUTES: [Degradation; 2] = [ /// keeps its layout optimized. pub(super) const OPTIMIZED: [Degradation; 1] = [Degradation::OptimizedDepthStencilTexture]; -/// A depth texture without GPU-optimized contents, sized, made in a placement heap and on the -/// device, announces `optimized-depth-stencil-texture` once where the driver keeps depth and +/// A 4-sample depth texture without GPU-optimized contents, sized, made in a placement heap and on +/// the device, announces `optimized-depth-stencil-texture` once where the driver keeps depth and /// stencil images GPU-optimized (`DriverFact::DepthStencilImagesStayGpuOptimized`: MoltenVK on /// Apple's GPUs), its answer then Metal's with the property on; elsewhere nothing. Made on the /// device first, it announces nothing there: nothing shows a device's own texture's layout. A -/// color texture without them, and a depth texture with them, announce nothing anywhere. +/// single-sample one is a shadow of Metal's tiles there, at Metal's answer (16384 bytes for 64x64 +/// `Depth32Float`, measured on the M3 Max, where it answers 16512 with them), and announces it +/// nowhere; nor do a color texture without them, and a depth texture with them. #[test] -fn a_depth_texture_without_optimized_contents_is_announced_where_it_stays_optimized() { +fn a_multisample_depth_texture_without_optimized_contents_is_announced_where_it_stays_optimized() { let messages = Messages::default(); let cache = ScratchCache::new().unwrap(); let optimized = { @@ -1076,8 +1061,12 @@ fn a_depth_texture_without_optimized_contents_is_announced_where_it_stays_optimi .contains(&DriverFact::DepthStencilImagesStayGpuOptimized); let options = ResourceOptions::private(); let target = TextureUsage::SHADER_READ | TextureUsage::RENDER_TARGET; - let make = |pixel_format, allow| { + let make = |pixel_format, allow, samples| { let mut descriptor = TextureDescriptor::texture_2d(pixel_format, 64, 64, false); + if samples > 1 { + descriptor.texture_type = TextureType::Type2DMultisample; + descriptor.sample_count = samples; + } descriptor.usage = target; descriptor.resource_options = options; descriptor.allow_gpu_optimized_contents = allow; @@ -1087,10 +1076,14 @@ fn a_depth_texture_without_optimized_contents_is_announced_where_it_stays_optimi device.new_texture(&descriptor).unwrap(); answer }; - make(PixelFormat::RGBA8Unorm, false); - let with = make(PixelFormat::Depth32Float, true); + make(PixelFormat::RGBA8Unorm, false, 1); + let with = make(PixelFormat::Depth32Float, true, 1); + let single = make(PixelFormat::Depth32Float, false, 1); + let with_samples = make(PixelFormat::Depth32Float, true, 4); assert!(!counts(&messages.take_notices()).contains_key(&OPTIMIZED[0])); let mut own = TextureDescriptor::texture_2d(PixelFormat::Depth32Float, 64, 64, false); + own.texture_type = TextureType::Type2DMultisample; + own.sample_count = 4; own.usage = target; own.resource_options = options; own.allow_gpu_optimized_contents = false; @@ -1099,13 +1092,15 @@ fn a_depth_texture_without_optimized_contents_is_announced_where_it_stays_optimi !counts(&messages.take_notices()).contains_key(&OPTIMIZED[0]), "a device's own depth texture without optimized contents announced" ); - let without = make(PixelFormat::Depth32Float, false); + let without = make(PixelFormat::Depth32Float, false, 4); eprintln!( - "HEAPTEX optimized depth: {} bytes with, {} without (fact {optimized})", - with.size, without.size + "HEAPTEX optimized depth: {} bytes with, {} without, one sample {} with, {} without \ + (fact {optimized})", + with_samples.size, without.size, with.size, single.size ); if optimized { - assert_eq!(with, without); + assert_eq!(with_samples, without); + assert_eq!((single.size, single.align), (16384, 128)); } optimized }; @@ -1723,6 +1718,390 @@ fn heap_depth_textures_keep_their_bytes_with_their_twins() { ); } +/// A heap's single-sample depth and stencil textures keep their texels where Metal's tiles place +/// them in the heap's bytes (`heap_layouts::tiled_offset`), at Metal's answer, where the driver +/// lays such images apart from their memory or keeps them GPU-optimized +/// (`DriverFact::DepthStencilImagesLieApart`, `DriverFact::DepthStencilImagesStayGpuOptimized`: +/// MoltenVK): a Metal probe on the M3 Max under macOS 27.0.1 found every texel of `Depth16Unorm`, +/// `Depth32Float` and `Stencil8` textures of 16x16, 37x5, 64x64, 100x70 and 300x200 with +/// `allowGPUOptimizedContents` off there, uploaded by a blit naming each texel; and each of a +/// `Depth32Float_Stencil8` texture's in two planes, its depth as a `Depth32Float` texture's at its +/// first byte and its stencil as a `Stencil8` texture's from the `Depth32Float` answer rounded up +/// to 16 KiB (one level and mipmapped, one slice and arrays). Each such texture here, in a +/// `Shared` placement heap, each aspect uploaded so, lies in a buffer over its bytes where the +/// tiles place it, and bytes a blit writes there through the buffer read back through a blit as +/// those texels. With the property on, a 64x64 `Depth32Float` texture (which Metal keeps +/// losslessly compressed, 16512 bytes) holds its uncompressed tiles there, announced +/// `heap-texture-lossless-layout` once. Elsewhere `HEAPTEX tiles` lines print whether they lie so; +/// but an `X32_Stencil8` texture's stencil lies as a `Stencil8` texture's on every device (the +/// probe alike: 8x8 to 300x200, both ways), its image never fitting the `Stencil8` answer. +#[test] +fn heap_depth_textures_keep_their_texels_in_metal_s_tiles() { + use super::heap_layouts::tiled_offset; + use BlitOption::{DepthFromDepthStencil as DEPTH, None as WHOLE, StencilFromDepthStencil}; + let messages = Messages::default(); + let cache = ScratchCache::new().unwrap(); + let tiled = { + let device = &validated_device(TEST_DEVICE, &messages, cache.path()).unwrap(); + let facts = &device.properties().driver_facts; + let tiled = facts.contains(&DriverFact::DepthStencilImagesLieApart) + || facts.contains(&DriverFact::DepthStencilImagesStayGpuOptimized); + let queue = device.new_command_queue().unwrap(); + let options = tracked(StorageMode::Shared); + let ds = PixelFormat::Depth32FloatStencil8; + // Each shape's format, extent, `allowGPUOptimizedContents` and Metal's size (every + // alignment 128), measured, and its aspects: each one's element bytes, blit option and + // first byte from the texture's. + type Aspects = &'static [(u64, BlitOption, u64)]; + let shapes: [(PixelFormat, [u64; 2], bool, u64, Aspects); 14] = [ + ( + PixelFormat::Depth16Unorm, + [37, 5], + false, + 0x400, + &[(2, WHOLE, 0)], + ), + ( + PixelFormat::Depth16Unorm, + [100, 70], + false, + 0x8000, + &[(2, WHOLE, 0)], + ), + ( + PixelFormat::Depth32Float, + [37, 5], + false, + 0x800, + &[(4, WHOLE, 0)], + ), + ( + PixelFormat::Depth32Float, + [64, 64], + false, + 0x4000, + &[(4, WHOLE, 0)], + ), + ( + PixelFormat::Depth32Float, + [100, 70], + false, + 0x10000, + &[(4, WHOLE, 0)], + ), + ( + PixelFormat::Stencil8, + [37, 5], + false, + 0x200, + &[(1, WHOLE, 0)], + ), + ( + PixelFormat::Stencil8, + [100, 70], + false, + 0x4000, + &[(1, WHOLE, 0)], + ), + ( + PixelFormat::Depth32Float, + [64, 64], + true, + 0x4080, + &[(4, WHOLE, 0)], + ), + ( + ds, + [37, 5], + false, + 0x4200, + &[(4, DEPTH, 0), (1, StencilFromDepthStencil, 0x4000)], + ), + ( + ds, + [64, 64], + false, + 0x5000, + &[(4, DEPTH, 0), (1, StencilFromDepthStencil, 0x4000)], + ), + ( + ds, + [100, 70], + false, + 0x14000, + &[(4, DEPTH, 0), (1, StencilFromDepthStencil, 0x10000)], + ), + ( + PixelFormat::X32Stencil8, + [37, 5], + false, + 0x200, + &[(1, WHOLE, 0)], + ), + ( + PixelFormat::X32Stencil8, + [100, 70], + false, + 0x4000, + &[(1, WHOLE, 0)], + ), + ( + PixelFormat::X32Stencil8, + [300, 200], + false, + 0x18000, + &[(1, WHOLE, 0)], + ), + ]; + for (format, [w, h], allow, metal, aspects) in shapes { + let what = format!("{format:?} {w}x{h} allow {allow}"); + let mut descriptor = TextureDescriptor::texture_2d(format, w, h, false); + descriptor.resource_options = options; + // A stencil view's texture is read, its stencil blitted. + let view = format == PixelFormat::X32Stencil8; + descriptor.usage = match view { + true => TextureUsage::SHADER_READ, + false => TextureUsage::SHADER_READ | TextureUsage::RENDER_TARGET, + }; + descriptor.allow_gpu_optimized_contents = allow; + let answer = device.heap_texture_size_and_align(&descriptor).unwrap(); + let heap = heap(device, HeapType::Placement, 1 << 20, options); + let texture = heap.new_texture_at_offset(&descriptor, 0).unwrap(); + let over = heap.new_buffer_at_offset(answer.size, options, 0).unwrap(); + let count = w * h; + let (mut off, mut read_off) = (0, 0); + for &(unit, option, first) in aspects { + // Texel `i`'s element, naming it: a depth of (i + 1) / 2^23 (exact), a 16-bit + // unorm of i + 1, a stencil byte of i + 1. + let element = |i: u64| -> Vec { + match unit { + 4 => ((i + 1) as f32 / (1u32 << 23) as f32) + .to_le_bytes() + .to_vec(), + 2 => ((i + 1) as u16).to_le_bytes().to_vec(), + _ => vec![(i + 1) as u8], + } + }; + let named: Vec = (0..count).flat_map(element).collect(); + let row = w * unit; + let blit = |into: bool, buffer: &Buffer| { + let command_buffer = queue.command_buffer().unwrap(); + let mut blit = command_buffer.blit_command_encoder().unwrap(); + let (origin, size) = (Origin::new(0, 0, 0), Size::new(w, h, 1)); + match into { + true => blit.copy_from_buffer_to_texture( + buffer, + 0, + row, + row * h, + size, + &texture, + 0, + 0, + origin, + option, + ), + false => blit.copy_from_texture_to_buffer( + &texture, + 0, + 0, + origin, + size, + buffer, + 0, + row, + row * h, + option, + ), + } + .unwrap(); + blit.end_encoding().unwrap(); + run(&command_buffer); + }; + gpu_fill(&queue, &over, 0..answer.size, 0xee); + blit(true, &staged(device, &named)); + let bytes = gpu_read(&queue, &over, 0..answer.size); + let at = |i: u64| (first + tiled_offset(unit, [w, h], i % w, i / w)) as usize; + off += (0..count) + .filter(|&i| bytes.get(at(i)..at(i) + unit as usize) != Some(&element(i)[..])) + .count(); + // Bytes written through the buffer where the tiles place each texel, naming it + // backwards, read back through a blit. + let mut backwards = bytes; + for i in 0..count { + let at = at(i); + if let Some(bytes) = backwards.get_mut(at..at + unit as usize) { + bytes.copy_from_slice(&element(count - 1 - i)); + } + } + let source = staged(device, &backwards); + let command_buffer = queue.command_buffer().unwrap(); + let mut copy = command_buffer.blit_command_encoder().unwrap(); + copy.copy_from_buffer_to_buffer(&source, 0, &over, 0, answer.size) + .unwrap(); + copy.end_encoding().unwrap(); + run(&command_buffer); + let read = staged(device, &vec![0; (row * h) as usize]); + blit(false, &read); + let read = read_buffer(&read, 0, row * h).unwrap(); + read_off += (0..count) + .filter(|&i| { + let at = (i * unit) as usize; + read[at..at + unit as usize] != element(count - 1 - i)[..] + }) + .count(); + } + let texels = count * aspects.len() as u64; + eprintln!( + "HEAPTEX tiles {what}: size {} align {}, Metal's {metal} 128; {off} of {texels} \ + texels off Metal's tiles, {read_off} read otherwise from them", + answer.size, answer.align + ); + if tiled { + assert_eq!((answer.size, answer.align), (metal, 128), "{what}"); + } + // A stencil view's image never fits a `Stencil8` texture's answer: on every device a + // shadow of Metal's tiles holds it. + if tiled || view { + assert_eq!((off, read_off), (0, 0), "{what}: texels off Metal's tiles"); + } + } + tiled + }; + let notices = counts(&messages.take_notices()); + let count = |kind| notices.get(&kind).copied().unwrap_or(0); + eprintln!("HEAPTEX tiles: {notices:?}"); + if tiled { + assert_eq!(count(Degradation::HeapTextureLosslessLayout), 1); + assert_eq!(count(Degradation::ShadowedTexture), 1); + assert_eq!(count(OPTIMIZED[0]), 0); + assert_eq!(count(APART[0]), 0); + } + let failing = messages.take(); + assert!( + failing.is_empty(), + "the validation layer reported: {failing:#?}" + ); +} + +/// A heap's colour textures that Metal keeps uncompressed, in a `Private` placement heap over the +/// device's memory, lie where Metal's tiles place each texel (`heap_layouts::tiled_offset`) on a +/// driver whose colour images lie as Metal's heap textures +/// (`DriverFact::ColorImagesLieAsMetalHeapTextures`: MoltenVK 1.4.2 on the M3 Max), and the device +/// announces no heap layout there; elsewhere the first announces `heap-texture-untiled-layout` +/// and each is counted. On every device a texture counted for no layout lies in Metal's tiles. +/// Kept uncompressed by `ShaderRead | ShaderWrite` usage: `RGBA8Unorm` of 64 x 64 and 37 x 5, +/// `R8Unorm` of 100 x 70 and `RG16Float` of 300 x 200; by `allowGPUOptimizedContents` off: +/// `RGBA8Unorm` of 64 x 64 of `ShaderRead` usage and of `ShaderRead | RenderTarget`; by a side +/// shorter than 16: `RGBA8Unorm` of 8 x 8 of `ShaderRead` usage. Each is written by a blit naming +/// each texel and found through a buffer over the heap; `HEAPTEX device-tiles` lines print the +/// texels off the tiles. +#[test] +fn device_heap_textures_lie_in_metal_s_tiles() { + use super::heap_layouts::tiled_offset; + let messages = Messages::default(); + let cache = ScratchCache::new().unwrap(); + let untiled = Degradation::HeapTextureUntiledLayout; + let (as_metal, counted) = { + let device = &validated_device(TEST_DEVICE, &messages, cache.path()).unwrap(); + let as_metal = device + .properties() + .driver_facts + .contains(&DriverFact::ColorImagesLieAsMetalHeapTextures); + let before = device.degraded_objects(untiled).unwrap(); + let queue = device.new_command_queue().unwrap(); + let options = tracked(StorageMode::Private); + let (read, written) = (TextureUsage::SHADER_READ, TextureUsage::SHADER_WRITE); + let shapes = [ + (PixelFormat::RGBA8Unorm, 4, [64, 64], read | written, true), + (PixelFormat::RGBA8Unorm, 4, [37, 5], read | written, true), + (PixelFormat::R8Unorm, 1, [100, 70], read | written, true), + (PixelFormat::RG16Float, 4, [300, 200], read | written, true), + (PixelFormat::RGBA8Unorm, 4, [64, 64], read, false), + ( + PixelFormat::RGBA8Unorm, + 4, + [64, 64], + read | TextureUsage::RENDER_TARGET, + false, + ), + (PixelFormat::RGBA8Unorm, 4, [8, 8], read, true), + ]; + let mut kept = Vec::new(); + for (format, unit, [w, h], usage, optimized) in shapes { + let what = format!("{format:?} {w}x{h} {usage:?} optimized {optimized}"); + let mut descriptor = TextureDescriptor::texture_2d(format, w, h, false); + descriptor.resource_options = options; + descriptor.usage = usage; + descriptor.allow_gpu_optimized_contents = optimized; + let answer = device.heap_texture_size_and_align(&descriptor).unwrap(); + let heap = heap(device, HeapType::Placement, 1 << 20, options); + let made_before = device.degraded_objects(untiled).unwrap(); + let texture = heap.new_texture_at_offset(&descriptor, 0).unwrap(); + let announced = device.degraded_objects(untiled).unwrap() > made_before; + let over = heap.new_buffer_at_offset(answer.size, options, 0).unwrap(); + gpu_fill(&queue, &over, 0..answer.size, 0); + // Texel `i`'s element, naming it: `unit` bytes of `i + 1`. + let element = |i: u64| (i + 1).to_le_bytes()[..unit as usize].to_vec(); + let count = w * h; + let named: Vec = (0..count).flat_map(element).collect(); + let row = w * unit; + let source = staged(device, &named); + let command_buffer = queue.command_buffer().unwrap(); + let mut blit = command_buffer.blit_command_encoder().unwrap(); + blit.copy_from_buffer_to_texture( + &source, + 0, + row, + row * h, + Size::new(w, h, 1), + &texture, + 0, + 0, + Origin::new(0, 0, 0), + BlitOption::None, + ) + .unwrap(); + blit.end_encoding().unwrap(); + run(&command_buffer); + let bytes = gpu_read(&queue, &over, 0..answer.size); + let off = (0..count) + .filter(|&i| { + let at = tiled_offset(unit, [w, h], i % w, i / w) as usize; + bytes.get(at..at + unit as usize) != Some(&element(i)[..]) + }) + .count(); + eprintln!( + "HEAPTEX device-tiles {what}: size {}, {off} of {count} texels off Metal's tiles \ + (fact {as_metal}, announced {announced})", + answer.size + ); + assert_eq!(announced, !as_metal, "{what}: counted untiled"); + if !announced { + assert_eq!(off, 0, "{what}: texels off Metal's tiles"); + } + kept.push((texture, over, heap)); + } + let counted = device.degraded_objects(untiled).unwrap() - before; + drop(kept); + (as_metal, counted) + }; + let notices = counts(&messages.take_notices()); + let layouts: Vec<_> = (notices.iter()) + .filter(|(kind, _)| HEAP_LAYOUTS.contains(kind)) + .collect(); + eprintln!("HEAPTEX device-tiles: {layouts:?}, {counted} counted"); + match as_metal { + true => assert_eq!((layouts.len(), counted), (0, 0)), + false => assert_eq!((layouts, counted), (vec![(&untiled, &1)], 7)), + } + let failing = messages.take(); + assert!( + failing.is_empty(), + "the validation layer reported: {failing:#?}" + ); +} + /// One aspect of a `side`-square depth or stencil texture, read back through a blit with /// `option`: `texel` bytes each. fn aspect_texels( @@ -1764,10 +2143,11 @@ fn aspect_texels( /// under a buffer over its answered bytes filled with zeros, cleared by a pass (depth 0.25, /// stencil 0x5a) that stores them, then the buffer filled with 0x3e. Where the device's driver /// lays depth and stencil images apart from their memory (`DriverFact::DepthStencilImagesLieApart`: -/// MoltenVK), each texture is a shadow of the heap's bytes, in its planes: the pass's clear lands -/// in the depth plane, from the texture's first byte, and in the stencil plane after it at a -/// multiple of 4 bytes, and the fill changes every texel of each aspect read back by a blit -/// (D32_S8's two regions). Elsewhere the texture aliases the heap's memory in the driver's layout, +/// MoltenVK), each texture is a shadow of the heap's bytes, in Metal's tiles: the pass's clear +/// lands in the depth plane, from the texture's first byte, and in the stencil plane, from the +/// texture's first byte or, for `Depth32Float_Stencil8`, from the `Depth32Float` answer rounded up +/// to 16 KiB, and the fill changes every texel of each aspect read back by a blit (D32_S8's two +/// regions). Elsewhere the texture aliases the heap's memory in the driver's layout, /// which Metal's answer for a pass's clear is not measured against, so `HEAPTEX attach` lines print /// the counts only. #[test] @@ -1873,7 +2253,13 @@ fn a_heap_depth_attachment_s_clear_reaches_the_heap_s_bytes() { at = texels * 4; } if stencil { - at = at.next_multiple_of(4); + // The stencil plane past the depth plane's answer, rounded up to 16 KiB. + if depth { + let mut plane = descriptor; + plane.pixel_format = PixelFormat::Depth32Float; + let answer = device.heap_texture_size_and_align(&plane).unwrap(); + at = answer.size.next_multiple_of(16 << 10) as usize; + } assert!( bytes[at..at + texels].iter().all(|&t| t == 0x5a), "{what}: the stencil plane does not hold the clear" diff --git a/crates/metal2vulkan-validation/src/runtime_lane/no_copy_heaps.rs b/crates/metal2vulkan-validation/src/runtime_lane/no_copy_heaps.rs index 913b9fb10..2da7a3ab9 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/no_copy_heaps.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/no_copy_heaps.rs @@ -15,7 +15,9 @@ //! the texture to imported host memory, the texture is a shadow of the heap's bytes, announced //! once (`shadowed-texture`), whose texels lie in the bytes level by level, rows packed, or, //! for a texture Metal keeps uncompressed, in Metal's tiles (`heap_layouts`): there the bytes are -//! asserted exactly. `NOCOPYHEAP` lines print each texture's route. +//! asserted exactly. One Metal keeps losslessly compressed (`heap-texture-lossless-layout`), +//! whose bytes on Metal are no layout of its texels, lies rows packed or in the tiles Metal lays +//! it in uncompressed. `NOCOPYHEAP` lines print each texture's route. //! - **Refusals.** Storage other than `Shared`, a sparse heap and a size of 0 are `Invalid`, as //! is memory whose first byte is off the import's unit //! (`HeapProblem::HostMemoryAlignment`); each refused call drops its deallocator unrun. A @@ -341,7 +343,8 @@ fn same_texels(after: &[u8], before: &[u8], bytes: u64) -> usize { fn texture_round_trip(pf: PixelFormat, side: u64, bytes: u64, offset: u64) -> Option { let what = format!("{pf:?} {side}x{side} at {offset}"); // Whether the heap made the texture, and whether its texels lay in the caller's bytes rows - // packed from its offset, or in Metal's tiles there where the runtime counts it tiled. + // packed from its offset, or in Metal's tiles there where the runtime counts it tiled (either + // where it counts it laid out losslessly: Metal's bytes are no layout of its texels). let (mut made, mut laid) = (false, false); let shadows = on_device(Degradation::ShadowedTexture, |device| { let queue = device.new_command_queue().unwrap(); @@ -360,6 +363,8 @@ fn texture_round_trip(pf: PixelFormat, side: u64, bytes: u64, offset: u64) -> Op TextureUsage::SHADER_READ | TextureUsage::SHADER_WRITE }; let tiled_before = device.work_counts().heap_textures_tiled; + let lossless = Degradation::HeapTextureLosslessLayout; + let lossless_before = device.degraded_objects(lossless).unwrap(); let texture = match heap.new_texture_at_offset(&descriptor, offset) { Ok(texture) => texture, Err(error @ Error::NotImplemented(RuntimeGap::HeapTextureMemory)) => { @@ -370,6 +375,7 @@ fn texture_round_trip(pf: PixelFormat, side: u64, bytes: u64, offset: u64) -> Op }; made = true; let tiled = device.work_counts().heap_textures_tiled - tiled_before == 1; + let lossless = device.degraded_objects(lossless).unwrap() - lossless_before == 1; assert_eq!(texture.heap_offset(), offset); let size = device .heap_texture_size_and_align(&descriptor) @@ -443,7 +449,7 @@ fn texture_round_trip(pf: PixelFormat, side: u64, bytes: u64, offset: u64) -> Op third, "{what}" ); - laid = if tiled { + let in_tiles = || { let n = bytes as usize; (0..side).all(|y| { (0..side).all(|x| { @@ -452,19 +458,23 @@ fn texture_round_trip(pf: PixelFormat, side: u64, bytes: u64, offset: u64) -> Op mapping.read(at..at + n) == third[from..from + n] }) }) - } else { - mapping.read(start..start + len) == third + }; + let in_rows = || mapping.read(start..start + len) == third; + laid = match (tiled, lossless) { + (true, _) => in_tiles(), + (false, true) => in_rows() || in_tiles(), + (false, false) => in_rows(), }; eprintln!( "NOCOPYHEAP {what}: size {size}, {changed} bytes changed by the texture's write, \ - texels laid at the offset (tiled {tiled}): {laid}" + texels laid at the offset (tiled {tiled}, lossless {lossless}): {laid}" ); drop((texture, buffer, heap)); drop(mapping); }); eprintln!("NOCOPYHEAP {what}: {shadows} shadowed-texture notices"); // A shadow's texels are the heap's bytes, rows packed from the texture's offset or in Metal's - // tiles there. + // tiles there (uncompressed, for a texture Metal keeps compressed). assert!( shadows == 0 || laid, "{what}: a shadow's texels lie elsewhere" @@ -486,7 +496,8 @@ fn a_no_copy_heap_s_texture_and_buffer_alias_both_ways() { /// A no-copy heap's depth texture aliases as its colour textures do: where the device binds no /// depth image to imported host memory (every device measured), a shadow of the heap's bytes, -/// announced once. +/// announced once. Metal keeps it losslessly compressed (`allowGPUOptimizedContents` on), so its +/// texels lie rows packed or in Metal's uncompressed tiles. #[test] fn a_no_copy_heap_s_depth_texture_aliases_both_ways() { if let Some(shadow) = texture_round_trip(PixelFormat::Depth16Unorm, 32, 2, 0) { diff --git a/crates/metal2vulkan-validation/src/runtime_lane/texture_fills.rs b/crates/metal2vulkan-validation/src/runtime_lane/texture_fills.rs index 68431d6ff..5fb98296b 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/texture_fills.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/texture_fills.rs @@ -566,15 +566,7 @@ fn texture_fills_write_metal_s_bytes() { // uploads into a depth image (the twin's texture holds its texels in colour), what // a float depth's may store, and the combined format's clamp; the `Shared` buffers. let pf = format(raw); - let shapes: Vec = CASES - .iter() - .map(|name| { - let case = case(raw, name, false); - !case.array && case.levels == 1 - }) - .collect(); - let one_level = shapes.iter().any(|&one| one); - let every_one_level = shapes.iter().all(|&one| one); + let mipmapped = CASES.iter().any(|name| case(raw, name, false).levels > 1); let twin = pf == PixelFormat::Depth32Float && twins_depth(device); let combined = pf == PixelFormat::Depth32FloatStencil8; let depth_image = combined || (pf == PixelFormat::Depth32Float && !twin); @@ -605,13 +597,10 @@ fn texture_fills_write_metal_s_bytes() { Degradation::SharedInSystemMemory, shared_in_system_memory(device), ), - // A two-plane format's cases lie in a heap: a 2D texture of one level a shadow of - // its planes in the heap's bytes, any other apart from them. - (Degradation::ShadowedTexture, heap > 0 && one_level), - ( - Degradation::HeapTwoPlaneTexture, - heap > 0 && !every_one_level, - ), + // A two-plane format's cases lie in a heap, a shadow of their first level's + // planes in the heap's bytes; a mipmapped one's later levels apart from them. + (Degradation::ShadowedTexture, heap > 0), + (Degradation::HeapTwoPlaneLayout, heap > 0 && mipmapped), ]); let announced = assert_made_once(messages, kinds, &first); let clamped = announced.contains_key(&Degradation::RestrictedDepthUpload); diff --git a/crates/metal2vulkan/src/device/driver_facts.rs b/crates/metal2vulkan/src/device/driver_facts.rs index 229c923d5..e2a4adfa3 100644 --- a/crates/metal2vulkan/src/device/driver_facts.rs +++ b/crates/metal2vulkan/src/device/driver_facts.rs @@ -1649,6 +1649,14 @@ pub enum DriverFact { /// shader's writes to its reads and writes, which RADV on the Radeon 780M needs (a later draw /// read texels from before an earlier one's writes without it). InterlockOrdersDraws, + /// A single-sample colour image bound to memory lies in it as Metal lays out a heap texture + /// of the image's usage there: a buffer over the memory meets each texel at the byte Metal's + /// tiles place it. Vulkan leaves an optimal image's layout to the driver. On a driver without + /// it the runtime announces `heap-texture-untiled-layout` for a texture of a heap over the + /// device's memory whose image lies in the heap's bytes (`texture/heap.rs`); on one with it, + /// only where Metal's layout is not the image's (a texture Metal may keep losslessly + /// compressed, `heap-texture-lossless-layout`; a multisample one, a layout not measured). + ColorImagesLieAsMetalHeapTextures, } impl DriverFact { @@ -2129,6 +2137,17 @@ const DYNAMIC_RESTART_WARNING: DriverDiagnostic = DriverDiagnostic { /// leaves 19 of the second's 495 bands wrong. Every other driver is unmeasured, and takes the /// barrier. /// +/// `ColorImagesLieAsMetalHeapTextures`, measured by +/// `runtime_lane::heap_textures::device_heap_textures_lie_in_metal_s_tiles` (textures Metal keeps +/// uncompressed in a `Private` placement heap: `RGBA8Unorm`, `R8Unorm` and `RG16Float` ones of +/// `ShaderRead | ShaderWrite` usage of 64 x 64, 37 x 5, 100 x 70 and 300 x 200 texels, +/// `RGBA8Unorm` ones of 64 x 64 of `ShaderRead` and `ShaderRead | RenderTarget` usage with +/// `allowGPUOptimizedContents` off, and one of 8 x 8 of `ShaderRead` usage; written by blits +/// naming each texel, found through a buffer over the heap): MoltenVK 1.4.2 on the M3 Max under +/// macOS 27.0.1, every texel at the byte Metal's tiles place it (the lane's restatement of the +/// tiled layout measured on Metal's own heap textures there, `heap_layouts::tiled_offset`). It +/// decides a notice, not an answer, so the M4 is not measured. Every other driver is unmeasured. +/// /// MoltenVK 1.4.2 on the M3 Max under macOS 27.0.1 ([`moltenvk_142`]; 2026-10-21, the runtime /// lanes in release builds under `--cfg m2v_gpu`, each fact taken): /// - Measured by the lane that measured its 1.4.1 row, which passed: `DepthImageKeepsDenormals` @@ -2752,6 +2771,7 @@ pub(crate) const MEASURED: &[Measured] = &[ moltenvk_142(DriverFact::Bc6hBlockDecodeIsMetals), moltenvk_142(DriverFact::Bc7BlockDecodeIsMetals), moltenvk_142(DriverFact::TileStoreIsMetals), + moltenvk_142(DriverFact::ColorImagesLieAsMetalHeapTextures), ]; /// Intel's `vendorID`. diff --git a/crates/metal2vulkan/tests/air_input/xr_two_plane_arrays.txt b/crates/metal2vulkan/tests/air_input/xr_two_plane_arrays.txt new file mode 100644 index 000000000..6c8aef2d1 --- /dev/null +++ b/crates/metal2vulkan/tests/air_input/xr_two_plane_arrays.txt @@ -0,0 +1,156 @@ +target triple = "air64_v28-apple-macosx26.0.0" +source_filename = "-" +; datalayout DataLayout { endian: Little, pointers: {0: PointerSpec { size_bits: 64, abi_bits: 64, pref_bits: 64, index_bits: 64 }}, ints: {1: AlignSpec { abi_bits: 8, pref_bits: 8 }, 8: AlignSpec { abi_bits: 8, pref_bits: 8 }, 16: AlignSpec { abi_bits: 16, pref_bits: 16 }, 32: AlignSpec { abi_bits: 32, pref_bits: 32 }, 64: AlignSpec { abi_bits: 64, pref_bits: 64 }}, floats: {16: AlignSpec { abi_bits: 16, pref_bits: 16 }, 32: AlignSpec { abi_bits: 32, pref_bits: 32 }, 64: AlignSpec { abi_bits: 64, pref_bits: 64 }, 128: AlignSpec { abi_bits: 128, pref_bits: 128 }}, vectors: {16: AlignSpec { abi_bits: 16, pref_bits: 16 }, 24: AlignSpec { abi_bits: 32, pref_bits: 32 }, 32: AlignSpec { abi_bits: 32, pref_bits: 32 }, 48: AlignSpec { abi_bits: 64, pref_bits: 64 }, 64: AlignSpec { abi_bits: 64, pref_bits: 64 }, 96: AlignSpec { abi_bits: 128, pref_bits: 128 }, 128: AlignSpec { abi_bits: 128, pref_bits: 128 }, 192: AlignSpec { abi_bits: 256, pref_bits: 256 }, 256: AlignSpec { abi_bits: 256, pref_bits: 256 }, 512: AlignSpec { abi_bits: 512, pref_bits: 512 }, 1024: AlignSpec { abi_bits: 1024, pref_bits: 1024 }}, aggregate: AlignSpec { abi_bits: 0, pref_bits: 64 }, native_ints: [8, 16, 32], stack_align_bits: None, alloca_space: 0, program_space: 0, globals_space: 0, mangling: None, fn_ptr_align: None, non_integral: [] } +%t6 = type void (ptr addrspace(1), ptr addrspace(1), ptr addrspace(2), <2 x i32>) +%t9 = type void (ptr addrspace(1), <2 x i32>, i32, <4 x float>, i32, i32) +%t10 = type ptr addrspace(2) () +%t12 = type { <4 x float>, i8 } +%t13 = type %t12 (ptr addrspace(1), ptr addrspace(2), <2 x i32>, i32, <2 x i32>, i32, i32) +%t15 = type [2 x i32] +%t17 = type { i32, i32 } ; "struct.Slice" +c8 = %t15 [27, 0] + +define %t6 @f0 "xr2pa_write_float" "approx-func-fp-math"="true" "frame-pointer"="all" "min-legal-vector-width"="128" "no-builtins"="" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" %a1( Ref nocapture "air-buffer-no-alias"="" ) %a2( align 4 dereferenceable(8) Ref nocapture "air-buffer-no-alias"="" ) { +bb0: + %i0 = extractelement %a3, i64 1 + %i1 = getelementptr inbounds %t17, %a2, i64 0, i32 0 + %i2 = load i32, %i1, align 4 + %i3 = mul i32 %i2, %i0 + %i4 = extractelement %a3, i64 0 + %i5 = add i32 %i3, %i4 + %i6 = zext %i5 to i64 + %i7 = getelementptr inbounds <4 x float>, %a1, %i6 + %i8 = load <4 x float>, %i7, align 16 + %i9 = getelementptr inbounds %t17, %a2, i64 0, i32 1 + %i10 = load i32, %i9, align 4 + tail call void @f2 [air Texture(Texture { op: Write, image: ImageShape { dim: D2, array: true, ms: false, depth: false }, texel: Some(Texel { ty: NumTy { elem: F32, lanes: 4 }, sign: None }), coord16: false, form: Current, access: Some(Write) })](%a0, %a3, %i10, %i8, i32 0, i32 2) arg0( nocapture ) + ret void +} + +define %t6 @f1 "xr2pa_read_float" "approx-func-fp-math"="true" "frame-pointer"="all" "min-legal-vector-width"="128" "no-builtins"="" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" %a0( Ref nocapture ) %a1( Mod nocapture "air-buffer-no-alias"="" ) %a2( align 4 dereferenceable(8) Ref nocapture "air-buffer-no-alias"="" ) { +bb0: + %i0 = getelementptr inbounds %t17, %a2, i64 0, i32 1 + %i1 = load i32, %i0, align 4 + %i2 = tail call ptr addrspace(2) @f3 [air Sampler(GetReadSampler)]() + %i3 = tail call %t12 @f4 [air Texture(Texture { op: Read, image: ImageShape { dim: D2, array: true, ms: false, depth: false }, texel: Some(Texel { ty: NumTy { elem: F32, lanes: 4 }, sign: None }), coord16: false, form: Current, access: Some(Read) })](%a0, %i2, %a3, %i1, <2 x i32> zeroinitializer, i32 0, i32 1) arg0( Ref nocapture ) + %i4 = extractvalue <4 x float> %i3, 0 + %i5 = extractelement %a3, i64 1 + %i6 = getelementptr inbounds %t17, %a2, i64 0, i32 0 + %i7 = load i32, %i6, align 4 + %i8 = mul i32 %i7, %i5 + %i9 = extractelement %a3, i64 0 + %i10 = add i32 %i8, %i9 + %i11 = zext %i10 to i64 + %i12 = getelementptr inbounds <4 x float>, %a1, %i11 + store %i4, %i12, align 16 + ret void +} + +declare %t9 @f2 "air.write_texture_2d_array.v4f32" memory(ModRef, NoModRef, NoModRef) %a0( nocapture ) + +declare %t10 @f3 "air.get_read_sampler" memory(NoModRef, Ref, NoModRef) + +declare %t13 @f4 "air.read_texture_2d_array.v4f32" memory(Ref, NoModRef, NoModRef) %a0( Ref nocapture ) +!md0 = !"SDK Version" +!md1 = !"wchar_size" +!md2 = !"frame-pointer" +!md3 = !"air.max_device_buffers" +!md4 = !"air.max_constant_buffers" +!md5 = !"air.max_threadgroup_buffers" +!md6 = !"air.max_textures" +!md7 = !"air.max_read_write_textures" +!md8 = !"air.max_samplers" +!md9 = !"air.texture" +!md10 = !"air.location_index" +!md11 = !"air.write" +!md12 = !"air.arg_type_name" +!md13 = !"texture2d_array" +!md14 = !"air.arg_name" +!md15 = !"t" +!md16 = !"air.buffer" +!md17 = !"air.read" +!md18 = !"air.address_space" +!md19 = !"air.arg_type_size" +!md20 = !"air.arg_type_align_size" +!md21 = !"float4" +!md22 = !"in" +!md23 = !"air.buffer_size" +!md24 = !"air.struct_type_info" +!md25 = !"uint" +!md26 = !"w" +!md27 = !"slice" +!md28 = !"Slice" +!md29 = !"s" +!md30 = !"air.thread_position_in_grid" +!md31 = !"uint2" +!md32 = !"g" +!md33 = !"texture2d_array" +!md34 = !"air.read_write" +!md35 = !"out" +!md36 = !"air.compile.denorms_disable" +!md37 = !"air.compile.fast_math_enable" +!md38 = !"air.compile.framebuffer_fetch_enable" +!md39 = !"Apple metal version 32023.921 (metalfe-32023.921.6)" +!md40 = !"Metal" +!md41 = !"_ZTS5Slice" +!md42 = !"int" +!md43 = !"omnipotent char" +!md44 = !"Simple C++ TBAA" +!md45 = !"air-alias-scope-arg(2)" +!md46 = !"air-alias-scope-arg(1)" +!md47 = !"air-alias-scope-textures" +!md48 = i32 2 +!md49 = %t15 c8 +!md50 = i32 1 +!md51 = i32 4 +!md52 = i32 7 +!md53 = i32 31 +!md54 = i32 128 +!md55 = i32 8 +!md56 = i32 16 +!md57 = ptr addrspace(0) @f0 +!md58 = i32 0 +!md59 = i32 3 +!md60 = ptr addrspace(0) @f1 +!md61 = i64 0 +!md62 = i64 4 +!md63 = !{!md48, !md0, !md49} +!md64 = !{!md50, !md1, !md51} +!md65 = !{!md52, !md2, !md48} +!md66 = !{!md52, !md3, !md53} +!md67 = !{!md52, !md4, !md53} +!md68 = !{!md52, !md5, !md53} +!md69 = !{!md52, !md6, !md54} +!md70 = !{!md52, !md7, !md55} +!md71 = !{!md52, !md8, !md56} +!md72 = !{} +!md73 = !{!md58, !md9, !md10, !md58, !md50, !md11, !md12, !md13, !md14, !md15} +!md74 = !{!md50, !md16, !md10, !md58, !md50, !md17, !md18, !md50, !md19, !md56, !md20, !md56, !md12, !md21, !md14, !md22} +!md75 = !{!md58, !md51, !md58, !md25, !md26, !md51, !md51, !md58, !md25, !md27} +!md76 = !{!md48, !md16, !md23, !md55, !md10, !md50, !md50, !md17, !md18, !md48, !md24, !md75, !md19, !md55, !md20, !md51, !md12, !md28, !md14, !md29} +!md77 = !{!md59, !md30, !md12, !md31, !md14, !md32} +!md78 = !{!md73, !md74, !md76, !md77} +!md79 = !{!md57, !md72, !md78} +!md80 = !{!md58, !md9, !md10, !md58, !md50, !md17, !md12, !md33, !md14, !md15} +!md81 = !{!md50, !md16, !md10, !md58, !md50, !md34, !md18, !md50, !md19, !md56, !md20, !md56, !md12, !md21, !md14, !md35} +!md82 = !{!md80, !md81, !md76, !md77} +!md83 = !{!md60, !md72, !md82} +!md84 = !{!md36} +!md85 = !{!md37} +!md86 = !{!md38} +!md87 = !{!md39} +!md88 = !{!md48, !md55, !md58} +!md89 = !{!md40, !md51, !md58, !md58} +!md90 = !{!md44} +!md91 = !{!md43, !md90, !md61} +!md92 = !{!md42, !md91, !md61} +!md93 = !{!md41, !md92, !md61, !md92, !md62} +!md94 = !{!md93, !md92, !md61} +!md95 = !{!md91, !md91, !md61} +!md96 = !{!md93, !md92, !md62} +!"llvm.module.flags" = !{!md63, !md64, !md65, !md66, !md67, !md68, !md69, !md70, !md71} +!"air.kernel" = !{!md79, !md83} +!"air.compile_options" = !{!md84, !md85, !md86} +!"llvm.ident" = !{!md87} +!"air.version" = !{!md88} +!"air.language_version" = !{!md89} diff --git a/crates/metal2vulkan/tests/public_fixture_expectations_engine.tsv b/crates/metal2vulkan/tests/public_fixture_expectations_engine.tsv index fadc9cabe..fe1193fef 100644 --- a/crates/metal2vulkan/tests/public_fixture_expectations_engine.tsv +++ b/crates/metal2vulkan/tests/public_fixture_expectations_engine.tsv @@ -2487,6 +2487,10 @@ engine/xr_samples.ll xr_sample_runtime ok ok ok ok ok ok ok ok ok ok ok ok ok ok engine/xr_samples.ll xr_sample_runtime_half ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok engine/xr_samples.ll xr_sample_constexpr ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok engine/xr_samples.ll xr_sample_constexpr_half ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok +engine/xr_two_plane_arrays.air.ll xr2pa_write_float ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok NeedsInput{StorageTextureFormat { slot: SlotRef { stage: Kernel, class: Texture, index: 0 } }} ok NeedsInput{StorageTextureFormat { slot: SlotRef { stage: Kernel, class: Texture, index: 0 } }} +engine/xr_two_plane_arrays.air.ll xr2pa_read_float ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok +engine/xr_two_plane_arrays.ll xr2pa_write_float ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok NeedsInput{StorageTextureFormat { slot: SlotRef { stage: Kernel, class: Texture, index: 0 } }} ok NeedsInput{StorageTextureFormat { slot: SlotRef { stage: Kernel, class: Texture, index: 0 } }} +engine/xr_two_plane_arrays.ll xr2pa_read_float ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok engine/xr_two_planes.air.ll xr2p_write_half ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok NeedsInput{StorageTextureFormat { slot: SlotRef { stage: Kernel, class: Texture, index: 0 } }} ok NeedsInput{StorageTextureFormat { slot: SlotRef { stage: Kernel, class: Texture, index: 0 } }} engine/xr_two_planes.air.ll xr2p_write_float ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok NeedsInput{StorageTextureFormat { slot: SlotRef { stage: Kernel, class: Texture, index: 0 } }} ok NeedsInput{StorageTextureFormat { slot: SlotRef { stage: Kernel, class: Texture, index: 0 } }} engine/xr_two_planes.air.ll xr2p_read_half ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok diff --git a/docs/API.md b/docs/API.md index 72b1f15a7..525710577 100644 --- a/docs/API.md +++ b/docs/API.md @@ -1655,12 +1655,12 @@ fast forms record, and each `PrecisionNote`'s rustdoc states its bound. - `metal2vulkan-degrade-optimized-depth-stencil-texture` (precision). `OptimizedDepthStencilTexture`: A depth or stencil texture with `allowGPUOptimizedContents` off sized or made in a heap (never a device's own texture, whose layout nothing shows), on a device - whose driver keeps depth and stencil images GPU-optimized whatever their create info: Metal lays - the texture out without its compression metadata, and the runtime's image keeps it. Cost: the - texture keeps its GPU-optimized layout: heap_texture_size_and_align answers Metal's size for the - texture with the property on, larger than Metal's with it off (16512 bytes for a 64x64 - Depth32Float texture, where Metal answers 16384), so a heap sized by Metal's answers holds fewer - such textures. + whose driver keeps depth and stencil images GPU-optimized whatever their create info, that no + shadow of Metal's tiles in the heap's bytes serves (a multisample texture, a depth twin, a format + whose layout is not measured): Metal lays the texture out without its compression metadata, and + the runtime's image keeps it. Cost: the texture keeps its GPU-optimized layout: + heap_texture_size_and_align answers Metal's size for the texture with the property on, larger + than Metal's with it off, so a heap sized by Metal's answers holds fewer such textures. - `metal2vulkan-degrade-narrow-surface-rows` (precision). `NarrowSurfaceRows`: A texture of an IOSurface plane of more than one row under 16 bytes a row: Metal's GPU writes its rows 16 bytes apart and reads every row past the first as memory-dependent bytes (zeros in a fresh process; @@ -1760,13 +1760,25 @@ fast forms record, and each `PrecisionNote`'s rustdoc states its bound. the texture's texels. Cost: its texels are copied into an image of its own before each command that binds it beyond its declared usage, and back after each write through it. - `metal2vulkan-degrade-heap-two-plane-texture` (precision). `HeapTwoPlaneTexture`: A texture of - `RGB10A8_2P_XR10` or its sRGB twin made in a heap other than a 2D texture of one level, whose - planes the heap's bytes keep: its one image holds each texel's colour word and alpha byte side by - side, more than Metal's two planes take in the heap, so it lies in memory of its own. Cost: the - texture's size and alignment answers are Metal's and its reads, writes and copies as outside a - heap, but its texels lie in memory of its own, apart from the heap's bytes: a buffer or texture - over its range of the heap neither sees nor changes them, where Metal's texture keeps its two - planes there. + `RGB10A8_2P_XR10` or its sRGB twin made in a heap whose planes no shadow of the heap's bytes + holds: a 3D texture of more than one depth slice (Metal's writes lay its depth slices over one + another), or one whose moves pass the device's limits. Its one image holds each texel's colour + word and alpha byte side by side, more than Metal's two planes take in the heap, so it lies in + memory of its own. Cost: the texture's size and alignment answers are Metal's and its reads, + writes and copies as outside a heap, but its texels lie in memory of its own, apart from the + heap's bytes: a buffer or texture over its range of the heap neither sees nor changes them, where + Metal's texture keeps its two planes there. +- `metal2vulkan-degrade-heap-two-plane-layout` (precision). `HeapTwoPlaneLayout`: A texture of + `RGB10A8_2P_XR10` or its sRGB twin made in a heap whose first level's planes lie in the heap's + bytes, of more than one level, or a 1D array: Metal's paths address the texture's levels past the + first at bytes that differ by path (its CPU copies at its first level's rows from past that level, + its blits and an array's GPU writes over the first level's bytes, a 2D texture's GPU writes + nowhere, its GPU reads at other bytes again), and a 1D array's GPU reads every texel at the + texture's first word. The runtime keeps the first level's slices in the heap's bytes, as Metal's + CPU copies and GPU writes lay them, and the other levels in the texture's image alone. Cost: the + first level's texels lie in the heap's bytes as Metal's CPU copies and GPU writes lay them, and + read as written; the later levels' texels lie apart from the heap's bytes, and a 1D array's GPU + reads read each texel, where Metal's paths address those texels at bytes that differ by path. - `metal2vulkan-degrade-moltenvk-argument-buffers-unread` (precision). `MoltenVkArgumentBuffersUnread`: A MoltenVK device at a release whose `pipelineCacheUUID` layout the runtime has not read: whether MoltenVK binds through Metal argument buffers is unknown, so a @@ -1935,9 +1947,12 @@ fast forms record, and each `PrecisionNote`'s rustdoc states its bound. released a map of one or more layers. Cost: the draws write nothing, where Metal draws rows of the pass (a 64-pixel map's rows 0 to 15, at the positions of a pass with no map). - `metal2vulkan-degrade-heap-texture-lossless-layout` (precision). `HeapTextureLosslessLayout`: A - texture made in a heap over host pages (`new_heap_with_bytes_no_copy`) that Metal keeps losslessly - compressed: its bytes on Metal are no layout of its texels, so the runtime lays them out as its - own. Cost: the texture's reads, writes and copies are Metal's, but its bytes in the heap are not + texture made in a heap over host pages (`new_heap_with_bytes_no_copy`), or a depth or stencil + texture made in any heap as a shadow of Metal's tiles (on a driver that lays such images apart from + their memory or keeps them GPU-optimized: MoltenVK), that Metal keeps losslessly compressed: its + bytes on Metal are no layout of its texels, so the runtime lays them out as its own, its + uncompressed tiles where it tiles them. Also such a texture whose image lies in a heap over the + device's memory: the image, of the runtime's usage, need not be compressed as Metal's. Cost: the texture's reads, writes and copies are Metal's, but its bytes in the heap are not Metal's compressed bytes (a single-sample texture's texels in the runtime's layout; a multisample texture's image lies in memory of its own, the heap's bytes keeping what they held): a buffer or texture over them reads and writes other bytes than Metal's would. @@ -1946,18 +1961,22 @@ fast forms record, and each `PrecisionNote`'s rustdoc states its bound. host pages whose placement the device's Metal level does not measure: Metal places a format family's blocks in each level by a rule that differs by family and by release, measured for BC, ETC2, EAC and ASTC under macOS 27.0.1 (an Apple M3 Max and an Apple M4 alike) and 26.7 (an - Apple M3 Max), where those lie as Metal lays them out, and not for PVRTC at any level, whose - blocks lie in the runtime's layout. Cost: the texture's + Apple M3 Max), and for PVRTC under 27.0.1 (an Apple M3 Max), where those lie as Metal lays them + out, and not for PVRTC under 26.7, whose blocks lie 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. - `metal2vulkan-degrade-heap-texture-untiled-layout` (precision). `HeapTextureUntiledLayout`: A texture made in a heap over host pages that Metal lays out tiled where the runtime does not: a - layout not measured (a two-aspect depth and stencil format, a PVRTC format), an image that holds - other bytes than Metal's elements, or moves past the device's limits. Cost: the texture's reads, - writes and copies are Metal's, but its texels lie in the heap's bytes in the runtime's layout, - where Metal tiles them: a buffer or texture over them meets the texels at other bytes than on - Metal. + layout not measured (a format whose layout in Metal's heaps is not probed), an image that holds + other bytes than Metal's elements, or moves past the device's limits. Also a texture made in any + other heap (over the device's memory) whose bytes there are not Metal's layout: its image bound + there in the driver's layout, on a driver whose colour images are not measured to lie as Metal's + heap textures (`DriverFact::ColorImagesLieAsMetalHeapTextures`) or of a depth or stencil texture + there; its image a shadow of the bytes in rows; a multisample texture; or a layout not measured. + Cost: the texture's reads, writes and copies are Metal's, but its texels lie in the heap's bytes + in the runtime's layout, where Metal tiles them: a buffer or texture over them meets the texels at + other bytes than on Metal. - `metal2vulkan-degrade-shader-side-depth-test` (performance). `ShaderSideDepthTest`: A render pass's draws test the depth in the fragment shader: a fragment function that stores a color through the pixel interlock before Vulkan's tests, in a draw whose depth test may drop the diff --git a/docs/REFUSALS.md b/docs/REFUSALS.md index d66a04d1b..b508eaaf2 100644 --- a/docs/REFUSALS.md +++ b/docs/REFUSALS.md @@ -14,15 +14,15 @@ Columns: - `none`: no public API path: malformed or non-Metal input, Apple-private calls, or a cap no valid program of ordinary size meets; - `?`: not assessed yet. -Generated at `6b9a3b33d`. +Generated at `ab403459b`. ## Totals | Kind | Variants | With a site | Reach system | Reach app | Reach rare | Reach none | Unassessed | |---|---|---|---|---|---|---|---| | Translator and front-end refusals | 125 | 125 | 6 | 33 | 68 | 18 | 0 | -| Runtime gaps | 68 | 68 | 1 | 8 | 41 | 18 | 0 | -| Apple-only calls | 8 | 8 | 0 | 0 | 0 | 8 | 0 | +| Runtime gaps | 67 | 67 | 1 | 8 | 41 | 17 | 0 | +| Apple-only calls | 9 | 9 | 1 | 0 | 0 | 8 | 0 | | Binder refusals at a device limit | 9 | 9 | 0 | 1 | 7 | 1 | 0 | | Translation caps | 14 | 14 | 0 | 0 | 7 | 7 | 0 | | Rate maps the compile layer does not compile | 5 | 5 | 0 | 0 | 4 | 1 | 0 | @@ -53,7 +53,7 @@ Generated at `6b9a3b33d`. | `QuadOperations` | Quad operations in a stage without quad support | devices without VkLimit::MinSubgroupSize; devices without VkProperty::SubgroupQuadOperationsInAllStages | 2: `crates/metal2vulkan/src/device/subgroup.rs:371`, `crates/metal2vulkan/src/device/subgroup.rs:405` | `app`: quad shuffles in kernels on devices without quad operations there | | `SimdgroupMatrix` | Simdgroup matrix operations | every device (not implemented) | 1: `crates/metal2vulkan/src/lower/simd/matrix.rs:83` | `rare`: simdgroup matrix kernels | | `ArgumentBufferPointers` | Argument buffers holding buffer pointers (dynamic roots) | devices without buffer device addresses (`addressed_needs`) | 1: `crates/metal2vulkan/src/device/metal.rs:236` | `app`: argument buffers holding buffer pointers | -| `ArgumentBufferTextures` | Argument buffers holding textures or samplers (handle domain) | devices short of a device limit the site names; devices without a capability the site computes (`gaps`); devices without a capability the site computes (`missing`); devices without a capability the site computes (`needs`); every device (not implemented) | 17: `crates/metal2vulkan-runtime/src/families/features.rs:1630`, `crates/metal2vulkan-runtime/src/pipeline/objects.rs:1036` (+15) | `app`: argument buffers holding textures and samplers (bindless) | +| `ArgumentBufferTextures` | Argument buffers holding textures or samplers (handle domain) | devices short of a device limit the site names; devices without a capability the site computes (`gaps`); devices without a capability the site computes (`missing`); devices without a capability the site computes (`needs`); every device (not implemented) | 17: `crates/metal2vulkan-runtime/src/families/features.rs:1621`, `crates/metal2vulkan-runtime/src/pipeline/objects.rs:1036` (+15) | `app`: argument buffers holding textures and samplers (bindless) | | `ArgumentBufferObjects` | Argument-buffer members that are pipeline states, ICBs, function tables, or acceleration structures | every device (not implemented) | 5: `crates/metal2vulkan/src/lower/access/encode.rs:445`, `crates/metal2vulkan/src/lower/access/encode.rs:495` (+3) | `rare`: pipeline states and ICBs in argument buffers | | `DereferenceLoadedPointer` | Dereferencing a pointer loaded from memory or made from an integer | devices short of a Vulkan feature the site names; devices without buffer device addresses (`addressed_needs`); every device (no Vulkan mechanism) | 4: `crates/metal2vulkan/src/lower/access/dynamic.rs:407`, `crates/metal2vulkan/src/lower/access/local.rs:774` (+2) | `app`: pointers loaded from argument buffers | | `PointerToInteger` | Storing a pointer or converting it to an integer | - | via a helper: 1: `crates/metal2vulkan/src/lower/access/dynamic.rs:347` | `rare`: pointer to integer casts | @@ -84,14 +84,14 @@ Generated at `6b9a3b33d`. | `PixelSamplerCompare` | A constexpr sampler with pixel coordinates and a compare function, which Apple's compiler rejects ("invalid values combination in sampler... | every device (no Vulkan mechanism) | 1: `crates/metal2vulkan/src/lower/sampler/constexpr.rs:115` | `none`: Apple's compiler rejects it | | `TexelBuffer` | Texture buffers beyond the device's texel-buffer limits | devices without a format's usage; every device (no Vulkan mechanism) | 3: `crates/metal2vulkan/src/bind/instantiate.rs:879`, `crates/metal2vulkan/src/bind/instantiate.rs:885` (+1) | `app`: texture buffers past a device's texel-buffer limits | | `RasterOrderGroups` | Raster order groups without fragment shader interlock | devices without VkFeature::FragmentShaderPixelInterlock; devices without VkFeature::FragmentShaderSampleInterlock; devices without a capability the site computes (`alternatives`); every device (not implemented) | 4: `crates/metal2vulkan/src/device/metal.rs:242`, `crates/metal2vulkan/src/lower/fragment/rog.rs:151` (+2) | `rare`: raster order groups | -| `FramebufferFetch` | Framebuffer fetch without an ordered form on the device (rasterization-order attachment access, or the pixel interlock's storage form where the... | devices short of a Vulkan property the site names; devices without VkFeature::FragmentShaderPixelInterlock; devices without VkFeature::RasterizationOrderColorAttachmentAccess; devices without VkFeature::SampleRateShading; devices without a capability the site computes; devices without a capability the site computes (`alternatives`); devices without a capability the site computes (`c`); devices without a capability the site computes (`capability`); devices without a capability the site computes (`missing`); devices without a format's usage; drivers with a defect; every device (not implemented) | 26: `crates/metal2vulkan-runtime/src/families/features.rs:1015`, `crates/metal2vulkan-runtime/src/render.rs:5709` (+24) | `system`: programmable blending (framebuffer fetch); macOS 26.6.2's login reaches it (two WindowServer and RenderBox pipelines fetch RGB10A8_2P_XR10 attachments, the consumer's boots) | -| `PrimitiveId` | `[[primitive_id]]` in a fragment function | devices without a capability the site computes; every device (not implemented) | 3: `crates/metal2vulkan-runtime/src/families/features.rs:1124`, `crates/metal2vulkan/src/lower/stage_io/plan.rs:3112` (+1) | `rare`: primitive_id on a device without geometry or tessellation shaders, in an indexed draw or behind a mesh function | +| `FramebufferFetch` | Framebuffer fetch without an ordered form on the device (rasterization-order attachment access, or the pixel interlock's storage form where the... | devices short of a Vulkan property the site names; devices without VkFeature::FragmentShaderPixelInterlock; devices without VkFeature::RasterizationOrderColorAttachmentAccess; devices without VkFeature::SampleRateShading; devices without a capability the site computes; devices without a capability the site computes (`alternatives`); devices without a capability the site computes (`c`); devices without a capability the site computes (`capability`); devices without a capability the site computes (`missing`); devices without a format's usage; drivers with a defect; every device (not implemented) | 26: `crates/metal2vulkan-runtime/src/families/features.rs:1007`, `crates/metal2vulkan-runtime/src/render.rs:5709` (+24) | `system`: programmable blending (framebuffer fetch); macOS 26.6.2's login reaches it (two WindowServer and RenderBox pipelines fetch RGB10A8_2P_XR10 attachments, the consumer's boots) | +| `PrimitiveId` | `[[primitive_id]]` in a fragment function | devices without a capability the site computes; every device (not implemented) | 3: `crates/metal2vulkan-runtime/src/families/features.rs:1115`, `crates/metal2vulkan/src/lower/stage_io/plan.rs:3112` (+1) | `rare`: primitive_id on a device without geometry or tessellation shaders, in an indexed draw or behind a mesh function | | `VertexAmplification` | Vertex amplification | devices without VkFeature::Multiview; devices without VkFeature::MultiviewTessellationShader; devices without VkLimit::MaxMultiviewInstanceIndex; devices without a capability the site computes (`needs`); every device (not implemented) | 5: `crates/metal2vulkan/src/bind/graphics.rs:3897`, `crates/metal2vulkan/src/lower/stage_io/plan.rs:1281` (+3) | `rare`: vertex amplification | | `LayeredRendering` | Layered rendering (`render_target_array_index`, `viewport_array_index`) | devices without VkFeature::ImageView2DOn3DImage; devices without VkFeature::MultiViewport; devices without VkFeature::ShaderOutputLayer; devices without VkFeature::ShaderOutputViewportIndex; devices without a capability the site computes (`needs`); every device (not implemented) | 7: `crates/metal2vulkan-runtime/src/render_pass.rs:1658`, `crates/metal2vulkan-runtime/src/render_state.rs:1078` (+5) | `rare`: layered rendering on a device without its features | | `ClipDistance` | Clip or cull distances | devices without VkFeature::ShaderClipDistance; devices without VkLimit::MaxClipDistances | 2: `crates/metal2vulkan/src/lower/mesh/mod.rs:934`, `crates/metal2vulkan/src/lower/mesh/mod.rs:942` | `rare`: clip distances on a device without them | | `DualSourceBlending` | Dual-source blending | devices without VkFeature::DualSrcBlend; devices without VkLimit::MaxFragmentDualSrcAttachments | 5: `crates/metal2vulkan-runtime/src/families/formats.rs:386`, `crates/metal2vulkan/src/metal/state.rs:37` (+3) | `rare`: dual-source blending on a device without it | | `Barycentrics` | Barycentric coordinates | devices without VkFeature::FragmentShaderBarycentric; devices without VkFeature::GeometryShader; devices without a capability the site computes (`needs`); drivers with a defect; every device (not implemented) | 5: `crates/metal2vulkan/src/device/metal.rs:263`, `crates/metal2vulkan/src/lower/stage_io/plan.rs:1876` (+3) | `rare`: barycentric coordinates | -| `StencilExport` | Stencil export | devices without VkExtension::ExtShaderStencilExport; every device (not implemented) | 6: `crates/metal2vulkan-runtime/src/families/features.rs:1111`, `crates/metal2vulkan/src/bind/graphics.rs:2606` (+4) | `rare`: stencil from the shader | +| `StencilExport` | Stencil export | devices without VkExtension::ExtShaderStencilExport; every device (not implemented) | 6: `crates/metal2vulkan-runtime/src/families/features.rs:1102`, `crates/metal2vulkan/src/bind/graphics.rs:2606` (+4) | `rare`: stencil from the shader | | `SampleRateShading` | Per-sample shading | devices without VkFeature::SampleRateShading; devices without a capability the site computes (`needs`); every device (not implemented) | 3: `crates/metal2vulkan/src/pipeline/link/graphics.rs:832`, `crates/metal2vulkan/src/pipeline/link/graphics.rs:834` (+1) | `rare`: per-sample shading | | `PixelCoverageAtSampleRate` | The pixel's coverage (`[[sample_mask]]` read) in a fragment function that runs once per sample | drivers with a defect; every device (no Vulkan mechanism); every device (not implemented) | 3: `crates/metal2vulkan/src/lower/fragment/coverage.rs:291`, `crates/metal2vulkan/src/lower/simd/mod.rs:754` (+1) | `rare`: coverage read at sample rate | | `InterfaceComponents` | Too many interface components or locations | devices short of a device limit the site names; devices without VkLimit::MaxColorAttachments; devices without VkLimit::MaxVertexInputAttributes | 4: `crates/metal2vulkan/src/pipeline/compile/color_group.rs:202`, `crates/metal2vulkan/src/pipeline/link/graphics.rs:301` (+2) | `rare`: too many varyings or attachments for a device | @@ -110,7 +110,7 @@ Generated at `6b9a3b33d`. | `Attribute` | An LLVM attribute kind that changes the calling ABI and that AIR does not use (`inalloca`, `preallocated`, `byref`, `nest`, the `swift*` kinds) | - | via a helper: 2: `crates/metal2vulkan-air/src/bitcode/attrs.rs:493`, `crates/metal2vulkan/src/error/mod.rs:256` | `none`: LLVM ABI attributes AIR does not use | | `BitcodeRecord` | A bitcode record LLVM defines in `block` that the typed model does not cover and that has no more specific variant (legacy spellings predating... | - | via a helper: 7: `crates/metal2vulkan-air/src/bitcode/attrs.rs:337`, `crates/metal2vulkan-air/src/bitcode/function.rs:572` (+5) | `none`: bitcode records AIR does not emit | | `SyncScope` | An atomic access or fence in a synchronization scope other than LLVM's built-in `singlethread` and system scopes | - | via a helper: 2: `crates/metal2vulkan-air/src/bitcode/function.rs:1255`, `crates/metal2vulkan/src/error/mod.rs:258` | `none`: synchronization scopes AIR does not use | -| `SubgroupOperations` | Simdgroup operations of a class the stage's subgroups do not support (the stage is not in `subgroupSupportedStages`, or an operation class is... | devices without VkFeature::ShaderQuadControl; devices without VkFeature::ShaderSubgroupExtendedTypes; devices without VkProperty::SubgroupStage | 4: `crates/metal2vulkan-runtime/src/families/features.rs:1695`, `crates/metal2vulkan/src/lower/simd/mod.rs:407` (+2) | `app`: simdgroup functions in a stage a device's subgroups do not support | +| `SubgroupOperations` | Simdgroup operations of a class the stage's subgroups do not support (the stage is not in `subgroupSupportedStages`, or an operation class is... | devices without VkFeature::ShaderQuadControl; devices without VkFeature::ShaderSubgroupExtendedTypes; devices without VkProperty::SubgroupStage | 4: `crates/metal2vulkan-runtime/src/families/features.rs:1686`, `crates/metal2vulkan/src/lower/simd/mod.rs:407` (+2) | `app`: simdgroup functions in a stage a device's subgroups do not support | | `DirectCall` | A call to a defined function the inliner cannot take | every device (not implemented) | 1: `crates/metal2vulkan-air/src/canon/mod.rs:1319` | `rare`: variadic or byval calls the inliner cannot take | | `WideSwitchLiteral` | A switch case literal wider than 32 bits | every device (not implemented) | 1: `crates/metal2vulkan/src/structurize/emit.rs:207` | `rare`: 64-bit switch literals | | `Lowering` | An instruction, intrinsic, or interface element of a lowering family whose lowering has not landed yet (each family narrows its refusals as it lands) | devices short of a device limit the site names; devices without VkFeature::ShaderDemoteToHelperInvocation; every device (not implemented) | 35: `crates/metal2vulkan/src/bind/plan/resources.rs:762`, `crates/metal2vulkan/src/lower/access/handle.rs:1062` (+33) | `system`: the catch-all of lowering families not landed: any shader can meet one | @@ -130,13 +130,13 @@ Generated at `6b9a3b33d`. | `SparseTexture` | A sparse texture (`MTLTexture.isSparse`) bound at `slot`, where a function observes the residency of its accesses (`sparse_color::resident()`) and... | - | via a helper: 2: `crates/metal2vulkan/src/bind/plan/slots.rs:583`, `crates/metal2vulkan/src/bind/plan/slots.rs:607` | `rare`: sparse residency reads | | `TextureSize` | A texture whose extent, array layers, or level count is past what the device takes for its format, type, and usage (`Capability::Limit` names the... | devices short of a device limit the site names | 1: `crates/metal2vulkan-runtime/src/image_plan.rs:1196` | `app`: a texture past a device's image limits | | `TextureSampleCount` | A texture sample count the device does not take for its format, type, and usage | devices short of a Vulkan property the site names; devices without VkFeature::MultisampleArrayImage; every device (no Vulkan mechanism) | 3: `crates/metal2vulkan-runtime/src/image_plan.rs:1244`, `crates/metal2vulkan-runtime/src/image_plan.rs:598` (+1) | `app`: a sample count a device lacks for the texture | -| `TextureView` | A texture view Vulkan cannot make exactly on this image | every device (no Vulkan mechanism); every device (not implemented) | 7: `crates/metal2vulkan-runtime/src/binding_view.rs:156`, `crates/metal2vulkan-runtime/src/texture.rs:5032` (+5) | `app`: a texture view Vulkan cannot make exactly | +| `TextureView` | A texture view Vulkan cannot make exactly on this image | every device (no Vulkan mechanism); every device (not implemented) | 7: `crates/metal2vulkan-runtime/src/binding_view.rs:156`, `crates/metal2vulkan-runtime/src/texture.rs:5033` (+5) | `app`: a texture view Vulkan cannot make exactly | | `TextureSwizzle` | A texture swizzle whose Metal behavior is not measured | devices short of a Vulkan feature the site names; every device (not implemented) | 7: `crates/metal2vulkan-runtime/src/binding_view.rs:167`, `crates/metal2vulkan-runtime/src/texture.rs:980` (+5) | `app`: texture swizzles whose Metal behaviour is unmeasured | -| `MipmapGeneration` | `generateMipmapsForTexture:` where the device's filter is not shown to give Metal's answer | devices without VkFeature::ShaderInt64; devices without a format's usage; every device (not implemented) | 7: `crates/metal2vulkan-runtime/src/blit_texture.rs:1796`, `crates/metal2vulkan-runtime/src/mipmap_pick.rs:37` (+5) | `app`: generateMipmapsForTexture: where the device's filter is not Metal's | +| `MipmapGeneration` | `generateMipmapsForTexture:` where the device's filter is not shown to give Metal's answer | devices without VkFeature::ShaderInt64; devices without a format's usage; every device (not implemented) | 7: `crates/metal2vulkan-runtime/src/blit_texture.rs:1787`, `crates/metal2vulkan-runtime/src/mipmap_pick.rs:37` (+5) | `app`: generateMipmapsForTexture: where the device's filter is not Metal's | | `HostMemory` | A buffer over the caller's host memory without a copy (`newBufferWithBytesNoCopy:`) | devices without VkExtension::ExtExternalMemoryHost; every device (no Vulkan mechanism); every device (not implemented) | 5: `crates/metal2vulkan-runtime/src/host_memory.rs:393`, `crates/metal2vulkan-runtime/src/host_memory.rs:433` (+3) | `system`: newBufferWithBytesNoCopy: where the device cannot import the memory | -| `GpuTimes` | A command buffer's GPU times (`GPUStartTime`, `GPUEndTime`) on a device whose queue family writes no timestamps (`timestampValidBits` 0) | every device (no Vulkan mechanism) | 1: `crates/metal2vulkan-runtime/src/command_buffer/mod.rs:2558` | `rare`: GPU times on a queue without timestamps | +| `GpuTimes` | A command buffer's GPU times (`GPUStartTime`, `GPUEndTime`) on a device whose queue family writes no timestamps (`timestampValidBits` 0) | every device (no Vulkan mechanism) | 1: `crates/metal2vulkan-runtime/src/command_buffer/mod.rs:2542` | `rare`: GPU times on a queue without timestamps | | `CountingVisibility` | A `Counting` visibility result (`MTLVisibilityResultModeCounting`) on a device without `occlusionQueryPrecise` | devices without VkFeature::OcclusionQueryPrecise | 1: `crates/metal2vulkan-runtime/src/visibility.rs:452` | `rare`: counting occlusion queries on a device without precise queries | -| `ViewFormatReinterpretation` | A texture view whose format has other components, or components of other widths, than its texture's (`RGBA8Unorm` as `R32Uint`), on a device whose... | every device (no Vulkan mechanism) | 1: `crates/metal2vulkan-runtime/src/view_plan.rs:570` | `app`: a view of another component layout on a portability subset (MoltenVK) | +| `ViewFormatReinterpretation` | A texture view whose format has other components, or components of other widths, than its texture's (`RGBA8Unorm` as `R32Uint`), on a device whose... | every device (no Vulkan mechanism) | 1: `crates/metal2vulkan-runtime/src/view_plan.rs:568` | `app`: a view of another component layout on a portability subset (MoltenVK) | | `SeparateMultisampledDepthStencil` | A render pass whose depth and stencil attachments are separate multisampled textures that it loads or may store, on a device without maintenance8,... | - | via a helper: 7: `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:188`, `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:294` (+5) | `rare`: separate multisampled depth and stencil textures | | `PixelCoverage` | The fragment's coverage (`[[sample_mask]]` read) in a fragment function of a pipeline of more than one sample that runs once per pixel | drivers with a defect | 1: `crates/metal2vulkan/src/pipeline/link/graphics.rs:771` | `rare`: coverage reads at pixel rate in a multisampled pipeline | | `CentroidVarying` | A centroid varying (`[[centroid_perspective]]`, `[[centroid_no_perspective]]`) in a fragment function of a pipeline of more than one sample | drivers with a defect | 1: `crates/metal2vulkan/src/pipeline/link/graphics.rs:789` | `rare`: centroid varyings in a multisampled pipeline | @@ -145,7 +145,7 @@ Generated at `6b9a3b33d`. | `SparseMapping` | A sparse texture's mapping update (`updateTextureMapping:` and its array form, or a move of mappings) that covers part of one of the device's... | every device (no Vulkan mechanism) | 1: `crates/metal2vulkan-runtime/src/sparse/encoder.rs:466` | `rare`: sparse mappings off the device's blocks | | `TimelineSemaphores` | Command buffers and events, which the runtime completes and signals through timeline semaphores (core in Vulkan 1.2), on a device whose... | every device (no Vulkan mechanism) | 1: `crates/metal2vulkan-runtime/src/device/create.rs:1053` | `none`: a device below the runtime's floor | | `Reflection` | Reflection of an argument whose answer Metal's has not been measured for (`reflection`) | every device (not implemented) | 9: `crates/metal2vulkan/src/bind/argument_buffer.rs:626`, `crates/metal2vulkan/src/reflection/derive.rs:178` (+7) | `rare`: reflection of argument kinds Metal's answer is unmeasured for | -| `HeapTextureTiling` | A texture of a heap whose memory the device's optimal images do not take (a `Shared` heap on a device whose optimal images take no host-visible... | every device (no Vulkan mechanism) | 1: `crates/metal2vulkan-runtime/src/texture/heap.rs:565` | `app`: textures in Shared heaps on a device whose optimal images take no host memory | +| `HeapTextureTiling` | A texture of a heap whose memory the device's optimal images do not take (a `Shared` heap on a device whose optimal images take no host-visible... | every device (no Vulkan mechanism) | 1: `crates/metal2vulkan-runtime/src/texture/heap.rs:614` | `app`: textures in Shared heaps on a device whose optimal images take no host memory | | `ViewportDepthRange` | A viewport depth range past `[0, 1]` (`setViewport:`), which Metal takes and the runtime draws natively (`VK_EXT_depth_range_unrestricted`) or... | drivers with a defect | 1: `crates/metal2vulkan-runtime/src/render_state.rs:1186` | `rare`: viewport depth outside [0, 1] | | `UndeclaredTextureUsage` | A shader write to a texture made without `ShaderWrite` (or `ShaderAtomic`), or a read of one made without `ShaderRead`, which plain Metal runs,... | every device (not implemented) | 2: `crates/metal2vulkan-runtime/src/binding_view.rs:141`, `crates/metal2vulkan-runtime/src/texture/usage_shadow.rs:72` | `app`: a shader write to a texture made without ShaderWrite, which plain Metal runs | | `RenderTargetSize` | A render pass whose render area or layers are past the device's framebuffer limits (`Capability::Limit` names `MaxFramebufferWidth`,... | devices short of a device limit the site names | 1: `crates/metal2vulkan-runtime/src/render_pass.rs:1264` | `rare`: a render area past a device's framebuffer limits | @@ -167,8 +167,8 @@ Generated at `6b9a3b33d`. | `SparseHeaps` | Sparse heaps and their textures | every device (runtime piece not built) | 3: `crates/metal2vulkan-runtime/src/sparse/encoder.rs:458`, `crates/metal2vulkan-runtime/src/texture.rs:1629` (+1) | `rare`: sparse heaps | | `SparseTileMaps` | What the runtime's emulation of sparse textures does not build yet | every device (runtime piece not built) | 3: `crates/metal2vulkan-runtime/src/binding.rs:553`, `crates/metal2vulkan-runtime/src/sparse/texture.rs:30` (+1) | `rare`: sparse texture emulation's unbuilt pieces | | `HeapPastMaxBufferSize` | A heap larger than the device's `maxBufferSize`, which the device can allocate | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/heap.rs:694` | `rare`: a heap past maxBufferSize | -| `HeapTextureAlignment` | A heap texture whose image needs an alignment past the heap memory's base alignment (256 KiB) | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture/heap.rs:980` | `rare`: a heap texture needing more than 256 KiB alignment | -| `HeapTextureMemory` | A heap texture whose image the heap's memory type does not take | every device (runtime piece not built) | 5: `crates/metal2vulkan-runtime/src/texture/heap.rs:1418`, `crates/metal2vulkan-runtime/src/texture/heap.rs:1425` (+3) | `app`: a heap texture the heap's memory type does not take | +| `HeapTextureAlignment` | A heap texture whose image needs an alignment past the heap memory's base alignment (256 KiB) | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture/heap.rs:1017` | `rare`: a heap texture needing more than 256 KiB alignment | +| `HeapTextureMemory` | A heap texture whose image the heap's memory type does not take | every device (runtime piece not built) | 5: `crates/metal2vulkan-runtime/src/texture/heap.rs:1459`, `crates/metal2vulkan-runtime/src/texture/heap.rs:1466` (+3) | `app`: a heap texture the heap's memory type does not take | | `FunctionTablePastMaxBufferLength` | A visible-function table of more entries than one buffer of the device's `max_buffer_length` holds words for, or than its size word holds | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/function_table.rs:622` | `none`: a function table past one buffer | | `IndirectCommandBufferPastMaxBufferLength` | An indirect command buffer of more commands than one buffer of the device's `max_buffer_length` holds the records of | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs:516` | `none`: an ICB past one buffer | | `IndirectRenderCommands` | What indirect command buffers lack of their render commands | every device (runtime piece not built) | 17: `crates/metal2vulkan-runtime/src/compute.rs:1084`, `crates/metal2vulkan-runtime/src/compute.rs:1163` (+15) | `rare`: indirect render commands' remaining pieces | @@ -192,57 +192,57 @@ Generated at `6b9a3b33d`. | `TileAtSampleCount` | The tile memory of a render pass of a sample count Apple's GPUs lack (theirs are 1, 2 and 4), which a Vulkan device may have | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/render_pass.rs:1600`, `crates/metal2vulkan-runtime/src/render_pass.rs:930` | `none`: tile memory at a sample count Apple's GPUs lack | | `ImageblockMasters` | A draw or tile dispatch whose imageblock is of another size than the pass's, or a draw whose fragment function's layouts are of another alignment... | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/render.rs:7115`, `crates/metal2vulkan-runtime/src/render/tile_dispatch.rs:930` | `rare`: imageblocks of mixed sizes in one pass | | `TileAndFragmentImageblocks` | A render pass that reaches its imageblock storage, from a draw whose fragment function declares an explicit imageblock or a tile dispatch whose... | every device (runtime piece not built) | 3: `crates/metal2vulkan-runtime/src/render.rs:7107`, `crates/metal2vulkan-runtime/src/render/tile_dispatch.rs:797` (+1) | `rare`: explicit imageblocks shared by tile and fragment functions | -| `Metal4Api` | Metal 4's API (`MTL4CommandQueue`, `MTL4CommandBuffer`, `MTL4ArgumentTable`, `MTL4Compiler` and the rest), with the features only its programming... (not scheduled) | every device (runtime piece not built) | family audit only: 3: `crates/metal2vulkan-runtime/src/families/features.rs:1469`, `crates/metal2vulkan-runtime/src/families/limits.rs:1022` (+1) | `app`: Metal 4 (the API is missing: METAL-COVERAGE.md) | +| `Metal4Api` | Metal 4's API (`MTL4CommandQueue`, `MTL4CommandBuffer`, `MTL4ArgumentTable`, `MTL4Compiler` and the rest), with the features only its programming... (not scheduled) | every device (runtime piece not built) | family audit only: 3: `crates/metal2vulkan-runtime/src/families/features.rs:1460`, `crates/metal2vulkan-runtime/src/families/limits.rs:1022` (+1) | `app`: Metal 4 (the API is missing: METAL-COVERAGE.md) | | `CounterSampleBuffers` | Counter sample buffers (`MTLCounterSampleBuffer`) and the commands that sample into them (not scheduled) | every device (runtime piece not built) | family audit only: 1: `crates/metal2vulkan-runtime/src/families/limits.rs:1013` | `app`: GPU counters and timestamps by sample buffer (missing API) | -| `ResidencySets` | Residency sets (`MTLResidencySet`) (not scheduled) | every device (runtime piece not built) | family audit only: 2: `crates/metal2vulkan-runtime/src/families/features.rs:1451`, `crates/metal2vulkan-runtime/src/families/limits.rs:1015` | `app`: residency sets (missing API) | -| `TextureAccessCounters` | A sparse texture's access counters (`getTextureAccessCounters:...` and `resetTextureAccessCounters:...` of a blit encoder) (not scheduled) | every device (runtime piece not built) | family audit only: 2: `crates/metal2vulkan-runtime/src/families/features.rs:1438`, `crates/metal2vulkan-runtime/src/families/features.rs:1443` | `rare`: sparse texture access counters | -| `IoCommandQueues` | Fast resource loading (not scheduled) | every device (runtime piece not built) | family audit only: 2: `crates/metal2vulkan-runtime/src/families/features.rs:1448`, `crates/metal2vulkan-runtime/src/families/limits.rs:1020` | `rare`: fast resource loading (missing API) | -| `TextureViewPools` | Texture view pools (`MTLTextureViewPool`) (not scheduled) | every device (runtime piece not built) | family audit only: 2: `crates/metal2vulkan-runtime/src/families/features.rs:1452`, `crates/metal2vulkan-runtime/src/families/limits.rs:1021` | `rare`: texture view pools (missing API) | -| `ColorAttachmentMapping` | Color attachment mapping (`MTLLogicalToPhysicalColorAttachmentMap`) (not scheduled) | every device (runtime piece not built) | family audit only: 1: `crates/metal2vulkan-runtime/src/families/features.rs:1453` | `rare`: color attachment mapping (missing API) | -| `LossyTextureCompression` | Lossy texture compression (`MTLTextureCompressionTypeLossy`) (not scheduled) | every device (runtime piece not built) | family audit only: 1: `crates/metal2vulkan-runtime/src/families/features.rs:1447` | `rare`: lossy texture compression | -| `ShaderValidation` | Per-pipeline shader validation (`MTLShaderValidation`) (not scheduled) | every device (runtime piece not built) | family audit only: 1: `crates/metal2vulkan-runtime/src/families/features.rs:1449` | `rare`: per-pipeline shader validation | -| `ShaderLogging` | Shader logging (`MTLLogState`, a shader's `os_log`) (not scheduled) | every device (runtime piece not built) | family audit only: 1: `crates/metal2vulkan-runtime/src/families/features.rs:1450` | `rare`: shader os_log | -| `DeviceNotifications` | Device notifications (`MTLCopyAllDevicesWithObserver`) (not scheduled) | every device (runtime piece not built) | family audit only: 1: `crates/metal2vulkan-runtime/src/families/features.rs:1454` | `rare`: device hotplug notifications (deprecated) | +| `ResidencySets` | Residency sets (`MTLResidencySet`) (not scheduled) | every device (runtime piece not built) | family audit only: 2: `crates/metal2vulkan-runtime/src/families/features.rs:1442`, `crates/metal2vulkan-runtime/src/families/limits.rs:1015` | `app`: residency sets (missing API) | +| `TextureAccessCounters` | A sparse texture's access counters (`getTextureAccessCounters:...` and `resetTextureAccessCounters:...` of a blit encoder) (not scheduled) | every device (runtime piece not built) | family audit only: 2: `crates/metal2vulkan-runtime/src/families/features.rs:1429`, `crates/metal2vulkan-runtime/src/families/features.rs:1434` | `rare`: sparse texture access counters | +| `IoCommandQueues` | Fast resource loading (not scheduled) | every device (runtime piece not built) | family audit only: 2: `crates/metal2vulkan-runtime/src/families/features.rs:1439`, `crates/metal2vulkan-runtime/src/families/limits.rs:1020` | `rare`: fast resource loading (missing API) | +| `TextureViewPools` | Texture view pools (`MTLTextureViewPool`) (not scheduled) | every device (runtime piece not built) | family audit only: 2: `crates/metal2vulkan-runtime/src/families/features.rs:1443`, `crates/metal2vulkan-runtime/src/families/limits.rs:1021` | `rare`: texture view pools (missing API) | +| `ColorAttachmentMapping` | Color attachment mapping (`MTLLogicalToPhysicalColorAttachmentMap`) (not scheduled) | every device (runtime piece not built) | family audit only: 1: `crates/metal2vulkan-runtime/src/families/features.rs:1444` | `rare`: color attachment mapping (missing API) | +| `LossyTextureCompression` | Lossy texture compression (`MTLTextureCompressionTypeLossy`) (not scheduled) | every device (runtime piece not built) | family audit only: 1: `crates/metal2vulkan-runtime/src/families/features.rs:1438` | `rare`: lossy texture compression | +| `ShaderValidation` | Per-pipeline shader validation (`MTLShaderValidation`) (not scheduled) | every device (runtime piece not built) | family audit only: 1: `crates/metal2vulkan-runtime/src/families/features.rs:1440` | `rare`: per-pipeline shader validation | +| `ShaderLogging` | Shader logging (`MTLLogState`, a shader's `os_log`) (not scheduled) | every device (runtime piece not built) | family audit only: 1: `crates/metal2vulkan-runtime/src/families/features.rs:1441` | `rare`: shader os_log | +| `DeviceNotifications` | Device notifications (`MTLCopyAllDevicesWithObserver`) (not scheduled) | every device (runtime piece not built) | family audit only: 1: `crates/metal2vulkan-runtime/src/families/features.rs:1445` | `rare`: device hotplug notifications (deprecated) | | `RateMapRegions` | A draw in a rate-mapped pass that the region path does not draw, for the compile layer's reason (`rate_mapped_pass.rs`) | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/rate_mapped_pass.rs:349` | `rare`: draws in rate-mapped passes the region path does not draw | | `LayeredPass` | A layered render pass (`renderTargetArrayLength` 2 or more) that needs a step of one layer | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/color_resolve.rs:890` | `rare`: layered passes needing a per-layer color resolve | | `FunctionOptions` | A function descriptor's options beyond `CompileToBinary` and `StoreFunctionInMetalPipelinesScript` (`Library::new_function_with_descriptor`) | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/library.rs:215` | `rare`: function descriptor options beyond CompileToBinary | -| `OverlappingTextureCopies` | A blit copy between overlapping regions of one texture's texels (`copyFromTexture:...` with the source's region meeting the destination's, through... (not scheduled) | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/blit_texture.rs:1251` | `rare`: overlapping texture copies (Metal races) | -| `RebindTextures` | `Buffer::rebind_bytes_no_copy` of a no-copy buffer with a live texture over its bytes, given memory at another offset in its page than the old | every device (runtime piece not built) | 5: `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:600`, `crates/metal2vulkan-runtime/src/texture/heap.rs:2431` (+3) | `none`: a runtime extension's rebind with a live texture | +| `OverlappingTextureCopies` | A blit copy between overlapping regions of one texture's texels (`copyFromTexture:...` with the source's region meeting the destination's, through... (not scheduled) | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/blit_texture.rs:1242` | `rare`: overlapping texture copies (Metal races) | +| `RebindTextures` | `Buffer::rebind_bytes_no_copy` of a no-copy buffer with a live texture over its bytes, given memory at another offset in its page than the old | every device (runtime piece not built) | 5: `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:600`, `crates/metal2vulkan-runtime/src/texture/heap.rs:2503` (+3) | `none`: a runtime extension's rebind with a live texture | | `PvrtcBlockOrder` | A PVRTC texture's blocks in a Metal block order the runtime does not lay out | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture.rs:5580` | `rare`: PVRTC regions off whole levels | -| `DecodedHeapTexture` | A heap's or a sparse heap's texture of an ASTC format on a device without that ASTC format (`astc.rs`), or a sparse heap's texture of an ETC2 or... | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/texture.rs:1637`, `crates/metal2vulkan-runtime/src/texture/heap.rs:1281` | `app`: an ASTC texture in a heap on a device without ASTC | +| `DecodedHeapTexture` | A heap's or a sparse heap's texture of an ASTC format on a device without that ASTC format (`astc.rs`), or a sparse heap's texture of an ETC2 or... | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/texture.rs:1637`, `crates/metal2vulkan-runtime/src/texture/heap.rs:1319` | `app`: an ASTC texture in a heap on a device without ASTC | | `VertexFetchPast4GiB` | A draw (`drawPrimitives:` and its forms, or an indirect command buffer's command) that may read a vertex attribute the pipeline fetches in its... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/render/vertex_reach.rs:72` | `rare`: vertex fetch past 4 GiB of a bind offset | | `StageInFetchPast4GiB` | A dispatch (`dispatchThreads:threadsPerThreadgroup:` and its forms, or an indirect command buffer's command) whose kernel may read a... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/fetch_reach.rs:126` | `rare`: stage-in fetch past 4 GiB of a bind offset | | `MappedTextureSampling` | A command that would sample a texture of an address-mode map (`TextureDescriptor::address_mode_map`) where the runtime cannot map it at bind... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/address_map.rs:158` | `none`: a runtime extension's texture (address_mode_map) sampled where the runtime cannot map it; no Metal API path | | `LibrarySource` | A library compiled from Metal Shading Language source | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/library.rs:107` | `app`: a library compiled from Metal source (newLibraryWithSource:); the runtime takes metallibs and AIR | | `RestartedStrip` | An indexed strip after `set_primitive_restart_enabled` with an index Vulkan does not restart at, which the runtime draws as a list an index... | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/index_rewrite.rs:110`, `crates/metal2vulkan-runtime/src/render.rs:7219` | `none`: a strip after the Apple-private setPrimitiveRestartEnabled:index: whose rewrite pass cannot run as Metal draws | | `PrimitiveIdIndices` | An indexed draw (`drawIndexedPrimitives:`) of a pipeline whose fragment function reads `[[primitive_id]]` on a device whose fragment stage cannot... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/render.rs:7596` | `rare`: an indexed draw of a primitive_id pipeline, on a device without geometry or tessellation shaders, whose indices the encoder wrote since its last barrier | -| `RotatedTexture` | A rotated texture (`TextureDescriptor::rotation`) where the runtime does not build what Metal does | every device (runtime piece not built) | 9: `crates/metal2vulkan-runtime/src/blit_texture.rs:1580`, `crates/metal2vulkan-runtime/src/buffer_texture.rs:715` (+7) | `rare`: a rotated drawable's views, blits with images over overlapping rows, rows past its buffer | +| `RotatedTexture` | A rotated texture (`TextureDescriptor::rotation`) where the runtime does not build what Metal does | every device (runtime piece not built) | 9: `crates/metal2vulkan-runtime/src/blit_texture.rs:1571`, `crates/metal2vulkan-runtime/src/buffer_texture.rs:715` (+7) | `rare`: a rotated drawable's views, blits with images over overlapping rows, rows past its buffer | | `DetachTextures` | A texture over a no-copy buffer's or heap's bytes (a heap's texture, or a texture over the buffer or over one of the heap's buffers) that no... | every device (runtime piece not built) | 8: `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:604`, `crates/metal2vulkan-runtime/src/buffer_texture.rs:622` (+6) | `none`: a runtime extension's detach with a texture no stand-in presents exactly | | `TextureBufferLevels` | A texture buffer of more than one level (`TextureDescriptor::mipmap_level_count`, up to its width's full chain) from the device's, a heap's or the... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture_descriptor.rs:540` | `rare`: a texture buffer of more than one level (public, unusual) | | `WriteSwizzle` | A texture of `TextureDescriptor::write_swizzle_enabled` whose swizzle is not the default, with `ShaderWrite` or `RenderTarget` usage, from the... | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture_descriptor.rs:547` | `none`: Apple-private writeSwizzleEnabled with a swizzle that writes | -| `DetachedTexelAccess` | `Texture::replace_region` or `get_bytes` of a texture whose bytes (a no-copy buffer's or heap's) are detached (`detach_backing`) | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture.rs:4820` | `none`: CPU texel access while a runtime extension detached the bytes | -| `SurfaceDepthStencil` | A use of a texture of a depth or stencil format (`Depth16Unorm`, `Depth32Float`, `Depth32Float_Stencil8`, `Stencil8`, `X32_Stencil8`) over a plane... | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/blit_texture.rs:240`, `crates/metal2vulkan-runtime/src/texture/surface_depth.rs:57` | `rare`: a blit of the stencil of a Depth32Float_Stencil8 texture over a plane of an IOSurface with planes, or a pass on an X32_Stencil8 one's view as Depth32Float_Stencil8 | -| `HostHeapUncompressedMultisample` | A multisample texture in a heap over host pages (`Device::new_heap_with_bytes_no_copy`) that Metal keeps uncompressed | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture/heap.rs:1924` | `none`: a multisample texture Metal keeps uncompressed in a runtime extension's heap over host pages | +| `DetachedTexelAccess` | `Texture::replace_region` or `get_bytes` of a texture whose bytes (a no-copy buffer's or heap's) are detached (`detach_backing`) | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/texture.rs:4821` | `none`: CPU texel access while a runtime extension detached the bytes | +| `SurfaceDepthStencil` | A use of a texture of a depth or stencil format (`Depth16Unorm`, `Depth32Float`, `Depth32Float_Stencil8`, `Stencil8`, `X32_Stencil8`) over a plane... | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/blit_texture.rs:236`, `crates/metal2vulkan-runtime/src/texture/surface_depth.rs:57` | `rare`: a blit of the stencil of a Depth32Float_Stencil8 texture over a plane of an IOSurface with planes, or a pass on an X32_Stencil8 one's view as Depth32Float_Stencil8 | | `PredicationUnbalanced` | An unbalanced command-predication record (`ComputeCommandEncoder::encode_end_if` and the other ends, or `encode_start_else`, with no block open;... | every device (runtime piece not built) | 4: `crates/metal2vulkan-runtime/src/predication.rs:371`, `crates/metal2vulkan-runtime/src/predication.rs:403` (+2) | `none`: an unbalanced Apple-private command-predication record, whose dropped work Metal decides by no rule measured | | `PredicationOpenAtUnitEnd` | A command buffer one of whose units of predication ended with an If still open that no misused record killed, refused at `CommandBuffer::commit` | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/predication.rs:280`, `crates/metal2vulkan-runtime/src/predication.rs:296` | `none`: an Apple-private predication If left open, live, where its unit ends | | `PredicationWordPastBuffer` | A predication condition word (`encode_start_if`'s offset, rounded down to a multiple of 4) past its buffer's end | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/predication.rs:139` | `none`: an Apple-private predication condition word past its buffer | | `PredicatedLoopDepth` | A predicated loop started (`ComputeCommandEncoder::encode_start_while`, `encode_start_do_while`) with three loops already open in its unit | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/predication.rs:483` | `none`: an Apple-private predicated loop four deep | | `PredicatedLoopAcrossEncoders` | A command buffer one of whose live predicated loops started in one compute encoder and ended in a later one of its unit, refused at... | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/predication.rs:284`, `crates/metal2vulkan-runtime/src/predication.rs:300` | `none`: a live Apple-private predicated loop spanning compute encoders | -| `MultisampledBufferCopy` | A blit copy between a buffer and a multisampled texture (`copyFromBuffer:...toTexture:` into, or `copyFromTexture:...toBuffer:` out of, a texture... | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/blit_texture.rs:489`, `crates/metal2vulkan-runtime/src/blit_texture.rs:645` | `rare`: a buffer<->multisampled-texture copy on a device without sample-rate shading, an integer multisample attachment at the count, or the copy format's storage; and, where maintenance8's depth/colour copies are missing or wrong, what the sample-rate draws cannot move: a 16-bit depth, or a depth or stencil texture they cannot sample or render to (emulated elsewhere; the consumer's Maps pans and screensaver make the copy) | +| `MultisampledBufferCopy` | A blit copy between a buffer and a multisampled texture (`copyFromBuffer:...toTexture:` into, or `copyFromTexture:...toBuffer:` out of, a texture... | every device (runtime piece not built) | 2: `crates/metal2vulkan-runtime/src/blit_texture.rs:485`, `crates/metal2vulkan-runtime/src/blit_texture.rs:641` | `rare`: a buffer<->multisampled-texture copy on a device without sample-rate shading, an integer multisample attachment at the count, or the copy format's storage; and, where maintenance8's depth/colour copies are missing or wrong, what the sample-rate draws cannot move: a 16-bit depth, or a depth or stencil texture they cannot sample or render to (emulated elsewhere; the consumer's Maps pans and screensaver make the copy) | | `ColorAttachmentGroups` | What a render pass the device draws in color groups does not build | every device (runtime piece not built) | 1: `crates/metal2vulkan-runtime/src/render/color_groups.rs:106` | `app`: in a render pass of more color attachments than the device draws at once (five or more on a device of four), or one at an index past them: a pipeline state of other colors, a tile state, an execution of render commands, a draw reading another group's attachment | ## 3. Apple-only calls (`Error::AppleOnly`) | Variant | What it blocks | Where | Sites | Reach | |---|---|---|---|---| -| `ProtectedContent` | Protected content | every device (Apple-private, Metal's answer not measured) | 1: `crates/metal2vulkan-runtime/src/apple_only.rs:189` | `none`: Apple-private (no public header) | -| `LineWidth` | A line width other than 1 (`setLineWidth:`) | every device (Apple-private, Metal's answer not measured) | 1: `crates/metal2vulkan-runtime/src/apple_only.rs:191` | `none`: Apple-private (no public header) | -| `ProvokingVertexMode` | `setProvokingVertexMode:` other than 0 | every device (Apple-private, not built) | 1: `crates/metal2vulkan-runtime/src/apple_only.rs:196` | `none`: Apple-private (no public header) | -| `ViewportTransformDisabled` | The viewport transform turned off (`setViewportTransformEnabled:NO`) | every device (Apple-private, Metal's answer not measured) | 1: `crates/metal2vulkan-runtime/src/apple_only.rs:193` | `none`: Apple-private (no public header) | -| `VertexAmplificationMode` | `setVertexAmplificationMode:value:` | every device (Apple-private, Metal's answer not measured) | 1: `crates/metal2vulkan-runtime/src/apple_only.rs:199` | `none`: Apple-private (no public header) | -| `DepthCleared` | `setDepthCleared` | every device (Apple-private, Metal's answer not measured) | 1: `crates/metal2vulkan-runtime/src/apple_only.rs:201` | `none`: Apple-private (no public header) | -| `StencilCleared` | `setStencilCleared` | every device (Apple-private, Metal's answer not measured) | 1: `crates/metal2vulkan-runtime/src/apple_only.rs:202` | `none`: Apple-private (no public header) | +| `ProtectedContent` | Protected content | every device (Apple-private, Metal's answer not measured) | 1: `crates/metal2vulkan-runtime/src/apple_only.rs:200` | `none`: Apple-private (no public header) | +| `LineWidth` | A line width other than 1 (`setLineWidth:`) | every device (Apple-private, Metal's answer not measured) | 1: `crates/metal2vulkan-runtime/src/apple_only.rs:202` | `none`: Apple-private (no public header) | +| `ProvokingVertexMode` | `setProvokingVertexMode:` other than 0 | every device (Apple-private, not built) | 1: `crates/metal2vulkan-runtime/src/apple_only.rs:207` | `none`: Apple-private (no public header) | +| `ViewportTransformDisabled` | The viewport transform turned off (`setViewportTransformEnabled:NO`) | every device (Apple-private, Metal's answer not measured) | 1: `crates/metal2vulkan-runtime/src/apple_only.rs:204` | `none`: Apple-private (no public header) | +| `VertexAmplificationMode` | `setVertexAmplificationMode:value:` | every device (Apple-private, Metal's answer not measured) | 1: `crates/metal2vulkan-runtime/src/apple_only.rs:210` | `none`: Apple-private (no public header) | +| `DepthCleared` | `setDepthCleared` | every device (Apple-private, Metal's answer not measured) | 1: `crates/metal2vulkan-runtime/src/apple_only.rs:212` | `none`: Apple-private (no public header) | +| `StencilCleared` | `setStencilCleared` | every device (Apple-private, Metal's answer not measured) | 1: `crates/metal2vulkan-runtime/src/apple_only.rs:213` | `none`: Apple-private (no public header) | | `SurfaceClientDirection` | A texture over an IOSurface made with `kIOSurfaceClientDirection` (`newTextureWithDescriptor:iosurface:plane:` of such a surface) | every device (Apple-private, Metal's answer not measured) | 1: `crates/metal2vulkan-runtime/src/buffer_texture.rs:417` | `none`: an IOSurface key in no public header | +| `FillUnmeasured` | A texture fill (`fillTexture:level:slice:region:bytes:length:` or a color form) whose answer on Apple's GPU is unmeasured | every device (Apple-private, Metal's answer not measured) | 1: `crates/metal2vulkan-runtime/src/blit_fill.rs:149` | `system`: Apple-private texture fills, which macOS system software encodes | ## 4. Binder refusals at a device limit (`BindError`) @@ -318,7 +318,7 @@ Each refusal's sites, with the function that builds it. - `feature::QuadOperations`: `crates/metal2vulkan/src/device/subgroup.rs:371 (subgroup_tier)`; `crates/metal2vulkan/src/device/subgroup.rs:405 (subgroup_tier)` - `feature::SimdgroupMatrix`: `crates/metal2vulkan/src/lower/simd/matrix.rs:83 (not_implemented)` - `feature::ArgumentBufferPointers`: `crates/metal2vulkan/src/device/metal.rs:236 (unsupported_features)` -- `feature::ArgumentBufferTextures`: `crates/metal2vulkan-runtime/src/families/features.rs:1630 (tier2)`; `crates/metal2vulkan-runtime/src/pipeline/objects.rs:1036 (create_set_layout)`; `crates/metal2vulkan-runtime/src/resource_ids.rs:1097 (check_capacity)`; `crates/metal2vulkan/src/bind/heap.rs:1325 (array)`; `crates/metal2vulkan/src/bind/heap.rs:415 (member_view)`; `crates/metal2vulkan/src/bind/heap.rs:423 (member_view)`; `crates/metal2vulkan/src/bind/heap.rs:467 (member_view)`; `crates/metal2vulkan/src/bind/heap.rs:472 (member_view)`; `crates/metal2vulkan/src/bind/heap.rs:485 (member_view)`; `crates/metal2vulkan/src/lower/access/handle.rs:708 (select)`; `crates/metal2vulkan/src/lower/sampler/select.rs:2362 (select_one)`; `crates/metal2vulkan/src/lower/sampler/select.rs:308 (select_sampling)`; `crates/metal2vulkan/src/lower/sampler/select.rs:469 (select_heap_sampling)`; `crates/metal2vulkan/src/lower/texture/atomic.rs:140 (select)`; `crates/metal2vulkan/src/lower/texture/slot.rs:465 (declare_heap)`; `crates/metal2vulkan/src/lower/texture/slot.rs:534 (declare_heap)`; `crates/metal2vulkan/src/pipeline/link.rs:977 (heap_set)` +- `feature::ArgumentBufferTextures`: `crates/metal2vulkan-runtime/src/families/features.rs:1621 (tier2)`; `crates/metal2vulkan-runtime/src/pipeline/objects.rs:1036 (create_set_layout)`; `crates/metal2vulkan-runtime/src/resource_ids.rs:1097 (check_capacity)`; `crates/metal2vulkan/src/bind/heap.rs:1325 (array)`; `crates/metal2vulkan/src/bind/heap.rs:415 (member_view)`; `crates/metal2vulkan/src/bind/heap.rs:423 (member_view)`; `crates/metal2vulkan/src/bind/heap.rs:467 (member_view)`; `crates/metal2vulkan/src/bind/heap.rs:472 (member_view)`; `crates/metal2vulkan/src/bind/heap.rs:485 (member_view)`; `crates/metal2vulkan/src/lower/access/handle.rs:708 (select)`; `crates/metal2vulkan/src/lower/sampler/select.rs:2362 (select_one)`; `crates/metal2vulkan/src/lower/sampler/select.rs:308 (select_sampling)`; `crates/metal2vulkan/src/lower/sampler/select.rs:469 (select_heap_sampling)`; `crates/metal2vulkan/src/lower/texture/atomic.rs:140 (select)`; `crates/metal2vulkan/src/lower/texture/slot.rs:465 (declare_heap)`; `crates/metal2vulkan/src/lower/texture/slot.rs:534 (declare_heap)`; `crates/metal2vulkan/src/pipeline/link.rs:977 (heap_set)` - `feature::ArgumentBufferObjects`: `crates/metal2vulkan/src/lower/access/encode.rs:445 (select_command)`; `crates/metal2vulkan/src/lower/access/encode.rs:495 (select_command)`; `crates/metal2vulkan/src/lower/access/encode.rs:623 (select_command)`; `crates/metal2vulkan/src/memory/provenance.rs:2185 (classify)`; `crates/metal2vulkan/src/memory/provenance.rs:2547 (access)` - `feature::DereferenceLoadedPointer`: `crates/metal2vulkan/src/lower/access/dynamic.rs:407 (plan_misses)`; `crates/metal2vulkan/src/lower/access/local.rs:774 (access_ptr)`; `crates/metal2vulkan/src/lower/access/local.rs:796 (threadgroup_constant_refusal)`; `crates/metal2vulkan/src/memory/plan.rs:593 (analyze)` - `feature::PointerToInteger`: `crates/metal2vulkan/src/lower/access/dynamic.rs:347 (require_addresses)` @@ -333,7 +333,7 @@ Each refusal's sites, with the function that builds it. - `feature::BufferRange`: `crates/metal2vulkan-runtime/src/function_table.rs:569 (past_storage_buffer_range)`; `crates/metal2vulkan/src/bind/graphics.rs:3556 (patch_binding)`; `crates/metal2vulkan/src/bind/graphics.rs:3600 (patch_binding)`; `crates/metal2vulkan/src/bind/graphics.rs:3638 (patch_binding)`; `crates/metal2vulkan/src/bind/instantiate.rs:658 (bind_buffers)`; `crates/metal2vulkan/src/lower/access/function_table.rs:226 (select)`; `crates/metal2vulkan/src/lower/access/mod.rs:1184 (place_slots)` - `feature::Int64Arithmetic`: `crates/metal2vulkan/src/lower/arith/legal.rs:582 (check_scalar)`; `crates/metal2vulkan/src/lower/select.rs:1133 (selector_form)` - `feature::Float64Arithmetic`: `crates/metal2vulkan/src/device/metal.rs:230 (unsupported_features)`; `crates/metal2vulkan/src/lower/arith/legal.rs:587 (check_scalar)` -- `feature::Format`: `crates/metal2vulkan-runtime/src/binding_view.rs:146 (binding_view)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:462 (check_formats)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:469 (check_formats)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:484 (check_formats)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:541 (pair_unit)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:633 (plan_levels_copy)`; `crates/metal2vulkan-runtime/src/blit_texture.rs:2096 (through_buffer)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:519 (make_texture_over)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:582 (make_texture_over)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:614 (make_texture_over)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:851 (texture_buffer_texel)`; `crates/metal2vulkan-runtime/src/copy_plan.rs:269 (colour_unit)`; `crates/metal2vulkan-runtime/src/copy_plan.rs:297 (copy_unit)`; `crates/metal2vulkan-runtime/src/copy_plan.rs:343 (copy_unit)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:346 (scratch)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:526 (usable_twin)`; `crates/metal2vulkan-runtime/src/families/features.rs:1607 (read_write_tier)`; `crates/metal2vulkan-runtime/src/families/formats.rs:1628 (sparse_missing)`; `crates/metal2vulkan-runtime/src/families/formats.rs:227 (none)`; `crates/metal2vulkan-runtime/src/families/formats.rs:271 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:291 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:306 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:353 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:392 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:474 (atomic_gap)`; `crates/metal2vulkan-runtime/src/families/formats.rs:508 (lacking)`; `crates/metal2vulkan-runtime/src/families/formats.rs:522 (unsupported)`; `crates/metal2vulkan-runtime/src/image_plan.rs:544 (check_own_memory)`; `crates/metal2vulkan-runtime/src/image_plan.rs:670 (plan_held)`; `crates/metal2vulkan-runtime/src/image_plan.rs:787 (plan_held)`; `crates/metal2vulkan-runtime/src/image_plan.rs:907 (plan_held)`; `crates/metal2vulkan-runtime/src/render.rs:2155 (viewing)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1024 (check_target)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1362 (layout)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1698 (target)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1791 (attachment_format)`; `crates/metal2vulkan-runtime/src/resolve.rs:392 (unmodelled_resolve)`; `crates/metal2vulkan-runtime/src/resolve.rs:482 (color)`; `crates/metal2vulkan-runtime/src/sample_copy.rs:177 (checked_twin)`; `crates/metal2vulkan-runtime/src/sample_copy.rs:205 (plan)`; `crates/metal2vulkan-runtime/src/sample_interleave.rs:296 (interleave_merge)`; `crates/metal2vulkan-runtime/src/shadow.rs:644 (unmerged)`; `crates/metal2vulkan-runtime/src/shadow.rs:651 (unmerged)`; `crates/metal2vulkan-runtime/src/texture.rs:2000 (texture_as)`; `crates/metal2vulkan-runtime/src/texture.rs:3540 (two_planes_refused)`; `crates/metal2vulkan-runtime/src/texture/decoded_twin.rs:498 (astc_texels)`; `crates/metal2vulkan-runtime/src/texture/decoded_twin.rs:534 (etc_texels)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1810 (planned_heap_texture)`; `crates/metal2vulkan-runtime/src/texture/surface_two_planes.rs:80 (refused)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs:115 (converted_storage)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs:278 (ycbcr_write_shadow)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs:384 (new_render_shadow)`; `crates/metal2vulkan-runtime/src/two_planes.rs:120 (unmeasured)`; `crates/metal2vulkan-runtime/src/view_plan.rs:380 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:393 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:400 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:412 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:422 (check_format)`; `crates/metal2vulkan-runtime/src/ycbcr.rs:285 (refused)`; `crates/metal2vulkan/src/bind/extended_shadow.rs:184 (extended_shadow_module)`; `crates/metal2vulkan/src/bind/plan/resources.rs:1134 (plain_texture)`; `crates/metal2vulkan/src/bind/plan/resources.rs:1814 (extended_sampler)`; `crates/metal2vulkan/src/bind/plan/resources.rs:193 (require_filter_features)`; `crates/metal2vulkan/src/bind/plan/resources.rs:959 (plain_texture)`; `crates/metal2vulkan/src/bind/sample_interleave.rs:304 (finish)`; `crates/metal2vulkan/src/bind/sample_interleave.rs:328 (interleave_split_module)`; `crates/metal2vulkan/src/bind/shadow_copy_in.rs:259 (shadow_copy_in_module)`; `crates/metal2vulkan/src/bind/unused_bits.rs:687 (unused_bits_module)`; `crates/metal2vulkan/src/lower/access/tile.rs:1029 (storage_format)`; `crates/metal2vulkan/src/lower/fragment/color.rs:160 (select_param)`; `crates/metal2vulkan/src/lower/fragment/color.rs:166 (select_param)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1138 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1159 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1165 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1171 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1196 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1371 (plan)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1762 (select_read)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1870 (select_output)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1897 (select_output)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1916 (select_output)`; `crates/metal2vulkan/src/lower/sampler/select.rs:1093 (select_extended)`; `crates/metal2vulkan/src/lower/sampler/select.rs:691 (texel_in)`; `crates/metal2vulkan/src/lower/stage_io/extended_color.rs:77 (plan)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:2288 (entry)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:865 (zeroed_output)`; `crates/metal2vulkan/src/lower/stage_io/word_color.rs:83 (plan)`; `crates/metal2vulkan/src/lower/texture/mod.rs:2342 (select)`; `crates/metal2vulkan/src/lower/texture/mod.rs:2984 (cross_class)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3156 (select_image)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3326 (select_read_as)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3363 (select_read_as)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3696 (select_write)`; `crates/metal2vulkan/src/lower/texture/slot.rs:1035 (declare_slot)`; `crates/metal2vulkan/src/lower/texture/slot.rs:1048 (declare_slot)`; `crates/metal2vulkan/src/lower/texture/slot.rs:1054 (declare_slot)`; `crates/metal2vulkan/src/lower/texture/slot.rs:739 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:742 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:753 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:771 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:791 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:815 (ulong_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:826 (ulong_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:873 (ulong_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:908 (atomic_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:917 (atomic_format)`; `crates/metal2vulkan/src/metal/format/mod.rs:1693 (vk_format)`; `crates/metal2vulkan/src/metal/format/mod.rs:1695 (vk_format)`; `crates/metal2vulkan/src/metal/format/mod.rs:1825 (candidates)`; `crates/metal2vulkan/src/metal/format/mod.rs:2783 (storage_choice_viewed)`; `crates/metal2vulkan/src/metal/format/mod.rs:2801 (held_storage_choice)`; `crates/metal2vulkan/src/metal/format/mod.rs:2809 (held_storage_choice)`; `crates/metal2vulkan/src/metal/format/mod.rs:2906 (held_storage_choice)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:1088 (extended_write_mask)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:428 (graphics_state)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:474 (graphics_state)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:546 (graphics_state)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:957 (reads_alpha_to_coverage)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:978 (reads_alpha_to_coverage)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs:449 (rotated_blend)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs:593 (alpha_in_red_blend)` +- `feature::Format`: `crates/metal2vulkan-runtime/src/binding_view.rs:146 (binding_view)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:462 (check_formats)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:469 (check_formats)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:484 (check_formats)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:541 (pair_unit)`; `crates/metal2vulkan-runtime/src/blit_plan.rs:633 (plan_levels_copy)`; `crates/metal2vulkan-runtime/src/blit_texture.rs:2087 (through_buffer)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:519 (make_texture_over)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:582 (make_texture_over)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:614 (make_texture_over)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:851 (texture_buffer_texel)`; `crates/metal2vulkan-runtime/src/copy_plan.rs:269 (colour_unit)`; `crates/metal2vulkan-runtime/src/copy_plan.rs:297 (copy_unit)`; `crates/metal2vulkan-runtime/src/copy_plan.rs:343 (copy_unit)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:346 (scratch)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:526 (usable_twin)`; `crates/metal2vulkan-runtime/src/families/features.rs:1598 (read_write_tier)`; `crates/metal2vulkan-runtime/src/families/formats.rs:1628 (sparse_missing)`; `crates/metal2vulkan-runtime/src/families/formats.rs:227 (none)`; `crates/metal2vulkan-runtime/src/families/formats.rs:271 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:291 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:306 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:353 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:392 (answers)`; `crates/metal2vulkan-runtime/src/families/formats.rs:474 (atomic_gap)`; `crates/metal2vulkan-runtime/src/families/formats.rs:508 (lacking)`; `crates/metal2vulkan-runtime/src/families/formats.rs:522 (unsupported)`; `crates/metal2vulkan-runtime/src/image_plan.rs:544 (check_own_memory)`; `crates/metal2vulkan-runtime/src/image_plan.rs:670 (plan_held)`; `crates/metal2vulkan-runtime/src/image_plan.rs:787 (plan_held)`; `crates/metal2vulkan-runtime/src/image_plan.rs:907 (plan_held)`; `crates/metal2vulkan-runtime/src/render.rs:2155 (viewing)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1024 (check_target)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1362 (layout)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1698 (target)`; `crates/metal2vulkan-runtime/src/render_pass.rs:1791 (attachment_format)`; `crates/metal2vulkan-runtime/src/resolve.rs:392 (unmodelled_resolve)`; `crates/metal2vulkan-runtime/src/resolve.rs:482 (color)`; `crates/metal2vulkan-runtime/src/sample_copy.rs:177 (checked_twin)`; `crates/metal2vulkan-runtime/src/sample_copy.rs:205 (plan)`; `crates/metal2vulkan-runtime/src/sample_interleave.rs:296 (interleave_merge)`; `crates/metal2vulkan-runtime/src/shadow.rs:648 (unmerged)`; `crates/metal2vulkan-runtime/src/shadow.rs:655 (unmerged)`; `crates/metal2vulkan-runtime/src/texture.rs:2000 (texture_as)`; `crates/metal2vulkan-runtime/src/texture.rs:3540 (two_planes_refused)`; `crates/metal2vulkan-runtime/src/texture/decoded_twin.rs:498 (astc_texels)`; `crates/metal2vulkan-runtime/src/texture/decoded_twin.rs:534 (etc_texels)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1875 (planned_heap_texture)`; `crates/metal2vulkan-runtime/src/texture/surface_two_planes.rs:80 (refused)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs:115 (converted_storage)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs:278 (ycbcr_write_shadow)`; `crates/metal2vulkan-runtime/src/texture/ycbcr_image.rs:384 (new_render_shadow)`; `crates/metal2vulkan-runtime/src/two_planes.rs:114 (unmeasured)`; `crates/metal2vulkan-runtime/src/view_plan.rs:380 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:393 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:400 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:410 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:420 (check_format)`; `crates/metal2vulkan-runtime/src/ycbcr.rs:285 (refused)`; `crates/metal2vulkan/src/bind/extended_shadow.rs:184 (extended_shadow_module)`; `crates/metal2vulkan/src/bind/plan/resources.rs:1134 (plain_texture)`; `crates/metal2vulkan/src/bind/plan/resources.rs:1814 (extended_sampler)`; `crates/metal2vulkan/src/bind/plan/resources.rs:193 (require_filter_features)`; `crates/metal2vulkan/src/bind/plan/resources.rs:959 (plain_texture)`; `crates/metal2vulkan/src/bind/sample_interleave.rs:304 (finish)`; `crates/metal2vulkan/src/bind/sample_interleave.rs:328 (interleave_split_module)`; `crates/metal2vulkan/src/bind/shadow_copy_in.rs:259 (shadow_copy_in_module)`; `crates/metal2vulkan/src/bind/unused_bits.rs:657 (unused_bits_module)`; `crates/metal2vulkan/src/lower/access/tile.rs:1029 (storage_format)`; `crates/metal2vulkan/src/lower/fragment/color.rs:160 (select_param)`; `crates/metal2vulkan/src/lower/fragment/color.rs:166 (select_param)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1138 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1159 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1165 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1171 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1196 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1371 (plan)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1762 (select_read)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1870 (select_output)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1897 (select_output)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1916 (select_output)`; `crates/metal2vulkan/src/lower/sampler/select.rs:1093 (select_extended)`; `crates/metal2vulkan/src/lower/sampler/select.rs:691 (texel_in)`; `crates/metal2vulkan/src/lower/stage_io/extended_color.rs:77 (plan)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:2288 (entry)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:865 (zeroed_output)`; `crates/metal2vulkan/src/lower/stage_io/word_color.rs:83 (plan)`; `crates/metal2vulkan/src/lower/texture/mod.rs:2342 (select)`; `crates/metal2vulkan/src/lower/texture/mod.rs:2984 (cross_class)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3156 (select_image)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3326 (select_read_as)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3363 (select_read_as)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3696 (select_write)`; `crates/metal2vulkan/src/lower/texture/slot.rs:1035 (declare_slot)`; `crates/metal2vulkan/src/lower/texture/slot.rs:1048 (declare_slot)`; `crates/metal2vulkan/src/lower/texture/slot.rs:1054 (declare_slot)`; `crates/metal2vulkan/src/lower/texture/slot.rs:739 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:742 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:753 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:771 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:791 (storage_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:815 (ulong_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:826 (ulong_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:873 (ulong_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:908 (atomic_format)`; `crates/metal2vulkan/src/lower/texture/slot.rs:917 (atomic_format)`; `crates/metal2vulkan/src/metal/format/mod.rs:1657 (vk_format)`; `crates/metal2vulkan/src/metal/format/mod.rs:1659 (vk_format)`; `crates/metal2vulkan/src/metal/format/mod.rs:1789 (candidates)`; `crates/metal2vulkan/src/metal/format/mod.rs:2745 (storage_choice_viewed)`; `crates/metal2vulkan/src/metal/format/mod.rs:2763 (held_storage_choice)`; `crates/metal2vulkan/src/metal/format/mod.rs:2771 (held_storage_choice)`; `crates/metal2vulkan/src/metal/format/mod.rs:2868 (held_storage_choice)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:1087 (extended_write_mask)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:428 (graphics_state)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:474 (graphics_state)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:546 (graphics_state)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:957 (reads_alpha_to_coverage)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:978 (reads_alpha_to_coverage)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs:449 (rotated_blend)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs:593 (alpha_in_red_blend)` - `feature::DivergentImplicitLod`: `crates/metal2vulkan/src/lower/sampler/select.rs:352 (select_sampling)` - `feature::ImplicitLodOutsideFragment`: `crates/metal2vulkan/src/lower/sampler/constexpr.rs:136 (query_min_level)`; `crates/metal2vulkan/src/lower/sampler/select.rs:229 (query_level_measured)`; `crates/metal2vulkan/src/lower/sampler/select.rs:255 (query_min_level)` - `feature::MinLodClamp`: `crates/metal2vulkan/src/lower/sampler/select.rs:1572 (select_one)`; `crates/metal2vulkan/src/lower/sampler/select.rs:973 (min_lod)` @@ -349,14 +349,14 @@ Each refusal's sites, with the function that builds it. - `feature::PixelSamplerCompare`: `crates/metal2vulkan/src/lower/sampler/constexpr.rs:115 (lowered)` - `feature::TexelBuffer`: `crates/metal2vulkan/src/bind/instantiate.rs:879 (texel_ranges)`; `crates/metal2vulkan/src/bind/instantiate.rs:885 (texel_ranges)`; `crates/metal2vulkan/src/bind/plan/resources.rs:1147 (plain_texture)` - `feature::RasterOrderGroups`: `crates/metal2vulkan/src/device/metal.rs:242 (unsupported_features)`; `crates/metal2vulkan/src/lower/fragment/rog.rs:151 (mode)`; `crates/metal2vulkan/src/lower/fragment/rog.rs:172 (mode)`; `crates/metal2vulkan/src/lower/fragment/snapshot.rs:158 (finish)` -- `feature::FramebufferFetch`: `crates/metal2vulkan-runtime/src/families/features.rs:1015 (state)`; `crates/metal2vulkan-runtime/src/render.rs:5709 (next_instance)`; `crates/metal2vulkan-runtime/src/sample_planes.rs:120 (lacks)`; `crates/metal2vulkan-runtime/src/sample_planes.rs:147 (new)`; `crates/metal2vulkan-runtime/src/sample_planes.rs:518 (planes_merge)`; `crates/metal2vulkan/src/bind/extended_shadow.rs:190 (extended_shadow_module)`; `crates/metal2vulkan/src/bind/graphics.rs:1453 (plan)`; `crates/metal2vulkan/src/bind/graphics.rs:1490 (plan)`; `crates/metal2vulkan/src/bind/graphics.rs:1509 (plan)`; `crates/metal2vulkan/src/bind/sample_planes.rs:477 (finish)`; `crates/metal2vulkan/src/device/metal.rs:252 (unsupported_features)`; `crates/metal2vulkan/src/lower/arith/extended_range/blend.rs:1198 (unorm8)`; `crates/metal2vulkan/src/lower/arith/extended_range/blend.rs:1216 (unorm8)`; `crates/metal2vulkan/src/lower/arith/extended_range/blend.rs:1230 (unorm8)`; `crates/metal2vulkan/src/lower/arith/extended_range/blend.rs:1273 (packed16)`; `crates/metal2vulkan/src/lower/fragment/color.rs:215 (select_param)`; `crates/metal2vulkan/src/lower/fragment/color.rs:279 (unordered)`; `crates/metal2vulkan/src/lower/fragment/depth_test.rs:195 (not_implemented)`; `crates/metal2vulkan/src/lower/fragment/depth_test.rs:272 (depth_test_form)`; `crates/metal2vulkan/src/lower/fragment/depth_test.rs:318 (stencil_test_form)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1024 (storage_form)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1114 (storage_form)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1151 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1716 (plan_sample)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:749 (not_implemented)`; `crates/metal2vulkan/src/pipeline/link/fetch.rs:164 (storage_attachments)` -- `feature::PrimitiveId`: `crates/metal2vulkan-runtime/src/families/features.rs:1124 (state)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:3112 (finish)`; `crates/metal2vulkan/src/pipeline/link/varyings.rs:240 (check_primitive_id)` +- `feature::FramebufferFetch`: `crates/metal2vulkan-runtime/src/families/features.rs:1007 (state)`; `crates/metal2vulkan-runtime/src/render.rs:5709 (next_instance)`; `crates/metal2vulkan-runtime/src/sample_planes.rs:116 (lacks)`; `crates/metal2vulkan-runtime/src/sample_planes.rs:143 (new)`; `crates/metal2vulkan-runtime/src/sample_planes.rs:514 (planes_merge)`; `crates/metal2vulkan/src/bind/extended_shadow.rs:190 (extended_shadow_module)`; `crates/metal2vulkan/src/bind/graphics.rs:1453 (plan)`; `crates/metal2vulkan/src/bind/graphics.rs:1490 (plan)`; `crates/metal2vulkan/src/bind/graphics.rs:1509 (plan)`; `crates/metal2vulkan/src/bind/sample_planes.rs:477 (finish)`; `crates/metal2vulkan/src/device/metal.rs:252 (unsupported_features)`; `crates/metal2vulkan/src/lower/arith/extended_range/blend.rs:1198 (unorm8)`; `crates/metal2vulkan/src/lower/arith/extended_range/blend.rs:1216 (unorm8)`; `crates/metal2vulkan/src/lower/arith/extended_range/blend.rs:1230 (unorm8)`; `crates/metal2vulkan/src/lower/arith/extended_range/blend.rs:1273 (packed16)`; `crates/metal2vulkan/src/lower/fragment/color.rs:215 (select_param)`; `crates/metal2vulkan/src/lower/fragment/color.rs:279 (unordered)`; `crates/metal2vulkan/src/lower/fragment/depth_test.rs:195 (not_implemented)`; `crates/metal2vulkan/src/lower/fragment/depth_test.rs:272 (depth_test_form)`; `crates/metal2vulkan/src/lower/fragment/depth_test.rs:318 (stencil_test_form)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1024 (storage_form)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1114 (storage_form)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1151 (extended_range_blend)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:1716 (plan_sample)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs:749 (not_implemented)`; `crates/metal2vulkan/src/pipeline/link/fetch.rs:164 (storage_attachments)` +- `feature::PrimitiveId`: `crates/metal2vulkan-runtime/src/families/features.rs:1115 (state)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:3112 (finish)`; `crates/metal2vulkan/src/pipeline/link/varyings.rs:240 (check_primitive_id)` - `feature::VertexAmplification`: `crates/metal2vulkan/src/bind/graphics.rs:3897 (multiview_instances)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:1281 (own_index_store)`; `crates/metal2vulkan/src/lower/tessellation/mod.rs:718 (select_param)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:258 (vertex_amplification)`; `crates/metal2vulkan/src/pipeline/link/tessellation/mod.rs:228 (control_plan)` - `feature::LayeredRendering`: `crates/metal2vulkan-runtime/src/render_pass.rs:1658 (target)`; `crates/metal2vulkan-runtime/src/render_state.rs:1078 (needs_viewports)`; `crates/metal2vulkan/src/lower/mesh/mod.rs:778 (target_index)`; `crates/metal2vulkan/src/lower/mesh/mod.rs:797 (target_index)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:1282 (own_index_store)`; `crates/metal2vulkan/src/pipeline/link/geometry.rs:150 (not_implemented)`; `crates/metal2vulkan/src/pipeline/link/geometry.rs:172 (refused)` - `feature::ClipDistance`: `crates/metal2vulkan/src/lower/mesh/mod.rs:934 (select)`; `crates/metal2vulkan/src/lower/mesh/mod.rs:942 (select)` -- `feature::DualSourceBlending`: `crates/metal2vulkan-runtime/src/families/formats.rs:386 (answers)`; `crates/metal2vulkan/src/metal/state.rs:37 (blend_factor)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:1145 (check_outputs)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs:463 (rotated_blend)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs:538 (rotated_blend)` +- `feature::DualSourceBlending`: `crates/metal2vulkan-runtime/src/families/formats.rs:386 (answers)`; `crates/metal2vulkan/src/metal/state.rs:37 (blend_factor)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:1144 (check_outputs)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs:463 (rotated_blend)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs:538 (rotated_blend)` - `feature::Barycentrics`: `crates/metal2vulkan/src/device/metal.rs:263 (unsupported_features)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:1876 (input_builtin)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs:742 (param)`; `crates/metal2vulkan/src/pipeline/link/geometry.rs:148 (not_implemented)`; `crates/metal2vulkan/src/pipeline/link/geometry.rs:170 (refused)` -- `feature::StencilExport`: `crates/metal2vulkan-runtime/src/families/features.rs:1111 (state)`; `crates/metal2vulkan/src/bind/graphics.rs:2606 (shadow_stencil_words)`; `crates/metal2vulkan/src/lower/fragment/stencil.rs:157 (device_form)`; `crates/metal2vulkan/src/lower/fragment/stencil.rs:168 (not_implemented)`; `crates/metal2vulkan/src/pipeline/link/stencil.rs:55 (shadow_stencil)`; `crates/metal2vulkan/src/pipeline/link/stencil.rs:73 (shadow_stencil)` +- `feature::StencilExport`: `crates/metal2vulkan-runtime/src/families/features.rs:1102 (state)`; `crates/metal2vulkan/src/bind/graphics.rs:2606 (shadow_stencil_words)`; `crates/metal2vulkan/src/lower/fragment/stencil.rs:157 (device_form)`; `crates/metal2vulkan/src/lower/fragment/stencil.rs:168 (not_implemented)`; `crates/metal2vulkan/src/pipeline/link/stencil.rs:55 (shadow_stencil)`; `crates/metal2vulkan/src/pipeline/link/stencil.rs:73 (shadow_stencil)` - `feature::SampleRateShading`: `crates/metal2vulkan/src/pipeline/link/graphics.rs:832 (sample_invocations)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:834 (sample_invocations)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:916 (sample_invocations)` - `feature::PixelCoverageAtSampleRate`: `crates/metal2vulkan/src/lower/fragment/coverage.rs:291 (finish)`; `crates/metal2vulkan/src/lower/simd/mod.rs:754 (select_param)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:867 (sample_invocations)` - `feature::InterfaceComponents`: `crates/metal2vulkan/src/pipeline/compile/color_group.rs:202 (refusal)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs:301 (graphics_state)`; `crates/metal2vulkan/src/pipeline/link/varyings.rs:409 (assign)`; `crates/metal2vulkan/src/pipeline/link/varyings.rs:90 (limit_error)` @@ -375,7 +375,7 @@ Each refusal's sites, with the function that builds it. - `feature::Attribute`: `crates/metal2vulkan-air/src/bitcode/attrs.rs:493 (known)`; `crates/metal2vulkan/src/error/mod.rs:256 (from)` - `feature::BitcodeRecord`: `crates/metal2vulkan-air/src/bitcode/attrs.rs:337 (decode_lists)`; `crates/metal2vulkan-air/src/bitcode/function.rs:572 (symtab)`; `crates/metal2vulkan-air/src/bitcode/metadata.rs:130 (decode)`; `crates/metal2vulkan-air/src/bitcode/metadata.rs:157 (decode)`; `crates/metal2vulkan-air/src/bitcode/module.rs:727 (check_bodies)`; `crates/metal2vulkan-air/src/bitcode/module.rs:872 (symtab)`; `crates/metal2vulkan/src/error/mod.rs:257 (from)` - `feature::SyncScope`: `crates/metal2vulkan-air/src/bitcode/function.rs:1255 (atomic)`; `crates/metal2vulkan/src/error/mod.rs:258 (from)` -- `feature::SubgroupOperations`: `crates/metal2vulkan-runtime/src/families/features.rs:1695 (simd)`; `crates/metal2vulkan/src/lower/simd/mod.rs:407 (finish)`; `crates/metal2vulkan/src/lower/simd/mod.rs:466 (full_quads)`; `crates/metal2vulkan/src/lower/simd/mod.rs:990 (select_group)` +- `feature::SubgroupOperations`: `crates/metal2vulkan-runtime/src/families/features.rs:1686 (simd)`; `crates/metal2vulkan/src/lower/simd/mod.rs:407 (finish)`; `crates/metal2vulkan/src/lower/simd/mod.rs:466 (full_quads)`; `crates/metal2vulkan/src/lower/simd/mod.rs:990 (select_group)` - `feature::DirectCall`: `crates/metal2vulkan-air/src/canon/mod.rs:1319 (post_check)` - `feature::WideSwitchLiteral`: `crates/metal2vulkan/src/structurize/emit.rs:207 (check_tree)` - `feature::Lowering`: `crates/metal2vulkan/src/bind/plan/resources.rs:762 (level_views)`; `crates/metal2vulkan/src/lower/access/handle.rs:1062 (texture_target)`; `crates/metal2vulkan/src/lower/access/handle.rs:1073 (sampler_target)`; `crates/metal2vulkan/src/lower/access/handle.rs:318 (domain_kind)`; `crates/metal2vulkan/src/lower/access/imageblock.rs:175 (operand)`; `crates/metal2vulkan/src/lower/access/mod.rs:571 (not_lowered)`; `crates/metal2vulkan/src/lower/access/pulled.rs:76 (share)`; `crates/metal2vulkan/src/lower/arith/legal.rs:53 (not_lowered)`; `crates/metal2vulkan/src/lower/dispatch.rs:113 (not_lowered)`; `crates/metal2vulkan/src/lower/fragment/discard.rs:144 (not_lowered)`; `crates/metal2vulkan/src/lower/fragment/discard.rs:653 (plan)`; `crates/metal2vulkan/src/lower/fragment/mod.rs:123 (not_lowered)`; `crates/metal2vulkan/src/lower/fragment/snapshot.rs:168 (finish)`; `crates/metal2vulkan/src/lower/mesh/mod.rs:147 (not_lowered)`; `crates/metal2vulkan/src/lower/raytracing/mod.rs:126 (not_lowered)`; `crates/metal2vulkan/src/lower/sampler/mod.rs:212 (refuse)`; `crates/metal2vulkan/src/lower/sampler/select.rs:30 (refuse)`; `crates/metal2vulkan/src/lower/select.rs:829 (not_lowered)`; `crates/metal2vulkan/src/lower/select.rs:918 (route_air)`; `crates/metal2vulkan/src/lower/simd/mod.rs:136 (not_lowered)`; `crates/metal2vulkan/src/lower/simd/mod.rs:747 (select_param)`; `crates/metal2vulkan/src/lower/simd/workgroup.rs:353 (check)`; `crates/metal2vulkan/src/lower/stage_io/fetch.rs:96 (not_lowered)`; `crates/metal2vulkan/src/lower/stage_io/mod.rs:177 (not_lowered)`; `crates/metal2vulkan/src/lower/sync/barrier.rs:72 (not_lowered)`; `crates/metal2vulkan/src/lower/sync/memory_model.rs:269 (not_implemented)`; `crates/metal2vulkan/src/lower/sync/memory_model.rs:310 (select)`; `crates/metal2vulkan/src/lower/tessellation/mod.rs:146 (not_lowered)`; `crates/metal2vulkan/src/lower/texture/mod.rs:180 (refuse)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3665 (select_write)`; `crates/metal2vulkan/src/memory/alloca.rs:54 (not_lowered)`; `crates/metal2vulkan/src/memory/leaf.rs:183 (not_lowered)`; `crates/metal2vulkan/src/memory/plan.rs:490 (not_lowered)`; `crates/metal2vulkan/src/memory/provenance.rs:665 (not_lowered)`; `crates/metal2vulkan/src/pipeline/link/tessellation/mod.rs:96 (patch_fetch_projection)` @@ -395,13 +395,13 @@ Each refusal's sites, with the function that builds it. - `feature::SparseTexture`: `crates/metal2vulkan/src/bind/plan/slots.rs:583 (check_sparse_textures)`; `crates/metal2vulkan/src/bind/plan/slots.rs:607 (check_sparse_textures)` - `feature::TextureSize`: `crates/metal2vulkan-runtime/src/image_plan.rs:1196 (check_image_limits)` - `feature::TextureSampleCount`: `crates/metal2vulkan-runtime/src/image_plan.rs:1244 (check_image_limits)`; `crates/metal2vulkan-runtime/src/image_plan.rs:598 (plan_held)`; `crates/metal2vulkan-runtime/src/image_plan.rs:608 (plan_held)` -- `feature::TextureView`: `crates/metal2vulkan-runtime/src/binding_view.rs:156 (binding_view)`; `crates/metal2vulkan-runtime/src/texture.rs:5032 (view)`; `crates/metal2vulkan-runtime/src/texture/decoded_twin.rs:1420 (make_second_twin)`; `crates/metal2vulkan-runtime/src/texture/view_shadow.rs:298 (apart_refusal)`; `crates/metal2vulkan-runtime/src/view_plan.rs:433 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:483 (check_view)`; `crates/metal2vulkan-runtime/src/view_plan.rs:505 (check_view)` +- `feature::TextureView`: `crates/metal2vulkan-runtime/src/binding_view.rs:156 (binding_view)`; `crates/metal2vulkan-runtime/src/texture.rs:5033 (view)`; `crates/metal2vulkan-runtime/src/texture/decoded_twin.rs:1420 (make_second_twin)`; `crates/metal2vulkan-runtime/src/texture/view_shadow.rs:298 (apart_refusal)`; `crates/metal2vulkan-runtime/src/view_plan.rs:431 (check_format)`; `crates/metal2vulkan-runtime/src/view_plan.rs:481 (check_view)`; `crates/metal2vulkan-runtime/src/view_plan.rs:503 (check_view)` - `feature::TextureSwizzle`: `crates/metal2vulkan-runtime/src/binding_view.rs:167 (binding_view)`; `crates/metal2vulkan-runtime/src/texture.rs:980 (may_view)`; `crates/metal2vulkan/src/bind/plan/resources.rs:1102 (plain_texture)`; `crates/metal2vulkan/src/lower/sampler/select.rs:2587 (select_one)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3391 (select_read_as)`; `crates/metal2vulkan/src/lower/texture/mod.rs:3738 (select_write)`; `crates/metal2vulkan/src/lower/texture/slice.rs:307 (select)` -- `feature::MipmapGeneration`: `crates/metal2vulkan-runtime/src/blit_texture.rs:1796 (mipmaps)`; `crates/metal2vulkan-runtime/src/mipmap_pick.rs:37 (pick_mipmaps)`; `crates/metal2vulkan-runtime/src/mipmap_plan.rs:262 (plan_mipmaps)`; `crates/metal2vulkan-runtime/src/mipmap_plan.rs:270 (plan_mipmaps)`; `crates/metal2vulkan-runtime/src/mipmap_plan.rs:275 (plan_mipmaps)`; `crates/metal2vulkan-runtime/src/mipmap_plan.rs:304 (plan_mipmaps)`; `crates/metal2vulkan/src/bind/mipmap_filter.rs:973 (mipmap_filter_module)` +- `feature::MipmapGeneration`: `crates/metal2vulkan-runtime/src/blit_texture.rs:1787 (mipmaps)`; `crates/metal2vulkan-runtime/src/mipmap_pick.rs:37 (pick_mipmaps)`; `crates/metal2vulkan-runtime/src/mipmap_plan.rs:262 (plan_mipmaps)`; `crates/metal2vulkan-runtime/src/mipmap_plan.rs:270 (plan_mipmaps)`; `crates/metal2vulkan-runtime/src/mipmap_plan.rs:275 (plan_mipmaps)`; `crates/metal2vulkan-runtime/src/mipmap_plan.rs:304 (plan_mipmaps)`; `crates/metal2vulkan/src/bind/mipmap_filter.rs:973 (mipmap_filter_module)` - `feature::HostMemory`: `crates/metal2vulkan-runtime/src/host_memory.rs:393 (not_importable)`; `crates/metal2vulkan-runtime/src/host_memory.rs:433 (refuse_unwritable)`; `crates/metal2vulkan-runtime/src/host_memory.rs:652 (new)`; `crates/metal2vulkan-runtime/src/host_memory.rs:657 (new)`; `crates/metal2vulkan-runtime/src/host_memory.rs:675 (new)` -- `feature::GpuTimes`: `crates/metal2vulkan-runtime/src/command_buffer/mod.rs:2558 (gpu_times)` +- `feature::GpuTimes`: `crates/metal2vulkan-runtime/src/command_buffer/mod.rs:2542 (gpu_times)` - `feature::CountingVisibility`: `crates/metal2vulkan-runtime/src/visibility.rs:452 (check_mode)` -- `feature::ViewFormatReinterpretation`: `crates/metal2vulkan-runtime/src/view_plan.rs:570 (reinterpretation_refused)` +- `feature::ViewFormatReinterpretation`: `crates/metal2vulkan-runtime/src/view_plan.rs:568 (reinterpretation_refused)` - `feature::SeparateMultisampledDepthStencil`: `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:188 (sampled_candidate)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:294 (by_draws)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:336 (scratch)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:376 (scratch)`; `crates/metal2vulkan-runtime/src/depth_stencil_scratch.rs:777 (plan)`; `crates/metal2vulkan-runtime/src/nan_clear.rs:651 (nan_write)`; `crates/metal2vulkan-runtime/src/texture/signed_depth.rs:191 (sample_strip)` - `feature::PixelCoverage`: `crates/metal2vulkan/src/pipeline/link/graphics.rs:771 (split_pixel_fragments)` - `feature::CentroidVarying`: `crates/metal2vulkan/src/pipeline/link/graphics.rs:789 (split_pixel_fragments)` @@ -410,7 +410,7 @@ Each refusal's sites, with the function that builds it. - `feature::SparseMapping`: `crates/metal2vulkan-runtime/src/sparse/encoder.rs:466 (splits_a_unit)` - `feature::TimelineSemaphores`: `crates/metal2vulkan-runtime/src/device/create.rs:1053 (timeline_difference)` - `feature::Reflection`: `crates/metal2vulkan/src/bind/argument_buffer.rs:626 (unmeasured)`; `crates/metal2vulkan/src/reflection/derive.rs:178 (specialized_reads)`; `crates/metal2vulkan/src/reflection/derive.rs:212 (read_attributes)`; `crates/metal2vulkan/src/reflection/derive.rs:239 (gap_at)`; `crates/metal2vulkan/src/reflection/function.rs:172 (unmeasured)`; `crates/metal2vulkan/src/reflection/function.rs:366 (attribute)`; `crates/metal2vulkan/src/reflection/function.rs:437 (module_constants)`; `crates/metal2vulkan/src/reflection/linked.rs:125 (function)`; `crates/metal2vulkan/src/reflection/mod.rs:249 (stage)` -- `feature::HeapTextureTiling`: `crates/metal2vulkan-runtime/src/texture/heap.rs:565 (tiling_refusal)` +- `feature::HeapTextureTiling`: `crates/metal2vulkan-runtime/src/texture/heap.rs:614 (tiling_refusal)` - `feature::ViewportDepthRange`: `crates/metal2vulkan-runtime/src/render_state.rs:1186 (depth_ranges_refused)` - `feature::UndeclaredTextureUsage`: `crates/metal2vulkan-runtime/src/binding_view.rs:141 (binding_view)`; `crates/metal2vulkan-runtime/src/texture/usage_shadow.rs:72 (refused)` - `feature::RenderTargetSize`: `crates/metal2vulkan-runtime/src/render_pass.rs:1264 (framebuffer_fits)` @@ -424,11 +424,11 @@ Each refusal's sites, with the function that builds it. - `feature::SeqCstFence`: `crates/metal2vulkan/src/lower/sync/barrier.rs:443 (require_seq_cst)` - `gap::Textures`: `crates/metal2vulkan-runtime/src/blit_texture.rs:163 (check_depth_view)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:1554 (view_usage)`; `crates/metal2vulkan-runtime/src/pipeline/mod.rs:1499 (compile_error)`; `crates/metal2vulkan-runtime/src/texture.rs:1445 (image_error)`; `crates/metal2vulkan-runtime/src/texture.rs:2174 (storage_over_buffer)`; `crates/metal2vulkan-runtime/src/texture.rs:2986 (new_image_starting)`; `crates/metal2vulkan-runtime/src/texture.rs:4030 (image)`; `crates/metal2vulkan-runtime/src/texture.rs:5508 (host_copy)`; `crates/metal2vulkan-runtime/src/texture/surface_two_planes.rs:207 (new_surface_planes_texture)` - `gap::ResourceHeap`: `crates/metal2vulkan-runtime/src/binding.rs:2016 (descriptor)` -- `gap::SparseHeaps`: `crates/metal2vulkan-runtime/src/sparse/encoder.rs:458 (first_slice)`; `crates/metal2vulkan-runtime/src/texture.rs:1629 (plan_sparse_texture)`; `crates/metal2vulkan-runtime/src/texture.rs:4722 (make_aliasable)` +- `gap::SparseHeaps`: `crates/metal2vulkan-runtime/src/sparse/encoder.rs:458 (first_slice)`; `crates/metal2vulkan-runtime/src/texture.rs:1629 (plan_sparse_texture)`; `crates/metal2vulkan-runtime/src/texture.rs:4723 (make_aliasable)` - `gap::SparseTileMaps`: `crates/metal2vulkan-runtime/src/binding.rs:553 (slot_tile_map)`; `crates/metal2vulkan-runtime/src/sparse/texture.rs:30 (sparse_refusal)`; `crates/metal2vulkan-runtime/src/texture.rs:1662 (plan_sparse_texture)` - `gap::HeapPastMaxBufferSize`: `crates/metal2vulkan-runtime/src/heap.rs:694 (heap_size)` -- `gap::HeapTextureAlignment`: `crates/metal2vulkan-runtime/src/texture/heap.rs:980 (check_heap_base)` -- `gap::HeapTextureMemory`: `crates/metal2vulkan-runtime/src/texture/heap.rs:1418 (heap_plan)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1425 (heap_plan)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1919 (host_heap_plan)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2132 (memory_shadow)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:489 (memory_refusal)` +- `gap::HeapTextureAlignment`: `crates/metal2vulkan-runtime/src/texture/heap.rs:1017 (check_heap_base)` +- `gap::HeapTextureMemory`: `crates/metal2vulkan-runtime/src/texture/heap.rs:1459 (heap_plan)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1466 (heap_plan)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1985 (host_heap_plan)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2197 (memory_shadow)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:538 (memory_refusal)` - `gap::FunctionTablePastMaxBufferLength`: `crates/metal2vulkan-runtime/src/function_table.rs:622 (past_limit)` - `gap::IndirectCommandBufferPastMaxBufferLength`: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs:516 (new_indirect_command_buffer)` - `gap::IndirectRenderCommands`: `crates/metal2vulkan-runtime/src/compute.rs:1084 (execute_range)`; `crates/metal2vulkan-runtime/src/compute.rs:1163 (execute_indirect_range)`; `crates/metal2vulkan-runtime/src/depth_stencil.rs:85 (gpu_resource_id)`; `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs:3638 (render_state)`; `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs:511 (new_indirect_command_buffer)`; `crates/metal2vulkan-runtime/src/pipeline/mod.rs:1506 (compile_error)`; `crates/metal2vulkan-runtime/src/render.rs:6979 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:7342 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:7747 (draw_resident)`; `crates/metal2vulkan-runtime/src/render.rs:8196 (draw_resident)`; `crates/metal2vulkan-runtime/src/render/executions.rs:1086 (back_memoryless)`; `crates/metal2vulkan-runtime/src/render/executions.rs:1989 (record)`; `crates/metal2vulkan-runtime/src/render/executions.rs:2032 (record)`; `crates/metal2vulkan-runtime/src/render/executions.rs:2827 (record_forms)`; `crates/metal2vulkan-runtime/src/render/executions.rs:375 (execute_range)`; `crates/metal2vulkan-runtime/src/render/executions.rs:434 (execute_indirect_range)`; `crates/metal2vulkan-runtime/src/render/executions.rs:449 (execute_indirect_range)` @@ -452,52 +452,52 @@ Each refusal's sites, with the function that builds it. - `gap::TileAtSampleCount`: `crates/metal2vulkan-runtime/src/render_pass.rs:1600 (layout)`; `crates/metal2vulkan-runtime/src/render_pass.rs:930` - `gap::ImageblockMasters`: `crates/metal2vulkan-runtime/src/render.rs:7115 (draw_resident)`; `crates/metal2vulkan-runtime/src/render/tile_dispatch.rs:930 (dispatch_tiles_resident)` - `gap::TileAndFragmentImageblocks`: `crates/metal2vulkan-runtime/src/render.rs:7107 (draw_resident)`; `crates/metal2vulkan-runtime/src/render/tile_dispatch.rs:797 (dispatch_tiles_resident)`; `crates/metal2vulkan-runtime/src/render/tile_dispatch.rs:922 (dispatch_tiles_resident)` -- `gap::Metal4Api`: `crates/metal2vulkan-runtime/src/families/features.rs:1469 (state)`; `crates/metal2vulkan-runtime/src/families/limits.rs:1022 (state)`; `crates/metal2vulkan-runtime/src/families/mod.rs:362 (audit)` +- `gap::Metal4Api`: `crates/metal2vulkan-runtime/src/families/features.rs:1460 (state)`; `crates/metal2vulkan-runtime/src/families/limits.rs:1022 (state)`; `crates/metal2vulkan-runtime/src/families/mod.rs:362 (audit)` - `gap::CounterSampleBuffers`: `crates/metal2vulkan-runtime/src/families/limits.rs:1013 (state)` -- `gap::ResidencySets`: `crates/metal2vulkan-runtime/src/families/features.rs:1451 (state)`; `crates/metal2vulkan-runtime/src/families/limits.rs:1015 (state)` -- `gap::TextureAccessCounters`: `crates/metal2vulkan-runtime/src/families/features.rs:1438 (state)`; `crates/metal2vulkan-runtime/src/families/features.rs:1443 (state)` -- `gap::IoCommandQueues`: `crates/metal2vulkan-runtime/src/families/features.rs:1448 (state)`; `crates/metal2vulkan-runtime/src/families/limits.rs:1020 (state)` -- `gap::TextureViewPools`: `crates/metal2vulkan-runtime/src/families/features.rs:1452 (state)`; `crates/metal2vulkan-runtime/src/families/limits.rs:1021 (state)` -- `gap::ColorAttachmentMapping`: `crates/metal2vulkan-runtime/src/families/features.rs:1453 (state)` -- `gap::LossyTextureCompression`: `crates/metal2vulkan-runtime/src/families/features.rs:1447 (state)` -- `gap::ShaderValidation`: `crates/metal2vulkan-runtime/src/families/features.rs:1449 (state)` -- `gap::ShaderLogging`: `crates/metal2vulkan-runtime/src/families/features.rs:1450 (state)` -- `gap::DeviceNotifications`: `crates/metal2vulkan-runtime/src/families/features.rs:1454 (state)` +- `gap::ResidencySets`: `crates/metal2vulkan-runtime/src/families/features.rs:1442 (state)`; `crates/metal2vulkan-runtime/src/families/limits.rs:1015 (state)` +- `gap::TextureAccessCounters`: `crates/metal2vulkan-runtime/src/families/features.rs:1429 (state)`; `crates/metal2vulkan-runtime/src/families/features.rs:1434 (state)` +- `gap::IoCommandQueues`: `crates/metal2vulkan-runtime/src/families/features.rs:1439 (state)`; `crates/metal2vulkan-runtime/src/families/limits.rs:1020 (state)` +- `gap::TextureViewPools`: `crates/metal2vulkan-runtime/src/families/features.rs:1443 (state)`; `crates/metal2vulkan-runtime/src/families/limits.rs:1021 (state)` +- `gap::ColorAttachmentMapping`: `crates/metal2vulkan-runtime/src/families/features.rs:1444 (state)` +- `gap::LossyTextureCompression`: `crates/metal2vulkan-runtime/src/families/features.rs:1438 (state)` +- `gap::ShaderValidation`: `crates/metal2vulkan-runtime/src/families/features.rs:1440 (state)` +- `gap::ShaderLogging`: `crates/metal2vulkan-runtime/src/families/features.rs:1441 (state)` +- `gap::DeviceNotifications`: `crates/metal2vulkan-runtime/src/families/features.rs:1445 (state)` - `gap::RateMapRegions`: `crates/metal2vulkan-runtime/src/rate_mapped_pass.rs:349 (refusal)` - `gap::LayeredPass`: `crates/metal2vulkan-runtime/src/color_resolve.rs:890 (plan)` - `gap::FunctionOptions`: `crates/metal2vulkan-runtime/src/library.rs:215 (new_function_with_descriptor)` -- `gap::OverlappingTextureCopies`: `crates/metal2vulkan-runtime/src/blit_texture.rs:1251 (texture_copies_of_bytes)` -- `gap::RebindTextures`: `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:600 (rebind_host_pages)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2431 (rebound_heap_images)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2446 (rebound_heap_images)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2457 (rebound_heap_images)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2500 (dma_buf_heap_images_again)` +- `gap::OverlappingTextureCopies`: `crates/metal2vulkan-runtime/src/blit_texture.rs:1242 (texture_copies_of_bytes)` +- `gap::RebindTextures`: `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:600 (rebind_host_pages)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2503 (rebound_heap_images)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2518 (rebound_heap_images)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2529 (rebound_heap_images)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2572 (dma_buf_heap_images_again)` - `gap::PvrtcBlockOrder`: `crates/metal2vulkan-runtime/src/texture.rs:5580 (host_copy)` -- `gap::DecodedHeapTexture`: `crates/metal2vulkan-runtime/src/texture.rs:1637 (plan_sparse_texture)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1281 (heap_plan)` +- `gap::DecodedHeapTexture`: `crates/metal2vulkan-runtime/src/texture.rs:1637 (plan_sparse_texture)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:1319 (heap_plan)` - `gap::VertexFetchPast4GiB`: `crates/metal2vulkan-runtime/src/render/vertex_reach.rs:72 (check_vertex_reach)` - `gap::StageInFetchPast4GiB`: `crates/metal2vulkan-runtime/src/fetch_reach.rs:126 (check_stage_in_reach)` - `gap::MappedTextureSampling`: `crates/metal2vulkan-runtime/src/address_map.rs:158 (resolve)` - `gap::LibrarySource`: `crates/metal2vulkan-runtime/src/library.rs:107 (new_library_with_source)` - `gap::RestartedStrip`: `crates/metal2vulkan-runtime/src/index_rewrite.rs:110 (new)`; `crates/metal2vulkan-runtime/src/render.rs:7219 (draw_resident)` - `gap::PrimitiveIdIndices`: `crates/metal2vulkan-runtime/src/render.rs:7596 (draw_resident)` -- `gap::RotatedTexture`: `crates/metal2vulkan-runtime/src/blit_texture.rs:1580 (texel_copies)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:715 (turned_plane)`; `crates/metal2vulkan-runtime/src/rotated.rs:185 (new)`; `crates/metal2vulkan-runtime/src/rotated.rs:201 (new)`; `crates/metal2vulkan-runtime/src/shadow.rs:638 (unmerged)`; `crates/metal2vulkan-runtime/src/texture.rs:4990 (view)`; `crates/metal2vulkan-runtime/src/texture/rotation.rs:100 (check_rotated_reach)`; `crates/metal2vulkan-runtime/src/texture/rotation.rs:322 (copied_image)`; `crates/metal2vulkan-runtime/src/texture/usage_shadow.rs:238 (new_usage_shadow)` -- `gap::DetachTextures`: `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:604 (rebind_host_pages)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:622 (make_texture_over)`; `crates/metal2vulkan-runtime/src/detach.rs:152 (detach_host_pages)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2639 (heap_texture_at)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:143 (new_stand_in)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:248 (stand_in_while_detached)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:298 (stand_ins)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:304 (stand_ins)` +- `gap::RotatedTexture`: `crates/metal2vulkan-runtime/src/blit_texture.rs:1571 (texel_copies)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:715 (turned_plane)`; `crates/metal2vulkan-runtime/src/rotated.rs:185 (new)`; `crates/metal2vulkan-runtime/src/rotated.rs:201 (new)`; `crates/metal2vulkan-runtime/src/shadow.rs:642 (unmerged)`; `crates/metal2vulkan-runtime/src/texture.rs:4991 (view)`; `crates/metal2vulkan-runtime/src/texture/rotation.rs:100 (check_rotated_reach)`; `crates/metal2vulkan-runtime/src/texture/rotation.rs:322 (copied_image)`; `crates/metal2vulkan-runtime/src/texture/usage_shadow.rs:238 (new_usage_shadow)` +- `gap::DetachTextures`: `crates/metal2vulkan-runtime/src/buffer_descriptor.rs:604 (rebind_host_pages)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs:622 (make_texture_over)`; `crates/metal2vulkan-runtime/src/detach.rs:152 (detach_host_pages)`; `crates/metal2vulkan-runtime/src/texture/heap.rs:2712 (heap_texture_at)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:143 (new_stand_in)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:248 (stand_in_while_detached)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:298 (stand_ins)`; `crates/metal2vulkan-runtime/src/texture/stand_in.rs:304 (stand_ins)` - `gap::TextureBufferLevels`: `crates/metal2vulkan-runtime/src/texture_descriptor.rs:540 (check_made)` - `gap::WriteSwizzle`: `crates/metal2vulkan-runtime/src/texture_descriptor.rs:547 (check_made)` -- `gap::DetachedTexelAccess`: `crates/metal2vulkan-runtime/src/texture.rs:4820 (refuse_detached_texels)` -- `gap::SurfaceDepthStencil`: `crates/metal2vulkan-runtime/src/blit_texture.rs:240 (unit)`; `crates/metal2vulkan-runtime/src/texture/surface_depth.rs:57 (surface_depth_twin)` -- `gap::HostHeapUncompressedMultisample`: `crates/metal2vulkan-runtime/src/texture/heap.rs:1924 (host_heap_plan)` +- `gap::DetachedTexelAccess`: `crates/metal2vulkan-runtime/src/texture.rs:4821 (refuse_detached_texels)` +- `gap::SurfaceDepthStencil`: `crates/metal2vulkan-runtime/src/blit_texture.rs:236 (unit)`; `crates/metal2vulkan-runtime/src/texture/surface_depth.rs:57 (surface_depth_twin)` - `gap::PredicationUnbalanced`: `crates/metal2vulkan-runtime/src/predication.rs:371 (nil)`; `crates/metal2vulkan-runtime/src/predication.rs:403 (start_else)`; `crates/metal2vulkan-runtime/src/predication.rs:455 (end_if)`; `crates/metal2vulkan-runtime/src/predication.rs:575 (end_loop)` - `gap::PredicationOpenAtUnitEnd`: `crates/metal2vulkan-runtime/src/predication.rs:280 (commit_refusal)`; `crates/metal2vulkan-runtime/src/predication.rs:296 (commit)` - `gap::PredicationWordPastBuffer`: `crates/metal2vulkan-runtime/src/predication.rs:139 (new)` - `gap::PredicatedLoopDepth`: `crates/metal2vulkan-runtime/src/predication.rs:483 (start_loop)` - `gap::PredicatedLoopAcrossEncoders`: `crates/metal2vulkan-runtime/src/predication.rs:284 (commit_refusal)`; `crates/metal2vulkan-runtime/src/predication.rs:300 (commit)` -- `gap::MultisampledBufferCopy`: `crates/metal2vulkan-runtime/src/blit_texture.rs:489 (copy_from_buffer_to_texture)`; `crates/metal2vulkan-runtime/src/blit_texture.rs:645 (copy_from_texture_to_buffer)` +- `gap::MultisampledBufferCopy`: `crates/metal2vulkan-runtime/src/blit_texture.rs:485 (copy_from_buffer_to_texture)`; `crates/metal2vulkan-runtime/src/blit_texture.rs:641 (copy_from_texture_to_buffer)` - `gap::ColorAttachmentGroups`: `crates/metal2vulkan-runtime/src/render/color_groups.rs:106 (gap)` -- `apple::ProtectedContent`: `crates/metal2vulkan-runtime/src/apple_only.rs:189 (check)` -- `apple::LineWidth`: `crates/metal2vulkan-runtime/src/apple_only.rs:191 (check)` -- `apple::ProvokingVertexMode`: `crates/metal2vulkan-runtime/src/apple_only.rs:196 (check)` -- `apple::ViewportTransformDisabled`: `crates/metal2vulkan-runtime/src/apple_only.rs:193 (check)` -- `apple::VertexAmplificationMode`: `crates/metal2vulkan-runtime/src/apple_only.rs:199 (check)` -- `apple::DepthCleared`: `crates/metal2vulkan-runtime/src/apple_only.rs:201 (check)` -- `apple::StencilCleared`: `crates/metal2vulkan-runtime/src/apple_only.rs:202 (check)` +- `apple::ProtectedContent`: `crates/metal2vulkan-runtime/src/apple_only.rs:200 (check)` +- `apple::LineWidth`: `crates/metal2vulkan-runtime/src/apple_only.rs:202 (check)` +- `apple::ProvokingVertexMode`: `crates/metal2vulkan-runtime/src/apple_only.rs:207 (check)` +- `apple::ViewportTransformDisabled`: `crates/metal2vulkan-runtime/src/apple_only.rs:204 (check)` +- `apple::VertexAmplificationMode`: `crates/metal2vulkan-runtime/src/apple_only.rs:210 (check)` +- `apple::DepthCleared`: `crates/metal2vulkan-runtime/src/apple_only.rs:212 (check)` +- `apple::StencilCleared`: `crates/metal2vulkan-runtime/src/apple_only.rs:213 (check)` - `apple::SurfaceClientDirection`: `crates/metal2vulkan-runtime/src/buffer_texture.rs:417 (new_texture_with_iosurface_plane)` +- `apple::FillUnmeasured`: `crates/metal2vulkan-runtime/src/blit_fill.rs:149 (unmeasured)` - `bind::DescriptorRangeExceeded`: `crates/metal2vulkan/src/bind/instantiate.rs:652 (bind_buffers)` - `bind::TexelBufferTooLarge`: `crates/metal2vulkan/src/bind/instantiate.rs:891 (texel_ranges)` - `bind::HeapTooLarge`: `crates/metal2vulkan/src/bind/heap.rs:1014 (new)`; `crates/metal2vulkan/src/bind/heap.rs:1748 (directory_bytes)`; `crates/metal2vulkan/src/bind/heap.rs:1863 (listed_sampler_tables)`; `crates/metal2vulkan/src/bind/heap.rs:1913 (placed)`; `crates/metal2vulkan/src/bind/heap.rs:2069 (heap_elements)`; `crates/metal2vulkan/src/bind/heap.rs:949 (new)`; `crates/metal2vulkan/src/bind/heap.rs:965 (new)` diff --git a/scripts/refusal-surface/reach.tsv b/scripts/refusal-surface/reach.tsv index 0f02bae5b..77b87c948 100644 --- a/scripts/refusal-surface/reach.tsv +++ b/scripts/refusal-surface/reach.tsv @@ -223,7 +223,6 @@ feature PrivateRenderState none Apple-private pipeline fields of OpenGL on Metal gap SurfaceDepthStencil rare a blit of the stencil of a Depth32Float_Stencil8 texture over a plane of an IOSurface with planes, or a pass on an X32_Stencil8 one's view as Depth32Float_Stencil8 feature ExtendedRangeBlend system the parts of a blend into an extended-range (XR10) attachment the measured model does not hold (second-source factors, the color blend color difference, a one-color-channel mask, float4 and sRGB outside the measured forms); the consumer's guests blend RGB10A8_2P_XR10 attachments feature TileReach app the tiles a pass's draws reach, binned on a device without shaderInt64 -gap HostHeapUncompressedMultisample none a multisample texture Metal keeps uncompressed in a runtime extension's heap over host pages feature CommandPredication none Apple-private command predication on a device without buffer device addresses feature ProgramScopeBinding app MSL 3.2 program-scope buffer bindings (macOS 15 and later) feature SeqCstFence rare a seq_cst fence in a vertex or fragment stage without its stores and atomics