Core Image's CIKL general kernels take their sampler as a struct with a
reference field, a type kind the AIR reader did not know: such a kernel's
signature read as unknown, and its reflection fell back to Metal's own
function, which has none on our device, so Core Image made no kernel.
The reader now knows every kind Metal compiles into a stitchable signature:
lvalue and rvalue references (read as pointers), void pointees, bfloat and
its vectors, enums, visible and intersection function tables, acceleration
structures, atomics whose struct has no fields, each type's address space,
and unnamed arguments. The builder answers them as Metal's own compiler
does, measured on our own stitchable functions (tests/air_arguments.metal)
on an M3 Max on macOS 27 and an AMD Radeon Pro 5300M on macOS 26.7.1:
enums and tables are of no data type, a pointer is sized by its innermost
pointee and not at all for opaque ones, a pointed-to texture takes its
address space as its access, and a field's pointer to a pointer is
described by its pointee's pointee. A signature that holds an acceleration
structure gets no reflection: Metal's own ends the process on it, and
Metal's own function on our device answers nil.
reflection_check compares a refused signature with Metal's own answer,
asked in a process of its own; it reports 0 differences on both devices
over the test library and Core Image's own libraries.
On our device a stitchable function's -returnType and -arguments were nil:
Metal makes them with the device's compiler, which our device does not have,
and the shadow (Metal's own function over the same library) asks that same
device. Core Image reads them to make a kernel of a CIKL string, so
CIColorKernel and CIWarpKernel kernels, among others, were not made (the
sweep's ci.kernel.color and ci.kernel.warp).
A visible function now answers -returnType, -arguments and -bindings (the
same array) from the signature its library reads (c5e740050), made once:
Metal's own reflection objects, each through its class's initialiser
(RgfxReflection.h; the initialisers are declared in RgfxMetalPrivate.h from
the runtime's method lists), holding what Metal's own compiler gives. Structs
carry their members whole: names, offsets, data types and nested types. A
visible function that is not stitchable answers nil and an empty array, as
Metal does. Where the signature has a type the reader does not know, or Metal
lacks a class or initialiser, the shadow answers as before, logged once.
What Metal's compiler gives was measured on an M3 Max (macOS 27) and an AMD
Radeon Pro 5300M (macOS 26.7.1), which agree, including its quirks: a nested
struct's type is nameless, an array of vectors or matrices has element type
137 or 136 and a stride of its alignment, a struct field's pointer describes
its pointee otherwise than an argument's, and a metal::array has no data type.
tools/reflection_check.mm (make reflection-check) compares ours with Metal's
getter by getter, each getter tried in a forked child first, as some end the
process where they do not apply. Over tests/air_arguments.metal's nine visible
functions, 3602 values, none differ on either machine.
shell_tests' test_stitchable_reflection_from_air checks the answers equal to
Metal's own (-isEqual: both ways, same classes), field by field for what Core
Image reads, made once and asking no shadow, and the fallback.
Checks: make -C guest/bundle test package on the M3 Max; reflection_check on
the M3 Max and the AMD Mac.