df9ae6b02dcbd1580f7e8500ba1ff0a5ffbb3fcd
1144
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
df9ae6b02d |
Snapshot reads with no barrier: API.md's accepted difference covers writers
docs/API.md's accepted difference for a draw that reads its own pass's color at its own pixels with no barrier now covers a draw that writes the color too: it reads what the draws before it wrote where the runtime takes no copy for it (in place, or through a snapshot where the device takes that route and the snapshot costs no more than the copy: a surface's reader always, a private texture's by the area rule), else the copy, the M3 Max's texels. Its lead-in is the slug the pass-start-barrier read rows name. FAST-PATHS.md's row and texture/attached_reads.rs say the same, each naming both answers. Verified: docs only; the conformance unit test that the slug exists runs in the 780M job. |
||
|
|
090930eebf |
Queue times: a default-off diagnostic notes when a command buffer became its queue's head and when its submission returned
What: with METAL2VULKAN_QUEUE_TIMES set, each command buffer notes two host times beside its kernel times (gpu_time::KernelTimes), read through two hidden runtime-extension methods: - CommandBuffer::queue_head_time: its first batch became the first of its queue's batches the scheduler had not taken. Noted as the scheduler takes it in onto an empty line, or as the batch before it on its line is taken for submission (Order::next, in the scheduler's passes and a committing thread's). - CommandBuffer::submit_returned_time: the vkQueueSubmit that carried its last batch returned (submit.rs for a batch submitted now, group.rs for a group's members). kernelEndTime is that call's start, so the two bracket the driver's time in the call. Unset, nothing is noted and no line is looked up: a relaxed load of the device's flag (read once from the environment into gpu_time::Timing) per take and per submission. Why: walkprof5 (m3-max-22376) put commit -> submission start at 37.0 ms p50, while kernel start to kernel end was 0.008 ms, which does not bracket the vkQueueSubmit cost (the call starts at the kernel end). The consumer's trace needs to split commit -> submission into time behind the queue's earlier work and time held at its head, and to see each call's own length. Docs: env_vars.rs's registry entry and accessor, docs/API.md's diagnostics paragraph, the validation artifact note's list of variables the runtime reads; api_signatures.tsv blessed (two hidden methods). Tests: tests::kernel_end_device::queue_times_are_noted_in_the_order_of_a_queue_s_submissions_and_only_where_asked (three command buffers on one queue, committed back to back): unasked, both read 0; asked (Timing::note_queue_times, test-only), head <= kernel start <= kernel end <= returned for each, heads in commit order, and each submission returned before the next one's kernel start. |
||
|
|
8274894e15 |
API.md: a rate-mapped pass draws several regions in one multi-draw where the device allows it
The accepted difference "A rate-mapped pass draws region by region" now says where the device enables multiDraw, multiViewport, shaderOutputViewportIndex and shaderDrawParameters, a direct draw of a vertex pipeline records up to the least of maxViewports and one below maxMultiDrawCount regions in one vkCmdDrawMulti[Indexed]EXT, its vertex variant storing ViewportIndex as DrawIndex, with the same pixels. Docs only; the behaviour landed in the previous commits. |
||
|
|
62568021fd |
Region viewports: name the three features in the refusal; bless the API table and REFUSALS.md
The refusal under LoweringInputs::region_viewports lists its features literally, so the refusal surface names them (devices without shaderOutputViewportIndex, shaderDrawParameters or multiViewport). api_signatures.tsv takes the new fields and variants; REFUSALS.md the new sites. Verified: signatures.py --bless and refusal_surface.py ran locally (source-only). |
||
|
|
3591461c0b |
Memory log: each copy of a no-copy object's host pages says its caller's pointer and length as it is made and as it goes
An Iris boot lost its VkDevice to one float written into an ANV batch buffer right after the boot's one copied no-copy buffer was made. A copy's merge back writes exactly the bytes the GPU changed into the caller's pages, one 4-byte store for one changed float, so a caller mapping unmapped under a live no-copy buffer and reused for a batch mapping would show that symptom. The memory log (METAL2VULKAN_LOG_MEMORY) placed only device addresses, so it could not test that. With the log on, the copied registry (copied.rs) now says one line as each copy is made and one as it goes: its number, the caller's pointer and length with the range's end, and the copy's host address and end, the two ranges the runtime's comparisons write on the CPU. The going line is said after the registry's lock is let go, as the consumer's sink takes it. Off, nothing is formatted: the registry holds no log. Verified: fmt only here; the new tests::memory line test, clippy and rustdoc run on a CPU node next. |
||
|
|
182e21e83c |
Arguments that function constants put on overlapping slots of one table are an invalid request
Function constants can set an argument's slot ([[texture(c)]]; the frontend states the index as a
global the static initializer computes). Values that put two present arguments of one argument
table on overlapping slots make a specialization Metal refuses when it makes the function: "<kind>
argument X has invalid location (<index,count>)", naming the later argument. Measured on an M3 Max
(macOS 27.0.1) for:
- buffers, a constant buffer and an argument buffer;
- a visible and an intersection function table, and an acceleration structure;
- textures, and a texture array overlapping a range;
- samplers;
- threadgroup memory.
Arguments of two tables at one index (a buffer and a texture at 0) are made.
The translation took such a set as valid and went on. Where a write texture and a sampled one met
on slot 0, the slot plan gave the slot the write access and the sample was refused as
Unsupported(Lowering(Sampler)), NotImplemented: a gap that is not ours. Where the two arguments'
uses agreed, one resource stood for both, a pipeline Metal never makes.
The specialized entry now refuses it (canon::interface, beside the duplicate color output check),
as RequestError::OverlappingArgument { param, index, count } and
DescriptorError::OverlappingArgument. Only present arguments count (MPS keeps gated pairs on one
index), and a count of 0 binds no slot. past_table and the new check share one table map.
API.md, the runtime's new_function_with_name_constant_values doc (the runtime checks constants
when a pipeline compiles the function) and the specialization planner's doc say so. The
signatures table is re-blessed; REFUSALS.md is unchanged (this is a refusal Metal makes).
Verified: the canon test covers each table and the non-overlapping cases. The MPS census A/B
(590 rows, every constant 0, release CLI on msi, base
|
||
|
|
0a4f4e87f2 |
Labels: command buffers and encoders take Metal's label, and a lost device's notice names the hang by them
A lost VkDevice's recovery notice named its hang only as "a command buffer (of queue `Q`)", so an Iris boot's GpuHang (46 victims) left nothing to tell which work hung. The runtime had no label for a command buffer or an encoder at all. CommandBuffer::label/set_label (MTLCommandBuffer.label) and label/set_label on the blit, compute, render and resource state encoders (MTLCommandEncoder.label) now keep what the program sets. A command buffer has one encoder open at a time, so the open encoder's label lives on the command buffer's state, and the encoder's record takes it as it ends: each EndedEncoder reports its label, in its place, a render encoder that ends on the lowering thread included. The recovery names its culprit from the command buffer's state as it fails the pending batches: its label and its queue's, then its first 32 ended encoders' places, kinds and labels, counting the rest, e.g. "command buffer `busy` of queue `relayed` (its 1 encoder: 0 blit `copies`) failed as the hang (`GpuHang`)". set_label and label are no calls in EncoderCall's numbering. The API table, the Metal and conformance coverage maps, docs/API.md's DeviceRecovered entry and the runtime README say so. The table's WorkCounts::spare_command_buffers_freed_past_recorded line moves to where the script sorts it. Verified: fmt only on this machine; tests::labels (both lowering policies) and tests::device_recovery's relayed-loss test, which asserts the named notice, run on lavapipe next. |
||
|
|
ad402b548e |
Every VkPipeline the runtime makes is named for the validation layer's messages
Where the instance reports messages (VK_EXT_debug_utils), each pipeline now carries a debug name, which the layer prints after its handle. Until now only a raster-order pipeline was named, so a synchronization report could not tell a program's kernel from one of the runtime's own. - A program's pipelines are named by its Metal functions' names, in pipeline order, joined by " + ". Each variant's objects keep them (`VariantObjects::name_pipelines`), set where a compute variant is made (`pipeline/mod.rs`) and at each render variant's making (`RenderVariant::of`). A pipeline library is named the same, with its part in parentheses. An indirect-bindable replay pipeline takes its variant's names. - The runtime's own pipelines are named "metal2vulkan: " and the kernel or step: each owned kernel by its module (for example "metal2vulkan: PagesCopy(Gather)"), the split, merge, resolve, copy and plane steps by their kind, the in-place check's draw, and the priming's kernels beside its pipeline. - A raster-order pipeline keeps its name alone, since the validation crate's lanes match it whole (`raster_order_gap.rs`). - A name is worked out only where the instance reports messages (`DeviceShared::name_pipeline` takes a closure), and nothing reads it: it is a diagnostic, and no translation or runtime path depends on it. Why now: a sync-validation run on the XTX (SYNCVAL_SHADER_ACCESSES_HEURISTIC) reported 45 WRITE_AFTER_WRITE hazards. All were vkCmdDispatch after vkCmdDispatch, on one pipeline, at storage binding 1 of a pushed set 0. What the code points to, which the next run's names will confirm or not: - The runtime's pushed kernels are RowsCopy, PagesCopy and the shadow copies and merges. Of those, the ones whose binding 1 is a written storage buffer are PagesCopy(Gather), RowsCopy and ShadowCopyBack. - Only PagesCopy(Gather) records several dispatches in a row with one pipeline in one command: one per guest RAM chunk the runs touch (`host_ram/copy.rs`). Every one of them binds the same window of the destination buffer at binding 1. - That path is taken only when no destination byte is written twice (`twice()`; a gather whose runs share a buffer byte takes regions instead), so those dispatches write disjoint words. The tracker orders the copy as one command over its whole span. - The heuristic counts each dispatch as writing its whole bound range. So these would be reports of disjoint writes, not a missing barrier. - Guest kernels push set 0 too, so a program's kernel in a concurrent compute encoder is not ruled out. That is what the names settle. Docs: HOWTO section 8 says what the names are. |
||
|
|
bf359931a6 |
Spares, FAST-PATHS: the dynamic-pool gap states what the guest's core measured
A scan of every ANV command buffer in the crashed guest's core found the 1 GiB dynamic state pool held in full (1023.7 MiB over 2985 command buffers). Nine held 92 to 112 MiB each: the crashing recording, and four earlier command buffers whose two passes (one vertex binding, then four) each replayed an indirect command buffer over the rate map, two to a pool. So a guest's command buffer of one draw per region holds 184 to 224 MiB, and about five alive at once fill the pool. The gap says so as today's measure, not as a bound, since a route that records fewer commands per region changes it. Verified: docs only; the scan is m3-max-22188 (core read in place, streamed). |
||
|
|
01207df533 |
Spares: a command buffer that recorded much frees its pools' command buffers as it gives them back
A rate-mapped pass records each draw once per region of its map, each with its own viewport and scissor. On ANV (Mesa 26.2.6, Iris Xe) every such draw takes about 100 bytes of a device-wide dynamic state pool of 1 GiB. A command buffer holds what its recording took until it is begun again, reset or freed, and spare pools kept their command buffers' recordings for later takers. A guest's ICB passes over a rate map, replayed by host steps at about 880k draws a step, filled the pool with four command buffers alive. The core showed the "dynamic pool" block pool at its 1 GiB maximum, one command buffer holding 97.5 MiB of it, and its batch status VK_ERROR_OUT_OF_DEVICE_MEMORY. ANV then wrote the next SF_CLIP_VIEWPORT through a null state inside vkCmdDrawIndexed, and QEMU took a SIGSEGV. A command buffer now counts the draws its recordings record (its host steps' included) with the state commands they set (CommandBuffer::recorded, counted at render.rs's draw loop). Where the count reaches spares::RECORDED (65,536), each pool it gives back sheds every command buffer it holds, freed on the device's free thread as an idle spare's are, and rejoins the spares stocked with a secondary. Below the bound nothing changes. The rerun check's pool passes its command buffer's count. A kept chunk's pool passes 0, since its draws count in the command buffer that recorded them. Counted: WorkCounts::spare_command_buffers_freed_past_recorded (api_signatures.tsv). FAST-PATHS records the gap that remains: command buffers alive at once that record enough to fill the pool by themselves. Tests: tests::spares::device::a_command_buffer_that_recorded_much_frees_its_pools_command_buffers (lavapipe). The opt-in Iris probe runtime_lane::rate_mapped_volume (m2v_gpu_hazards) prints the new count per round. |
||
|
|
99146ff67f |
In-place reads: the lane test and docs name the devices whose passes fetch no color
A pass on a device with rasterization-order color attachment access (lavapipe) or without the pixel interlock (the RX 550) fetches its colors as input attachments, and in place, like the snapshot, takes no such pass (its subpass would name the color in two layouts). The lane test asserts the read in place only where the device's passes fetch no color, and API.md, FAST-PATHS.md and render/snapshot.rs say which devices keep the copy. Verified: lavapipe lane job m3-max-22227 (msi) at e83d75fe83: 33 of 34 attachment-read, snapshot and in-place tests passed, debug and under METAL2VULKAN_LANE_VALIDATION=sync; the one failure was this expectation (lavapipe fetches through inputs: copies 1, in place 0). |
||
|
|
7284147b43 |
A draw that reads its own color at its own pixels and writes none of it reads in place
A draw whose fragment function reads, at its own pixels alone, a texture its own render pass instance renders as a color, and whose pipeline writes no channel of that color, now reads the attachment in place, with a memory barrier before it or without: no copy, snapshot or split. The color is in the feedback loop layout for its instance, the pipeline is made with VK_PIPELINE_CREATE_COLOR_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT, and the slot binds the texture in that layout. A by-region barrier before the draw (color writes to fragment shader reads) orders the earlier draws' and the load's writes before its reads (Vulkan 8.10.5), and a by-region execution barrier after it (fragment shader to color output) orders its reads before later draws' writes. Its own writes go to other colors, so no fragment of the draw races another over the texels it reads. It reuses the snapshot route's checks (pass shape, view format, pins, one image) and its binding (render/snapshot.rs, in place), on a device that enabled attachmentFeedbackLoopLayout. Why: the real Macs disagree on such a read without a barrier (probe ownread.m: the M3 Max answers the texels from before the pass at every pixel; the 5300M answers the earlier draws' writes at 98.6% of pixels and at all after a barrier; the UHD 630 at all but 0.01%). Under the owner's rule for such disagreements we take the cheapest form, the x86 Macs' answer, recorded as an accepted difference in docs/API.md. A compositor's backdrop reads paid a copy of the whole target per draw before. texture/attached_reads.rs now gives a color's image feedback loop usage wherever the device enabled attachmentFeedbackLoopLayout, not only where it has the snapshot route's write-mask command. New WorkCounts::reading_draws_in_place (api_signatures.tsv row). The draw-key and graphics-key carry a feedback_loop bit for the pipeline flag. render.rs (the draw's snapshot plumbing) is touched at: the draw's snapshot request, the phase hole, the counts, the snapshot views, the pair base and phases, Recording::record (the barrier after), and settle_draw's snapshot checks. Lane test runtime_lane::in_place_reads with an owned fixture ipr_reads.metal (regenerated with scripts/regen-air-fixtures). The golden tables and the compile census are re-blessed on development. Verified: not yet compiled; potluck build, lint and lavapipe lane jobs follow. |
||
|
|
47ca9278c8 |
Pages beside live dma-buf imports import their own dma-bufs, not a copy
A no-copy buffer or heap (made or rebound) whose pages a live import of another holds some of was always a copy of them (CopiedBecause::OverImport), for VK_EXT_external_memory_host's undefined second import of a host pointer (its issue 6). On RADV every no-copy object's pages are udmabuf dma-bufs, which that clause does not cover, so since the one-import rule landed a consumer's 780M walk made 2715 such copies (copied_over_live_imports, 292 MB copied in). Now, where every live import that holds some of the pages is of dma-bufs, the pages come with a source of dma-bufs the device imports, and the device's barriers order blits through two imports of the same pages (no RuntimeDriverDefect::AliasedImportBlitsUnordered, which ANV and MoltenVK have), the object imports its own dma-bufs from the source, never its pointer (Device::imports_beside). Two dma-bufs of the same pages are two aliases of external memory (Vulkan 1.4, 12.11 Memory Aliasing: consistent for buffers, uses separated by a memory dependency); the tracker orders every use by the host bytes it touches across keys with global memory barriers, as for a guest RAM's run imported beside its chunk. A pointer import on either side keeps the copy. A failed import there falls back to the copy, announced with the failure. HostAliases::within now names the live imports that meet the pages (Within::Meets(Vec)). Counted: ObjectChurn::dma_buf_imports_beside_live (imports_inside_live stays the count of pages imported twice where that is undefined). Tests: tests::dma_buf_beside (device, Linux): a buffer over part of a live import's pages and a buffer rebound onto pages two live imports hold some of, as made and without pointer imports: beside dma-bufs where the first import is of dma-bufs, else a copy; the GPU reads the CPU's bytes, CPU writes between encode and commit reach the command, GPU writes reach the pages and the other buffer, and in imports a fill through one and a copy through the other in one encoder are ordered either way. The host_aliases unit test checks Meets names the import met. The validation lane's dma-buf joined-import test takes the third outcome. Checks: to run. |
||
|
|
3a619009b7 |
Run one-row threadgroups of a row-lockstep kernel on a variant without its simdgroup barriers
What: a kernel whose only simdgroup semantics are lockstep simdgroup barriers that order pairs meeting only where a simdgroup spans two rows (RowLockstep) kept them, their cross-lane class and, on a device with tangled 32-lane subgroups, its pinned subgroup size, even for a dispatch of one-row threadgroups, where no such pair meets. On the Iris Xe that pin makes ANV compile a register-heavy kernel at SIMD32, which spills and takes seconds where SIMD8 takes 0.3 s. - Address facts: a place among the threadgroup's linear threads (thread_index_in_threadgroup, and under rows thread_position_in_threadgroup's x, never the grid's) with its low five bits cleared (`& -32`) or shifted out (`>> k`, k >= 5) is one value per simdgroup (AddrFacts:: aligned, in fixed). The lattice walk skips such terms like uniform ones, and its spread now holds two facts, the finest lattice and the whole bounded difference, either clearing a pair. - Lockstep::rows holds where, under row facts, no conflicting pair wants more than a threadgroup barrier: threadgroup barriers stand where the whole threadgroup runs together, order every pair a simdgroup barrier would and need no subgroup size, so a one-row pipeline keeps them and drops only the simdgroup barriers (the argument is in Lockstep::rows' doc). - VariantKey::one_row / LoweringInputs::one_row: the lockstep pass inserts only the threadgroup barriers where rows holds; the kernel states RuntimeFact::OneRow (Mechanism::Variant). The binder asks a dispatch whose every region is one row of a RowLockstep kernel for it (dispatch_variant), the planned pipeline still runs such a dispatch, and the variant's plan sends a dispatch with a taller region back (NeedsVariant). The runtime settles on it through dispatch_variant and prepares it beside the base where a one-thread dispatch asks for it. Tests: engine_simd_emulated's a_one_row_dispatch_drops_the_lockstep_simdgroup_barriers on the Iris profile (a tile whose halves meet only across rows plus a workgroup-uniform pair): the own pipeline keeps its simdgroup and threadgroup lockstep barriers, CrossLane(BASIC), Direct and RowLockstep, and leaves the expected words at 144 x 2 (the shared lane's included); the one-row variant has one threadgroup lockstep barrier, no simdgroup one, (None, NoSubgroup), no subgroup requirement and OneRow, and leaves the expected words at 128 x 1 and 48 x 1 at 8, 16 and 32 lanes; the binder sends 128 and 48 to the variant and 144 x 2 to the base, whose plan refuses the variant 144 x 2; the kernel with a simdgroup sum keeps Direct and its own pipeline for 32, 128 and 144 x 2. a_row_of_a_lockstep_only_kernel_takes_one_compile now expects the one-row variant for one-row threadgroups of the row kernel, and the pinned pipeline for whole ones of the others. The mechanism table, the inputs-encoding test and api_signatures take the new items. |
||
|
|
b46459080d |
A batch held for its pipelines' making gives way to later commits of other queues
What: the scheduler's order across queues (scheduler/order.rs) no longer keeps the place of a batch held unsubmitted for a host step that has not taken its gate: its pipelines being made, or a step that reads nothing the GPU writes (`place_of`: `Place::GivesWay`). A later commit of another queue that conflicts with it on a resource goes first, and the held batch is submitted after it, so the tracker orders the two that way (submission order). The batches after it on its line give way with it. What still holds a head back behind such a batch is a fence the two share (`tracker::fenced`: one updates a fence the other waits for or updates, or a batch whose uses are not known yet against one that names a fence), so no batch is moved after a fence update it waits for. Unchanged: same-queue order, event and binary-semaphore waits (a batch waiting for the program still keeps no place), batches held for their submission checks or for a host step whose gate was taken (they keep their place: a later write going first would land after the step read), and the order among submitted batches. Why: on an Intel Iris Xe a guest process's cold compute pipeline took about 3 s to make; its command buffer kept its place, and the other processes' heads that conflicted with it (the window server's frames among them, over a surface they shared) waited behind it: the guest's display froze for 3.1 s. Metal's order across queues is the order the GPU takes the command buffers, not commit order: probes/cross_queue_surface_order.m's same-buffer control (one tracked buffer, written by queue A's long compute, then read or written by queue B's later commit) ran B before A once in three on a Radeon Pro 5300M and on a UHD 630 (macOS 26.7.1; m3-max-21850, m3-max-21851), and in commit order on an M3 Max (macOS 27.0.1). Where real Macs differ, the cheapest form inside them is taken; no switch, as matching the x86 Macs trades no accuracy. (The previous commit's message miscounted the no-copy buffer case: unordered in 10 of 12 runs, 6 of 6 on the M3, 3 of 3 on the 5300M, 1 of 3 on the 630.) Docs: order.rs's contract (**Tracked order across queues is the order the batches go**, **Held batches give way**, **No deadlock**), the scheduler's tracking and gate docs, WorkCounts::heads_held_for_earlier_commits, pending_dispatch.rs, docs/API.md's and the runtime README's pipeline-wait passages. Tests: tests::scheduler a_later_commit_goes_before_a_batch_held_for_its_making and a_batch_held_for_its_making_holds_back_a_commit_sharing_a_fence (the order's model; its existing a_later_commit_that_conflicts_waits_behind_a_batch_held_for_its_step is the kept-place control); tests::hold_sites a_head_that_shares_a_buffer_with_a_batch_held_for_its_making_goes_first (was ..._waits_behind_it: the fill completes while the dispatch is held, and the dispatch's words land over it), a_head_that_waits_for_a_fence_a_batch_held_for_its_making_updates_waits_behind_it (the fence control), and the host-alias leg, which passes again. |
||
|
|
aa2256b6e7 |
Order host-alias uses across queues again: Metal orders textures over one IOSurface across queues
Reverts a5634d48db and 3926d2d8c9, which left the uses the host aliases add out of the scheduler's order across queues on the strength of host_aliases.rs's line that Metal orders two textures over one IOSurface across queues only as the program orders them. The conformance probe probes/cross_queue_surface_order.m measured that case (queue A's long compute write committed before queue B's blit read of the same bytes, no event between them, three runs each): - two tracked textures over one IOSurface: B ran after A and read its writes in every run on an M3 Max (macOS 27.0.1, m3-max-21812, m3-max-21830), a Radeon Pro 5300M and a UHD 630 (macOS 26.7.1, m3-max-21850, m3-max-21851); untracked, the same but one run on the 5300M; - a texture of another surface (control): ran alongside A on the M3 and the 5300M; - two no-copy buffers over one allocation: B ran alongside A, reading stale or mixed words, on all three (8 of 9 runs; the 630 ran it one after the other twice); - one tracked buffer (control): ordered on the M3; the 5300M and the 630 each took B first once. So the alias keys' order across queues is the surfaces' order, which Metal keeps; dropping it was wrong for the consumer's surfaces, whose textures lie over per-texture no-copy buffers. host_aliases.rs now states those measurements, the plain no-copy buffers' among them, in place of the M4 line. The freeze the revert reopens (a held batch's making holding other queues' heads over a shared surface) is answered by the next commit, which lets a batch held for its making give way across queues, as the x86 Macs' GPUs may take a later commit first. Until that commit, tests::hold_sites::a_head_over_the_same_host_bytes_through_another_buffer_goes_while_a_batch_is_held fails as before a5634d48db (m3-max-21752). |
||
|
|
1b802ea45a |
Cross-queue commit order counts a conflict only on a resource both batches name
What: a use the device's host aliases add (host_aliases.rs: a no-copy buffer over the bytes of another, the consumer's textures of one IOSurface over their plane buffers) is now marked (`Use::aliased`). The scheduler's order across queues (`Footprint::conflicts`, behind `Order::is_behind`) leaves marked uses out, so a batch the runtime holds for a reason of its own (its pipelines' making, a host step, its checks) holds back no later commit of another queue that meets it only over shared host bytes. A use joined with one its command named stays named (join and merge keep `aliased` only where both are; `covers` lets no aliased use hold a named one), so two batches that name one resource still run in commit order, as Metal's tracking orders them. The tracker's barriers, inside a queue and on the GPU once both are submitted, take aliased uses as before. Why: on an Intel Iris Xe, one guest process's compute pipeline took about 3 s to make cold. Its command buffer kept its place in commit order (held for its making), and five other queues' heads in each scheduling pass, the window server's frame among them, conflicted with its footprint only through the alias keys over IOSurface pages they shared (heads_held_for_earlier_commits +5 per pass, footprints_built +2, the scheduler otherwise idle). The frame's present waits for its writers' completion, the guest's display pipe allows two unanswered presents, and the guest froze for 3.1 s. Metal orders two textures over one IOSurface across queues only as the program orders them (host_aliases.rs's measurement: an M4, macOS 27.0.1, plain and under API validation), so a later commit of another queue through another resource over those pages does not wait for an earlier one there; holding it was ours alone. docs/HOWTO.md's paragraph on copied and same-surface buffers says the same; the order.rs, scheduler gate and host_aliases.rs docs name the exception. Tests: tests::hold_sites::a_head_over_the_same_host_bytes_through_another_buffer_goes_while_a_batch_is_held (the previous commit) failed before this change on lavapipe (m3-max-21752: TimedOut, the fill waited behind the held dispatch) and is expected to pass after; tests::tracker gains a_use_the_host_aliases_added_orders_no_batch_across_queues (aliased-only overlaps unordered both ways, a named key on both sides ordered, a named use joined with an added one of the same range named); tests::host_aliases expects the added uses marked. |
||
|
|
a96e93f4da |
runtime_lane under sync validation: the layer's false positives become narrow claims, and the tests' own races are taken out
Under METAL2VULKAN_LANE_VALIDATION=sync on lavapipe the runtime lane failed 31 tests on the layer's hazard reports. At |
||
|
|
1d911cb848 |
FAST-PATHS: RADV refuses a dma-buf plane at offset 32 even at 256-byte rows
The probe on the Radeon 780M (m3-max-21640, Mesa 26.2.6): a dma-buf DRM_FORMAT_MOD_LINEAR plane at rows 256 bytes apart is made at offsets 0 and 256 and refused at offset 32 (VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT), and an image's memory offset must be a multiple of its own alignment (VUID-vkBindImageMemory-None-10735), so the gap row names the offset as well as the pitch. Verified: the cited device run. |
||
|
|
52a4f5c147 |
GenericPointer::Aggregate and the FAST-PATHS gap: what an aggregate's leaves do not follow
With an aggregate's generic pointers followed element by element, `Aggregate` refuses only a value no followed instruction makes, a part taken from a constant aggregate, or a constant expression in an aggregate constant; an aggregate loaded from memory is `Memory` and one that crosses a call is `Call`. The variant docs and docs/FAST-PATHS.md's known gap say so. docs/REFUSALS.md regenerates unchanged (0 variants without a reach mark or basis). |
||
|
|
079b8c8af3 |
FAST-PATHS: RADV's 256-byte rows hold on the RX 7900 XTX too
The probe on the XTX (m3-max-21379, Mesa 26.2.6) answers as the 780M: linear rows 256 apart for 18 RGBA16Float texels, explicit planes refused at rows 192, 384 and 1920 (offsets 0, 256, 32) and made at 256, minimum linear alignment 256. The row's lines are rewrapped. Verified: the cited device run. |
||
|
|
daf22e11d1 |
Docs: the red-held A8 route in the runtime README; NVIDIA's 128-byte rows and its ordered renders as known gaps
README: a read-only A8Unorm texture over a buffer, on a device whose A8_UNORM image lacks a feature in linear or DRM_FORMAT_MOD_LINEAR tiling and whose R8_UNORM image lacks none, has R8Unorm's image read through (0,0,0,R). FAST-PATHS known gaps: the RTX 3090 lays linear rows at multiples of 128 bytes and reports an explicit plane asked at 192 at rows 256, so glyph-sized A8 textures at rows 16 to 448 that are no multiple of 128 stay shadows there (m3-max-21480's sweep); and on the 3090 the check of renders over pooled memory makes no image (verdicts unchecked), so a render target over padded rows in ordered memory stays a shadow there (m3-max-21392, m3-max-21480). Verified: the cited device runs; cargo fmt. |
||
|
|
ed8b9a137b |
A texture that renders over padded rows in ordered memory is in place where the device's check of renders passed
linear_plan::holding refused every texture that renders over rows with bytes between them, ordered memory too (a Private buffer, a Managed one's own copy on a discrete GPU), since Vulkan lets a render pass's load and store read and write back any byte of the attachment's subresource. So each such render target was a shadow (BytesBetweenRows): 32 Managed textures at rows of 152 in 256 on reims's XTX walk. Now holding takes renders_kept: Device::ordered_renders_kept answers it where the device's policy takes images in place and its check of renders over its pooled memory (PagesClass::Pooled, Access::Renders, the texels' row ends) passed. That check renders into a linear image over padded rows, through its moves into the layouts a render takes, a pass that clears and stores it and a draw over its last column, while the CPU writes the bytes beside its texels, and passes only where every byte but a texel keeps what was last written: the owner's per-driver check, the same that takes images in place over host pages and pooled memory. In ordered memory no other agent writes those bytes meanwhile. The texture is then the device's linear image made PREINITIALIZED (Between::Kept), as one that only reads; a pending verdict starts the check, and a texture made meanwhile is a shadow. The pooled move path asks the same. Docs: the shadowed-texture notice (API.md), HOWTO, the degradation's declaration and linear_texture_bytes_per_row's doc say so. Verified: cargo fmt; unit test linear_plan::ordered_writes_let_a_ texture_that_renders_nothing_hold_its_rows_padding covers renders_kept (kept in ordered memory, refused outside it and over shared rows); device runs of tests::ordered_renders follow. |
||
|
|
f958409811 |
FAST-PATHS known gaps: RADV's 256-byte linear rows, and the short last row's documented basis
RADV lays a linear image's rows at multiples of 256 bytes and refuses a DRM_FORMAT_MOD_LINEAR image with an explicit plane at any other pitch (VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT), so an IOSurface plane of RGBA16Float 18x28 at 192-byte rows and dma-buf planes at rows 384 or 1920 bytes apart (offsets 0, 256, 32) are shadows there. The surface or dma-buf sets the pitch; no image of the device lays rows there. The short-last-row row now names the Vulkan rules that keep it a shadow (VUID-vkBindImageMemory-None-10737, VUID-VkImportMemoryHostPointerInfoEXT-handleType-01750). Verified (device probe tests::shadow_causes_device at 282341f5bb): Radeon 780M m3-max-21292 (rowPitch 256/512/2048, explicit planes refused at 192/384/1920, made at 256, minimum alignment 256); RTX 3090 m3-max-21293 (short last row Refused(Placement), a page longer InPlace); lavapipe m3-max-21290 (explicit planes made at 192/384/1920). |
||
|
|
12119c572d | GenericPointer::Memory and the FAST-PATHS gap: memory other than a closed thread allocation's slots | ||
|
|
039f6e5fbc |
FAST-PATHS: a replayed draw's attributes are among those the shader pulls
The GPU form of an execution's draws now pulls every attribute, so a normalized one there is the module's product, as the vertex conversion row states for the other pulled attributes. |
||
|
|
7cd885ea5b |
runtime_lane::render_merged_attributes: stage_in states' executions run on the GPU alone
The lane test of executions whose inherited state's vertex function reads [[stage_in]] attributes now states the GPU form, against the host step's pixels (a barrier the CPU set and cleared), for a kernel-written ICB of triangle draws and indexed draws (merged) and triangle strips (one draw per command), each command binding its own positions and per-instance marks at its own offsets, first/base vertex and base instance: - pulled_attributes_of_executed_draws_fetch_their_commands_elements: strides 10 and 6, which the shader fetches anyway (merged draws read the command's vertex and instance, not the merged draw's corner indices); - fixed_function_layouts_of_executed_draws_are_pulled: strides 8 and 4, marks at step rates 1 and 2, no vertex buffer bound at the encoder; - a_layout_of_a_stride_set_per_bind_keeps_the_host_step: a dynamic-stride position layout the commands bind at their own stride takes the host step, whose notice names the rule. The fixture gains ima_strips (a triangle strip writer). docs/API.md states the attribute rule in the indirect command buffer section and in the GPU form's list; api_signatures.tsv and api_surface.rs list draw_replay_vertex_layouts. |
||
|
|
729912a69e | ARCHITECTURE: SCCP's values of a few constants | ||
|
|
15866645a8 |
A generic pointer of no one space is refused as GenericPointer, naming how and where
canon::generic refused every generic pointer it could not give one address space as AddressSpace(8), with no location, so a caller could not tell a pointer of two spaces from one loaded from memory. Feature::GenericPointer (both crates) now names how the pointer gets a space only the run knows (TwoSpaces, Memory, Aggregate, Call, Integer) and the refusal locates the instruction where it does. AddressSpace's doc now lists 8 as defined; the planner treats a generic pointer that survived canonicalization as an invariant breach. FAST-PATHS records the gap, REFUSALS and the API signature table are regenerated, ARCHITECTURE names the pass. runtime_lane::generic_pointers compares generic_spaces and generic_null with the M3 Max's answers (run next on lavapipe). |
||
|
|
3a7568d5b4 |
A device can be made to open no dynamic library's file; only regular files are read
A pipeline creation loads, for each install name its stage's libraries name, the file that name names (dynamic_library.rs, `stage_with_dependencies`), and `new_dynamic_library_with_url` and a binary archive's descriptor read the file they name. Where the library bytes come from another party (a guest's metallib in a virtual GPU), its install names name any host path: `/dev/zero` grew `read_to_end` until the process ran out of memory, a FIFO blocked the creating thread for ever, opening a device file could act on the device, and any host file that parses as a dynamic metallib linked into the pipeline. - `DeviceOptions::load_no_dynamic_library_file` (and `RawDevice`'s), off by default: the device opens no file a library's install names name and refuses `new_dynamic_library_with_url` (`DynamicLibraryError::NoFileLoading`, new). A creation links only the libraries its function descriptors give (`libraries.preloaded`, `libraries.loaded` by install name); an install name `loaded` lacks loads nothing, so a creation whose import survives specialization fails `Compile(NeedsInput(DynamicLibrary))`, as Metal's does for a file it cannot load. - Without the switch, every such read goes through `container::read_file`: a regular file alone, looked at before it is opened, opened `O_NONBLOCK | O_NOCTTY` and looked at again through the handle, read once no further than its length when opened, a length the process cannot hold refused rather than allocated. A FIFO, device or directory loads nothing as an install name and is `InvalidFile` for `new_dynamic_library_with_url` and a binary archive. The stage_with_dependencies call sites (compute, render, mesh, tile creation) pass the device. Docs: the field's and variant's doc comments, the runtime README's options table, docs/API.md's accepted differences. api_signatures.tsv blessed (two fields, one variant); docs/REFUSALS.md regenerates unchanged. Tests, each failing without the change (a control commit neutralizing the gate and the regular-file read, run once): - tests::binary_archive::a_path_of_no_regular_file_is_no_archive_and_is_not_waited_on (CPU): a FIFO and /dev/zero are InvalidFile, each read bounded at 30 s. - runtime_lane::dynamic_libraries::an_install_name_of_no_regular_file_loads_nothing_and_waits_on_nothing (lavapipe): a FIFO's and /dev/zero's install names load nothing, the creation is refused NeedsInput(DynamicLibrary), new_dynamic_library_with_url is InvalidFile, each bounded at 60 s. - runtime_lane::dynamic_libraries::a_device_that_loads_no_file_links_only_the_libraries_it_is_given (lavapipe): with the switch, a client linked against A's real file is refused, A preloaded or not; given A in `libraries.loaded` it links A's values; new_dynamic_library_with_url is refused. |
||
|
|
9dc4b0c953 |
Runtime lane: argument_buffers lets the layer's writes after writes between its dispatches' apart words pass
Under METAL2VULKAN_LANE_VALIDATION=sync on lavapipe, two argument_buffers tests failed with
SYNC-HAZARD-WRITE-AFTER-WRITE between dispatches of the word copier on set 0 binding 1
(resource_ids_a_kernel_writes_name_resources_as_the_cpus_do,
addresses_a_kernel_writes_reach_buffers_as_the_cpus_do; privmem's m3-max-21017 and 21016).
These hazards are not races. Each copy writes 4 bytes, at owner offsets 4 bytes apart. The
runtime's tracker orders a serial encoder's dispatches by the plan's proven window (here 4 bytes
each, disjoint), so it records no barrier between them. The layer takes the descriptor's whole
range as written, and bind::descriptor_range binds that range from the offset alignment down, in
16-byte granules and 16 bytes at least, so to the layer the two ranges meet. Vulkan's memory
model has a data race only between operations on overlapping memory locations ("A memory
operation must not affect memory at a memory location not within its set of memory locations").
The lane's sync_coverage::disjoint_words_of_one_block_are_a_hazard_to_the_layer_alone already
shows this false positive word by word and names these reports. The runtime is unchanged:
adding barriers would only silence what the layer reports.
runtime_lane::apart_writes is a fourth claim form,
layer_reported_nothing_but_apart_writes(messages, claim, &writes). The test notes each
dispatch write as it places it (DispatchWrites: buffer, bytes). A message passes, with a
LAYER-APART-WRITES line, only when all of these hold:
- it is a SYNC-HAZARD-WRITE-AFTER-WRITE (not the racing form);
- both commands are dispatches (hazards::DISPATCHES, now shared with the sequences lane);
- it is on a VkBuffer the test noted two writes or more of;
- no two of those writes share a byte. The writes are read in VkBuffer space through
Buffer::vk_buffer, asked only once the work ran.
Everything else fails as layer_reported_nothing does. So does a message list the sink filled
(Messages::MAX, now crate-visible), since what it dropped is unread. The hazard text is read by
the sequences lane's parser (parity::sequences::hazards::parse, now crate-visible), not a second
one. Both tests now state that claim after each iteration's run. VALIDATION.md's claim-form table
gets the row. The table's last row and the paragraph after it had run together on one line; they
are split again.
Unit tests (no device) show these fail: a read after a write, a write after a read, the racing
form, a draw or a copy at either end, an image, a buffer not noted or noted once, and two noted
writes at one word or overlapping ones.
|
||
|
|
fbb1f7c6bb | docs/REFUSALS.md: regenerated after the heap texture beside a selected sampler compiles (one ArgumentBufferTextures site fewer) | ||
|
|
416f6aeb32 | Lane test and Metal answers for the sampler-table fixture; architecture doc | ||
|
|
126420d6a8 |
SCCP folds integer minimum and maximum of constants
A loop whose trip count the function constants decide through llvm.umax (a convolution kernel's max(tile / stride, 1)) kept the call unfolded, so its exit compare had no constant bound, reach could not follow the counter, and a 256 KiB private accumulator was refused against the device's 96 KiB (PrivateMemory 263240). The scalar llvm.umin, umax, smin and smax now fold over constants as ctpop, bitreverse and bswap do; integer minimum and maximum have one answer. engine_arith took its opaque integer bits from llvm.umin(C, -1); they now come from a volatile private word, which no pass folds. Verified: canon::tests::private_reach's clamped trip count (fails without the fold); the guest kernel at its constants compiles with 144 bytes of private memory on the rdna3 profile (scratch, m3-max-20815). |
||
|
|
131887a2e1 |
Merged draw replays take indexed draws, and each fragment its own command's slot table
A render execution whose records a kernel writes ran on the host step wherever the buffer's command types held DRAW_INDEXED, and the merged form refused any fragment function that reads buffers, since one merged draw had one fragment slot table. Now both stay on the GPU. - Indexed draws (DrawReplay::indexed, from draw_replay_indexed over the decided writes). The preprocess holds an indexed record where the policy and the INDEXED flag allow it: its arguments are [index count, instances, base vertex, base instance], and it writes a 16-byte index entry per command (the device address of the first index, its offset rounded down to the index size; the whole indices to the buffer's end; the size, 2, 4 or 0 for a draw without indices). An index buffer of address 0 or a bad index type is a RECORD fault; an address no resident range holds draws nothing and counts a resident miss; a position past the buffer reads index 0, as the encoder's indexed draw reads it. The merged vertex reads its vertex as the index at its position plus the base vertex, a u16 from its aligned word. An indexed replay that does not merge is refused (ReplayRefusal::IndexedApart): the runtime host-steps it (HostStepCause::Rule). - Per-command fragment tables. The merged vertex writes its command to a flat uint varying (IoRole::MergedCommand, VaryingKey::merged_command). A merged fragment that reads buffers takes it as an input and MergedDrawAddress as its push field, and reads its RootTableAddress as the header's tables plus command times the stride plus the fragment table's offset (bind::merged_fragment_table). The header grows two words (H_INDICES_AT 48, H_FRAGMENT_TABLE 52; MERGED_HEADER_BYTES 56). A fragment that reads [[primitive_id]] keeps the merged variant refused, so its executions host-step, as before. - Runtime (render/executions/gpu.rs): indexed executions take the merged form alone, no per-command fallback; one whose type does not merge host-steps with the rule named. The host-replayed-indirect-commands notice text names indexed draws that do not merge. - The fixture icb_merged_indexed (ours: kernels writing indexed draws of 16-bit and 32-bit indices with per-command vertex marks and fragment tints), its AIR companions compiled by scripts/regen-air-fixtures on the M3, and its AIR input golden. Verified: - metal2vulkan's draw replay, merge, stage IO, varyings, link and API tests, among them the new interpreter test of seven indexed records (u16 and u32 offsets, base vertex -1 over two instances, indices past the buffer, a residency miss, a bad type, a null buffer): 354/354 (potluck m3-max-20787, msi). - Clippy in every configuration (all features, each feature alone, the runtime, --cfg m2v_gpu) (m3-max-20812, msi); Rustdoc of both crates and 379/379 tests of the replay, AIR goldens, stage IO, API tables, refusals and catalogue (m3-max-20824, msi). - The new lane test merged_indexed_draws_draw_what_the_host_step_draws (16-bit and 32-bit: six commands merged on the GPU with no record read, each fragment its own command's tint, the same pixels as the host step's) with the other merged and range-read lanes: lavapipe 12/12 (m3-max-20811, msi), RADV Radeon 780M 10/10 (m3-max-20814, um790). - The golden icb_merged_indexed.txt was blessed under the pinned llvm-as (m3-max-20792); no other golden moved. The semantics and artifact format bumps, the golden re-bless and the census stay with the landing. |
||
|
|
c2b02c5269 | Static-initializer division by zero: the probe of what Metal answers, and the accepted difference | ||
|
|
e6df98ef2a |
Rebind a kept draw of another call or index buffer, not every step
A render encoder's draw that differs from its pipeline state's kept draw only in its call of the same primitive type (with indices or without), its counts and its index buffer or type, each read in place, now takes the rebound of a draw of other arguments instead of every step. The binder's redraw_apart_into writes the Vulkan draw, overrun, base fields and index use of any pair of direct draws (Ok(false) where a vertices-per-primitive field or a fixed-function fetch window sets them apart); the route check adds the two route parts a call or index type changes (a strip restarted at another index, a de-indexed variant); a draw of another index buffer is no draw moved (its uses meet a buffer the kept draw's did not: detached buffers and shadows are looked at again) and holds that buffer as every step does; the kept draw takes the new call. Same draws, bindings and pixels: the debug-assertion checks compare each rebound draw with every step's commands, writes, uses and recording; the new runtime test draws_with_indices_and_without_in_turn_are_rebound_with_their_call compares the commands and pixels with every step; the binder test covers the new pairs. Counter: draws_unlike_kept_call and draws_rebound_arguments in draw_costs compositor --counts. |
||
|
|
e17223aed8 |
A render execution's range read from a buffer runs on the GPU in the merged form
executeCommandsInBuffer:indirectBuffer:indirectBufferOffset: sent every render execution to the host step, even when the GPU wrote the commands and they merge into one draw. That costs a GPU-to-CPU round trip each time. Now an execution whose commands merge takes the GPU form whatever its range: - The draw replay gets DrawReplay::range_read. The preprocess runs over every command of the buffer. Each invocation reads the range (location, then length) from the parameters (DrawReplayLayout::range_offset). A command outside the range draws nothing. - The range is taken as the host step takes it (ExecutionRange::commands): clamped at the size. A location past the size, or an end past 2^32 - 1, draws nothing and reports RANGE once. - The binder refuses range_read unless the replay is merged and covers the whole buffer (ReplayRefusal::RangeRead). - The runtime copies the range's 8 bytes, where the encoder read them (indirect_execute::range_from), into the scratch's parameters between barriers, before the preprocess. - These still take the host step, and the notice names the rule: commands that do not merge (a strip type, or a rule of the merged form), and an execution whose records the CPU alone writes. The degrade notice's text (degradation.rs, docs/API.md), the render executions' docs and the upload arena's docs now describe this. The API signatures are re-blessed. Tests: - bind::replay::draws::tests::a_replay_that_reads_its_range_draws_the_commands_inside_it, on the CPU interpreter: seven ranges, including clamped, empty, at the size, past the size and past 2^32 - 1. Each command's arguments and the merged corners are checked, plus both refusals. - runtime_lane::render_merged_executions::a_range_read_from_a_buffer_draws_on_the_gpu_what_the_host_step_draws: four ranges, one written by a blit before the pass. The GPU form draws 8 merged commands and reads no record. Its pixels and execution report equal the host step's. |
||
|
|
2724757bbf |
A host step waits for the batches that wrote what it reads, not every queue's work
A batch whose host step records indirect commands the GPU may write waited, once otherwise ready, until every VkQueue completed what was submitted to it by then. A frame of a GPU-culling renderer (a kernel encodes the draws and their execution range, then several render passes execute them through the range) paid one GPU round trip per pass: each pass's step waited for the passes before it in its command buffer, and for other queues' unrelated work, though it reads only the records and the range the culling wrote. The range read made it worse: it was read from a copy recorded right before the execution, in the batch of the previous pass. Now the gate is taken from the hazard state where it can be (scheduler gate_of): - CommandBufferShared::step_reads names what a batch's host step reads on the host of what the GPU may write, where each segment whose step waits for the GPU is an execution (outside a block of command predication) or a render pass of executions whose uses commit bounded: their records and ranges (Deferred::host_reads, ExecutionRange::host_reads), with their host aliases. Anything else (an indirect dispatch, a loop's check, a staged gather, an indirect sparse update) answers None. - Tracker::last_writes answers, per VkQueue, the value of the last batch that wrote those bytes of the writes the state holds; None for an untracked resource. The state forgets only what completed, and a write that let an older entry go waited for it, so once each queue reached its value every GPU write to those bytes completed and reached the host (every batch ends with the barrier to the host). Every such writer is submitted by the time the gate is taken: earlier batches of the line went first, an earlier commit's conflicting batch on another line holds the head behind it (its footprint holds the step's reads), a later one waits behind it. - Where either answers None the gate is every queue's last submission, as before. - The range of executeCommandsInBuffer:indirectBuffer: is read in place where the host maps the bytes the GPU writes (Buffer::maps_gpu_bytes: not Private, not a Managed host copy on a discrete device, not a copied host buffer), through Buffer::read_mapped, which holds a no-copy buffer's pages while it reads 8 bytes so a detach and rebind meanwhile free none of them; a detached buffer runs nothing. The read is noted at the call as a command that reads the bytes (no GPU work), so the encoder's order, a detach and the hazard state see it as they saw the copy's. Other buffers keep the copy. - WorkCounts::host_step_gates_narrowed counts gates that left out work submitted before them; the conformance cost tables report it and never gate it (QUEUE_DEPTH: whether a gate falls below a queue's last submission depends on whether the host had seen the writer complete). - The HostReplayedIndirectCommands notice's cost, its catalogue entry in docs/API.md, the scheduler's and indirect_execute's module docs and the execution calls' docs say so. Tests: tracker a_host_read_waits_for_the_last_writes_of_its_bytes_alone (the writer per queue, no writer, a covering write on another queue, untracked, a queue past the count, retired). Lane depth_executions a_frame_s_executions_wait_for_the_culling_alone: a culling command buffer on one queue, a fill on another queue submitted before the frame, then a frame of two passes that execute the commands through the range: two host steps, both gates narrowed, both targets hold each kept chunk's depth. The existing depth_executions test now shares its workload. No Metal-visible behaviour changes: what the steps read and record is the same; they start earlier. |
||
|
|
605a99f639 |
A texture over a Private buffer at a pitch the driver takes only explicitly is in place: the GPU keeps its bytes
A Between::Kept texture (bytes only the runtime's ordered commands write; no render target) whose pitch the device's linear image does not lay on its own now takes route 2, the DRM explicit-pitch image (VK_EXT_image_drm_format_modifier, DRM_FORMAT_MOD_LINEAR), over the buffer's own memory, where the driver's reported rowPitch equals the buffer's pitch at offset 0 and the image fits. Checked per texture. Such an image starts UNDEFINED (VUID-VkImageCreateInfo-initialLayout-12478: PREINITIALIZED only with TILING_LINEAR; 01443 for external memory), and 7.1.1 lets the move out of UNDEFINED discard its range, so the first move keeps the bytes on the GPU: one span copied out to a scratch buffer, the move UNDEFINED -> GENERAL, the span copied back, in one ordered sequence. The submission taking a keep waits on every other queue's last submitted work, so the keep follows every earlier access to the span; later work waits through the first move's owners. Afterwards the image and the buffer alias as a linear resource (glossary, DRM_FORMAT_MOD_LINEAR; 12.11). Counted: WorkCounts::first_moves_kept, first_move_bytes_kept. |
||
|
|
89483d65cb |
An idle device lets go of its kept empty blocks and parked objects
What: a device keeps an emptied memory block for 10 s (KEPT_EMPTY_FOR) and a released image or buffer parked for 1 s (recycle.rs), and only let either go at a later call of the program: a release in the block's pool, a creation call (sweep_stale, from keep_room), or a recycler's park or take. A device whose program stopped making resources kept them until its next creation call, however long that took. The consumer's Iris Xe rerun showed it: after a guest application quit, 11 empty pooled blocks, 4 empty dedicated ones and the parked objects sat 33 s with no counter moving; the first creation call then freed 12 at once, and 7 empty blocks still stayed, the "one pooled block per pool" kept for good. How: one idle-sweep thread per device (idle_sweep.rs), started by the first creation call that may wait (Device::keep_room). A block kept empty, a block made ahead and an object parked each say when they may go (Due::by). The thread waits for the earliest of those moments, sweeps (recyclers first, then Memory::sweep_kept, the creation calls' sweep without its throttle), asks what comes due next (Recycler::due, Memory::sweep_due) and waits again, with no timeout when nothing is due. It sweeps at most once a second. It holds the memory, the two recyclers (now Arc'd), the functions and the counts, never the device. Its Vulkan calls run in an exit-guard section, and the teardown stops and joins it before the parked objects and the memory go. Freed blocks are posted to the free thread, which paces them as before. The pool's last empty block now stays only in the pools the runtime keeps room in for its own encodings' and commits' resources (Memory::keeps_room: the kept list, not a small heap's). That block is the room the next creation call's keep_room would make again. Every other pool keeps none past the 10 s. So the lasting spare is bounded at one block per kept pool and counted in WorkCounts::empty_memory_blocks_live. docs/FAST-PATHS.md's row says so and no longer claims "held until 10 s after the dip" for blocks that stayed for good. Verified: tests::idle_sweep (lavapipe, ms01). Private buffers and textures over several blocks are used by a command buffer that completes, one refused at commit (abandoned encoder) and one its submission check fails, then all are released and the device idles. Before this change (b11d8115f1, job m3-max-20498) it failed after 40 s idle: 32 images and 3 buffers parked, 8 pooled blocks live against 1 at the start, 512 MiB in the heap against 64 MiB. The unit test a_pool_without_room_lets_its_last_kept_block_go covers stale/stale_at with and without room. The after-run is in the report. |
||
|
|
6d9bc9f096 |
RuntimeGap::IndirectRenderCommands names the rule that refused it (IndirectRule)
One gap stood for a dozen rules: an execution of the other encoder kind's commands, a range a draw of the encoder may write, a command's memoryless texture slot, a color in another format, the shader-side depth test, a shadowed texture the call did not gather, residency past the call meeting a shadow's truth, an emulated mesh command's ordering, a memoryless attachment read past the pass, and on an Apple10 device the render states the commands set themselves. A consumer's log said "IndirectRenderCommands" for all of them, so a report could not say which one a program met (a public GPU-culling sample's host step on an RX 550 did not). The variant now carries IndirectRule (public, non-exhaustive, Copy), one value per site, and the error's text prints it: "not implemented in the runtime yet: IndirectRenderCommands(UngatheredShadow)". A family row of indirect render commands names FamilyRow, the summary of the others. No behavior changes: every site refuses where it did, typed as before. Tests that expected the gap now expect its rule: the other encoder kind (render_executions, indirect_command_buffers), a range a draw wrote (render_executions), residency past the call (buffer_texture_renders), mesh ordering (mesh_commands) and the Apple10 states (state_ids, command_render_states, families). docs/REFUSALS.md and api_signatures.tsv regenerated. A consumer that names RuntimeGap::IndirectRenderCommands names a rule now, or matches IndirectRenderCommands(_). |
||
|
|
3e5293679e |
minimumLinearTextureAlignment: every usage's pitch, at least the device's line
The answer was, per format, the smallest power of two from 16 at which a ShaderRead texture of every probed width took its in-place image. Two things it did not cover: - A texture that renders or that a shader writes takes the same in-place image with those usages, whose linear layout the driver may pitch otherwise. The probe now tries reading, reading and rendering, and reading and a shader's writes (USAGES), and answers the largest of the usages that ever lie in place (a usage the format's linear images cannot take has none). - The device's check of images in place measures lines of nonCoherentAtomSize bytes (in_place::RowEnds), and on the Iris Xe its renders and writes of texels that share a line with bytes beside them fail (the line holding a row's last texels is written back whole). ANV answered 16 against a 64-byte line, so a guest that laid a render target out at 16 put its texels in a line with bytes before them: a shadow. The answer is now at least nonCoherentAtomSize, "the size and alignment in bytes that bounds concurrent access to host-mapped device memory" (vkspec, Limits) (placed_answer). At it, a texture whose rows' bytes fill whole lines shares none with other bytes. Rows whose bytes are no multiple of the line keep their padding in their last line at any alignment, so on ANV those stay shadows for renders and writes whatever the answer; the docs say so. Metal's 16 stays where the device imports no host pages, for a format no usage brings in place, and where a probe failed. The record's VERSION goes to 2, so no answer of the old probe is read again. Expected answers (the venues' read answers with the line): ANV 16 -> 64, lavapipe 64, RADV 256, MoltenVK 16 (its line is 16). Tests: tests::linear_alignment's the_answer_is_the_usages_largest_and_ at_least_the_line (the rule over every committed profile's line, ANV's 16 before and 64 after); the lane's render-target test (previous commit) gains the same texture at Metal's 16, a shadow wherever the check failed such renders. |
||
|
|
cdcd787fb8 |
A render target's channel-order sibling views are views of its image
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. |
||
|
|
946ee6e0b6 |
Device::linear_texture_bytes_per_row: the driver's own linear pitch for a 2D texture
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. |
||
|
|
42e11abcd4 |
Textures over buffers only the device's ordered commands write hold their rows' padding in place
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.
|
||
|
|
9d184d13ec |
Heaps over host pages: a texture Metal tiles lies in the device's image over the pages first
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. |
||
|
|
13a8232d8c |
docs/API.md: maxThreadgroupMemoryLength among the presented Mac's answers
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. |
||
|
|
236340a171 |
A heap texture's observed residency is resident; a sparse member under it is refused at plan
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).
|
||
|
|
664b7617d7 |
The tile fixtures' lane and engine tests; SEMANTICS_VERSION 2040
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.
|