Commit Graph
4389 Commits
Author SHA1 Message Date
Anees Iqbal 175fd330f6 Take back image_plan::view_candidate, committed with the test's removal by mistake
The previous commit swept in an unfinished function of the next change
(a texture's view form), which nothing calls yet: a dead-code warning.
image_plan.rs is again as the change clearing linear attachments in place
left it.
2026-11-12 03:03:40 -08:00
Anees Iqbal 46737dba6b Drop the forced-rule test of a cleared linear target: lavapipe counts it neither way
a_cleared_target_alone_renders_in_place counted the pass neither in place
nor through copies on lavapipe (job m3-max-20144: (0, 0)): there the device's
framebuffer fetch reads input attachments, so every color of a pass counts as
taken and linear_attachment::choose counts none of them, before the change as
after. It proved nothing on the device it was for. The lane test of a cleared
render target over a Shared buffer counts the pass on a device that renders it
by the rule, which is the proof.
2026-11-12 03:03:40 -08:00
Anees Iqbal 6b14f719d3 Clear a linear color attachment in place where the rule allows it
A pass that cleared a color attachment whose texture's image is linear and
which the device renders under VK_NV_linear_color_attachment, where the rule
allowed it in place, cleared an image its texture keeps and copied it back,
announced linear-attachment-clear-copies, because clearing a linear image of
host memory in place measured slower than that copy. A copy chosen for speed:
the owner's rule keeps a copy only where the device lacks the in-place form.
The pass now renders such an attachment in place whatever it loads.

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

Tests: the lane test of a pass clearing a render target over a Shared buffer
(now a_cleared_render_target_over_a_shared_buffer_renders_in_place) counts it
in place and through no copy on a device that renders it by the rule; the
runtime's a_cleared_target_alone_renders_in_place forces the rule (lavapipe
included) and counts 1 in place, 0 through copies, every texel the clear; it
counted 0 and 1 before.
2026-11-12 03:03:40 -08:00
Anees Iqbal a0c40c1182 Print a cleared linear render target's ways and GPU time at 1080p
The lane test of a pass clearing a render target over a Shared buffer now
also clears a 1920x1080 one, printing how many passes rendered it in place
and through copies and the median GPU time of seven, and checks the buffer
holds the clear. A record of the clear's cost before and after a change to
how it renders; it asserts nothing about the time.
2026-11-12 03:03:40 -08:00
Anees Iqbal c46497dc8b Re-pin the runtime sources at the landing tip
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.
2026-11-12 02:47:24 -08:00
Anees Iqbal d5d76912e9 The lowest level's test takes a NaN sampler bias as none, as the code does
the_lowest_level_follows_the_bound_sampler expected a NaN bias to give the first level, but
f32::min takes it as none (m3-max-20172 failed there): a bias of 3.0 with a NaN bias gives 3.
That is the device's answer too: no Vulkan sampler takes a NaN mipLodBias, and
metal::sampler::device_lod_bias makes it none. The test and the comment now say so.

Verified: built and run in the next job.
2026-11-12 02:46:14 -08:00
Anees Iqbal 6a951995e1 The lowest level a slot reads counts no size query: it reads no texel
What: LevelReads::lowest_read counted a size query at a constant level as a read of that level.
A sample's lowering queries the level-0 size for offsets, pixel coordinates and bias axes
(lower/sampler/emit.rs), so every such slot stated lowest_read 0 and no read past an attached
level could read in place: the lane and runtime tests of the past-level reads counted the slots
first-level or reaching (m3-max-20154, at 70b6b737e7 on lavapipe). A size query reads no texel,
and the view a narrowed slot binds keeps the texture's first level as its own, so it answers the
same at any level the view holds; the query still raises named, which keeps that level in the
view. Fetches and gathers read texels and still count.

