Commit Graph
6748 Commits
Author SHA1 Message Date
Anees Iqbal 56e7f3770f tests: the workgroup layout census also checks each module's requirements name neither the explicit layout's extension nor its four features
The floor's extension and features are needed only if a module requires
them, which the requirement set states beside the declared capabilities:
a layout rule can ask for workgroupMemoryExplicitLayoutScalarBlockLayout
without a capability of its own.
2026-11-17 19:17:15 -08:00
Anees Iqbal 4022e00dc0 tests: the workgroup layout census counts the modules whose threadgroup arena is sized at run time apart from those with fixed-size Workgroup variables
A module whose [[threadgroup(n)]] regions the binder sizes from the encoder's
threadgroup memory lengths declares its arena as a Workgroup array whose
length is a specialization constant. The census now reports those modules
apart from the ones with only fixed-size Workgroup variables, so the claim
that no module needs the explicit layout's capabilities is shown on the
modules that use threadgroup memory sized at run time.
2026-11-17 19:17:15 -08:00
Anees Iqbal 8ae23a2281 tests: no module the translator writes declares the explicit workgroup layout's capabilities 2026-11-17 19:17:15 -08:00
Anees Iqbal ff4c6835aa rt tests: a synchronize of a texture without named bytes leaves the segment's end barrier alone
Legs 43734/43735/43736 at ae67a08163 measured one barrier, not none, for a command buffer whose
blit encoder only synchronizes a texture without named bytes, on all seven devices: the
command buffer's segment end, which every command buffer of an encoder records. The
synchronize itself records none; the test now expects the end alone.
2026-11-17 19:08:49 -08:00
Anees Iqbal e438446cdd rt tests: the blit tests open each count once the pool holds a ready block of each class
Core's legs at 03677fd352 (um870 43664) saw two submissions in every_device_copies_between_textures
on the 3090 where the test counts one, and one on the rerun (43687). A submission the runtime
counts outside command buffers is the block-maker thread's zero fill of a Private block it makes
after one is taken (fill.rs); the test's textures take the ready one just before the window. Each
blit test now waits, before each count it asserts, until the pool holds a ready block of each
class again, as the pacing tests wait for theirs; the runtime adds no submission to a blit.
2026-11-17 19:08:49 -08:00
Anees Iqbal d70cb2baec rt tests: the synchronize test makes its texture before the command buffers it measures
Legs 43678/43679 failed every_device_synchronizes_a_managed_buffer on every device: the texture
made just before the measured command buffer was moved home by that command buffer's upload, two
barriers the synchronize did not record. The texture is now made before the first command
buffer, whose upload moves it home; the synchronize of it still records no barrier.
2026-11-17 19:08:49 -08:00
Anees Iqbal 552fb45223 conformance: a probe of which texture views Metal makes, what a view reports, and the bytes it reads
Eleven cases, one per process under Metal's validation layer: whole views, level subranges, a 2D
view of one slice of a 2D array, a slice subrange of the array, ranges past the parent or empty,
and a view of another pixel format with and without PixelFormatView usage. A view that is made
reports its extent, level and slice counts, type and parent-relative level and slice, and the
FNV-1a 64 of its level 0 copied out by a blit: what rt's views must answer.
2026-11-17 19:08:49 -08:00
Anees Iqbal 9771d45fdb rt: a blit encoder synchronizes a Managed texture, each level and slice of its image into its named bytes
synchronize_resource of a Managed texture with named bytes
(Device::new_managed_texture, on every device) records one
vkCmdCopyImageToBuffer of each level and slice of its image into its place in
the named buffer, between one pair of a buffer copy's barriers, and marks the
segment so its end barrier reaches the host. A texture without named bytes
still records nothing; every call is counted in Metrics::synchronizations.

texture.rs gains one read hook, Texture::named_bytes (the named buffer and its
per-level/slice places), which main agreed to. The blit encoder's buffer copy
now records through record_buffer_copies, which takes a list of checked copies
and puts each copy's level and slice in the same two barriers; one copy
records exactly as before. new_managed_texture's doc names the synchronize.

