Commit Graph
555 Commits
Author SHA1 Message Date
Anees Iqbal 9b308145e9 A texture buffer goes on over its carried texels; the notice counts lost textures by storage mode
What: Texture::carry makes a texture buffer of new_texture again over its texels' buffer where the
recovery carried that buffer (texture_buffer_over, the runtime's own ID use), so a Shared one
reads the bytes the buffer carry kept; where the buffer was left it is made new as before.
Remade splits the textures whose contents were lost by storage mode (Shared, Managed, Private or
memoryless), and the recovery's notice says those three counts. carry.rs says how kept bytes are
read: Vulkan makes the content of external memory imported to a lost device undefined (vkspec
5.2.3), read as the hung work's writes possibly landing in part; once the lost import goes, the
pages are only our or the caller's memory. Docs: texture/carry.rs, carry.rs, the
DeviceRecovered cost (degradation.rs, docs/API.md, equal), the runtime README, and a known gap in
docs/FAST-PATHS.md: a recovery loses the contents of textures whose only copy is device memory
(new_texture of any storage mode), textures over carried pages keeping what their buffer keeps.

Why: the consumer asked for Shared textures' contents kept across a reset. A texture of
new_texture of any storage mode has no copy outside its image in the lost VkDevice's memory, so
keeping it would need a CPU copy at a cost to every frame; decided against for now, and recorded
as the known gap. Textures over carried pages already keep their bytes; texture buffers did not.

Verified: see the lane run reported with this sha (the test commit before it fails, this one
passes).
2026-11-12 16:27:36 -08:00
Anees Iqbal b564fb7a91 A recovery carries textures, their views and those over carried buffers
What: a device's recovery now carries the program's textures made by a call it can make
again (texture/carry.rs). That covers a texture of `Device::new_texture`, a texture over a
buffer the recovery carried (`Buffer::new_texture` and its kin), and a view of either.

- The call is made again on the new generation as the runtime's own texture, which takes no
  ID. That texture holds the program texture's parts there: `TextureShared::next`, with a
  `carried` flag.
- `Texture::s` picks the parts the work at hand reaches. Inside a command buffer's work it
  answers that generation's parts (`NoticesFor::generation`); elsewhere, those of the
  generation the texture was carried to last. The buffer carry picks its parts the same way.
- Every read of a per-generation field goes through it: `storage()` (the hub), facts, faces,
  usage shadows, storage forms, render shadows, snapshots, memoryless backings and planes in
  place.
- The texture object keeps its `ObjectId`, resource ID, label, parent and handles, and its
  purgeable state is copied across. Its ID's slot in the new generation's texture table and
  heap sets names its parts there (`heap_sets::place`), and leaving the slot walks every
  generation's parts.
- Each program texture is kept by its generation's carry registry as it is made
  (`Carry::texture`). The call that made it sets how to make it again (`Remake`) and carries
  it itself where the take came first (`Device::kept_texture`, `Carry::late_texture`).
- The carry runs inside a `NoticesFor::of_generation` scope for the new generation, so the
  buffer it remakes a texture over and a view's parent answer their parts there.
- Left refused, and counted by kind in the notice: a heap's texture or one over a heap's
  buffer, a texture over the caller's `VkImage`, a sparse or shareable texture, a texture over
  a buffer left, and their views.
- The notice adds ", and N textures whose contents were lost too (they read as new ones), M
  textures over the buffers carried and V texture views".

Known gap, documented in API.md, the README and device/carry.rs: a carried texture's images
on the lost generation, and so the lost `VkDevice`, stay until the texture goes. Letting them
go at the lost generation's rest needs a hold of the parts by each call outside command
buffers' work, as `Buffer::held_parts` does for buffers.

Why: render targets and display textures made before a recovery were refused
(`MadeBeforeRecovery`) where they met the new `VkDevice`, while Metal's go on.

Tests: device_recovery_carry's main test now leaves a `Shared` heap instead of a texture as the
object that keeps the lost `VkDevice`. Its held-parts test now expects the texture made by a
call that completed on the lost generation to be carried by its maker. Docs updated:
`MadeBeforeRecovery`, the device-recovered cost (degradation.rs and docs/API.md, kept equal),
the runtime README and the heap docs. docs/REFUSALS.md regenerated (`view` became `view_as`).

Verified: the lane run of the test commit before and this one after is reported with its sha.
2026-11-12 16:27:35 -08:00
Anees Iqbal b1d963289e The resident-set search is its loop alone, without 16 unrolled steps
Each resolve of a loaded pointer emitted 16 unrolled binary-search steps before the loop that
finished sets of more than 2^16 entries. RADV inlines every call of the search, so a module with
many loaded pointers paid the 16 steps at every site: on a curve-shading kernel with 1,065
searches, its creation on the 780M took 92.9 s and 8.4 GiB of compile memory.

The search now starts the loop from all N entries. A step halves the candidates whatever its
compare gives, so the trip count, ceil(log2 N), depends on N alone: every invocation that
searches one table takes the same branches, and a set below 2^16 entries does fewer entry loads
than the 16 steps did (they kept loading after one candidate was left). search_step is the loop's
step; search_rest is now bisect, from (0, N). SEARCH_STEPS is gone, SEARCH_WORDS charges one step
plus the loop, and the docs (roots.rs, API.md) and the tests that named the unrolled reach say
what is true now. The handle-table search keeps its own unrolled steps. Answers are unchanged.

Measured on the 780M (RADV PHOENIX), before (1125fb62d2) and after, one job (m3-max-23016), one
run each:

The curve-shading kernel's creation (pipeline cache off, RADV_DEBUG=shaderstats):
  time in the driver   92.9 s -> 62.6 s
  peak RSS             8,462 -> 5,846 MiB
  ACO instructions     1,741,690 -> 1,000,747
  spilled VGPRs        179,037 -> 105,970
  spilled SGPRs        95,824 -> 46,562

GPU time of a dispatch whose 262,144 threads each resolve 64 loaded pointers, over M buffers made
resident, every lane's address the same (uniform) or its own (divergent); median of 15 commits,
every thread's sum checked (0 wrong in every row):
  M        form       before      after
  16       uniform    5.56 ms     4.02 ms   -28%
  16       divergent  4.61 ms     4.03 ms   -13%
  1,024    uniform    5.58 ms     6.52 ms   +17%
  1,024    divergent  8.37 ms     7.84 ms    -6%
  66,048   uniform    7.86 ms     9.04 ms   +15%
  66,048   divergent  92.4 ms     95.8 ms    +4% (ranges overlap)
Uniform addresses over sets of 1,024 entries or more cost 15-17% more GPU time: the loop's exit
test and back branch at each step cost more there than the unrolled chain's extra steps.
2026-11-12 16:12:29 -08:00
Anees Iqbal a610b58b8a A replayed draw whose making outlasts the commit's bound leaves its pass to the host step
The last draw dropped for its making's time: a draw of an execution's replay at commit (render
commands the CPU writes) whose pipeline the replay began itself and that was still being made at
the command buffer's bound recorded nothing. Metal cannot encode a draw before its pipeline
exists, so every encoded draw runs.

Now the replay at commit stops there, keeps the making on the command buffer
(CommandBuffer::leave_unmade), and the pass takes it into the makings its host step waits for
(DeferredPass::left_for_makings): the commit leaves the pass to the host step with its
pipelines pending, as it already did for a pass whose settled makings were still being made, and
the step records it from the records as they stand then once the making lands. A replay inside
a host step waits for its making until made, on the step's thread. record_on_gpu declines to
the host step the same way. The commit still returns at its bound at most.

Removed: DrawDroppedStillMaking, WorkCounts::draws_dropped_still_making,
CommandBuffer::drop_late_draw, RenderLowering::drop_late_replayed_draw, the execution's encoder
place that only named the dropped draw, and the open-gap text in FAST-PATHS row 43, API.md (the
bullet and the catalogue entry), the runtime README and the PipelineWaitPolicy docs
(api_signatures.tsv -2). The IndirectCommandCheck and executed-commands docs name the new case
in which an execution read at commit is read and checked again in its host step.

The gap's test flips: a_replayed_draw_whose_pipeline_is_still_being_made_at_its_bound_renders_once_made
(commit returns after the bound and before the 10 s watchdog; the command buffer is not complete
a second past its bound while another queue completes; once the hold goes it completes with the
rectangle drawn and nothing dropped). Checked by the lint and lavapipe jobs reported with it.
2026-11-12 16:01:25 -08:00
Anees Iqbal b4eaf4caa7 Keep the replayed draw's test as the open gap's, and name the gap by the replay's own wait
The lavapipe run (m3-max-23046) showed a draw of a commit-time replay of
CPU-written records dropped at the bound: the replay waits for that
making itself, which the settle did not leave to the host step. That is
the open gap this change keeps; its test asserts the drop, and the docs
name the gap by the replay's own wait.
2026-11-12 15:41:59 -08:00
Anees Iqbal 91dbc91bbc Hold a command buffer for its draws' and dispatches' makings instead of dropping them
A dispatch whose pipeline was still being made 4.5 s after its command
buffer's commit recorded nothing, and so did such a draw. Metal makes a
state's pipelines inside its creation, so every draw and dispatch it
encodes runs: a dropped dispatch leaves wrong results (a guest's path
tracer dropped 45 dispatches behind a 116 s compile on the RX 7900 XTX),
and a dropped draw leaves content drawn once (a cached shadow map, a
glyph atlas) without it. The owner's rule: no switch may break Metal's
contract, so the dropping form is removed, not kept behind a switch.

A batch's host step now waits for every making its segments record,
past the bound too (Segment::steps_after_pipelines; the scheduler's
StepWaits loses its `until`, and Segment::holds goes): the batch stays
in its queue's line on the scheduler's thread, which no call waits for,
and records the draws and dispatches once made. Held batches still give
way to other queues' later commits that share no fence. `commit` waits
for no making but a pass that executes render commands the CPU writes,
until its bound, and leaves that pass to the host step past it. The
pending dispatch, tile dispatch and pending draw recordings wait until
made. DispatchDroppedStillMaking, its counter and catalogue entry, and
CommandBuffer::drop_late_dispatch are removed.

One drop remains, an open gap named in FAST-PATHS and the notice: a draw
of an execution's replay whose pipeline the replay itself began making,
of a key the commit's settle did not foresee, still being made at the
bound (DrawDroppedStillMaking, now that case alone). That case is the
next change.

Tests (device, rewritten): a draw, a replayed draw and a dispatch whose
makings are held past the bound each complete once the making lands,
drawn or written, nothing dropped, while another queue's command buffer
completes meanwhile and the held one is still not complete a second past
its bound.
2026-11-12 15:41:59 -08:00
Anees Iqbal 3c88a7df60 An address pool goes on past its device's recovery
What: `AddressPool` holds a root handle of its device (`Device::root`) and the device's
address space, instead of a handle of the generation it was reserved on. A buffer placed in
one of its slots after a recovery passes the same-device check (`Device::same` answers a root
and any generation of its line alike), and the pool's drop gives its span back to the address
space, which every generation shares, without reaching a generation.

Why: a consumer found that after a recovery every new buffer in a slot of a pool reserved
before it was refused (`MadeBeforeRecovery`), which refused all of its buffers under 16 KiB.
A pool holds no Vulkan object and no memory: it is a span of the line's address space
(`AddressSpace::reserve_pool`), and a buffer in a slot takes its own memory as any buffer
does, only its Metal address from the slot. Holding a generation handle also kept the lost
`VkDevice` alive while the pool lived.

Docs: the recovery lists in `MadeBeforeRecovery`, the device-recovered cost (degradation.rs
and docs/API.md), the runtime README and device/carry.rs name address pools; the pool's own
docs say it goes on. docs/REFUSALS.md regenerated with no change.

Verified: the lane run of the test commit before and this one after is reported with its sha.
2026-11-12 15:33:06 -08:00
Anees Iqbal 62923811dc A library and its functions go on past their device's recovery
What: a library holds a root handle of its device (Device::root) rather than the generation
it was made on, and its functions take that handle, as a fence does. A library is the
compile layer's parsed library and a function the compile layer's function with its
constants, no Vulkan object; their sampler-ID holds are the line's resource IDs, which every
generation shares. So a pipeline made from them on any generation passes its device check
(same matches a root handle by its line), and they no longer keep the lost VkDevice alive.
Docs: library.rs, carry.rs, MadeBeforeRecovery (libraries leave the refused list), the
device-recovered cost (degradation.rs and docs/API.md), the runtime README. REFUSALS.md
regenerated: unchanged.

Why: after a recovery a pipeline made from a library or function made before it was refused
NotImplemented(MadeBeforeRecovery); Metal's library goes on.

Verified: see the lane run reported with this sha (the test commit before it fails, this
one passes).
2026-11-12 15:11:30 -08:00
Anees Iqbal fb7eaa8cbc A depth/stencil state goes on past its device's recovery
What: a depth/stencil state holds a root handle of its device (Device::root) rather than
the generation it was made on, as a fence does. The state is its descriptor and the compile
layer's Vulkan depth/stencil state, no Vulkan object, so a render encoder of any generation
accepts it (check_device matches a root handle by its line), and it no longer keeps the lost
VkDevice alive. gpu_resource_id asks supports_family, which goes to the serving generation,
instead of the "now" form a root handle has no generation for. Docs: depth_stencil.rs,
carry.rs, MadeBeforeRecovery, the device-recovered cost (degradation.rs and docs/API.md),
the runtime README. REFUSALS.md regenerated: unchanged.

Why: after a recovery a state made before it was refused NotImplemented(MadeBeforeRecovery)
at set_depth_stencil_state; Metal's state goes on.

Verified: see the lane run reported with this sha (the test commit before it fails, this
one passes).
2026-11-12 15:11:29 -08:00
Anees Iqbal e05beb832d A fence goes on past its device's recovery
What: a fence holds a root handle of its device (Device::root) rather than the generation
it was made on. A fence has no Vulkan object, only the key the tracker orders on, so
update_fence and wait_for_fence of any generation's encoder now accept a fence made before
a recovery (check_device matches a root handle by its line); an update made on a lost
generation went with that generation's work, so a wait on the next one finds none, as for a
fence never updated there. The fence no longer keeps the lost VkDevice alive. Docs: fence.rs
module and item docs, carry.rs, MadeBeforeRecovery, the device-recovered cost (degradation.rs
and docs/API.md), the runtime README. REFUSALS.md regenerated: unchanged.

Why: after a 780M gfx ring timeout and a recovery, a guest's waitForFence: calls were
refused NotImplemented(MadeBeforeRecovery) about 2,000 times; Metal's fence goes on.

Verified: see the lane run reported with this sha (the test commit before it fails, this
one passes).
2026-11-12 15:02:41 -08:00
Anees Iqbal b10839e2b2 A recovery carries Private heaps with the buffers placed in them
What: a device's recovery now carries each live heap to the new VkDevice (Heap::carry,
called from Device::carry_to after the buffers, or by a heap's maker where the recovery
took the generation first). A Private heap's own buffer is made again in new memory placed
where the heap's textures can lie (place_heap_buffer), zeroed as a carried Private buffer
is, keeping its ObjectId, hazard key, Metal address and range, range token, label and
purgeable state; the heap is registered by its key there and kept in the new generation's
registry for a later recovery. Each live buffer placed in it gets a new link on the new
generation (Buffer::carry_placed) at the same offset of the carried bytes, with the same
ObjectId, address, label and a shared aliasable flag; its old link lets go of its live-list
entry and device handle at the lost generation's rest (LostPlaced). A placed buffer's drop
gives an automatic heap's range back only from the link carried to last, so a carried
buffer frees its range once. A buffer placed while the heap is being carried carries itself
under the heap's placed lock. The heap's textures made before stay the lost generation's
(no recovery carries a texture); the heap forgets them (keeping their numbering), so a
use_heap on the new generation never makes an old image resident. Shared heaps (their bytes
are pooled host-visible memory, never the runtime's own pages), no-copy heaps and sparse
heaps stay left, with their buffers.

The recovery notice now counts carried heaps ("N `Private` heaps (B bytes) with the M
buffers placed in them") and left heaps by kind, and splits the old "buffers over the
caller's or exportable memory" into "buffers over the caller's `VkBuffer`" and "buffers in
exportable memory" (Left::Caller / Left::Exported). Docs: carry.rs module docs, the
Buffer::carry docs, heap.rs, MadeBeforeRecovery, the device-recovered cost (degradation.rs
and docs/API.md), the runtime README. REFUSALS.md regenerated: unchanged.

Why: after a GPU recovery a guest's MTLHeap newBufferWithLength:options:offset: was refused
NotImplemented(MadeBeforeRecovery) and the guest got nil; Metal's heap goes on.

Verified: see the lane run reported with this sha (the test commit before it fails, this
one passes).
2026-11-12 14:59:22 -08:00
Anees Iqbal da3cea7633 A heap texture's chosen constexpr samplers are one sampler array, not a switch
A heap texture sampled through one of several constexpr samplers that a
sampler handle names at run time (a table of constexpr samplers read at a
computed index) was a switch-at-use with one arm per candidate: each arm
its own heap sampling and raw-texel emulation. On large kernels that
multiplies the sampling code by the candidate count.

Where every candidate is a constexpr sampler, their handles are
consecutive, each candidate's sampling is the same but for its sampler
and the state its raw emulation follows, the use is not tangled, and the
device indexes a sampler array non-uniformly
(shaderSampledImageArrayNonUniformIndexing, which heap textures already
need), the sampling is now one sampling through a set-0 array of the
candidates' samplers (ResourceKind::SamplerArray,
BindingSource::SamplerArray): element handle - first, NonUniform, its
immutable samplers each made as the heap sampler of that candidate alone
would be (DescriptorBinding::immutable_samplers, listed per stage in
StageInterface::sampler_arrays). A handle outside the array reads zero,
as the switch's null arm. The raw emulation reads the element's sampler
word from a constant table at the same index (heap_raw::State::Table),
through the runtime-word path. Elsewhere the switch stays.

The runtime bakes one sampler per element into the set layout, pushes
each element's own sampler where set 0 is pushed, and keys the set-0
shape on them.

Tests: the array form on every profile with the sampled heap (one
sampled image, L3), the switch kept for non-consecutive handles, each
element equal to the immutable sampler of the candidate sampled alone and
never written by the plan, and a device test (lavapipe under
m2v_cpu_icd) that each lane reads what its sampler alone reads and what
the address modes define.

Docs: API.md section 5, the sampler module doc, api_signatures,
api_surface, REFUSALS regenerated.
2026-11-12 14:55:47 -08:00
Anees Iqbal bcfec16960 A rate-mapped draw skips the regions its viewport and render area leave no pixel
Each draw of a rate-mapped pass was recorded once per region of the map's plan, even where the
region's scissor, cut to the pixels whose centres lie in the guest's viewport and to the render
area, held no pixel. Such a recording shades nothing (the scissor test discards every fragment),
and its vertex function repeats nothing observable (a plan of several regions refuses a vertex
function that writes memory), so it is now left out. Where the cut leaves no region a pixel, the
first region alone is still recorded through its empty scissor, so the vertex function runs as
Metal's does. A draw whose viewport covers part of the screen now records only the regions it
reaches; one over the whole screen records what it did.

The new lane test draws the case's fullscreen triangle over a 256-pixel map at the falling
quality with a viewport over the screen's left quarter: fewer regions than the whole screen's,
from an indirect buffer region by region, and the direct (batched) draw shades bit for bit the
same pixels, inside the left half of the physical columns.
2026-11-12 14:37:06 -08:00
Anees Iqbal 1b1ebfd055 GPU times from the host start at the first submission that carried the work
A command buffer whose work went as several submissions (a wait for an
event the host signals, an execution its host step records) answered,
on a device made with gpu_times_from_host or a driver whose timestamps
wait for every queue's, the call of its LAST submission (its
kernelEndTime) as its GPUStartTime: its window missed the work of its
earlier submissions. Metal's GPUStartTime and GPUEndTime span the whole
command buffer's GPU work. A consumer that answers GPU times from the
host read windows of 0 to 240 ms on an Iris Xe for command buffers whose
kernel start to end spanned 2 to 8 s, each GPU start at the kernel end.

