Byte copies: the kernel's heap slot is the kernel stage's; the draw's docs, the README's and API.md's lines, and the device test's all-codes row and counts

The translator's sample kernel named its heap slot under a stage that does not exist (Stage::Kernel
is the compute stage's); fixed with the other error the first build (lavapipe job m3-max-84536)
reported. The runtime README states the measured layout, the form, the refusals left with their
causes, and names this caller on the stencil-export known gap; API.md documents own_draw and
SamplesToBytes and catalogues PrecisionNote::RoundedSampleDepthCopy. The device test gains a
128 x 128 Depth16Unorm row at 4 samples whose 65,536 units are every code once, checks every unit
of the copy back out, and asserts the counts: 2 sample copies a row, and 8 stencil bit draws for a
stencil row on a device without stencil export, else none.
This commit is contained in:
Anees Iqbal committed 2026-12-03 09:59:39 -08:00
1 parent cfe1e81775
commit b337c83e25
4 files changed
+142 -27

No files matched your search

+30
View File
@@ -308,6 +308,23 @@ the runtime's, the command line's, the compile worker's and every validation too
into the parameter block `pipeline::ExecutionCounts` lays out, where each part's
`sequenceCountAddress` reads it. Its interface is a compiled function's: the one push range,
holding the block's device address at offset 0, and no descriptor.
- **A blit's copy between a buffer and a multisample texture's samples.** No Vulkan copy command
takes a multisample image, so a runtime moves a stencil's or a 16-bit depth's samples with
modules built from no Metal function, in Metal's layout as measured (copy unit `i` of a row of
the region is texel `i / n` of the row, sample `i % n`, for `n` samples). Out of the texture,
`pipeline::own_kernel(OwnKernel::SamplesToBytes { aspect, arrayed }, profile)`: a compute
stage of `SampleBytes::WORKGROUP` invocations a workgroup along x, one a unit, dispatched with
`ceil(width * samples / 64)` workgroups along x and one a row of the region along y, which reads
each sample through set 1's sampled-image array (binding 0) at the texture's element and stores
its unit (a 16-bit depth as the code nearest its value) at a device address. Into it,
`pipeline::own_draw(write, profile)`: a vertex stage that draws one triangle over the viewport
from `VertexIndex` 0 to 2 and a fragment stage, run once a sample (it reads `SampleId`; the
pipeline enables sample shading at 1), that reads its unit at a device address and writes it
as `SampleWrite` says: `FragDepth` for a 16-bit depth (`PrecisionNote::RoundedSampleDepthCopy`),
`FragStencilRefEXT`, or, on a device without stencil export, no output, the invocation demoted
where the bit `SampleBytes::BIT_AT` names is clear in its unit, for a draw a bit. Both take
`SampleBytes`' parameter block, its device address the one push field at offset 0
(`PushField::ArgumentTableAddress`).
- **A kernel's bound buffers** (`DeviceProfile::binds_kernel_buffers`). Under the identity
domains, on a device that answers this query, a kernel reaches each buffer argument through a
storage buffer of set 0 bound over that buffer, not at its address. The descriptor covers the
@@ -2005,6 +2022,19 @@ category, and says what makes an operation carry the note and what may differ. E
before the draw, where Metal tests a later fragment against the depth an earlier one wrote. A
draw whose fragments reach each sample at most once (a quad of two triangles, one fullscreen
triangle) stores Metal's values.
- `metal2vulkan-degrade-rounded-sample-depth-copy` (precision).
`PrecisionNote::RoundedSampleDepthCopy`: A copy of bytes into the 16-bit depth
(`Depth16Unorm`) of a multisample texture by a blit's copy from a buffer, on every device. On
`metal2vulkan-runtime` it is the static note `Texture::SAMPLE_DEPTH_COPY_NOTE` of
`copy_from_buffer_with_options` into one, decided by the format, never by the bytes. No Vulkan
copy command writes a multisample image, so the runtime draws the bytes in
(`pipeline::own_draw` of `SampleWrite::Depth16`): each sample's fragment writes the code `c` it
reads as `FragDepth`, `(c + 1/4) / 65535` (1 for 65535), and the device converts that `float` to
a code, which Vulkan's fixed-point conversion lets be either of the two codes nearest it
(`convertFloatToUint`). A device that rounds to nearest, as Vulkan says implementations should,
or toward zero stores `c`, Metal's code: the `float`'s error is far below a quarter code. Cost:
a device that rounded up would store `c + 1`, one code above Metal's, which a later depth test
or read sees.
- `metal2vulkan-degrade-cube-gradient-footprint` (precision).
`PrecisionNote::CubeGradientFootprint`: An explicit-gradient sample of a cube texture takes
Metal's footprint in the form Vulkan's rule reads, in every stage on every device. Cost: the