Translator: OpenCL-mode image arguments reflect as the textures bound, of no data type

What: AIR names an OpenCL C image's component `unknown` (`texture1d<unknown, read>`), which the
reflection's type grammar did not parse, so a pipeline of OpenCL mode with an image argument had
no reflection (Unsupported, Feature::Reflection, naming the type). Now:
- reflection/types.rs: a texture whose component AIR names `unknown` reflects data type
  DataType::None;
- canon::opencl::entry, the entry as a pipeline of OpenCL mode binds it: a 1D image's texture is
  the 2D one Metal's OpenCL binds (`texture1d<..>` -> `texture2d<..>`, `texture1d_array<..>` ->
  `texture2d_array<..>`, bound_texture), as canon::opencl_1d already reads it, so its binding
  reflects TextureType::Type2D / Type2DArray.
Only the reflection reads an argument's type name; lowering and binding are unchanged.

Why: Metal states exactly that. The probe opencl_image_reflection on the M3 Max (macOS 27.0.1,
job m3-max-16390) reflects every image of an OpenCL-mode pipeline as MTLDataTypeNone, whether
read as float, int, uint or half, written, only queried or unused; image1d_t as 2D and
image1d_array_t as 2DArray (as the clmode-images probe found on the M3 Max and a Radeon Pro
5300M). The data type is not the element type a kernel reads: Metal answers None for every one.

Tests: engine_opencl_mode::an_opencl_mode_pipeline_reflects_its_images_as_the_textures_bound_of_no_data_type
reflects an owned fixture (image1d_t arguments read as float, int, uint and half, an
image1d_array_t, a write-only image1d_t, a buffer) and holds each texture binding to the M3 Max's
answer (type, None, access, not depth, length 1) and the buffers to theirs; before this commit
its reflection is refused. reflection::tests::the_type_grammar_names_textures parses the
`unknown` component.

Docs: canon::opencl's module docs and docs/API.md's OpenCL-mode images.

SEMANTICS_VERSION 2033: a reflection the translator refused it now answers.
This commit is contained in:
Anees Iqbal committed 2026-11-11 09:54:16 -08:00
1 parent 49175d0a24
commit 2fc317f6e3
5 files changed
+183 -4

No files matched your search

+5 -1
View File
@@ -777,7 +777,11 @@ layout stride of `None` is `MTLBufferLayoutStrideDynamic`: the stride comes from
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.
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
`unknown`) whatever the kernel reads it as, as an M3 Max (macOS 27.0.1) answers for 1D, 1D
array, 2D and 3D images read as float, int, uint and half, written, only queried and unused.
- 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