The owned fixture tess_primitive_ids (MSL we wrote, its companions
regenerated on the Mac, job m3-max-80275) is a post-tessellation vertex
function (triangle patches of three control points, no stage-in) that places
patch pid of instance iid in its own tile of an 8x8 target and passes pid and
iid flat, and a fragment function that writes [[primitive_id]], pid, iid and 1.
Metal's answer, read on an Apple M3 Max (job m3-max-80266, the same shape at
64x32, every factor 4 with the integer partition): every fragment of every
triangle of a patch reads one value, the patch's position in its draw,
patch start included, the same in each instance. A draw of two patches from
patch 0 over two instances reads 0 and 1 in both; a draw of two patches from
patch 2 reads 2 and 3. Vulkan's PrimitiveId behind an evaluation stage counts
the draw's patches from 0 and restarts in each instance, so it reads 0 and 1
for the second draw.
every_device_reads_a_patch_s_position_as_its_fragments_primitive_id draws
both in one pass and checks every covered texel of each drawn tile, and that
the tiles no patch draws stay clear. Today the translator refuses the
pipeline: Tessellation, NotImplemented, at link (a fragment function that
reads [[primitive_id]] behind an evaluation stage).
Red on lavapipe (llvmpipe), job m3-max-80279: "Tessellation; needs
NotImplemented" for the state; the control draw passes.