engine_private_memory: the kernel 'reached' declares float a[64][64][16]
(256 KiB) and reaches a[0..2][0..4][3] and a[gid & 1][3][3]; it compiles at
128 bytes a thread with no note on the RTX 5080 (32 KiB) and on the floor of
a device not measured, and read at a[gid][3][3] it keeps 256 KiB and is
refused on both. reach also bounds 'and' by one bounded operand and 'urem' by
its divisor.
A kernel written for its largest configuration declares its thread arrays at
that size and indexes them by counters whose trip counts its function
constants decide. Selection held such an array to the device's Function
storage at its declared size: a 256 KiB accumulator of which the bound
constants reach 512 bytes refused the pipeline on every AMD device.
canon::reach narrows each alloca of nested arrays whose every use is a typed
load or store through an address of its own type, and every index of every
address is bounded within its array: constants, counters of loops whose
header runs the bound constants decide (followed as unrolling follows them,
now shared as unroll::counter_bounds), and non-wrapping integer arithmetic
of those. Each level is allocated as long as the largest index an access
takes there, plus one; a level an address does not index stays whole. Any
other use or any unbounded index keeps the declared type.
Verified: canon tests (private_reach) on a potluck job, see the report.
The landed packet changed a runtime-sources input, so the committed digest no
longer described the sources and `the_runtime_sources_are_the_committed_ones`
would fail. Recomputed over the same inputs and committed by land-pkt.sh.
The commits before this one. RADV's fast-linked graphics pipeline libraries break the ordered fragment shader
interlock on GFX11: the fragment library is compiled without the output interface, so its last export lands in a
separately built PS epilog after the main part's image stores, with no wait for them, and the ordered section (which
ends at the done export) closes before the stores land; the next overlapping wave reads stale data. Nothing the
runtime emits breaks the spec (EarlyFragmentTests with PixelInterlockOrderedEXT, Begin/End once in the entry point,
Coherent storage image). New RuntimeDriverDefect::FastLinkedInterlocksUnordered, every RADV GPU (driverID MESA_RADV):
on it GraphicsContent::links() is false for a variant whose fragment stage declares an interlock mode, so the pipeline
is made whole, the switch the feedback-loop states already take. Every interlocked fetch, the attached reads'
snapshot route included, was exposed on such a device.
Measured, RX 7900 XTX (RADV NAVI31), release, lone_fetch's two tests: base (m3-max-20257) 20 of 42 and 35 of 72
targets wrong; fix (m3-max-20254) 0 of 42 and 0 of 72, "pipelines made whole 3 of 5". Creation, cold, the first
pipeline: whole 0.9 ms against linked 1.1 ms; a later key of an interlocked state pays its own compile (~0.9 ms)
where a linked one paid ~0. A bare-Vulkan probe of our own reproduces the defect (fast link 62 of 72 wrong, whole
0) and shows an LTO link also fixes it, but VUID-VkGraphicsPipelineCreateInfo-flags-06609 needs
RETAIN_LINK_TIME_OPTIMIZATION_INFO on all four libraries, so whole it is. lavapipe (m3-max-20223) lone_fetch 16/16,
driver_defects + interlocked_writes 13/13; lint (m3-max-20279).
Release, on the RX 7900 XTX with Mesa 26.2.6 and MESA_SHADER_CACHE_DISABLE=true:
con_fetch_coverage's first pipeline made whole in 0.9 ms (m3-max-20254, at the fix), and
linked in 1.1 ms at the base (m3-max-20257: pre-rasterization library 0.6-0.7 ms, fragment
shader library 0.4 ms, link 0.0 ms).
RADV's fast-linked graphics pipelines leave the ordered pixel interlock unordered within a
draw. A fragment shader library made without the fragment output interface jumps to a separate
color epilog, and ACO waits for the interlocked storage writes before the final export only where
that export is the shader's own (RADV_DEBUG=shaders: a whole pipeline's image_store is followed
by s_waitcnt_vscnt and the done export, a fast-linked one's by s_setpc_b64 into the epilog). The
GPU ends the ordered section at that export, so the next overlapping fragment reads before the
write lands.
The new RuntimeDriverDefect::FastLinkedInterlocksUnordered is RADV's on every GPU (keyed on the
driverID, no clean GPU). On a driver with it, GraphicsContent::links() is false for a variant
whose fragment stage declares an interlock execution mode (interlocked_writes::facts), so the
pipeline is made whole, as a feedback-loop state is.
Evidence so far, all on the RX 7900 XTX, Mesa 26.2.6:
- tests::lone_fetch's layers leg at the base: 35 of 72 targets wrong, and 0 of 72 under
RADV_DEBUG=nogpl (m3-max-20108).
- A bare-Vulkan probe with 12 instances of one quad in one draw: fast-linked, 46 to 62 of 72
counters wrong; whole or linked with link-time optimization, none (m3-max-20040, -20134).
lone_fetch's run now prints the device's pipelines made whole and asserts one there. The fixed
tests on the XTX, the creation time, lavapipe and lint follow.
The landed packet changed a runtime-sources input, so the committed digest no
longer described the sources and `the_runtime_sources_are_the_committed_ones`
would fail. Recomputed over the same inputs and committed by land-pkt.sh.
The commits before this one. A pass that cleared a color attachment whose texture's image is linear, and which the
device renders under VK_NV_linear_color_attachment, cleared an image its texture keeps and copied it back after,
because clearing the linear image of host memory in place measured slower (linear-attachment-clear-copies). That is a
copy chosen for speed, and the owner's rule is zero copy, in place where possible, shadows a fallback only. Such a
pass now renders the attachment in place whatever its load action. Removed: Degradation::LinearAttachmentClearCopies,
its API.md catalogue entry and api_signatures row, the pass-end check only that route used, and the notice's lane and
conformance expectations. On every device where the rule applies (NVIDIA).
Measured, RTX 3090, a 1920x1080 clear over a Shared buffer, median GPU time of 7 (m3-max-20249 before, 20269 after):
4.926 ms through copies -> 8.434 ms in place (1.7x; the zero-copy rule's cost, kept on the record).
Test: the linear_attachments lane, 25/25 on the 3090 (20269) and lavapipe (20259): a cleared render target over a
Shared buffer counts 1 in place, 0 through copies, texels right; a pass beside a stencil attachment announces
linear-attachment-copies exactly when it renders apart by the rule. The touched set 103/103 on lavapipe (20232); lint
three ways and rustdoc (20270).
The change that cleared linear attachments in place turned the sampling
tests' check that no pass announced linear-attachment-clear-copies into a
check that none announced linear-attachment-copies. A pass beside a stencil
attachment renders apart by the rule and announces exactly that kind: on the
RTX 3090 (job m3-max-20256) a_pass_apart_sampling_its_surface_after_a_barrier_
reads_its_draws and a_cleared_pass_apart_sampling_its_surface_after_a_barrier_
reads_its_draws failed on it (Some(1)), their texels right. The check is now
that the kind is announced exactly where the pass renders apart by the rule.
For the record (not a gate), the 1920x1080 clear of a render target over a
Shared buffer (host-cached system memory on the 3090), median GPU time of 7
passes, debug build, the lane test's cleared_1080p:
- before (962b302902, cleared on chip and copied back, job m3-max-20249):
0 passes in place, 8 through copies, 4.926 ms (4.526 to 5.726)
- after (86d08081e6, in place, job m3-max-20256): 8 passes in place, 0
through copies, 8.430 ms (8.425 to 9.616)
clippy's chunks_exact_to_as_chunks (job m3-max-20145, the lint at 4fa0d76217)
flags chunks_exact with a constant size in cleared_1080p; as_chunks reads
the same texels.
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.
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.
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.
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.
The landed packet changed a runtime-sources input, so the committed digest no
longer described the sources and `the_runtime_sources_are_the_committed_ones`
would fail. Recomputed over the same inputs and committed by land-pkt.sh.
the_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.
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.
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.
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.
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.
The landed packet changed a runtime-sources input, so the committed digest no
longer described the sources and `the_runtime_sources_are_the_committed_ones`
would fail. Recomputed over the same inputs and committed by land-pkt.sh.
The 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).
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.
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).
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).
The landed packet changed a runtime-sources input, so the committed digest no
longer described the sources and `the_runtime_sources_are_the_committed_ones`
would fail. Recomputed over the same inputs and committed by land-pkt.sh.
The 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.
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.
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).
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.
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.
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.
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.
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.
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.
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.
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.
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.
The landed packet changed a runtime-sources input, so the committed digest no
longer described the sources and `the_runtime_sources_are_the_committed_ones`
would fail. Recomputed over the same inputs and committed by land-pkt.sh.
The 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).
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.
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).
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.
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.
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.
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.
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.