Translator: a storage slot its function only queries binds a swizzled texture unswizzled

A guest's OpenCL kernel that only queries a write-only image Apple's OpenCL binds as a swizzled
view (CL_BGRA over an RGBA8Unorm view, and on an M3 Max every CL_UNORM_INT8 order but RGBA and
RGBx) failed: the plan joins a storage slot to the swizzled-storage variant only where its
function reads or writes texels, so a query-only slot kept the texture's swizzle on its storage
view, which Vulkan cannot swizzle, and the runtime refused the binding
(NotImplemented(TextureSwizzle)). The guest then read zeros.

A query reads no texel, and what it answers (the view's size, levels and layers; an OpenCL
image's order and data type, which the third hidden buffer holds) no swizzle reaches. Measured
on an M3 Max, macOS 27.0.1 (probe opencl_swizzled_images, job m3-max-16336): plain Metal's
get_width/get_height of a swizzled view at an access::write slot answer the view's size, and
OpenCL mode's width, height, order and data-type queries answer the size and the hidden words,
on every swizzle measured. So the plan now binds such a slot's storage view with no swizzle
(ImageViewDesc::shader_swizzle, under no variant): exact.

The same probe confirms the rest of the contract the crate already builds, in plain Metal and
OpenCL mode alike: reads (read(), read_write, sample, read_imagef with and without a sampler)
answer the swizzled texel, and writes (access::write, read_write, write_imagef) store it with
the swizzle undone. The channel order table and the swizzle never both apply: the table answers
queries only, the swizzle moves texels only.

Docs: ImageViewDesc::shader_swizzle, the runtime's binding_view and view_plan, docs/API.md's
OpenCL-mode images. REFUSALS.md regenerated, unchanged.

SEMANTICS_VERSION 2033.
This commit is contained in:
Anees Iqbal committed 2026-11-11 09:37:09 -08:00
1 parent 2e9d3c1e44
commit e8418615f1
6 files changed
+25 -8

No files matched your search

+8 -1
View File
@@ -768,7 +768,14 @@ layout stride of `None` is `MTLBufferLayoutStrideDynamic`: the stride comes from
height 1 for an `image1d_array_t` (`texture1d_array`). In the mode the kernel's slot is that
texture's type (`TextureType::Type2D`, `Type2DArray`), and each read, sample and write of the
image, `get_image_width` and `get_image_array_size` is the 2D texture's at row 0 (a sampled
coordinate at the row's centre), as both Macs answer.
coordinate at the row's centre), as both Macs answer. Apple's OpenCL binds an image of most
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.
A storage slot the kernel only queries binds the texture's view with no swizzle.
- OpenCL C's `native_<function>` and `half_<function>` of `float` types
(`air.native_<stem>.<type>` and `air.half_<stem>.<type>`, for `cos`, `exp`, `exp10`, `exp2`,
`log`, `log10`, `log2`, `powr`, `rsqrt`, `sin`, `sqrt` and `tan`, scalar and of every vector