KernelTimes keeps the call of the first driver's submission that carried
a batch of the command buffer (the batch's own vkQueueSubmit, or its
group's), and the host-clock start is that call where it came before
the kernel end, else the kernel end as before, or the queue's latest GPU
end where later. A command buffer whose work went as one submission
answers as before. Devices that write timestamps already started at the
first batch's timestamp (lavapipe, job 22670: GPU start 173 ms before
the signal its second batch waited for).

Docs: gpu_time.rs (the host-clock bullet, rule 2), gpu_start_time,
DeviceOptions::gpu_times_from_host, the GpuTimesFromHost notice's cost
and its API.md entry.

Verified: pending lavapipe before and after, the 780M, lint.
2026-11-12 14:35:01 -08:00
Anees Iqbal 6014ad370d Faces: a logged pass turns, and an encoding again meets the faces as first met
While the device has a buffer over host pages, every render pass logs its calls for a rebind,
and a pass with a log, or with an earlier encoder of its command buffer keeping one, turned no
texture (Unturned::Pass): under a consumer that keeps host-page buffers alive, no attached read
ever took the turn and every one copied in.

A logged pass now turns as any other. A rebind's encoding again of the command buffer's encoders
meets the faces as their first encodings met them: the encoding again runs with a thread-local
context of the command buffer and the encoder's parts (with_faces_as_of); a texture a later pass
of the command buffer turned presents the face from before that turn to it (Faces::face), and
the turning pass encoded again takes its turn again (Texture::retake_turn: the shadow of the face
from before the turn held current, no copy in). Any other pass encoded again turns nothing.
TurnPoint drops logs_kept; SwapRecord keeps the face it turned from.

