From 0bb092f8fff1ea73eda2f917555a47021b390094 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Fri, 27 Nov 2026 05:11:07 -0800 Subject: [PATCH] API docs: a kernel's write through a channel-permuting swizzled view is stored as written Section 10's Kernels gains the accepted difference: the runtime stores a kernel's write through a texture view whose swizzle permutes its format's channels as written, where the M3 Max stores it through the swizzle (an RGBA8Unorm (Blue, Green, Red, Alpha) view's write of (0x33, 0x66, 0xb3, 0xcc) leaves (0xb3, 0x66, 0x33, 0xcc); swizzled_view_stores.m, job m3-max-76829) and Metal's validation refuses the write, the view reporting no ShaderWrite usage. The OpenCL images paragraph said a write stores the value with the swizzle undone, which is the M3's answer, not the runtime's; it now states the runtime's rule and points to the entry. Docs only; the rule is the runtime's README's ("A swizzle reaches a texture's sampled element alone") and the lane's write test asserts it. --- docs/API.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/API.md b/docs/API.md index 3300dfce0..726741b97 100644 --- a/docs/API.md +++ b/docs/API.md @@ -829,9 +829,10 @@ through buffer arguments it reads at any index. channel orders as a swizzled view (on an M3 Max, macOS 27.0.1, with `CL_UNORM_INT8`: `CL_R`, `CL_RG`, `CL_A`, `CL_RA` and `CL_INTENSITY` as `R8Unorm` or `RG8Unorm` views, `CL_BGRA`, `CL_ARGB` and `CL_RGB` as `RGBA8Unorm` views). A read (with a sampler or without) answers the - swizzled texel, a write stores it with the swizzle undone (each channel from the first lane - whose source it is), and a query answers the view's size and the hidden buffer's words, which - no swizzle reaches, as plain Metal answers for the same view; the order is never applied twice. + swizzled texel and a query answers the view's size and the hidden buffer's words, which no + swizzle reaches, as plain Metal answers for the same view; the order is never applied twice. A + write stores the value as written, where the M3 Max stores it with the swizzle undone (each + channel from the first lane whose source it is; section 10, Kernels). A storage slot the kernel only queries binds the texture's view with no swizzle. The reflection states each image argument as the texture bound for it, an `image1d_t` `TextureType::Type2D` and an `image1d_array_t` `Type2DArray`, of data type `DataType::None` (the AIR names its component @@ -2883,6 +2884,12 @@ named states the rule in full. for `get_local_size`, `get_global_size` and `get_num_groups`, as OpenCL C defines them. The M3 Max (macOS 27.0.1) leaves unwritten the store of `get_global_id(3) + get_local_size(4) + get_global_size(5)`, where the runtime stores 2. +- **A kernel's write through a texture view whose swizzle permutes its format's channels is + stored as written** (`metal2vulkan-runtime`'s `Texture::new_texture_view_with_swizzle`), where + an Apple M3 Max (macOS 27.0.1) stores it through the swizzle (a write of `(0x33, 0x66, 0xb3, + 0xcc)` through an `RGBA8Unorm` view of `(Blue, Green, Red, Alpha)` leaves `(0xb3, 0x66, 0x33, + 0xcc)`, `crates/metal2vulkan-conformance/probes/swizzled_view_stores.m`) and Metal's validation + refuses the write, the view reporting no `ShaderWrite` usage. **Queues and command buffers**