Test (device cfgs): every_device_synchronizes_a_managed_texture_into_its_named_bytes:
a 2-level 4x4 RGBA8Unorm Managed texture with places 256-byte rows apart;
copies into its image alone leave the named bytes zero; the synchronize puts
level 0 at offset 0 and level 1 at 1024, the bytes between the rows kept, at 1
submission, 3 barriers, 0 bytes copied, 1 synchronization, 1 host reach.
Level 0 is plain Metal's: probe blit_synchronize_rules.m, job m3-max-43667,
getBytes of a Managed texture copied into then synchronized hashes
a918a78fc82cbba5 (the managed-buffer case still 5d28bc84b408472d).
2026-11-17 19:08:49 -08:00
Anees Iqbal b025e83119 conformance: the synchronize probe writes its Managed texture by a copy and hashes getBytes after the synchronize
The two Managed texture cases now copy the 64 bytes the buffer cases start from into the 4x4
RGBA8Unorm texture with copyFromBuffer: before the synchronize, and hash getBytes: (rows 16
bytes apart) once the command buffer completes: the bytes a synchronized Managed texture gives
the host.
2026-11-17 19:08:49 -08:00
Anees Iqbal 3398f59995 harness: a description's synchronize, synchronizeResource: of a managed buffer before a dispatch
The directive `synchronize BUFFER` records synchronizeResource: in the blit
encoder before its dispatch, as the other blits do. A buffer not made before it
and one that is not managed (Metal's validation stops a synchronize of it) are
refused with the line's number. The old runtime's synchronize_resource and the
new one's back the trait method; the new runtime's harness keeps a managed
buffer as a Private one, so the call records nothing there.

The described test gains workload `synced` (a managed buffer filled, then
synchronized, then stepped by lcg_step and checked); tests.rs gains the three
refusals.
2026-11-17 19:08:48 -08:00
Anees Iqbal b37339a609 rt: a blit encoder synchronizes a Managed buffer, one copy of its device copy into the consumer's bytes
BlitCommandEncoder::synchronize_resource is synchronizeResource:. Of a Managed
buffer with a device copy (Shared memory not device-local) it records one
vkCmdCopyBuffer of the copy into the consumer's bytes between the two barriers a
fill records, and marks the segment so its end barrier reaches the host: the
host reads the GPU's writes before the call once the command buffer completes or
it sees an event signaled after it. A buffer without a device copy is read by
the host where shaders write it, and a texture has no bytes the host reads
apart from its image (no texture has named bytes on development yet): for
those the call records nothing. Every call is counted in the new
Metrics::synchronizations and is no submission of its own.

Metal's validation stops a synchronize of a Shared or Private buffer or
texture (probe blit_synchronize_rules.m, job m3-max-43632: "synchronizeResource:
only applies when ... == MTLResourceStorageModeManaged"); rt keeps no storage
mode for those and records nothing, as the old runtime does. The probe's
Managed buffer, filled 4..12 with 0xab and synchronized, hashes
5d28bc84b408472d, the bytes the test asserts.

The barrier after a blit's write into a buffer is one helper now (fill, buffer
copy, synchronize); a buffer copy's source stage widens from COPY to
ALL_TRANSFER.

Tests (device cfgs): every_device_synchronizes_a_managed_buffer (a fill alone
leaves the host's bytes where the buffer has a device copy; fill + synchronize
gives Metal's bytes at 1 submission, 5 barriers with a device copy and 3
without, 0 bytes copied, 1 synchronization, 1 host reach; a texture's
synchronize records no barrier) and
every_device_reaches_the_host_only_after_a_blit_writes_shared_memory (the
wrote_host invariant for blit encoders: fills and copies into Private memory
or a texture reach no host, into a Shared buffer they do). README,
REFUSALS.md and the signatures table updated; the README drops the line that
said synchronizeResource comes with blit encoders, and names
synchronizeTexture:slice:level: as not built (no recorded stream calls it).
2026-11-17 19:08:48 -08:00
Anees Iqbal 8239a53a35 conformance: a probe of which resources Metal's synchronize takes, and the bytes after one
Seven cases, one per process under Metal's validation layer: synchronizeResource: of a Managed,
Shared and Private buffer after a fill in the same encoder (the host's bytes hashed where it
reaches them), of a Managed, Shared and Private texture, and synchronizeTexture:slice:level: of a
Managed one. It tells which calls rt may refuse and which must do nothing.
2026-11-17 19:08:48 -08:00
Anees Iqbal 594b86d1f2 rt: the floor asks the created device for support of the runtime's set layouts
vkGetDescriptorSetLayoutSupport is Vulkan's answer to whether a set layout can be made; the
limits the floor checks do not promise it. MoltenVK 1.4.2 on an M3 Max reports set 1's layout
(65,536 sampled images, 4,096 storage images, three arrays of 4,000 samplers, update after bind)
unsupported, and the validation layer then names VUID-vkCreateDescriptorSetLayout-support-09582
at device creation (probe job m3-max-43634).

Arrays::make asks it for the empty set 0 and for set 1 before making either; an unsupported one
refuses the device with Error::BelowFloor and the new Missing::SetLayout { set }. Vulkan answers
it only for a created device, so PhysicalDevice::check cannot. Set 1's layout is built in one
place, with_arrays_layout, for the query and the creation.

Tests: every_device_supports_the_runtimes_set_layouts (each device of the cfg's kind supports
both), a_set_layout_the_device_does_not_support_is_named. README floor section, REFUSALS.md and
api_signatures.tsv regenerated.
2026-11-17 18:52:30 -08:00
Anees Iqbal 088f8bb61c rt, harness: the device tests and the harness's test session follow the shared kernel
Fixes forward the kernel-map commit (a010c3090d). That commit's checks (m3-max-43671) failed in
three places:
- The device-cfg tests in rt's tests/translate.rs still read the emulated and whole modules
  on the state. They now read them on its compiled kernel.
- The harness's test session still took a buffer length in Session::create. It now takes Makes.
- The harness's run.rs doc linked STATE_CREATIONS with an explicit target that rustdoc reports
  as redundant.

Verified: formatted only. The checks run on this commit next.
2026-11-17 18:51:28 -08:00
Anees Iqbal b431b1cca9 rt: states of one compute pipeline content share one compiled kernel
Before this, each compute pipeline state lowered its own kernel. It made its own VkShaderModule
and its own VkPipelines, so 1,000 states of one content cost 1,000 translations, or 1,000 reads
of the cache directory where one was set. Now the device keeps a map from content to compiled
kernel. A state of a content the map holds takes that kernel: it lowers nothing and makes no
module or pipeline. The VkPipelines live in the shared kernel, one per variant (workgroup size,
threadgroup memory lengths, tiles), so states of one content share them too.

The key is the translator's compute_pipeline_key(descriptor) plus
required_threads_per_threadgroup. The pipeline key does not cover that field, but rt reads it
into each module's interface (Kernel::new's max_total_threads). One entry holds the content's
whole kernel: the whole module, the partial-threadgroups module where the translator made one,
and the emulated-SIMD-group module the reaper lowers. The module kind therefore lives inside the
entry, not in the key.

