From ff94af82143bf69b162ddaebef96f158cdf540d0 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Fri, 20 Nov 2026 11:20:54 -0800 Subject: [PATCH] conformance: the texture-over-buffer cases say what the runtime refuses buffer_tails and texture_buffer_tails said the runtime's texels lie in the buffer's memory past its length, as a buffer holds its allocation rounded to 16 KiB. The runtime refuses texels past the buffer (Refusal::BufferTextureLayout, texture.rs check_over; the rt ledger's buffer-tails rows record that refusal) and builds no texture buffer (Gap::TextureBuffer). Each module now says so, and keeps why the case asks the 20000-byte shape: Metal's answer there is one a case can compare. buffer_textures and buffer_texture named a refusal that does not exist (BufferTextureProblem::RowPitch) and an `Invalid` answer the runtime has no error for; a pitch equal to the row is taken (check_over requires only whole texels at least a row apart). They now name Refusal:: BufferTextureLayout for a 2D texture and Gap::TextureBuffer for the stride row's texture buffer, and the table's doc names the test that holds it away from Metal's assertion in place of a device test the module does not have. Docs only. The stride row's committed recording keeps the old words in its timing half (a measured run's stop reason), which the recording test excludes. --- .../src/buffer_texture.rs | 5 +-- .../src/cases/buffer_tails.rs | 14 ++++---- .../src/cases/buffer_textures.rs | 33 ++++++++++--------- .../src/cases/texture_buffer_tails.rs | 9 +++-- 4 files changed, 32 insertions(+), 29 deletions(-) diff --git a/crates/metal2vulkan-conformance/src/buffer_texture.rs b/crates/metal2vulkan-conformance/src/buffer_texture.rs index c7ad3bedd..94a32f838 100644 --- a/crates/metal2vulkan-conformance/src/buffer_texture.rs +++ b/crates/metal2vulkan-conformance/src/buffer_texture.rs @@ -175,8 +175,9 @@ impl BufferTextureRequest { /// /// The one shape: a row pitch below the texture's own row. The AGX driver fails /// `bytes_per_row >= used_bytes_per_row` and ends the process, so the suite's standing rule — no -/// case may end Metal's process — forbids the call outright. The runtime refuses it typed -/// (`BufferTextureProblem::RowPitch`), which is what a case of this shape pins. +/// case may end Metal's process — forbids the call outright. The runtime refuses it typed, which +/// is what a case of this shape pins: a 2D texture whose rows are closer than a row is +/// `Refusal::BufferTextureLayout`, and the texture buffer the case asks is `Gap::TextureBuffer`. /// /// A pitch **at or above** the row is refused by nothing here: a texture buffer takes any pitch /// that covers its texels (measured: 300 bytes over a 256-byte row), and a 2D texture's own rules diff --git a/crates/metal2vulkan-conformance/src/cases/buffer_tails.rs b/crates/metal2vulkan-conformance/src/cases/buffer_tails.rs index 47bece689..4421cd064 100644 --- a/crates/metal2vulkan-conformance/src/cases/buffer_tails.rs +++ b/crates/metal2vulkan-conformance/src/cases/buffer_tails.rs @@ -9,12 +9,14 @@ //! holds before anything writes it is the allocation's: over a buffer of 4096 bytes, whose //! `allocatedSize` is its length, it is the buffer allocated next, which no case can state; over //! a buffer of 20000 bytes, whose `allocatedSize` is 32768, it is the rest of the buffer's own -//! allocation, and it reads zero. The runtime's lie in the buffer's memory too, as a buffer of -//! 16 KiB or more holds its allocation, its length rounded up to 16 KiB, zero when made, so this -//! family asks the second shape, where -//! Metal's answer is one a case can compare: a 16 by 256 `RGBA8Uint` texture at -//! offset 4096, its rows 64 bytes apart, over 20000 bytes. Its rows 0 to 247 lie inside the -//! length, row 248 crosses it 32 bytes (8 texels) in, and rows 249 to 255 lie past it. +//! allocation, and it reads zero. So this family asks the second shape, where Metal's answer is +//! one a case can compare: a 16 by 256 `RGBA8Uint` texture at offset 4096, its rows 64 bytes +//! apart, over 20000 bytes. Its rows 0 to 247 lie inside the length, row 248 crosses it 32 bytes +//! (8 texels) in, and rows 249 to 255 lie past it. +//! +//! The runtime makes no such texture: texels past the buffer are refused +//! (`Refusal::BufferTextureLayout`, its README, Textures), as they would lie in memory the buffer +//! does not hold, so each case's run of it ends at that refusal. //! //! - `buffer-tails-kernels` reads the texture through the format scout's `scout_read_u` and //! `getBytes:` as made, after `scout_write_u` wrote every texel, and after `replaceRegion:` diff --git a/crates/metal2vulkan-conformance/src/cases/buffer_textures.rs b/crates/metal2vulkan-conformance/src/cases/buffer_textures.rs index 3a6d3beb5..86e0fd4b0 100644 --- a/crates/metal2vulkan-conformance/src/cases/buffer_textures.rs +++ b/crates/metal2vulkan-conformance/src/cases/buffer_textures.rs @@ -26,8 +26,10 @@ //! [`MetalSource::did_not_return`]: its recording is written by hand, record mode refuses it, and //! [`crate::buffer_texture::ends_metals_process`] refuses the call on the Metal side as the second //! line of defence. What the case pins is the one fact there is — Metal did not come back — against -//! our typed refusal (`BufferTextureProblem::RowPitch`) at the same site, so a release where we -//! stop refusing it reads as a divergence rather than as a pass. +//! the runtime's typed error at the same site, so a release where it answers reads as a divergence +//! rather than as a pass. The row is a texture buffer, which the runtime does not build +//! (`Gap::TextureBuffer`); a 2D texture whose rows are closer than a row is +//! `Refusal::BufferTextureLayout`. //! //! # What is deliberately not a case, and why //! @@ -74,9 +76,9 @@ pub fn all() -> Vec> { /// The shapes the making case asks about, in the order it asks them. /// -/// Every row is one the runtime answers — a texture or Metal's own nil — and a device test of this -/// module holds the table to that, because a row the runtime answers `Invalid` for is a row -/// record mode would hand to Metal's assertion. +/// No row is a shape the guard refuses ([`crate::buffer_texture::ends_metals_process`]), and a +/// test of this module holds the table to that (`no_recorded_shape_would_end_metals_process`), +/// because such a row is one record mode would hand to Metal's assertion. fn requests() -> Vec { let mut rows = Vec::new(); // A texture buffer of 64 `R32Uint` texels: its row is 256 bytes. @@ -135,11 +137,10 @@ fn requests() -> Vec { rows.push( Request::texture_2d(BUFFER, PixelFormat::R32Uint, [3, 2], 4, 256, 32).used(READ_WRITE), ); - // A one-byte format at a pitch far wider than its row. Measured while writing this table: a - // pitch of 8 — the row exactly — is refused `Invalid` by the runtime, which by its own model - // means Metal stops the call, so the row that reached Metal is the padded one. Which pitches a - // 2D linear texture takes is Metal's own rule and belongs in the refusal surface rather than - // here, where it cannot be asked safely. + // A one-byte format at a pitch far wider than its row. The runtime takes any pitch of whole + // texels at least a row long (`Refusal::BufferTextureLayout` refuses the rest); which pitches + // Metal takes for a 2D linear texture is Metal's own rule and belongs in the refusal surface + // rather than here, where it cannot be asked safely, so the row asks a padded one. rows.push( Request::texture_2d(BUFFER, PixelFormat::R8Unorm, [8, 8], 1, 0, 256).used(READ_WRITE), ); @@ -223,8 +224,8 @@ const ASSERTED_IN: &str = "AGX's own assertion text, which this suite's own whol const ASSERTED_SAYS: &str = "a texture over a buffer whose bytesPerRow is below the texture's own row fails AGX's \ assertion `bytes_per_row >= used_bytes_per_row`, which ends Metal's process in the call; the \ - runtime refuses it typed (BufferTextureProblem::RowPitch) and that refusal is what the row \ - pins"; + runtime refuses it typed (it builds no texture buffer, Gap::TextureBuffer) and that refusal \ + is what the row pins"; /// The runs behind the answer: the finding met the assertion once and the process ended with it. const ASSERTED_RUNS: u32 = 1; @@ -767,8 +768,8 @@ mod tests { assert_eq!(sites.len(), total, "two shapes of the table share a site"); } - /// Every shape the bytes case lays over a buffer is also a row of the making table, whose - /// device guard has shown the runtime answers it. + /// Every shape the bytes case lays over a buffer is also a row of the making table, which the + /// guard holds away from Metal's assertion (`no_recorded_shape_would_end_metals_process`). /// /// Without this, the bytes case's safety would be a coincidence: its program makes its /// textures as resources, and a resource Metal stops would end the recorder's process before @@ -788,8 +789,8 @@ mod tests { }); assert!( found, - "{}: its shape is not a row of the making table, so nothing has shown the runtime \ - answers it and record mode would hand it to Metal unguarded", + "{}: its shape is not a row of the making table, so no test holds it away from \ + Metal's assertion and record mode would hand it to Metal unguarded", row.key ); } diff --git a/crates/metal2vulkan-conformance/src/cases/texture_buffer_tails.rs b/crates/metal2vulkan-conformance/src/cases/texture_buffer_tails.rs index 93562b22a..5ef078f92 100644 --- a/crates/metal2vulkan-conformance/src/cases/texture_buffer_tails.rs +++ b/crates/metal2vulkan-conformance/src/cases/texture_buffer_tails.rs @@ -9,11 +9,10 @@ //! (`probes/texture_buffer_past_length.m`, an Apple M3 Max under macOS 27.0.1). Over a 4096-byte //! buffer, whose `allocatedSize` is its length, that memory is the buffer allocated next, which no //! case can state; over a 20000-byte buffer, whose `allocatedSize` is 32768, it is the rest of the -//! buffer's own allocation, and it reads zero. The runtime's lie in the buffer's memory too, as a -//! buffer of 16 KiB or more holds its allocation, its length rounded up to 16 KiB, zero when -//! made, which its functions view in place. So the case asks the second shape: 1024 `R32Uint` -//! texels from byte 16384 of a 20000-byte buffer, the first 904 inside the -//! length and the last 120 past it. +//! buffer's own allocation, and it reads zero. So the case asks the second shape, where Metal's +//! answer is one a case can compare: 1024 `R32Uint` texels from byte 16384 of a 20000-byte +//! buffer, the first 904 inside the length and the last 120 past it. The runtime builds no texture +//! buffer (`Gap::TextureBuffer`, its README, Textures), so no run of it reaches the texels. //! //! `buffer-tails-texture-buffer` reads texels through `ob1_texel_buffer` (the owned fixture whose //! thread `t` of eight reads texel `idx[t]` of its first texture buffer and writes `0xA0000000 |