Commit Graph
928 Commits
Author SHA1 Message Date
Anees Iqbal 84db1b3675 FAST-PATHS: the ANV binding-table pool gap with the passes inline and the barriers bounded
The known gap now counts command buffers begun (barrier command buffers took blocks too), names
the passes that still take a secondary, the 2,048 planned barrier command buffers a batch begins
at most, and what ms01's Iris Xe (Mesa 26.2.6) measured: 10,000 passes beside a cleared depth in
one command buffer run in 12,049 command buffers (tests::many_passes); passes inline encode to
16,173; passes with a secondary fail at the end of the 8,087th; with the targets' first clears in
the submission 14,000 passes ran and 14,300 crashed in the driver, recorded as the open part.

Verified: the numbers are the probe runs' (jobs m3-max-13726, -13731, -13643).
(cherry picked from commit 67f1d8710d78adf21768002c82a86e739721e271)
2026-11-10 05:25:14 -08:00
Anees Iqbal f0b1976e58 Queue sharing: a command buffer whose VkQueue waits on the GPU for another's work counts that wait in its long mark
The Adaptive long mark read a command buffer's own GPU timestamps alone. A batch that waits on the
GPU for another VkQueue's work (an MTLEvent's signal pending there, the tracker's wait for another
VkQueue's writes, new resources' first work there) writes its start timestamp only once that wait
is met, so a queue of short command buffers, each waiting for another queue's 30 ms one, never went
long: it kept sharing its VkQueue, and every command buffer the queues sharing it committed behind
each wait waited for the other queue's whole long command buffer.

Now submit_batch notes, at the first batch whose VkQueue it hands such a wait (an event wait whose
signal is pending on another VkQueue or is the caller's, EventTimeline::waits_across; a tracker or
first-work wait on another VkQueue), the host time its submission was called (Times::waited_across).
place_gpu_times marks the queue long also where more than LONG_HEAD ran from then to the command
buffer's GPU end, placed in the host's time. A command buffer with no such wait is timed as before,
by its own timestamps, so the host-view false marks the module docs describe stay out.

The device test a_compositor_beside_a_queue_waiting_on_the_gpu_for_long_work_keeps_its_latency now
also asserts that the waiting queue goes long (WorkCounts::queues_gone_long >= 2). The QueueSharing
notice's cost, docs/API.md's catalogue entry and the FAST-PATHS row name the wait.

Verified: cargo fmt; unit test a_wait_crosses_queues_where_its_signal_is_pending_on_another; the
build, clippy and the 5080 device run are dispatched.