What stays per state, checked against every field a state reads:
- The numbered samplers. Each state keeps the sampler indices the consumer gave
  (sampler_ids, pushed by every dispatch), plus its hold on the constexpr sampler elements at
  those indices. Two states of one content may number them differently, so they stay with the
  state (Numbered).
- support_indirect_command_buffers is refused before the lookup.
- No other descriptor field reaches the module, its interface or a variant. The emulated
  module's sampler check needs only the kernel's constexprs (covers), which come from the
  content.

The map holds at most 1,024 entries and forgets the least recently used past that. It bounds
what it holds, not what lives: a state keeps its kernel, so eviction only forgets the entry, and
the kernel goes with its last state. Two new gauges, kernels and kernel_entries, count live
kernels and map entries. Both read 0 once the device is gone, because the device's teardown
clears the map after the queue halts. The map's kernels hold the core, and clearing the map
breaks that cycle.

Tests (rt src/tests/kernel_map.rs):
- the map filled past its cap, on the host;
- on every device of the cfg: two states of one content share one translation, one module and
  one VkPipeline per variant, for a tiling kernel and for one that observes its threadgroups;
- other constant values and other linked functions compile apart;
- a cap of 2 filled with 3 contents holds 2, frees a forgotten kernel with its last state, and
  compiles a forgotten content again.

The harness gains create_state. It times the first creation of a content the device has not
seen ("first"), then 1,000 creations of a content it has, against the old runtime too, with
the gauges at 100 and 200.

The README's compute pipeline states section and the counters' docs say "per kernel" where they
said "per state". api_signatures.tsv is reblessed for the two gauges.