The shadow log (METAL2VULKAN_LOG_SHADOWS) also names, once per shadowed texture, at the first
draw that binds it after its shadow was made: the slot, whether the function fetches, samples or
writes it, and each sampler's min, mag and mip filters (a sampler state's by Metal's names, a
constexpr sampler's as the layout bakes it).

Tests: the runtime's attached_read_faces gains a lane with a host-page buffer alive (a logged
pass turns; a blit and a turning pass behind a shared-event wait, encoded again by a rebind, read
the texels from before the turn), against the same lane beside an open command buffer (the copy
route); the validation crate's runtime_lane::logged_face_turns runs the same under the layer.
Not yet run: dispatched next.
2026-11-12 14:03:30 -08:00
Anees Iqbal f62966f4f0 did_modify_range's bytes are taken at the next commit, as Metal takes them
What: did_modify_range (and a CPU write through a texture over a buffer) notes the range on the
device (managed.rs Modified); every commit, at its start and before it returns, copies each
noted range of a buffer with a host copy on the CPU into staging buffers as the host copy holds
it then (Buffer::upload_now, CallerCopy::copy_in_now, managed_copy::stage_in), which the next
submission copies into the device copy before any of its commands. A range the staging buffers
find no memory for falls back to the copy from the host copy as the submission runs.

Why: the copy in read the host copy (the caller's pages through their import, or the runtime's
own host copy) when the GPU ran it, so a CPU write made after the commit, before the GPU reached
the command buffer, was what the command buffer read. Metal on a Radeon Pro 5300M (macOS
26.7.1, reims's oracle) takes the bytes at the commit after didModifyRange: a write before the
commit (after the call, or with the command buffer encoded before it) is read, one made 30 ms
after the commit while the GPU spun is not. Capturing at the call would be wrong (steps 2 and
3 read the later write there). An RX 7900 XTX computed frame 0 of a benchmark on frame 1's
input this way.

Docs: managed.rs and managed_copy.rs state the rule and its cost (a CPU copy of the range's
bytes at the commit); API.md, the runtime README and FAST-PATHS.md's managed row follow.
managed_bytes_copied_in counts a caller copy's copies alone, as before.

Verified: the lane test of the parent commit on an RTX 3090 (job ids in the report).
2026-11-12 13:47:32 -08:00
Anees Iqbal a7ba65dd66 synchronize_texture copies a Managed texture's bytes over a two-copy buffer out
What: on a device without unified memory, BlitCommandEncoder::synchronize_texture
now copies a Managed texture's bytes over a buffer from the buffer's device copy to
its host copy (the caller's pages, or the runtime's own host copy), as
synchronize_resource of the texture already did. A level that lies in the image
alone (a tiled texture's past its first) copies nothing; a texture of an image
alone still records nothing, its CPU access reading its image. The copy is shared
code: synchronize_resource's buffer and texture arms now call synchronize_bytes and
synchronize_texels.

Why: synchronize_texture recorded nothing on every device, its doc saying Managed
memory behaves as shared memory. Without unified memory a Managed buffer is two
copies (managed.rs, managed_copy.rs), and a texture over one serves get_bytes, and
the buffer its contents, from the host copy (buffer_texture.rs Texels::read). So a
program that synchronized with synchronizeTexture:slice:level: read the CPU copy as
of its last didModifyRange: stale texels. Found reading the read-back paths for a
benchmark that fails validation on an RX 7900 XTX.

Docs: the stale doc is replaced; API.md and FAST-PATHS.md name synchronize_texture
beside synchronize_resource for the copy out; the managed counters' docs count it.

Verified: the lane test runtime_lane::device_copies::
a_synchronize_texture_copies_the_texels_out (a blit into rows of a Managed texture
over pages and over a runtime-made Managed buffer, then synchronize_texture: the
contents and get_bytes hold the rows; the copy out counted for the pages with two
copies) is run on a discrete NVIDIA GPU with this change and once without the
runtime fix (negative control); job ids in the report.
2026-11-12 13:27:01 -08:00
Anees Iqbal df9ae6b02d Snapshot reads with no barrier: API.md's accepted difference covers writers
docs/API.md's accepted difference for a draw that reads its own pass's color at its own pixels
with no barrier now covers a draw that writes the color too: it reads what the draws before it
wrote where the runtime takes no copy for it (in place, or through a snapshot where the device
takes that route and the snapshot costs no more than the copy: a surface's reader always, a
private texture's by the area rule), else the copy, the M3 Max's texels. Its lead-in is the slug
the pass-start-barrier read rows name. FAST-PATHS.md's row and texture/attached_reads.rs say the
same, each naming both answers.

Verified: docs only; the conformance unit test that the slug exists runs in the 780M job.
2026-11-12 12:52:10 -08:00
Anees Iqbal 090930eebf Queue times: a default-off diagnostic notes when a command buffer became its queue's head and when its submission returned
What: with METAL2VULKAN_QUEUE_TIMES set, each command buffer notes two host times beside its kernel
times (gpu_time::KernelTimes), read through two hidden runtime-extension methods:
- CommandBuffer::queue_head_time: its first batch became the first of its queue's batches the
  scheduler had not taken. Noted as the scheduler takes it in onto an empty line, or as the batch
  before it on its line is taken for submission (Order::next, in the scheduler's passes and a
  committing thread's).
- CommandBuffer::submit_returned_time: the vkQueueSubmit that carried its last batch returned
  (submit.rs for a batch submitted now, group.rs for a group's members). kernelEndTime is that
  call's start, so the two bracket the driver's time in the call.
Unset, nothing is noted and no line is looked up: a relaxed load of the device's flag (read once
from the environment into gpu_time::Timing) per take and per submission.

Why: walkprof5 (m3-max-22376) put commit -> submission start at 37.0 ms p50, while kernel start to
kernel end was 0.008 ms, which does not bracket the vkQueueSubmit cost (the call starts at the
kernel end). The consumer's trace needs to split commit -> submission into time behind the
queue's earlier work and time held at its head, and to see each call's own length.

Docs: env_vars.rs's registry entry and accessor, docs/API.md's diagnostics paragraph, the
validation artifact note's list of variables the runtime reads; api_signatures.tsv blessed (two
hidden methods).

Tests: tests::kernel_end_device::queue_times_are_noted_in_the_order_of_a_queue_s_submissions_and_only_where_asked
(three command buffers on one queue, committed back to back): unasked, both read 0; asked
(Timing::note_queue_times, test-only), head <= kernel start <= kernel end <= returned for each,
heads in commit order, and each submission returned before the next one's kernel start.
2026-11-12 12:45:56 -08:00
Anees Iqbal 8274894e15 API.md: a rate-mapped pass draws several regions in one multi-draw where the device allows it
The accepted difference "A rate-mapped pass draws region by region" now says where the device
enables multiDraw, multiViewport, shaderOutputViewportIndex and shaderDrawParameters, a direct
draw of a vertex pipeline records up to the least of maxViewports and one below
maxMultiDrawCount regions in one vkCmdDrawMulti[Indexed]EXT, its vertex variant storing
ViewportIndex as DrawIndex, with the same pixels.

Docs only; the behaviour landed in the previous commits.
2026-11-12 12:37:46 -08:00
Anees Iqbal 3591461c0b Memory log: each copy of a no-copy object's host pages says its caller's pointer and length as it is made and as it goes
An Iris boot lost its VkDevice to one float written into an ANV batch buffer right after the
boot's one copied no-copy buffer was made. A copy's merge back writes exactly the bytes the GPU
changed into the caller's pages, one 4-byte store for one changed float, so a caller mapping
unmapped under a live no-copy buffer and reused for a batch mapping would show that symptom. The
memory log (METAL2VULKAN_LOG_MEMORY) placed only device addresses, so it could not test that.

With the log on, the copied registry (copied.rs) now says one line as each copy is made and one
as it goes: its number, the caller's pointer and length with the range's end, and the copy's
host address and end, the two ranges the runtime's comparisons write on the CPU. The going line
is said after the registry's lock is let go, as the consumer's sink takes it. Off, nothing is
formatted: the registry holds no log.

Verified: fmt only here; the new tests::memory line test, clippy and rustdoc run on a CPU node
next.
2026-11-12 12:25:38 -08:00
Anees Iqbal 182e21e83c Arguments that function constants put on overlapping slots of one table are an invalid request
Function constants can set an argument's slot ([[texture(c)]]; the frontend states the index as a
global the static initializer computes). Values that put two present arguments of one argument
table on overlapping slots make a specialization Metal refuses when it makes the function: "<kind>
argument X has invalid location (<index,count>)", naming the later argument. Measured on an M3 Max
(macOS 27.0.1) for:
- buffers, a constant buffer and an argument buffer;
- a visible and an intersection function table, and an acceleration structure;
- textures, and a texture array overlapping a range;
- samplers;
- threadgroup memory.
Arguments of two tables at one index (a buffer and a texture at 0) are made.

The translation took such a set as valid and went on. Where a write texture and a sampled one met
on slot 0, the slot plan gave the slot the write access and the sample was refused as
Unsupported(Lowering(Sampler)), NotImplemented: a gap that is not ours. Where the two arguments'
uses agreed, one resource stood for both, a pipeline Metal never makes.

The specialized entry now refuses it (canon::interface, beside the duplicate color output check),
as RequestError::OverlappingArgument { param, index, count } and
DescriptorError::OverlappingArgument. Only present arguments count (MPS keeps gated pairs on one
index), and a count of 0 binds no slot. past_table and the new check share one table map.

API.md, the runtime's new_function_with_name_constant_values doc (the runtime checks constants
when a pipeline compiles the function) and the specialization planner's doc say so. The
signatures table is re-blessed; REFUSALS.md is unchanged (this is a refusal Metal makes).

Verified: the canon test covers each table and the non-overlapping cases. The MPS census A/B
(590 rows, every constant 0, release CLI on msi, base 9c2635b430) moves 42 rows to
InvalidDescriptor(OverlappingArgument): the 35 Lowering(Sampler) rows, 2 Lowering(Texture) rows,
and 5 rows that translated a specialization Metal refuses. No other row changes. With constant 125
(the batch size that puts the sampled texture after the written one) set to 1, all 42 translate
and pass spirv-val.
2026-11-12 12:14:41 -08:00
Anees Iqbal 0a4f4e87f2 Labels: command buffers and encoders take Metal's label, and a lost device's notice names the hang by them
A lost VkDevice's recovery notice named its hang only as "a command buffer (of queue `Q`)",
so an Iris boot's GpuHang (46 victims) left nothing to tell which work hung. The runtime had
no label for a command buffer or an encoder at all.

CommandBuffer::label/set_label (MTLCommandBuffer.label) and label/set_label on the blit,
compute, render and resource state encoders (MTLCommandEncoder.label) now keep what the
program sets. A command buffer has one encoder open at a time, so the open encoder's label
lives on the command buffer's state, and the encoder's record takes it as it ends: each
EndedEncoder reports its label, in its place, a render encoder that ends on the lowering
thread included. The recovery names its culprit from the command buffer's state as it fails
the pending batches: its label and its queue's, then its first 32 ended encoders' places,
kinds and labels, counting the rest, e.g. "command buffer `busy` of queue `relayed` (its 1
encoder: 0 blit `copies`) failed as the hang (`GpuHang`)".