(cherry picked from commit 6391625634472fb158b6477dfad36340956ae2dd)
2026-11-10 05:16:05 -08:00
Anees Iqbal ff45556bcc An argument buffer's sample filter note holds only where its heap can name a filtered raw texture
What: a heap sample the function emulates (`sampler::heap_raw`) recorded
`PrecisionNote::BicubicFilterArithmetic` whatever the command's heap held: unconditionally
through a constexpr linear sampler, and under the bound sampler's word through a runtime
slot. A command whose heap holds no raw texture samples through the device's own sampler,
and a bfloat form's sample reads the nearest texel, so neither filters by the device's
arithmetic. `SpecKey::HeapRawTextures`' value now carries two bits, which the plan gives
from the command's heap members (`slots::heap_raw`): `heap_raw::HELD` (1, a raw-held
texture: the decode's `DevicePackConversion`, unchanged) and `heap_raw::FILTERED` (2, a
raw-held texture of a form the function filters: not a bfloat one). The filter note's
clauses each test `FILTERED` (beside the bound word's test through a runtime slot).

Runtime: `degrade_bound_values` reads the clause at each draw or dispatch, so a command
whose heap holds only RGBA8Unorm or RGBA16Bfloat textures no longer announces
bicubic-filter-arithmetic for a linear heap sample; one holding a BGRA10XR texture still
does. No runtime code changed (the path is generic).

Tests: heap::a_heap_sample_s_filter_note_follows_the_raw_texture_and_the_bound_sampler_word
(artifact clauses on every committed profile), heap::a_heap_sample_s_filter_note_holds_where_its_command_can_name_a_filtered_raw_texture
(plan values 3/1/0 and the notes bound under them), the decode-note plan test's values
(3 for BGRA10XR, 1 for RGBA16Bfloat), engine_sampler's argument-buffer stage check, and the
lane heap_extended_reads::a_heap_sample_s_filter_note_is_announced_where_its_command_can_name_a_filtered_raw_texture.
Docs: SpecKey::HeapRawTextures, the note's rustdoc, API.md.

SEMANTICS_VERSION 2018 (renumbered at landing).

(cherry picked from commit dbc8a2781ef6170f797d5b7a7a83b46264c5e4e2)
2026-11-10 04:45:12 -08:00
Anees Iqbal 24025b3866 Argument-buffer textures read through a sampler: border texels from the handle-table entry
What: a Metal 4.1 read(sampler, ...) of a texture held in an argument buffer now hands back
Metal's border texel of the resident texture, its pixel format's through its swizzle, for every
sampler: a constexpr one of any border colour, a runtime [[sampler(n)]] and an argument buffer's
sampler (the colour from the sampler's word).
- The binder writes each texture's border texels (metal::sampler::border_texels of its format
  and swizzle, the layout of a slot's BorderTexels specialization) in its handle-table entry's
  flags, bits 3 to 14 (memory::handles::FLAG_BORDER_TEXELS); handle_entry_flags carries them, so
  a consumer's own table of every ID gets them too.
- A module with such a read searches the table in a new indexed form (Lookup::Indexed): the
  handle is the element with the found entry's index in its top 16 bits (HANDLE_ENTRY). The read
  loads the entry's border texels by it (handles::border_texels); every use that reads another of
  the entry's flags (texel class, red-blue order, out-of-bounds alpha) loads them from the entry
  into the flagged handle's layout (handles::flagged_handle), through one typed value
  (texture::emit::HeapFlags) so no reader sees the entry index in those bits.
- through::finish selects the border texel for slots and heap elements alike; a heap member read
  by its raw texels (an extended-range form) takes its border and its zero past the level or
  layer from its own image's addressing inside the raw arm, not the float array's neutral's.
- The old heap path, which selected the out-of-bounds texel (transparent black, unswizzled) and
  refused every other border colour and runtime sampler NotImplemented(ArgumentBufferTextures),
  is gone, with ReadSampler::transparent and the forced alpha flag of such reads.

Why: the M3 runs all three (conformance cases read-through-heap-border, read-through-heap-sampler,
and read-through-rgba8-swizzled's rt_heap_zero, where (G, R, 1, 0) reads (0, 0, 1, 0) past the
edge and we read (0, 0, 0, 0)). A 32-bit heap handle had no room for 12 border bits beside the
element, class, red-blue and alpha fields; the entry does (bits 3 to 14 were unused).

SEMANTICS_VERSION 2017 (translation output changes). ARTIFACT_FORMAT_VERSION unchanged: no
encoded type changed. RUNTIME (for the orchestrator's bump): the runtime's handle tables
(heap_sets.rs, through bind::handle_entry_flags) now carry the border-texel bits.

Ledger: the three rows of these gaps go; llvmpipe's rt_heap_zero row of the swizzled case keeps
only llvmpipe's 8-bit unorm conversion. FAST-PATHS known gap removed; REFUSALS.md,
CONFORMANCE-COVERAGE.md regenerated (METAL-COVERAGE.md unchanged).

Verified: not yet built (next: Linux build, clippy and the touched tests).
(cherry picked from commit bc000fa475e572131248b908541dbe29f1f5996c)
2026-11-10 04:45:05 -08:00
Anees Iqbal 7b41681b7e Regenerate CONFORMANCE-COVERAGE.md after triage-a's ledger rows
The llvmpipe 3D mirror rows' text and the RADV row of pass-bytes-srgb-decode-all-bytes
(the two commits before this one) change what the coverage document derives.
Verified: scripts/conformance-coverage/coverage.py regenerated it.
2026-11-10 04:15:23 -08:00
Anees Iqbal 5e51dc6023 METAL-COVERAGE names the macOS 27.2 SDK its table was checked against
coverage.py's SDK line still said the macOS 27.0 SDK (Xcode 27.0, 27A266a),
while the M3 has Xcode 27.2 (27B52) and its MacOSX27.2.sdk; the generated
enum tables already name 27.2. The table needed no row change: on the M3,
coverage.py --sdk against MacOSX27.2.sdk answered 'coverage.tsv names every
SDK item (2135)', rc 0 (potluck job m3-max-13567). docs/METAL-COVERAGE.md
regenerated (coverage.py), coverage.py --check current.

(cherry picked from commit ca8424427caaa8636587eb5593e7b91b68afe9b1)
2026-11-10 04:15:05 -08:00
Anees Iqbal 2c31428f3c Measure a texture's first CPU copies after a runtime suspend; the known gap is the device's resume
The XTX's first get_bytes after the GPU idled into runtime suspend took 4.7 to
5.2 s. A run decides whose that is: any first submission after the suspend
pays it, so it is the kernel's resume of the device, not our staging queue.

tests::cpu_copy_times gains an ignored measurement, run by name: per size
(1920 x 1080 in a pooled block, 4096 x 4096 in a block of its own) it makes a
Shared BGRA8Unorm texture, copies it awake once, then for three sequences,
each twice, waits for the PCI function's power/runtime_status to read
suspended and times each step: replace_region then get_bytes; get_bytes then
replace_region; a fill command buffer on the program's queue (commit timed
apart from its wait) then both copies. It prints the status after each step
and the staging submissions made.

Evidence, RX 7900 XTX on gem10 (Mesa 26.2.6, autosuspend delay 5000 ms),
job m3-max-13545, two runs, 24 suspends:
- the program queue's command buffer: commit 0.12 to 0.52 ms, its wait 4.83
  to 4.86 s;
- the staging queue: replace_region returned in its awake time (0.48 to 12.74
  ms at 1080p, 5.02 to 5.58 ms at 4096^2) with the device still suspended,
  and the get_bytes after it, the first staging submission, took 4.73 to
  4.79 s; get_bytes first took 4.76 to 4.88 s;
- after the command buffer woke the device, get_bytes took 3.2 to 4.0 ms
  (1080p) and 18.7 to 20.8 ms (4096^2).
The kernel's log of the run's last resume: SMU resumed at :09, "Wait for DMUB
auto-load failed" at :10, 16 "DMCUB error" lines to :13, "Cannot find any crtc
or sizes", then the rings: the card has no display attached.

Paying it ahead off the caller's path: a commit already hands its batches to
the scheduler thread and returns in under a millisecond, so only a wait or a
synchronous read waits. A wake started when a replace_region queues its copy
would win only the time between that call and the next submission (none in
the measured sequences) against a 4.8 s resume, and the program's queue and
the staging queue pay alike, so no queue choice avoids it. A keep-alive is
out. No runtime change.

docs/FAST-PATHS.md's known gap is rewritten with these numbers; its 86 ms
and 73 ms first replace_region of the host path no longer apply on the XTX,
whose Shared textures copy on the staging queue (replace_region now
returns in its awake time after a suspend).

(cherry picked from commit 112b405a9167666407ae15cd08b7bdf76d09d038)
2026-11-10 03:33:55 -08:00
Anees Iqbal 445d410eda An extended-range sample's filter note through a runtime sampler follows the bound word
What: a sample of an extended-range or padded texture that the module filters itself
(`sampler::extended`, through the slot's variant, and `sampler::heap_raw`, through an
argument buffer's raw element) recorded `PrecisionNote::BicubicFilterArithmetic`
unconditionally through a runtime sampler slot. It is now specialized on the word of the
sampler bound at that slot (`NoteOn::BoundSampler`, `SpecKey::BoundSamplerWord`), with the
two tests `linear::filtering_word` gives, as the YCbCr filter note does: a linear
minification or magnification filter, anisotropy or a cubic filter (any of those bits), or
a linear mip filter. The level blend of a word-stated mip filter holds on the linear mip
test alone. A constexpr sampler keeps its rule (linear: unconditional; nearest: none).

Runtime: the clauses test a bound value, so `Device::degrade_bound_values` reads them at
each draw or dispatch of the variant (no runtime code changes: the path is generic, and
`slots::record_noted` already records the word for a noted key). A nearest runtime sampler
over such a texture no longer announces bicubic-filter-arithmetic; a filtering one still
does.

Why: a nearest sample is the decoded texel at Metal's position (no filter arithmetic), yet
it announced the note, so the conformance suite's nearest cases
(`rgb10a2-srgb-samples-nearest-*`, the eight `xr-two-plane-samples-*-n*-*`) declared it.

Tests: engine_extended_range::samples::a_runtime_sampler_s_filter_note_holds_only_where_the_bound_word_filters
(every form, half and float, runtime / constexpr linear / constexpr nearest, on lavapipe,
moltenvk-m3 and the RTX 5080 profile: clauses hold for linear, linear min, linear mag,
linear mip, anisotropic and cubic words, not for nearest or nearest-mip ones; bfloat forms
record none) and heap::a_heap_sample_s_filter_note_follows_the_bound_sampler_word. The
rgb10a2_srgb lane now checks its nearest samples announce no filter note. The conformance
allowances of the rgb10a2 sRGB and two-plane sample cases name the note for the linear
cases only. Docs: the note's rustdoc and API.md's catalogue entry.

SEMANTICS_VERSION 2016: an artifact's notes change.

(cherry picked from commit fd5212bee216b823ba18d3c5ba5e5a74a4b12073)
2026-11-10 03:17:33 -08:00
Anees Iqbal 6be4be9791 Keep the predicted plain half arm in a key's general form: a creation makes one pipeline, not two
What: on a device that samples through Metal's own texture unit (MoltenVK), a texture slot a
function converts to `half` declares SpecKey::PlainHalfTexels and SpecKey::UnmeasuredTexels.
The general form (render/residual.rs) zeroed both, so a state's creation made its predicted
key's general form (the class routine's arm, PlainHalfTexels 0) and handed the predicted key
itself (the plain arm, 1, as an unbound slot takes) to the pool right after. Every draw of a
plain class takes the predicted key, so the general form served a draw only while the
predicted key was still being made; the conformance cases render-then-sample-magnified-nearest
and -linear made it and no draw took it (cost.rs named it an open bug). PlainHalfTexels is no
longer a constant of the general form: a key keeps the plain arm its binding gives it. The
predicted key is now its own general form, and the creation makes that one pipeline.

What still takes a general form: a draw binding a class whose `half` conversion is not
measured (BC4 to BC7, the linear ASTC formats) keys UnmeasuredTexels 1, which no instruction
reads; its general form is the predicted key, made at creation, so it draws at once and runs
its own key's instructions while its own is made on the pool, as before. A draw binding a
YCbCr field on the grid 8192 (PlainHalfTexels 0) makes its own key at its draw, as any key the
creation did not predict; on a device whose memory is the host's such a slot reads its planes
in place in a variant of its own (VariantKey::ycbcr_in_place), which no creation predicts
either.

Tests: tests::general_form now expects the plain arm kept ([1,1,1,5,3] -> [0,1,0,5,3], an
unmeasured plain class's key -> the predicted key, a YCbCr class keeps the routine's arm); the
made_at_creation lane expects one making at creation on every device (it expected two on
Metal-sampler devices) and the unmeasured-class draw to take the predicted key as its general
form; ycbcr_textures' and runtime_lane's comments follow. Docs: residual.rs, predicted.rs,
WorkCounts::residual_form_draws, API.md's general-form bullet, and cost.rs's open-bug
paragraph (the recordings read 3 made until the rows' next measurement; WASTED_BY_CLASS's
draws ceiling can then drop by 2).

Verified on the M3 Max (MoltenVK 1.4.2), the same diff at 3e0db77c6f over 6f7bb169d2:
- conformance cost --runs 8 --show, each case, in order and alone (jobs m3-max-13511,
  13518): render-then-sample-magnified-nearest and -linear read creation_pipelines_made 2,
  creation_render_pipelines_made 2, variant_pipelines_made 2 (the record holds 3 of each),
  creation_pipelines_drawn 2 (the record's 2): the pipeline no draw took is gone, every
  pipeline made is drawn.
- conformance replay, the whole set (70 s): exit 0, "the 391 row(s) above are exactly the
  open gaps known-gaps.tsv expects on this venue": no case's answers moved.
- 77 touched tests under --cfg m2v_gpu passed: made_at_creation, ycbcr_textures' creation-made
  slot, pipeline_creation's pool draws, draw_work, general_form, uniform_bind_offsets,
  draw_again, draw_shape_notices.

(cherry picked from commit 56ddedfc3498c9376384a3ad4b57e7607d78594a)
2026-11-10 03:07:56 -08:00
Anees Iqbal e14253045b CONFORMANCE-COVERAGE.md regenerated for the extended-range mipmap cases and their ledger rows
Regenerated by scripts/conformance-coverage/coverage.py in job m3-max-13466 at 94a89c5273
(gem10, lavapipe cfg): two more recordings (1265), 23 more ledger rows (3484), and the
blit_encoder_commands family's case count (11). The conformance crate's tests passed against
it there (1050 of 1050).

(cherry picked from commit 0bbbd5f379db297f84df60b129b15a4e6e1222d5)
2026-11-10 03:00:00 -08:00
Anees Iqbal 782da3582b A half read of a 32-bit or small float texel records no NaN note where the device's half is Metal's
On MoltenVK on the M3 Max (m3-max-13447, default policy) half-texel-nans-r32f, -rgba32f,
-rg11b10f and -rgb9e5f answered every value as Metal does and still announced
device-nan-encoding; runtime_lane::half_texel_nans read 0 differing half lanes. The profile takes
DriverDeviation::MetalHalfConversion, whose measurement covers the half result of a read, sample
and gather of every float word of RGBA32Float (NaNs among them) and 16,384 random words each of
RG11B10Float and RGB9E5Float.

half_texel_nans now records DeviceNanEncoding on such a profile only where the bound class is a
half-float one (packed field 0) or of no family, and requires VkProperty::MetalHalfConversion;
elsewhere it keeps the one clause of TexelFormat::NAN_FREE. The 16-bit float formats keep the
note: no deviation records their NaN payloads as measured.

Test: engine_texture's half-read test checks both forms per committed profile (clauses, formats
that hold, the property) and that a profile of the deviation ran. Docs: the note's rustdoc,
API.md's exemptions, the storage_properties doc. Under the branch's SEMANTICS_VERSION (2015).

(cherry picked from commit b03555f8c9f05e382f744593cfaa01f2dc3bbb20)
2026-11-10 02:59:43 -08:00
Anees Iqbal 85b896a7e1 Mesh pipelines: a required object size answers as Metal's first compile, as the mesh stage's does
Metal's answers here depend on what its compiler compiled before, which it keeps across processes
keyed on the function's AIR. With the probe's salt now in the AIR (d49370d732), an M3 Max under
macOS 27.0.1 answered, twice over, each sequence one fresh salt (m3-max-13430):

- required-object-32-max-64: refused on a first compile ("Kernel specified max total threads per
  threadgroup (32) must match compute pipeline specified max total threads per threadgroup (64)"),
  refused again, and again after required-object-32x2 or plain; made only after
  required-object-64-max-64. required-mesh-32-max-64 the same, made only after
  required-mesh-64-max-64. The object stage was made here because an earlier compile let it be.
- A required size gives its stage its threads on a first compile: required-object-32x2 answers an
  object maximum of 64 (we answered 1024), required-mesh-16x2 a mesh maximum of 32, and a
  required 32 beside a function's [[max_total_threads_per_threadgroup(64)]] 32 in either stage.

So the object stage now refuses a required size of other threads than its maximum
(MaxThreadsDiffer { stage: Object }), as the mesh stage already did, and each stage's thread
limit is the least of the descriptor's maximum, the function's, the required size's threads and
1024. RUNTIME behaviour: new_mesh_render_pipeline_state refuses an object maximum beside a
required object size of other threads, and maxTotalThreadsPer{Object,Mesh}Threadgroup answer a
required size's threads. The translator's mesh answers change, under the branch's
SEMANTICS_VERSION bump (2015).

Tests: engine_mesh's refusal test adds the object cases (32 and 16x2 under 64) and makes 64
under 64; its answers test checks a required size alone in each stage and below a function's
maximum; the runtime lane's mesh test does the same on a device. docs/API.md's accepted
difference, the error's and the getters' docs and the probe's measurements say the first-compile
rule and what later compiles answer.

(cherry picked from commit 3b05b274aec46c172fd0a38276c5ca45a1ade4ca)
2026-11-10 02:59:31 -08:00
Anees Iqbal 5bb3d04838 A float ldexp records no NativeNanEncoding: its lowering answers Metal's NaN itself
The 11-02 carve-out run flagged ldexp as possibly over-noted. A float
ldexp is lowered on the bits (math::ldexp_bits): an infinity or a NaN
operand is selected as the result bit for bit, which is Metal's answer
(NanAnswer::Operand: ldexp returns a NaN operand itself). No NaN of the
device's reaches the result on any device, yet float_call left the
answer to the device and recorded NativeNanEncoding everywhere,
MoltenVK included.

FloatFn::metal_nans now includes ldexp on float lanes, so the call
leaves no NaN answer and records no NaN note. A half ldexp multiplies by
2^k, so its NaN is still the device's product's where Metal answers the
canonical half NaN, and stays noted where the device does not answer
that. PrecisionNote::NativeNanEncoding's docs and docs/API.md's
catalogue say so.

Verified: lower::arith::tests::float_ldexp_answers_metals_nan_itself
(fails without the metal_nans change: call.nan is Some(Operand) and
NativeNanEncoding is recorded). SEMANTICS_VERSION 2014: a module
calling float ldexp records one note fewer.

(cherry picked from commit c4b748c1e63cee2a32400145a3665387a8ca72cf)
2026-11-10 02:59:23 -08:00
Anees Iqbal 95969121f1 Known gaps: the padded-fetch cases on the Iris Xe
From the replay of the 11 padded-fetch cases on the Iris Xe (job m3-max-13463): its linear loads
exact, an sRGB twin's colour a half step from Metal's table where the device's Pow decode rounds
apart (device-pack-conversion), and the clear and draw cases the announced stored-codes
difference; the same replay held every padded-blend row on the Iris Xe. CONFORMANCE-COVERAGE.md
regenerated.

(cherry picked from commit 51f7de510a25e696fbb83be145d73e6ee70be94f)
(cherry picked from commit 92f9642928970b8d8f19731a667f9af3572881df)
(cherry picked from commit 9dd440ac76a1bbb46b6d001e936d4693dbe1cd06)
2026-11-10 02:59:19 -08:00
Anees Iqbal 75b45c6493 Regenerate CONFORMANCE-COVERAGE.md after the padded-fetch rows
python3 -I scripts/conformance-coverage/coverage.py; the coverage test found the document stale
at 85edc61c8f (job m3-max-13469).

(cherry picked from commit 53c388806fad4a522aee606e4f8021e95cdabfdb)
(cherry picked from commit b90d930e487ed30c141f5d0e20e0d5c6496a07c6)
(cherry picked from commit 7b59616984a87356c649888200cca22fb52e00be)
2026-11-10 02:59:19 -08:00
Anees Iqbal 8ed67dfa17 Regenerate REFUSALS.md and CONFORMANCE-COVERAGE.md for the padded fetch and its cases
python3 scripts/refusal-surface/refusal_surface.py (the padded fetch's FramebufferFetch site
gone) and python3 -I scripts/conformance-coverage/coverage.py (the padded-fetch cases);
METAL-COVERAGE.md is current (coverage.py --check).

(cherry picked from commit 0c8ad6c47d76ff7436835fa5377ff17700151c21)
(cherry picked from commit f448ad63ca5d317526e923c2363c3f05a44a0068)
(cherry picked from commit 4037ac989aa2942bdde46538b8b9856a9bfd3d78)
2026-11-10 02:59:19 -08:00
Anees Iqbal af1dd85b66 Blend-source notes state their bound and the device compiler's regrouping; padded rows on the 5080 and the Iris Xe
ExtendedRangeBlendSource and ExtendedRangeFloatBlendSource (their docs, the API
catalogue entries and the FAST-PATHS device-gap row) now say what the suite
measured: the device's compiler may contract and regroup the in-shader blend
(MoltenVK on the M3 Max and NVIDIA's driver on the RTX 5080 compute
S·F + D·(1 - F) as D + F·(S - D)); a stored channel lands within two codes of
Metal's on a linear format and within six near zero on an sRGB twin; and where
the compiler regroups a padded format's blend, an infinite second source stores
an end code where Metal's sum is NaN, stored as 0. The FAST-PATHS row names the
padded formats, which it lacked, and no longer says 'not measured'.

known-gaps.tsv: the 168 extended-range rows (xr-blend, xr-gamut, xr-gradient,
xr-masked) whose Open item was the blend notes' documentation are closed (Open:
nothing, the recorded bound covering the difference); every one is within the
bound (survey of the rows' largest differences). The padded-blend rows are
regenerated for five venues: the M3 Max, RADV PHOENIX and llvmpipe as before,
and the RTX 5080 (b5080 entry xrblend2-padded-replay-5080) and the Iris Xe
(job m3-max-13386), 17 each. The 5080's second-source cases differ by the whole
code range as the M3's do, and its counts are exactly a model of
D + a·(S - D) over an unnarrowed float destination (971 on R10Unorm_X6, 1850 on
RG10Unorm_X12); the Iris's are exactly the sum as written over the half
destination (844, 1607), as RADV's; llvmpipe's the sum as written over a float
destination (962, 1831). No venue's largest difference exceeds the M3's, the
780M's or llvmpipe's.

engine_padded_blends: a fetch of a padded attachment makes the whole pipeline
on every committed profile that orders fetch (storage form or input
attachment) and names the device gap elsewhere; a bfloat fetch stays
NotImplemented(Format), the negative control. Not yet run.

(cherry picked from commit c923b6d49c36c8354f375f6dababfd5f81f1ffbc)
(cherry picked from commit e3a2b226d7f5938811d1d251172088baf05c15cb)
(cherry picked from commit 85a2473cc6ea6a2c9165e2614d1e87ca77c1627e)
2026-11-10 02:59:18 -08:00
Anees Iqbal 962aa365dd FAST-PATHS: the fill decision's evidence on um870 and gem10
The fill row gains the decision's measurements: the images arm of
tests::reclaim_submit_bench, two runs each of the base (every block filled),
the decision (cf5561bb5d) and the arm with no fill, interleaved, the TTM
page pools emptied through the shrinker's debugfs before each arm and before
its pressed phase.

um870 (RADV, Mesa 26.2.6, Linux 7.3.1-1-cachyos), pressed, base / decision /
no fill: turnarounds of 8 ms or more 19 and 4 / 5 and 11 / 11 and 17, of
17 ms or more 1 and 1 / 1 and 2 / 8 and 9; the ready thread's makings 419
and 461 / 379 and 343 / 494 and 292 ms, in compaction 269 and 299 / 215 and
203 / 374 and 179 ms; block-sized buffer objects 2.0 / 2.0 and 1.5 / 1.0 a
making. Quiet: the decision filled every block (1 miss alone in 26) with no
turnaround of 8 ms or more; no fill had 12 a run. gem10 (quiet in both
phases): the decision made no block plain, no turnaround of 8 ms or more.

Also: the misses' free times (17 of 18 quiet misses freed in 0.06 to
0.20 ms, the pages left to the kernel's deferred delete; 44 of 47 pressed
ones in 2.7 ms or more), the fill's CPU shares (91 to 99% and 85 to 100%),
the page-table buffer objects a fill's mapping adds, and the block_fills
misses as now measured (0 or 1 of 5).

(cherry picked from commit 58bff1328f25ca7f96f4c82bab23d46ff5a40b1b)
2026-11-10 02:11:07 -08:00
Anees Iqbal 15c596f09a Memory: a device stops its fills once 3 of its last 4 missed
On gem10's 780M, quiet (12 GiB of free memory left beside the bench), a
tip of 2 of the last 4 stopped once: two fills in a row whose frees
returned in 0.14 and 0.17 ms, the pages left to the kernel's deferred
delete, each block then filling its own (8.0 and 10.9 ms); the 2 plain
makings that followed held the submissions 10.0 ms. Of the misses the
benches' quiet phases saw on um870 and gem10, 14 of 15 had such a fast
free; of those under um870's pressed phase, 30 of 33 freed in 2.7 ms or
more, in runs of up to 6.

Replayed over the always-filling base's phases, stopping at 3 of the last 4
fills 6 to 8 of 12 under um870's pressure (2 of 4: 5 to 7) and none on a
quiet host.

Verified so far: the CPU test is rewritten for the threshold; its run and
the device evidence follow.

(cherry picked from commit cf5561bb5d95b659debfeeedc3454188cda701b3)
2026-11-10 02:11:07 -08:00
Anees Iqbal 09e4afdba6 Memory: a device stops its fills once 2 of its last 4 missed, not after a lone miss
On um870's 780M (pools emptied before each arm and again before its
pressed phase), a quiet phase's fills missed alone: 1 of 13 and 1 of 5 in
the always-filling base, each the fill's free returning in 0.06 to 0.15 ms
where a free that hands its pages to the kernel's pool takes 2.7 to 3.5 ms,
so that the block's allocation ran before the pages were back. Backing off
after each such miss (837c461b2b) made the next 2 makings plain on the
quiet host, each holding the submissions 9.0 to 9.6 ms: 3 turnarounds of
8 ms or more in a quiet phase where the base had none.

Now a device keeps the outcomes of its last 4 fills (FILL_RECENT) and
stops filling once 2 of them missed (FILL_STOP_MISSES); the backoff after
that is as before (2, doubling with each missed probe up to 32), and a
probe that saves clears the record. Misses under pressure come together
(the same base, pressed: 8 of 12 and 3 of 12, runs of up to 5).

Verified so far: the rule's CPU test is rewritten for it
(tests::memory::fills_stop_once_two_of_the_last_four_miss_and_a_saved_probe_brings_them_back);
its run and the device evidence follow.

(cherry picked from commit bc3338dee50f9627b799cf68c747bef1b36a4672)
2026-11-10 02:11:07 -08:00
Anees Iqbal 261af18a27 Memory: after a fill misses, a device makes its next plain blocks plain, probing with backoff
The fill rule of 6da2c8c1dc kept a device filling while each fill spared
its block's allocation half its time, so on a host short of free memory it
kept making a second block-sized allocation for each block, the kernel
compacting and reclaiming for both: the consumer's scroll on um870's 780M
(pin 33) waited longer on host compaction than pin 30 did, with no fill.

Now a fill that missed (its block's own allocation took 1 ms or more,
FILL_SAVED_BELOW, as WorkCounts::plain_block_fills_missed counts) leaves the
next 2 makings plain, then fills one, a probe; each further miss in a row
doubles the plain makings between probes, up to 32; a probe that saves
brings filling back for every making (Fills, FILL_BACKOFF_FIRST,
FILL_BACKOFF_MOST). The module docs, the skipped count's docs and the
ledger row say the rule.

Verified so far: tests::memory::fills_back_off_after_a_miss_and_a_saved_probe_brings_them_back
is the rule's CPU test (not yet run: the build is next). Device evidence
follows in a later commit.

(cherry picked from commit 837c461b2b1aa716622237afc48870307282dbf8)
2026-11-10 02:11:07 -08:00
Anees Iqbal e5fffbf611 Known gaps: the padded-blend cases on lavapipe
Seventeen rows for the 256-bit llvmpipe venue, the counts its replay printed at
31d3ac25a2 (job m3-max-13288). lavapipe computes the second-source blend as
written with a product fused into the sum (native-fma), so an infinite second
source's NaN stores code 0 as Metal's does and no linear element is more than two
codes from Metal's.

CONFORMANCE-COVERAGE.md regenerated for the ledger's row count.

(cherry picked from commit 37237c7c805a19a814c809d13a1b2c196fd148b2)
2026-11-10 01:36:16 -08:00
Anees Iqbal 54e0d91b2c Known gaps: the padded-blend cases on the M3 Max and RADV PHOENIX
Seventeen rows per venue, the counts the replays printed at 31d3ac25a2 (M3 under
MoltenVK, job m3-max-13278; the 780M under RADV, job m3-max-13289). Each blend runs
in the shader in the device's arithmetic, unclamped, and lands a code or two from
Metal's on a linear format, up to six near zero on an sRGB twin. The second-source
blends differ by venue: the M3's compiler computes S·a + D·(1 - a) as D + a·(S - D),
so an infinite second source stores an end code where Metal's IEEE sum is NaN,
stored as 0; RADV computes the sum as written and stores 0. A model of each form
reproduces the replay's count exactly on R10Unorm_X6 and RG10Unorm_X12.

CONFORMANCE-COVERAGE.md regenerated (the new case module, its recordings and rows).

(cherry picked from commit e117b085632700b586e56d043b91b16b2365a524)
2026-11-10 01:35:57 -08:00
Anees Iqbal 880b03cb2b Blend into a padded attachment over unclamped operands; padded tiles announced
Measured on the M3 Max under macOS 27.0.1 (probes/padded_and_bfloat_blends.m,
targets without Metal's optimized layout, whose blits moved every texel):
- Metal clamps nothing before a blend into a padded attachment (R10Unorm_X6,
  RG10Unorm_X12, their sRGB twins, RGB10A2Unorm_sRGB): sources, second
  sources and blend colors past both ends of [0, 1], alpha among them, blend
  as they are. With the operands unclamped, the stored codes of 18 blend states
  under fast and safe math, half and float outputs, match the f32 model within
  one code for the linear forms (16-bit safe-math half outputs exactly in half
  arithmetic), apart from NaN and infinity results; clamped to [0, 1], up to
  1023 codes off in 30-50% of channels.
- A padded attachment's tile holds half through the pass: a premultiplied blend
  of (0, 0, 0, 0.5) over a clear of 0.33371 stored code 171 (the half's), not
  170 (code 341's), and over an unblended draw of values in [-0.5, 1.5] it
  matched the unclamped half in every channel (65,536 texels of R10Unorm_X6,
  131,072 channels of RG10Unorm_X12).

So blend::extended_ranges is None for a padded form (native() clamps nothing),
source_range drops its padded arm, and the model test clamps no padded lane:
every_blend_is_the_devices_arithmetic's random sources past the range fail it
with the clamp. The runtime's extended-range-blends-stored-codes now covers
padded colors (render.rs extended_colors), and ExtendedRange::clear_read_back
answers a padded form's clear by its codes' values (c / 1023, the sRGB twins'
transfer, RG10Unorm_X12_sRGB linear), so a blend over a clear between two codes
is announced as for the extended-range forms. Docs: the blend-source notes, the
stored-codes kind and its catalogue entry, ExtendedRangeColor.

(cherry picked from commit 5750641750642bdb7800da8e9618f98919d2cc9f)
2026-11-10 01:35:19 -08:00
Anees Iqbal 17cf2bf636 Bfloat blend refusal: tests, docs, refusal surface; SEMANTICS 2012
The translator test of bfloat targets expects Metal's pipeline error for a
blended bfloat attachment, in the translation and at link with no fragment
function, with the unblended unwritten pipeline as its negative control. A new
engine test (engine_padded_blends) checks the same on every committed profile
through compile_render_pipeline, under a full mask and a mask of no channel, and
without a fragment function, with the unblended pipeline made as its control.

Docs: stage_io::extended_color, input_blend, ExtendedRangeColor::blended (any
blend now, not factors one and zero), DescriptorError::ColorAttachment (a
blended bfloat attachment). docs/REFUSALS.md regenerated. SEMANTICS_VERSION
2012 (a refusal's class changed, padded blends translate). A clippy literal in
extended_range's tests grouped.

(cherry picked from commit 8ef001f0a0eeed4c1b51a31df2ae093285dfbe9c)
2026-11-10 01:35:19 -08:00
Anees Iqbal 848c072b8f CONFORMANCE-COVERAGE.md with read_through's ledger rows
Regenerated by scripts/conformance-coverage/coverage.py after the 96 llvmpipe
rows and the three read_through gap rows: 3410 ledger rows.

Verified: the conformance suite on msi (job m3-max-13292) failed only
the_conformance_coverage_document_is_what_the_sources_derive before this.

(cherry picked from commit 3514ac3e7a91a8245325939db06bbec5e950a63a)
2026-11-10 01:30:12 -08:00
Anees Iqbal 0fcb724d2c CONFORMANCE-COVERAGE.md with the read_through family
Regenerated by scripts/conformance-coverage/coverage.py: 13 more recordings,
162 case modules, three ledger rows, and read_through among the families that
compare MTLSamplerState and the texture and buffer items it calls.

Verified: coverage.py --check reported the doc stale before and is the
generator's output now.

(cherry picked from commit b2b166a2d4b03ed957824bc8290b214d4c78c66b)
2026-11-10 01:30:11 -08:00
Anees Iqbal 34310d93f7 Reads through a sampler: a texture buffer's border by its t axis, the ledger rows
The read_through conformance family's per-axis states, recorded on the M3 Max,
show a texture buffer's index past its end addressed as the first texel of a
row past its one row: the border texel where t's mode is a border mode, else
texel 0, whatever s and r are; a runtime sampler whose s mode is
clamp_to_edge clamps it first (s-border reads texel 0, st-border the border,
tr-border clamps). The read took s's mode, which read the border for s-border,
sr-border, s-zero and three mixed states. The border now follows t, and never
applies where the sampler clamps.

The retaken buffer recording; known-gaps rows for the argument-buffer
texture's swizzled transparent border (divergent) and its opaque-border and
runtime-sampler reads (refused), with the swizzle gap in FAST-PATHS.md's known
gaps; the module docs say both.

Verified: the replay on the M3 through MoltenVK (job m3-max-13263) named the
six buffer divergences this fixes; the fix's replay is next.

(cherry picked from commit 22c6817d4074c1b18bbc7c6d166370fe9990c1a5)
2026-11-10 01:30:11 -08:00
Anees Iqbal 5b24698068 SEMANTICS 2012, ARTIFACT_FORMAT 499, REFUSALS.md and the API signatures for reads through a sampler
What: SEMANTICS_VERSION 2011 -> 2012: reads through a sampler other than constexpr
clamp_to_edge now translate (they were refused), a clamp-to-edge read past its level or layer
reads zero in every lane, and a texture buffer's index outside a constexpr clamp_to_edge reads
its first texel. ARTIFACT_FORMAT_VERSION 498 -> 499: SpecKey::BorderTexels and
RuntimeFact::BorderTexels are encoded variants. docs/REFUSALS.md regenerated
(refusal_surface.py): select_through's two sites. api_signatures.tsv blessed:
SpecKey::BorderTexels, RuntimeFact::BorderTexels and SamplerWord::READ_STATE are added; nothing
is removed or changed.

Why: the translation's output changed under unchanged keys, and the encoding gained two variants.

Verified: refusal_surface.py wrote the doc with 0 unmarked variants; signatures.py --bless
reported only those three additions; METAL-COVERAGE.md --check is current.

(cherry picked from commit 26c37d74d6d2a4bb395ff64a539eb7fc617619bd)
2026-11-10 01:30:11 -08:00
Anees Iqbal ac0ffe1c25 Probe measurements and the API guide for reads dead after specialization
dead_ordered_and_unattached_reads.m records what it measured on the M3
Max under macOS 27.0.1 (potluck job m3-max-13241): dfr_color,
dfr_buffer and dfr_output are made and drawn, dead and live, every texel
the closed form's, with the debug layer silent; dfr_lacks has no state,
dead and live ('Shaders reads from a color attachment whose pixel format
is MTLPixelFormatInvalid'). Its header names the tests and the lane that
read it.

docs/API.md's color-group refusal list now names a raster order group on
a color output or on a parameter the function uses; one on a parameter
it never uses orders nothing and is not refused.

(cherry picked from commit 93aaa9c6685770db04032b710ec7b36950b56f89)
2026-11-10 00:55:27 -08:00
Anees Iqbal e51d85e18d API guide: a color input of another group is refused only where it is read
docs/API.md's color groups paragraph lists what each group's draw would
read from another group as the pipeline's limit refusal; a
[[color(n)]] input of another group is that only where the specialized
function reads it, as pipeline::compile::color_group::entry now decides.

(cherry picked from commit 1df7b9589dc6bda472d3faaa14bf432677647658)
2026-11-10 00:11:07 -08:00
Anees Iqbal c42e63e64b Record DevicePackConversion where a heap read decodes a raw-held texture
A float or half read, sample or gather through an argument buffer that
decodes a texture the heap holds by its raw texels alone (BGR10_XR,
BGRA10_XR, R10Unorm_X6, RG10Unorm_X12 and the bfloat formats; the
heap_raw routine) converts by the device's arithmetic, as a slot's decode
of the same texel does, but recorded no PrecisionNote: a reader of the
module alone saw no near-equivalent, against AGENTS.md's "allowed only
when the artifact records it".

The decode is planned in one place now, texture::heap_raw::plan, which
both the read (select_read_as) and the emulated sample or gather
(heap_raw_sample) call. It records DevicePackConversion as a specialized
note with one clause on a new bound-value key, SpecKey::HeapRawTextures
(stage): a texture the stage's handles can name is held raw. The binding
plan gives the key from the command's heap members (resident or bound
textures, as for HeapYCbCrTextures), so the note is in the module's
notes, holds under precision_notes_bound exactly where the command can
name such a texture, and the runtime announces it at that draw or
dispatch (degrade_bound_values) and never at the pipeline's making. A
stage that records the note outright for another conversion keeps it
outright. Heap accesses that reach no such texture (queries, integer
reads, storage reads, samples the function does not emulate) record
nothing.

NoteOn::HeapTextures is renamed HeapYCbCr beside the new HeapRaw.
bind::heap::raw_held is pub(crate) for the plan. The heap set's own
announcement naming the texture (heap_sets::RawRead) stays.

SEMANTICS_VERSION 2008 (heap-reading modules gain the note);
ARTIFACT_FORMAT_VERSION 498 (a SpecKey variant). api_signatures blessed;
REFUSALS.md regenerated (unchanged). docs/API.md's catalogue and the
runtime's Degradation docs say where the note is recorded and announced.

Tests: heap_decodes_record_the_device_pack_conversion now also asserts
the one HeapRawTextures clause; the new
a_heap_decode_s_note_holds_where_its_command_can_name_a_raw_texture checks
the plan's key and the bound note on every committed profile; the lane
a_heap_decode_s_stage_note_is_announced_where_its_command_can_name_a_raw_texture
checks the runtime's announcement under announce_each.

(cherry picked from commit 1ab403b671f18773a10c8572ffbe0a73b56f5bbc)
2026-11-09 23:54:15 -08:00
Anees Iqbal dbad32bb7b Docs: visibility venues, Metal's subnormal sample coordinates, a shared event's queue rule
Three corrections, each checked against the tree:

- runtime/src/visibility.rs said Metal's visibility-result behaviour was
  measured on an M4, which is not one of our venues. The conformance
  suite's visibility cases record Metal's answers on an Apple M3 Max with
  macOS 27.0.1 (recordings/visibility-*.json); the doc now names that venue.
  The 5300M and UHD 630 answers it cites beside it are unchanged.

- docs/FAST-PATHS.md's DeviceSampling row (and docs/API.md's device-sampling
  entry) said Metal reads any subnormal coordinate as the zero of its sign
  before addressing. That holds for a normalized coordinate (measured on the
  M3 Max on R32Float, PrecisionNote::DeviceSampling's documentation); a
  negative subnormal pixel coordinate addresses texel -1, as the M3 Max's
  recording of pixel-samplers-subnormal-border answers (the border at
  -2^-149, -2^-140 and -2^-127, known-gaps.tsv). Both now say so, and the 27
  known-gaps.tsv rows that quoted the old reading quote the new one.

- SharedEvent::reserve_vk_signal's Safety text lacked the same-VkQueue rule
  that Event::reserve_vk_signal states. A shared event's command-buffer waits
  are held on the host (event_timeline.rs: a settable timeline never hands
  a wait to Vulkan), but a command buffer that signals the event after the
  reservation waits on its VkQueue for the reserved index before its own
  signal (EventTimeline::signal's `after`, the order wait in
  command_buffer/submit.rs), so the caller's signalling submission must not
  go behind it on one VkQueue, and a texture copy on the first VkQueue behind
  it waits for the signal too. The rule is now stated, scoped to those
  signalling command buffers.

Verified: rustdoc and the runtime's degradation_catalogue test over the
edited text; no behaviour changes.

(cherry picked from commit 12bac3fafd3d3e66dc0b88d01231dd30e2694ffb)
2026-11-09 23:49:33 -08:00
Anees Iqbal ab10b3cbcf Runtime: say what a decoded twin's CPU decode makes replace_region wait for
The cpu-block-decode notice said the call waits for the decode where a
command buffer that may read the texture is submitted and not yet complete,
or the texture is untracked. The call has waited for no GPU work since the
decode moved to the device's decode thread (texture/twin_decode.rs): it waits
only for room, while 256 MiB of written blocks wait for the thread (a 4:2:2
carrier's partial-row write also reads its rows back first), and the
scheduler holds the first command buffer that may read the texture, every
command buffer where the texture is untracked.

The declaration's rustdoc, its announced cost and docs/API.md's catalogue
entry now say that. A test ties the stated bound to the queue's QUEUED_BYTES
(made pub(crate) for it), so the text follows the constant.

Verified: tests::degradation::the_cpu_block_decode_cost_states_the_calls_
only_wait and tests::degradation_catalogue (the catalogue states the cost).

(cherry picked from commit f128722f1b2197f52833080eca738fd498cf6ce5)
2026-11-09 23:49:33 -08:00
Anees Iqbal b1625c535c Translator: note a mesh function's point size only where it outputs points
A mesh function that writes a vertex's point size recorded
PrecisionNote::DevicePointSize whatever primitive its mesh outputs. The
rasterizer reads a vertex's size for points alone, so a line or triangle
mesh's size draws nothing on any device, and the runtime already announces
the note only at draws that rasterize points (7715a47be3). The note is now
recorded only where the mesh type's topology (air.mesh_type_info) is points,
a structural test, so the artifact carries no note its draws can never meet.

Apple's compiler refuses [[point_size]] in a triangle mesh's vertex, so the
case arises only for AIR not compiled from MSL. The test derives the
triangle mesh from the owned fixture's point mesh (mesh_outputs_points) by
its topology word alone.

SEMANTICS_VERSION 2008: an artifact's precision notes change. docs/API.md's
catalogue entry and the note's rustdoc say which mesh functions record it.

Verified: engine_mesh::a_mesh_point_size_is_noted_only_where_the_mesh_
outputs_points on every committed mesh profile with the largest point set
below Metal's: the point mesh is noted, the triangle mesh is not, both store
the size; the test fails with the topology check reverted.

(cherry picked from commit adc0435c64495e2f3a3355becf055941fc529fc3)
2026-11-09 23:49:33 -08:00
Anees Iqbal 05a31354c1 Spares: hold at most 4,096 command buffers, the pools out of them counted
A command buffer keeps what its recording took of the driver's device-wide pools until it is
begun again, reset or freed, and the spare command pools kept each pool's peak over its recent
uses with no bound across pools. On ANV below Xe-HP each command buffer that records a binding
table takes a 64 KiB block of the device's 1 GiB binding-table pool, so a device holds at most
16,384 of them, and the next recording fails with VK_ERROR_OUT_OF_DEVICE_MEMORY with no driver
message. tests::linear_runs::checked_frames_merge_once failed so on ms01's Iris Xe (6 of 79 runs
beside the runtime suite, job m3-max-13027): its frames of 707 and 1,413 render passes, each a
command buffer whose pool kept its peak, left the spares holding 9,716 to 9,771 command buffers
in every failed run (2,786 to 7,747 in sampled passing runs) before the frame that failed. A
probe on the same Iris Xe (job m3-max-13053, twice): one command buffer of render passes, each
a primary and a secondary beside a cleared depth target, failed at the end of its 8,087th pass
with the spares holding 424, 2 x 8,086 + 212 = 16,384.

A give-back now counts the spares, the pool given back, and what each pool out of the spares
held as it went out (taken by a command buffer, out for frees, or beginning a primary ahead:
CommandPools::out, kept under the spares' lock). Past HELD (4,096) the oldest spares that hold
any shed all their command buffers on the free thread as an idle spare does and go back as the
oldest; where that is not enough, the pool given back frees its last made past the bound, a
secondary kept, never the primary begun ahead (past_held, CommandPool::past). On ANV the frees
do not trim, as before, so kept barriers stay valid. HELD leaves three quarters of the binding-
table pool to the command buffers committed and in recording.

Tests: tests::spares::the_spares_and_a_pool_given_back_hold_at_most_held_command_buffers (the
policy, no device) and tests::spares::device::
command_buffers_alive_at_once_leave_the_spares_holding_at_most_held (three command buffers of
2,112 blit encoders alive at once, each in a pool of its own). docs/FAST-PATHS.md records the
remaining ceiling: one command buffer of about 8,000 such passes still fails on ANV below Xe-HP.

Verification follows in the next commits' messages and the report: build and clippy, the
spares tests on lavapipe, the M3 and the Iris Xe with a negative control, and a loaded Iris run.

(cherry picked from commit 8ab6915d698cdaf29e2aa8bfd50c77cd8922d507)
2026-11-09 23:18:09 -08:00
Anees Iqbal c120cdf105 Docs: the fill misses often, not mostly, in a process that submits nothing
tests::block_fills on the Radeon 780M (RADV PHOENIX, Mesa 26.2.6) missed 4 of its 5 fills in job
12841 and 2 of 5 in job 12891 (at the rebased tree of this branch); the fill row said "mostly"
from the first run alone. Documentation only.

(cherry picked from commit caa2b45263277b2696184602298e329291c8b5dd)
2026-11-09 20:49:31 -08:00
Anees Iqbal ee0b8af622 Docs: the fill row's fragmented phases at 68 MiB blocks of images, 0 to 4 and 0 to 2
The row said a fragmented phase had 1 to 4 turnarounds of 8 ms or more and 1 or 2 missed fills;
job 12852's second run of the bursts arm had neither (0 and 0), so the ranges are 0 to 4 and 0 to
2. Documentation only.

(cherry picked from commit e20985fc7ff241c40edcd55b3c21506b715bb899)
2026-11-09 20:49:31 -08:00
Anees Iqbal 6f4f45f1a8 Docs: the fill with 68 MiB blocks of images, measured; its misses where nothing is submitted
The fill row's numbers were of 64 MiB blocks of images. With the 68 MiB ones made now, on the
Radeon 780M (RADV PHOENIX, Mesa 26.2.6), the kernel's page pools drained before each run, the
reclaim bench's arms (jobs 12852, two runs, and 12860, one run with the fill-window print): a
quiet phase 0 or 1 turnarounds of 8 ms or more, no fill missed, the makings' vkAllocateMemory
1.2 to 2.0 ms in all; a fragmented phase 1 to 4 (the slowest 33.1 ms, behind a missed block
whose allocation took 29.4 ms), 1 or 2 of its 12 or 13 fills missed. Of the 957 submissions
begun while a fill ran (12860), 1 turned around in 8 ms or more (14.0 ms, fragmented); in 12852
a 24.0 ms one began within a 32 ms fill on the fragmented host. The row also says that in a
process that submits nothing the fill mostly misses (tests::block_fills on the 780M, job 12841:
of 5 fills, 1 saved and 4 missed), the cause not measured, and the fill's cost for a 68 MiB
block (about 16 ms on the quiet host, at most 17.3 ms).

(cherry picked from commit 30108c53759b9f76e25c0994e7db3cd4f7de7731)
2026-11-09 20:49:30 -08:00
Anees Iqbal 314263e447 Docs: the 2048x2048 packing measured, the slack's reason; the fill's other devices by the test
Verified at the tree of "Memory: pooled blocks stay 64 MiB, 68 MiB for images" (job 12840 on
ms01, the Iris Xe; job 12841 on gem10, the 780M) and at that of "Memory: a block's making time is
the tests' alone" (job 12851 on ms01, the Iris Xe and lavapipe):
- tests::blocks_ahead::a_block_of_images_holds_four_textures_of_a_quarter_block_each passes on
  the Radeon 780M (RADV PHOENIX, Mesa 26.2.6; 12841), on the Iris Xe (ANV; 12840 and 12851) and
  on lavapipe (12851): eight RGBA8Unorm textures of 2048x2048 lie in 2 blocks of 68 MiB. Each
  took 16842752 bytes at an alignment of 65536 on the 780M and the Iris Xe, 16777216 at 64 on
  lavapipe. With the slack taken out (a negative control, image blocks of 64 MiB), the test fails
  on the 780M (12841) and the Iris Xe (12840): the eight lie in 3 blocks. So the sixteenth stays,
  for images.
- tests::block_fills passes on all three: the 780M fills every block of images first (types
  0x15864: of 3 blocks of images, 5 plain blocks filled first, 1 made under 1 ms and 4 not, in a
  process that submits nothing; 12841); the Iris Xe and lavapipe fill none (types 0x0, 0 fills;
  12851).
- The memory, blocks_ahead, zeroed_start, clip_bursts, exported and freed memory,
  device_recovery and host_copy tests pass on the 780M (51 of 51; 12841) and the Iris Xe (51 of
  51; 12840); blocks_ahead and block_fills on the Iris Xe (8 of 8; 12851), and blocks_ahead,
  block_fills and memory on lavapipe under --cfg m2v_cpu_icd (27 of 27; 12851).
- clippy with no cfg, with --cfg m2v_gpu and with --cfg m2v_cpu_icd, the runtime's Rustdoc, the
  API signatures and the driver-fact tests (9 of 9): clean (12851). The conformance crate's suite:
  1029 of 1029 (12840).

(cherry picked from commit 458aa4a23c3359cc6b44f01812d53a88260f29ba)
2026-11-09 20:49:30 -08:00
Anees Iqbal 930e3aa49e Memory: pooled blocks stay 64 MiB, 68 MiB for images; the making-rate rule goes
The rule that made a device's later pooled blocks of plain memory smaller once a making took
longer than 8 ms (MAKING_BOUND, MIN_PLAIN_BLOCK_BYTES, Memory::plain_block_made) is removed,
with what existed only for it: placements larger than a pool's small blocks taking blocks of
their own power of two (pooled_block_bytes, Pool::large, took_large), the block's worth of small
blocks kept ahead (ahead_sizes' count), the call's upper bound on the blocks it takes
(ready::Need's most; a call now takes a block of its least bytes or more), and nearness by the
largest block a pool holds (Pool::ahead_room). Every pool's blocks are one size: 64 MiB, or the
device's largest allocation, and a pool of images' 68 MiB, a sixteenth besides
(IMAGE_BLOCK_SLACK, formerly PLAIN_BLOCK_SLACK, now on images alone): a driver's image takes more
than its texels, so that four images of a quarter of a block fit in one.

The hold that rule shortened is taken away by the exportable fill of the commit before, where
the driver holds submissions in plain makings, with the blocks kept at 64 MiB: the 17 MiB blocks
made 45 to 55 makings a phase on the 780M against 13 to 15, holding 138 to 230 ms against 125 to
201 ms, and put every texture past 17 MiB in a block of its own (docs/FAST-PATHS.md).

Tests: tests::plain_blocks goes; blocks_ahead's small-blocks tests go (the reserve of four small
blocks, the large placements' block, the mixed-sizes run made smaller partway); its packing test
now packs four RGBA8Unorm textures of 2048x2048 (a quarter of 64 MiB) to a block of images;
the first-block test runs on 64 MiB blocks. A new device test, tests::block_fills, holds that a
device with DriverFact::PlainAllocationsHoldSubmissions fills every block of images it makes
exportable first, counted, and that a device without it fills none. The reclaim bench's
small-blocks arms go. The conformance cost gate gates device_memory_allocated again (the
BLOCK_SIZE reason goes): block sizes no longer follow how long earlier makings took.

docs/FAST-PATHS.md: the RADV plain-blocks row is rewritten (blocks stay 64 MiB, the hold
measured), a row for the fill is added (its kernel dependency, its counters, the 780M A/B and
its cost), and the NVIDIA memory-block row says one block is kept ahead.

Verified: not yet compiled; the clippy, Rustdoc and device runs follow.

(cherry picked from commit 2cc9b21cb99b3fa7ac3b4199ae2aca88a99e014e)
2026-11-09 20:49:29 -08:00
Anees Iqbal 25401533b9 Docs: a fast-math NaN constant beside a run value stores the NaN; the fold's wording
API.md, section 10, Function constants: an fadd, fsub, fmul or fdiv under
nnan whose operand is a function constant bound to a NaN is poison in the
AIR. The translation answers the NaN operand unchanged, as it does without
fast math, where that NaN is Metal's answer. On the M3 Max, Metal drops a
kernel's store of it.

Measured in job m3-max-12877 with case 2d9a7e3091e1f9d9..., which is the
fixture sfold_fast_poison in a scratch corpus:
- Metal on apple-m3-max-macos27.0.1 left every poison row's float and
  half store at the 0xCD fill, and wrote the run-value row.
- MoltenVK with the folds wrote the NaN operand unchanged in every poison
  row (ffc12345, 7f800321, fd21).
- MoltenVK with the base translator dropped the float rows, and wrote ff21
  and 0 in the half rows.
The case is not committed: the corpus compares exactly.

ARCHITECTURE.md: the canon row now says a NaN operand is as it is beside a
value the run computes, and quieted where every operand is a constant.

(cherry picked from commit cddef968a3a8a971341fafcc5469e141fb97b434)
2026-11-09 20:44:24 -08:00
Anees Iqbal f12af61da9 ARCHITECTURE: SCCP's float folds in the canonicalization summary
The canon row names what SCCP settles; it now names the float operations a constant operand
decides (a NaN operand, the first in order, quieted; a product by a zero under nnan and nsz).

(cherry picked from commit f6b2db494f2aabdb2a875c5a49651abc2e28803b)
2026-11-09 20:44:23 -08:00
Anees Iqbal b83d35f35a Clear reach: a pass without a draw call clears before itself where its own clear would overreach
On MoltenVK, a pass's own Clear load in a pass without a draw call reaches
the whole attachment. Where the reach is the render area itself (an
uncompressed attachment whose render area ends on 32x32 tiles, now that only
a compressed one is cleared whole), the pass's own clear was used and reached
the whole 128x128 texture over a 64x64 area: lane fresh_clear_reach on the M3
Max (MoltenVK), 3 of 150 cases, BGRA8Unorm, RGBA16Float and RG16Float.

ReachClears now clears such a stored attachment before the pass by a render
pass of its own and the pass loads it (own_clear_overreaches: no draw call,
an attachment larger than the render area), color and depth/stencil alike.
The pass's render area stays Metal's, so a DontCare or Load attachment beside
it keeps its texels.

Docs: MacClass and docs/API.md cite arm64metal's tileclear2 jobs: the M3's
answer (m3-max-12716, 12735) and the x86 Macs' disagreement (5300M whole,
UHD 630 from the area to the whole texture: m3-max-12736, 12737), where the
runtime keeps the whole level, the 5300M's answer.

(cherry picked from commit ea34c273885ff00633c3afe983fdb3a7a398dd03)
2026-11-09 19:20:24 -08:00
Anees Iqbal 44e51b5081 Docs: how far a Clear reaches without a draw call, by the Mac class
MacClass and docs/API.md's accepted differences (the Mac a device presents)
state the answer: on a device presenting an Apple silicon Mac, a Clear load in
a pass of one layer without a draw call clears a compressed texture's whole
level and slice and any other texture's render area rounded up to 32x32
tiles; on one presenting a Mac with an Intel or AMD GPU, the whole level and
slice whatever the texture, unmeasured there and kept as it was. The lane's
clear_reach docs name the compressed textures their whole-level cases use.

Docs only; no behaviour change.

(cherry picked from commit 5591cc4b71a9458fef7a3773ed99d1bf0eeb1dcd)
2026-11-09 19:20:24 -08:00
Anees Iqbal f066aaf587 Blocks made ahead: a pool near its next block by three quarters of the largest block it holds
tests::blocks_ahead::mixed_sizes_find_their_blocks_made_ahead failed in
two of five runs of the memory tests on the Radeon 780M (gem10, jobs
12627 and 12669): "creation calls waited for a block of images at
textures [11]". In both, a slow making of the host's (the tests beside
it) made the device's blocks of plain memory smaller early in the run,
while its pool of images still filled its first block of 64 MiB, made
before. A pool that has not grown keeps its next block made ahead once
it is near it (Pool::near_next), which was measured by three quarters of
its blocks' size now: 12.75 MiB of a 17 MiB block (12 MiB of 16 MiB
before the blocks' sixteenth). The 64 MiB block had 12.4 MiB left, so
the pool kept none ahead, and texture 11 (2560 x 1440, 15,790,080 bytes
on RADV) found no room and waited for its block. Told of a slow making
before its fourth texture (a scratch of the test, job 12687) the 780M
waited at texture 11 in two runs of two; before its seventh or eleventh,
by which the pool had grown or was near its next block, in none.

A pool is now near its next block below three quarters of the largest of
its blocks' size and the pooled blocks it holds (Pool::ahead_room), so a
pool still filling a block made before its blocks were made smaller
keeps its next block ahead as it did for that block; the sweep of blocks
made ahead and unused reads the same measure. A pool whose blocks are
all of one size is unchanged.

New test: mixed_sizes_after_blocks_made_smaller_find_their_blocks_made_
ahead, the mixed run told of a slow making before its fourth texture.
memory/ready.rs and docs/FAST-PATHS.md's blocks-made-ahead row say the
measure.

Verified on the 780M (job 12692): the new test without this change
waited at texture 11 in three runs of three; with it, the memory tests
(66) pass in three runs of three, the new test with no wait (7 blocks of
images made ahead), and in one of them the existing mixed test's own
blocks made smaller at texture 15 by a slow making of the host's, with
no wait. The memory tests pass on the RX 550, lavapipe (job 12693) and
the Iris Xe (job 12694); clippy plain and under m2v_gpu and
m2v_cpu_icd, and the runtime's Rustdoc, clean.

(cherry picked from commit c3fd622421584dfcc0b34ca133dbae22f53203e6)
2026-11-09 17:52:06 -08:00
Anees Iqbal 6346da2609 Small blocks: a sixteenth besides the power of two, so four quarter-block images fit
A pooled block of plain memory made smaller after a slow making
(Memory::plain_block_made) was a power of two, 16 MiB at the least. A
driver's image takes more than its texels: a Private RGBA8Unorm texture
of 1024 x 1024, sampled and rendered to, is placed in 4,210,688 bytes on
a Radeon 780M (RADV PHOENIX) and an Iris Xe (ANV, RPL-P) and 4,210,712 on
an RX 550 (RADV POLARIS12), each at an alignment of 64 KiB, so the second
starts at 4 MiB and 64 KiB and a 16 MiB block holds three, not four
(lavapipe: 4,194,304 bytes at 64, four).

The blocks are now made of that power of two and a sixteenth of it
besides (PLAIN_BLOCK_SLACK): 17 MiB at the least, holding four images of
a quarter of the power of two with up to 256 KiB of metadata and
alignment each, two of a half with up to 512 KiB, one of the whole with
up to 1 MiB. plain_block_made picks the largest power of two whose block
with its sixteenth the slow making's rate makes within MAKING_BOUND, so
the 8 ms bound holds for the block as made (64 MiB in 16 ms: 16 MiB, not
32, as 34 MiB would pass it). A placement larger than such a block takes
the least power of two so made that holds it (a 20 MiB texture: 34 MiB).
Blocks of plain memory not made smaller keep their 64 MiB, and the
blocks of exportable buffers theirs. The reserve a pool keeps ahead is
as many of its blocks as come to a 64 MiB block or more (four of 17 MiB,
68 MiB), at least what it kept before.

Verified, tests::blocks_ahead::small_blocks_hold_four_textures_of_a_
quarter_block_each (16 such textures, one at a time, on a device told of
a slow making): before, 6 pooled blocks of 16 MiB held them on the 780M
and the RX 550 (failing, jobs 12602 and 12590); after, 4 blocks of 17 MiB
hold them on the 780M, the RX 550, the Iris Xe and lavapipe (a fifth
made ahead). The memory tests (blocks_ahead, plain_blocks, zeroed_start,
memory, clip_bursts, host_copy) pass on the RX 550, lavapipe and the
Iris Xe, and on the 780M but for mixed_sizes_find_their_blocks_made_
ahead in two runs of five: a wait older than the sixteenth, which the
branch's last commit fixes. Clippy plain and under both cfgs, and the
runtime's Rustdoc, clean.

tests::reclaim_submit_bench on the 780M (gem10, Mesa 26.2.6), the
small-blocks arms, pooled blocks made a phase before -> after (two runs
each, release):
- images, 1024 x 1024 one a frame: quiet 64 (1024 MiB) -> 48 (816 MiB),
  pressed 67 (1072 MiB) -> 51 (867 MiB);
- images of mixed sizes: quiet 36 (576 MiB) -> 30 (510 MiB), pressed 39
  (624 MiB) -> 33 (561 MiB);
- images in bursts: quiet 64 (1024 MiB) -> 48 (816 MiB), pressed 64-67
  (1024-1072 MiB) -> 51 (867 MiB); calls that waited for a block made
  ahead 23 -> 15 quiet, 20-23 -> 15 pressed.
The three blocks made ahead and freed unused in each pressed phase stay
(48 MiB -> 51 MiB).

docs/FAST-PATHS.md's known gap (blocks made smaller, down to 17 MiB) and
its blocks-made-ahead row change with it.

(cherry picked from commit 532d06c2359fb2756f5514ba2821f959cf48293b)
2026-11-09 17:52:06 -08:00
Anees Iqbal 40831926fd Blocks made ahead: the reserve counted in bytes with the pool's room, made again at large placements
The trigger of a pool's blocks made ahead skipped the pool while it had room for a whole block
(`ready_if_growing`'s `has_room(bytes)`). A call that takes a block from the reserve leaves the
pool a whole block of room and none made ahead, so nothing was made again until a later creation
call found the pool short of a whole block; by then the placements had taken the room, and the
next call that needed a block waited for a making it started itself. On an RX 550 (64 MiB
blocks, textures of 4, 14.1 and 31.6 MiB one at a time, every making ended between two) the call
after each 31.6 MiB texture waited so, at textures 8, 16 and 24 of 32 (job 12539,
`tests::blocks_ahead::mixed_sizes_find_their_blocks_made_ahead`, with made-ahead empty from
texture 6 on). On a Radeon 780M the bench's mixed arm waited for 8 and 6 of its blocks with
none hurried (job 12513).

- The reserve counts its own blocks in bytes together with the pool's room (`Memory::lacking`,
  the longest free range, `Pool::room`): none lacks while those made ahead and the room come to
  their worth (a block's worth, as before), and once they come to less, as many as bring those
  made ahead back to it. The trigger no longer skips a pool with room for a whole block: a pool
  that grew or is near its next block keeps what it lacks. The large block's rule is unchanged.
- A placement of a quarter of a block or more in a pool whose blocks are made ahead runs that
  trigger there and then (`ready_after_placing`, in `place`), not at the next creation call,
  which may need the block at once: a quarter of a block is the lead `ahead_room` gives the next
  block's making before the half block `keep_room` keeps, so such a placement can use it up in
  one step. (A threshold of half a block would miss the 31.6 MiB texture, just under half of
  64 MiB, and pooled placements are at most half a block.) Room is cached
  (`Pool::room`), so the check derives it where the next creation call would have.
- A call whose waited making ended without its block waits once more, on a making that counts
  it from its start (`take_ready`), before it makes the block itself. A thread ends so without a
  failure: a reserve making no call waited for as it began makes no block within the device's
  allocation margin (`Allocations::room_ahead`), and its ending drops the sizes queued behind
  it, the waiting call's among them. This is the hole the M3 cost records' selection-only image
  and buffer blocks made in place point to (not measured here).

Measured on a Radeon 780M (RADV PHOENIX, gem10, exclusive; job 12560, two runs each, the
reclaim bench's images arms; RT 1991 is development with the ready threads' rename):
- Mixed sizes, 64 MiB blocks: blocks waited for, quiet and pressed, RT 1991 8 and 6 in both runs
  (none hurried), with this change 0 and 0 in both. Slowest creation call in the pressed phase
  8.5 and 5.8 ms at RT 1991, 3.6 and 1.9 ms with it (RT 1987: 5.2 and 1.5 ms, with 8 and 6
  blocks of images made in place, none since). Blocks made, 13 and 14 a phase, unchanged.
- Bursts of 16 textures, 16 MiB blocks: waited for, quiet 24 and 25 at RT 1991, 20 and 21 with
  it; pressed 27 and 27, then 23 and 23; hurried 11 to 12 at both (RT 1987: 60 a phase).
- Images one a frame and mixed sizes on 16 MiB blocks, and the 64 MiB images and bursts arms:
  no wait at either, none in place, the same blocks made.
On an RX 550 the mixed-sizes test waited at textures 8, 16 and 24 without this change and at
none with it (job 12556); lavapipe, whose slow makings made its blocks 16 MiB, waits only at
texture 7, the first texture larger than its blocks.

The mixed-sizes test allows the one wait it should: where a device's slow makings made its
blocks of images smaller (lavapipe, 16 MiB), the first texture larger than them waits for a
block of its own size, which nothing foretold.

Work counts expected to move: blocks_ahead_waited_for down (the mixed and burst arms' waits on
makings started late become blocks made ahead and found ready); image/buffer_blocks_made_ahead
about the same in total, with makings started earlier; blocks_ahead_hurried down where those
makings would have been cut short; image/buffer_blocks_made_in_place down to 0 in the M3
selection where the room_ahead ending was the cause (expected, unmeasured). The bytes kept ahead
are bounded as before: a block's worth a pool, plus the large block.

(cherry picked from commit 384c96121f7fa1ff8dec80ccfbf98f401ab77a74)
2026-11-09 16:55:06 -08:00
Anees Iqbal f79bf9a144 Blocks made ahead: calls for a pool's own blocks leave its large block alone, and a taken block is waited for again
1. The large block kept ahead was not kept for the large placements. While a pool's placements
   past its 16 MiB blocks are recent, it keeps one 32 MiB block ahead (074d8e762e). But
   add_ready and the waits took the smallest made block of the needed size or more. So a burst of
   textures that ran through the pool's own 16 MiB blocks before their refill took the 32 MiB
   block too, and the next large placement waited for a new one. Shown at d562bd4148 by the new
   burst phase of tests::blocks_ahead (24 textures of 4 MiB back to back with a queue use held
   open): the burst took the 32 MiB block, nothing made ahead was left (lavapipe and the RX 550),
   and the pool ended with 5 and 6 blocks of 32 MiB against 4 large textures.

   Fix (memory.rs, memory/ready.rs): a call takes a block within a range (ready::Need). Below the
   pool's recent large size it takes no block of that size or more. The waits and the "will a
   block come" check use the same range. The pool's own blocks are kept at a full block's worth
   again (4 of 16 MiB), and the large block is kept besides them. Before, the large block was
   inside the 64 MiB but could already come on top of four small ones. So a pool of 16 MiB blocks
   with placements past 16 MiB in the last 10 s keeps up to 64 + 32 MiB ahead; every other pool
   keeps 64 MiB, as before 1984. ready.rs and FAST-PATHS' kept-blocks row say so.

2. A call that waited for a block made for it could still make one itself, if another call took
   that block first: take_ready then returned false and keep_room made the block in place. Now
   Waiter::wait says whether a fitting block was made, and take_ready waits again when one was
   but another call took it. Found by reading the path for the 5080's first-growth red at RT 1987.
   A call now makes a pool's block itself only where no making serves it: a host-copies placement
   while that pool's thread reads pages, a making that failed or a thread that did not start, or a
   placement before the device's first creation call.

3. The test placements_past_a_pool_s_small_blocks_find_a_block_of_their_size_made_ahead checked
   the device's count of waits, which also counts other pools' blocks. On the RX 550 (job 12498)
   it went red with the filtered suite running: 7 waits, 1 after the first 20 MiB texture. Alone,
   d562bd4148 passed 3 of 3 with the memory log on (job 12514): 5 waits, 0 after. It now reads the
   image pool's made blocks before each later 20 MiB texture, and it adds the burst phase.

Work counts expected to move against 074d8e762e: none in the cost cases. Their pools' blocks are
64 MiB and they place nothing past half a block, so the range is unbounded there and the reserve
is the same. Only a device whose blocks shrank and that places past them keeps the large block
ahead through a burst: fewer blocks_ahead_waited_for, and pooled_memory_blocks_made rises by the
small blocks the burst waits for instead of taking the large one.

(cherry picked from commit b38f14b41a45a152453358a9f6dd5459bf74f3cd)
2026-11-09 15:45:26 -08:00
Anees Iqbal 074d8e762e Blocks made ahead: a block's worth of bytes per pool, a block for large placements, and calls wait instead of making
The problem, from reims's pin 31 scroll round on um870's 780M. After slow makings, its plain
blocks were made at 16 MiB (RT 1984). Over two boots:
- 250 and 264 pooled blocks were made;
- 114 and 82 image blocks were made in place on the guest's threads;
- 110 and 159 blocks made ahead were waited for (91 and 122 hurried);
- direct compaction on guest threads took 833 and 306 ms.

Two causes:
- The ready thread kept one block ahead per pool. With 16 MiB blocks that is a quarter of the
  reserve that one 64 MiB block used to give. A call that found no block made and no making under
  way made its own.
- A placement larger than a 16 MiB block takes a 32 MiB block of its own size
  (pooled_block_bytes). No block made ahead could hold it, so it was always made in place.

What changed (memory/ready.rs, memory.rs):
- A pool keeps a block's worth of bytes ahead: as many of its blocks as one 64 MiB block holds
  (4 of 16 MiB).
- While the pool's placements larger than its blocks are recent (the last within
  KEPT_EMPTY_FOR), the reserve also holds one block of the largest such size. The pool's own
  blocks fill the rest of the 64 MiB (32 MiB + 2 x 16 MiB).
- One thread per pool makes them one after another, one vkAllocateMemory each, after a single
  wait for a burst's end. A block a call or a top-up queues while the thread runs joins its queue;
  a waiting call's block goes first.
- A call that finds no made block of the size it needs no longer makes one itself. It waits for
  the block being made or queued, or queues one first and waits. If the pool has no thread, it
  starts one. The waited block's pages are not read.
- The host copies' pool is now waited for too, except while its thread reads a block's pages
  (whose first touch may wait behind the program's GPU work). The waiter counts itself before it
  checks a reading flag; the thread sets the flag before it checks for waiters.
- A block is made in place only in these cases: a host-copies placement while that pool's thread
  reads pages; a making that failed or a thread that could not start; a placement before the
  device's first creation call.
- A placement over half of BLOCK_BYTES stays dedicated, as before.
- keep_room's per-pool step moves into keep_pool_room.

Resting cost (bytes kept ahead per pool, counted against the kept-blocks budget):
- Against pre-1984 (one 64 MiB block per growing or near-next pool): unchanged at 64 MiB.
- Against RT 1984 and RT 1987 (one block of the pool's size): unchanged for 64 MiB pools. A pool
  of 16 MiB blocks keeps up to 48 MiB more while it grows or is near its next block.
- At the device's first creation call, a pool of 16 MiB blocks also makes 3 blocks ahead after
  its first. If the pool never nears its next block they go after KEPT_EMPTY_FOR
  (blocks_ahead_unused). Pools of 64 MiB blocks, the default before any slow making, make none
  extra.

Work counts expected to move, for the cost records:
- buffer_blocks_made_in_place and image_blocks_made_in_place fall to 0, except in the cases above.
  That includes each kept pool's first block at a device's first creation call, which the call
  now waits for on the ready thread.
- buffer_blocks_made_ahead and image_blocks_made_ahead rise by as many. So does
  blocks_ahead_waited_for, since a call waited for each of them. These are not hurried: the
  making started at once for the call.
- host_copy_blocks_readied rises, and host_copy_blocks_made_in_place falls, where a host-copies
  placement found no making at all.
- pooled_memory_blocks_made is unchanged with 64 MiB blocks. With 16 MiB blocks the extra reserve
  blocks count there when added. When swept unused they count as blocks_ahead_unused and
  pooled_memory_blocks_freed.
- Kept-ahead bytes against the heap budget: a block's worth per pool, as above.

Docs: memory/ready.rs, memory.rs, the WorkCounts fields, and FAST-PATHS' kept-blocks row, which
now describes the 64 MiB reserve and the large block.

Tests (tests::blocks_ahead), on lavapipe under --cfg m2v_cpu_icd:
- a_pool_of_small_blocks_keeps_a_block_s_bytes_ahead_and_no_creation_call_makes_one: 16 MiB
  blocks, 4 MiB textures. 0 in place, 64 MiB kept ahead. The base fails it: 1 in place, 16 MiB
  ahead.
- placements_past_a_pool_s_small_blocks_find_a_block_of_their_size_made_ahead: a 20 MiB texture
  every 4. 0 in place, four 32 MiB blocks, 0 waits after the first 20 MiB texture. The base fails
  it: 5 in place, four of them 32 MiB.
- The memory, blocks_ahead, plain_blocks, zeroed_start, clip_bursts, exported/freed memory,
  device_recovery and host_copy tests passed, 78 of 78 (jobs 12486 and 12491).
- The 780M bench before and after (images, mixed and burst arms, fragmented) is running on gem10
  (job 12492). Its numbers go in the pin notes.

(cherry picked from commit 096241d0964536db875ab2957c64b40922e7fa8e)
2026-11-09 15:19:28 -08:00