Verified: formatted only. The checks run on this commit next (clippy x3, rustdoc, the touched
tests, and rt's lavapipe device tests).
2026-11-17 18:51:27 -08:00
Anees Iqbal 75bfbbb062 harness: a buffer copy's whole-texel check uses is_multiple_of
Clippy's manual_is_multiple_of stopped the harness (lint m3-max-43622) on the two remainder
tests of BufferCopy::problem; is_multiple_of says the same.
2026-11-17 18:37:19 -08:00
Anees Iqbal b00be4734d rt: the blit refusals' doc lines fit in 100 columns
Three doc lines of TextureBytes, FloatDepthUpload and FillAlignment ran past 100 columns; they
are reflowed with no word changed. docs/REFUSALS.md regenerates unchanged.
2026-11-17 18:37:18 -08:00
Anees Iqbal 9576102404 harness: the run names the plan's blits
a172c73d93 matched on Blit in run.rs without importing it, so the harness did not build
(lint m3-max-43611, E0433 four times). The import joins the plan's others.
2026-11-17 18:37:18 -08:00
Anees Iqbal e9f43bb855 rt: blit buffer copies and fills reach a buffer through its device range, and keep the buffer
Development's Managed buffers (ee7c4a5173) replaced held_block with held and device_range: a
Managed buffer's GPU side is its device copy where the Shared type is not device-local. A blit copy
or fill now records against device_range's VkBuffer and offset (alignment checked from that
offset) and keeps the buffer through Building::keep, which keeps a device copy too; is_shared
answers false for a buffer with a device copy, so only a copy or fill into the bytes the host
reads marks the segment. The lint of a172c73d93 (m3-max-43607) was cancelled before it compiled:
held_block no longer exists. Docs say 'the bytes shaders reach' where they said the block.
2026-11-17 18:37:18 -08:00
Anees Iqbal f4b7e606cc harness: a description's buffer copies and fills, in the blit encoder before a dispatch
A dispatch carries the blit commands before it (plan::Blit: a texture copy, a copy from a buffer
into a texture or back, or a fill), recorded in order in one blit encoder between the compute
encoders; the field is blits, not copies. The BlitCommandEncoder trait gains copy_from_buffer,
copy_from_texture_to_buffer and fill_buffer, and both runtimes implement them (the old runtime's
copy_from_buffer_to_texture, copy_from_texture_to_buffer and fill_buffer with BlitOption::None;
rt's copy_from_buffer, copy_from_texture_to_buffer and fill_buffer).

A description names them with
  copy-buffer-to-texture BUFFER OFFSET ROW-BYTES IMAGE-BYTES WIDTH HEIGHT TEXTURE SLICE X Y
  copy-texture-to-buffer TEXTURE SLICE X Y WIDTH HEIGHT BUFFER OFFSET ROW-BYTES IMAGE-BYTES
  fill-buffer BUFFER OFFSET LENGTH VALUE
before the next dispatch's set lines. Refused with the line's number, as Metal's validation stops
them (probes blit_buffer_copy_rules.m and blit_fill_rules.m): a buffer or texture no line before it
makes, a slice or region outside the texture, an empty region, an offset or row stride of no whole
texels or rows closer than the region's, a region or fill past the buffer's end, an empty fill. The
messages for a blit after the set lines or after the last dispatch now say blit.

The rt README's segment paragraph names a blit copy or fill into a Shared buffer among the writes
that make a segment's end barrier reach the host.

Tests: each new refusal in the faulty-description test; the described device test gains 'staged':
a Private texture written whole from a buffer, a fill of buffer 2, a region of the texture read
into buffer 2 at padded rows, then texels_out of the texture, checked against its CPU model and
between the runtimes.
2026-11-17 18:37:18 -08:00
Anees Iqbal 2cb7ea189d rt: a blit encoder fills a range of a buffer, one vkCmdFillBuffer between two barriers
fill_buffer (fillBuffer:range:value:) records vkCmdFillBuffer of the byte four times over in each
word against the buffer's own range of its block, between the two barriers a copy records (the
second from every transfer stage's writes to every later command), and a fill of a Shared buffer
marks the segment so its end barrier reaches the host.

Probe blit_fill_rules.m on an Apple M3 Max, macOS 27.0.1: Metal's validation stops an empty range
and one past the buffer's end (job m3-max-43573), Refusal::FillRange; it takes ranges of no whole
words (job m3-max-43571), which vkCmdFillBuffer cannot write: Gap::FillAlignment until a replay
stream makes one.

Tests: the range checks (offset from the buffer's place in its block, empty, past the end,
reversed, unaligned start, length or block offset); a device test filling 4..12 of a 64-byte
Shared buffer with 0xab, its bytes plain Metal's FNV-1a 64 (job m3-max-43571), at one submission,
three barriers, no byte of the runtime's own.
2026-11-17 18:37:18 -08:00
Anees Iqbal 8603abbad3 conformance: the fill probe asks about a range past the buffer's end and an empty one 2026-11-17 18:36:53 -08:00
Anees Iqbal 41fcf99168 conformance: a probe of which ranges Metal's buffer fill takes, and the bytes it leaves
Whole words, an offset or a length of no whole word, both, and a Private buffer, one case per
process under the validation layer; each Shared buffer's FNV-1a 64 after the fill. The rt blit
fill (next) takes its rules and its bytes from it.
2026-11-17 18:36:53 -08:00
Anees Iqbal 8e39e812e5 rt: a blit encoder copies between a buffer and a texture, one copy command an image of the region
copy_from_buffer (copyFromBuffer:sourceOffset:sourceBytesPerRow:sourceBytesPerImage:sourceSize:
toTexture:destinationSlice:destinationLevel:destinationOrigin:) and copy_from_texture_to_buffer
(copyFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toBuffer:destinationOffset:
destinationBytesPerRow:destinationBytesPerImage:) record vkCmdCopyBufferToImage or
vkCmdCopyImageToBuffer against the buffer's own range of its block, nothing staged, between the
two barriers a texture copy records. One region per image of the region, each at its own offset
(offset + image x bytesPerImage), so an image stride of no whole number of rows copies too;
bufferRowLength is bytesPerRow in texels, 0 for one row. The second barrier also makes a buffer
write visible to every later command, and a write into a Shared buffer marks the segment, whose
end barrier reaches the host. BufferLayout carries the offset and the two strides.

Refusals follow probe blit_buffer_copy_rules.m on an Apple M3 Max, macOS 27.0.1 (jobs
m3-max-43541, m3-max-43545): Metal's validation stops an offset or a row stride of no whole
texels, rows or images closer than the region's and a region past the buffer's end
(Refusal::BufferCopyLayout); it takes an R8Unorm offset of 2, a row stride of 0 for one row, image
strides of no whole rows, and bytesPerImage on 2D and 1D-array copies. Where Metal takes bytes a
copy command cannot address (a depth or stencil offset not a multiple of 4, as a 16-bit depth at
2; a compressed offset or row stride of no whole blocks, as BC1 rows 20 apart, which Metal takes)
it is Gap::BufferCopyAlignment. TextureBytes and FloatDepthUpload now name the blit copies too.

Tests: pure checks of the regions (padded rows, one row, a 3D region's images at their own
offsets, a 1D array slice, BC1 blocks) and of each refusal and gap; a device test copying into a
mipmap level, out of an array slice and a 3D region at padded strides, into a 1D array slice and
BC1 blocks, each result held to plain Metal's FNV-1a 64 (probe blit_copy_layouts.m, job
m3-max-43555, plain and under the validation layer), and one copy into a Shared buffer alone at
one submission, three barriers, no byte of the runtime's own.
2026-11-17 18:36:53 -08:00
Anees Iqbal 4664a6f276 conformance: the blit copy probe copies between Shared buffers and textures
Five copies the rt device test makes too: into a mipmap level at an offset with padded rows, out
of an array slice with padded rows, out of a 3D region with an image stride of no whole number
of rows, into a 1D array slice with an image stride, and BC1 blocks from a buffer; each
destination's length and FNV-1a 64 printed.
2026-11-17 18:36:28 -08:00
Anees Iqbal d90d36def9 rt: a Private allocation spills to the next memory type on its own out-of-device-memory error, and reports it
As the plan decided for reims's first need (Metal never fails a Managed
resource for want of video memory): a Private allocation takes the device-local
Private type and, where that allocation itself fails with
VK_ERROR_OUT_OF_DEVICE_MEMORY (never a budget poll), the next memory type the
resource allows, in the device's order (memory::allocate_spilling).

Reporting: BlockInfo::device_local is false for a spilled block (and, for a
Shared block, says whether the Shared type is device-local);
Gauges::spilled_bytes counts the bytes of spilled blocks and of textures' own
spilled allocations until they are freed.

Where it applies:
- blocks, pooled and dedicated (memory::make); a spilled pooled block is freed
  when given back, so the pool's next block tries device-local memory again;
