Commit Graph
6782 Commits
Author SHA1 Message Date
Anees Iqbal 8db961145b rt: the linear texture alignment answer is the device's linear row rounding alone
minimum_linear_texture_alignment no longer requires the linear image's memory alignment
(VkMemoryRequirements::alignment) to divide the answer. The answer is the smallest power of two P
at which the device lays every probed width's rows at the row rounded up to P, the largest over
the usages, and Metal's 16 where no P explains a format's pitches. The in-place test is
unchanged: a texture is in place only where its place in the buffer's memory is a multiple of the
image's memory alignment too, and is copied (over a Managed buffer's device copy, refused)
elsewhere. Nothing changes on NVIDIA, AMD or lavapipe, whose linear images' memory alignment
equals their row rounding (probe jobs 43742-43744). On the UHD 630, whose linear rows round to 64
bytes and whose linear images' memory aligns to 4,096 (probe 43758), the answer goes from 16 (no
P held) to 64, so a guest that pads its rows to the answer gets the device's own pitch.

Tests: tests::over places its textures at the answer rounded up to the linear image's memory
alignment (a test-only Device::linear_memory_alignment), and checks at widths 1, 3, 17, 64, 65 and
100 that a texture whose pitch is its row rounded up to the answer is in place; it prints how many
of its five formats answer 16. README and the getter's doc state what the number is and that
offsets are honoured in place only at the image's memory alignment.
2026-11-17 20:17:09 -08:00
Anees Iqbal 1ada6e8b1c rt: a texture over a buffer of no device copy that the device's linear image does not take is copied between the buffer and an image of its own
Where the in-place linear image does not hold a texture over a Shared buffer (or a Managed one
without a device copy) for its pitch, place, memory type or format features, the texture is now
an optimal image of its own instead of a Gap::TextureOverBuffer. The device copies the buffer's
bytes into it and back, one vkCmdCopyBufferToImage or vkCmdCopyImageToBuffer region a texture,
with no CPU copy (crate::over):

- in, once a submission: the upload that leads it copies into every such texture a segment uses
  before any command of the segment wrote the buffer; inside a segment, a use after a write of
  the buffer copies in again first; a segment leaning on the leading copy for a buffer an earlier
  segment of the held group wrote leads a new group;
- back, after a write of the texture: before the next command of the segment that reaches the
  buffer, and at the segment's end, whose end barrier then reaches the host.

Commands track what they write only while such a texture lives (a device count); a command
recorded while none lived counts as a write through an unbound address, so a texture made later
never leans on a copy that could precede it. Each copy counts in Metrics::over_copies and its
bytes in bytes_copied. The accepted difference (a CPU write between two held members' commits
races an uncompleted command buffer, which Metal leaves undefined) is stated at the rule and in
the README.

A texture over a Managed buffer's device copy that the linear image does not take stays a
Gap::TextureOverBuffer: the Managed branch waits on the measurement of whether a Managed buffer
keeps a device side at all.

Tests: tests::copy_over (every device under the device cfgs): a render target over a Shared
buffer at one alignment past the device's pitch copies in once per command buffer and takes the
host's writes; a fill then a use in one command buffer copies once, after the fill; a fill and a
use in two command buffers committed back to back takes the filled bytes; a blit's write to the
texture is in the buffer once the command buffer completes.

A view of such a texture shares its parent's image and id, so it is tracked and copied as its
parent; the live count counts the parent alone. An ended segment keeps its tracking, cut to the
textures that lean on the leading copy, for the submit thread to read in place.
2026-11-17 20:17:09 -08:00
Anees Iqbal 9a9135b4c9 Re-derive the generated documents at the landing tip
They are generated from the whole case set, and the set grew on `development`
while this branch was in flight, so the copy committed here counted a smaller
one.

Verified: regenerating at this tip leaves no change beyond the `Generated at`
stamp.
2026-11-17 20:12:11 -08:00
Anees Iqbal 05ce4db691 rt: Fence, MTLFence, whose updates and waits on compute and blit encoders record nothing
A command buffer's encoders run in order and a queue's command buffers in commit
order, each encoder's writes reaching the commands after it through the barrier
at its end or its segment's end, so a wait after an update already sees them. A
fence keeps the first queue whose encoder uses it; a use on another queue is
Gap::FenceOtherQueue, as Metal's fence orders one queue and MTLEvent orders
queues. Another device's fence is Refusal::OtherDevice.

