090930eebf866b1c7a2c02c1b2097f66e9c12215
537
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
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. |
||
|
|
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. |
||
|
|
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. |
||
|
|
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. |
||
|
|
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. |
||
|
|
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. |
||
|
|
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. |
||
|
|
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. |
||
|
|
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. |
||
|
|
6b14f719d3 |
Clear a linear color attachment in place where the rule allows it
A pass that cleared a color attachment whose texture's image is linear and which the device renders under VK_NV_linear_color_attachment, where the rule allowed it in place, cleared an image its texture keeps and copied it back, announced linear-attachment-clear-copies, because clearing a linear image of host memory in place measured slower than that copy. A copy chosen for speed: the owner's rule keeps a copy only where the device lacks the in-place form. The pass now renders such an attachment in place whatever it loads. Removed with it: the Degradation kind (its API.md catalogue entry and its api_signatures row), the pass end's analysis of whether a command of the pass may read the attachment's bytes, which only that route used, and the lane and conformance expectations of the notice. through_backing keeps the one kind and area its callers still pass. Tests: the lane test of a pass clearing a render target over a Shared buffer (now a_cleared_render_target_over_a_shared_buffer_renders_in_place) counts it in place and through no copy on a device that renders it by the rule; the runtime's a_cleared_target_alone_renders_in_place forces the rule (lavapipe included) and counts 1 in place, 0 through copies, every texel the clear; it counted 0 and 1 before. |
||
|
|
6a951995e1 |
The lowest level a slot reads counts no size query: it reads no texel
What: LevelReads::lowest_read counted a size query at a constant level as a read of that level. A sample's lowering queries the level-0 size for offsets, pixel coordinates and bias axes (lower/sampler/emit.rs), so every such slot stated lowest_read 0 and no read past an attached level could read in place: the lane and runtime tests of the past-level reads counted the slots first-level or reaching (m3-max-20154, at 70b6b737e7 on lavapipe). A size query reads no texel, and the view a narrowed slot binds keeps the texture's first level as its own, so it answers the same at any level the view holds; the query still raises named, which keeps that level in the view. Fetches and gathers read texels and still count. Tests: level_reads::tests::each_read_states_the_levels_it_reaches (a size query at level 3: named 3, lowest_read none). Verified: built and run in the next job. |
||
|
|
6ab2d18f04 |
LevelReads and SampledLevels state the lowest level a slot's reads may reach
A runtime that serves a draw's read of a texture its own pass renders can read the texture's own image in place where every read reaches only levels past the highest attached one, but the fact gave only the highest level read. It now gives the lowest too: - LevelReads::lowest_read: the lowest constant level a fetch, size query or gather reads (a level-count containment's comparison reads no level, so it raises `named` alone). - SampledLevels::lowest_lod_bits: the lowest constant explicit level of detail through each sampler, a NaN where one is. - SampledLevels::lowest(SamplerLevels): floor of the lower bound of the level of detail, which Vulkan's LOD Operation clamps into [minLod, maxLod] after any bias (minLod where one is computed; the lowest constant plus a negative sampler bias, clamped so), the first level for a NaN constant or crossed or unbounded sampler bounds. Both mipmap modes read floor(L) or above. - LevelReads::lowest_level: the lowest among the reads; 0 where a read may reach any level. ARTIFACT_FORMAT_VERSION 503 (two encoded fields); the interface's other facts are unchanged, so SEMANTICS_VERSION stays at the NaN fix's 2040. api_signatures rows added; docs/API.md's "Levels a slot reads" says how to ask. Tests: level_reads::tests::each_read_states_the_levels_it_reaches (each read's lowest, and a fetch beside a level-count comparison: named 3, lowest 2), the_lowest_level_follows_the_bound_sampler, constant_levels_of_detail_keep_their_lowest_and_a_nan_there. Verified: built and run in the next job. |
||
|
|
0709ba7ba5 |
A sampler state's lodBias moves the level on a device presenting an Intel or AMD Mac
What: vk_sampler set mipLodBias 0 whatever the descriptor's lodBias, read as Apple9 (an Apple M3 Max samples every level as with no bias). The consumer's oracle (an AMD Radeon Pro 5300M and an Intel UHD 630) shows a Mac with an Intel or AMD GPU adds the bias to every sample's level, explicit (level()), gradient and implicit alike, clamped into the texture's levels. So a guest presenting such a Mac read the wrong level. How: the translator's SamplerUse gains lod_bias (with_lod_bias), a fact the consumer states per bind from the Mac it presents; a plan's uses leave it unset. With it, vk_sampler's mipLodBias is device_lod_bias's (new, public): the bias within the device's maxSamplerLodBias, the limit of its sign past it (Capped), none for a NaN (NotANumber) and none where the portability subset withholds samplerMipLodBias (Withheld). Without it, 0 as before; a use of texel coordinates takes none either way. Vulkan adds mipLodBias to an explicit level too, so the device's sampler gives the measured answer within the limit. The runtime keeps the resolved MacClass in DeviceProperties (one place, presented_class; lossless_compression derives from it). A state's taken descriptor keeps its bias on IntelOrAmd (-0 as 0, NaN as none) and 0 on AppleSilicon, and SamplerState::bound_use adds the flag at every bind: a slot's, an argument sampler's, a heap set's array element, and the attached-levels reckoning of the levels a draw samples. A bias the device cannot take as it is is announced once as the state is made, the new precision kind CappedLodBias (capped-lod-bias), never fatal. Docs: vk_sampler, SamplerDescriptor::lod_bias, the runtime sampler module, MacClass and DeviceOptions::mac_class name the answer per class; API.md's catalogue lists capped-lod-bias and the Mac-class section the bias. The api_surface and api_signatures tables take DeviceLodBias, device_lod_bias, SamplerUse::lod_bias/with_lod_bias and the new kind. REFUSALS.md regenerated unchanged. Tests: metal::sampler's a_lod_bias_is_the_device_s_where_the_use_adds_it (every committed profile, both uses) and the_device_lod_bias_is_the_bias_within_what_the_device_takes (exact, capped finite and infinite, NaN, withheld on MoltenVK's profile); tests::sampler takes the bias per class; the lane's lod_bias tests a device presenting each class: AppleSilicon reads the unbiased level (kernel explicit, fragment implicit), IntelOrAmd the biased one, the capped ones announced once (CAPPED_LOD_BIAS, listed as a site). Evidence: potluck jobs in the report to main. |
||
|
|
20a186a87e |
Docs: a heap texture's answer under each HeapAnswerPolicy
The heap module's size-and-alignment bullet, the heap-texture-larger-than-metal declaration and its catalogue entry, docs/API.md's heaps-and-memory bullet (which said every answer was the device's image's, where the code answered Metal's model) and WorkCounts::heap_textures_refit now say what each policy value answers: under Device the larger of Metal's answer and the route's image within the 64 KiB and 4 KiB-or-size bounds, the 4 KiB image in its place past them; under Metal, Metal's answer held by a refit or a shadow. Verified: cargo fmt only; docs alone, no code moved. |
||
|
|
ee9e1140b1 |
API.md: a texture's size never makes a texture over the runtime's own memory a shadow
The clause the bound's removal left read as a trailing participle; it now states the rule. |
||
|
|
0d144ec0de |
Pooled memory: no bound on a texture's bytes; ShadowCause::LinearCost is gone
The owner, through reims: zero copy, in place where possible, shadow copies a fallback and never a first option. A tracked texture over a Private buffer of the runtime's pooled memory whose rows the device's own linear image lays out otherwise was a shadow past 48 KiB to its pitch (TextureShadowReason::LinearCost), a speed choice measured on an Iris Xe alone that shadowed 1001 of an RTX 2080 guest boot's 1366 textures. It now takes its DRM_FORMAT_MOD_LINEAR image at Metal's pitch at any size, wherever the device makes one and its check of the pooled memory passed, as a texture over a Shared buffer already did; it is a shadow only where the device makes no such image (its format, usage, pitch or limits), its policy is HostPageTexturePolicy::Shadow, or the check failed or is pending (a pending one still moves in place once it passes). Removed with the bound: in_place::POOLED_PITCHED_BYTES, ShadowCause::LinearCost and the public TextureShadowReason::LinearCost (a breaking change of metal2vulkan-runtime's surface: api_signatures.tsv loses its variant), texture_spans.rs (the runs of bytes textures were made over, which only the bound read) and the moves it fed (MoveAfter::Aliases, LoneShadow, the buffer's note and wait), Texels::only_commands_write (the bound's alone), the bench behind the bound (runtime_lane::pooled_draw_costs, its crossover additions included) and aliased_surfaces' cost bench. aliased_surfaces' first check now asserts every texture over one surface's bytes takes the image at Metal's pitch, the first included, and a read copies nothing; its one-after-another check, about the first texture's shadow, is gone. storage_over_buffer is one function again (REFUSALS.md regenerated for the name). API.md, HOWTO.md, FAST-PATHS.md (the in-place row) say "at any size". RUNTIME_VERSION is not bumped here: the landing bumps it and re-pins the runtime sources. |
||
|
|
ba69642609 |
Copied buffers: a comparison splits across up to eight threads, not four
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). |
||
|
|
13d05be0a4 |
Copied buffers: a comparison splits across threads from 4 MiB, not 16
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. |
||
|
|
7c5a452dac |
Submission checks: a submission that never completes stalls them at 10 s, and the teardown returns
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). |
||
|
|
3b986605e3 |
The host-deallocator-delayed kind announces the wait for a buffer bound inside the import
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). |
||
|
|
3aa410e2ab |
A device refused for want of resources takes its least plan whatever the code: too many objects and host memory too
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. |
||
|
|
37db40177b |
Command queues take the VkQueue the fewest live queues hold; unshared ones an empty one under every verdict
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. |
||
|
|
b649078d10 |
Docs: a buffer bound inside a no-copy buffer's import holds its keep-alive, or its deallocator
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. |
||
|
|
88af28874e |
Host RAM: an object's own import claims its RAM pages until noted; chunks mark in flight under the claims
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. |
||
|
|
53501197a8 |
Host RAM: an object across two imported chunks is a copy, never a second import
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. |
||
|
|
8cb5400e78 |
Pooled bound: a texture over bytes another texture was made over takes the image at its pitch
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 (
|
||
|
|
d277b155e2 |
Shadows of a tracked Private image stand across command buffers, stale inside a rectangle
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). |
||
|
|
0e53ff56d5 |
Docs: the fill queue, where a batch's fills run, and what waits for it
device/staging.rs documents the fill queue: why (a copy through the graphics family runs on the engine the kernels run on; the 3090 and 5080 numbers so far), why not the staging queue, what it waits for, what waits for it (with the spec's semaphore and sharing text), what it holds, and what stays where it was. first_move.rs and managed_copy.rs say where a batch's fills go. Queue counts: the plan takes 18 queues on NVIDIA now, so the measured 17- and 2-queue devices are named by their queues, and the least plan keeps the fill queue as it keeps the staging queue. |
||
|
|
b3a9bda684 |
Docs: copied-host-pages names pages a live import holds some of; listed runs alone described where they stay
API.md's copied-host-pages entry gains the over-a-live-import cause (copied_over_live_imports, announced once per device as the others are). HOWTO's listed-plan paragraph described its runs alone "as above", text the previous commit removed: it now says what a listed RAM's run import is (a dma-buf), what it costs, how it orders, and that MoltenVK and ANV import the chunk instead. |
||
|
|
e97d5da60c |
Docs: HelperBranchDropsSimdgroupStores also covers a call in no branch that SPIRV-Cross writes in one
The catalogue entry and the variant's rustdoc name the new case: a ?: arm, the right side of a && or ||, or a selection's arm, where the call's value is read once (spirv::helper_branches). |
||
|
|
5175cca5b4 |
Pipeline creation log: a compute line names its kernel's descriptor, and the dump writes compute modules
A compute pipeline's line in METAL2VULKAN_LOG_PIPELINES named the kernel's function, its SPIR-V
hash and length, its specialization constants and notes, but not what the kernel was made from:
a cold boot's slow compute creations could not be made again off the device, because the
function's Metal constant values were nowhere in the log, and METAL2VULKAN_DUMP_PIPELINES wrote
render modules only.
The compute line now ends with `; descriptor: ` and the same naming a render state's first line
gives each function (its name, the SHA-256 of its bitcode, the constant values by index and by
name with their types and bytes), from one helper both share (`render::logged_function`). With
the dump directory set, the line's module is written there as `<hash>.spv` (`dump_modules`, the
render dump's writer, now over any modules), and a failed write is named in the line as a render
line names it. Nothing is kept or measured while the variables are unset: the descriptor's text
is made only where the log is on (`compute_kernel`).
The creation log's module doc also names the record words the split prints since the record
naming change (`record's cache shared`, `found in cache`, `compiled`).
Test: `opencl_data::the_pipeline_creation_log_names_a_compute_pipeline_and_its_notes` now runs
its child with the dump directory set, and asserts the line's descriptor (the kernel's name,
`air`, `constants {`), no dump failure, and a SPIR-V module (its magic) at the hash the line
names. It and the creation_log unit tests, and lint, run on this commit as jobs after it is made
(the report names them); a failure is fixed forward.
|
||
|
|
5a1e043784 |
A driver cache record names its pass without the attachments' formats
A render making's record of the driver's data, and the libraries of its pre-rasterization and fragment shader parts, were named by the pass shape whole, formats included. A program that makes one state against passes that differ only in a colour attachment's format (RGBA8Unorm, RGBA16Float, BGRA8Unorm) so got one VkPipelineCache per format, and the driver compiled the same fragment module once in each: on the Iris Xe (ANV, Mesa 26.2.6) 3.3 to 3.7 s per compile for one large module, three times over at a cold start. No stage's conversion reads an attachment's format through the pass: a format the translation reads is in the stage's own words and constants, which name the part's record too. So a part's record now names the pass by PassShape::without_formats (which attachments it has, its samples, fetch inputs, unread inputs, storage attachments, view mask and locations), and the depth bias is left out of it as before. The library names the runtime keys its own library objects by keep the formats (the libraries are made against VkRenderPasses, which must be compatible); only the driver cache record is shared. A driver that does key a stage by format keys that entry apart in the one cache: a compile, never a wrong pipeline. The record-naming version (shader_cache/driver.rs VERSION) goes to 3. METAL2VULKAN_LOG_PIPELINES now says, per library, whether its record was loaded, missed or its cache shared with an earlier making, and whether the driver found it in that cache or compiled it (from VK_EXT_pipeline_creation_feedback). Measured before the change (a harness making the module's fragment library against three passes on the Iris Xe, MESA_SHADER_CACHE_DISABLE): a cache per format, 3.5 s, 3.7 s, 3.3 s; one shared cache, 3.5 s then 0.0 ms and 0.0 ms, the second and third APPLICATION_PIPELINE_CACHE_HIT. Tests: record_pass_formats (a pass's record name drops formats, keeps presence, samples, fetch inputs and view mask); driver_pipeline_compile::creations_over_colour_formats_take_the_first_s_records (two makings over BGRA8Unorm and RGBA16Float share the first's record, caches_shared grows by the makings, one fragment library compiled, while a constant that changes the module keeps its own record); creation_log's text test. |
||
|
|
e393b10cb7 |
Half + - * on the device's 16-bit arithmetic take the AIR's own contraction
A half fadd, fsub or fmul on the device's 16-bit arithmetic (ArithStrategy::F16: MoltenVK, measured, and the float-controls profiles) was always kept apart: a sum or difference decorated NoContraction and a product as Fma(a, b, -0.0) decorated NoContraction, whatever the AIR's flags allowed. That holds Metal's exact half bits at the cost of every fusion the flags allow (AGENTS.md rule 1: the device's native arithmetic). It now decides as float does (contraction()): an operation whose flags carry both contract and reassoc is undecorated, its product a plain OpFMul, and the device's compiler groups and fuses it; any other keeps today's form. Notes mirror float's: note_rewrites already records FastMathRewrites where a neighbour can be rewritten. On MoltenVK, Metal's fast compile folds an undecorated 16-bit operation's conversions away and answers the float result unrounded (the MetalHalfArithmetic measurement), so there a fast operation records FastMathRewrites, whose doc (and docs/API.md's catalogue entry and the FAST-PATHS device-gap row) now says so, and requires no MetalHalfArithmetic, which the kept form still requires. On an owned proxy (hnq_half_layer_composite) on the Iris Xe, the step-1 prototype of this form cut the SIMD8 cycle estimate from 58584 to 33092. Tests: f16_binary's rounded-result and one-instruction tests under both contractions; half_arithmetic_on_the_device_takes_the_airs_contraction compiles fast, contract-only and flagless half + - * on every profile that computes them in 16 bits and checks the instruction, its decoration, the note, the requirement and the interpreted answers. |
||
|
|
edbd81a4df |
Docs: a copied host buffer's device base, its host blocks and its reads back on the staging queue
FAST-PATHS' base bullet gives the host's uncached reads of a device base (9-16 us a block awake, 170-206 us idle on the RTX 5080 Laptop GPU's host), the blocks kept on the host, the read back of 32 blocks or more on the staging queue with the crossover bench's figures on the 5080 and the RX 7900 XTX, the GPU's wake from power-down a copy may wait for, and the first and later merges back of a 256 MiB copy both sides wrote whole. Its cost bullet gives the quiet gem10 run's figures (job 17408), and its kernel bullet the 5080's pass figures (job 17417). HOWTO and API.md name copied_base_host_blocks and copied_base_blocks_read_back. Earlier commits 4af4a8665b and 7a93903404 carried doc edits with their code (the split's sentence in API.md and HOWTO, copied.rs's cost bullet). |
||
|
|
d2f862c193 |
Copied host buffers: a split comparison's threads take their runs with the runs' lock let go
The pull loop's while-let held the lock of the runs' iterator through each run's work, so the threads took their runs one after another. The lock is now let go before the work, as a let statement drops its temporaries. |