490db000524d93d8c0fa658fb403283f76e5a986
1151
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
6014ad370d |
Faces: a logged pass turns, and an encoding again meets the faces as first met
While the device has a buffer over host pages, every render pass logs its calls for a rebind, and a pass with a log, or with an earlier encoder of its command buffer keeping one, turned no texture (Unturned::Pass): under a consumer that keeps host-page buffers alive, no attached read ever took the turn and every one copied in. A logged pass now turns as any other. A rebind's encoding again of the command buffer's encoders meets the faces as their first encodings met them: the encoding again runs with a thread-local context of the command buffer and the encoder's parts (with_faces_as_of); a texture a later pass of the command buffer turned presents the face from before that turn to it (Faces::face), and the turning pass encoded again takes its turn again (Texture::retake_turn: the shadow of the face from before the turn held current, no copy in). Any other pass encoded again turns nothing. TurnPoint drops logs_kept; SwapRecord keeps the face it turned from. The shadow log (METAL2VULKAN_LOG_SHADOWS) also names, once per shadowed texture, at the first draw that binds it after its shadow was made: the slot, whether the function fetches, samples or writes it, and each sampler's min, mag and mip filters (a sampler state's by Metal's names, a constexpr sampler's as the layout bakes it). Tests: the runtime's attached_read_faces gains a lane with a host-page buffer alive (a logged pass turns; a blit and a turning pass behind a shared-event wait, encoded again by a rebind, read the texels from before the turn), against the same lane beside an open command buffer (the copy route); the validation crate's runtime_lane::logged_face_turns runs the same under the layer. Not yet run: dispatched next. |
||
|
|
7926fa6e66 |
SEMANTICS_VERSION 2062: the predicated walk's size estimate charges what the walk emits
The commit before this one. The emulated-simdgroup variant (a dispatch whose threadgroup leaves a partial simdgroup) took its size forecast from divergent::extra_words: 512 words per AIR block and 12 per operand use, about 15M words on a large kernel, so two kernels of a guest's path tracer (4.0M and 4.5M words emitted) were refused LimitExceeded(SpirvWords) before emission, where Metal makes them. The estimate now charges each construct the walk emits beyond the plain walk, from the structured tree (guards per segment, syncs and their guarded stores, reloads of demoted uses, flag and vote words per walked loop, arm sequencing per walked branch); each constant names the emitter code it bounds. Translation results change: modules that were refused now translate. Verified (on the branch): nextest -p metal2vulkan --all-features (m3-max-22642) 3500/3501, the one failure golden_hashes from SEMANTICS_VERSION 2061's pending re-bless (blessed since at pin 59; this commit changes no emitted word); the shared test helpers assert estimate >= emitted on every Emulated-tier or walked module the engine suites build; a_large_predicated_body_compiles_under_a_cap_it_fits (old forecast ~20x emitted). Lint m3-max-22643. Release translation, amd-780m-radv profile (m3-max-22644): the two kernels' emulated variants at 1.64 s / 256.6 MiB and 1.99 s / 287.4 MiB, within 20 s / 500 MiB. Census over the 3,781 simd/quad/barrier rows on vk12-floor (m3-max-22649) pending. |
||
|
|
cc694355b1 |
Residency: a device test of the release past the most, and the guide's and HostMemory's words for it
past_the_most_resident_the_least_recently_read_import_is_released: with the most held at two (Device::keep_resident_host_imports), three dma-buf imports read in turn; one released past the most, the least recently read; the other two read with no import again; the released one's next blit imports it again and reads the file's writes made meanwhile. It prints the free's and the import again's times. HOWTO.md and HostMemory::with_dma_buf say a device whose held imports cost every submission keeps at most 64 resident. |
||
|
|
f62966f4f0 |
did_modify_range's bytes are taken at the next commit, as Metal takes them
What: did_modify_range (and a CPU write through a texture over a buffer) notes the range on the device (managed.rs Modified); every commit, at its start and before it returns, copies each noted range of a buffer with a host copy on the CPU into staging buffers as the host copy holds it then (Buffer::upload_now, CallerCopy::copy_in_now, managed_copy::stage_in), which the next submission copies into the device copy before any of its commands. A range the staging buffers find no memory for falls back to the copy from the host copy as the submission runs. Why: the copy in read the host copy (the caller's pages through their import, or the runtime's own host copy) when the GPU ran it, so a CPU write made after the commit, before the GPU reached the command buffer, was what the command buffer read. Metal on a Radeon Pro 5300M (macOS 26.7.1, reims's oracle) takes the bytes at the commit after didModifyRange: a write before the commit (after the call, or with the command buffer encoded before it) is read, one made 30 ms after the commit while the GPU spun is not. Capturing at the call would be wrong (steps 2 and 3 read the later write there). An RX 7900 XTX computed frame 0 of a benchmark on frame 1's input this way. Docs: managed.rs and managed_copy.rs state the rule and its cost (a CPU copy of the range's bytes at the commit); API.md, the runtime README and FAST-PATHS.md's managed row follow. managed_bytes_copied_in counts a caller copy's copies alone, as before. Verified: the lane test of the parent commit on an RTX 3090 (job ids in the report). |
||
|
|
27cd4bccc0 |
Guest RAM: on a listed plan an object over a chunk not imported takes its own path and asks for no chunk
On a device whose plan is listed (each held import costing every submission and the RAM's chunks its dma-bufs: RADV, ANV where the import tax holds), an object over a chunk whose import was not made was bound in an import of its own run and asked the device's thread for the chunk, which faulted in and imported the whole chunk: udmabuf allocates every page of it and keeps them after the import is freed, so attaching runs to every no-copy object would make the guest RAM under every object resident chunk by chunk (12.3 GiB of a 16 GiB guest on the 780M before the listed plan). Now such an object is bound in the chunk only where its import is made, and otherwise takes its own path, as over memory no RAM holds: no run import, no ask. Chunks are imported for the copies over them, and the objects over them after that lie in them. Plans that import ahead (NVIDIA, host-pointer chunks) are unchanged. Removed with the object path: RunAgain, Routed::run_again, Placement::over_ram_run, the residency's AgainFrom::RamRun with Device::ram_run_in_chunk and ram_run_alone_again, and WorkCounts::run_bound_buffers_made (an object is never bound in a run import now; copies keep their ranges alone and run_imports_live). Docs: host_ram.rs, host_residency.rs, copy.rs, HostMemory::with_runs, driver_defects.rs, WorkCounts, HOWTO.md; the API signatures table re-blessed. Tests: the listed tests now import their chunks by copies; the first object over a chunk not imported, with a source of its own pages as a consumer's come, takes its own import, no chunk imported and none asked of the RAM's source, and the objects over a chunk a copy imported lie in it. The other host RAM tests lose their run-bound terms (0 on every plan they run). |
||
|
|
a7ba65dd66 |
synchronize_texture copies a Managed texture's bytes over a two-copy buffer out
What: on a device without unified memory, BlitCommandEncoder::synchronize_texture now copies a Managed texture's bytes over a buffer from the buffer's device copy to its host copy (the caller's pages, or the runtime's own host copy), as synchronize_resource of the texture already did. A level that lies in the image alone (a tiled texture's past its first) copies nothing; a texture of an image alone still records nothing, its CPU access reading its image. The copy is shared code: synchronize_resource's buffer and texture arms now call synchronize_bytes and synchronize_texels. Why: synchronize_texture recorded nothing on every device, its doc saying Managed memory behaves as shared memory. Without unified memory a Managed buffer is two copies (managed.rs, managed_copy.rs), and a texture over one serves get_bytes, and the buffer its contents, from the host copy (buffer_texture.rs Texels::read). So a program that synchronized with synchronizeTexture:slice:level: read the CPU copy as of its last didModifyRange: stale texels. Found reading the read-back paths for a benchmark that fails validation on an RX 7900 XTX. Docs: the stale doc is replaced; API.md and FAST-PATHS.md name synchronize_texture beside synchronize_resource for the copy out; the managed counters' docs count it. Verified: the lane test runtime_lane::device_copies:: a_synchronize_texture_copies_the_texels_out (a blit into rows of a Managed texture over pages and over a runtime-made Managed buffer, then synchronize_texture: the contents and get_bytes hold the rows; the copy out counted for the pages with two copies) is run on a discrete NVIDIA GPU with this change and once without the runtime fix (negative control); job ids in the report. |
||
|
|
7b27d0b63e |
Re-derive the generated documents at the landing tip
They are generated from the whole case set, and the set grew on `development` while this branch was in flight, so the copy committed here counted a smaller one. Verified: regenerating at this tip leaves no change beyond the `Generated at` stamp. |
||
|
|
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. |