Files
metal2vulkan/docs
Anees Iqbal dd04f204e1 Report an argument-buffer handle at the size it occupies
Metal spells a resource-handle member of an argument buffer with the type it
points AT -- `char` for a `device char *`, `float4x3` for a `device float4x3 *`,
`texture2d<half, sample>` for a texture, an opaque class name for a
`device Foo *` -- while the member itself stores an eight-byte handle. Reading
that name as the member's storage put a 64-byte matrix where the buffer holds an
address, and shifted the meaning of every member after it. `MTLGenericBVHData`
reported a 120-byte member layout for its 72-byte argument, with eight of its
nine members mistyped.

The member's `air.indirect_argument` node already says which it is, and nothing
read it: `air.indirect_constant` is the one role that means "stored inline";
`air.buffer`, `air.texture`, `air.sampler`, `air.indirect_buffer`, and the
pipeline-state / command-buffer roles are all references. `parse_struct_info`
walked past that suffix to find the next member; it now binds it to the member it
trails, exactly as `embedded::embedded_argument_members` does, and lets the role
decide. An unrecognized role is treated as a reference, since the declared size
describes the bytes either way while a handle mistaken for its pointee corrupts
the rest of the layout.

Over 2880 corpus sources the split is clean: 63,137 members carry no suffix or an
`air.indirect_constant` one and every single one of them agrees with its name;
2,762 carry a resource role and every single one of them declares eight bytes.
1,736 of those were mis-sized before -- 795 named a primitive of the wrong width
across 9 type names, 941 named a type AIR never defines, which silently became a
four-byte float.

This is not only a reporting fix. Twenty-one modules' SPIR-V changes, because
`infer_metadata_buffer_pointees` types a buffer from the same reconstruction:
they declared four-byte floats at eight-byte member offsets and now declare the
addresses AIR does. No corpus source changes status, and spirv-val is clean over
all 2880.

Reflection schema v36.
2026-09-01 01:00:13 +03:00
..