set_label and label are no calls in EncoderCall's numbering. The API table, the Metal and
conformance coverage maps, docs/API.md's DeviceRecovered entry and the runtime README say so.
The table's WorkCounts::spare_command_buffers_freed_past_recorded line moves to where the
script sorts it.

Verified: fmt only on this machine; tests::labels (both lowering policies) and
tests::device_recovery's relayed-loss test, which asserts the named notice, run on lavapipe next.
2026-11-12 12:12:54 -08:00
Anees Iqbal 99146ff67f In-place reads: the lane test and docs name the devices whose passes fetch no color
A pass on a device with rasterization-order color attachment access (lavapipe) or without the
pixel interlock (the RX 550) fetches its colors as input attachments, and in place, like the
snapshot, takes no such pass (its subpass would name the color in two layouts). The lane test
asserts the read in place only where the device's passes fetch no color, and API.md, FAST-PATHS.md
and render/snapshot.rs say which devices keep the copy.

Verified: lavapipe lane job m3-max-22227 (msi) at e83d75fe83: 33 of 34 attachment-read, snapshot
and in-place tests passed, debug and under METAL2VULKAN_LANE_VALIDATION=sync; the one failure was
this expectation (lavapipe fetches through inputs: copies 1, in place 0).
2026-11-12 11:55:21 -08:00
Anees Iqbal 7284147b43 A draw that reads its own color at its own pixels and writes none of it reads in place
A draw whose fragment function reads, at its own pixels alone, a texture its own render pass
instance renders as a color, and whose pipeline writes no channel of that color, now reads the
attachment in place, with a memory barrier before it or without: no copy, snapshot or split.
The color is in the feedback loop layout for its instance, the pipeline is made with
VK_PIPELINE_CREATE_COLOR_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT, and the slot binds the texture in that
layout. A by-region barrier before the draw (color writes to fragment shader reads) orders the
earlier draws' and the load's writes before its reads (Vulkan 8.10.5), and a by-region execution
barrier after it (fragment shader to color output) orders its reads before later draws' writes.
Its own writes go to other colors, so no fragment of the draw races another over the texels it
reads. It reuses the snapshot route's checks (pass shape, view format, pins, one image) and its
binding (render/snapshot.rs, in place), on a device that enabled attachmentFeedbackLoopLayout.

Why: the real Macs disagree on such a read without a barrier (probe ownread.m: the M3 Max
answers the texels from before the pass at every pixel; the 5300M answers the earlier draws'
writes at 98.6% of pixels and at all after a barrier; the UHD 630 at all but 0.01%). Under the
owner's rule for such disagreements we take the cheapest form, the x86 Macs' answer, recorded as
an accepted difference in docs/API.md. A compositor's backdrop reads paid a copy of the whole
target per draw before.

texture/attached_reads.rs now gives a color's image feedback loop usage wherever the device
enabled attachmentFeedbackLoopLayout, not only where it has the snapshot route's write-mask
command. New WorkCounts::reading_draws_in_place (api_signatures.tsv row). The draw-key and
graphics-key carry a feedback_loop bit for the pipeline flag.

render.rs (the draw's snapshot plumbing) is touched at: the draw's snapshot request, the phase
hole, the counts, the snapshot views, the pair base and phases, Recording::record (the barrier
after), and settle_draw's snapshot checks.

Lane test runtime_lane::in_place_reads with an owned fixture ipr_reads.metal (regenerated with
scripts/regen-air-fixtures). The golden tables and the compile census are re-blessed on
development.

Verified: not yet compiled; potluck build, lint and lavapipe lane jobs follow.
2026-11-12 11:55:21 -08:00
Anees Iqbal 47ca9278c8 Pages beside live dma-buf imports import their own dma-bufs, not a copy
A no-copy buffer or heap (made or rebound) whose pages a live import of another holds some of
was always a copy of them (CopiedBecause::OverImport), for VK_EXT_external_memory_host's
undefined second import of a host pointer (its issue 6). On RADV every no-copy object's pages
are udmabuf dma-bufs, which that clause does not cover, so since the one-import rule landed a
consumer's 780M walk made 2715 such copies (copied_over_live_imports, 292 MB copied in).

Now, where every live import that holds some of the pages is of dma-bufs, the pages come with a
source of dma-bufs the device imports, and the device's barriers order blits through two
imports of the same pages (no RuntimeDriverDefect::AliasedImportBlitsUnordered, which ANV and
MoltenVK have), the object imports its own dma-bufs from the source, never its pointer
(Device::imports_beside). Two dma-bufs of the same pages are two aliases of external memory
(Vulkan 1.4, 12.11 Memory Aliasing: consistent for buffers, uses separated by a memory
dependency); the tracker orders every use by the host bytes it touches across keys with global
memory barriers, as for a guest RAM's run imported beside its chunk. A pointer import on either
side keeps the copy. A failed import there falls back to the copy, announced with the failure.
HostAliases::within now names the live imports that meet the pages (Within::Meets(Vec)).
Counted: ObjectChurn::dma_buf_imports_beside_live (imports_inside_live stays the count of
pages imported twice where that is undefined).

Tests: tests::dma_buf_beside (device, Linux): a buffer over part of a live import's pages and a
buffer rebound onto pages two live imports hold some of, as made and without pointer imports:
beside dma-bufs where the first import is of dma-bufs, else a copy; the GPU reads the CPU's
bytes, CPU writes between encode and commit reach the command, GPU writes reach the pages and
the other buffer, and in imports a fill through one and a copy through the other in one encoder
are ordered either way. The host_aliases unit test checks Meets names the import met. The
validation lane's dma-buf joined-import test takes the third outcome. Checks: to run.
2026-11-12 11:11:08 -08:00
Anees Iqbal 3a619009b7 Run one-row threadgroups of a row-lockstep kernel on a variant without its simdgroup barriers
What: a kernel whose only simdgroup semantics are lockstep simdgroup barriers that order pairs
meeting only where a simdgroup spans two rows (RowLockstep) kept them, their cross-lane class
and, on a device with tangled 32-lane subgroups, its pinned subgroup size, even for a dispatch
of one-row threadgroups, where no such pair meets. On the Iris Xe that pin makes ANV compile a
register-heavy kernel at SIMD32, which spills and takes seconds where SIMD8 takes 0.3 s.

- Address facts: a place among the threadgroup's linear threads (thread_index_in_threadgroup,
  and under rows thread_position_in_threadgroup's x, never the grid's) with its low five bits
  cleared (`& -32`) or shifted out (`>> k`, k >= 5) is one value per simdgroup (AddrFacts::
  aligned, in fixed). The lattice walk skips such terms like uniform ones, and its spread now
  holds two facts, the finest lattice and the whole bounded difference, either clearing a pair.
