SEMANTICS 2133 / RUNTIME 2425: OpenCL mode: a 1D image bound to a real 1D texture reads it, through a variant

An OpenCL-mode kernel declares each image1d_t / image1d_array_t slot as the 2D texture of
height 1 Apple's OpenCL binds (canon::opencl::entry, canon::opencl_1d). A real 1D or 1D array
texture is a VK_IMAGE_TYPE_1D image, which takes only 1D views (Table 18,
VUID-VkImageViewCreateInfo-subResourceRange-01021), and a 1D view cannot sit in the slot's
Dim 2D descriptor (VUID-vkCmdDispatch-viewType-07752). So the binder wrote the declared 2D
type's neutral (PlanDiagnostic::IncompatibleBinding) and every read answered zero, outside
both measured answers (Radeon Pro 5300M: the 1D values; UHD 630: layer 0 of the array).

Now a per-slot variant keyed by the bound texture's type:
- air: Entry::open_cl_1d_images records the texture indices of an OpenCL-mode kernel's 1D
  images; SpecRequest::open_cl_lines names those a 1D texture is bound for, whose parameter
  keeps its texture1d type (opencl::entry) and whose operations stay 1D (opencl_1d::expand
  skips a call whose texture operand is that parameter).
- The kernel states RuntimeFact::OpenClLineTexture { slot } (Mechanism::Variant) per 1D image,
  in the base and the variant alike; nothing else states it.
- The compute plan puts such a slot in VariantKey::open_cl_lines where the shape binds a
  Type1D (Type1DArray) texture at a 1D (array) image read by the kernel
  (bind::plan::slots::open_cl_line_variant). VariantKey::lowering_inputs carries it to
  LoweringInputs::open_cl_lines, the specialized-entry cache key and SpecRequest. The variant's
  interface states the slot Type1D / Type1DArray, so its plan binds the 1D view and states the
  same key. The answer is the 5300M's.

With the set empty (Apple's 2D bindings) canon, the SPIR-V and the VariantKey are as before;
the base artifact gains only the OpenClLineTexture facts. The reflection still states the 2D
types. No runtime source changes.

Tests: canon::tests::opencl::opencl_1d_images_bound_to_1d_textures_keep_their_1d_operations,
engine_opencl_mode::an_opencl_mode_kernel_reads_real_1d_textures_through_its_variant and
a_plain_2d_texture_slot_given_a_1d_texture_binds_the_neutral; the runtime's
opencl_mode_1d_images_read_real_1d_textures (the repro).

SEMANTICS_VERSION 2133. api_signatures blessed (5 records); REFUSALS unchanged; docs/API.md's
OpenCL images paragraph.

Also e1aba1ad67 (the repro test), 9f3b309b65 and 8f2677c0ae (compile fixes: an Idx import; every SpecRequest literal names open_cl_lines).

Verified in the lane at 8f2677c0ae: lavapipe (m3-max-35393) OpenCL-mode runtime tests 19/19, the
new opencl_mode_1d_images_read_real_1d_textures among them (it failed at e1aba1ad67, m3-max-35348:
[0,0,0,0] for [10,11,12,13]); the 2D height-1 read and write tests pass at both. air OpenCL tests
9/9 (m3-max-35386). Still running when landed: the translator's engine_opencl_mode and api tests,
clippy x3, rustdoc, executor parity (runtime_lane::executions, runtime_run), the probe comparing
the guest 2D path's SPIR-V, facts and plan at base and tip, the PHOENIX run.

RUNTIME 2425 because the runtime's variant choice moves (bind::plan::slots); no runtime source
changed. New Degradation kinds: none.
This commit is contained in:
Anees Iqbal committed 2026-11-15 23:13:43 -08:00
1 parent 84a75db279
commit 59fc85ea83
27 files changed
+603 -66

No files matched your search

+7 -1
View File
@@ -1026,7 +1026,13 @@ through buffer arguments it reads at any index.
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. Apple's OpenCL binds an image of most
coordinate at the row's centre), as both Macs answer. A real 1D texture bound for an
`image1d_t`, or a 1D array texture for an `image1d_array_t`, which Apple's OpenCL never binds,
takes the kernel's variant that declares that slot as the 1D texture
(`RuntimeFact::OpenClLineTexture`, `VariantKey::open_cl_lines`): each read, sample and size
query answers the 1D texture's values, of the layer an array access names, as a Radeon Pro
5300M (macOS 26.7.1) answers (an Intel UHD Graphics 630 reads layer 0 of the array, an M3 Max
texel 0 at every coordinate). 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