A rebind of a Managed no-copy buffer with a device copy makes a new host copy
of the new pages as the making does (an import made as HostCopy, never a
copied.rs copy, or the pages alone), in place of the old, which goes once
nothing holds it, and copies the pages in whole: a rebind whose import the
gate refuses no longer stacks a copied host buffer under the device copy.
Tests: a texture over a two-copy buffer follows its device copy (its GPU
reads after the making, did_modify_range and replace_region, and its
synchronize_resource).
Docs: the runtime's guide (the memory model, host memory without a copy,
host_backing, the recovery), docs/API.md (the two-copy paragraph beside the
Managed device-copy textures, which now reach only buffers that lie in their
pages, and device-memory-overflow), HOWTO (copied host buffers: a two-copy
buffer is never one; did_modify_range is the contract).
Device tests (managed_copy_device.rs), each over an import of the pages and
over pages no import maps (the caller's gate refuses the import): the copies
in at the making and at did_modify_range, not at an unnamed CPU write; the
copy out at synchronize_resource, not without one; a 256 MiB buffer's device
copy and staging within the bound across cycles, none at rest, and no copy of
the pages; rebind, detach, read-only pages dropping the GPU's writes, a
recovery; a Shared no-copy buffer with no device copy. On unified memory each
leg checks the buffer is one copy.
Not yet built.
On a Mac with a discrete GPU a Managed resource has two copies, the CPU's and
the GPU's own, synced at didModifyRange: and a blit's synchronizeResource:,
and a Managed buffer over the caller's pages is no exception: a kernel read
one 256 MiB such buffer and wrote another at 102.5 GB/s on a Radeon Pro
5300M. The runtime left it in the caller's pages, read across the bus
(5.8 GB/s on an RTX 5080 Laptop), as a Shared one.
Now (managed_copy.rs) such a buffer is a buffer of device-local memory of the
runtime's own, as a Managed buffer the runtime makes there, whose host copy
is the caller's pages: an import of them made as a no-copy buffer's (by
pointer, dma-bufs, a guest RAM's chunk), outside the Metal address space, or,
where the device imports none, the pages alone (never a copied.rs copy as
well). contents is the caller's pointer; the deallocator and keep-alive go
as a no-copy buffer's.
- Copies in (the making, did_modify_range, a rebind) go through the device's
next submission's first work, after the commands before it on its queue:
from the import's VkBuffer, or through write-combined staging of 32 MiB at
most, freed when the submission completed.
- synchronize_resource copies out as a blit's write of the import, or into
host-cached staging copied to the pages at the command buffer's completion
(CommandBuffer::at_completion, run in completion.rs before anything sees it
complete).
- Read-only pages: nothing is copied out, and the pages are copied in again at
the completion of each command buffer that used the buffer.
- Rebind and detach act on the host copy (the import's own, or the pages'),
a rebind copying the new pages in whole; a recovery makes the host copy
again and copies the pages in.
- No device-local room: the buffer lies in its pages, announced as
device-memory-overflow, never refused.
- Counted: WorkCounts::managed_device_copies*, managed_bytes_copied_in/out,
managed_staging_bytes, managed_writes_undone. HostBacking::DeviceCopy.
Not yet built: the commits after this one fix what the build finds.
The check wanted 2 * (i + shift) where the kernel writes input + i, which is
2i + shift; it read the output through its own slice, leaving common::bytes
unused (a dead-code warning).
Not a consumer's example: a kernel reads one 256 MiB buffer and writes another
of the same kind (scale_and_offset of the owned fixture, 4 bytes read and 4
written a thread), timed by the command buffers' GPU times, for Shared and
Managed no-copy buffers over the example's own pages and the runtime's own
Shared, Managed and Private buffers. Each row checks the kernel's answer
(a Managed output after a blit's synchronize_resource), and the Managed
no-copy row checks that a CPU write told by did_modify_range reaches the next
command buffer. It is the bandwidth evidence for Managed no-copy buffers on a
discrete GPU, with Shared no-copy as the control.
Bit 20 (0x100000) is an option no Metal header names, of unstated meaning,
which programs pass with their buffers' options (0x100010 for a Managed
no-copy buffer). ResourceOptions::from_raw refused it as undefined, so such
a buffer could not be made at all.
Measured with probes/resource_option_bit20.m on an M3 Max (macOS 27.0.1)
and a Radeon Pro 5300M (macOS 26.7.1), plain and under API validation:
buffers of a length, of bytes and over the caller's pages are made with it,
of every storage mode, and report their options without it; so do a heap
and a heap's buffer (API validation stops the heap's buffer); a texture
descriptor with it ends Metal's process.
So from_raw takes it (ResourceOptions::BIT_20), every buffer and heap maker
drops it (own_memory_options, no_copy_options, take_options, a heap's
new_buffer), and texture_options refuses it as it refuses bit 24 there.
Nothing reads it. docs/API.md states both halves; api_signatures blessed.
Tests: values::bit_20_is_taken_and_dropped_apart, and the device test
option_bit_20 (buffers, no-copy, heaps and their buffers report without
it; a texture descriptor with it is Invalid). Not yet run.
The options a guest's OpenCL runtime passes for its buffers set bit 20 (0x100000),
which no public MTLResourceOptions value names, and the runtime refuses it today.
The probe prints, for each way of making a resource, whether Metal made it and
what the resource reports of its options.
The landed packet changed a runtime-sources input, so the committed digest no
longer described the sources and `the_runtime_sources_are_the_committed_ones`
would fail. Recomputed over the same inputs and committed by land-pkt.sh.
A command buffer failed by its host step's recording or by vkQueueSubmit now gives back the
takes of the failed batch and every later part (CommandBufferShared::never_runs_from), as
fail_part does. A predicated loop's rerun stays a known gap. Verified on the branch: before
the fix lavapipe's two new legs take no copy (potluck m3-max-16608); after it lavapipe and
RADV PHOENIX 272/272 (m3-max-16713, 16714); lint m3-max-16715, 16716.
The before-runs of the GPU-pass rebind leg passed on the pre-fix code
(lavapipe, m3-max-16674 with the draw before the execution, m3-max-16689
with it after): the draw read the bytes. A render pass recorded in a
segment has its shadowed textures' copies planned by its encoder's own core
as the pass ends (render.rs end_pass, shadows::plan), the take among them,
and the segment only records them. GPU-alone compute executions
(gpu_execute) plan no shadows. The segment cores that plan their own
(indirect dispatches, executions recorded from records) are host steps'
recordings, which a rebind does not record again. So no segment a rebind
records again decides a take, and the encoding again's main core already
keeps them (ShadowSync::again).
So this puts back shadow.rs's two modes, State::replaying_takes and
step_takes, and reencode.rs and encoder.rs as development has them. The
shared pool, the give-backs at a splice and Replayed::takes are gone. Kept:
the failed-submission give-back (State::give_back_from, never_runs_from,
place joining a segment's takes into its encoder's), its docs, the loop
gap in FAST-PATHS, and the GPU-pass leg as a regression test, its doc now
saying where the take is decided.
Its before-run at 92a2a37461 (job m3-max-16674, lavapipe) passed: the draw came before the
execution, in an instance of its own that the encoder records inline (the pass split before the
execution), so its take was the encoder's, which the encoding again already kept. The draw now
follows the execution, in the instance the commit records in a segment.
A tiled texture's copy taken at use is taken by the first use encoded after
its mark; a recording that never runs must hand its take on or give it back.
Three paths lost it:
- A rebind that encodes an encoder again re-recorded the encoder's segments
(a render pass recorded on the GPU alone, its shadowed textures' copies
in the segment) into cores that asked the mark, which the first
recording had cleared: the pass read a copy nothing made. The same held
for work on the GPU alone a rebind records again without encoding its
encoder again.
- A host step whose recording failed, and a vkQueueSubmit that failed,
failed the command buffer outside fail_part: the takes of the batch and
the later ones were never given back, so the next use read stale levels.
How:
- shadow.rs: one way to decide. ShadowSync::again (take nothing unmet,
note nothing) is gone; every recording in place of others is
ShadowSync::over a shared Replaced pool: a use that meets a decision of
the replaced recordings keeps its take, any other asks the mark. The
cores recorded during one turn share the pool, so each decision is met
once, in order.
- State::replaced_takes (was step_takes and replaying_takes) holds the
pool while a host step, a rebind's encoding again (the first encoding's
takes and its segments' recordings' takes, State::takes_of) or a
rebind's recording again on the GPU alone records. segment_raw hands it
to every core. A spliced encoding again or segment gives back the takes
of the first recordings it did not meet (Takes::give_back_unheld); a
refused one gives back its own takes the first did not hold. The
encoder's record keeps the encoding again's takes.
- State::place joins a placed segment's takes into its encoder's record,
and CommandBufferShared::never_runs_from (State::give_back_from) gives
back the takes of every part from the failed batch on, called beside
each of the scheduler's three failed() calls.
- docs/FAST-PATHS.md, known gaps: a predicated loop's run again records
its work apart as a new recording that asks the mark, so a
did_modify_data during the loop is taken mid-loop and the next use
after it takes nothing. Keeping the first run's takes (over) would copy
in again at every run, so it stays a recorded gap.
- docs/API.md and the shadow.rs and reencode.rs module docs say the
above.
Verified: see the next report (lavapipe before/after, the 780M, lint).
Its first run (job m3-max-16608, lavapipe) found the pass recorded by a host step, not on the
GPU alone: the GPU form asks that the records may hold draws, and a reset alone holds none. The
host step then held the index buffer's pages, so the rebind was refused (EncodedUses). The CPU
now writes a triangle draw into command 0, which the blit resets on the GPU before the pass.
Three device legs that fail on the tip:
- tiled_texture_reencode: a render pass recorded on the GPU alone (it
executes indirect commands a blit reset) whose indexed draw reads a
tiled texture and takes its indices from a no-copy buffer. A rebind of
that buffer encodes the render encoder again; the pass's segment is
recorded again, and must take the copy the commit's segment took.
- tiled_texture_step: the host-step leg's setup shared, and a leg whose
host step's recording fails (CommandBuffer::fail_host_step, a test
injection after the step records): the batch never runs, so the
commit's take must be given back.
- tiled_texture_failed: a leg whose batch's vkQueueSubmit fails
(Device::fail_next_submissions, a test injection in submit_logged that
makes no call): the take must be given back.
Both injections are cfg(test) only. Not run yet: the before-run is the
next step.
The consumer re-measured (their job m3-max-16759): Apple's OpenCL on Metal makes one Managed
no-copy buffer per cl_mem and synchronizes it as Metal requires; its Shared buffers are
staging. So no OpenCL buffer must stay Shared on a discrete GPU; the Shared bus cost stands
as measured.
The landed packet changed a runtime-sources input, so the committed digest no
longer described the sources and `the_runtime_sources_are_the_committed_ones`
would fail. Recomputed over the same inputs and committed by land-pkt.sh.
On a driver whose fixed-function vertex fetch wraps at 4 GiB
(RuntimeDriverDefect::VertexFetchWrapsPast4GiB, lavapipe), a layout the draw's own values
reach past 2^32 is pulled; uint-indexed and indirect draws are pulled under
DevicePolicy::vertex_reach = Exact (exact_answers()), announced vertex-fetch-may-wrap
otherwise. The submission-merge check floors each call apart on its own (CHECK_VERSION 8).
Rebased over the unstored-DontCare switch: both DevicePolicy fields kept. Verified on the
branch: lavapipe before 24 elements differ (potluck m3-max-16570), after exact under
exact_answers() (16602); touched tests on lavapipe, the 780M and the M3 (16602, 16642,
16617); full lavapipe lane 5518/5519, the pin alone failing (16647); core 5432/5432 (16666);
lint 16601; ledger tests 34/34 (16712).
runtime_lane::far_vertex_fetches::far_reach_costs on lavapipe (Mesa 26.2.4, LLVM 23.1.1, msi;
jobs m3-max-16602 and m3-max-16705): under Exact one pipeline more (the pulled variant, made at
the first uint-indexed draw), and a pass of one draw of 65,536 uint-indexed points 2.3 to 2.8
times as long (medians 0.94 against 2.41 ms beside two builds; 3.5 to 4.8 against 9.7 to 12.0 ms
at a load average of 59 on 24 threads). Not free, so the switch stays opt-in.
The defect's doc names the second lavapipe release measured and the 780M's Mesa.
The gpucfg build (m3-max-16573) found no new_library_with_air on Device: it is the validation
crate's AirLibrary extension, which the module did not import.
a_held_group_goes_before_another_queue_s_submission_handler_runs and
a_shared_event_wait_for_a_kept_group_s_signal_ends_at_the_next_completion_turn make their device
with DeviceOptions::assume_submissions_merge and asserted a held group wherever the two queues
share a VkQueue. The runtime holds a batch in a group only where the merge check holds and the
queue's failures are not relayed (command_buffer/group.rs `groups`); MoltenVK's are relayed, so
there no group is held whatever the check says, and the group assertions could not pass on the
M3. As 4fc5f5b6e4 did for grouped_submissions' own runs, both tests now read `groups` (merges and
not relayed): the group assertions run where the device groups and the queues share a VkQueue;
where it groups none they assert nothing was kept, grouped or sent as a group, and the waits
and completions are checked as before. Both still assert that the merge held as assumed.
The merge check compared the least of its rounds of one call of four VkSubmitInfos against the
least of its rounds' sums of four calls of one. A round of the calls apart holds four windows
inside a call, the one call one, so load beside the check that lengthened any one call of a
round lifted that round's sum: every round of the calls apart took a hit about four times as
often, its floor rose where the one call's stayed, and that reads as a merge. On the M3 Max
beside loops of the device tests (MoltenVK 1.4.2), 145 of 15,181 devices answered Holds at 0.29
and up where its quiet tries are 0.81 to 0.91. A relayed queue never groups, so that verdict
mattered only for an adopted MoltenVK device, whose queues are not relayed: there a Holds for
the device's life groups its batches on a driver that runs each VkSubmitInfo as a Metal command
buffer of its own.
No structural fact decides it: Vulkan says nothing of whether a driver merges submit infos, and
the check exists so that no decision reads the driver's identity. So the comparison is made
load-robust instead: the calls apart keep each call's time, and the form's floor is the sum of
each call position's own floor over the rounds (apart_floor). Each floor is then the least of as
many single-call windows as the one call's (eight a half), equally exposed to load; load on one
call of each round, whichever, moves none. The thresholds are unchanged (MERGE_RATIO 0.6 in both
halves; a record needs MERGE_HOLDS_CLEAR 0.5 / MERGE_FAILS_CLEAR 0.75 and MERGE_REPEATS more
tries). Quiet, the sum of the floors is at most the old floor of the sums, so the probe's
quiet ratios (RADV 0.33-0.38, ANV 0.39, MoltenVK 0.98) stay where they were.
CHECK_VERSION 8: what the check measures changed, so no record of 7 is read.
New test: load_on_one_call_of_each_round_apart_answers_no_merge (the M3 Max's quiet floors
under a rotating load: the old floors answer Holds, apart_floor answers Fails; the 780M's
floors under the same load still answer Holds).
The serde round-trips of BindState and BindShape name every field, so the new one failed to
compile there (lint job m3-max-16571, core job m3-max-16572).
lavapipe's fixed-function vertex input takes an element's displacement modulo 2^32: the
conformance case vertex-fetch-past-4gib-small-buffer reads the wrapped words in 24 elements
where Metal reads zero. Vulkan places the attribute at the whole displacement (28.4 Vertex Input
Address Calculation) and robustBufferAccess2 makes a read past the bound range zero, so the
wrap is the driver's defect: a new RuntimeDriverDefect::VertexFetchWrapsPast4GiB, listed for
MESA_LLVMPIPE alone.
On a listed driver the render lowering names the fixed-function layouts a draw may fetch past
2^32 bytes of their bind offset in a new BindState/BindShape field, far_vertex_buffers, and the
binder pulls them (the existing pulled-vertex-buffer variant, whose fetch reads past 2^32 as
zero). The reach is the existing furthest_element: a draw's last vertex, 65535 plus the base
vertex for ushort indices, the base instance plus the last instance over the rate. Those are
pulled by default. A per-vertex layout of a uint-indexed draw, and an indirect draw's, has its
reach stated by GPU memory; pulling it costs a variant for every such draw, so it is behind a
new runtime-only DevicePolicy switch, vertex_reach (VertexReachPolicy::Bounded by default,
Exact in exact_answers()). Under Bounded such a draw keeps fixed function and is announced
vertex-fetch-may-wrap (Precision). The draw-again paths (rebound, restated) compare the pulled
set; the host-step precompile names none; the GPU replay derives it from its indirect draw.
WorkCounts::far_vertex_fetch_pulled_draws counts the pulled draws.
The conformance case's known-gaps row is removed: replay runs under Exact. FAST-PATHS gets the
switch's row (its lavapipe cost is measured next, in a later commit). New tests: the binder
pulls a named layout; far_layouts under both policies; runtime_lane::far_vertex_fetches
measures the defect on every device under both values, and far_reach_costs (ignored) measures
the exact form's cost.
SEMANTICS_VERSION is unchanged: an empty far_vertex_buffers, every existing shape's, plans as
before, so no output changes under an unchanged key.
Verified so far: api_signatures blessed (signatures.py), refusal_surface --check, the
conformance and Metal coverage checks; builds and tests follow as potluck jobs.
Paused by main for a higher-priority bug. This commit has no code changes. It
records where the work stands so the branch can resume from here.
Item 1 (vertex-fetch-past-4gib-small-buffer on lavapipe):
- Spec reading (main agreed): Vulkan forbids the 2^32 wrap. 28.4's
attribAddress = bufferBindingAddress + vertexIndex * stride + offset gives
no width or modulus. 28.4.1 sends an attribAddress outside the bound vertex
buffer to Shader Out-of-Bounds Memory Access, and under robustBufferAccess2
a vertex input read outside the range produces zero (9.6.2). No VU or limit
keeps vertexIndex * stride below 2^32 (fullDrawIndexUint32 allows index
2^32-1, and maxVertexInputBindingStride is at least 2048). So the wrap is
lavapipe's defect.
- Gate: a RuntimeDriverDefect row on MESA_LLVMPIPE's driverID
(runtime/driver_defects.rs), measured on each device by a runtime_lane
test. It is not a DriverFact: those cover answers Vulkan leaves open.
- Decided with main (rule 1):
- Default, exact, no switch: on a device with the defect, pull a
fixed-function layout when its reach reaches 2^32 bytes or more past the
bind offset. The reach is the draw's own O(1) bound times the stride,
plus the attribute's offset and size. The bound is the last vertex of a
non-indexed draw, 65535 + base vertex for u16 indices, and baseInstance
+ (instanceCount-1)/rate for per-instance layouts.
- Opt-in switch: a new DevicePolicy field, included in exact_answers().
It also pulls u32-indexed and indirect draws, whose reach GPU memory
states. Without it they keep fixed function, and the wrap stays.
- FAST-PATHS row for the switch, with the measured lavapipe cost: pipeline
creations and draw time, pulled vs fixed function, for a u32-indexed
draw. Tests of both settings.
- Ledger: conformance replay runs under Exact, so with the switch in
exact_answers() the case passes there and its known-gaps row goes. The
ledger has no policy scope, so the default-policy divergence (the two
far u32-indexed draws at stride 4) is described in FAST-PATHS. Tell main
about this.
- Mechanism found:
- BindState/BindShape get a per-draw field, the Metal vertex buffer
indices to pull, part of the shape like private_list.
- The binder (bind/graphics.rs, the vertex-buffer loop near
`if !fetchable`) adds them to pulled_vertex_buffers, the existing
pulled-vertex-buffer variant (link/vertex.rs item 7).
- The runtime fills the field in settle_draw (render.rs, the reshape.field
lines) from pipeline.base().vertex_input.bindings and attributes, the
encoder's per-bind strides and the draw. Reuse
render/vertex_reach.rs furthest_element and fetch_reach::reach.
- Also cover render/draw_again/rebound.rs and render/executions.rs, which
call check_vertex_reach.
- Regenerate api_signatures.tsv (scripts/api-signatures), REFUSALS.md
(scripts/refusal-surface) and the fast_paths choices list.
Item 2 (submit_check merge verdict, assume_submissions_merge tests): not
started. Notes so far:
- groups() in command_buffer/group.rs needs Grouped, submissions_merge_now
and an unrelayed queue (flights(queue).is_none()).
- An adopted MoltenVK device is unrelayed (device/relay.rs "Not relayed").
So skipping the check on relayed devices alone would not fix the case
that matters; the timing or the structure must decide there.
- The merge check compares the floor of one vkQueueSubmit of four infos
against four calls of one. The four-call arm sees four times the load
exposure.
The landed packet changed a runtime-sources input, so the committed digest no
longer described the sources and `the_runtime_sources_are_the_committed_ones`
would fail. Recomputed over the same inputs and committed by land-pkt.sh.
Each aspect of a pass's separate depth and stencil textures loaded DontCare and not stored
now clears the scratch to its clear value where UnstoredDontCarePolicy clears (Cleared, or a
driver with UnstoredClearNoSlower), else stays DONT_CARE with dont-care-unstored-load
announced. Verified on the branch: Metal on the M3 Max 120/120 (potluck m3-max-16522);
before the fix lavapipe and the M3 fail (16542, 16558: 48/120); after it lavapipe 2/2 lane,
1972/1972 lanes, 2130/2130 suite (16550, 16609), M3 120/120 and 180/180 lanes (16606,
16643); lint 16552; fast_paths/api tables 40/40 (16569).
Correction to cd81764912's message: MoltenVK's earlier DONT_CARE read a stencil of 0
(verified, 16558); the depth read neither the poison nor the clear value, and 1.0 was not
verified.
A pass whose depth and stencil attachments are two textures renders through a scratch image of
the combined format (depth_stencil_scratch.rs), and clear_reach::dont_care_loads skipped it: an
aspect loaded DontCare and not stored took the scratch's DONT_CARE load under every policy, with
no notice. So under exact_answers() its draws read what the new scratch image held (on MoltenVK
a stencil of 0 and a depth of 1.0, Metal's defaults for a load that names no clear value), where
Metal's read the pass's clear value: measured on the M3 Max under macOS 27.0.1 by the lane's
passes through Metal itself (job m3-max-16522), each aspect apart, whether the other aspect is so
loaded or loaded and stored.
Now such an aspect takes the answer of any attachment so loaded, each aspect apart: in a pass
whose draws reach a tile, the scratch's Clear to the aspect's clear value under
UnstoredDontCarePolicy::Cleared and on a driver with DriverFact::UnstoredClearNoSlower (the
scratch image is a combined depth/stencil attachment, the shape the fact measured), else its
DONT_CARE, announced dont-care-unstored-load naming the aspect. Nothing is copied into the
aspect before the pass (only Load aspects are), so no earlier bytes reach it. An aspect the pass
stores keeps the scratch's DONT_CARE load as before.
Docs: clear_reach.rs records Metal's answer for separate textures and the rule; the scratch
module, the notice's rustdoc and catalogue entry, UnstoredDontCarePolicy's rustdoc, API.md's
section and the FAST-PATHS row name separate textures; the known gap is removed.
A pass of a Depth32Float and a Stencil8 texture apart, which the runtime renders through a
scratch image of the combined format: in three modes it loads both DontCare and stores neither,
or one so and the other Load and Store; dcs_mark writes MARK (stencil 1, depth 0.125 through the
viewport's depth), then dcs_flag draws over the whole target under a stencil test (Equal 0, the
poison's 0xAB, the pass's clear value 0x5C) or a depth test (Equal the poison's 0.625, the clear
value 0.375). Two sizes, two runs each, under the default policy and exact_answers().
Metal's answer, measured on the M3 Max under macOS 27.0.1 by the same passes through Metal itself
(a throwaway Swift probe of the fixture's MSL, job m3-max-16522, with and without API validation,
120 of 120 cases): an aspect loaded DontCare and not stored reads the pass's clear value, one
loaded reads the poison, whatever the other aspect does. The lane expects that under
exact_answers() and on a driver with UnstoredClearNoSlower, and dont-care-unstored-load exactly
where the runtime leaves the load to the driver; elsewhere it prints the reads.
The runtime at this commit loads the scratch DONT_CARE under every policy and announces nothing:
the new test fails here, and the next commit fixes the runtime. The existing test's mismatches
helper now takes the expectation as a closure, and Draws a depth format.
Measured by the consumer on the RTX 5080 Laptop GPU and a Radeon Pro 5300M (their jobs
16447, 16453, 16455, 16554): Shared no-copy 5.3 GB/s against Private 328 GB/s on the 5080;
6.1 against 96.1 on the 5300M. Apple's OpenCL on Metal synchronizes its Managed buffers on
its map path only, so a second copy would go stale; its buffers stay Shared on a discrete
GPU, a cost recorded here.
The landed packet changed a runtime-sources input, so the committed digest no
longer described the sources and `the_runtime_sources_are_the_committed_ones`
would fail. Recomputed over the same inputs and committed by land-pkt.sh.
A host step's recording in place of the commit's follows the old recording's decisions and
keeps its takes, giving back those it never met; a command buffer dropped before its commit
gives back every take of its ended encoders. Verified on the branch: before the fix lavapipe
fails both legs (potluck m3-max-16466, 16507); after it lavapipe and RADV PHOENIX 39/39
(m3-max-16508, 16509) and 268/268 broad selection (16467, 16468); lint m3-max-16510.
Metal makes no state for indirect command buffers whose function takes a texture directly (the
runtime answers IndirectCommandsDirectArgument as Metal does: lavapipe m3-max-16487, the 780M
m3-max-16488), so the leg's sample_level command could not be made. An indirect command reaches a
texture only through an argument buffer naming its resource ID, the texture made resident.
The leg now runs rt_heap_zero (engine/kernel_read_through.ll), which reads texel (1, 1) of level 1
of the argument buffer's texture, with the tiled texture made resident by useResource. The
commit's recording takes the copy; the host step records the execution again after the CPU writes
the command; the read must find level 1's grey, and the next use must take no copy and read every
level as taken.
The leg's first form made the texture resident with useResource under a kernel of plain buffers.
Its commands reach no resident texture, so no recording took the copy and the leg passed with or
without the fix (lavapipe m3-max-16466/16467, the 780M m3-max-16468: the next use took the
copy).
Now the indirect command buffer inherits the encoder's bindings (inherit_buffers) and its command
runs sample_level, which samples the texture the encoder set at LOD 1. The commit's recording of
the execution takes the copy; the host step records it again after the CPU writes the command.
The leg checks that the step's recording made the copy (the samples read level 1's grey), and
that the next use takes none and reads every level as taken.
A tiled texture's copy taken at use was lost in two places where nothing ran it:
- Work the commit recorded and a host step records again (an execution of indirect commands the
CPU wrote since the commit): the step's cores decided by the mark, which the commit's recording
had cleared, so the recording that runs took no copy and the texture read stale levels. Now the
step hands the replaced recording's takes to the cores it records into (State::step_takes, read
by EncoderCore::segment_raw, under the step's turn): ShadowSync::over follows each decision
that recording made, keeping its take and number, and decides a use it never met by the mark.
As the step's recording replaces the commit's, a take of the commit's it never met is given
back (Takes::give_back_unheld). TakeBy::Mark carries the replaced decisions; a core with none
decides as before.
- A command buffer dropped without a commit kept its encoders' takes. Its drop now gives back
every take of its ended encoders and of its segments' recordings while its status is still
NotEnqueued.
Unit test tests::shadow::a_recording_in_place_of_another_keeps_its_takes covers the follow, the
by-mark decision of an unmet use, the give-back of an unmet take and of none kept, and a kept
no-take after did_modify_data. The device legs are in the previous commit. docs/API.md's tiled
texture paragraph says both.
Two device legs of a tiled texture whose first use's take is lost today:
- tiled_texture_failed: a command buffer whose blit takes the copy is dropped without a commit.
Nothing of it ran, so the next use must take the copy and read the grey in every level.
- tiled_texture_step (new): a compute encoder makes the texture resident and executes an indirect
command buffer the CPU encoded, behind a shared-event wait; the CPU writes the command again
after the commit, so the host step records the execution again (counted in
host_steps_recorded). The commit's recording took the copy and never runs; the step's must take
it there, so the next use takes no copy and reads the grey as taken.
Both fail before the fix: the next use takes no copy and reads zeros.
The landed packet changed a runtime-sources input, so the committed digest no
longer described the sources and `the_runtime_sources_are_the_committed_ones`
would fail. Recomputed over the same inputs and committed by land-pkt.sh.
DevicePolicy::unstored_dont_care_loads (Driver by default, Cleared under exact_answers()):
a DontCare load the pass does not store clears on a driver with
DriverFact::UnstoredClearNoSlower (MoltenVK on the M3 Max, RADV on the 780M, measured) and
elsewhere stays DONT_CARE with the dont-care-unstored-load notice. Verified on the branch:
M3 lane and 111/111 lanes (potluck m3-max-16385), lavapipe 112/112 lanes and 2097/2097
device suite (m3-max-16387), clippy three ways and rustdoc (m3-max-16438). The new fixture
dcs_dont_care_split's golden tables are re-blessed on development.
The same probe through the 5080 batch loop (b1111-091522-t, job m3-max-16381, exclusive): 74.4 and
74.6 us a pass with CLEAR against 71.2 and 71.4 with DONT_CARE, the rounds' spreads apart (73.6 to
75.1 against 70.2 to 72.6). NVIDIA keeps DONT_CARE under the default, announced; the RTX 3090 is
unmeasured (um870 stayed behind exclusive boots) and takes the same.
a_radv_gpu_no_row_names_takes_radv_s_driver_wide_fact_alone failed at 468712b4ab (m3-max-16386):
its Phoenix set lacked the new row; the XTX, the RX 550 and an unnamed RADV GPU still take none.
degrade_notices::every_kind_has_a_site_a_lane_test_takes failed on the M3 (m3-max-16380): the new
kind had no lane site. dont_care_unstored declares UNSTORED_LOADS and asserts it where the runtime
leaves the load to the driver.
The fix before this cleared every attachment a pass loads `DontCare` and does not store, Metal's
answer (lane dont_care_unstored). Measured, that clear is no cost on some drivers and a cost on
others, so by rule 1 it is now a speed-for-accuracy choice with both forms kept:
- DevicePolicy::unstored_dont_care_loads: UnstoredDontCarePolicy::Driver (the default) clears
such an attachment on a driver with DriverFact::UnstoredClearNoSlower and leaves it DONT_CARE
elsewhere, announced `dont-care-unstored-load` (a new precision notice); ::Cleared, which
exact_answers() selects, clears it everywhere. The runtime's choice alone: no profile carries it.
- DriverFact::UnstoredClearNoSlower, a cost fact, one row per GPU measured no slower with CLEAR
than DONT_CARE (a probe of eight 3648x2038 passes a frame, an RG16Float colour and a
Depth32Float_Stencil8 loaded by the form and stored DontCare, GPU time per pass, medians of 15
frames in two rounds): RADV, Mesa 26.2.6, on the Radeon 780M (861 and 865 us against 1147 and
988, job m3-max-16320) and MoltenVK 1.4.2 on the M3 Max (218 and 218 against 224 and 217,
within one form's spread, m3-max-16341). Measured slower, so no row: lavapipe (10480 and 10744
against 7280 and 7259, m3-max-16321) and ANV, Mesa 26.2.6, on the Iris Xe (1936 and 1936
against 1907 and 1151, m3-max-16343).
- The lane dont_care_unstored expects Metal's answer under exact_answers() and on a driver with
the fact, lavapipe's earlier texels under the default there, and the notice exactly where the
load is left to the driver.
- dont-care-store's text names the new answer after such a pass: where the pass loads the
attachment DontCare and clears it, a tile no draw touches holds zero or the clear value.
- docs/FAST-PATHS.md: the switch's row with the per-driver numbers, and a known gap: separate
depth and stencil textures (the scratch path) still load DONT_CARE under every policy.
NVIDIA is not measured yet; its row follows with the measurement.
Metal (an M3 Max, macOS 27.0.1, lane dont_care_unstored): an attachment a pass loads `DontCare`
and does not store reads zero (a color) or the pass's clear value (a stencil) wherever the pass's
draws read it, never its earlier texels. The runtime left such an attachment `DONT_CARE`
(clear_reach::dont_care_loads skipped every attachment the pass does not store): the first
instance's DONT_CARE load read 0 for the stencil (MoltenVK names no clear value there), later
instances of a split pass LOAD what the first left, so the tiles it did not reach read the
earlier texels, and a color the only instance leaves out (fetched through the pixel interlock)
read its earlier texels everywhere.
Now such an attachment (not memoryless, not separate depth and stencil textures) takes `Clear`
in a pass whose draws reach a tile: zero for a color (dont_care_clear), the attachment's clear
value for depth and stencil, by the first instance's load operation over the render area, and a
color that instance leaves out is cleared before the pass by the existing path for cleared
storage colors (cleared_ahead, or the reach pass over the render area). It is not tile-bounded
and not announced: no fragment reads a tile no draw touches, so the answer is Metal's wherever it
is read. `dont-care-load-tiles`' text, rustdoc and catalogue entry are scoped to stored
attachments; clear_reach.rs records Metal's measured answer and the rule.
A pass loads a second RG16Float color and a Stencil8 `DontCare` and stores neither; its draws
read them through a framebuffer fetch and a stencil test, in seven arms: a pass whose first draw
reaches some 32x32 tiles and a later one every tile (which splits the pass where the device
fetches through the pixel interlock), a pass of the fetch alone (the second color left out of the
only instance), and passes of no fetch testing the stencil against 0, the poison's 0xAB and the
pass's clear value 0x5C. Each arm runs twice over the same textures, at 224x128 and 128x128,
under the default policy and exact_answers().
The expected classes are Metal's, measured on the M3 Max (macOS 27.0.1) by running the same MSL
through Metal itself (probe jobs m3-max-16192 and m3-max-16205): the color reads zero and the
stencil the pass's clear value wherever a draw reads them. The runtime at this commit reads the
poison's second color in the tiles a split pass's first instance does not reach and everywhere
in the fetch-only pass, and a stencil of 0 (Vulkan's DONT_CARE) or the poison, where Metal reads
0x5C: the lane fails here, and the next commit fixes the runtime.
The fixture dcs_dont_care_split is our own MSL, its companions from
scripts/regen-air-fixtures.
The landed packet changed a runtime-sources input, so the committed digest no
longer described the sources and `the_runtime_sources_are_the_committed_ones`
would fail. Recomputed over the same inputs and committed by land-pkt.sh.
The branch's own bump to 2033 collided with clswizzle's identical one, so its reflection change
takes 2034. The runtime's copied-host-pages notice now names the failed import's cause.
Verified on the branch: lavapipe 114 touched tests (potluck m3-max-16426) and 52/52 at the tip
(m3-max-16434), RTX 3090 6/6 (m3-max-16470), clippy three ways and rustdoc (16424, 16465, 16477).
The device test's sink now keeps each notice's reason with its kind. The buffer and the rebind
whose pointer import fails (Device::fail_next_host_imports, the driver's out of device memory)
assert their copied-host-pages reason opens "their pointer's import failed: out of", the
failure the commit before names; before it, the reason was "their import failed". This runs
the failed-import cause on every device that imports pointers, lavapipe among them, not only on
NVIDIA's unpinnable pages.
The copy-cause test was inserted between the_host_page_is_known_on_unix and its #[cfg(unix)],
which then guarded the new test and left the host-page test unguarded. Each has its own now: the
cause test runs everywhere, the host-page test on unix alone, as before.
entry is public; its doc linked the private bound_texture, which rustdoc refuses under -D warnings
(AGENTS.md: public docs never link to private items). No code change.