A pass rendering into a BGRA8Unorm or BGRA8Unorm_sRGB view of an
RGBA8Unorm texture made without PixelFormatView usage (and the same for
BGRA8Unorm and the sRGB twins) rendered through a shadow image of the
view's format, copied in before the pass and back after it
(shadowed-texture-view, about 50-95 us a command buffer at 64x64): the
texture's image was mutable only for its sRGB twin's formats, so Vulkan
made no view of it in the sibling's format.
Basis, documented on both sides:
- Vulkan: VkImageFormatListCreateInfo (core 1.2), pViewFormats
"specifying all formats which can be used when creating views of this
image", with MUTABLE_FORMAT; the formats are of one class.
- Metal: MTLTextureUsage.pixelFormatView, "Don't set this option if your
texture view only converts between linear space and sRGB. For example,
if your texture uses the rgba8Unorm pixel format and your texture view
uses bgra8Unorm_srgb." Plain Metal makes the BGRA8Unorm view too and
renders through it (its API validation stops it; view_attachments).
Change (image_plan.rs): a color texture of those four formats with
RenderTarget usage lists, besides its sRGB twin's views, the views of
its sibling and the sibling's twin (reordered_views, reordered_formats),
in the single-sample and the multisample plan; a word attachment's view
is left out as for the twin. A texture that renders nothing lists none:
its sibling views already read the image through a swizzle. The view's
other uses then view the image too (takes_views_of).
Compression: expected, not measured. Mesa's sources suggest RADV before
GFX11 keeps no DCC for a list whose formats' channel orders differ, ANV
keeps CCS_E for formats of the same channel bits, RADV GFX11+ keeps DCC
for any list; NVIDIA documents nothing. The A/B lane
view_attachments::reordered_view_render_costs (the parent commit)
measures it per driver.
Tests: image_plan::render_targets_take_their_channel_order_sibling_s_views
(every committed profile: the sibling and its twin taken where the
device renders them directly, none for a texture that only reads, none
for RGBA16Float); runtime_lane::view_attachments::
a_render_target_s_reordered_views_render_in_place (draws through both
views, Metal's bytes, no shadowed-texture-view).
Docs: the ShadowedTextureView notice (degradation.rs, API.md), the
FAST-PATHS view bullet, view_shadow.rs.
Verified: not yet built.
A texture over a buffer whose rows hold bytes between them is the
device's linear image in place (route 1, and Between::Kept for a buffer
only the device's ordered commands write) only at the pitch the driver
itself reports for that image (vkGetImageSubresourceLayout's rowPitch);
the alias checks it exactly. A caller laying out rows had no way to ask
for that pitch: minimum_linear_texture_alignment_for_pixel_format
answers the alignment of images over host pages (16 where the device
imports none), and a pitch rounded up to it can miss the driver's.
The new query (a runtime extension, no Metal counterpart) plans the
image as the texture's making does (declared_plan), makes the plan's
linear image unbound, reads its rowPitch, and releases it. It answers
None where the texture is not one 2D level, layer and sample, or where
the device has no linear image of the plan.
Test (kept_padding.rs): at the answered pitch the texture over a
Private buffer is in place; at each other padded pitch it is a shadow.
Docs: the runtime README beside the alignment query, HOWTO beside the
kept-padding sentence; api_signatures.tsv.
Verified: not yet built; the lavapipe job and one GPU run follow.
What: a texture that renders nothing over a buffer of the runtime's own memory whose rows lie
with the buffer's bytes between them is now the device's linear image, made PREINITIALIZED, at
the buffer's pitch, where only the device's commands, in the runtime's order, write those bytes:
a Private buffer, and a Managed buffer's own on a device without unified memory (a two-copy
no-copy buffer's device copy, or one with its own host copy), not one whose VkBuffer was handed
out or whose memory is exportable (Buffer::gpu_bytes_ordered). linear_plan::holding answers what
an image may hold besides the texels (Between::{Nothing, Unobserved, Kept}); Kept takes route 1
alone: the linear image whose rowPitch the driver reports equal to the buffer's
(vkGetImageSubresourceLayout, aliases with within_padding). No DRM_FORMAT_MOD_LINEAR image at
Metal's pitch, no image over exportable memory or in exportable blocks, as each is made
UNDEFINED. A render target stays a shadow. Counted: WorkCounts::kept_padding_aliases.
Also two pairs of counts of what the program asks of a two-copy Managed buffer, beside the bytes
the runtime copies: managed_ranges_modified and managed_bytes_modified (did_modify_range),
managed_resources_synchronized and managed_bytes_synchronized (synchronize_resource), to compare
with managed_bytes_copied_in and managed_bytes_copied_out.
Why: the RTX 2080 guest census (reims's v302 run) made 230 textures over Managed buffers, 200 of
them RGBA8 ShaderRead|ShaderWrite at 3884, 4208 and 2448 texels a row with rows rounded up to
256 bytes, every one a shadow for its padded rows ("its rows lie N bytes apart"): 2.52 G shadow
texels first copied in, 1.26 G kept, 1.26 G words examined by merges back. Owner's rule:
in place where possible, a shadow only where impossible. Main approved the route and its
conditions.
Basis (Vulkan 1.4, docs/API.md's shadowed-texture entry): 7.1.1 Image Layout Transitions, "Image
layout transitions may perform read and write accesses on all memory bound to the image
subresource range ... If the old layout matches the current layout of the image subresource
range, the transition preserves the contents of that range": the image's one transition is its
first move, PREINITIALIZED to GENERAL, out of the layout it is in, ordered after and before every
write of those bytes, as only the device's ordered commands write them. 12.11 Memory Aliasing:
"Buffers, linear tensors, and linear image subresources are considered host-accessible
subresources when they are in any of these layouts: VK_IMAGE_LAYOUT_PREINITIALIZED,
VK_IMAGE_LAYOUT_GENERAL ... If two aliases are both host-accessible, then they interpret the
contents of the memory in consistent ways, and data written to one alias can be read by the other
alias." VkSubresourceLayout's "size includes any extra memory that is required based on
rowPitch" puts the padding inside the range. A kernel's writes may change the padding as on the
x86 Macs (in_place::Padding::Free); a render pass's load and store "may read and write back" it,
so render targets keep the shadow.
Verified: not built yet. tests::kept_padding (a Private buffer at 416, 448 and 512 bytes a row,
the buffer read back whole after the image's first move; a Managed two-copy texture changed in
one row through did_modify_range, then a blit-written row synchronized out, every byte between
rows as given, against a Shared buffer's shadow), tests::linear_plan's holding cases and
tests::texture_placement run on lavapipe next, then one RTX 3090 run.
In a heap over the caller's host pages (new_heap_with_bytes_no_copy), a single-sample texture
whose bytes Metal lays out in its tiles now takes the image bound to the pages wherever one
serves: its linear image made for host allocations, or over dma-buf pages the driver's
DRM_FORMAT_MOD_LINEAR image, in the driver's rows with no copy, announced
heap-texture-untiled-layout (Untiled::LINEAR). The shadow of Metal's tiles (AliasRoute::Tiled)
is the fallback where no such image serves, and stays the route of a copied heap.
The bytes in guest pages are now the device's layout, not Metal's tiles. Basis: Apple documents
a texture's layout in a heap's bytes as private to Metal, and the consumer confirms that no guest
code of theirs reads or writes a heap texture's bytes in guest pages (replaceRegion and getBytes
go through a staging blit; no buffer aliases a heap texture), so the copies in and out of the
tiles shadow bought nothing it could see (the owner's rule: shadows are a fallback, never a
first option). dma_buf_heap_plan now answers why its image does not serve instead of taking the
shadow itself, so a texture Metal tiles over dma-buf pages falls back to the tiles shadow before
the rows one.
Docs: host_heap_plan, AliasRoute::Tiled, the dma_buf module, the heap-texture-untiled-layout
declaration and catalogue entry, and the FAST-PATHS known-gap entry on heap textures in the
driver's layout.
Verified: cargo fmt only; builds and tests run as potluck jobs after this commit.
The Mac-class section lists what a device presenting a Mac with an Intel
or AMD GPU answers as that Mac; it now names the threadgroup memory
bound (65536 bytes, where an Apple silicon Mac's is 32768) that the
previous commit made the runtime's answer. Docs only.
A function that observes the residency of a read, sample or gather of a texture it reaches
through an argument buffer (sparse_sample, then sparse_color::resident()) was refused at
pipeline creation: lower::texture::residency answered Lowering(Texture), NotImplemented, for a
heap element's status word. A forward renderer that streams its material textures compiles
exactly that, so its pipeline never made and it drew nothing.
Metal reports a texture that is not sparse resident everywhere, which is the word 0 the module
already builds for a heap element's access (emit::with_word). So residency() now answers a heap
element's observed residency with no residency form, the word 0, and the stage states the new
RuntimeFact::HeapResidency { stage } (PlanTimeCheck). The planner (bind::heap::HeapPlanner::new)
refuses a sparse texture (TextureFacts::sparse) that such a stage's handle tables reach,
Unsupported { ArgumentBufferTextures, NotImplemented }: answering one would need the member's
tile map or sparse image per handle-table entry, which is not built. docs/FAST-PATHS.md records
it as a known gap; a slot's sparse texture stays answered (RuntimeFact::SparseTexture).
SEMANTICS_VERSION 2041 (refusals become modules); ARTIFACT_FORMAT_VERSION 504 (a RuntimeFact
variant). docs/REFUSALS.md and the API surface table regenerated.
Test: tests::engine_heap_residency over the new tail_argument_sparse_samples fixture: both
fragments compile behind its vertex function on every committed profile with what they use
(moltenvk-m3, lavapipe and amd-780m-radv named), state the fact and pass L3; their plan holds
a texture that is not sparse and refuses a sparse one. Before the change the base CLI refused
argument_sparse_fragment with Lowering(Texture), NotImplemented, at block 0 instruction 2, the
sparse sample (job m3-max-20327, gem10).
The runtime lane's private_reach makes private_reach_tiles (tile sizes 2 and 4, linking postfix)
on the device the cfg selects and compares its words with what the probe private_array_reach.m
printed on the M3 Max under macOS 27.0.1, and checks private_reach_rows, whose loop a buffer word
bounds, is refused needing its 256 KiB, as the M3 refused it ("Compute function exceeds available
stack space"). The engine test compiles the same fixtures on the RX 7900 XTX's profile: 128 bytes
a thread with no note, and the rows kernel refused needing 262144 of 98304.
SEMANTICS_VERSION 2040: a private array of nested arrays that bounded indices reach in part is
now emitted and counted at its reach, so refusals and modules change under unchanged keys.
The canon module docs and ARCHITECTURE name the pass.
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.
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.
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: 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.
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.
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 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.
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.
tests::fill_waits_bench on the RTX 3090 (job m3-max-19457): beside an app making two 4 MiB Private buffers per command buffer, the compositor's frame p50 went from 8.96-9.01 ms (every batch waiting for the fill queue's last submission, 424-429 unused waits in 4 s) to 2.10 ms (0 unused), as with nothing made (2.08-2.12 ms).
On a device with a fill queue (NVIDIA's copy engine), a batch took every fill waiting, whichever
buffers its commands name, and every submission of the device's waited on the GPU for the fill
queue's last submission until the host saw it complete. A fill-queue submission waits for the
batches before its batch on that batch's VkQueue, so a compositor's frame that named only old
buffers waited for an app's new buffer's zeros behind the app's kernels, or made them itself and
waited for its own queue's last batch first.
What, on such a device:
- A batch takes the fills of memory its commands may reach (FillTake::Reached): memory a resource
its encoders' uses name owns (used_resources::owner_of over Owners and HeapKeys: the buffer, or
the heap it lies in); every fill where a command of it may reach memory no use names
(State::reaches_unnamed, State::parts_reach) or where it takes a move of an image in memory
another resource owns or a staged copy (Taken::every_fill), which come after every fill of that
memory; and the fills of the device's own buffers, which no use names. The rest stay waiting, in
their order, for a batch that may reach them or an internal submission, which takes every one.
A fill's key is noted as it is registered (Filled::key), and its owner as it is taken, so a
buffer's fills share their turn.
- A batch waits on the GPU for the last fill-queue submission the host may not have seen complete
whose fills it may reach (Device::fill_queue_wait_for), where its VkQueue did not already.
Internal submissions still wait for the fill queue's last.
- A command buffer that needs no GPU work goes with no submission where nothing waits but fills of
the program's memory (FirstMoves::none_waiting_but).
Other devices take every fill, as before.
Tests: first_move::a_batch_takes_the_fills_of_memory_it_reaches (pure); fill_waits (device) holds
fill_queue_waits_unused at 0, where the commit before counts the compositor's waits.
Docs: device/staging.rs and texture/first_move.rs module docs, the runtime README, FAST-PATHS'
fill-queue row.
Verified: cargo fmt. Builds, device runs and numbers follow as potluck jobs.
SamplerDescriptor gains `lod_bias: f32` (MTLSamplerDescriptor.lodBias,
default 0, serde default), so a guest's bias is carried rather than
having no field to land in.
What Metal does with it, measured on the M3 Max (Apple9, macOS 27.0.1
26A434) with a throwaway Swift probe of runtime-compiled MSL (jobs
m3-max-19665/19666): level L of a 7-level texture held L, so every
sample read its own level of detail. Across 136 row groups no sample
changed with the sampler's bias: fragment implicit, shader bias(),
level(), gradient2d(), min_lod_clamp() and bias+min_lod_clamp; kernel
default, level, gradient and bias; linear and nearest mip filters on
float textures, both on uint ones; a NotMipmapped sampler's min/mag
choice; clamps [1,3], [1.5,MAX], [0,2]; biases -1000 to 1000, 15.99,
16, 16.5, 17, NaN, +-inf. The probe saw levels move with the shader
bias, the clamps, explicit levels and the NotMipmapped filter switch.
With MTL_DEBUG_LAYER=1 every value made a sampler with no assertion and
read back as set. Apple's tables list the bias under Apple10, which no
runtime device claims.
So the Vulkan sampler's mipLodBias stays 0 whatever the descriptor
holds: no bias is past maxSamplerLodBias, and none needs a portability
subset's samplerMipLodBias. The binding shape and the sampler word do
not carry it either. The runtime's state key does: on the M3 (job
m3-max-19683, with and without validation) biases 0 and 1, 1 and
1.0001, and 20 and 30 gave two states each, while 0 and -0, and two
NaNs of one encoding, gave one. The key takes the bits of `bias + 0.0`.
The Apple10 family row stays a gap, its reason now that the biased
level of Apple10 is not built. The conformance suite's SamplerSpec
states the bias too (tag 8, a word only where it is not 0, so no
recording's fingerprint moves), and both legs set it. METAL-COVERAGE
lists lodBias as implemented; CONFORMANCE-COVERAGE and the API
signature table are regenerated.
Tests: metal::sampler::a_lod_bias_makes_the_unbiased_sampler covers
every committed profile, every mip filter, three filter pairs and four
uses plus the unnormalized one, and 15 biases: the Vulkan sampler and
the binding shape are the zero bias's. That includes MoltenVK, which
withholds samplerMipLodBias, and biases past every device's limit.
runtime_lane::lod_bias::a_sampler_s_lod_bias_reads_the_unbiased_level
runs a kernel's biased samples through runtime sampler states of ten
biases, under linear and nearest mip filters, and compares them bit for
bit with the unbiased state's. It also checks the state-sharing rule.
A copy's comparison of 4 MiB or more (a commit's copy in with no base, whose
pages carry no log, and a comparison with a base) ran on up to four threads, the
calling one among them. On the RTX 5080 Laptop GPU's host (a Core Ultra 9
275HX) eight cut the commit of a kernel-read pass over 256 MiB from 11.2 to
8.4 ms (12.3 to 14.1 GB/s), 64 MiB from 2.9 to 2.2 ms, a copy in after the CPU
rewrote every float of 256 MiB from 30.3 to 17.0 ms (6.6 to 9.0 GB/s), and the
merge back of a 256 MiB kernel-write from 65 to 41 ms with the stores of
27c4a1ae46 (copied_bandwidth_bench's copied-t8 rows at 31333d4bf4, b5080
entry nvcopybw-nvcopybw-5080-ab-234252); on the RTX 3090's host (a Ryzen 7
7840HS) the 256 MiB kernel-read commit from 14.0 to 11.9 ms and the 64 MiB
kernel-write merge back from 11.2 to 8.8 ms (m3-max-19454). A host that runs
fewer threads at once runs that many.
SPLIT_THREADS is now 8, so a device's comparisons (one at a time under its
copies' lock) hold at most seven more threads at once. The bandwidth bench's
contrast row is now four threads (copied-t4); copied_256_bench_eight_threads,
which measured what is now the default, is gone. Docs say eight.
Tests: run after this commit (copied tests on a host without AVX-512, lavapipe).
SPLIT_BYTES, the fewest bytes each thread of a split comparison takes, goes
from 8 MiB to 2 MiB. A merge back runs about 1.75 GB/s a thread on the RTX 5080
Laptop GPU's host (copied_bandwidth_bench, b5080 entry nvcopybw-bw-before-222944),
so a 16 MiB copy the GPU rewrote merged back on two threads in 4.2-4.5 ms of a
5.4-6.4 ms pass (2.6-3.1 GB/s); a run of 2 MiB takes about a millisecond a
thread, against tens of microseconds to start one. The thread count stays at
most four.
Docs: HOWTO, API and FAST-PATHS said a comparison of a copy with a base of 16 MiB
or more splits; now 4 MiB or more, with a base or without (the copy in with no
base splits since d33e19bc70).
Tests: the split tests take 4 x SPLIT_BYTES (a_comparison_split_across_threads_...,
a_copy_in_with_no_base_splits_...), now 8 MiB. Not run yet.
On the RTX 3090 (NVIDIA 620.70.06), eight processes of the extra-queues test at once, 6 rounds
(m3-max-19109, the bound built in): 5 of 48 processes' checks met a submission that had not
completed at 10 s, each announced, its verdicts Unchecked, and every process ended (95 of 96 exit
0; the one exit 101 is the process of an Xid 32, whose own wait on its extra compute queue's fence
failed). Every other process's longest wait for a check submission was 1.3 to 12.0 ms; lavapipe's
0.05 ms (m3-max-19057). The same run logged Xid 13 (a compute class c7c0 exception) in one more
process, with no channel-ID allocation failure in the kernel log around it.
On an RTX 3090 behind a Thunderbolt 3 bridge (NVIDIA 620.70.06, Linux 7.3.3), six processes of
tests::video_interop::extra_queues_are_made_or_reported_and_the_video_features_enabled at once
(job m3-max-18786) met Xid 69 (class c797, offset 0x1b0c SET_REPORT_SEMAPHORE_D, ErrorCode 0xc,
data 0x2001c00d, itself a valid method header: the GPU read the method stream one word short) in
one process and Xid 32 (intr0 0x40000, PBENTRY) twice in another, 37 ms apart; two copies' empty
submission on the extra compute queue failed its fence wait, and one copy's submission checks
waited on their fence with no end. No PCIe error was logged then. The faulting processes of the
first report (um870, m3-max-18368) were video_interop tests too.
What was ruled out: every runtime VkQueue use holds that queue's lock (the queues audit), and a
probe that tracked each thread inside vkQueueSubmit, vkQueueWaitIdle, vkQueueBindSparse and
vkDeviceWaitIdle per VkQueue saw no two threads on one queue in 240 processes of the same shape
(m3-max-18977: 10 variants x 4 rounds x 6 copies: checks off, merge off, import tax off, no extra
queues, no video extensions, the test's submissions off, the validation layer). None of those
240 met the Xid either, so the variants decide nothing; 1 of the 18 earlier processes did.
Recorded as a host note (HOWTO.md), and the four tests run alone on Linux (.config/nextest.toml),
so no other process makes a device beside theirs.
Not run: a check that running alone avoids the error (it is too rare to show in a short run).
The submission checks' thread waited for each of its fences in 100 ms slices with no end. On the
RTX 3090, with six processes making their devices at once, the kernel logged a pushbuffer error
(Xid 69, Xid 32) and one process's checks waited on their fence for good, its device's teardown
behind them (SubmitChecks::stop waits for the thread). An accuracy-free self-check must not end
a program's work (AGENTS.md rule 2).
Now a wait past STALL (10 s) takes the device as lost for the checks: nothing is submitted again,
what had not answered is Unchecked for the device's life, nothing is recorded, and the sink hears
metal2vulkan-submit-check-stalled. The stalled submission's fence and command pool stay pending,
so the thread leaves them to the teardown, which waits up to STALL more and releases them once the
fence signalled; where it still has not, the teardown leaves the device and its instance to the
process's end (as the exit path does) instead of a vkDeviceWaitIdle that would never return. A
step held whole lets go of the loader word without waiting for the relay mark of a stalled use.
The checks' report now gives their longest wait.
Test: a_submission_that_never_completes_stalls_the_checks_and_the_teardown_returns injects a
submission whose first info waits on a timeline semaphore nothing signals, with a 2 s bound; the
checks settle at the bound, the sink hears it once, nothing is recorded, and the device's drop
returns after the bound with its VkDevice still live; then the test signals the semaphore.
Not yet verified: build, lint, the test runs (to come in the following jobs).
A commit copies into each copied host buffer the bytes the CPU changed in
its pages, before any of the command buffer's work is submitted. A batch
that waits for an event runs its commands only once the event reaches
the value, and on Metal those commands read the pages as they stand
then. So a CPU write made after the commit and before the host's signal
(or before a later command buffer's signal) never reached the copy, and
the waiting command buffer read the bytes from before it.
The commit now notes, before its copy in, the batches that wait for an
event value not yet reached (CopiesAgain::unreached, from each event's
timeline). When the scheduler submits such a batch, which it does only
once the wait is met, submit_batch first copies in again
(copy_in_again): the copies the command buffer reaches, as at the
commit, take the CPU's changes since. This runs with no lock of the
command buffer held, since a copy over logged pages waits for the log's
publication. A batch with no wait, or whose every wait was already
reached at the commit, copies nothing more. The new counter is
WorkCounts::copied_copy_ins_after_waits.
The same mechanism serves a reader held by an event across queues: the
signal of a batch submitted while a copy is live is seen only at its
completion turn, after the merge back. The FAST-PATHS gap that listed
event-ordered reads across queues as stale now says the held reader
copies in again; that case is expected from the code and not run.
Docs: copied.rs (Coherence, the two-memories bullet, copy_in),
dirty_pages.rs (stamps), HOWTO (copied host buffers), FAST-PATHS (cost
row and gap), api_signatures.tsv (the new field).
Verified: waited_reads in the jobs named in the report. The copied leg
fails at cae2e24b4d and passes here; the no-wait copied leg makes 0
copies in again.
RUNTIME_VERSION 2083 made a buffer bound inside its pages' import hold the import, so a no-copy
buffer's deallocator given no keep-alive waits for that buffer to go, and docs/API.md's catalogue
entry said so in its cost. The kind's announced cost (Degradation::HostDeallocatorDelayed's) did
not, and tests::degradation_catalogue::a_runtime_kind_s_entry_states_the_cost_it_announces failed
on every device that runs it (pin 44: Iris, m3-max-19132, and the 780M).
The announced cost now carries the same clause, worded 'every buffer bound inside their import
goes' in both, and the kind's own docs list the case beside the others it waits for.
Verified: the degradation_catalogue tests on lavapipe (see the landing report).
On NVIDIA's driver each VkQueue is a channel and a runtime device of
the queue plan takes 18. An RTX 2080 held 10 such devices at once
(job m3-max-18774), so a 16-thread host's default 16 test processes
ask it for 288 VkQueues and the driver refuses the rest; the 3090 and
the 5080 Laptop GPU held 61 (jobs m3-max-18776, m3-max-18775).
--profile few-channels runs three at a time, as the consumer's own
profile does. docs/VALIDATION.md says when to pass it.
vkCreateDevice's answer where the device-specific resources a logical
device needs run out is VK_ERROR_TOO_MANY_OBJECTS (the Vulkan spec,
vkCreateDevice), and a driver short of host memory for the plan's
VkQueues may make a device of fewer: both now take the least plan, as
VK_ERROR_INITIALIZATION_FAILED (NVIDIA's channels) and
VK_ERROR_OUT_OF_DEVICE_MEMORY did. A device refused with both plans
is refused naming each attempt, as before.
Asked for by a device test on an RTX 2080 under parallel test load
(job m3-max-18589) that got OutOfMemory(Host) from
Device::system_default_with, where the least plan's three queues would
have fit: the 2080 held 10 devices of the plan's 18 VkQueues at once,
and 68 of the least plan's 3 (job m3-max-18774).
The pure test of made_within_resources takes each of the four codes.
A new command queue took the round robin's VkQueue by a creation counter (made modulo the
round robin), which never reuses a slot: a guest makes about 340 queues past NVIDIA's 14 in a
250 s walk, so live queues landed together while other VkQueues stood empty. An unshared
queue (a compositor's) got a VkQueue of its own only where the device shares (an Adaptive
verdict of Idles); under PerQueue, on MoltenVK, and on a device that answers GPU times from
the host (reims-vgpu's, Unchecked) it took the round robin's next, so app queues made later
landed on it every 14th make. Guest walks (reims's logs, read in place): unshared command
buffers behind another queue's batch 1062 in one 3090 walk (39 over 16 ms, longest 33.8 ms),
5 in the next on the same build; 511 on a 2080; 2048 on the M3 (437 over 16 ms).
Now, under every policy and verdict, a command queue takes, as it is made, the round robin's
VkQueue the fewest live command queues hold of those no unshared queue holds, the first in
turn from the counter among equals (queue_share.rs fewest_held, Device::take_round_robin):
one pass over the round robin's VkQueues' counts, atomics alone, at creation only; nothing
scans the command queues. Its claim is made before it reads the unshared count, as an
unshared queue's is made before it reads the live count, both sequentially consistent, so the
two never both succeed. An unshared queue takes one no command queue holds where one is free
(the existing unshared_order, now ungated), else the one the fewest hold.
Counts: WorkCounts::command_queues_live_most (the most command queues the program held at
once: what a walk needs to size the plan by) and unshared_queues_sharing_a_vk_queue (an
unshared queue that found no VkQueue free of other queues). queues_sharing_a_vk_queue keeps
its meaning, the queues made past the round robin's VkQueues; unshared queues now count among
them under every verdict, as they did where the device did not share. QueueLimits notes keep
theirs, an unshared queue's included.
Tests: tests::queue_share's pure churn shaped like a walk (354 made over 14 VkQueues, at most
12 live, an unshared one kept): no queue placed beside a live one while one stood empty and
the unshared one never shared, against a positive count by the old rule; device test
over_a_churn_queues_take_the_least_held_vk_queue_and_unshared_ones_an_empty_one under
Adaptive, PerQueue and untimed Adaptive. The helpers that share a VkQueue on purpose (beside,
the lane's queue_where) keep the queues they make until one lands there.
Docs: QueueSharingPolicy, new_command_queue_unshared, new_command_queue_for_presenting,
queue.rs and queue_share.rs module docs, docs/API.md, the runtime README, FAST-PATHS's queue
sharing row and its known gaps.
Not yet built or run: potluck jobs follow.
The release order RV 2073 brought, in the docs a consumer reads. A no-copy buffer made over part
of a live one's bytes, or over the same bytes as memory of another class, is bound inside the
live one's import (one live import of a page: VK_EXT_external_memory_host leaves a host allocation
imported twice into one device undefined) and holds it, so the live one's keep-alive is dropped
only once both are released and the import is freed. With a keep-alive its deallocator still runs
at its release, as Metal's; given none, the deallocator waits for the free, announced as
host-deallocator-delayed.
- API.md: the host-deallocator-delayed entry names the cause and its cost; section 10 (Heaps and
memory) records the keep-alive's later drop as an accepted difference, with
WorkCounts::host_releases_held_inside.
- HOWTO, "Unmapping host memory": the order for a buffer over part of another's bytes.
- The runtime README's no-copy paragraph and KeepAlive's doc name it.
The straddle copy (f083e9c806) and the held-back chunk (c55501db1b) each read only finished
state: an object's check read made chunk imports alone (chunks_hold_any), and a chunk's check
read noted object imports alone (the alias registry). So an object made while a chunk's import
was in flight, or a chunk imported while an object's own import was between its checks and its
note, imported the same pages twice. Both tests of 1d77522508 showed it on lavapipe, 3 runs of
3 each (m3-max-18881): imports_inside_live 1.
Each RAM the device uses now keeps the claims of objects' own imports in flight. An object's
making and a rebind claim their window's RAM pages (Device::claim_ram_pages) where no chunk binds
them, and hold the claim through their import until it is noted: where a chunk's import, made or
in flight, holds some of the pages, nothing is claimed and the object is a copy
(CopiedBecause::OverRamChunk, as for a made one). A chunk's import is marked in flight only under
the RAM's claims (RamOnDevice::chunk takes them before the chunk's lock, as a claim does, and
looks at the chunk again), and is held back where a claim meets its pages (held_back), as where a
noted import does. Whichever starts first, the other never imports the same page.
Docs: host_ram.rs's one-import bullet; the OverRamChunk cause, copied_over_live_imports and
docs/API.md's copied-host-pages entry say made or in flight.
A no-copy object whose pages cross the end of a guest RAM's chunk, the chunks on both sides
imported, is bound in neither: route_runs answers Runs, and the object took the gate's path
and imported its own pages, the same host addresses as the two live chunk imports
(VK_EXT_external_memory_host leaves that undefined; imports_inside_live counted it). The
consumer's walks hit it at boot on the 2080 and the 3090: a 2 MiB heap from 0x3f22000 into a
64 MiB chunk, 0xde000 bytes in the first chunk and 0x122000 in the next.
Such an object, and one over a live chunk's pages that no resolver routed, is now a copy of its
pages (CopiedBecause::OverRamChunk, counted in copied_over_live_imports, announced as
copied-host-pages, the gate not asked), at its making and at a heap's rebind. Chosen over:
- aligning chunk imports to objects: the chunks are imported ahead, before the objects over
them exist, and objects lie anywhere;
- one import over both chunks: each chunk's import already binds objects when the straddling
one comes, and swapping it would move every bound object;
- a sparse binding of both chunks' memory: heaps place resources at any offset, and not every
device binds sparse buffers.
A copy costs one copy of the object's pages per commit, the rare edge object alone (one per
chunk end an object crosses).
Test: a_heap_across_two_imported_chunks_is_a_copy_and_imports_nothing (the consumer's shape:
both chunks imported by a buffer each, then a 2 MiB heap from 0xde000 before the first chunk's
end): one copy, no pointer import, imports_inside_live 0, the gate not asked; a buffer placed
across the chunks' end reads the RAM's bytes and a fill through it reaches them.
reims's pin 42 walks on the RTX 2080 counted imports_inside_live = 1 at boot, once in each of
two walks, in the second the device's thread imported its first chunks ahead (with a 2 MiB
pointer import and host_imports_kept_of_heap in the same second). A no-copy heap made over the
RAM's pages before use_host_ram (or with no run resolver) imports its own pages outside the
RAM's routing, and the thread's import of the chunk holding them then imported those pages a
second time, which VK_EXT_external_memory_host leaves undefined (issue 6).
Now RamOnDevice::chunk holds the chunk back while HostAliases::within finds a live import over
its span (RamOnDevice::held_back): no import, the device's thread marks it tried, an object
over it falls back to the paths of memory no RAM holds (its own import, inside the live
import, or a copy), and copy_take sends copies over it through the CPU. Once every such import
over the chunk went, the next object over it imports it. Counted:
WorkCounts::host_ram_chunks_held_back (api_signatures updated).
Docs: host_ram.rs's module doc no longer describes pointer chunks' runs imported alone (the
2073 fix made those dma-buf-only); it states the held-back chunk. host_aliases.rs,
churn_counts.rs's imports_inside_live and HOWTO's guest RAM paragraph say the same.
Test: host_ram_device::a_chunk_a_live_import_made_before_the_use_holds_waits_for_it_to_go
(a heap over the first chunk made before the use; the thread and a buffer's take hold the
chunk back, the buffer imports its own pages and reads the RAM's bytes, no import inside a
live one; once both went, the next buffer is bound in the chunk).
87b0acd6d5 tried every type the host does not map before every type it maps. On an Iris Xe
(ANV, Mesa 26.2.x, m3-max-18804) that moved Shared, WriteCombined and Managed imports of a
udmabuf and of a device-local dma-buf from type 2 (DEVICE_LOCAL|HOST_VISIBLE|COHERENT|CACHED,
the class's first) to type 0 (DEVICE_LOCAL alone). On a unified-memory GPU the host's flags on
a device-local type may choose how the GPU caches its accesses to the pages, so that move is
not shown to be harmless.
Now only the system-memory types the host maps (HOST_VISIBLE without DEVICE_LOCAL) go last;
device-local types keep their class's order. NVIDIA's udmabuf types (0: no flag, 4: host-visible
coherent cached system memory) still order 0 before 4, so the 3090's result stands. ANV's types
are all device-local, RADV's for a udmabuf all host-mapped system memory, lavapipe's one: the
class's order as before.
Unit test: dma_buf_imports_try_the_system_memory_types_the_host_maps_last (renamed), with an
ANV-like set (all device-local, unified) and a GTT-like set (all host-mapped system memory)
whose orders and forms stand. FAST-PATHS's NVIDIA dma-buf gap says the same.
NVIDIA's 620.70.06 lists a udmabuf of host pages as its type 0 (system memory, no property
flag) and its type 4 (host-visible, coherent and cached, the Shared class's first), refuses
every import as type 4 with ERROR_OUT_OF_DEVICE_MEMORY, and imports it as type 0. Measured on
an RTX 3090 (tests::export_after_dma_buf, raw vkAllocateMemory answers on fresh devices): once
it refused an import as type 4, it answers ERROR_OUT_OF_DEVICE_MEMORY to every allocation of
its device-local type 1 exportable as an opaque fd or a dma-buf (with the device-address flag
or without), at 12,441,600 bytes and at 64 MiB, for the device's life; plain and
device-address-only allocations are still made. After a successful import as type 0, every
chain is made. Whether the import was dedicated does not matter. The runtime's first Shared
dma-buf import tried type 4 first, so every later Private exportable buffer overflowed into
system memory (type 0, DeviceMemoryOverflow).
The runtime never maps a dma-buf import (the CPU reaches the pages through the caller's own
mapping), so a type the host does not map serves it as well. dma_buf_candidates now orders the
types the host does not map first, then those it maps, each in the class's order
(dma_buf_class_order, the order before), and dma_buf_attempts tries every form (dedicated to
nothing, then to the buffer) of the first group before any form of the second. On NVIDIA the
import ends as type 0, as before, without the refused attempt. A driver that lists only
host-mapped types for a dma-buf keeps the class's order.
Tests:
- memory::dma_buf_imports_try_the_types_the_host_does_not_map_first (unit): both orders, and the
attempts' order, for NVIDIA's types and for a set whose listed types are all host-mapped.
- export_after_dma_buf::a_private_exportable_buffer_after_a_dma_buf_import_lies_in_device_local_memory
(renamed): asserts each export lies in a DEVICE_LOCAL type with the control's flags and no
overflow counted. It failed on the RTX 3090 before this change (type 0, one overflow each).
- export_after_dma_buf::the_driver_s_answers_after_each_kind_of_dma_buf_import: kept as the
driver's evidence, printed and not asserted.
- export_after_dma_buf::the_type_each_class_s_dma_buf_import_takes_against_the_class_s_order:
prints, per class, the type the runtime's import takes and the type the class's order took,
for a udmabuf and for a dma-buf of the device's own device-local memory; asserts they agree
where both orders are the same.
docs/FAST-PATHS.md's NVIDIA dma-buf gap records the driver's refusal and the order.
The quiet-commit definition, where a shadow made before its verdicts (or a pooled texture's
shadow of its linear cost) moves in place, named only the uncommitted command buffers, events
and textures bound by ID. The commit also takes the move only where every batch before it was
submitted, every encoder of it may run, and none of its work is left to record after the commit
(command_buffer/storage_form.rs takes_storage_forms; Device::storage_form_switch). Found on
lavapipe: a diagnostic run (m3-max-18654, scratch prints, never landed) showed four compute-only
commits declining the move, each with recorded segments, and a blit's commit taking it
(moved 1, freed 1, the next read copying nothing).
A guest's window server makes dozens of textures over each of its large Private surfaces (other
formats of the same bytes, and a new texture each frame), and past the pooled bound each was a
shadow of its linear cost of its own (216 on a Radeon 780M at a login, 1022 in 13 s on an Iris Xe).
storage_over_buffer decided each texture alone: pooled_pitched_image answered LinearCost for any
tracked texture over a Private buffer past 48 KiB, so every texture over the same bytes made a
full image of its own, copied every texel in at its first use, copied in again after a write
through any other (which lets go of its standing) and copied back whole after a kernel's write.
The shadow log names the buffer's object, not the texture's, so one object's two lines 22 ms apart
are two textures over the same surface, a frame apart.
The bound weighed one texture over the bytes. A buffer now notes the runs of bytes textures were
made over (texture_spans.rs, at most 8 runs, joined where they meet), whether those textures
still live: a texture over bytes another texture was made over takes the DRM_FORMAT_MOD_LINEAR
image at Metal's pitch at any size, as over CPU-visible memory, and the first texture's shadow of
its linear cost moves to that image once another texture is made over its bytes, through the
existing pooled move (wait_to_move_in_place: at the next quiet commit, with no copy). Both forms
give Metal's answer; the textures alias the bytes as Metal's do. The bound has no FAST-PATHS row:
it chooses between two exact speeds (6717cac4ea). API.md, HOWTO and the LinearCost docs say so.
Verified: cargo fmt; builds and device runs follow as potluck jobs.
What: a usage or attached-read shadow whose truth is a tracked Private or Memoryless image the
runtime made in memory of its own (not shareable, its VkImage never handed out) now stands
across command buffers, as a shadow of a Private buffer's bytes already did
(Backing::PrivateImage, StandingAcross::over_image). A standing also keeps the rectangle its
image is stale in when the command buffer ended with it current there alone, and the next
command buffer's gated copy in moves only those texels (Standings::standing,
GatedCopyIn::standing_copy). The first render pass instance of a pass now bounds its loaded
colors' writes by its draws' scissors as later instances did, so a draw that samples the
texture its pass renders leaves that texture's shadow stale inside the drawn rectangle alone.
Why: on the 780M a 2618x1024 texture read through such a shadow was copied in whole once per
frame although its texels changed only every 4th frame: 2,680,832 texels a frame, about
200-370 us of GPU time, for a draw beyond the texture's usage and for one that samples it in
the pass that renders it through a 64x64 scissor. An image truth never stood (stands_across
took bytes alone), and a one-instance pass's attachment writes were never bounded, so the
shadow lost the truth whole. The copy an attached read takes before any barrier stays: read in
place through the feedback loop it would race the pass's own writes, which Vulkan forbids
(attached_reads.rs now names it).
New WorkCounts fields: shadow_texels_first_copied_in_private_images,
shadow_texels_unskipped_stale_within.
Tests: unchanged_truth_copies now asserts that a frame that changed nothing moves no texel the
shadow holds (0 beyond usage, the scissor's 4096 for the small attached read); image_standing
checks the stale-rectangle copy's texels and counts, the let-go after another write, and the
mip chain (clear level 0, render level 1 sampling the whole texture, then level 2, then sample
every level) with and without a usage shadow, its passes apart and in one command buffer. Run on
lavapipe and RADV PHOENIX after this commit (job ids in the report to main).
A compute state whose descriptor requires no threadgroup size predicts no
VkPipeline at its creation: the local size and the threadgroup memory
lengths are the dispatch's own calls, so its creation's record made none of
its dispatches' pipelines on a later warm pass, and each was a cold driver
compile at the program's first dispatch of its shape (the 12.7.6 kernels'
case in FAST-PATHS).
Now, where the device hands records over, a compute state's direct dispatch
(dispatchThreadgroups: or dispatchThreads:) whose regions' pipelines were not
all made hands the hook one more record: the creation's descriptor, as its
own record holds it, and the dispatch (its threadgroup, a dispatchThreads:
grid reduced to one whole threadgroup and its ragged edge per axis, and the
encoder's threadgroup memory lengths). Each such dispatch once per state, at
most 16 a state (pipeline/dispatch_record.rs). A warm pass that creates such a
record's state then plans the dispatch as a creation's prediction plans its
first one (nothing bound but the default samplers), with the recorded
lengths, settles its variant as a dispatch does, and makes each region's
VkPipeline on the pass's thread, so their driver data lands in the records
under the names the program's dispatch of that shape asks for.
WarmStatistics::dispatch_pipelines_warmed counts them. Indirect dispatches,
dispatches of a threadgroup range and tile dispatches record nothing.
Records are immutable, one per dispatch shape, so a consumer keeps each once
and needs no rule for which supersedes which. The record format moves to 7:
a compute record's bytes now end in its dispatch list (count, then each
dispatch), so a format-6 record reads as none. The codec bounds the list at
16 dispatches and 31 lengths each, both when writing and when reading.
Tests: warm_record round-trips a compute record with a dispatchThreadgroups:
and a ragged dispatchThreads: carrying two threadgroup lengths, and bounds the
list (more than 16 is unwritable; bytes claiming 17, resealed, are no record;
16 read back). The device test
a_warm_pass_makes_the_pipelines_of_the_dispatches_its_records_name records a
state's creation and first dispatch, checks that the same dispatch again and a
grid of the same edge make and record nothing, warms both records on a
device over the same directory (dispatch_pipelines_warmed equals the regions
the recording dispatch made), and checks that the program's first dispatch
there hands each of its makings the driver cache the pass filled
(caches_shared) and translates nothing. A control device warmed with the
creation's record alone makes no dispatch pipeline and shares no cache.
Verification is in the report to main (potluck lint and lavapipe jobs).
Docs: the runtime README, HOWTO and FAST-PATHS ("Made again before the
program asks") describe the dispatch records; api_signatures gains the
WarmStatistics field.
At the tip the RTX 3090's 1 MiB frame alone took 0.93 times as long through
the fill queue (18358), against 1.04 in the two runs before (17900, 18199),
and the RTX 2080's 64 MiB one 1.04 times (18309, against 1.00 in 18167): the
trade sentence names both, and the swept size from which the fill queue was
within 1% alone in every run is 256 MiB, not 64 MiB. The tip's runs, whose
two devices both copy at the batch's start under 1 MiB, put them 0.31 to
1.85 times apart there (RTX 2080 18309, RTX 3090 18358, RX 7900 XTX 18310);
64 MiB beside the kernels at the batch's start took up to 49.4 ms, and the
other queue's share moved -11 to +8 points on the RTX 3090 and RTX 2080.
Verified: cargo fmt.
The ledger bullet and staging.rs's fill-queue docs take the ranges of all
the runs: 1 MiB beside another queue's kernels 1.80-1.84 against
3.53-3.60 ms on the RTX 3090 and RTX 2080 (18199, 18167, 18309), 64 MiB
35.9-37.8 against 40.6-48.9 ms, and on the RTX 5080 Laptop GPU 3.31-3.39
against 5.90-5.92 ms (18316, 18108). Under 1 MiB the fill queue's frames
took 0.51-2.03 times the batch's start's, but at the tip, where both of
the bench's devices copy at the batch's start under 1 MiB, the same bench
put them 0.31-1.39 times apart (18309): the sub-1 MiB differences are not
past the bench's spread, which the docs now say instead of a 2.0x loss.
Verified: cargo fmt.
At 1 MiB alone the RTX 3090's frame took 1.04 times as long through the fill
queue (jobs 17900 and 18199), and beside another queue's kernels half as
long; the swept size from which it is within 1% alone on all three NVIDIA
GPUs is 64 MiB. The owner's coordinator kept 1 MiB; the bullet says the trade.
Verified: cargo fmt.
The fill queue's own submission and the batch's wait for it cost small
copies more than the copy engine saves them. The sweep of
managed_copies_bench (a Managed buffer's copy in each frame, the fill queue
against the batch's start, p50) placed the crossover:
- RTX 2080 (18167): 128 KiB 1.04x alone and 1.11x beside another queue's
kernels; 256 KiB 2.03x alone (0.94 against 0.46 ms), 1.09x beside;
512 KiB 1.31x alone; from 1 MiB up 0.98-1.00x alone and 0.51-0.91x
beside (1 MiB 1.81 against 3.57 ms).
- RTX 3090 (18199): faster or within 4% everywhere; 1 MiB alone 1.04x
(reproduced, 17900), beside 0.51x (1.80 against 3.53 ms).
- RTX 5080 Laptop GPU (18108, before the sweep): 64 KiB 1.44x alone and
1.06x beside; from 1 MiB up 0.93-0.99x alone and 0.56-0.96x beside.
So FILL_QUEUE_LEAST is 1 MiB, the smallest swept size from which the fill
queue is no slower beside the kernels on any of the three and at most 1.04
times as long alone: Taken::take_fills takes the batch's fills only where
they write that many bytes in all (copies and zeros), and fewer stay at the
batch's start, as on a device without a fill queue. Decided from bytes, not
from the device.
The fill-queue test gains a last command buffer whose fills (a new Managed
buffer's zeros and its copy in, under half the least each) make no
fill-queue submission and read back exactly. The ledger's costs of
matching Metal gain the fill queue's bullet; the staging, create, bench and
README docs say the least and the measured numbers (the create.rs 82% came
from the raw example and is gone).
Verified: cargo fmt; device runs, lavapipe and lint follow.