- Lockstep::rows holds where, under row facts, no conflicting pair wants more than a
  threadgroup barrier: threadgroup barriers stand where the whole threadgroup runs together,
  order every pair a simdgroup barrier would and need no subgroup size, so a one-row pipeline
  keeps them and drops only the simdgroup barriers (the argument is in Lockstep::rows' doc).
- VariantKey::one_row / LoweringInputs::one_row: the lockstep pass inserts only the threadgroup
  barriers where rows holds; the kernel states RuntimeFact::OneRow (Mechanism::Variant). The
  binder asks a dispatch whose every region is one row of a RowLockstep kernel for it
  (dispatch_variant), the planned pipeline still runs such a dispatch, and the variant's plan
  sends a dispatch with a taller region back (NeedsVariant). The runtime settles on it through
  dispatch_variant and prepares it beside the base where a one-thread dispatch asks for it.

Tests: engine_simd_emulated's a_one_row_dispatch_drops_the_lockstep_simdgroup_barriers on the
Iris profile (a tile whose halves meet only across rows plus a workgroup-uniform pair): the own
pipeline keeps its simdgroup and threadgroup lockstep barriers, CrossLane(BASIC), Direct and
RowLockstep, and leaves the expected words at 144 x 2 (the shared lane's included); the one-row
variant has one threadgroup lockstep barrier, no simdgroup one, (None, NoSubgroup), no subgroup
requirement and OneRow, and leaves the expected words at 128 x 1 and 48 x 1 at 8, 16 and 32
lanes; the binder sends 128 and 48 to the variant and 144 x 2 to the base, whose plan refuses
the variant 144 x 2; the kernel with a simdgroup sum keeps Direct and its own pipeline for 32,
128 and 144 x 2. a_row_of_a_lockstep_only_kernel_takes_one_compile now expects the one-row
variant for one-row threadgroups of the row kernel, and the pinned pipeline for whole ones of
the others. The mechanism table, the inputs-encoding test and api_signatures take the new items.
2026-11-12 11:02:40 -08:00
Anees Iqbal b46459080d A batch held for its pipelines' making gives way to later commits of other queues
What: the scheduler's order across queues (scheduler/order.rs) no longer keeps the place of a
batch held unsubmitted for a host step that has not taken its gate: its pipelines being made, or a
step that reads nothing the GPU writes (`place_of`: `Place::GivesWay`). A later commit of another
queue that conflicts with it on a resource goes first, and the held batch is submitted after it,
so the tracker orders the two that way (submission order). The batches after it on its line give
way with it. What still holds a head back behind such a batch is a fence the two share
(`tracker::fenced`: one updates a fence the other waits for or updates, or a batch whose uses are
not known yet against one that names a fence), so no batch is moved after a fence update it waits
for. Unchanged: same-queue order, event and binary-semaphore waits (a batch waiting for the
program still keeps no place), batches held for their submission checks or for a host step whose
gate was taken (they keep their place: a later write going first would land after the step read),
and the order among submitted batches.

Why: on an Intel Iris Xe a guest process's cold compute pipeline took about 3 s to make; its
command buffer kept its place, and the other processes' heads that conflicted with it (the window
server's frames among them, over a surface they shared) waited behind it: the guest's display
froze for 3.1 s. Metal's order across queues is the order the GPU takes the command buffers, not
commit order: probes/cross_queue_surface_order.m's same-buffer control (one tracked buffer,
written by queue A's long compute, then read or written by queue B's later commit) ran B before A
once in three on a Radeon Pro 5300M and on a UHD 630 (macOS 26.7.1; m3-max-21850, m3-max-21851),
and in commit order on an M3 Max (macOS 27.0.1). Where real Macs differ, the cheapest form inside
them is taken; no switch, as matching the x86 Macs trades no accuracy. (The previous commit's
message miscounted the no-copy buffer case: unordered in 10 of 12 runs, 6 of 6 on the M3, 3 of 3
on the 5300M, 1 of 3 on the 630.)

Docs: order.rs's contract (**Tracked order across queues is the order the batches go**, **Held
batches give way**, **No deadlock**), the scheduler's tracking and gate docs,
WorkCounts::heads_held_for_earlier_commits, pending_dispatch.rs, docs/API.md's and the runtime
README's pipeline-wait passages.

Tests: tests::scheduler a_later_commit_goes_before_a_batch_held_for_its_making and
a_batch_held_for_its_making_holds_back_a_commit_sharing_a_fence (the order's model; its existing
a_later_commit_that_conflicts_waits_behind_a_batch_held_for_its_step is the kept-place control);
tests::hold_sites a_head_that_shares_a_buffer_with_a_batch_held_for_its_making_goes_first (was
..._waits_behind_it: the fill completes while the dispatch is held, and the dispatch's words land
over it), a_head_that_waits_for_a_fence_a_batch_held_for_its_making_updates_waits_behind_it (the
fence control), and the host-alias leg, which passes again.
2026-11-12 10:29:05 -08:00
Anees Iqbal ed8b9a137b A texture that renders over padded rows in ordered memory is in place where the device's check of renders passed
linear_plan::holding refused every texture that renders over rows with
bytes between them, ordered memory too (a Private buffer, a Managed one's
own copy on a discrete GPU), since Vulkan lets a render pass's load and
store read and write back any byte of the attachment's subresource. So
each such render target was a shadow (BytesBetweenRows): 32 Managed
textures at rows of 152 in 256 on reims's XTX walk.

Now holding takes renders_kept: Device::ordered_renders_kept answers it
where the device's policy takes images in place and its check of renders
over its pooled memory (PagesClass::Pooled, Access::Renders, the texels'
row ends) passed. That check renders into a linear image over padded
rows, through its moves into the layouts a render takes, a pass that
clears and stores it and a draw over its last column, while the CPU
writes the bytes beside its texels, and passes only where every byte but
a texel keeps what was last written: the owner's per-driver check, the
same that takes images in place over host pages and pooled memory. In
ordered memory no other agent writes those bytes meanwhile. The texture
is then the device's linear image made PREINITIALIZED (Between::Kept),
as one that only reads; a pending verdict starts the check, and a
texture made meanwhile is a shadow. The pooled move path asks the same.

Docs: the shadowed-texture notice (API.md), HOWTO, the degradation's
declaration and linear_texture_bytes_per_row's doc say so.

Verified: cargo fmt; unit test linear_plan::ordered_writes_let_a_
texture_that_renders_nothing_hold_its_rows_padding covers renders_kept
(kept in ordered memory, refused outside it and over shared rows);
device runs of tests::ordered_renders follow.
2026-11-12 08:57:13 -08:00
Anees Iqbal 7cd885ea5b runtime_lane::render_merged_attributes: stage_in states' executions run on the GPU alone
The lane test of executions whose inherited state's vertex function reads [[stage_in]]
attributes now states the GPU form, against the host step's pixels (a barrier the CPU set and
cleared), for a kernel-written ICB of triangle draws and indexed draws (merged) and triangle
strips (one draw per command), each command binding its own positions and per-instance marks at
its own offsets, first/base vertex and base instance:

- pulled_attributes_of_executed_draws_fetch_their_commands_elements: strides 10 and 6, which the
  shader fetches anyway (merged draws read the command's vertex and instance, not the merged
  draw's corner indices);
- fixed_function_layouts_of_executed_draws_are_pulled: strides 8 and 4, marks at step rates 1
  and 2, no vertex buffer bound at the encoder;
- a_layout_of_a_stride_set_per_bind_keeps_the_host_step: a dynamic-stride position layout the
  commands bind at their own stride takes the host step, whose notice names the rule.

The fixture gains ima_strips (a triangle strip writer). docs/API.md states the attribute rule in
the indirect command buffer section and in the GPU form's list; api_signatures.tsv and
api_surface.rs list draw_replay_vertex_layouts.
2026-11-12 08:37:43 -08:00
Anees Iqbal 3a7568d5b4 A device can be made to open no dynamic library's file; only regular files are read
A pipeline creation loads, for each install name its stage's libraries name, the file that name
names (dynamic_library.rs, `stage_with_dependencies`), and `new_dynamic_library_with_url` and a
binary archive's descriptor read the file they name. Where the library bytes come from another
party (a guest's metallib in a virtual GPU), its install names name any host path: `/dev/zero` grew
`read_to_end` until the process ran out of memory, a FIFO blocked the creating thread for ever,
opening a device file could act on the device, and any host file that parses as a dynamic metallib
linked into the pipeline.

- `DeviceOptions::load_no_dynamic_library_file` (and `RawDevice`'s), off by default: the device
  opens no file a library's install names name and refuses `new_dynamic_library_with_url`
  (`DynamicLibraryError::NoFileLoading`, new). A creation links only the libraries its function
  descriptors give (`libraries.preloaded`, `libraries.loaded` by install name); an install name
  `loaded` lacks loads nothing, so a creation whose import survives specialization fails
  `Compile(NeedsInput(DynamicLibrary))`, as Metal's does for a file it cannot load.
- Without the switch, every such read goes through `container::read_file`: a regular file alone,
  looked at before it is opened, opened `O_NONBLOCK | O_NOCTTY` and looked at again through the
  handle, read once no further than its length when opened, a length the process cannot hold
  refused rather than allocated. A FIFO, device or directory loads nothing as an install name and
  is `InvalidFile` for `new_dynamic_library_with_url` and a binary archive.

The stage_with_dependencies call sites (compute, render, mesh, tile creation) pass the device.
Docs: the field's and variant's doc comments, the runtime README's options table, docs/API.md's
accepted differences. api_signatures.tsv blessed (two fields, one variant); docs/REFUSALS.md
regenerates unchanged.

Tests, each failing without the change (a control commit neutralizing the gate and the
regular-file read, run once):
- tests::binary_archive::a_path_of_no_regular_file_is_no_archive_and_is_not_waited_on (CPU):
  a FIFO and /dev/zero are InvalidFile, each read bounded at 30 s.
- runtime_lane::dynamic_libraries::an_install_name_of_no_regular_file_loads_nothing_and_waits_on_nothing
  (lavapipe): a FIFO's and /dev/zero's install names load nothing, the creation is refused
  NeedsInput(DynamicLibrary), new_dynamic_library_with_url is InvalidFile, each bounded at 60 s.
- runtime_lane::dynamic_libraries::a_device_that_loads_no_file_links_only_the_libraries_it_is_given
  (lavapipe): with the switch, a client linked against A's real file is refused, A preloaded or
  not; given A in `libraries.loaded` it links A's values; new_dynamic_library_with_url is refused.
2026-11-12 07:02:06 -08:00
Anees Iqbal 126420d6a8 SCCP folds integer minimum and maximum of constants
A loop whose trip count the function constants decide through llvm.umax (a convolution kernel's max(tile / stride, 1)) kept the call unfolded, so its exit compare had no constant bound, reach could not follow the counter, and a 256 KiB private accumulator was refused against the device's 96 KiB (PrivateMemory 263240). The scalar llvm.umin, umax, smin and smax now fold over constants as ctpop, bitreverse and bswap do; integer minimum and maximum have one answer. engine_arith took its opaque integer bits from llvm.umin(C, -1); they now come from a volatile private word, which no pass folds.

Verified: canon::tests::private_reach's clamped trip count (fails without the fold); the guest kernel at its constants compiles with 144 bytes of private memory on the rdna3 profile (scratch, m3-max-20815).
2026-11-12 05:57:01 -08:00
Anees Iqbal 131887a2e1 Merged draw replays take indexed draws, and each fragment its own command's slot table
A render execution whose records a kernel writes ran on the host step wherever the buffer's
command types held DRAW_INDEXED, and the merged form refused any fragment function that reads
buffers, since one merged draw had one fragment slot table. Now both stay on the GPU.

- Indexed draws (DrawReplay::indexed, from draw_replay_indexed over the decided writes). The
  preprocess holds an indexed record where the policy and the INDEXED flag allow it: its
  arguments are [index count, instances, base vertex, base instance], and it writes a 16-byte
  index entry per command (the device address of the first index, its offset rounded down to the
  index size; the whole indices to the buffer's end; the size, 2, 4 or 0 for a draw without
  indices). An index buffer of address 0 or a bad index type is a RECORD fault; an address no
  resident range holds draws nothing and counts a resident miss; a position past the buffer reads
  index 0, as the encoder's indexed draw reads it. The merged vertex reads its vertex as the index
  at its position plus the base vertex, a u16 from its aligned word. An indexed replay that does
  not merge is refused (ReplayRefusal::IndexedApart): the runtime host-steps it
  (HostStepCause::Rule).
- Per-command fragment tables. The merged vertex writes its command to a flat uint varying
  (IoRole::MergedCommand, VaryingKey::merged_command). A merged fragment that reads buffers takes
  it as an input and MergedDrawAddress as its push field, and reads its RootTableAddress as the
  header's tables plus command times the stride plus the fragment table's offset
  (bind::merged_fragment_table). The header grows two words (H_INDICES_AT 48, H_FRAGMENT_TABLE
  52; MERGED_HEADER_BYTES 56). A fragment that reads [[primitive_id]] keeps the merged variant
  refused, so its executions host-step, as before.
- Runtime (render/executions/gpu.rs): indexed executions take the merged form alone, no
  per-command fallback; one whose type does not merge host-steps with the rule named. The
  host-replayed-indirect-commands notice text names indexed draws that do not merge.
- The fixture icb_merged_indexed (ours: kernels writing indexed draws of 16-bit and 32-bit
  indices with per-command vertex marks and fragment tints), its AIR companions compiled by
  scripts/regen-air-fixtures on the M3, and its AIR input golden.

Verified:
- metal2vulkan's draw replay, merge, stage IO, varyings, link and API tests, among them the new
  interpreter test of seven indexed records (u16 and u32 offsets, base vertex -1 over two
  instances, indices past the buffer, a residency miss, a bad type, a null buffer): 354/354
  (potluck m3-max-20787, msi).
- Clippy in every configuration (all features, each feature alone, the runtime, --cfg m2v_gpu)
  (m3-max-20812, msi); Rustdoc of both crates and 379/379 tests of the replay, AIR goldens, stage
  IO, API tables, refusals and catalogue (m3-max-20824, msi).
- The new lane test merged_indexed_draws_draw_what_the_host_step_draws (16-bit and 32-bit: six
  commands merged on the GPU with no record read, each fragment its own command's tint, the
  same pixels as the host step's) with the other merged and range-read lanes: lavapipe 12/12
  (m3-max-20811, msi), RADV Radeon 780M 10/10 (m3-max-20814, um790).
- The golden icb_merged_indexed.txt was blessed under the pinned llvm-as (m3-max-20792); no other
  golden moved.

The semantics and artifact format bumps, the golden re-bless and the census stay with the
landing.
2026-11-12 05:39:20 -08:00
Anees Iqbal c2b02c5269 Static-initializer division by zero: the probe of what Metal answers, and the accepted difference 2026-11-12 05:30:09 -08:00
Anees Iqbal e6df98ef2a Rebind a kept draw of another call or index buffer, not every step
A render encoder's draw that differs from its pipeline state's kept draw only in
its call of the same primitive type (with indices or without), its counts and its
index buffer or type, each read in place, now takes the rebound of a draw of
other arguments instead of every step. The binder's redraw_apart_into writes the
Vulkan draw, overrun, base fields and index use of any pair of direct draws
(Ok(false) where a vertices-per-primitive field or a fixed-function fetch window
sets them apart); the route check adds the two route parts a call or index type
changes (a strip restarted at another index, a de-indexed variant); a draw of
another index buffer is no draw moved (its uses meet a buffer the kept draw's did
not: detached buffers and shadows are looked at again) and holds that buffer as
every step does; the kept draw takes the new call.

Same draws, bindings and pixels: the debug-assertion checks compare each rebound
draw with every step's commands, writes, uses and recording; the new runtime test
draws_with_indices_and_without_in_turn_are_rebound_with_their_call compares the
commands and pixels with every step; the binder test covers the new pairs.
Counter: draws_unlike_kept_call and draws_rebound_arguments in draw_costs
compositor --counts.
2026-11-12 05:23:20 -08:00
Anees Iqbal e17223aed8 A render execution's range read from a buffer runs on the GPU in the merged form
executeCommandsInBuffer:indirectBuffer:indirectBufferOffset: sent every render execution to the
host step, even when the GPU wrote the commands and they merge into one draw. That costs a
GPU-to-CPU round trip each time.

Now an execution whose commands merge takes the GPU form whatever its range:

- The draw replay gets DrawReplay::range_read. The preprocess runs over every command of the
  buffer. Each invocation reads the range (location, then length) from the parameters
  (DrawReplayLayout::range_offset). A command outside the range draws nothing.
- The range is taken as the host step takes it (ExecutionRange::commands): clamped at the size.
  A location past the size, or an end past 2^32 - 1, draws nothing and reports RANGE once.
- The binder refuses range_read unless the replay is merged and covers the whole buffer
  (ReplayRefusal::RangeRead).
- The runtime copies the range's 8 bytes, where the encoder read them
  (indirect_execute::range_from), into the scratch's parameters between barriers, before the
  preprocess.
- These still take the host step, and the notice names the rule: commands that do not merge (a
  strip type, or a rule of the merged form), and an execution whose records the CPU alone writes.

The degrade notice's text (degradation.rs, docs/API.md), the render executions' docs and the
upload arena's docs now describe this. The API signatures are re-blessed.

Tests:
- bind::replay::draws::tests::a_replay_that_reads_its_range_draws_the_commands_inside_it, on
  the CPU interpreter: seven ranges, including clamped, empty, at the size, past the size and
  past 2^32 - 1. Each command's arguments and the merged corners are checked, plus both refusals.
- runtime_lane::render_merged_executions::a_range_read_from_a_buffer_draws_on_the_gpu_what_the_host_step_draws:
  four ranges, one written by a blit before the pass. The GPU form draws 8 merged commands and
  reads no record. Its pixels and execution report equal the host step's.
2026-11-12 05:08:28 -08:00
Anees Iqbal 2724757bbf A host step waits for the batches that wrote what it reads, not every queue's work
A batch whose host step records indirect commands the GPU may write waited, once otherwise
ready, until every VkQueue completed what was submitted to it by then. A frame of a GPU-culling
renderer (a kernel encodes the draws and their execution range, then several render passes
execute them through the range) paid one GPU round trip per pass: each pass's step waited for
the passes before it in its command buffer, and for other queues' unrelated work, though it
reads only the records and the range the culling wrote. The range read made it worse: it was
read from a copy recorded right before the execution, in the batch of the previous pass.

Now the gate is taken from the hazard state where it can be (scheduler gate_of):

- CommandBufferShared::step_reads names what a batch's host step reads on the host of what the
  GPU may write, where each segment whose step waits for the GPU is an execution (outside a block
  of command predication) or a render pass of executions whose uses commit bounded: their
  records and ranges (Deferred::host_reads, ExecutionRange::host_reads), with their host
  aliases. Anything else (an indirect dispatch, a loop's check, a staged gather, an indirect
  sparse update) answers None.
- Tracker::last_writes answers, per VkQueue, the value of the last batch that wrote those bytes
  of the writes the state holds; None for an untracked resource. The state forgets only what
  completed, and a write that let an older entry go waited for it, so once each queue reached its
  value every GPU write to those bytes completed and reached the host (every batch ends with the
  barrier to the host). Every such writer is submitted by the time the gate is taken: earlier
  batches of the line went first, an earlier commit's conflicting batch on another line holds the
  head behind it (its footprint holds the step's reads), a later one waits behind it.
- Where either answers None the gate is every queue's last submission, as before.
- The range of executeCommandsInBuffer:indirectBuffer: is read in place where the host maps the
  bytes the GPU writes (Buffer::maps_gpu_bytes: not Private, not a Managed host copy on a
  discrete device, not a copied host buffer), through Buffer::read_mapped, which holds a no-copy
  buffer's pages while it reads 8 bytes so a detach and rebind meanwhile free none of them; a
  detached buffer runs nothing. The read is noted at the call as a command that reads the bytes
  (no GPU work), so the encoder's order, a detach and the hazard state see it as they saw the
  copy's. Other buffers keep the copy.
- WorkCounts::host_step_gates_narrowed counts gates that left out work submitted before them;
  the conformance cost tables report it and never gate it (QUEUE_DEPTH: whether a gate falls
  below a queue's last submission depends on whether the host had seen the writer complete).
- The HostReplayedIndirectCommands notice's cost, its catalogue entry in docs/API.md, the
  scheduler's and indirect_execute's module docs and the execution calls' docs say so.

Tests: tracker a_host_read_waits_for_the_last_writes_of_its_bytes_alone (the writer per queue, no
writer, a covering write on another queue, untracked, a queue past the count, retired). Lane
depth_executions a_frame_s_executions_wait_for_the_culling_alone: a culling command buffer on one
queue, a fill on another queue submitted before the frame, then a frame of two passes that
execute the commands through the range: two host steps, both gates narrowed, both targets hold
each kept chunk's depth. The existing depth_executions test now shares its workload.

No Metal-visible behaviour changes: what the steps read and record is the same; they start
earlier.
2026-11-12 04:53:27 -08:00
Anees Iqbal 605a99f639 A texture over a Private buffer at a pitch the driver takes only explicitly is in place: the GPU keeps its bytes
A Between::Kept texture (bytes only the runtime's ordered commands write; no render target) whose
pitch the device's linear image does not lay on its own now takes route 2, the DRM explicit-pitch
image (VK_EXT_image_drm_format_modifier, DRM_FORMAT_MOD_LINEAR), over the buffer's own memory,
where the driver's reported rowPitch equals the buffer's pitch at offset 0 and the image fits.
Checked per texture. Such an image starts UNDEFINED (VUID-VkImageCreateInfo-initialLayout-12478:
PREINITIALIZED only with TILING_LINEAR; 01443 for external memory), and 7.1.1 lets the move out of
UNDEFINED discard its range, so the first move keeps the bytes on the GPU: one span copied out to
a scratch buffer, the move UNDEFINED -> GENERAL, the span copied back, in one ordered sequence.
The submission taking a keep waits on every other queue's last submitted work, so the keep follows
every earlier access to the span; later work waits through the first move's owners. Afterwards the
image and the buffer alias as a linear resource (glossary, DRM_FORMAT_MOD_LINEAR; 12.11).

Counted: WorkCounts::first_moves_kept, first_move_bytes_kept.
2026-11-12 04:26:42 -08:00
Anees Iqbal cdcd787fb8 A render target's channel-order sibling views are views of its image
A pass rendering into a BGRA8Unorm or BGRA8Unorm_sRGB view of an
RGBA8Unorm texture made without PixelFormatView usage (and the same for
BGRA8Unorm and the sRGB twins) rendered through a shadow image of the
view's format, copied in before the pass and back after it
(shadowed-texture-view, about 50-95 us a command buffer at 64x64): the
texture's image was mutable only for its sRGB twin's formats, so Vulkan
made no view of it in the sibling's format.

Basis, documented on both sides:
- Vulkan: VkImageFormatListCreateInfo (core 1.2), pViewFormats
  "specifying all formats which can be used when creating views of this
  image", with MUTABLE_FORMAT; the formats are of one class.
- Metal: MTLTextureUsage.pixelFormatView, "Don't set this option if your
  texture view only converts between linear space and sRGB. For example,
  if your texture uses the rgba8Unorm pixel format and your texture view
  uses bgra8Unorm_srgb." Plain Metal makes the BGRA8Unorm view too and
  renders through it (its API validation stops it; view_attachments).

Change (image_plan.rs): a color texture of those four formats with
RenderTarget usage lists, besides its sRGB twin's views, the views of
its sibling and the sibling's twin (reordered_views, reordered_formats),
in the single-sample and the multisample plan; a word attachment's view
is left out as for the twin. A texture that renders nothing lists none:
its sibling views already read the image through a swizzle. The view's
other uses then view the image too (takes_views_of).

Compression: expected, not measured. Mesa's sources suggest RADV before
GFX11 keeps no DCC for a list whose formats' channel orders differ, ANV
keeps CCS_E for formats of the same channel bits, RADV GFX11+ keeps DCC
for any list; NVIDIA documents nothing. The A/B lane
view_attachments::reordered_view_render_costs (the parent commit)
measures it per driver.

Tests: image_plan::render_targets_take_their_channel_order_sibling_s_views
(every committed profile: the sibling and its twin taken where the
device renders them directly, none for a texture that only reads, none
for RGBA16Float); runtime_lane::view_attachments::
a_render_target_s_reordered_views_render_in_place (draws through both
views, Metal's bytes, no shadowed-texture-view).
Docs: the ShadowedTextureView notice (degradation.rs, API.md), the
FAST-PATHS view bullet, view_shadow.rs.

Verified: not yet built.
2026-11-12 03:56:51 -08:00
Anees Iqbal 42e11abcd4 Textures over buffers only the device's ordered commands write hold their rows' padding in place
What: a texture that renders nothing over a buffer of the runtime's own memory whose rows lie
with the buffer's bytes between them is now the device's linear image, made PREINITIALIZED, at
the buffer's pitch, where only the device's commands, in the runtime's order, write those bytes:
a Private buffer, and a Managed buffer's own on a device without unified memory (a two-copy
no-copy buffer's device copy, or one with its own host copy), not one whose VkBuffer was handed
out or whose memory is exportable (Buffer::gpu_bytes_ordered). linear_plan::holding answers what
an image may hold besides the texels (Between::{Nothing, Unobserved, Kept}); Kept takes route 1
alone: the linear image whose rowPitch the driver reports equal to the buffer's
(vkGetImageSubresourceLayout, aliases with within_padding). No DRM_FORMAT_MOD_LINEAR image at
Metal's pitch, no image over exportable memory or in exportable blocks, as each is made
UNDEFINED. A render target stays a shadow. Counted: WorkCounts::kept_padding_aliases.

Also two pairs of counts of what the program asks of a two-copy Managed buffer, beside the bytes
the runtime copies: managed_ranges_modified and managed_bytes_modified (did_modify_range),
managed_resources_synchronized and managed_bytes_synchronized (synchronize_resource), to compare
with managed_bytes_copied_in and managed_bytes_copied_out.

Why: the RTX 2080 guest census (reims's v302 run) made 230 textures over Managed buffers, 200 of
them RGBA8 ShaderRead|ShaderWrite at 3884, 4208 and 2448 texels a row with rows rounded up to
256 bytes, every one a shadow for its padded rows ("its rows lie N bytes apart"): 2.52 G shadow
texels first copied in, 1.26 G kept, 1.26 G words examined by merges back. Owner's rule:
in place where possible, a shadow only where impossible. Main approved the route and its
conditions.

Basis (Vulkan 1.4, docs/API.md's shadowed-texture entry): 7.1.1 Image Layout Transitions, "Image
layout transitions may perform read and write accesses on all memory bound to the image
subresource range ... If the old layout matches the current layout of the image subresource
range, the transition preserves the contents of that range": the image's one transition is its
first move, PREINITIALIZED to GENERAL, out of the layout it is in, ordered after and before every
write of those bytes, as only the device's ordered commands write them. 12.11 Memory Aliasing:
"Buffers, linear tensors, and linear image subresources are considered host-accessible
subresources when they are in any of these layouts: VK_IMAGE_LAYOUT_PREINITIALIZED,
VK_IMAGE_LAYOUT_GENERAL ... If two aliases are both host-accessible, then they interpret the
contents of the memory in consistent ways, and data written to one alias can be read by the other
alias." VkSubresourceLayout's "size includes any extra memory that is required based on
rowPitch" puts the padding inside the range. A kernel's writes may change the padding as on the
x86 Macs (in_place::Padding::Free); a render pass's load and store "may read and write back" it,
so render targets keep the shadow.

Verified: not built yet. tests::kept_padding (a Private buffer at 416, 448 and 512 bytes a row,
the buffer read back whole after the image's first move; a Managed two-copy texture changed in
one row through did_modify_range, then a blit-written row synchronized out, every byte between
rows as given, against a Shared buffer's shadow), tests::linear_plan's holding cases and
tests::texture_placement run on lavapipe next, then one RTX 3090 run.
2026-11-12 03:56:50 -08:00
Anees Iqbal 9d184d13ec Heaps over host pages: a texture Metal tiles lies in the device's image over the pages first
In a heap over the caller's host pages (new_heap_with_bytes_no_copy), a single-sample texture
whose bytes Metal lays out in its tiles now takes the image bound to the pages wherever one
serves: its linear image made for host allocations, or over dma-buf pages the driver's
DRM_FORMAT_MOD_LINEAR image, in the driver's rows with no copy, announced
heap-texture-untiled-layout (Untiled::LINEAR). The shadow of Metal's tiles (AliasRoute::Tiled)
is the fallback where no such image serves, and stays the route of a copied heap.

The bytes in guest pages are now the device's layout, not Metal's tiles. Basis: Apple documents
a texture's layout in a heap's bytes as private to Metal, and the consumer confirms that no guest
code of theirs reads or writes a heap texture's bytes in guest pages (replaceRegion and getBytes
go through a staging blit; no buffer aliases a heap texture), so the copies in and out of the
tiles shadow bought nothing it could see (the owner's rule: shadows are a fallback, never a
first option). dma_buf_heap_plan now answers why its image does not serve instead of taking the
shadow itself, so a texture Metal tiles over dma-buf pages falls back to the tiles shadow before
the rows one.

Docs: host_heap_plan, AliasRoute::Tiled, the dma_buf module, the heap-texture-untiled-layout
declaration and catalogue entry, and the FAST-PATHS known-gap entry on heap textures in the
driver's layout.

Verified: cargo fmt only; builds and tests run as potluck jobs after this commit.
2026-11-12 03:56:49 -08:00
Anees Iqbal 13a8232d8c docs/API.md: maxThreadgroupMemoryLength among the presented Mac's answers
The Mac-class section lists what a device presenting a Mac with an Intel
or AMD GPU answers as that Mac; it now names the threadgroup memory
bound (65536 bytes, where an Apple silicon Mac's is 32768) that the
previous commit made the runtime's answer. Docs only.
2026-11-12 03:38:01 -08:00
Anees Iqbal 6b14f719d3 Clear a linear color attachment in place where the rule allows it
A pass that cleared a color attachment whose texture's image is linear and
which the device renders under VK_NV_linear_color_attachment, where the rule
allowed it in place, cleared an image its texture keeps and copied it back,
announced linear-attachment-clear-copies, because clearing a linear image of
host memory in place measured slower than that copy. A copy chosen for speed:
the owner's rule keeps a copy only where the device lacks the in-place form.
The pass now renders such an attachment in place whatever it loads.

Removed with it: the Degradation kind (its API.md catalogue entry and its
api_signatures row), the pass end's analysis of whether a command of the pass
may read the attachment's bytes, which only that route used, and the lane and
conformance expectations of the notice. through_backing keeps the one kind
and area its callers still pass.

Tests: the lane test of a pass clearing a render target over a Shared buffer
(now a_cleared_render_target_over_a_shared_buffer_renders_in_place) counts it
in place and through no copy on a device that renders it by the rule; the
runtime's a_cleared_target_alone_renders_in_place forces the rule (lavapipe
included) and counts 1 in place, 0 through copies, every texel the clear; it
counted 0 and 1 before.
2026-11-12 03:03:40 -08:00
Anees Iqbal 6a951995e1 The lowest level a slot reads counts no size query: it reads no texel
What: LevelReads::lowest_read counted a size query at a constant level as a read of that level.
A sample's lowering queries the level-0 size for offsets, pixel coordinates and bias axes
(lower/sampler/emit.rs), so every such slot stated lowest_read 0 and no read past an attached
level could read in place: the lane and runtime tests of the past-level reads counted the slots
first-level or reaching (m3-max-20154, at 70b6b737e7 on lavapipe). A size query reads no texel,
and the view a narrowed slot binds keeps the texture's first level as its own, so it answers the
same at any level the view holds; the query still raises named, which keeps that level in the
view. Fetches and gathers read texels and still count.

Tests: level_reads::tests::each_read_states_the_levels_it_reaches (a size query at level 3:
named 3, lowest_read none). Verified: built and run in the next job.
2026-11-12 02:46:14 -08:00
Anees Iqbal 6ab2d18f04 LevelReads and SampledLevels state the lowest level a slot's reads may reach
A runtime that serves a draw's read of a texture its own pass renders can read the texture's own
image in place where every read reaches only levels past the highest attached one, but the fact
gave only the highest level read. It now gives the lowest too:

- LevelReads::lowest_read: the lowest constant level a fetch, size query or gather reads (a
  level-count containment's comparison reads no level, so it raises `named` alone).
- SampledLevels::lowest_lod_bits: the lowest constant explicit level of detail through each
  sampler, a NaN where one is.
- SampledLevels::lowest(SamplerLevels): floor of the lower bound of the level of detail, which
  Vulkan's LOD Operation clamps into [minLod, maxLod] after any bias (minLod where one is
  computed; the lowest constant plus a negative sampler bias, clamped so), the first level for a
  NaN constant or crossed or unbounded sampler bounds. Both mipmap modes read floor(L) or above.
- LevelReads::lowest_level: the lowest among the reads; 0 where a read may reach any level.

ARTIFACT_FORMAT_VERSION 503 (two encoded fields); the interface's other facts are unchanged, so
SEMANTICS_VERSION stays at the NaN fix's 2040. api_signatures rows added; docs/API.md's "Levels a
slot reads" says how to ask.

Tests: level_reads::tests::each_read_states_the_levels_it_reaches (each read's lowest, and a fetch
beside a level-count comparison: named 3, lowest 2), the_lowest_level_follows_the_bound_sampler,
constant_levels_of_detail_keep_their_lowest_and_a_nan_there. Verified: built and run in the next
job.
2026-11-12 02:46:13 -08:00
Anees Iqbal 0709ba7ba5 A sampler state's lodBias moves the level on a device presenting an Intel or AMD Mac
What: vk_sampler set mipLodBias 0 whatever the descriptor's lodBias, read as
Apple9 (an Apple M3 Max samples every level as with no bias). The
consumer's oracle (an AMD Radeon Pro 5300M and an Intel UHD 630) shows a
Mac with an Intel or AMD GPU adds the bias to every sample's level,
explicit (level()), gradient and implicit alike, clamped into the
texture's levels. So a guest presenting such a Mac read the wrong level.

How: the translator's SamplerUse gains lod_bias (with_lod_bias), a fact
the consumer states per bind from the Mac it presents; a plan's uses
leave it unset. With it, vk_sampler's mipLodBias is device_lod_bias's
(new, public): the bias within the device's maxSamplerLodBias, the limit
of its sign past it (Capped), none for a NaN (NotANumber) and none where
the portability subset withholds samplerMipLodBias (Withheld). Without
it, 0 as before; a use of texel coordinates takes none either way. Vulkan
adds mipLodBias to an explicit level too, so the device's sampler gives
the measured answer within the limit.

The runtime keeps the resolved MacClass in DeviceProperties (one place,
presented_class; lossless_compression derives from it). A state's taken
descriptor keeps its bias on IntelOrAmd (-0 as 0, NaN as none) and 0 on
AppleSilicon, and SamplerState::bound_use adds the flag at every bind:
a slot's, an argument sampler's, a heap set's array element, and the
attached-levels reckoning of the levels a draw samples. A bias the
device cannot take as it is is announced once as the state is made, the
new precision kind CappedLodBias (capped-lod-bias), never fatal.

Docs: vk_sampler, SamplerDescriptor::lod_bias, the runtime sampler module,
MacClass and DeviceOptions::mac_class name the answer per class; API.md's
catalogue lists capped-lod-bias and the Mac-class section the bias. The
api_surface and api_signatures tables take DeviceLodBias,
device_lod_bias, SamplerUse::lod_bias/with_lod_bias and the new kind.
REFUSALS.md regenerated unchanged.

Tests: metal::sampler's a_lod_bias_is_the_device_s_where_the_use_adds_it
(every committed profile, both uses) and
the_device_lod_bias_is_the_bias_within_what_the_device_takes (exact,
capped finite and infinite, NaN, withheld on MoltenVK's profile);
tests::sampler takes the bias per class; the lane's lod_bias tests a
device presenting each class: AppleSilicon reads the unbiased level
(kernel explicit, fragment implicit), IntelOrAmd the biased one, the
capped ones announced once (CAPPED_LOD_BIAS, listed as a site).
Evidence: potluck jobs in the report to main.
2026-11-12 02:04:48 -08:00
Anees Iqbal 20a186a87e Docs: a heap texture's answer under each HeapAnswerPolicy
The heap module's size-and-alignment bullet, the heap-texture-larger-than-metal declaration and
its catalogue entry, docs/API.md's heaps-and-memory bullet (which said every answer was the
device's image's, where the code answered Metal's model) and WorkCounts::heap_textures_refit now
say what each policy value answers: under Device the larger of Metal's answer and the route's
image within the 64 KiB and 4 KiB-or-size bounds, the 4 KiB image in its place past them; under
Metal, Metal's answer held by a refit or a shadow.

Verified: cargo fmt only; docs alone, no code moved.
2026-11-12 01:52:37 -08:00
Anees Iqbal ee9e1140b1 API.md: a texture's size never makes a texture over the runtime's own memory a shadow
The clause the bound's removal left read as a trailing participle; it now states the rule.
2026-11-12 01:50:58 -08:00
Anees Iqbal 0d144ec0de Pooled memory: no bound on a texture's bytes; ShadowCause::LinearCost is gone
The owner, through reims: zero copy, in place where possible, shadow copies a fallback and never
a first option. A tracked texture over a Private buffer of the runtime's pooled memory whose rows
the device's own linear image lays out otherwise was a shadow past 48 KiB to its pitch
(TextureShadowReason::LinearCost), a speed choice measured on an Iris Xe alone that shadowed 1001
of an RTX 2080 guest boot's 1366 textures. It now takes its DRM_FORMAT_MOD_LINEAR image at Metal's
pitch at any size, wherever the device makes one and its check of the pooled memory passed, as a
texture over a Shared buffer already did; it is a shadow only where the device makes no such
image (its format, usage, pitch or limits), its policy is HostPageTexturePolicy::Shadow, or the
check failed or is pending (a pending one still moves in place once it passes).

Removed with the bound: in_place::POOLED_PITCHED_BYTES, ShadowCause::LinearCost and the public
TextureShadowReason::LinearCost (a breaking change of metal2vulkan-runtime's surface:
api_signatures.tsv loses its variant), texture_spans.rs (the runs of bytes textures were made
over, which only the bound read) and the moves it fed (MoveAfter::Aliases, LoneShadow, the
buffer's note and wait), Texels::only_commands_write (the bound's alone), the bench behind the
bound (runtime_lane::pooled_draw_costs, its crossover additions included) and
aliased_surfaces' cost bench. aliased_surfaces' first check now asserts every texture over one
surface's bytes takes the image at Metal's pitch, the first included, and a read copies nothing;
its one-after-another check, about the first texture's shadow, is gone. storage_over_buffer is
one function again (REFUSALS.md regenerated for the name). API.md, HOWTO.md, FAST-PATHS.md (the
in-place row) say "at any size".

RUNTIME_VERSION is not bumped here: the landing bumps it and re-pins the runtime sources.
2026-11-12 01:50:58 -08:00
Anees Iqbal ba69642609 Copied buffers: a comparison splits across up to eight threads, not four
A copy's comparison of 4 MiB or more (a commit's copy in with no base, whose
pages carry no log, and a comparison with a base) ran on up to four threads, the
calling one among them. On the RTX 5080 Laptop GPU's host (a Core Ultra 9
275HX) eight cut the commit of a kernel-read pass over 256 MiB from 11.2 to
8.4 ms (12.3 to 14.1 GB/s), 64 MiB from 2.9 to 2.2 ms, a copy in after the CPU
rewrote every float of 256 MiB from 30.3 to 17.0 ms (6.6 to 9.0 GB/s), and the
merge back of a 256 MiB kernel-write from 65 to 41 ms with the stores of
27c4a1ae46 (copied_bandwidth_bench's copied-t8 rows at 31333d4bf4, b5080
entry nvcopybw-nvcopybw-5080-ab-234252); on the RTX 3090's host (a Ryzen 7
7840HS) the 256 MiB kernel-read commit from 14.0 to 11.9 ms and the 64 MiB
kernel-write merge back from 11.2 to 8.8 ms (m3-max-19454). A host that runs
fewer threads at once runs that many.

SPLIT_THREADS is now 8, so a device's comparisons (one at a time under its
copies' lock) hold at most seven more threads at once. The bandwidth bench's
contrast row is now four threads (copied-t4); copied_256_bench_eight_threads,
which measured what is now the default, is gone. Docs say eight.

Tests: run after this commit (copied tests on a host without AVX-512, lavapipe).
2026-11-12 00:47:30 -08:00