- texture blocks and copy blocks never hold a place in a spilled block
  (Places::place gives it back and answers the out-of-memory error): a texture
  then takes an allocation of its own, which spills the same way where the
  image allows another type;
- a Managed buffer whose device copy finds no device-local room is its Shared
  range for its life, as on a unified device: no second copy in system memory.

The device tests stand in for a full device with Core::fail_private (test
builds only), which fails the Private type's allocations before the driver is
called.

Test: tests::spill::every_device_spills_private_memory_out_of_device_memory.
2026-11-17 18:33:50 -08:00
Anees Iqbal 25602502e3 rt: the translator's description enables the portability subset and its floor features where the device lists it
Device creation enables VK_KHR_portability_subset and the three portability features the floor
asks for where a device lists the subset, but shader_enables named neither to the translator.
DeviceDescription::with_enabled then refuses a description that does not enable a listed
portability subset, so Device::new failed on MoltenVK with 'the translator made no pipeline:
invalid descriptor: does not enable KhrPortabilitySubset, which the device lists' (M3 probe job
m3-max-43626, with the probe admitting MoltenVK past the two floor items it lacks).

shader_extension maps the subset to VkExtension::KhrPortabilitySubset, the PORTABILITY features
carry their translator names, and shader_enables reads them: false, so not named, where the
subset is not listed. Test: the_translator_sees_the_portability_subset_device_creation_enables
(fails without the fix: the extension is not in the enable set).
2026-11-17 18:27:16 -08:00
Anees Iqbal 2105fa114e rt: heap textures, bound at the consumer's offsets in a heap's range of a Private block
A heap is a range of a Private block the consumer took at the heap's creation
(HeapRange: block, offset, length), as the plan decided: one Private range per
heap, resources at the offsets the guest's first-fit allocator picks.

Device::heap_texture_size_and_align answers heapTextureSizeAndAlignWithDescriptor:
with this device's image requirements (vkGetDeviceImageMemoryRequirements of the
same create info new_texture uses), never Metal's: the size rounded up to and
the alignment raised to bufferImageGranularity, so a buffer placed by the same
answers never shares a granularity page with the image. Replay showed why: one
vendor's image for a recorded heap texture is larger than the recording
device's (7.47 MB in a 5.9 MB heap), so the guest places by this answer.