Tests: level_reads::tests::each_read_states_the_levels_it_reaches (a size query at level 3:
named 3, lowest_read none). Verified: built and run in the next job.
2026-11-12 02:46:14 -08:00
Anees Iqbal d971205216 RUNTIME_VERSION 2101: a slot that reads only levels past the attached ones reads them in place
A draw that samples a texture its own pass renders at one level read the texture's copy unless
every read reached only levels before the lowest attached one. A slot every read of which
reaches only levels past the highest attached one (a pyramid pass that renders level m from
level m + 1, or through a sampler whose minLod lies past m) now binds the texture's own image
through a view of its levels from the first up to the highest it reads (all of them where the
sampler's maxLod reaches past the last), and names in its uses only those from the lowest it may
read (LevelReads::lowest_level, SampledLevels::lowest, through each bound sampler's levels, its
lodBias as the bind takes it included). The levels read hold the copy's texels: nothing the
instance does writes them, checked as the levels-before case checks (reads_levels_in_place,
shares_attachment, the unordered writes, the draw's own writes).

The view holds the attached levels too, unread. Vulkan's rules against reading an attachment are
of accesses (VUID-vkCmdDraw-None-10795; the Render Pass chapter's subresource "simultaneously
being used as an attachment"), and the descriptor's layout must match the subresources the view
holds (VUID-vkCmdDraw-imageLayout-00344): GENERAL, where every attachment rests. So such a slot
keeps its copy in an instance that holds one of the texture's attached colors in the feedback
loop layout, and the instance's general_colors (renamed from storage_colors, which now also
holds the colors such a view spans) sends a later snapshot read of one into another instance.

Counted as WorkCounts::attached_read_slots_past. The reasons a slot keeps its copy now test any
level before the first-level case, which covers only a read that may reach an attached level.

Tests: tests::attached_levels (runtime, the device cfgs) gains reads past the attached level;
runtime_lane::attached_levels (validation, under the layer) reads levels past the attached one in
a pass recorded inline, where the layer sees the attachment. Verified: built and run in the next
job, with a negative control.
2026-11-12 02:46:13 -08:00
Anees Iqbal 6ab2d18f04 LevelReads and SampledLevels state the lowest level a slot's reads may reach
A runtime that serves a draw's read of a texture its own pass renders can read the texture's own
image in place where every read reaches only levels past the highest attached one, but the fact
gave only the highest level read. It now gives the lowest too:

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

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

Tests: level_reads::tests::each_read_states_the_levels_it_reaches (each read's lowest, and a fetch
beside a level-count comparison: named 3, lowest 2), the_lowest_level_follows_the_bound_sampler,
constant_levels_of_detail_keep_their_lowest_and_a_nan_there. Verified: built and run in the next
job.
2026-11-12 02:46:13 -08:00
Anees Iqbal f8bfc1088b A NaN constant level of detail stays a sampler's highest whatever comes after it
What: level_reads kept the highest constant explicit level of detail through each sampler with
f32::max, which drops a NaN: a NaN followed by another constant (2.0, NaN, 1.0) left 2.0, so
SampledLevels::level answered the level of 2.0 where a NaN reads the sampler's maxLod, and a
runtime narrowing a slot to the levels before an attached one could read through too few levels.
Now a NaN stays (kept_nan).

SEMANTICS_VERSION 2040: an interface fact (SampledLevels::highest_lod_bits) changes for such a
module.

Test: level_reads::tests::constant_levels_of_detail_keep_a_nan (2.0, NaN, 1.0 keeps the NaN,
which reads level 3 at maxLod 3). Verified: built and run in the next job.
2026-11-12 02:46:13 -08:00
Anees Iqbal 8a585e7a76 Re-pin the runtime sources at the landing tip
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.
2026-11-12 02:05:54 -08:00
Anees Iqbal be443d0497 RUNTIME_VERSION 2100: a sampler state's lodBias moves the level on a device presenting an Intel or AMD Mac
The commit before this one. Real AMD (Radeon Pro 5300M) and Intel (UHD 630) Macs apply a sampler's lodBias,
clamp(LOD + bias, 0, levels), from explicit, gradient and implicit LOD alike; Apple9 ignores it. On a device
whose resolved Mac class (DeviceOptions::mac_class, else MacClass::of_vendor) is IntelOrAmd, the sampler's
mipLodBias is now the bias (SamplerUse::lod_bias, set at every runtime sampler bind); AppleSilicon keeps 0. A
bias past maxSamplerLodBias, a NaN bias, or a device withholding samplerMipLodBias (a portability subset) is
announced once by a new precision kind, capped-lod-bias, and never fails. New public translator items:
SamplerUse::lod_bias / with_lod_bias, metal::sampler::DeviceLodBias and device_lod_bias.

Verified on lavapipe (m3-max-20041): IntelOrAmd, 160 biased samples read the biased level (96 another than the
unbiased state's), kernel explicit level and fragment implicit level; AppleSilicon, 240 read the unbiased
level; capped-lod-bias announced once (bias 100, the device adds 16). Negative control (m3-max-20049): with
the bind dropping the flag, the IntelOrAmd lane test fails (0 against level 1). Lint three ways and rustdoc
(m3-max-20036, 20042). Not run: the M3 or MoltenVK (AppleSilicon default: unchanged).
2026-11-12 02:04:57 -08:00
Anees Iqbal 0709ba7ba5 A sampler state's lodBias moves the level on a device presenting an Intel or AMD Mac
What: vk_sampler set mipLodBias 0 whatever the descriptor's lodBias, read as
Apple9 (an Apple M3 Max samples every level as with no bias). The
consumer's oracle (an AMD Radeon Pro 5300M and an Intel UHD 630) shows a
Mac with an Intel or AMD GPU adds the bias to every sample's level,
explicit (level()), gradient and implicit alike, clamped into the
texture's levels. So a guest presenting such a Mac read the wrong level.

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

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

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

Tests: metal::sampler's a_lod_bias_is_the_device_s_where_the_use_adds_it
(every committed profile, both uses) and
the_device_lod_bias_is_the_bias_within_what_the_device_takes (exact,
capped finite and infinite, NaN, withheld on MoltenVK's profile);
tests::sampler takes the bias per class; the lane's lod_bias tests a
device presenting each class: AppleSilicon reads the unbiased level
(kernel explicit, fragment implicit), IntelOrAmd the biased one, the
capped ones announced once (CAPPED_LOD_BIAS, listed as a site).
Evidence: potluck jobs in the report to main.
2026-11-12 02:04:48 -08:00
Anees Iqbal 954bd4771e RUNTIME_VERSION 2099: a held pass's gated copy in begins no command buffer around it
Its run changes: a standing- or log-gated copy in deferred from a held pass is recorded into the
batch's scrub command buffer with no continuation begun around it, so
command_buffers_begun_continuations drops where a held pass meets one.

The commit before this one. Test: tests::image_standing::a_copy_in_after_an_attached_read_moves_what_its_pass_drew_alone
asserts command_buffers_begun_continuations 0 for the last pass's gated copy (was 2): 12 VkCommandBuffer begins
fewer per command buffer in the compositor shape over Private surfaces (cache mode).
2026-11-12 02:04:48 -08:00
Anees Iqbal c04a824a8b A held pass's gated copy in begins no command buffer around it
A shadow's copy in that its batch's submission decides (GatedCopyIn: a
shadow that may stand across command buffers, or one over host pages a
consumer logs) is recorded at submission in a VkCommandBuffer of its own,
behind a barrier from everything before it and before one to everything
after it. Before a render pass held for an instance recorded inline (an
attached read's copy, texture/attached_reads.rs), the encoder still did
two more things. It began a continuation to record its own barrier before
the copy, and it began another, eagerly, to go on in after the copy, which
then held only the run's trailing barrier. Both barriers repeat the
segment's own. So each such pass began two VkCommandBuffers that each held
one barrier. In the compositor shape over Private surfaces that is 12 per
command buffer, on the encoding thread (begin_command_buffer, 5.6% of it
in reims's profile on the Radeon 780M).

Now, where a pass is held in an encoder Metal leaves unordered, outside a
predicated loop's laying (EncoderCore::defers_apart), the copy is tracked
as before but nothing is recorded for it. The encoder goes on in a command
buffer begun only when a command records before the pass, and the run
goes on as after a barrier. Every other deferral is as it was.

Test: tests::image_standing::a_copy_in_after_an_attached_read_moves_what_its_pass_drew_alone
now asserts that the last pass's gated copy begins no continuation
(command_buffers_begun_continuations 0, was 2).
2026-11-12 02:04:39 -08:00
Anees Iqbal 11302667c3 Re-pin the runtime sources at the landing tip
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.
2026-11-12 01:56:25 -08:00
Anees Iqbal d4a2bad950 RUNTIME_VERSION 2098: a shadow made before its verdict moves in place with its usage shadow of the bytes
The commits before this one. A texture over host pages or pooled memory made before its in-place verdicts is a
shadow that moves in place at a quiet commit. Prepared::move_in refused the move for good wherever the texture
had a usage shadow (shadowed_again), and a draw that samples its own pass's attachment (an attached read) takes
one in its first command buffer: such a target stayed a shadow for the whole process, and over host pages each
command buffer copied back every texel its passes wrote (a compositor's whole 3840x2400 framebuffer). A usage
shadow of a texture over a buffer has the buffer's bytes as its truth (ShadowSource::Bytes), which is what the
in-place image is, so the move now keeps it; only a render shadow or a usage shadow of another truth blocks it.
The move still goes through move_in, so views_go runs on the old shadow before it may be freed; the kept usage
shadow is the texture's own and lives as long as it. On every device. Also: the draw_costs compositor bench
(the consumer's frame as a shape), and the pass-end tile count's sweep tried and reverted (0.4% at this pin).

Measured, Radeon 780M (RADV PHOENIX), exclusive, fresh shader cache (the check pending at first, as in a first
session), the compositor shape (m3-max-20002): moved in place 12 -> 17 of 18 pending (the 800x600 layer stays,
refused for its pitch); per command buffer shadow_texels_copied_back 9,216,000 -> 144,000, shadow_texels_kept
2,546,940 -> 304,002, copied in 6,207,444 -> 3,964,506; per draw 74,636 -> 68,504 instructions, CPU 32.1 ->
29.4 us; end_encoding 109,380 -> 67,027 instructions.

Test: tests::in_place_textures::a_texture_an_attached_read_copied_before_its_verdict_moves_in_place_too.
2026-11-12 01:55:28 -08:00
Anees Iqbal 4b3eb3b253 draw_costs: the compositor's plan walks its passes' sizes, as clippy asks 2026-11-12 01:55:19 -08:00
Anees Iqbal 2a485c9b9e A shadow made before its verdict moves in place with its usage shadow of the bytes
A texture over host pages (or the device's pooled memory) made before its
class's in-place verdict is a shadow that moves in place at a quiet commit
once the verdict passes. The move was refused for good where a binding or a
pass had taken a usage shadow of the texture. In a compositor's frame, a
draw that reads its own pass's color attachment at its own pixel (an
attached read) takes that usage shadow in the first command buffer. So
every target made before the verdict stayed a shadow for the process's
life. Over host pages, each command buffer then copied back every texel
that its passes wrote: on the Radeon 780M, the whole 3840x2400
framebuffer, 9.2M texels a command buffer, in reims's first session.

A usage shadow of a texture over a buffer holds the buffer's bytes as its
truth (ShadowSource::Bytes). An image in place over those bytes is the
same truth, and an aliasing image's uses are uses of those bytes. So such
a usage shadow serves the moved texture exactly as it serves one made in
place. Now only a render shadow, or a usage shadow of another truth, keeps
the texture a shadow (ShadowCopies::copies_bytes).

draw_costs' compositor shape now settles the in-place check after making
its surfaces. A run with a fresh shader cache then measures a first
session after its verdict.

Test: runtime_lane::in_place_textures::a_texture_an_attached_read_copied_before_its_verdict_moves_in_place_too.
2026-11-12 01:55:19 -08:00
Anees Iqbal 27bca2eeab draw_costs: a pass step's arm answers as the other steps' do 2026-11-12 01:55:19 -08:00
Anees Iqbal e74e1b70d9 draw_costs: the consumer's compositor frame as a shape, shadow lines on stderr
The consumer's per-draw table on the Radeon 780M measures a window compositor's command
buffer: five passes that load a layer's surface and draw 4 quads each, then a pass that clears
a 3840x2400 framebuffer surface and draws 15, every surface a texture over its own buffer's
IOSurface plane. Its draws cost about 12 us each and its pass ends about 39 us on that host,
against draw_costs's 1.9 us: its surfaces are shadows. draw_costs had no shape of it.

- compositor: 8 command buffers of that frame (6 passes, 35 draws, 21 indexed), each pass
  opened with set_viewport, each draw setting a pipeline state where its kind changes (plain,
  masked, backdrop; blended), two vertex buffers and a fragment buffer at moving slots of one
  no-copy buffer over host pages, one or two fragment textures (a backdrop draw reads its own
  pass's color attachment at the fragment's pixel), a sampler and a scissor rectangle. Surfaces
  over Private buffers, or with --pages over host pages.
- Steps: a Pass step opens a compositor pass (a command buffer of other steps opens the
  bench's one pass as before); fragment textures take an index; indexed draws; the calls
  set_viewport and draw_indexed_primitives counted apart with --calls.
- With METAL2VULKAN_LOG_SHADOWS=1 the sink prints the shadow log's lines and each degrade
  notice's text on stderr.
- draw_costs.metal: the compositor's quad functions, written for this example.

Verified: the build and the 780M run follow in the next jobs (the metallib is compiled on the
M3 Max).
2026-11-12 01:55:19 -08:00
Anees Iqbal 54c2f82432 Revert the pass-end tile count's sweep: count_colors and covered_tiles are 0.4% at this pin
reims's 780M encode-thread profile (m3-max-19824, cache mode) puts count_colors and DrawnArea::covered_tiles at 0.4% of the encoding thread together, so the sweep (e5f571166b) is not worth its code. On draw_costs damage --shadowed (500 rectangles a pass) it took 17,659 instructions a draw to 17,210 on the 780M (m3-max-19827); no shape the consumer runs has such passes.
2026-11-12 01:55:19 -08:00
Anees Iqbal d4d66d3f74 Pass-end tile count: one sweep down the rows, each rectangle looked at once
DrawnArea::covered_tiles (WorkCounts::shadow_attachment_tiles_covered, counted at each pass
end for a shadowed color loaded within its draws' scissors) walked every rectangle for every
band of tile rows between two rectangle edges: O(bands x rectangles), up to 2047 x 1024 at
MOST_RECTS, about 34 x N on a 1080p pass of N damaged rectangles. reims's 780M encode-thread
profile put count_colors / covered_tiles at ~6.4%.

Now each rectangle's tile columns enter a sweep at its first row of tiles and leave past its
last; a count per column of the rectangles reaching it and the number of columns any reaches
give each band's tiles at once: O(N log N + the rectangles' widths in tiles). The answer is
the same count (the existing brute-force comparison over 200 random sets holds it).

Test: clear_reach::tests::covered_tiles_look_at_each_rectangle_once counts the rectangles a
count looks at (made::LOOKED): 1024 one-tile rectangles in 1024 rows of tiles, and 1024
overlapping ones checked tile by tile, each looked at once.
2026-11-12 01:55:19 -08:00
Anees Iqbal 99c40c6e28 draw_costs: a damage shape and a shadowed, loaded target
A guest's compositor pass loads its window surface, a texture over guest pages, and draws
inside damaged rectangles, so the pass's end plans a shadow's copy back and counts its tiles
against its draws' scissor rectangles (count_colors, DrawnArea::covered_tiles). draw_costs
had neither: its target is a cleared Private texture and its clips shape takes two
rectangles.

- damage: as clips, each draw after a scissor rectangle of its own, the next cell of a
  25 x 20 grid of 20x25 pixels (500 rectangles a pass).
- --shadowed: the target is a texture over a no-copy buffer of host pages at its packed
  rows, loaded, the device opened with HostPageTexturePolicy::Shadow so it is a shadow on
  every device.
- The host-page mapping is one helper (host_pages) for the chunks and the target.

Verified: built in the next commit's job; the before/after numbers are in its message.
2026-11-12 01:55:19 -08:00
Anees Iqbal 77d3f928cf Re-pin the runtime sources at the landing tip
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.
2026-11-12 01:53:49 -08:00
Anees Iqbal cf4d8017f2 FAST-PATHS: the heap answer row's measured counts and bytes
heap_texture_images at 4c6ffc7567 (code identical to this tip), under each HeapAnswerPolicy:
of the 22 compositor shapes, on ANV (Iris Xe, m3-max-20000) 14 lie in an image put in place of
their first one and 7 are shadows in Metal's tiles under Metal, none of either under Device, the
answers 3769962 bytes against Metal's 3656426; on the RX 7900 XTX (m3-max-20001) 1 and 8 under
Metal, none under Device, 4155498 bytes. heap_compression_costs on ANV under the default
(m3-max-20014): the 2048x2048 render target still takes the linear image under both compression
values (clear 955.3 and 971.4 us), so the HeapCompression row now says so.

Verified: the jobs named; docs only here.
2026-11-12 01:52:37 -08:00
Anees Iqbal b63d1553e9 Docs: Device::heap_texture_size_and_align names its answer under each HeapAnswerPolicy
The public query's doc said it answered Metal's numbers wherever the runtime models them; under
the default HeapAnswerPolicy::Device a texture whose image needs more answers the larger of the
two within the bounds.

Verified: cargo fmt only; a doc comment.
2026-11-12 01:52:37 -08:00
Anees Iqbal 5b5362124c FAST-PATHS: the heap-shadow cost entry is HeapAnswerPolicy::Metal's
Under the default HeapAnswerPolicy::Device a heap texture Metal keeps uncompressed lies in its
device's image wherever its alignment is within the answer's bounds, so the entry's shadow and its
ANV figures describe the switch, and a texture past the bounds whose 4 KiB image does not fit.

Verified: docs only.
2026-11-12 01:52:37 -08:00
Anees Iqbal 20a186a87e Docs: a heap texture's answer under each HeapAnswerPolicy
The heap module's size-and-alignment bullet, the heap-texture-larger-than-metal declaration and
its catalogue entry, docs/API.md's heaps-and-memory bullet (which said every answer was the
device's image's, where the code answered Metal's model) and WorkCounts::heap_textures_refit now
say what each policy value answers: under Device the larger of Metal's answer and the route's
image within the 64 KiB and 4 KiB-or-size bounds, the 4 KiB image in its place past them; under
Metal, Metal's answer held by a refit or a shadow.

Verified: cargo fmt only; docs alone, no code moved.
2026-11-12 01:52:37 -08:00
Anees Iqbal d8b584a939 RUNTIME_VERSION 2097: a heap texture answers its device's image where that needs more than Metal's answer
Add DevicePolicy::heap_answers, HeapAnswerPolicy::{Device (the default), Metal (in
exact_answers)}. Under Device, a single-sample heap texture whose image binds into the heap's
memory and needs more bytes or a coarser alignment than Metal's modelled answer answers the
larger of Metal's answer and that image's (heap_extent), and lies in that image: no refit to an
image that fits Metal's answer and no shadow of Metal's tiles. A Shared texture's answer also
holds the linear image a heap over host pages binds for it (host_route_extent), so a heap over
guest pages places it too. The answer's alignment is taken only up to 64 KiB (the largest a Mac
answers: an AMD Radeon Pro 5300M) and up to the larger of 4 KiB and its own size, so padding
before a texture stays at most a page or its own bytes. Where the first route's alignment is
coarser than that (ANV's compressed image of a small texture: 64 KiB for 16 KiB), the image a
4 KiB alignment holds (host-transfer usage, else linear: fitting_heap_image with no tiles) lies
there in its place and the answer is that image's, before any shadow. Metal's measured answers
(4:2:2, one-plane YCbCr, two-plane, X32_Stencil8, BlockWritesOnly), multisample textures and
textures whose image lies in memory of its own keep Metal's answer. Metal keeps today's
behaviour exactly.

Why: Metal's 128-byte model made every non-MoltenVK device refit or shadow its heap textures.
Measured with heap_shadow_costs::heap_texture_images, 0 of a guest compositor's 22 heap shapes
fit Metal's answer on ANV (Iris Xe, every optimal image at 65536), on the RTX 3090 (1024) and on
the RX 7900 XTX (256 to 65536). The shadow costs a frame that clears and blits a 1x1 array 34.7
us against 8.2 us outside a heap (ANV). The ledger gets the row; the HeapCompression row notes
that its compressed figure needs the device's answer.

heap_texture_images now runs under both values, makes each shape in a heap and prints a
HEAP-COUNT line (refits, tiled shadows, answer bytes against Metal's).

Verified: cargo fmt only, here; the build, clippy and tests run as potluck jobs after this commit.
2026-11-12 01:52:36 -08:00
Anees Iqbal ad01568553 Re-pin the runtime sources at the landing tip
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.
2026-11-12 01:52:07 -08:00
Anees Iqbal 3be4e7669f RUNTIME_VERSION 2096: a texture over pooled memory is in place at any size; the LinearCost bound is gone
The commits before this one. A tracked texture over a Private buffer in pooled memory larger than
POOLED_PITCHED_BYTES (48 KiB) was a shadow by a speed bound measured on Iris alone (ShadowCause::LinearCost):
a linear image judged slower to sample than an optimal shadow plus its copies. The owner's rule (11-12):
shadows are a fallback, never a first option. Such a texture now takes its DRM_FORMAT_MOD_LINEAR image at
Metal's pitch at any size wherever the device makes one and the pooled check passed; it is a shadow only for
a cause the device has (Refused, CheckFailed, Unchecked, a pending check, or the Shadow policy). Removed:
POOLED_PITCHED_BYTES, ShadowCause::LinearCost and the public TextureShadowReason::LinearCost (api_signatures:
one variant fewer), and the code only the bound used (texture_spans.rs and its moves, Texels::
only_commands_write, the bound's cost benches). API.md, HOWTO.md and the FAST-PATHS in-place row say "at any
size". On every device.

Measured, Radeon 780M (RADV PHOENIX), a 3840x2400 BGRA8 RT|ShaderRead texture at 15616-byte rows (37 MB)
over a Private buffer, per frame (upload, read through the texture, clear pass, read back): with the bound
(m3-max-19924) a LinearCost shadow, 9,216,000 texels copied back each frame; without it (m3-max-19966,
20011) in place, 0 copied in or back.

Test: tests::padding_unobserved::a_large_texture_over_a_private_buffer_is_in_place_where_the_device_makes_it_and_reads_right
(780M 20011, lavapipe 20007: in place, 0 copies, texels right). Touched tests on lavapipe (19928), api
tables 15/15 (19963), lint three ways and rustdoc (19922, 20006).
2026-11-12 01:51:07 -08:00
Anees Iqbal e45394cb76 padding_unobserved: the large texture is a shadow only for a cause the device has
On lavapipe (m3-max-19963) its first three rows were no control either: llvmpipe answered
Shadow(Refused(Pitch)) for 3840x3 at 15616 while the 37 MB texture took its DRM_FORMAT_MOD_LINEAR
image in place (pitched 1, no shadow texel copied in two frames). A smaller shape is no oracle of
what the driver makes. The test now asserts the answer itself: in place with no shadow texel
copied, or a shadow whose cause is the device's (Refused, CheckFailed, Unchecked), never another
reason; under the old bound the 780M's Shadow(LinearCost) fails it.
2026-11-12 01:50:58 -08:00
Anees Iqbal 9a7779de13 padding_unobserved: the large texture's control is its first three rows, not one
On lavapipe (m3-max-19928) the one-row control answered Shadow(Refused(Pitch)) while the 37 MB
texture took its DRM_FORMAT_MOD_LINEAR image in place (pitched 1, no shadow texel copied), so
the equality failed for the control's sake: llvmpipe makes no image of a single row at a padded
pitch. Three rows (46,848 bytes, under the old bound too) are the control the pitched-image test
already uses (3662x3 at 14656).
2026-11-12 01:50:58 -08:00
Anees Iqbal ee9e1140b1 API.md: a texture's size never makes a texture over the runtime's own memory a shadow
The clause the bound's removal left read as a trailing participle; it now states the rule.
2026-11-12 01:50:58 -08:00
Anees Iqbal 0d144ec0de Pooled memory: no bound on a texture's bytes; ShadowCause::LinearCost is gone
The owner, through reims: zero copy, in place where possible, shadow copies a fallback and never
a first option. A tracked texture over a Private buffer of the runtime's pooled memory whose rows
the device's own linear image lays out otherwise was a shadow past 48 KiB to its pitch
(TextureShadowReason::LinearCost), a speed choice measured on an Iris Xe alone that shadowed 1001
of an RTX 2080 guest boot's 1366 textures. It now takes its DRM_FORMAT_MOD_LINEAR image at Metal's
pitch at any size, wherever the device makes one and its check of the pooled memory passed, as a
texture over a Shared buffer already did; it is a shadow only where the device makes no such
image (its format, usage, pitch or limits), its policy is HostPageTexturePolicy::Shadow, or the
check failed or is pending (a pending one still moves in place once it passes).

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

RUNTIME_VERSION is not bumped here: the landing bumps it and re-pins the runtime sources.
2026-11-12 01:50:58 -08:00
Anees Iqbal 20d84ebf33 Pooled memory: a test that a 3840x2400 texture over a Private buffer lies as its first row does
a_large_texture_over_a_private_buffer_lies_as_its_one_row_does_and_reads_right replaces the
pooled bound's test. A compositor's texture, 3840x2400 BGRA8Unorm that renders and samples at
rows of 15,616 bytes (37 MB) over a tracked Private buffer that declares its padding unobserved,
must take the placement its first row alone takes at the same pitch: the DRM_FORMAT_MOD_LINEAR
image in place wherever the device makes one, whatever the texture's bytes. Two frames each
upload texels into the buffer, read them through the texture, clear it through a pass and read
the buffer back; it prints the shadow texels copied in and back a frame (LARGE-POOLED) and, in
place, asserts none. With the 48 KiB bound still in the runtime it fails (the texture answers
Shadow(LinearCost), its row NotHostPages): the next commit removes the bound.
2026-11-12 01:50:58 -08:00
Anees Iqbal 0910ffd92e Validation lane: a guest's shadows of their linear cost, alone and beside another texture (pooled_guest_set)
The 15 shapes of a guest boot's 1001 LinearCost shadows on an RTX 2080 (textures over Private
buffers that declare their padding unobserved), each weighed by how many it made: where the
placement query puts each alone over its bytes (the pooled bound read) and beside a one-row
texture made over them first (the image at Metal's pitch at any size where the device makes it).
Report only, ignored, run by name.
2026-11-12 01:50:57 -08:00
Anees Iqbal 5b228b1309 Validation lane: the pooled bound's crossover per device (pooled_crossover_costs)
One texture over a Private buffer, BGRA8Unorm and RGBA16Float, 16 KiB to 4 MiB to its pitch and
the guest's 723x625 shape, in place at its pitch (a one-row texture made over the bytes first, so
the measured one takes the DRM_FORMAT_MOD_LINEAR image at any size) against a shadow, each frame
a compositor-like draw that samples it whole, the texture changing every frame or every 60th by a
render pass or by a blit into its buffer. Report only, ignored, run by name in release: the
numbers decide the bound on each device.
2026-11-12 01:50:57 -08:00
Anees Iqbal 2afea6eb77 Re-pin the runtime sources at the landing tip
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.
2026-11-12 01:35:27 -08:00
Anees Iqbal 28be5e8adc RUNTIME_VERSION 2095: a shadow's move in place counts in the views epoch, so no bind pushes its freed views
The commits before this one. A texture over host pages made before its in-place verdicts is a shadow;
when the verdicts pass, Prepared::move_in moves it in place and ShadowAfterMove frees the shadow's image
and views once the committing command buffer completes. The move did not bump DeviceShared::views_epoch,
so the render encoders' bind memo (kept on the device, views keyed by texture address) still held the
shadow's view, and a later encoder's bind pushed a freed VkImageView. move_in now calls views_go on the
shadow, under its views lock, before the flag that lets the shadow be freed; the pooled-memory moves take
the same path. On every device.

Found by reims's per-draw repro in pages mode: SIGSEGV on the RTX 3090 about 70 s in (the original core:
the pushed combined image sampler's view was freed memory, its sampler intact; gdb m3-max-19818, 19829).

Test: tests::first_host_texture::a_surface_moved_in_place_is_drawn_through_its_image_once_its_shadow_went,
RTX 3090 (m3-max-19897): without the fix the later draw worked out 0 views and read wrong rows; with it
1 view, the new texels, pass. lavapipe (m3-max-19891) 29/29 of the touched files; lint three ways
(m3-max-19908, 19909).
2026-11-12 01:34:26 -08:00
Anees Iqbal e26d12b544 A shadow's move in place counts in the views epoch, so no bind names its views after they went
A texture over host pages made before its pages' in-place verdicts is a shadow;
once they pass, a commit moves it in place (TextureShared::moved) and the shadow's
VkImage, views and memory go when that command buffer completes
(ShadowAfterMove). Render encoders' bind memo (binding::BindMemo) keeps each
texture slot's VkImageView by the texture's address, current while the device's
views epoch holds; the move changed the image the texture presents without
moving the epoch. A later encoder's draw then took the shadow's view from the
memo and pushed it after it was destroyed: on the RTX 3090 (NVIDIA 620.70.06) a
consumer's per-draw run with surfaces over host pages died with SIGSEGV in
vkCmdPushDescriptorSet (push_set <- Recording::record <- draw_resident; the
pushed combined image sampler's view object was freed memory). Before the
shadow went, the same draw read the shadow instead of the image in place.

The move now counts as the shadow letting its views go, under the shadow's
views lock, before the flag that lets ShadowAfterMove free it: every kept view
is dropped at the next bind, which works out the view of the image in place.
The pooled-memory moves take the same path. Docs of the epoch, the memo, the
counter and the storage-form module say so.

Verified: cargo fmt; the device runs are in the report.
2026-11-12 01:34:17 -08:00
Anees Iqbal 3bc7cb60a9 Test a surface over host pages drawn after its move in place, once its shadow went
A ShaderRead BGRA8 surface of tight rows over a no-copy buffer, made on a new
device before its in-place verdict, is drawn through its shadow; once the check
settles, the next commit moves it in place and its shadow's image and views go
when that command buffer completes. A later render encoder starts from the bind
memo the first encoder left its device: its draw must work out the texture's
view again (bind_views_worked_out) and read the texels the CPU wrote into the
pages after the move. Without a fix the memo hands it the shadow's view, which
was destroyed: on NVIDIA 620.70.06 (RTX 3090) vkCmdPushDescriptorSet faults on
it, as a consumer's per-draw run over host pages did (SIGSEGV in push_set,
binding 3, a combined image sampler whose VkImageView object was freed).

The draw and the blit helpers are shared with the odd-width test, which reads
as before.

Verified: cargo fmt; device runs follow in the fix's commit.
2026-11-12 01:34:17 -08:00
Anees Iqbal 2c8a34a79e Test: recorded_at_the_call counts fills once the device's queue-switch check ended
What: a_fill_is_recorded_at_its_call waits for the device's queue-switch check
(settle_queue_switch_check, 120 s) after making its command queue and before it counts, as the
other tests that read commands_recorded do (fill_waits, fill_queue, draw_again).

Why: the test's expectation went stale at RUNTIME_VERSION 2089 (24f233db8b). The check's rounds
now open their gate on the GPU with a vkCmdFillBuffer of the check's scratch buffer, recorded on
the check's thread, and WorkCounts::commands_recorded counts every command of the device whatever
the thread (its contract). The test counts all of the device's fills, so a check whose opening was
recorded between the test's fill and its commit read as "the fill recorded again": the RTX 5080's
runtime suite at pin 45 (m3-max-19738) saw 1 at the call and 2 after the commit.

Verified on the RTX 5080 Laptop GPU (NVIDIA 615.71.09), b5080 batch m3-max-19866, with a scratch
probe that counts the device's fills from before its first command queue until its check settled,
the program recording none: 0 at pin 44 (bf442ceb9e + the probe) and 1 at development 9768c1b352
(+ the probe), the check's verdict Idles at both. In that batch this commit's test passed (fills 1
at the call, 1 after the commit). The failure itself needs the check's recording to land inside
the test's window (it did under the suite's load); the unsettled test passed alone in the batch,
as it did in the other devices' suites.
2026-11-12 01:32:26 -08:00
Anees Iqbal ec8991b130 Re-pin the runtime sources at the landing tip
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.
2026-11-12 01:14:20 -08:00
Anees Iqbal fbef0a0948 Docs: the copied buffers' 7840HS and pass figures are of comparisons on four threads
The ledger's copied-buffer rows (FAST-PATHS) and copied.rs's Cost bullet quote
the copied_bench and copied_pass_bench figures measured while a comparison ran
on up to four threads; it now runs on up to eight, so they say so, in the past
tense, rather than read as the eight-thread cost. The two FAST-PATHS rows are
rewrapped to 100 columns (one line ran to 130).

No behaviour change; no figure is new.
2026-11-12 01:13:40 -08:00
Anees Iqbal 9768c1b352 Re-pin the runtime sources at the landing tip
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.
2026-11-12 01:12:19 -08:00
Anees Iqbal cd8a3600c1 RUNTIME_VERSION 2094: a batch waits for other queues' first work only where its commands or its own first work may reach that memory
The commits before this one. A batch on another VkQueue waited on the GPU for every batch that did new
resources' first work (image first moves, staged texel copies, fills at a batch's start) until it
completed. Each such batch is now kept with what owns the memory its work wrote, and a batch waits for
it only where its commands may reach that memory (its uses name it or make it resident; a command
reaches unnamed memory, the root table or work recorded on the GPU alone; or the owner is unknown, the
device's own resources) or where the first work it took lies in that memory. Internal submissions still
wait for every one. On every device. Counted: WorkCounts::first_work_waits and first_work_waits_unused
(the conformance cost SUBMISSION group lists first_work_waits).

Measured, RTX 3090, release, one run (m3-max-19766), a compositor's frame p50 beside an app on another
queue:
- app making two 1024x1024 Private textures per command buffer: 17.07 -> 2.06 ms (2.10 with nothing
  made); waits on unused first work per 4 s 247 -> 0;
- making buffers and textures: 12.07 -> 2.00 ms;
- a device with no fill queue: buffers 16.51 -> 2.12 ms (unused 231 -> 0), textures 17.07 -> 2.06 ms.

Test: tests::fill_waits::a_batch_that_reaches_no_new_texture_waits_for_none_of_its_first_work saw 16
unused waits before (fail), 0 after. The zero-read test now holds a heap texture and a plain Private
texture whose moves are taken behind a long load on another queue: both read what was written. 23/23
zeroed_start / fill_queue / first_move tests on the 3090 (19766), lavapipe 26/26 touched (19767), lint
19732. Not run: the 5080, RADV, Intel, MoltenVK.
2026-11-12 01:11:24 -08:00
Anees Iqbal 49e4ec15f4 First moves' docs: the narrowed waits for other queues' first work, as the RTX 3090 measured them
Job m3-max-19766, one before/after on the RTX 3090 (before: c76b6d619a's code, every batch waiting for all of it; after: 22064bea33). tests::fill_waits_bench, the compositor's frame p50: app making textures 17.07 -> 2.06 ms (247 -> 0 unused waits in 4 s), buffers and textures 12.07 -> 2.00 ms; on the device made with no fill queue, buffers 16.51 -> 2.12 ms (231 -> 0), textures 17.07 -> 2.06 ms. tests::fill_waits::a_batch_that_reaches_no_new_texture_waits_for_none_of_its_first_work: 16 unused waits before (fails), 0 after (passes); zeroed_start, fill_queue, first_moves and first_move: 23/23 after.
2026-11-12 01:11:15 -08:00
Anees Iqbal 5cf984c6d1 Test fill_waits: the texture blit helper is write_and_read, apart from the pointer test's command buffer
Named through, it was shadowed by the zero-reach test's local command buffer of that name (E0618 under --cfg m2v_gpu, job m3-max-19719).
2026-11-12 01:11:15 -08:00