diff --git a/crates/metal2vulkan-runtime/src/buffer_texture.rs b/crates/metal2vulkan-runtime/src/buffer_texture.rs index 34404260c..365aae553 100644 --- a/crates/metal2vulkan-runtime/src/buffer_texture.rs +++ b/crates/metal2vulkan-runtime/src/buffer_texture.rs @@ -395,10 +395,13 @@ impl Buffer { } /// The stand-in for `newTextureWithDescriptor:iosurface:plane:` over the caller's memory: a - /// 2D texture of `descriptor` whose texels are `plane`'s, the buffer standing for the - /// IOSurface (a no-copy buffer over the surface's pages, `IOSurfaceGetBaseAddress` for - /// `IOSurfaceGetAllocSize` bytes, or a buffer holding them). Metal's IOSurface rules apply, - /// measured on the M3 Max and an M4, not [`new_texture`](Self::new_texture)'s buffer rules: + /// texture of `descriptor` whose texels are `plane`'s, the buffer standing for the IOSurface + /// (a no-copy buffer over the surface's pages, `IOSurfaceGetBaseAddress` for + /// `IOSurfaceGetAllocSize` bytes, or a buffer holding them): a 2D texture or a texture buffer, + /// and over a plane of a surface with planes also a 1D texture whose row fits and a 2D array + /// of one slice, laid out as the 2D texture of their rows (a texture buffer's texels run on + /// from such a plane's offset however wide). Metal's IOSurface rules apply, measured on the M3 + /// Max and an M4, not [`new_texture`](Self::new_texture)'s buffer rules: /// /// - the texture takes and reports the descriptor's resource options, whatever the buffer's /// (its default hazard tracking mode resolves to tracked), as an M4's plain run and its @@ -435,9 +438,13 @@ impl Buffer { /// Refused: a surface made with `kIOSurfaceClientDirection`, SPI /// ([`AppleOnly::SurfaceClientDirection`](super::AppleOnly::SurfaceClientDirection)); what /// Metal stops (`Invalid`, with a [`TextureProblem`](super::TextureProblem) or a - /// [`BufferTextureProblem`](super::BufferTextureProblem): a type other than 2D, more than one - /// level, a pitch below the row, a surface without planes at another pitch or offset, or one - /// whose rows end past it, which plain Metal asserts on); `Memoryless` storage, which plain + /// [`BufferTextureProblem`](super::BufferTextureProblem): over a surface without planes a + /// type other than 2D or a texture buffer, more than one level, a pitch below the row, another + /// pitch or offset, or rows that end past it, which plain Metal asserts on); what Metal makes + /// over a plane of a surface with planes and lays out no one way across the GPUs measured + /// (`NotImplemented(SurfacePlaneShape)`, which carries the measurements: rows wider than the + /// plane's, more than one level, another type, a 2D array of slices, a texture buffer or BC + /// texture at an offset or pitch off 16 bytes); `Memoryless` storage, which plain /// Metal makes and serves on the CPU while its GPU uses fail the command buffer /// (`NotImplemented(MemorylessSurfacePlane)`, which carries the measurement); rows that /// overlap on Metal's GPU where no shadow of the runtime's holds them @@ -459,6 +466,14 @@ impl Buffer { /// `texture/surface_depth.rs` lists. Over a surface without planes Metal stops it (`Invalid`, /// `BufferTextureProblem::NotLinear`). /// + /// A BC1 to BC7 texture over a surface's rows (2D, over a plane of a surface with planes at an + /// offset and pitch that are multiples of 16) is made as the x86 Macs make it, where the M3 + /// Max answers nil: row `j` of its blocks at the plane's offset + `j` x `bytes_per_row`, which + /// its samples, blits and CPU calls take (`linear_plan.rs`'s **Block-compressed surfaces**). + /// Over a surface without planes Metal stops a row of blocks wider than the surface's + /// (`RowPitch`) and rows of texels past it (`PastBuffer`). Every other compressed format is + /// stopped as over a buffer (`NotLinear`). + /// /// A plane of a 4:2:2 format (`GBGR422`, `BGRG422`: a CoreVideo `2vuy` or `yuvs` surface's) /// is made as Metal makes it, 2 bytes a texel, copied as a 4:2:2 texture of the device's is /// (`linear_plan.rs`). diff --git a/crates/metal2vulkan-runtime/src/error.rs b/crates/metal2vulkan-runtime/src/error.rs index 5d4cedd8e..4433d4e8e 100644 --- a/crates/metal2vulkan-runtime/src/error.rs +++ b/crates/metal2vulkan-runtime/src/error.rs @@ -1403,8 +1403,13 @@ pub enum RuntimeGap { /// bytes its buffer's allocation has past the length (a 2D texture, a texture buffer and a 2D /// array alike, up to the allocation, past which Metal answers nil: /// [`Problem::BufferTexture`]'s `PastAllocation`), or a texture over a plane of a surface - /// with planes whose rows or GPU texels run past the buffer standing for the surface, which - /// Metal reads as zeros there: the runtime's buffers have no bytes there. + /// with planes whose rows or GPU texels run past the buffer standing for the surface: the + /// runtime's buffers have no bytes there. Metal lays those in no one place + /// (`metal2vulkan-conformance/probes/surface_texture_envelope.m`, an Apple M3 Max under + /// macOS 27.0.1): its blits read zeros past the surface, its kernels zeros and, 32 KiB on, the + /// surface's first bytes again, its `getBytes` other memory, and its blits and + /// `replaceRegion` write the surface's bytes alone. The x86 Macs' are not measured, as a read + /// past a surface can fault their GPUs. TexelsPastBufferLength, /// A texture of an IOSurface plane (`Buffer::new_texture_with_iosurface_plane`, the stand-in /// for `newTextureWithDescriptor:iosurface:plane:`) whose rows overlap on Metal's GPU: more @@ -1434,7 +1439,7 @@ pub enum RuntimeGap { /// the stand-in for `newTextureWithDescriptor:iosurface:plane:`) that Metal makes and whose /// texels it lays out no one way: rows wider than the plane's `bytesPerRow`, more than one mip /// level, a 2D array of more than one slice, a 3D, cube or multisample texture or any other - /// type but 2D, a texture buffer, 1D and a 2D array of one slice, a 1D texture wider than the + /// type but 2D, a texture buffer, 1D or a 2D array of one slice, a 1D texture wider than the /// plane's row, a BC texture of another type than 2D or wider than the plane's rows, and a /// texture buffer or BC texture over a plane at an offset or `bytesPerRow` off 16 bytes. /// diff --git a/crates/metal2vulkan-runtime/src/linear_plan.rs b/crates/metal2vulkan-runtime/src/linear_plan.rs index d90b03cd7..b89aba06f 100644 --- a/crates/metal2vulkan-runtime/src/linear_plan.rs +++ b/crates/metal2vulkan-runtime/src/linear_plan.rs @@ -158,6 +158,43 @@ //! (`texture/surface_depth.rs`, which lists what stays the runtime's gap, //! `NotImplemented(RuntimeGap::SurfaceDepthStencil)`, with a blit of the stencil of //! `Depth32Float_Stencil8`). +//! - **Block-compressed surfaces** (an AMD Radeon Pro 5300M and an Intel UHD 630 under macOS +//! 26.7.1, `metal2vulkan-conformance/probes/surface_texture_envelope.m`; the consumer's +//! `oracle_surftex` 66, 67, 125, 131 to 135, 147 and 148). The x86 Macs make a BC1 to BC7 +//! texture over a surface's rows wherever they fit, over a surface with planes or without, in +//! `Managed` or `Private` storage; the M3 Max answers nil. Their blits (a `Private` +//! texture's too), `getBytes`, the UHD 630's `replaceRegion` and both GPUs' samples take block +//! row `j` at the plane's offset + `j` × `bytesPerRow`, the row its blocks' bytes (8 or 16 a +//! block, [`surface_blocks`]), a last block of a row or column whole however few of its texels +//! the texture covers. Over a surface without planes Metal stops a row of blocks wider than the +//! surface's ("Descriptor rowBytes (264) > IOSurface rowBytes (256)": `RowPitch`) and texels +//! past the surface's rows, counted in rows of texels ("Descriptor height*arrayLength > +//! IOSurface height": `PastBuffer`). The runtime lays such a texture out as those rows of blocks +//! (a shadow image, or an aliasing one where the device's linear image holds the format): its +//! shadow copies them as the texels they hold (`plane_copy_regions`), and its blits and CPU calls +//! count a region in blocks (`blit_plan::texel_rows`, `Texels::region_layout`). Over a plane of +//! a surface with planes it holds a 2D one at an offset and `bytesPerRow` that are multiples of +//! 16, the planes measured; any other is the runtime's gap ([`BufferRefusal::PlaneShape`]). Two +//! answers of the 5300M's are not reproduced: its `replaceRegion` wrote other bytes than the +//! texture's past the first row of blocks, and some of its blits into a BC texture over a +//! surface, and of its `replaceRegion` calls, ended the process. Every other compressed format +//! over a surface is no buffer's (`NotLinear`). +//! - **Beyond the plane's rows** (the same probe, on those two and the M3 Max under macOS +//! 27.0.1). Over a plane of a surface with planes Metal makes a texture of any type, extent and +//! levels (`oracle_surftex` 17, 21, 42, 116 to 123, 127, 129), but the three GPUs and their CPU +//! calls lay out alike only a texture buffer (its texels contiguous from the plane's offset, +//! however wide: past the plane's row too on the M3 Max and the 5300M, where the UHD 630's +//! kernels read other bytes), a 1D texture whose row fits and a 2D array of one slice, each +//! where the 2D texture of its rows lies; the runtime makes those. Every other shape lies +//! differently on each, or was not measured: [`BufferRefusal::PlaneShape`] +//! ([`RuntimeGap::SurfacePlaneShape`](crate::RuntimeGap::SurfacePlaneShape), which carries the +//! measurements). A texture taller than its plane is held as the M3 Max's GPU and CPU lay it +//! out, its rows past the plane at the plane's pitch, inside the surface; the x86 Macs' GPUs +//! keep it to the plane (the UHD 630's reads other bytes there and drops the writes, the 5300M's +//! reads zeros and its blit into it writes nothing), which the runtime does not, as it is given +//! no plane's height. Rows past the surface's end lie in no one place either (the M3 Max's +//! blits read zeros there, its kernels wrap to the surface's start 32 KiB on, its `getBytes` +//! reads other memory, and its writes keep to the surface): [`BufferRefusal::TexelsPastLength`]. //! //! The runtime holds both layouts: the GPU's ([`Placed::gpu`]) is the texture's texels for every //! command, the copies of its shadow, an aliasing image and their hazards; the CPU's diff --git a/crates/metal2vulkan/tests/api_signatures.tsv b/crates/metal2vulkan/tests/api_signatures.tsv index 13ebcdec8..12a3cee38 100644 --- a/crates/metal2vulkan/tests/api_signatures.tsv +++ b/crates/metal2vulkan/tests/api_signatures.tsv @@ -12150,6 +12150,7 @@ variant metal2vulkan-runtime::RuntimeGap::SparseHeaps SparseHeaps variant metal2vulkan-runtime::RuntimeGap::SparseTileMaps SparseTileMaps variant metal2vulkan-runtime::RuntimeGap::StageInFetchPast4GiB StageInFetchPast4GiB { buffer_index: u32, reach: u64 } variant metal2vulkan-runtime::RuntimeGap::SurfaceDepthStencil SurfaceDepthStencil { pixel_format: PixelFormat } +variant metal2vulkan-runtime::RuntimeGap::SurfacePlaneShape SurfacePlaneShape variant metal2vulkan-runtime::RuntimeGap::TexelsPastBufferLength TexelsPastBufferLength variant metal2vulkan-runtime::RuntimeGap::TextureAccessCounters TextureAccessCounters variant metal2vulkan-runtime::RuntimeGap::TextureBufferLevels TextureBufferLevels diff --git a/docs/FAST-PATHS.md b/docs/FAST-PATHS.md index 58ac26a21..a4cb2ef2f 100644 --- a/docs/FAST-PATHS.md +++ b/docs/FAST-PATHS.md @@ -1006,6 +1006,16 @@ else. read settles nothing. A rotated plane never reaches any of this: its `bytesPerRow` must be a multiple of 16, so its GPU rows lie at the pitch itself and share no byte. +- **Textures over an IOSurface plane past one 2D image of its rows are refused.** Over a plane of + a surface with planes Metal makes a texture of any type, extent and levels, but its GPUs lay out + alike only a texture buffer, a 1D texture whose row fits and a 2D array of one slice + (`probes/surface_texture_envelope.m`, an AMD Radeon Pro 5300M, an Intel UHD 630 and an Apple M3 + Max); rows wider than the plane's, more levels, slices, a 3D, cube or multisample texture, and + a texture buffer or BC texture at an offset or pitch off 16 are + `NotImplemented(SurfacePlaneShape)`, and rows past the surface's end + `NotImplemented(TexelsPastBufferLength)`. A texture taller than its plane, inside the surface, + is held as the M3 Max lays it out (its rows on at the plane's pitch); the x86 Macs' GPUs keep it + to the plane, which the runtime cannot, as `IoSurfacePlane` gives no plane height. - **A shadow's merge back to host pages stores each changed word alone after a command that leaves texels it does not write** (a kernel's or a blit's partial writes among them; a render pass that loads and stores its attachment inside its scissors, and a command that replaces diff --git a/docs/REFUSALS.md b/docs/REFUSALS.md index 48d678c48..d70f09831 100644 --- a/docs/REFUSALS.md +++ b/docs/REFUSALS.md @@ -28,7 +28,7 @@ Columns: | Kind | Variants | With a site | Reach system | Reach app | Reach rare | Reach none | Unassessed | |---|---|---|---|---|---|---|---| | Translator and front-end refusals | 128 | 128 | 6 | 32 | 71 | 19 | 0 | -| Runtime gaps | 73 | 73 | 1 | 8 | 46 | 18 | 0 | +| Runtime gaps | 74 | 74 | 1 | 8 | 47 | 18 | 0 | | Apple-only calls | 4 | 4 | 0 | 0 | 0 | 4 | 0 | | Binder refusals at a device limit | 9 | 9 | 0 | 1 | 7 | 1 | 0 | | Translation caps | 14 | 14 | 0 | 0 | 7 | 7 | 0 | @@ -42,7 +42,7 @@ Columns: | Kind | `metal-measured` | `metal-documented` | `metal-takes` | `device` | `ours` | `unknown` | `delegated` | `-` | |---|---|---|---|---|---|---|---|---| | Translator and front-end refusals | 0 | 0 | 0 | 48 | 57 | 0 | 0 | 23 | -| Runtime gaps | 0 | 0 | 0 | 0 | 73 | 0 | 0 | 0 | +| Runtime gaps | 0 | 0 | 0 | 0 | 74 | 0 | 0 | 0 | | Apple-only calls | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 4 | | Binder refusals at a device limit | 0 | 0 | 0 | 9 | 0 | 0 | 0 | 0 | | Translation caps | 0 | 0 | 0 | 0 | 14 | 0 | 0 | 0 | @@ -208,6 +208,7 @@ Columns: | `TexelsPastBufferLength` | A texture over a buffer whose texels run past the buffer's length, which Metal makes over bytes its buffer's allocation has past the length (a 2D... | every device (runtime piece not built) | `ours` | 2: `crates/metal2vulkan-runtime/src/buffer_texture.rs (refusal_error)`, `crates/metal2vulkan-runtime/src/texture/surface_depth.rs (surface_depth_twin)` | `rare`: a texture over a buffer past its length | | `OverlappingSurfaceRows` | A texture of an IOSurface plane (`Buffer::new_texture_with_iosurface_plane`, the stand-in for `newTextureWithDescriptor:iosurface:plane:`) whose... | every device (runtime piece not built) | `ours` | 4: `crates/metal2vulkan-runtime/src/blit_plan.rs (plan_texels_rows_copy)`, `crates/metal2vulkan-runtime/src/blit_texture.rs (buffer_into_texture)` (+2) | `rare`: an IOSurface plane whose rows overlap | | `MemorylessSurfacePlane` | A texture of an IOSurface plane (`Buffer::new_texture_with_iosurface_plane`, the stand-in for `newTextureWithDescriptor:iosurface:plane:`) whose... | every device (runtime piece not built) | `ours` | 1: `crates/metal2vulkan-runtime/src/buffer_texture.rs (refusal_error)` | `rare`: a memoryless texture over an IOSurface plane | +| `SurfacePlaneShape` | A texture over a plane of an IOSurface with planes (`Buffer::new_texture_with_iosurface_plane`, the stand-in for... | every device (runtime piece not built) | `ours` | 1: `crates/metal2vulkan-runtime/src/buffer_texture.rs (refusal_error)` | `rare`: a texture over an IOSurface plane past one 2D image of its rows | | `IndirectCommandPastSize` | A command of an indirect command buffer at or past its size (`indirectComputeCommandAtIndex:`, `indirectRenderCommandAtIndex:`) | every device (runtime piece not built) | `ours` | 1: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (command_at)` | `none`: an indirect command at or past the buffer's size | | `ExecutionRangePastBuffer` | An `MTLIndirectCommandBufferExecutionRange` whose 8 bytes run past the buffer it is read from (`execute_commands_in_buffer_indirect`, a compute... | every device (runtime piece not built) | `ours` | 1: `crates/metal2vulkan-runtime/src/indirect_execute.rs (check_range_buffer)` | `rare`: an execution range whose 8 bytes run past its buffer | | `ExecutionRangeOffFour` | An `MTLIndirectCommandBufferExecutionRange` read at an offset that is not a multiple of 4 bytes (`execute_commands_in_buffer_indirect`, a compute... | every device (runtime piece not built) | `ours` | 1: `crates/metal2vulkan-runtime/src/indirect_execute.rs (check_range_buffer)` | `rare`: an execution range at an offset off 4 bytes | @@ -714,6 +715,7 @@ Each refusal's sites, with the function that builds it. - `gap::TexelsPastBufferLength`: `crates/metal2vulkan-runtime/src/buffer_texture.rs (refusal_error)`; `crates/metal2vulkan-runtime/src/texture/surface_depth.rs (surface_depth_twin)` - `gap::OverlappingSurfaceRows`: `crates/metal2vulkan-runtime/src/blit_plan.rs (plan_texels_rows_copy)`; `crates/metal2vulkan-runtime/src/blit_texture.rs (buffer_into_texture)`; `crates/metal2vulkan-runtime/src/blit_texture.rs (texel_copies)`; `crates/metal2vulkan-runtime/src/buffer_texture.rs (refusal_error)` - `gap::MemorylessSurfacePlane`: `crates/metal2vulkan-runtime/src/buffer_texture.rs (refusal_error)` +- `gap::SurfacePlaneShape`: `crates/metal2vulkan-runtime/src/buffer_texture.rs (refusal_error)` - `gap::IndirectCommandPastSize`: `crates/metal2vulkan-runtime/src/indirect_command_buffer.rs (command_at)` - `gap::ExecutionRangePastBuffer`: `crates/metal2vulkan-runtime/src/indirect_execute.rs (check_range_buffer)` - `gap::ExecutionRangeOffFour`: `crates/metal2vulkan-runtime/src/indirect_execute.rs (check_range_buffer)`