Test: every_device_orders_a_wait_after_an_update_and_records_nothing_for_either
fills a buffer in one command buffer and updates the fence from a blit and a
compute encoder, waits in a second committed before the first completes and
copies the buffer out, and counts the same submissions, barriers, bytes copied
and passes with the fence calls as without; a second queue's compute and blit
encoders get the gap. REFUSALS.md and api_signatures.tsv regenerated.
2026-11-17 20:11:26 -08:00
Anees Iqbal 5c9ca33c48 rt: the device makes its first block of each class before it returns
The block-maker thread made the pool's first Shared and Private blocks after Device::new
returned, so their allocations ran beside the consumer's first calls. On NVIDIA's Linux driver
(620.70.06), a vkAllocateMemory of host-visible memory holds the device's other calls,
vkCreateComputePipelines and vkQueueSubmit2 among them, until it returns: a 256 MiB Shared
block's allocation took 39 to 56 ms on an RTX 3090, and a pipeline state created right after
Device::new waited 47 to 61 ms behind it (2.4 to 3.1 ms once the block was made in
Device::new; scratch probe f3c15f7ca3, job m3-max-43980).

Device::new now makes READY (one) block of each class on its own thread before it starts the
block-maker thread, which keeps one of each ready after that as before. Memory held is the
same; Device::new takes the two allocations and their zero fills longer.

Test: every_device_holds_a_block_of_each_class_when_it_is_made: as Device::new returns each
class holds a ready block and the blocks gauge counts them, and the block-maker thread makes
none in the 200 ms after.
2026-11-17 20:10:27 -08:00
Anees Iqbal d2fa098f0c replay: a message to nil (receiver 0, no result, no class named) plays nothing, as Objective-C does nothing for it; gb's stream holds such a replaceRegion 2026-11-17 20:05:15 -08:00
Anees Iqbal 8cfda4b5e1 rt: the cache's writes make a missing pipelines directory, the pending count uses try_update, and the test kernel has a digest 2026-11-17 19:58:23 -08:00
Anees Iqbal 72f75ea087 rt: each VkPipeline is made through a VkPipelineCache of its own, kept as one file, under the consumer's cap
The device-wide VkPipelineCache and its blob (written every 10 s and at the end, up to
256 MiB) are gone. Each VkPipeline is made through a small cache started from its file,
pipelines/<pipelineCacheUUID>/<SHA-256 of its creation: SPIR-V, entry, stage flags, required
subgroup size, constant IDs, the runtime's layout and the specialization>. The reaper reads
the cache's data and writes it as the file unless it is no longer than the file's (the
pipeline came from it), then destroys the cache: nothing is written on the calling thread,
and a hit writes nothing. At most 64 caches wait for the reaper; past that the data is
dropped (a miss next time), never back-pressure. Without a directory a pipeline is made with
no cache.

Translations and pipelines share one LRU store inside DeviceOptions::pipeline_cache_cap
(None = 512 MiB), ordered by use: a file's time on disk, moved forward at a use when older
than an hour, so the order holds across runs and processes. File reads and writes run
outside the store's lock. Metrics::cache_bytes_written counts the bytes written. The README
says a consumer should pass a directory (None compiles cold every boot).