Device::new_heap_texture binds the image at the heap offset: no allocation and
no texture block, bytes not zeroed (as Metal's heap textures), aliasing allowed.
A placement past the heap's end, an offset in the block off the image's
alignment, or a heap range past its block is Refusal::HeapTexturePlace at
creation; the image is never bound outside its heap. A Shared block, or an image
that requires an allocation of its own or does not take the Private type, is
Gap::HeapTexture (every optimal image measured takes the Private type). The
image holds the block, so a released block returns to the pool only once its
heap textures' images are gone.

new_texture's checks move into Device::prepare, shared with the size query, and
the image's create info into image_info. README: heap textures leave the
not-built line; REFUSALS.md and the signatures table updated.

Test: tests::heap::every_device_places_heap_textures_at_the_consumer_s_offsets
(answer equals the image's own size rounded to granularity; first-fit
placements allocate nothing and keep their own bytes; an alias; refusals for
past the end, off the alignment, a heap past its block, and a Shared block).
2026-11-17 18:26:07 -08:00
Anees Iqbal c96072be85 rt tests: once the reads drain the staging ring, the next copy's span starts at the region's start
The planner ruled that the staging ring restarts at its start whenever nothing
is pending in it. Ring::take already does that: since the region became its own
allocation, the head is the end of the last live span, so an empty ring takes
at 0 (the ring unit test checks "empty starts at 0"). This adds the device-level
check: in the upload test, after get_bytes has waited for every copy, the next
replace_region's span is 0..len (Work::staging_spans, for the device tests).
A one-texel read then sends that copy so the test's later bounds start from
an empty upload.
2026-11-17 18:26:07 -08:00
Anees Iqbal 8fc4064da5 rt: Managed textures, an image and the consumer's named bytes, uploaded by a device copy
A Managed texture is a Private image plus a range the consumer names, on every
device. Device::new_managed_texture takes a Shared buffer and, per level and
slice, a BytesPlace (offset, bytes per row, bytes per image) laid out as the
consumer chooses; rt never picks the layout. Places that a buffer-to-image copy
cannot read in place (rows not whole texel blocks apart, images not whole rows
apart, a first byte off the block's bytes or off 4 for depth/stencil, a level
leaving the buffer, a wrong count, a buffer the host does not reach) are
refused with Refusal::ManagedTextureBytes.

Texture::upload_region(region, level, slice) records one vkCmdCopyBufferToImage
from the named place into the image in the upload, ahead of every command
buffer committed after the call on every queue, as did_modify_range copies a
Managed buffer: no CPU copy, no staging. On such a texture replace_region
writes the named bytes (Metal's CPU copy) and uploads them; get_bytes reads the
named bytes with no submission. The texture copy's record() now takes a buffer
and region, so staging and named copies share it.

README, the API.md accepted difference (the copy reads the bytes when the GPU
reaches it), REFUSALS.md and the signatures table updated.

Test: tests::managed::every_device_copies_a_managed_texture_s_named_regions
(whole-level uploads, a sub-region upload with an unmarked change outside it,
get_bytes reading the named bytes, replace_region writing them, six refusals).
2026-11-17 18:26:07 -08:00
Anees Iqbal 3da5c35785 rt tests: the floor's device test passes the runtime's instance reference as it is 2026-11-17 18:18:24 -08:00
Anees Iqbal 0ef45ca579 rt tests: the floor's device test checks through the runtime instance's loader 2026-11-17 18:18:24 -08:00
Anees Iqbal cd59238673 rt tests: the floor's device test lists devices through the runtime's instance, portability ones included, and names the extensions and portability features it enables
The test made its own instance with the floor's instance extensions alone, so
it never listed a portability device, which the runtime's instance now lists
where the loader offers VK_KHR_portability_enumeration. It now checks every
device Instance::new lists, and its line for each device above the floor names
the extensions device creation enables and the three portability features.
2026-11-17 18:18:24 -08:00
Anees Iqbal 31f5ee822b rt: the device test of accesses up to 2 GiB runs alone
an_access_up_to_2_gib_lands_at_its_own_word holds one Shared block of MAX_BUFFER_LENGTH
(2 GiB). Where the Shared memory type is host memory (an RTX 2080, NVIDIA 620.70.06: the
host-cached type), that is 2 GiB of the host beside every test running with it. On the 2080
the compute encoder tests with the four touched translate tests peaked at 4.7 GiB of host
memory (job m3-max-43586, 8 GiB held); in a job holding 4 GiB the run reached the 4 GiB and
every_device_refuses_what_metal_refuses_in_an_encoder's Shared block failed with
ERROR_OUT_OF_DEVICE_MEMORY (m3-max-43554; m3-max-43585 passed at the same 4.0 GiB peak). The
same set without the 2 GiB test peaked at 2.4 GiB (m3-max-43556), and the 2 GiB test beside the
refusal test alone at 2.8 GiB, passing (m3-max-43578, 43579).

A nextest override gives it threads-required = num-test-threads, so nothing runs beside it and
a run's peak is the larger of its own and the rest's, not their sum. Nothing is retried or
skipped; the test is unchanged but for its doc, which says it runs alone.
2026-11-17 18:13:25 -08:00
Anees Iqbal fa74b3e758 harness: the run brings the blit encoder trait into scope
Lint m3-max-43531 at b0aed301bb failed to compile the harness: copy_from_texture and end_encoding
were not in scope in run.rs.
2026-11-17 18:10:37 -08:00
Anees Iqbal c337ad421a conformance: the buffer copy rules probe asks about one row of bytesPerRow 0 and a region past the buffer 2026-11-17 18:10:37 -08:00
Anees Iqbal c626d076b7 conformance: a probe of which buffer layouts Metal's buffer and texture copies take
Offsets and rows that are not whole pixels, offsets not a multiple of 4, rows shorter than the
region, bytesPerImage on a 2D texture and on a 1D array slice, images not whole rows or shorter
than the region, compressed rows not whole blocks, and a 16-bit depth offset, one case per
process under the validation layer. The rt blit copies between buffers and textures (next) take
their refusals from its answers.
2026-11-17 18:10:37 -08:00
Anees Iqbal 301938c1aa harness: a description's copy-texture, copyFromTexture: in a blit encoder before a dispatch
The harness drives each runtime's blit encoder now: a BlitCommandEncoder trait
(copyFromTexture:... and endEncoding), blitCommandEncoder on the command buffer, and both
runtimes behind them (the old runtime's copy_from_texture_to_texture, rt's copy_from_texture).
A dispatch carries the texture copies before it (plan::TextureCopy, level 0 of each texture, one
texel deep); a run ends the compute encoder before them, records them in a blit encoder and opens
a new compute encoder for the dispatch.

A description names one with
  copy-texture SOURCE SLICE X Y WIDTH HEIGHT DESTINATION SLICE X Y
before the next dispatch's set lines. Refused with the line's number: a texture no line before
it makes, a slice past the array, a region outside either texture, two pixel formats (Metal's
validation requires one), a copy after the set lines of its dispatch, and a copy after the last
dispatch.

Tests: the faulty-description test covers each refusal; the described workloads' device test
gains 'copied', an 8x6 region of slice 1 of an RGBA8Unorm array copied into a 2D texture that
texels_out then reads, checked against its CPU model and between the runtimes.
2026-11-17 18:10:36 -08:00
Anees Iqbal 60fe8aacaf rt: TextureCopyMismatch quotes Metal's messages as code
Rustdoc read "[destinationTexture sampleCount](1)" as a link and failed -D warnings (job
m3-max-43474).
2026-11-17 18:10:36 -08:00
Anees Iqbal f10ed213a0 rt: the blit device test holds each copy's expected bytes to plain Metal's
Each expected result's FNV-1a 64 is the hash probe blit_copy_layouts.m printed on an Apple M3 Max,
macOS 27.0.1 (job m3-max-43464, at 31f5a93c4b), plain and under the validation layer alike: a
level into an array slice, a cube face into a 3D slice, a 3D slice into 2D, slice to slice and
BC1 blocks. The format-pair probe's sample-count case ran too (job m3-max-43465): Metal's
validation stops four samples into one with "[sourceTexture sampleCount](4) must equal
[destinationTexture sampleCount](1)", which Refusal::TextureCopyMismatch's basis now cites.
2026-11-17 18:10:36 -08:00
Anees Iqbal 42d274f91a rt: a blit texture copy takes one pixel format and one sample count, as Metal's validation does
Metal's validation layer stops copyFromTexture between any two pixel formats (Apple M3 Max,
macOS 27.0.1, probe blit_copy_format_pairs.m, job m3-max-43433): RGBA8Unorm into sRGB, Uint,
R32Uint and BGRA8Unorm, R32Uint into R32Float, Depth32Float into R32Float and BC1 into RG32Uint all
fail with "[sourceTexture pixelFormat] must equal [destinationTexture pixelFormat]"; the same
format is taken. So Refusal::TextureCopyMismatch is now every pair of two formats (basis
metal-measured, was metal-takes), and the rules for copying between formats of one unit's bytes
are gone: no alpha special case, no block, aspect or unit comparison. What stays a gap: a
multisample texture, depth and stencil both, a 1D texture with another type, one subresource
into itself, and, new, one pixel format held in two Vulkan formats by the textures' usages, whose
texels may sit in two layouts.

The device test's array is RGBA8Unorm now (the copy into it was RGBA8Unorm into R32Uint), and the
slice-past-the-array check copies into a texture of its format: on 7f2a3c5cb1 it met the format
check first on every device (legs m3-max-43406, 43407, 43408: RX 550, 780M HawkPoint, 3090, XTX,
2080, 780M Phoenix, lavapipe; every assertion before it passed, validation errors 0).
The probes add the sample-count case and make the layout probe's array RGBA8Unorm; their runs
follow.
2026-11-17 18:10:36 -08:00
Anees Iqbal aa957fd5a4 conformance: a probe of which format pairs Metal's texture copy takes
The blit copy probe (job m3-max-43426, Apple M3 Max, macOS 27.0.1) showed Metal's validation
layer stopping at RGBA8Unorm into R32Uint: the source's pixel format must equal the
destination's. This probe asks the same of sRGB, integer, float, channel order, depth and
compressed pairs, one case per process under the validation layer.
2026-11-17 18:10:05 -08:00
Anees Iqbal a28f701223 conformance: the blit copy probe's helpers take names libc does not
write() clashed with unistd's, which stopped the build on the M3 (job m3-max-43424).
2026-11-17 18:10:05 -08:00
Anees Iqbal c71ce1a0f9 conformance: a probe of plain Metal's bytes after the rt blit test's texture copies
The rt device test (tests::blit::on_device) checks the bytes each copy leaves against a model of
its own. This probe makes the same textures, patterns and copies on Metal and prints each
destination's length and FNV-1a 64 hash, so the test can hold its model to Metal's answer: level
and slice addressing, a cube face into a 3D slice, a 3D slice into 2D, and BC1 blocks. It also
runs under Metal's validation layer, which stops at a copy Metal does not take, such as
RGBA8Unorm into R32Uint if it refused one unit's bytes in two formats.

Not run yet; the hashes follow with the run that made them.
2026-11-17 18:10:05 -08:00
Anees Iqbal c5b380ad31 rt: a blit's checked regions hold plain texel arrays, which derive Debug where ash's types do not
ash's Offset3D, Extent3D and ImageAspectFlags implement Debug only with its debug feature, which the
workspace leaves off, so Placed holds its origin and size as arrays and makes the Vulkan types for
the copy command; CopyUnit and ImageCopy derive no Debug. The rule tests compare fields.
2026-11-17 18:10:05 -08:00
Anees Iqbal 247ed69da0 rt: a blit encoder copies a region of one texture into another, one vkCmdCopyImage between two barriers
CommandBuffer::blit_command_encoder (blitCommandEncoder) and BlitCommandEncoder::copy_from_texture
(copyFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toTexture:destinationSlice:
destinationLevel:destinationOrigin:, the only texture-to-texture selector the compute recordings
use: 2,736 copies in one, 3 in the other, none multisample, compressed or within one texture).

The copy is recorded at once into the current segment: no staging and no byte beyond the region.
The first barrier moves each texture's level and slice from home to its transfer layout and carries
the global barrier (every earlier write visible to every later command), so it pays what an encoder
owed and the hazard sets start again; the second moves them home with the copy's writes visible to
every later command. A command buffer of one copy is one submission and three barriers (the
segment's end among them), and Metrics::bytes_copied does not move.

Bytes move as they are between formats whose units have the same bytes; a compressed region is
whole blocks or reaches the level's edge on both sides; a 3D image copies to and from a 2D slice.
Refusal::TextureCopyMismatch for units of different bytes or different sample counts (Metal stores
its GPU's own layout there); Gap::TextureCopy for what one vkCmdCopyImage in the floor does not
make (multisample, depth and stencil both, depth or stencil with another format, compressed with
another block extent, A8_UNORM with another format, 1D with another type, one level and slice into
itself). The texture's region check is shared with replace_region and get_bytes (texture::place).

Tests: tests::blit (the rules, no device) and on every device of the cfg's kind
tests::blit::on_device::every_device_copies_between_textures (bytes of a level into an array slice
of another format, a cube face into a 3D image, a 3D image into a 2D texture, one array slice into
another, BC1 blocks where made; 1 submission, 3 barriers, 0 bytes copied, 1 pass for one copy; an
owed barrier paid by the copy: 3 barriers, 4 without the fold).
2026-11-17 18:10:04 -08:00
Anees Iqbal f0d4d49ae7 validation: the runtime pin after the rounding commit's comment edits
The rounding commit changes only comments in runtime inputs of the translator:
device/mechanism.rs (AddressAlignment's mechanism comment: the binder rounds the address)
and pipeline/facts.rs (RuntimeFact::AddressAlignment's doc). No behaviour of a run
changes, so the hash moves and RUNTIME_VERSION does not.

Verified: the guard (the_runtime_sources_are_the_committed_ones) at c138859277 named
509d1d0d17c9d8435d198e9811d3796710f2ba5680e45512c20f55bd1aaa5771 (potluck job m3-max-43550).
2026-11-17 18:07:45 -08:00
Anees Iqbal 4732ce6cd7 rt: a buffer bound off its argument's alignment runs at the address rounded down to it
The binder (ComputeCommandEncoder::fill_parameters) pushes each bound buffer's address,
its gpuAddress plus the bind offset, rounded down to a multiple of the alignment the
kernel takes it to have (FieldValue::BufferAddress's mask, from
RuntimeFact::AddressAlignment: the argument's air.arg_type_align_size, at most 16), for
every slot. Refusal::MisalignedBuffer and the dispatch it skipped are deleted, so
fill_parameters cannot fail.

Why: Metal's API validation refuses such a bind offset, and without validation an Apple
M3 Max (macOS 27.0.1) reaches each element at its address rounded down to the smaller of
the element's alignment and 4, for loads, stores and pointers stored in a buffer alike.
The probe that measured it is committed as
crates/metal2vulkan-conformance/probes/misaligned_buffer_binds.m. The two agree at
alignments 2 and 4 and for 8- and 16-byte arguments bound 1 to 3 bytes off a multiple of
4; an 8- or 16-byte argument bound at a multiple of 4 that is not a multiple of its
alignment is reached at the rounded address where the M3 reaches it exactly there, a bind
Metal's validation rejects. docs/API.md section 10 lists that as an accepted difference.

Tests: rt's every_device_rounds_a_bound_address_down_to_its_alignment steps a buffer bound
off each alignment (2, 4, 8 and 16; 15 binds) through the step kernel with the mask set,
and checks the words stepped start at the rounded address; at the 8- and 16-byte binds 4,
8 or 12 bytes off, an unrounded bind would step other words on any device.
an_argument_bound_off_its_alignment_runs_at_the_address_rounded_down binds
vector_word_phases' vwp_words 1 and 3 bytes and vwp_vec16 4 and 12 bytes off their
alignment and expects Metal's words for the rounded binds. They replace
an_argument_bound_off_its_alignment_is_refused and
a_misaligned_dispatch_refused_leaves_its_encoder_and_command_buffer_usable.

Docs: REFUSALS.md and api_signatures.tsv regenerated (the variant's row goes), the rt
README's compute encoders say what the binder pushes, the translator's
RuntimeFact::AddressAlignment doc and the mechanism comment say the binder rounds.
2026-11-17 18:07:45 -08:00
Anees Iqbal ee7c4a5173 rt: Managed buffers, a device copy where Shared memory is not device-local
newBufferWithLength:options: and newBufferWithBytes:length:options: with Managed storage over a
range of a Shared block the consumer names: Device::new_managed_buffer(block, offset, length,
copied). The device's memory-type query picks the form. Where the Shared type is device-local the
buffer is its bytes, as a Shared buffer is, and didModifyRange does nothing. Elsewhere shaders
reach a device copy in Private memory, as Metal keeps one on a Mac with a discrete GPU.

The device copy is a place in a copy block: a Private block of the pool, or a dedicated one past
BLOCK_LEN, in a set apart from the texture blocks, so no buffer lies beside an optimal image. Its
first `copied` bytes are copied from the consumer's and the rest zero-filled, in the upload.
Buffer::did_modify_range(start, length) marks a range changed: the upload, which goes ahead of
every command buffer committed after the call on every queue, copies it from the consumer's bytes
into the device copy as it is submitted, one vkCmdCopyBuffer per buffer with its ranges merged
where they overlap or touch, after a counted barrier that puts the upload's earlier fills first.
No CPU copy, no staging, nothing sized by the call. Each change is one of the upload's 4,096 calls,
so changes past them submit it and wait. The copy reads the bytes when the GPU reaches it, which
docs/API.md records as an accepted difference.

A command buffer keeps each device copy it uses, and an upload each one it copies into, until it
retires; the copy's place is freed then. An indirect dispatch reads its arguments from the device
copy. Places take a core and give a block back once it empties where it is dedicated or another
pooled block of the set is empty; Core::take_memory chooses a pooled or dedicated block for both
take_block and the places.

Refusals: ManagedBlockNotShared (a Private block) and ModifiedRange (a range past the buffer),
both ours; docs/REFUSALS.md and the signatures table regenerated.

Tests: changed ranges merge where they overlap or touch; on every device, in the form its query
picks, the device copy holds the first bytes and zeros, a changed range reaches it at the next
submission and an unmarked change does not, changes past the upload's calls submit it (none
without a copy), both refusals, and every gauge zero after teardown.
2026-11-17 18:00:53 -08:00
Anees Iqbal 8d6586a74d rt: replace_region and get_bytes copy packed rows in one run
A region whose rows lie back to back in the caller's bytes, as they do in the staging span, moves
as one copy of its whole length; only a pitch past the row, or images apart by more than their
rows, copies row by row. Before, every call copied row by row: a whole 1 MiB RGBA16Float texture
was 256 copies of 4 KiB.

Behaviour is unchanged; the texture tests cover packed rows and rows with a pitch in both
directions.
2026-11-17 18:00:29 -08:00