dad0470c2e8402b2fc85229bc01acd7ac0fa9678
489
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
dad0470c2e |
A flagged fan-out draw is drawn in parts: only its flagged range region by region
Under DevicePolicy's RateMapRegionPolicy::FanOut the probe flags a draw that has a triangle crossing w = 0 or reaching more regions than the geometry stage's copies. The whole draw was then recorded region by region, once per region of the map (2074 for a 61 by 34 map), however few of its triangles were flagged. The probe now also records each flagged draw's first and last flagged triangle. A flagged list of triangles of one instance, whose pipeline reads no [[primitive_id]] and writes no memory (the conditions under which a draw is already cut into index ranges), is drawn in up to three parts in its place: the triangles before the first flagged one fanned out, those from it to the last region by region, and those after fanned out. Each part is a range of the draw's vertices or indices, so each triangle keeps its vertices, vertex_id and order. Parts of a 16-bit index list begin at even triangles, so their ranges start 4-byte aligned as the draw does. Any other flagged draw is drawn region by region whole, as before. The probe words grow from 1 + 2*32 to 1 + 4*32 per draw (bind::fan_out::PROBE_DRAW_WORDS). For a flagged triangle the probe raises one of 32 words to u32::MAX - PrimitiveId and one to PrimitiveId + 1, picked by PrimitiveId as the counts are, so no single word takes every atomic. The wide marks that choose the variant of four copies now come only from triangles the probe does not flag, so the fanned-out parts can take that variant. Also: WorkCounts::rate_map_probe_wait_nanos sums the host's wall time from each probe's submission until it saw it complete, so a walk can split host_step_nanos into the probe's round trip and the host's own recording. rate_map_parted_draws and rate_map_parted_region_triangles count the draws in parts and their triangles drawn region by region. An earlier attempt drew a flagged draw through a geometry stage of 32 invocations, each taking a block of up to 16 regions, in 5 passes over the map. On the pieces lane's frame with wide triangles it made no GPU gain on an RTX 2080 (41.0 against 42.9 ms warm). On a Radeon 780M (RADV) it went from 182 to 1900 ms, with one piece of 1.1 s. That attempt is not in this change. Tests: render::fan_out's unit tests check that the parts take each triangle once, in order, with no flagged triangle in a fanned-out part, and that the probe's words decode to the first and last flagged triangle. The link test checks the probe's two atomic raises. The runtime's rate_mapped_fan_out test adds two commands that draw the grid with one triangle over half the target, one indexed and one without indices, and a triangle across w = 0 over the whole target. Under FanOut all four flagged draws are drawn in parts and the frame is compared pixel for pixel with the encoder's region-by-region frame. The pieces lane's wide frame checks that every flagged draw is drawn in parts. |
||
|
|
2d98657ca8 |
A Managed buffer's pages that a guest RAM's chunk imports hold are copied in by the GPU from them
What: a Managed no-copy buffer on a device without unified memory can have
a host copy that is its pages alone, because its own import would map pages
a live import holds or the device refused it. Where a guest RAM's chunk
imports hold all of those pages, it now keeps the pieces of those imports
(host_ram.rs RamOnDevice::pieces_of, ChunkPiece). The caller's resolver is
still asked once: its answer is kept for the pieces.
- Its copies in (as it is made, at a rebind, and each range
did_modify_range names under AtSubmission) are GPU copies from those
imports' VkBuffers, one per piece. They are held as a host copy
(Keeps::HostCopy): nothing is staged, no bound applies, no submission is
made. AtCommit still stages a named range on the CPU at the commit.
- New public WorkCounts, so a pass can tell the paths apart:
- managed_bytes_staged_in, the bytes the CPU staged for copies in;
- managed_bytes_copied_in_from_ram;
- managed_pages_alone_refused, managed_pages_alone_over_imports and
managed_pages_alone_unwritable, why a host copy is its pages alone;
- managed_pages_in_ram_chunks.
- Tests: tests/host_ram_managed.rs, a buffer across a chunk's end with
both chunks imported, under both policies. It checks the counts (pages
alone over imports, held by the chunks, nothing imported, gate unasked),
the bytes the GPU reads as the buffer is made and after a named CPU
write across the end, and which path copied them.
- Docs: managed_copy.rs, managed.rs, buffer.rs, HostMemory::with_runs,
docs/API.md, and FAST-PATHS row 51. Signatures blessed.
Why: such pages were staged by the CPU at every commit that took a named
range. That is a CPU copy and staging memory, on the commit's thread, for
bytes the device already maps through the chunk imports. Zero copy first.
Verified: not run at this commit. The 2080 equality tests and the bench
(before at the bench commit, after here) and lint follow on the rebased
branch.
|
||
|
|
10f2539a71 |
8-bit floats widen through the device's own type where it has one
Owner rule 1: where a device has a native 8-bit float type, its conversion is the only form.
VK_EXT_shader_float8's shaderFloat8 (the SPIR-V capability Float8EXT, SPV_EXT_float8) is now a
VkFeature the device enables and the profile reads (leaf.float8); the SPIR-V IR has
Type::Float8 { encoding } (OpTypeFloat 8 with its FPEncoding, from the regenerated grammar items),
and the interpreter reads OCP's E4M3 and E5M2.
The shared decode, narrow::fp8_to_f32, widens through the device's type where the layout names
one (Fp8Layout::on): each u32 lane bitcast to four 8-bit floats, the low byte's widened by
OpFConvert, so no 8-bit integer type is needed. f8e4m3fn and a tensor's e4m3 take Float8E4M3EXT,
f8e5m2 and a tensor's e5m2 Float8E5M2EXT; the IEEE-like f8e4m3 has no device encoding and keeps
the integer decode. Every site takes it: air.convert's 8-bit float sources, simdgroup-matrix fp8
cells, and matmul2d, whose expansion now widens each element by an air.convert of the tensor's
format (Fp8::TensorE4M3, Fp8::TensorE5M2: Metal's reading, qualified on the M3 Max, e4m3 with no
specials, e5m2's NaNs 0x7FC00000; never parsed from a name, built by Out::air_call). A device
without shaderFloat8 decodes with integers, as before.
Where a tensor's element widens natively the stage records PrecisionNote::NativeFloat8
(native-float8): the device's e4m3 reads 0x7F and 0xFF as NaN where Metal reads 480 and -480,
and an e5m2 NaN's bits are the device's. Validation classes it Unbounded; the conformance suite
lists it among the native notes; FAST-PATHS.md has its device-gap row and API.md its catalogue
entry. The other formats record none: Metal on Apple M3 does not compile them.
The refusal of a matmul2d of 8-bit floats on such a device (Entry::float8_products, the select
check) goes. REFUSALS.md and api_signatures.tsv regenerated.
Tests: matmul2d's fp8 fused sums on the RTX 50 profile (Float8EXT declared, the note recorded,
e4m3 NaN sums) beside MoltenVK, RADV and lavapipe (neither); air.convert widenings on the RTX 50
profile and lavapipe; simdgroup-matrix fp8 cells on the RTX 50 profile too. Not yet built here:
the build and these tests run next on the cluster.
|
||
|
|
a0e7b75ad6 |
The copy-in ledger row states the measured cost of AtCommit
What: docs/FAST-PATHS.md's managed_copy_in row gives the copy-in bench's medians on the RTX 3090 (eGPU) and the RX 7900 XTX: the commit call and the wall time to completion of 32 MiB commits under both values. Why: a ledger row states the cost of its accurate form. Verified: jobs 24627 (3090) and 24636 (XTX), two rounds each, both values. |
||
|
|
9f3dc79994 |
A Managed buffer's named range is copied in by the GPU as the submission runs, by default
What: DevicePolicy gains managed_copy_in (ManagedCopyInPolicy, a runtime choice no profile carries). Under the default, AtSubmission, a commit that takes a did_modify_range's range has the GPU copy it from the host copy (the import of the caller's pages, or the runtime's own host-cached memory) into the device copy as the submission runs (Buffer::upload), with no CPU copy and no staging. Pages no import maps are still staged by the CPU at the commit. Under AtCommit, which exact_answers() selects, the commit copies the range on the CPU as the host copy holds it then (the RV2145 snapshot, Buffer::upload_now, now upload_at_commit). Staging buffers of both directions are now Shared in the default CPU cache mode, host-cached system memory, never the device-local (BAR) memory a write-combined buffer prefers without unified memory, and of power-of-two lengths (64 KiB at least), so a like-sized later copy takes a buffer the recycler parked rather than new memory. The ledger gets its row (the bound: a CPU write after the commit, before the GPU runs the command buffer, may be read), and managed.rs, managed_copy.rs, API.md's accepted difference, the runtime README, FAST-PATHS' costs bullet and the conformance crate's Policy::Exact say so. tests::fast_paths names the choice and checks it keys no profile and that exact_answers() takes AtCommit. The named-rounds race tests take the policy: by default each round reads, in each byte, its own byte or one the CPU wrote to its buffer after its commit (0xee, a later round's), never an earlier round's; under AtCommit only its own; three AtCommit tests join the three default ones. The lane test's step 4 reads either oracle's answer by default and the 5300M's under AtCommit (exact_answers_take_a_did_modify_range_at_the_commit). Why: a compute benchmark's commits spent most of their time in this copy on a discrete GPU (a CPU memcpy into write-combined staging in BAR across an eGPU link, fresh 32 MiB chunks each time). The oracles differ on the bytes after the commit (5300M A,B,B,A,B; UHD 630 A,B,B,B,B), so the cheaper answer is the default and the snapshot stays behind the switch (AGENTS.md rule 1). Verified: jobs in the report (lint both cfgs, the translator's fast_paths, the runtime suite on lavapipe, managed_copy_device and the lane test on the RTX 3090 and the RX 7900 XTX, and the copy-in bench there before and after). |
||
|
|
7b77851a95 |
Runtime attachment images start at zero where an unstored DontCare load stays DONT_CARE
What: Device::new_planned_texture, which makes the runtime's own images (the scratch image of separate depth and stencil textures, stand-ins, backings, colour twins), starts an image with color or depth/stencil attachment usage that a clear writes at zero (Start::ZeroUnpatterned) on a device whose unstored DontCare loads stay the driver's DONT_CARE (clear_reach::UnstoredLoads::DontCare: UnstoredDontCarePolicy::Driver on a driver without DriverFact::UnstoredClearNoSlower). Elsewhere it starts as its memory lies, as before. FAST-PATHS' unstored DontCare row and API.md say so. Why: such a load reads what the image holds (a depth or stencil test, a blend, a fetch). A Private runtime image started as its memory lay, and a recycled one may hold a released texture's texels, of another process of a consumer whose processes share the device. Devices that clear such loads read nothing of it, so they pay no clear. Verified: tests::unwritten_parts on lavapipe and Iris Xe (jobs in the report). |
||
|
|
ab56a1c88e |
Half division and square root at 16 bits under the 16-bit float controls
Rule 1: where the module computes half in 16 bits under the 16-bit float controls (QuantizeForm::Controlled), the device's native form of a half division and square root is its 16-bit OpFDiv and Sqrt, so those are the only form there; elsewhere the float instruction rounded to half stays. - divide::native: a half quotient under the controls narrows its operands (exact, they are halves), scales a divisor past 2^14 by 2^-2 and a denormal one by 2^10 into Vulkan's range for the 16-bit OpFDiv ([2^-14, 2^14], 2.5 half ulp), divides at 16 bits and widens. The scaling is exact but where the quotient rounds to zero or overflows anyway. - math::float_fn: a half sqrt under the controls is the 16-bit Sqrt between exact conversions (Vulkan: inherited from 1 / InverseSqrt). - narrow::computes_in_16_bits counts 16-bit FDiv and Sqrt, so the entry declares the controls (denormals kept, IEEE zeros, infinities, NaNs). - ops: float_ty and f16_splat, shared with f16_binary. - NativeDivision and DeviceArithmetic state the 16-bit bounds; docs/API.md, docs/FAST-PATHS.md, the narrow and half_hold module docs follow. - Test: engine_half_hold's half_division_and_sqrt_are_16_bit_under_the_ float_controls (Iris Xe and RADV: 16-bit FDiv x2 and Sqrt, none at 32, no exact narrowing, the exact answers on the interpreter, L3, the notes; lavapipe: the float forms, the same answers). Verification: in the following potluck runs (FConvert count on hnq, the half engine tests, spirv-val, clippy, the suite). |
||
|
|
b8257d9c10 |
Runtime images whose parts no copy writes start at zero, never as their memory lies
What: - Device::storage_over_buffer: a surface depth or stencil texture's shadow whose copies leave an aspect out starts ZeroUnpatterned in every storage mode (Metal reads 0 there); a tiled texture of more than one level starts Start::Zero, as a new texture of its storage mode does. Before, both went through new_image, which starts a Private image held. - surface_depth.rs pass_image (the twin and an X32_Stencil8 view's private image) starts ZeroUnpatterned: no copy writes its stencil. - Docs: storage_over_buffer's comment, surface_depth.rs module docs and FAST-PATHS.md's tiled later levels gap say what they now read. Why: a Private image's memory may hold a released texture's texels, of another process sharing the device (a recycled image). A kernel reads the shadow's stencil through an X32_Stencil8 view, blits and samples read a tiled texture's kept later levels, and a pass's DontCare stencil load the driver leaves reads the twin's. Verified: tests/unwritten_parts.rs (previous commit) fails without this and passes with it; runs follow. |
||
|
|
41b5430f6a |
A completed command buffer's release posts the host imports it frees last to the free thread
On NVIDIA each vkFreeMemory holds the device's other vkQueueSubmits while it runs, and a completed command buffer that let go of no-copy buffers' imports last freed them on the thread that runs the next completed handlers, back to back and unpaced. Now, inside a completed command buffer's release (free_thread::AtCompletion), an import whose free a deallocator or a keep-alive waits for is posted to the device's free thread, which paces it as it paces a block's free; the deallocator and keep-alive run there after the free, possibly after the command buffer's waiters returned. The queue stays bounded at 64: a post that finds it full, the teardown begun or no thread frees in place. An import nothing waits for is freed in place, before the waiters return, as the caller may unmap its pages once they did. A program's own release still frees in the release. No switch, nothing by vendor. The paths: HostImport::drop (a pin's last hold at completion), and rebind's Retained, a command buffer's hold of a releasable import's objects (Imported::let_go_at_completion). The posted objects hold the device through holder handles (device/holds.rs), so the program's last drop on a program thread waits for them, and the thread frees them unpaced once the holds stopped. Where the program's last drop ran on a runtime thread, a posted import can hold the device's last share: the teardown then runs on the free thread, which frees what is still queued in place of waiting for itself and ends unjoined. Counted: WorkCounts::host_import_frees_posted; memory_frees_paced counts their pacing. docs/FAST-PATHS.md's known gap on NVIDIA's frees is updated, and the Deallocator doc names the free thread. Verified: tests::completion_import_frees (posted with a deallocator, in place with none, and the teardown on the free thread), the runtime suite and lavapipe device tests in the check job, and the 2080 bench before and after. |
||
|
|
158f9788b5 |
Half holding: the dot and mix bounds are NativeDot's and NativeMix's, a test, the docs
A half dot or mix already records NativeDot or NativeMix on every device, so the DeviceArithmetic scan the previous commit added in compile.rs is removed, and those two notes' docs (artifact.rs, docs/API.md's catalogue) and docs/FAST-PATHS.md's device-gap row now state the 16-bit form and its bound: a 16-bit dot of n lanes within (3n - 1) * 2^-11 * sum |a_i b_i| + (3n - 1) * 2^-25 of Metal's chain (2n - 1 correctly rounded 16-bit roundings beside Metal's n), a 16-bit mix within 2^-8 of its two terms plus 2^-22. narrow.rs's module docs, lower/arith's dot and mix comment, and docs/ARCHITECTURE.md (the tidy stage and the spirv/ map) name the pass. tests::engine_half_hold: a kernel of half min, max, clamp, dot, mix, a loop-carried half and a thread array of half; on the Iris Xe and RADV profiles it narrows no exact half, its four input roundings are its only narrowings and its result's its only widening, its dot, mix and bounds are 16-bit instructions, no float variable stays 32-bit, it answers 33.25 on the interpreter, passes L3 and records NativeDot and NativeMix; on lavapipe (Converted) nothing is held and it answers the same. Verification: not yet run (the build and tests follow). |
||
|
|
47ee9f4806 |
Fan a rate-mapped draw out through four copies where its triangles reach at most four regions
A host step's fanned-out draw went through one geometry-stage variant that
declares the output of the most copies (up to 16) for every triangle, though
most draws' triangles touch only a few regions. The declared output size is
what the 780M's geometry stage pays for.
- The translator: RegionFanOut::DrawFew, the draw variant whose loop emits
at most FEW_COPIES (4) copies and whose geometry stage declares 3 x 4
output vertices; its codec name and compile-key word (" region_fan_out
few"); the link and engine tests cover the three modes.
- The probe: each draw's words grow to 1 + 2 x PROBE_COUNT_WORDS (65): its
flag, the 32 count lanes, and 32 wide lanes, where a triangle whose
widened pair count exceeds FEW_COPIES stores 1 (picked by PrimitiveId
mod 32, as the counts are). The host reduces them to (flag, copies, wide).
- The runtime: a fanned-out draw no triangle of which is wide draws
through DrawFew, else through Draw; commit's settle begins the three
variants (probe, few, most). Counted:
WorkCounts::rate_map_fanned_few_draws.
- The pieces lane prints the count. The runtime test's 8 commands add one
whose triangle covers four tiles a side (more regions than four, no more
than the most copies), drawn through the most copies, and assert the
other 6 fanned-out draws took four; the pixels are still the encoder's
region-by-region draws'.
- docs/FAST-PATHS.md: the fan-out row names the variant and its count, and
its cost cell carries the numbers below. bind/fan_out.rs: FEW_COPIES's
numbers.
Verified, release binaries, runtime_lane::rate_mapped_pieces and
tests::rate_mapped_fan_out, the command buffer's GPU time, cold then warm:
- Radeon 780M (Mesa 26.2.6), m3-max-24369, this change plus a scratch
switch (never landed) drawing every fanned draw through the most copies,
interleaved in one job: 4 copies 40.2/29.7 and 43.9/30.8 ms; the most
copies 61.9/36.8 and 62.7/34.5 ms. Warm about 5.4 ms (15%) less.
64 of 64 draws of four copies.
- Iris Xe (Mesa 26.2.6), m3-max-24317: 47.7 ms cold, 40.0 ms warm (40.5
warm through the most copies in an earlier run); 64 of 64 of four copies.
- RTX 3090 (NVIDIA 620.70.06), m3-max-24316: 28.6 ms cold, 6.1 ms warm
(6.2 ms before); 64 of 64 of four copies.
- tests::rate_mapped_fan_out on all three: 3 passed, 6 drawn of few
copies, the fan-out's pipelines 3 ready plus waited, 0 made at the step.
The Iris and 3090 runs are of the same change at base 9c30ffd263; the
780M's at
|
||
|
|
9e19371285 |
Pieces lane: default pipeline waits, the commit's time, the fan-out's makings taken
The lane's device ran under exact_answers(), whose PipelineWaitPolicy::Exact made every pipeline a commit settles on the program's thread: with the fan-out's begun at commit, the cold frame's commit took 86.9 ms on an RTX 3090 and 69.8 ms on an Iris Xe, a cost a consumer's device, under the default Bounded waits, hands to the pool. The lane's device now makes them under the default waits, as a consumer's does. Its line adds the program's time in commit (the host's clock) and the fan-out's makings the commit began that the step found made or waited for (WorkCounts::rate_map_fan_out_pipelines_ready, _waited). The lane's docs and the fan-out row's cost cell in docs/FAST-PATHS.md carry the three GPUs' numbers with the fan-out's pipelines begun at commit and the copy loop (m3-max-24007 RTX 3090, 24008 Iris Xe, 24009 Radeon 780M), command buffer GPU time FanOut against Exact, cold then warm: - Iris Xe: 47.3 and 40.6 ms against 514.3 and 496.8 ms; commit 2.1 ms. - Radeon 780M: 42.3 and 29.4 ms against 299.3 and 232.6 ms; commit 1.8 ms. - RTX 3090: 44.2 and 7.5 ms against 71.2 and 65.5 ms, the step waiting for the fan-out's makings in the cold frame; commit 7.4 ms. |
||
|
|
d4ab197556 |
Metal's command-buffer watchdog: a front batch 20.2 s without its timeline advancing fails as Metal's timeout
reims's 3090 boot after an Xid 109 (CTX SWITCH TIMEOUT) had its graphics queue's batch never
complete while the copy engine ran on: the staging probe completed 23 times in under a
millisecond, so the stall rule found the GPU running and nothing failed. The probe stays; beside
it each queue's front batch now has its own clock (stall::Clock::front_held), which runs while
its waiter's waits run out with it pending and stops whenever its queue's timeline advances,
whatever the probe answers. Past stall::WATCHDOG (20.2 s, the x86 AMD Mac's measured bound and the
largest of Metal's) the front fails as Metal's timed-out command buffer (GpuHang, code 2, named
exactly: its queue is known, no inference), the rest in flight as GpuRecoveryVictim, and the
generation is marked stopped (Stop::Watchdog), parked and recovered from as a wedge; the notice
says the watchdog stopped it. Counted: WorkCounts::watchdog_timeouts (wedges_declared keeps the
unanswered probe's stops).
Measured on the M3 Max (macOS 27.0.1, a Swift probe): a command buffer waiting for an event no one
signalled, shared or plain, failed with MTLCommandBufferErrorTimeout ('Caused GPU Timeout Error
(00000002:kIOGPUCommandBufferCallbackErrorTimeout)') 5.00 s after its commit, nothing of it run;
two such on one queue revoked it (the next fill failed AccessRevoked 0.24 ms after its commit,
a new queue ran). So the clock counts event waits, as Metal's does, and the watchdog's GpuHang
counts against its queue as any timeout (revocation.rs says so; the count is QueueCommon's and
carries over a recovery, as Metal's queue keeps it).
Tests (tests::stall): the stuck front with an answered probe fails at the hooks' 1 s bound, no
sooner, as GpuHang, parks the generation and runs the next command buffer; the answered leg
whose front advances within the hooks' 3 s fails nothing. Docs: stall.rs, revocation.rs,
docs/FAST-PATHS.md known gap, docs/API.md, the runtime README, WorkCounts, api_signatures.
|
||
|
|
4906f145e3 |
Pieces lane: each frame cold, then warm; the fan-out row's cold and warm costs
The lane's one frame mixed two costs at the host step: the GPU work, and on the first frame of a state the driver making the fan-out's probe and draw pipelines inside the step (82.1 of the RTX 3090's 88.6 ms cold fanned-out window). The frame now runs twice on the same device, cold, then warm, each printed and checked, and the line adds the host step's time (WorkCounts::host_step_nanos), the pipelines it made (host_step_pipelines_made) and the time creating render pipelines (render_pipeline_create_nanos). The lane's docs and the fan-out row's cost cell in docs/FAST-PATHS.md carry the three GPUs' cold and warm numbers after the probe spread, from one run each (m3-max-23899 RTX 3090, 23900 Iris Xe, 23901 Radeon 780M), command buffer GPU time FanOut against Exact: - Iris Xe: 110.4 ms cold, 40.3 ms warm, against 514.6 and 499.1 ms. - Radeon 780M: 84.3 and 34.7 ms against 299.5 and 231.7 ms. - RTX 3090: 88.6 and 6.0 ms against 61.9 and 63.0 ms. The guest-scale fanned-out figure, measured before the spread, is dropped; its region-by-region one stands. |
||
|
|
0c6d7cc1c8 |
Pieces lane at a guest frame's scale, a GPU hazard; the RTX 3090's numbers
rate_mapped_pieces_guest_scale (FanOut) and _guest_scale_exact run the host step's frame at six times the commands (384 commands, 5,508,648 indices, about the 126 pieces a guest frame was recorded in on an RTX 3090), compiled only under m2v_gpu_hazards and ignored by default. Measured once on an RTX 3090 (NVIDIA 620.70.06), um870, each test its own process: at 64 commands Exact 54.4 ms in 20 pieces (longest 2.63 ms), FanOut 98.4 ms with a 14.0 ms probe; at guest scale Exact 332.3 ms in 117 pieces (longest 2.67 ms, mean 2.00 ms), FanOut 174.3 ms with a 74.4 ms probe. The numbers go in the lane's docs and the fan-out row's cost cell in docs/FAST-PATHS.md, where FanOut is slower than Exact at the small size on that device. Verified: clippy with --cfg m2v_gpu --cfg m2v_gpu_hazards over the runtime, the translator and validation, 0 messages; the five lanes passed on the RTX 3090 (job m3-max-23744), built from the same lane source. |
||
|
|
c3a002b71c |
stall test: the stopped test drains the parked queue before the process exits
On NVIDIA (620.70.06; um870's RTX 3090 and um790's RTX 2080) the stopped test passed and its process never exited: under gdb (job 23736) the test reported ok in 21.5 s, and the main thread then spun in exit(), in an exit handler of libEGL_nvidia that tears down every VkDevice left and waits for its work. The parked VkDevice's batch waits for the event's semaphore, which the test never signalled. The test now keeps the stopping generation's functions and semaphore and signals the reserved counter on the parked VkDevice once it has checked the recovery, so its queue drains. It prints when the stuck command buffer failed and when the next one ran. docs/FAST-PATHS.md's known gap and stall.rs's module docs say a driver may wait for a parked VkDevice's work at the process's exit (NVIDIA's did, for that stand-in wait); a GPU that truly stopped is not measured there. Verified: cargo fmt. The NVIDIA runs follow with this commit's archive. |
||
|
|
64982ac827 |
A GPU that stops with no loss from the driver fails its work and is parked
On NVIDIA after an Xid 109 the device's queues stopped: no batch completed and every completion wait answered VK_TIMEOUT, never VK_ERROR_DEVICE_LOST, so the program's command buffers waited without end. The completion's waiters now keep a device-wide stall clock (command_buffer/stall.rs): it runs while a wait ran out with its front batch pending and stops whenever any queue's timeline advances. Past 10 s one waiter probes the staging queue (NVIDIA's copy engine) with a submission of nothing that waits for nothing, and for up to 2 s reads the probe's answer and the stuck front's fence (a wait of no time) and timeline (vkGetSemaphoreCounterValue); a loss either read answers takes the failed wait's path at once. One informational message, metal2vulkan-stall-probe, names the stall, the probe's answer and each read's last VkResult. A probe answered, or a front that advanced, fails nothing and restarts the clock, so a device that still makes progress is never failed whatever its work's length. A probe unanswered in 2 s stops the generation: Device::mark_wedged marks it stopped and lost, the wait fails as a lost device's (the oldest command buffer as GpuHang, the rest GpuRecoveryVictim), and the line recovers; the DeviceRecovered notice says the VkDevice stopped and was parked. Parked: release.rs's door leaves every object of a parked VkDevice, the device itself included; DeviceShared::queues_idle waits for none of its queues, and its teardown returns before vkDeviceWaitIdle, keeping the instance. New public query Device::is_parked(vk::Device) -> bool (no Metal counterpart), for a consumer that holds the stopped generation's handles. Counters: WorkCounts::stall_probes_sent, wedges_declared, longest_stall_nanos. A device without a staging queue sends no probe (FAST-PATHS known gap, with the leak and Metal's bounds: about 5 s on the M3 Max, 20.2 s and 16.1 s on x86 Macs' AMD and Intel GPUs). Tests (tests::stall, through the line's hooks: the clock's bound 200 ms, and no probe seen answered): a command buffer waiting on its VkQueue for a reserved event signal is pending; with the probe answered nothing fails and it completes once the host signals; with none answered it fails as GpuHang, the old VkDevice is parked, the new one is not, and a command buffer runs after. Verification follows on this commit. |
||
|
|
a52c30aff2 |
A recovery carries no-copy heaps and the textures placed in heaps
What: a heap over the caller's memory (new_heap_with_bytes_no_copy) is
carried as a no-copy buffer is: its own buffer made again over the same
pages (Buffer::carry_no_copy, now for a heap's own buffer too, kept among
no program resources; its pages keep what they were made of, a heap's own
included), its identity kept, the buffers placed in it carried at their
offsets (Buffer::carry_placed), their bytes as they are. The textures
placed in a carried heap, Private or no-copy, are made again there after
the heaps (Remake::Heap, Device::heap_texture_again): as the runtime's own
texture over the same range of the heap's bytes, through the making that
placed them (a texture buffer's buffer carried with carry_placed), sharing
the range's makeAliasable flag (HeapPlace::aliasable is an Arc), the range
handed to the newest image (HeapPlace::again, hand_range_to), so it is
given back once. A Private heap's texture reads as a new one, a no-copy
heap's reads the pages. The heap keeps its textures numbered as they were
(no forget_held); one the recovery leaves is forgotten (Numbered::forget,
Heap::forget_texture). A texture over a carried heap buffer is made again
over it, as over any carried buffer. Heap::carry answers what its bytes'
carry did with their contents and None where it was carried already, so
the notice counts no-copy heaps apart (", and N no-copy heaps with the M
buffers placed in them, over the same pages") and textures placed in
no-copy heaps apart ("N textures placed in the no-copy heaps carried"),
a Private heap's textures by storage mode. Docs: heap.rs, texture/carry.rs,
device/carry.rs, MadeBeforeRecovery, the device-recovered cost (degradation.rs,
API.md), the runtime README, and FAST-PATHS's known gap on lost texture
contents, which now names a Private heap's textures.
Why: reims's forced recoveries (3090 m3-max-23482, XTX m3-max-23547) left
44 no-copy heaps and 929 heaps' textures refused: 3424 refused texture
binds in one compositor's command buffers, 82 placements in those heaps
refused, the desktop mostly black after. Metal keeps a heap and what is
placed in it. The owner's call: a Private heap's textures are carried with
their contents lost, as new_texture's are.
Verified: a check of the runtime's lib and tests under plain and
m2v_cpu_icd was clean (m3-max-23688, on a probe commit of this change);
the lane that follows runs the tests.
|
||
|
|
257b77bc21 |
Fan a host step's rate-mapped draws out to the regions in one draw
A rate-mapped pass drew every draw once per region of the map's plan: an executed command's
triangles ran their vertex function 2074 times on a 3648 by 1734 screen's plan, and the command
buffer of a guest frame's shape took 514 ms of an Iris Xe's GPU and 462 ms of a Radeon 780M's.
At a host step, where the default `RateMapRegionPolicy::FanOut` holds and the device enables
`geometryShader`, `shaderClipDistance` and `vertexPipelineStoresAndAtomics`, the pass is now
probed first: each execution's commands, read once, are replayed in probe mode into a segment of
their own (one middle render pass per instance, the fan-out variant's geometry stage writing a
flag and a copy count per command and emitting nothing), submitted and waited for. A command
whose flag is clear (no triangle crosses w = 0 or touches more regions than the copies) is drawn
once through the fan-out variant over the whole target, its geometry stage emitting a copy per
region it touches; a flagged command, and every command after a barrier, after a draw that writes
memory or at a mesh or patch draw, is drawn region by region as before. A fan-out variant the
compile refuses falls back to region by region at the settle.
`RateMapRegionPolicy::Exact` (`DevicePolicy::exact_answers()`) keeps every draw region by
region. The FAST-PATHS row, the API.md bullet and a known gap (the encoder's own draws and the
draws commit records stay region by region) describe it; `WorkCounts` counts the probes, the
flagged and fanned-out draws and the probes' GPU time. `CommandBuffer::submit_waited` is the
loop check's waited submission, shared with the probe.
Verified (release, `--cfg m2v_gpu`, e55e6ebd01 before the rebase onto
|
||
|
|
c4376d1042 |
canon::generic: a struct's generic pointers read through its address another thread object holds
What: canon::generic's cells (canon/generic/cells.rs) follow thread pointers through thread
memory. A slot of an alloca into which only the address of one alloca at one offset is stored
(a null among them or not), that no other write, copy, atomic or load at another offset or width
meets, of an alloca whose address no use but an access and address arithmetic takes, is
followed: a thread pointer loaded from it places what it addresses, and storing that address into
it is no escape. Places also derive through casts between the thread and the generic space, so
an object reached through a generic `this` is a cell too. The slots followed and the places they
lead to are found together, in rounds; a slot followed once and not after is never followed
again, and past the rounds' bound none is.
Why: macOS 27's MPS matmul and quantized matmul kernels keep their array_refs' generic pointers in
a thread struct and read them through a lambda that captures the struct by reference: the
lambda's object holds the struct's address, and its call operator, inlined, loads that address
and then the struct's fields. The fields' loads were from no place a cell knew, and the struct
was open because its address was stored into the lambda's object, so each was
GenericPointer(Memory).
The owned fixture generic_pointers gains generic_captured (a lambda capturing a `refs` by
reference, its call operator taking its object as a thread pointer) and generic_functor (a
functor holding `&r`, its out-of-line call operator taking the functor as a generic pointer), and
its Metal probe the same kernels. docs/FAST-PATHS.md's generic pointer gap says so.
Verified, one run each:
- Before, at development with the fixture: engine_generic_pointers refuses generic_captured
with GenericPointer(Memory) (m3-max-23363).
- The M3 Max (macOS 27.0.1) answers both new kernels as generic_slots: 100+t, 201+t, 1 for t<4
then 4, and t (m3-max-23383).
- engine_generic_pointers and the metal2vulkan-air suite pass, 561 tests (m3-max-23381).
- The metal2vulkan and metal2vulkan-air suites (m3-max-23401): 4060 of 4063 pass; the three
that fail are the golden tables, which development re-blesses: golden_hashes, the engine
inventory's two new rows (generic_captured and generic_functor, ok in every cell), and the
engine printout of generic_pointers.ll (tests/air_input/generic_pointers.txt, recorded under
LLVM 21).
- runtime_lane::generic_pointers on lavapipe, both tests, the five struct kernels among them
(m3-max-23413).
- fmt, clippy with all features and rustdoc (m3-max-23436, the same patch on development
|
||
|
|
56a8aa5283 |
did_modify_range: a commit takes the ranges of the buffers its command buffer uses, copied in on its queue
What: Modified::take_at_commit takes, at a commit, only the noted ranges of the buffers the
command buffer may use (CommandBuffer::may_use: its encoders' uses name the buffer or made it
resident, a command may reach memory no use names, its last encoder's end is still with the
lowering thread, or nothing owns the buffer's key); the rest stay noted, in their order, for a
commit that uses them (managed.rs's Noted). Their copies in, and every other upload into a
buffer the program may have read (Buffer::upload, copy_in_from), register as uploads
(FirstMoves::register_upload, FirstFill::reached_only): a batch takes one only where its
commands may reach the buffer, on a device with a fill queue or without one, never because it
takes every other fill; an internal submission takes it too, and a batch that needs no GPU work
leaves it waiting. FillTake::Owned carries the batch's reach for that. So the copy lands on the
user's queue, after the command buffers before it there, before the commands of the first that
uses it: Metal's shape. Docs: managed.rs, managed_copy.rs (the 'as on Metal' line now says what
holds: only two queues' unordered uses of the buffer race the copy), first_move.rs, API.md, the
runtime README and FAST-PATHS.md's managed row.
Why: any queue's commit took every noted range, and any queue's next submission took its copy in
(before
|
||
|
|
9b308145e9 |
A texture buffer goes on over its carried texels; the notice counts lost textures by storage mode
What: Texture::carry makes a texture buffer of new_texture again over its texels' buffer where the recovery carried that buffer (texture_buffer_over, the runtime's own ID use), so a Shared one reads the bytes the buffer carry kept; where the buffer was left it is made new as before. Remade splits the textures whose contents were lost by storage mode (Shared, Managed, Private or memoryless), and the recovery's notice says those three counts. carry.rs says how kept bytes are read: Vulkan makes the content of external memory imported to a lost device undefined (vkspec 5.2.3), read as the hung work's writes possibly landing in part; once the lost import goes, the pages are only our or the caller's memory. Docs: texture/carry.rs, carry.rs, the DeviceRecovered cost (degradation.rs, docs/API.md, equal), the runtime README, and a known gap in docs/FAST-PATHS.md: a recovery loses the contents of textures whose only copy is device memory (new_texture of any storage mode), textures over carried pages keeping what their buffer keeps. Why: the consumer asked for Shared textures' contents kept across a reset. A texture of new_texture of any storage mode has no copy outside its image in the lost VkDevice's memory, so keeping it would need a CPU copy at a cost to every frame; decided against for now, and recorded as the known gap. Textures over carried pages already keep their bytes; texture buffers did not. Verified: see the lane run reported with this sha (the test commit before it fails, this one passes). |
||
|
|
f5d97f8e95 |
Cut a rate-mapped execution's big draws into ranges of their indices
A piece bound by command count, or by whole commands, still lets one command hold unbounded work: the sample's largest executed command draws 161,820 indices, times its 2,074 regions about 2.5 times the old piece work in one draw. Where an executed command's draw in a rate-mapped pass would alone hold more than the piece work, it is now drawn as consecutive ranges of its indices, each a draw of its own that a piece may begin before. That draws what Metal's one draw does only for an indexed list (points, lines, triangles: Metal never restarts a list) cut at primitive ends, of one instance, whose pipeline reads no [[primitive_id]] and writes no memory; every command of the sample is such a draw. Ranges are sized by the most region draws a draw of the execution made so far (the most a plan holds before any), an even count of primitives so 16-bit ranges keep 4-byte offsets. Any other draw rides whole: FAST-PATHS' known gaps now name them, with the encoder's own draws, as able to pass amdgpu's job timeout and NVIDIA's context-switch timeout. PIECE_WORK halves to 2^26, so a piece of cut draws holds under 2^27: about 56 ms of Iris Xe at a trivial vertex function, 35x under 2 s. WorkCounts::rate_map_index_ranges counts the ranges past the first; the signature table gains it and the four piece counters. A runtime device test draws eight commands of a twice-drawn blended triangle grid through 32-bit and offset 16-bit indices over a falling map, and checks the execution cut under a small piece work against the uncut execution and the encoder's own draws, byte for byte, with pieces and ranges counted. Unverified at this commit: the compile check and device runs are next. |
||
|
|
a610b58b8a |
A replayed draw whose making outlasts the commit's bound leaves its pass to the host step
The last draw dropped for its making's time: a draw of an execution's replay at commit (render commands the CPU writes) whose pipeline the replay began itself and that was still being made at the command buffer's bound recorded nothing. Metal cannot encode a draw before its pipeline exists, so every encoded draw runs. Now the replay at commit stops there, keeps the making on the command buffer (CommandBuffer::leave_unmade), and the pass takes it into the makings its host step waits for (DeferredPass::left_for_makings): the commit leaves the pass to the host step with its pipelines pending, as it already did for a pass whose settled makings were still being made, and the step records it from the records as they stand then once the making lands. A replay inside a host step waits for its making until made, on the step's thread. record_on_gpu declines to the host step the same way. The commit still returns at its bound at most. Removed: DrawDroppedStillMaking, WorkCounts::draws_dropped_still_making, CommandBuffer::drop_late_draw, RenderLowering::drop_late_replayed_draw, the execution's encoder place that only named the dropped draw, and the open-gap text in FAST-PATHS row 43, API.md (the bullet and the catalogue entry), the runtime README and the PipelineWaitPolicy docs (api_signatures.tsv -2). The IndirectCommandCheck and executed-commands docs name the new case in which an execution read at commit is read and checked again in its host step. The gap's test flips: a_replayed_draw_whose_pipeline_is_still_being_made_at_its_bound_renders_once_made (commit returns after the bound and before the 10 s watchdog; the command buffer is not complete a second past its bound while another queue completes; once the hold goes it completes with the rectangle drawn and nothing dropped). Checked by the lint and lavapipe jobs reported with it. |
||
|
|
b4eaf4caa7 |
Keep the replayed draw's test as the open gap's, and name the gap by the replay's own wait
The lavapipe run (m3-max-23046) showed a draw of a commit-time replay of CPU-written records dropped at the bound: the replay waits for that making itself, which the settle did not leave to the host step. That is the open gap this change keeps; its test asserts the drop, and the docs name the gap by the replay's own wait. |
||
|
|
91dbc91bbc |
Hold a command buffer for its draws' and dispatches' makings instead of dropping them
A dispatch whose pipeline was still being made 4.5 s after its command buffer's commit recorded nothing, and so did such a draw. Metal makes a state's pipelines inside its creation, so every draw and dispatch it encodes runs: a dropped dispatch leaves wrong results (a guest's path tracer dropped 45 dispatches behind a 116 s compile on the RX 7900 XTX), and a dropped draw leaves content drawn once (a cached shadow map, a glyph atlas) without it. The owner's rule: no switch may break Metal's contract, so the dropping form is removed, not kept behind a switch. A batch's host step now waits for every making its segments record, past the bound too (Segment::steps_after_pipelines; the scheduler's StepWaits loses its `until`, and Segment::holds goes): the batch stays in its queue's line on the scheduler's thread, which no call waits for, and records the draws and dispatches once made. Held batches still give way to other queues' later commits that share no fence. `commit` waits for no making but a pass that executes render commands the CPU writes, until its bound, and leaves that pass to the host step past it. The pending dispatch, tile dispatch and pending draw recordings wait until made. DispatchDroppedStillMaking, its counter and catalogue entry, and CommandBuffer::drop_late_dispatch are removed. One drop remains, an open gap named in FAST-PATHS and the notice: a draw of an execution's replay whose pipeline the replay itself began making, of a key the commit's settle did not foresee, still being made at the bound (DrawDroppedStillMaking, now that case alone). That case is the next change. Tests (device, rewritten): a draw, a replayed draw and a dispatch whose makings are held past the bound each complete once the making lands, drawn or written, nothing dropped, while another queue's command buffer completes meanwhile and the held one is still not complete a second past its bound. |
||
|
|
bcfec16960 |
A rate-mapped draw skips the regions its viewport and render area leave no pixel
Each draw of a rate-mapped pass was recorded once per region of the map's plan, even where the region's scissor, cut to the pixels whose centres lie in the guest's viewport and to the render area, held no pixel. Such a recording shades nothing (the scissor test discards every fragment), and its vertex function repeats nothing observable (a plan of several regions refuses a vertex function that writes memory), so it is now left out. Where the cut leaves no region a pixel, the first region alone is still recorded through its empty scissor, so the vertex function runs as Metal's does. A draw whose viewport covers part of the screen now records only the regions it reaches; one over the whole screen records what it did. The new lane test draws the case's fullscreen triangle over a 256-pixel map at the falling quality with a viewport over the screen's left quarter: fewer regions than the whole screen's, from an indirect buffer region by region, and the direct (batched) draw shades bit for bit the same pixels, inside the left half of the physical columns. |
||
|
|
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). |
||
|
|
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. |
||
|
|
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. |
||
|
|
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. |
||
|
|
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. |
||
|
|
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. |
||
|
|
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). |
||
|
|
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. |
||
|
|
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. |
||
|
|
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. |
||
|
|
236340a171 |
A heap texture's observed residency is resident; a sparse member under it is refused at plan
A function that observes the residency of a read, sample or gather of a texture it reaches
through an argument buffer (sparse_sample, then sparse_color::resident()) was refused at
pipeline creation: lower::texture::residency answered Lowering(Texture), NotImplemented, for a
heap element's status word. A forward renderer that streams its material textures compiles
exactly that, so its pipeline never made and it drew nothing.
Metal reports a texture that is not sparse resident everywhere, which is the word 0 the module
already builds for a heap element's access (emit::with_word). So residency() now answers a heap
element's observed residency with no residency form, the word 0, and the stage states the new
RuntimeFact::HeapResidency { stage } (PlanTimeCheck). The planner (bind::heap::HeapPlanner::new)
refuses a sparse texture (TextureFacts::sparse) that such a stage's handle tables reach,
Unsupported { ArgumentBufferTextures, NotImplemented }: answering one would need the member's
tile map or sparse image per handle-table entry, which is not built. docs/FAST-PATHS.md records
it as a known gap; a slot's sparse texture stays answered (RuntimeFact::SparseTexture).
SEMANTICS_VERSION 2041 (refusals become modules); ARTIFACT_FORMAT_VERSION 504 (a RuntimeFact
variant). docs/REFUSALS.md and the API surface table regenerated.
Test: tests::engine_heap_residency over the new tail_argument_sparse_samples fixture: both
fragments compile behind its vertex function on every committed profile with what they use
(moltenvk-m3, lavapipe and amd-780m-radv named), state the fact and pass L3; their plan holds
a texture that is not sparse and refuses a sparse one. Before the change the base CLI refused
argument_sparse_fragment with Lowering(Texture), NotImplemented, at block 0 instruction 2, the
sparse sample (job m3-max-20327, gem10).
|
||
|
|
e25e6c5258 |
FAST-PATHS: the RADV interlock row's measured creation time
Release, on the RX 7900 XTX with Mesa 26.2.6 and MESA_SHADER_CACHE_DISABLE=true: con_fetch_coverage's first pipeline made whole in 0.9 ms (m3-max-20254, at the fix), and linked in 1.1 ms at the base (m3-max-20257: pre-rasterization library 0.6-0.7 ms, fragment shader library 0.4 ms, link 0.0 ms). |
||
|
|
9ad6257845 |
Runtime: on RADV a render pipeline whose fragment stage interlocks is made whole
RADV's fast-linked graphics pipelines leave the ordered pixel interlock unordered within a draw. A fragment shader library made without the fragment output interface jumps to a separate color epilog, and ACO waits for the interlocked storage writes before the final export only where that export is the shader's own (RADV_DEBUG=shaders: a whole pipeline's image_store is followed by s_waitcnt_vscnt and the done export, a fast-linked one's by s_setpc_b64 into the epilog). The GPU ends the ordered section at that export, so the next overlapping fragment reads before the write lands. The new RuntimeDriverDefect::FastLinkedInterlocksUnordered is RADV's on every GPU (keyed on the driverID, no clean GPU). On a driver with it, GraphicsContent::links() is false for a variant whose fragment stage declares an interlock execution mode (interlocked_writes::facts), so the pipeline is made whole, as a feedback-loop state is. Evidence so far, all on the RX 7900 XTX, Mesa 26.2.6: - tests::lone_fetch's layers leg at the base: 35 of 72 targets wrong, and 0 of 72 under RADV_DEBUG=nogpl (m3-max-20108). - A bare-Vulkan probe with 12 instances of one quad in one draw: fast-linked, 46 to 62 of 72 counters wrong; whole or linked with link-time optimization, none (m3-max-20040, -20134). lone_fetch's run now prints the device's pipelines made whole and asserts one there. The fixed tests on the XTX, the creation time, lavapipe and lint follow. |
||
|
|
d971205216 |
RUNTIME_VERSION 2101: a slot that reads only levels past the attached ones reads them in place
A draw that samples a texture its own pass renders at one level read the texture's copy unless every read reached only levels before the lowest attached one. A slot every read of which reaches only levels past the highest attached one (a pyramid pass that renders level m from level m + 1, or through a sampler whose minLod lies past m) now binds the texture's own image through a view of its levels from the first up to the highest it reads (all of them where the sampler's maxLod reaches past the last), and names in its uses only those from the lowest it may read (LevelReads::lowest_level, SampledLevels::lowest, through each bound sampler's levels, its lodBias as the bind takes it included). The levels read hold the copy's texels: nothing the instance does writes them, checked as the levels-before case checks (reads_levels_in_place, shares_attachment, the unordered writes, the draw's own writes). The view holds the attached levels too, unread. Vulkan's rules against reading an attachment are of accesses (VUID-vkCmdDraw-None-10795; the Render Pass chapter's subresource "simultaneously being used as an attachment"), and the descriptor's layout must match the subresources the view holds (VUID-vkCmdDraw-imageLayout-00344): GENERAL, where every attachment rests. So such a slot keeps its copy in an instance that holds one of the texture's attached colors in the feedback loop layout, and the instance's general_colors (renamed from storage_colors, which now also holds the colors such a view spans) sends a later snapshot read of one into another instance. Counted as WorkCounts::attached_read_slots_past. The reasons a slot keeps its copy now test any level before the first-level case, which covers only a read that may reach an attached level. Tests: tests::attached_levels (runtime, the device cfgs) gains reads past the attached level; runtime_lane::attached_levels (validation, under the layer) reads levels past the attached one in a pass recorded inline, where the layer sees the attachment. Verified: built and run in the next job, with a negative control. |
||
|
|
cf4d8017f2 |
FAST-PATHS: the heap answer row's measured counts and bytes
heap_texture_images at 4c6ffc7567 (code identical to this tip), under each HeapAnswerPolicy: of the 22 compositor shapes, on ANV (Iris Xe, m3-max-20000) 14 lie in an image put in place of their first one and 7 are shadows in Metal's tiles under Metal, none of either under Device, the answers 3769962 bytes against Metal's 3656426; on the RX 7900 XTX (m3-max-20001) 1 and 8 under Metal, none under Device, 4155498 bytes. heap_compression_costs on ANV under the default (m3-max-20014): the 2048x2048 render target still takes the linear image under both compression values (clear 955.3 and 971.4 us), so the HeapCompression row now says so. Verified: the jobs named; docs only here. |