Files
metal2vulkan/docs
Anees Iqbal abb3c82247 rt: a copy between two textures over one buffer whose bytes meet copies in slabs
copy_from_texture recorded one vkCmdCopyImage when its source and destination were two
different textures in place over one buffer (each a linear image on the buffer's bytes) whose
regions' bytes meet, which Vulkan forbids (VUID-vkCmdCopyImage-pRegions-00124: no memory both a
source and a destination of one command). Only regions of one subresource of one image were
cut into slabs. Metal leaves such a copy undefined; an Apple M3 Max gives each destination texel
what the source held before the copy (the conformance crate's buffer_texture_blits rows
within-buffer-a-row-on and -reversed).

A texture in place now names where its texels lie: the VkBuffer commands reach the buffer's bytes
through (one per allocation, spanning it), the first texel's offset there and the row pitch the
device reports for the linear image (Rows, Side::rows). Where both textures of a copy lie in one
VkBuffer, texture_copy finds every pair of a destination row and a source row whose bytes meet
(meeting: a source row meets at most the two destination rows whose starts lie nearest it, as a
pitch is at least a row; nothing to look at where the two regions' spans of bytes do not meet)
and feeds their shifts to the slab chooser of 7c1baad228, generalized to take several shifts
(cut): an axis every shift moves along, all one way, is cut no thicker than the least shift in
whole texels (bytes along x, rows along y), the end the shifts point to first, so no slab's
source and destination share a byte and no slab reads a byte an earlier one wrote; the axis of
fewest slabs wins, as before. One subresource of one image is the one-shift case and cuts as
before. Regions on the same bytes copy nothing. Regions whose bytes do not meet, interleaved rows
included, stay one command.

Where along each axis the rows meet shifted both ways, or not shifted (a destination row across
the end of its own source row and the start of the next, or rows of two pitches meeting at their
starts), no cut along one axis keeps the order: Gap::TextureCopy names that arm now, its doc,
docs/REFUSALS.md (regenerated) and the rt README's blit section with it, instead of an invalid
command. No scratch image, no cap, no copy of the runtime's own.

Tests: regions_of_two_textures_over_one_buffer_copy_in_slabs_where_their_bytes_meet checks the
slabs (a row on both ways with the regions' order, two rows on, two texels on within the rows
both ways, a row and two texels on), the gap (whole rows two texels on; two pitches meeting),
one slab for interleaved rows of one pitch and of two and for another buffer, and nothing for
the same bytes. On a device, every_device_copies_between_textures_over_one_buffer_from_the_source_before_the_copy
makes four RGBA8 textures in place over one Shared buffer at the device's own pitch (asserted in
place) and copies a row on and a row back, a memory alignment on within the rows on and back,
and apart, each expecting the whole buffer to hold the source's bytes from before the copy and
everything else kept, one submission, 2 + slabs barriers, no byte copied; the gap case is refused
and records nothing.
2026-11-21 07:08:04 -08:00
..