Tests: the store's cap across both kinds; eviction by time on disk of files others wrote;
a file another removed is a miss; on every device, a second device writes nothing and leaves
every file as it was while the first's bytes written equal the files'; a second process adds
one pipeline file for its new pipeline and rewrites none.
2026-11-17 19:58:23 -08:00
Anees Iqbal 26a7658e0e rt tests: a texture's image is read once the pending upload has run
The upload copies a Managed buffer's changed ranges at its end, after everything recorded into
it before (the blit lane's change). The in-place test read the image over a Managed buffer through
the same upload, so the read ran before the did_modify_range copy and saw the device copy's zero
fill, on every GPU (legs 43804, 43805, 43806). Texture::image_bytes (test-only) now has the
pending upload submitted and waits for it before recording its read, so it sees what the next
command sees.
2026-11-17 19:54:28 -08:00
Anees Iqbal 4ab2897bf1 rt: the over-buffer device test holds a shader-read-write texture in place, and prints a render target's form
A render target over a buffer is not held in place on NVIDIA (2080, 3090), so the in-place
checks use a texture shaders read and write, at indices of a grant; the render target's
answer is printed per device. The bytes the test copies are the plain texture's upload and
three image reads.
2026-11-17 19:54:28 -08:00
Anees Iqbal 7424f5301b rt: what holds a texture's memory is named in fields the image keeps, and the device test compares the answer asked again 2026-11-17 19:54:27 -08:00
Anees Iqbal 231a0cc003 rt: a texture over a Managed buffer lies in its device copy; blits and dispatches that write a texture over a Shared buffer reach the host
The in-place linear image binds in the bytes shaders reach: a Managed buffer's device copy
where it has one, so replace_region writes the consumer's bytes and copies the rows' span
into the copy as did_modify_range does, and get_bytes reads the consumer's bytes as Metal
reads a Managed texture's CPU copy. A blit or dispatch that writes a texture over a Shared
buffer marks its segment's end to reach the host, as a write to the buffer does.

The device test (tests/over.rs) checks the alignment answer, the in-place texture over a
Shared and a Managed buffer (nothing allocated or staged, the image the buffer's bytes as the
host changes them, replace_region and get_bytes, a blit's write reaching the host), the
layout refusals and the gap.
2026-11-17 19:54:27 -08:00
Anees Iqbal 9646734a11 rt: a texture over a buffer is the device's linear image on the buffer's memory, where its layout is met
Buffer::new_texture (newTextureWithDescriptor:offset:bytesPerRow:) binds a linear image,
made preinitialized and kept in the general layout, at the texture's place in the buffer's
block, where the device's own linear image of the texture lays its rows at the guest's pitch,
the place meets the image's alignment and memory type, and linear tiling keeps every format
feature of optimal tiling the usage uses. Nothing is copied: replace_region and get_bytes
write and read the buffer, and the hazard sets track the texture under the buffer's id.
Rows not whole texels apart or shorter than a row, an offset off a texel, or texels past the
buffer are refused (Refusal::BufferTextureLayout); what the device's linear image does not
hold is Gap::TextureOverBuffer until the copy form is built.

Device::minimum_linear_texture_alignment answers per format the smallest power of two at
which the device's linear images of nine widths lay their rows at the row rounded up to it,
and of which the image alignment is a factor, across read, read+render and read+write.
2026-11-17 19:54:27 -08:00
Anees Iqbal e432e01fd0 replay: the rt backend's skipped objects carry no unread kind; a new block's free range is pushed (clippy, job m3-max-43948) 2026-11-17 19:50:26 -08:00
Anees Iqbal fc352835bc replay: the rt backend's translator errors map whatever error type the library answers 2026-11-17 19:50:26 -08:00
Anees Iqbal 53b6e17487 replay: the rt backend plays block buffers, synchronizeResource and the optionless buffer-to-texture blit; skips texture views, surface and tiled textures, pass descriptors, source libraries and what is made of a skipped object; a backend may decline the player's snapshots (rt does), counted unsnapshotted 2026-11-17 19:50:26 -08:00
Anees Iqbal ec7984da43 replay: the rt backend's heap storage mode reads with explicit precedence 2026-11-17 19:50:26 -08:00
Anees Iqbal 4b92cec28a replay: the player's backend over the new runtime, what it does not build yet skipped and counted; command-replay --runtime old|rt 2026-11-17 19:50:25 -08:00
Anees Iqbal 45b5778d03 conformance: the empty command buffer probe records what it measured on the M3
Job m3-max-43955 (M3 Max, macOS 27.0.1, five runs per case, plain and under the
validation layer): every case Completed with no error and nonzero GPU times;
handlers in commit order; an empty or fence-only command buffer after a busy one
reports equal start and end just after the busy one's end; an empty-kernel
dispatch ran on the GPU beside the busy one, its handler still after the busy
one's.
2026-11-17 19:47:36 -08:00
Anees Iqbal 11229c6989 conformance: a probe of what Metal reports for a command buffer that does no work
Its GPU start and end times, when its completed handler runs against the
command buffer committed before it on the same queue, and its status and error:
an empty command buffer, one with a compute encoder that only waits on and
updates a fence, and one dispatching an empty kernel, each alone and after a
busy command buffer.
2026-11-17 19:46:22 -08:00
Anees Iqbal bef6f4bb2b rt tests: the cross-queue counts are read before any busy command buffer completes, and a commit's lock wait is at least half the 20 ms hold 2026-11-17 19:40:19 -08:00
Anees Iqbal 3a0f6abca1 api signatures: the queue counters' Metrics fields 2026-11-17 19:40:19 -08:00
Anees Iqbal e1d2df75e4 rt: counters of what a second Metal queue adds: commit-lock waits, groups beside another queue, lone submissions across queues, forced flushes
Replay counted two Metal queues in flight at once in 99% of gb's frames, and every Metal queue
submits to the device's one VkQueue. These metrics measure what that costs on rt's own side, per
frame as differences of two reads:
- commit_lock_wait_nanos and commit_lock_wait_max_nanos: how long commits waited to take the
  submission lock, which every queue's commits and the submit thread take;
- groups_beside_another_queue: groups opened while another queue held one (each queue groups
  its own command buffers, so one queue would not have opened them);
- lone_submissions_across_queues: submissions sent with fewer than IN_FLIGHT of their own
  queue's in flight while the device had IN_FLIGHT or more across queues, which one queue would
  have held in a group;
- forced_flushes_across_queues: groups sent with no reason of their own queue's. No path sends
  one, so it stays 0; it is counted to show that.

Tests: every_device_counts_what_a_second_queue_adds (two lone submissions and one group beside
another queue, no forced flush, checked once the busy work outlasted the held commits),
every_device_counts_a_commits_wait_for_the_submission_lock (a commit behind a 20 ms hold waits at
least 20 ms).
2026-11-17 19:40:19 -08:00
Anees Iqbal 671ba2e958 rt tests: the view test grants the indices of every texture it makes
The test made textures at 4112 to 4114 with only 4096 to 4111 granted, so every
device refused the first (legs 43825-43827); the views, their bytes and the
refusals before it had passed.
2026-11-17 19:35:26 -08:00
Anees Iqbal 1874c8272d rt: a view of a Managed texture names the parent's bytes of its levels and slices
A view of a Managed texture had no named bytes, so replace_region and get_bytes
through it reached the image while the parent's reached its named bytes: a write
through the view was lost to the parent's getBytes, and a synchronize of the view
copied nothing. The view now takes the parent's buffer and the places of its own
levels and slices, in the view's level-major order, so both reach the same bytes
as Metal's do.

Test: every_device_views_a_managed_texture_s_named_bytes writes level 0 of a 2D
view of level 1, slice 1 of a Managed 2D array and reads it back through the
parent and from the named place.
2026-11-17 19:35:26 -08:00
Anees Iqbal 36cbf6e44c rt tests: the view test's cases take their types from their use
Clippy's type_complexity stopped lint m3-max-43764 under both device cfgs on the cases array's
annotation; the element types follow from the calls and comparisons that take them.
2026-11-17 19:35:26 -08:00
Anees Iqbal 9b427f7cf7 harness: a description's texture-view, a view of an earlier texture's slices
`texture-view PARENT TYPE SLICE SLICES` makes the next texture as
newTextureViewWithPixelFormat:textureType:levels:slices: of texture PARENT: its
format, extent, usage and storage, its one level, SLICES slices from SLICE, of
raw MTLTextureType TYPE (TextureSource::View). A parent not made before it, and
slices empty or past the parent's (Metal's validation stops both), are refused
with the line's number, as is a view of a type the harness does not make. The
run makes views from their made parents through ComputeDevice::new_texture_view:
the old runtime's new_texture_view_with_levels_slices and the new one's
new_texture_view, placed at an index as a texture is.

The described test gains workload `viewed`: a 2D view of slice 1 of a 2D array
read by texels_out, checked against the slice's bytes; tests.rs gains five
refusals.
2026-11-17 19:35:26 -08:00
Anees Iqbal 0a39715cf8 rt: texture views, a texture over levels and slices of its parent's image with image views of its own
Texture::new_texture_view(pixel_format, texture_type, levels, slices, index) is
newTextureViewWithPixelFormat:textureType:levels:slices: (and, with the
texture's own type and every level and slice, newTextureViewWithPixelFormat:).
A view is a TextureInner over its parent's image: its own sampled and storage
image views of the subresource range, its own index and elements of set 1, no
image, memory or copy. It keeps its first parent (a view of a view composes
the ranges), shares the parent's resource id so hazards between them are one
texture's, and reports Metal's view descriptor: the extent of its first level,
its levels and slices (probe texture_view_rules.m, job m3-max-43677: width 4
for levels 1..3 of an 8-wide texture, arrayLength 2 for slices 1..3).
place() takes the texture's base level and layer, so blit copies,
replace_region and get_bytes through a view reach the parent's levels and
slices under it. The view's image views go to the reaper (Free::Views) when it
drops; Gauges::textures counts views until then.

Built, from replay's compute-bound views (gb 18, b2 19): the parent's own
pixel format over every slice in its type, a slice subrange of a 1D or 2D
array, one slice of a 2D array as a 2D texture, each over any level
subrange. Refused as Metal's validation stops them (job m3-max-43677):
Refusal::TextureViewRange (empty or past ranges) and
Refusal::TextureViewFormat (another format without PixelFormatView usage).
Not built: Gap::TextureView naming the kind (TextureViewKind: PixelFormat,
TextureType, Slices, Swizzle).

Test (device cfgs): tests::view::every_device_views_levels_and_slices_of_a_texture:
six views and a view of a view report Metal's descriptor and read Metal's
bytes (the probe's FNV-1a 64 of each view's level 0 copied out), each view
costs 0 submissions, 0 blocks and 0 bytes copied; the three range refusals,
the format refusal and four gap kinds; views outlive their parents' handles
and every gauge falls to zero. The blit tests' Side carries the base.
README, REFUSALS.md and the signatures table updated.
2026-11-17 19:35:25 -08:00
Anees Iqbal 00288ca6dc replay: a placement heap's placements are a named type (clippy type_complexity, job m3-max-43774) 2026-11-17 19:22:14 -08:00
Anees Iqbal 647c186ec8 replay: placement heaps laid out for the runtime's sizes and alignments
A stream's heap offsets and heap sizes are the recording device's answers. On another device a
texture can be larger: b2 on an NVIDIA GPU stopped at a heap texture whose image the old runtime
makes 7.47 MB in a 5.9 MB heap. A live program lays its heap out by the device's
heapTextureSizeAndAlignWithDescriptor: and heapBufferSizeAndAlignWithLength:options:, so the player
now does the same: before it plays, it reads every placement in each placement heap ahead, asks the
backend the size and alignment of each (a texture's of its descriptor as its making call and setters
left it), and moves each offset up until the resources below it end and it is aligned, growing the
heap to hold them. Resources at one offset still share it; where every answer fits the stream's
layout, nothing moves. The report says what moved (`relaid HEAPS moved OFFSETS grown BYTES`).

The backend gains heap_size_and_align; the old runtime's answers through its own queries, with the
texture descriptor's making and setters shared with its play of those calls.

Verified: not yet built; a unit test on the keeping backend covers a texture larger than its room
(the buffer above it moves, the heap grows), a texture made again at its offset, a heap where every
answer fits, and the descriptor calls the backend is asked with.
2026-11-17 19:22:14 -08:00
Anees Iqbal b6368b040b translator tests: the builder's pointer and Workgroup-block tests follow the implicit-only Workgroup rule
pointer_classes_admit_only_their_layouts now checks a Workgroup pointer or
variable refuses an explicitly laid-out type, Block or not; the test of
member pointers into a Workgroup block goes with the blocks.
2026-11-17 19:17:15 -08:00
Anees Iqbal 4c3b32e481 rt: the floor's comment says threadgroup memory is implicitly laid out
Comment only: the arena is a word array and the typed shared objects are
typed variables, both implicitly laid out, so "addressed by byte offset"
described only the arena.
2026-11-17 19:17:15 -08:00
Anees Iqbal 54b39b4ea9 translator: Workgroup memory is implicitly laid out; the explicit layout's requirement path goes
Every Workgroup variable the translator declares is a plain array or
scalar, so the requirement walk's explicit-layout branch (the capability,
SPV_KHR_workgroup_memory_explicit_layout and its four features), the
entry interface's mixed-layout rule and the scalar Workgroup layout
feature were reached only by builder tests. ModuleBuilder::plain_global
and the pointer type rule now refuse an explicitly laid-out Workgroup
variable or pointee, Block or not, so the path cannot be reached, and it
goes with GlobalRule::MixedWorkgroupLayout and spirv-val's
--workgroup-scalar-block-layout option in the test validator. The
families_stage test checks the refusal; the workgroup layout census
checks no translated module declares the capabilities or requires the
extension or its features.
2026-11-17 19:17:15 -08:00
Anees Iqbal 61fa23a414 rt: the floor no longer requires VK_KHR_workgroup_memory_explicit_layout or its four features
The translator declares every Workgroup variable as a plain array or scalar
(the threadgroup arena, typed shared objects, SIMD-group scratch, mesh and
object state, the bind prepasses' lists), never an explicitly laid-out
Block, so no module it writes declares WorkgroupMemoryExplicitLayoutKHR or
its 8- and 16-bit access capabilities. The census over the fixtures, the
authored cases and the recorded kernels found none. The extension, its
feature structure in floor::Features, the four required features, the
README's floor rows and the floor tests' cases go; a device that lacks the
extension is no longer below the floor.
2026-11-17 19:17:15 -08:00
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