Repository navigation
Nvidia dev - #2572
Nvidia dev#2572bmjask wants to merge 429 commits into
Conversation
…LSL path The direct translator turned s_barrier into a plain group barrier. That barrier waits for every hardware wave of the group, and a console wave that has left, or that ran one barrier fewer, never arrives: on the console the waves left go on, on NVIDIA they wait for ever and the GPU hangs. The HLSL path has had the barrier that counts the waves still there since 0c02b87 (xcl_s_barrier); with XCL_DIRECT_DXIL=1 compute programs and the compute pass of mesh pipelines did not get it. A retail title has it in 216 compute programs (19 of them branch a wave with no active lane around barriers the other waves run) and in all 36 of its mesh programs: the first wave of a group whose vertex or primitive count is 0, or past 128, runs a barrier the other waves branch around, then the one they all run. Its world, the first to draw meshes in two passes, ended in a driver time-out with no shader exception in two runs of three. A compute or mesh program with s_barrier in a group of more than one hardware wave is now an error of the direct translator, which sends it to the HLSL path (XCL_SAFE_BARRIER=0: as before, in both translators). Not run on a GPU: whether this was the cause of those time-outs is not shown, and the HLSL compute pass of that title's mesh pipelines has not run in its 16-window layout. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Translated shaders index the bound sampler heap with S# word 3 & 0x7FF (SamplerDescriptorHeap in the HLSL path, SAMPLER_HEAP_MASK in direct DXIL), so an index from 0 to 2047. A console sampler heap got as many PC samplers as the title asked for (128 in a retail title): an S# the title builds itself with a nonzero border color pointer in word 3 [11:0], or any index from 128 on, read past the end of the bound PC sampler heap, which D3D12 leaves undefined. A shader-visible console sampler heap now gets 2 048 PC samplers (the D3D12 maximum for a shader-visible sampler heap) whatever the title asked for, all of them made as the zero sampler XCL already wrote into the title's slots (point, wrap, mip 0). The console side does not change: the heap keeps the title's slot count, its 16-byte increment and its indexes, and copies, CreateSampler and the release only touch the title's slots. A CPU-only sampler heap keeps the title's count (shaders never bind it). The cost is up to 2 048 CreateSampler calls and 2 048 PC sampler descriptors a heap. The PC heap's own GetDesc (not hooked) now says 2 048 for such a heap; a console view heap's already says twice its slots. Tested on the software adapter only (WARP): the new test every_sampler_index_a_shader_forms_is_in_the_pc_heap checks the count for every index a shader forms and that D3D12 makes a shader-visible sampler heap of that size. Not run on the hardware GPU or on a title. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t ranges view_want's per-thread memory of the ranges it asked for lately matched an exact (va, len) among the last 8. Mesh-stage root views of a retail title come at a new offset of tiles asked for already, draw after draw, so 12 000-74 000 of them every 2 s missed it and walked their tiles again in sparse::map_mirror (a shard lock and a hash insert a tile) for nothing. The memory now holds the span of 64 KiB tiles each range covers, 32 of them, and a range is skipped only when all its tiles lie in one span asked for while the GPU views were as they are now: it is still emptied when kernelx::gpu_view_map_gen() changes, and a range reaching one tile further still goes to map_mirror. What gets mapped does not change. map_mirror returns how many tiles it queued, and the "KB new" figure of the "GPU view (2 s)" line counts those tiles (64 KiB each) instead of the length of every range that missed the memory: before, 0.3-35 % of it ever became a filled tile. Tested: cargo test --release -p xcl --lib view_want (3 passed) and map_mirror (1 passed), on the software adapter. Not run on a GPU or a title: the miss rate on a title is not measured. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The compute path kept a driver blob on disk only when its build took 250 ms (driver_cache::KEEP), and XCL_PSO_DISK_CACHE_MIN_MS, which the graphics and two-pass paths read, did not reach it. A compute program whose build takes 100 to 250 ms was compiled again in every run, at its first bind, and a compute pipeline is waited for: often on one of the title's threads. In a retail title's run one of its threads spent 228 ms in the driver on a 4 KB program that no file was kept for. driver_cache::keep (its only caller is translated_compute_pso) now keeps a blob of a build of 20 ms or more, and XCL_PSO_DISK_CACHE_MIN_MS chooses for it as for the others. The graphics and two-pass default stays 250 ms. The cost is more small files in the driver folder, at most one a compute program. Programs under 16 KB of DXIL still keep no blob (COMPUTE_BLOB_MIN_DXIL), as before. Tested with the unit tests only (software adapter): the new test keeps a 100 ms compute build and fails on the old threshold. Not run on a GPU or on the title. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ges by counters A wave64 program on 32-lane hardware runs as two hardware halves that exchange ballot words and lane values. Groups of more than one console wave do that through bounded group-shared counters; a group of exactly one (33 to 64 threads) met at a group barrier at every exchange. Those barriers hung NVIDIA GPUs when several such programs ran at once (xcl-dev#1727: device hung and driver event 153 in 11 of 25 parallel runs of the lib tests on an RTX 5070, none on the HLSL path, whose exchange spins by default). A retail title's world runs such programs on several queues at once and ended in a driver time-out with no shader exception. A compute or mesh group of one console wave now takes the counter exchange too (its slots and counters are made for it when the program has no LDS). Geometry programs, which set their partner by phase, and the tests' kernel form keep the barrier. The change is that of xcl-dev#1741 (hajduzsolt), which is open and written against an older main; applied here by hand. Not run on a GPU. The test checks the translated program: one group barrier (the start's) and the counters' atomics for 33, 64 and 128 threads. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… ones A retail title's world made about 33 committed buffers of 1-32 MiB a second for two-pass mesh draws, and let as many go, on a card that was nearly full (the "two-pass res buffer #n" lines: xcl-dev#2048 at 201 s, #8192 at 384 s). Most of them are 32 MiB, and they do not come from DispatchMesh: an ExecuteIndirect of two-pass commands always asked for 32 MiB of records (each with a 1 MiB argument scratch block), since a command's groups are known on the GPU only. A DispatchMesh asked for its need, at least 4 MiB. Each recording keeps its buffers until its PC allocator is reset; then they went to FREE_RES, which kept 16 buffers or 256 MiB at most: eight of the 32 MiB ones. 24-27 of them were made in the world's first two seconds, so each round of allocator resets let go of most of what the next recordings made again. The pick from FREE_RES also took the first buffer large enough, so a DispatchMesh of a few groups could take a 32 MiB one that the next ExecuteIndirect then made anew. - Record buffers are a power of two from 1 MiB (the scratch block's size) to 128 MiB. A draw gets at least the groups it got before (a test checks this over record sizes, splits and group counts). An ExecuteIndirect keeps 32 MiB of records unless a command's groups in X (65 535 / split) need less, which leaves its group cap as it was. - FREE_RES keeps every buffer handed back, up to 1 GiB, and lets go of one no recording took for 2 s; a recording takes the smallest one that fits, the last handed back of that size. What it keeps is bounded by what recordings took in the last 2 s and by 1 GiB. When a buffer goes back to FREE_RES does not change: when its allocator is reset (or alloc_pool sees the GPU past its submits), or 10 s after a recording with no known allocator. A buffer leaves FREE_RES only for a recording or to be let go, both after that point. The DispatchMesh floor goes from 4 MiB to 1 MiB: fewer bytes past the last record. Every store to a record is bounded by its vertex and primitive counts (HLSL and direct DXIL mesh and geometry paths), so a store does not reach past the records a draw dispatched. Tested on the software adapter only (unit tests of the sizing and of the pool). Not run on a GPU or with the title: how many buffers a frame now makes is not measured. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The coherent window is committed when unified memory is made, so it is sized from what the title asked of it in an earlier run (<data>/cache/uma_coherent.txt), and that value only grew. A retail title's 4582 MB of GPU heaps, stored by a run that put them in the window, made two coherent windows of 4095 + 998 MB in later runs with XCL_COHERENT_HEAPS=sparse:16. Those runs sent every such heap to the sparse windows and put at most 105 MB in the coherent window, but with XCL_UMA_SHADOW=1 each window is shadowed by a video-memory heap of its full size: about 4.6 GB of video memory and as much commit for nothing, on a card that was full. The sparse branch returned before the need was noted, so the stale value never came down. uma_coherent.txt now keeps one size per XCL_COHERENT_HEAPS setting (lines "<bytes> <setting>"; the old single number counts as the setting that puts every heap in the window), and the window is sized from the one of the run's setting. A heap sent to the sparse windows is noted too, and a run that has lasted 60 s stores what it put in the window by then even when that is less than the stored size. A run that ends sooner only grows it, so a run cut short before it made its heaps does not leave the next one a window too small for them. XCL_COHERENT_MB still chooses the size. With one coherent window instead of two, the view windows of the 16-window layout start at window 4 instead of 5. Everything that uses them asks the layout (is_view_window, bind::view_span_of, list_x::pc_va_in, real.rs), and the uma tests already build that layout with a 512 MB window. Shader translation and the shader and driver caches are keyed on the number of windows (pso::mem_windows), which does not change. Tested: cargo check -p xcl --tests; the uma and kernelx unit tests (new: the_stored_coherent_need_is_the_one_of_the_heaps_setting, coherent_heaps_routes), on the software adapter. Not run on the title or on a hardware GPU. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ull views When the shared view heap is full, a page of a console view heap that is first used gets no place there. console_heap::slot then gave its slots the index 2k, the one they would have in a PC heap of their own, and XCL wrote that index into the slot's T# (CreateShaderResourceView, CreateUnorderedAccessView, copies). But that heap is CPU-only once it is meant for the shared heap, and lists bind only the shared heap, so the shaders read descriptor 2k of the shared heap: another heap's view, a memory window's raw buffer UAV for k from 2 to 9 (read as a texture, which hangs NVIDIA), or, for k of 500 000 or more in a large heap, a descriptor past the heap's end that the translators' guard (below 2^21 - 1) lets through. Such a slot now has index 0, the null SRV / UAV pair at 0 / 1, with no shared descriptor and no GPU handle (nothing is copied for it, and a UAV clear of it is skipped as before). A heap that has no shared heap at all keeps its own PC heap and 2k. The frame-trace census takes 0 as such a slot's own index. Every page that finds no room is counted (each try), and the warning comes at the first and at every power of two with the count, where it came only once before. Nothing in the logs of the last three runs of a retail title shows the shared heap full, so this does not explain them; that title's heaps would need 2.56 times the shared heap if every page were placed. Tested on the software adapter only: the new test a_slot_whose_page_finds_no_room_names_the_null_views (a fake shared heap with room for one page, run in a child process) fails without the change (slot 258 got index 516) and passes with it. Not run on the hardware GPU or on a title. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
How many two-pass record buffers and argument scratch blocks were alive at once was not logged: the analysis of a retail title's world had to work it out from the addresses of the first 48 and the powers of two of "two-pass res buffer #n", and could only guess their share of the 5 GB of video memory the memory line does not name. A two-pass buffer is now a TwoPassBuf that counts itself when it is made and when it is dropped, wherever that happens (FREE_RES letting go of an idle one or one past its cap, the no-allocator hold past its cap, a test). A line, always on, at most every 2 s while the counts change: D3D12.X: two-pass buffers: N made, N taken again, N let go; N alive (N MiB), N of them kept for reuse (N MiB) The line is left out when FREE_RES is locked on the same thread (a buffer dropped there); the next change writes it. No behaviour change besides the line. Tested on the software adapter only (the bind unit tests; the line shows in their output). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A dispatch waits for its compute pipeline until it is built, and a bind
whose pipeline no worker has started builds it on its own thread, outside
the gate of huge driver compiles. A lazy compute pipeline is sent to no
worker before its first bind, so its first bind always builds it there. In
a retail title's run one of its threads spent 57 s in the driver's
compiler on one program no earlier run had used (827 KB of DXIL, no driver
blob), and another of its threads waited for that pipeline all the time:
no frame for 57 s.
XCL_CS_PSO_WAIT_MS=<ms> is a budget of compute pipelines, as
XCL_GFX_PSO_WAIT_MS is one of graphics pipelines (it goes before
XCL_PSO_WAIT_MS for them). With it a bind takes the path XCL_PSO_WAIT_MS
takes today (resolve_within): the build goes to the xcl-pso workers, where
a huge driver compile waits for its slot once no thread waits for it, the
bind's thread waits at most the budget and never builds the pipeline
itself, and past the budget the pipeline is late: its dispatches get the
stand-in until it is built. Dispatch, the console list replay and
ExecuteIndirect already skip a dispatch with a stand-in and count it
(Dispatch and the replay as a skipped dispatch, ExecuteIndirect as a
skipped draw). Each late program is logged once ("compute pipeline of
record X not built after N ms: its dispatches are skipped until it is"),
by its console program's hash, which the pipeline now carries from its
creation.
Unset or 0, a compute pipeline is waited for exactly as before: the
budget is XCL_PSO_WAIT_MS, and without that, until it is built.
What a skipped dispatch breaks: what it computes is missing or old until
the pipeline is built. When that is the count of a later ExecuteIndirect
(culling and compaction programs), indirect_guard replaces only counts out
of range; an old count in range still draws or dispatches over old data.
Tested with the unit tests only (software adapter): the choice of the
budget, a bind that waits no longer than it while a worker (not the bind's
thread) builds a lazy compute pipeline, and one log line a program. Not run
on a GPU or on the title: what skipped dispatches do to its frames is not
known.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A pool tile that flush_parked unmapped went straight to the free list, and take_tile popped it last in, first out: the tile unmapped last was the next one mapped, cleared and filled for another address on the "xcl sparse queue". When the free list was empty, take_tile even flushed the parked tiles itself and took one of them in the same submit. That queue waits for no title queue (with the readback queue, the normal case), so work the title submitted before the unmap and still running on its own queues could read the new owner's zeros or bytes, or write into its tile through the old mapping. vram.rs keeps its freed pages cooling for 2 s (COOL) for the same reason; sparse.rs had nothing of the kind. Freed pool tiles (flush_parked, and release_if_unused when a placed buffer's last user goes) now go to State::cooling with the time they were freed. take_tile takes the oldest tile freed 2 s ago or more, then one of the free list (tiles of a pool never used), and otherwise takes back a retired pool or makes a heap: a tile freed less than 2 s ago is never handed out, and take_tile no longer flushes the parked tiles (they would only start cooling). retire_free_pools counts only free and cooled tiles, so a pool with a tile still cooling is not retired. new_mirror's "tiles at hand" check after a failed heap counts free, cooled and retired tiles, no longer parked ones. pool_bytes counts the cooling tiles as not mapped. This is a time bound, not a fence: a GPU frame longer than 2 s can still race. It holds more video memory while a title gives back and asks for tiles (about 2 s of freed tiles, 60 MB at the 466 tiles/s measured). Tested on the software adapter: cargo test --release -p xcl --lib sparse (51 passed, 0 failed, 1 ignored). New tests a_freed_pool_tile_cools_before_it_is_used_again and a_pool_with_a_tile_still_cooling_is_not_retired (an injected clock), and a_tile_given_back_is_not_used_again_before_it_cooled (a state on the software device); all three fail with COOL set to 0. a_tile_decommitted_and_committed_again_keeps_its_video_memory, changed here for the new rule, opens the hardware device and was not run. Not run on a GPU or a title. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 64 MiB pool heaps that back the 64 KiB pages of textures in title memory (vram::Pages) only grew: bind made a heap when the pool had no free tile, and nothing ever let one go. In two runs of a retail title 350 MB of those pools sat free, more after a streaming burst, on a card that was full. A pool heap all of whose tiles are free goes now. A tile is only in a free list after COOL in the cooling queue, so such a heap has no page in use, idle or cooling. After each placement, TilePool::take_free_heaps takes such heaps out: their tiles are not handed out again, and their index becomes free (TilePool::live, Pages.pools holds None there). The next heap takes the first free index. take_batch now gives make_heap the index to fill, so the pool and Pages.pools cannot disagree on it. A tile of a given-back heap that came back to the pool (none should) is dropped instead of handed out. A heap that came free is retired first, as sparse.rs retire_free_pools does with its pools. The next pool that is needed takes it back before a new heap is made, so placing and freeing in turn does not make and end a heap each time. It is let go once the page-mapping fence is past the value it had when the heap came free and 2 s went by. Even then it does not go at once: it goes through late_release (new: hold_heap, Dead::Heap), in a batch sealed after it. A texture the title released is held there and still maps pages of the heap, and work queued before that release may still read them. A heap destroyed under that work is a GPU page fault, where a page reused under it only gives wrong texels. So the heap goes once every queue XCL knows of is past that work, never before the textures held with it. If a queue never gets past, the heap is never released, which is no worse than before. The 'pools' figure of the memory line (page_bytes) counts the retired heaps that are not let go yet. Tested: cargo check -p xcl --tests; the vram and late_release unit tests on the software adapter (new: tile_pool_gives_back_wholly_free_heaps_and_reuses_their_index, retired_pool_heaps_go_after_the_fence_and_a_moment). The test of the churned pool now also checks the index each new heap gets. Not run: the tests that place textures on a hardware device (d32s8_targets_take_their_own_size_of_video_memory, reservable_agrees_with_the_driver and the other hardware tests), the title, and any real D3D12 run of bind with a heap given back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The build-ahead backlog took a lazy compute pipeline only when an earlier run had used its shaders (used-pipelines.txt). Any other compute pipeline was built at its first bind, which waits for it: in a retail title's run one of its threads spent 57 s in the driver's compiler on a program the two runs before had never used, while another of its threads waited for it. Compute pipelines of shaders no earlier run used now go to the backlog too, in a lane of their own. The backlog serves the known compute pipelines first, then this lane, then the known graphics ones, then the other graphics ones (translated first, then built) as before. The known compute ones, which used to share a lane with the known graphics ones in the order they were made, now all come before them. The new lane is under the rules of every pipeline no earlier run used: built only with XCL_PSO_AHEAD's cap not reached and 8 GB of commit free (ahead_room), counted against that cap, on the lowest-priority preload workers, a huge driver compile behind the gate and giving its turn to any build a bind waited for, and one a bind wants is left to the bind's workers. This shortens how long a new compute pipeline is waited for (or, with XCL_CS_PSO_WAIT_MS, how long its dispatches are skipped) and fills the driver blob folder for the next run. It cannot build all of a title's compute programs in its menus on a first run: a retail title has ~1 600 it never used, many of them taking the driver seconds to a minute. The cost: each pipeline built keeps ~400 KB in the driver whether it is used or not, and the known graphics pipelines are built later than before, so a draw is more likely to wait for one (or, with XCL_GFX_PSO_WAIT_MS, to be skipped). The test of known pipelines built ahead no longer says an unknown compute pipeline is still pending before its first bind (it may now be built ahead); it still says nobody used it before then. Tested with the unit tests only (software adapter): the lane order, room and cap, and a lazy compute pipeline of new shaders built with no bind when commit is free. Not run on a GPU or on the title. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…texel size A dumped texel was read as 4 bytes at a 4-byte stride whatever its format, and only four formats had a colour. A retail title's scene colour (RGBA16F), its normals and velocities (R16G16), ids (R32_UINT) and masks (R8) were written as black pictures, "format not decoded", with every other half texel in the raw values; a one-byte target was read past its rows. The picture stayed flat over a drawn G-buffer and the stages between could not be looked at. Texels are read at the size of their format and the float, 16-bit, 8-bit and integer render-target formats get a colour (floats tone-mapped as R11G11B10 is, NaN and infinity white). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The sparse windows' timing line is written only at power-of-two submit counts, and TILE_WORK is read only with XCL_LOOK_STATS=2, so the logs of a run that ended in a graphics driver hang had no rate of mapping changes in its last minute: the UpdateTileMappings calls and tiles a second could only be inferred. map_tiles and unmap_tiles now count their calls and tiles with relaxed atomics, always, split by the kind of window the resource lies in (sparse windows, view windows for GPU views; a placed buffer counts with its window), and the activity thread logs them every 2 s: tile mappings (2 s): sparse windows N calls mapping N tiles, N calls unmapping N tiles; GPU views N calls mapping N tiles, N calls unmapping N tiles The line is left out when there were no calls. The vram.rs tile-mapping queue (textures in title memory) is not counted here. Tested on the software adapter: cargo test --release -p xcl --lib sparse (52 passed, 0 failed, 1 ignored), new test the_tile_mapping_line_counts_since_the_last. The line was not seen in a run of a title. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Nothing in the log said how full the shared view heap got: the only line was the warning once it was full, so a run that came near the end, or how fast pages were placed, could not be told from the log. A retail title's heaps would need 2.56 times the heap if every page were placed. The shared heap now counts the pages of console heaps placed in it (placing one adds, a heap's release takes its pages off), and the first time the descriptors in use (those below the cursor, less the released ranges; the null views and memory windows at the start count) pass 50, 75 and 90 % of the heap, one info line says the mark, the descriptors in use, the heap's size and the pages placed. The full warning gives the same numbers. The 2 s "memory:" line in host.rs is left as it is: adding the heap there is more than a one-line change, and the marks give the same answer. Tested on the software adapter only: shared_heap_use_and_the_marks_it_passes (the arithmetic) and the placed-page count and marks in a_slot_whose_page_finds_no_room_names_the_null_views. Not run on a title, so the log lines have not been seen in a run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Nothing bounded the two-pass record buffers and argument scratch blocks alive at once: each recording holds its own until the GPU is done with it, and a retail title's world had about 0.8 GB of them a few seconds in, on a card its process kept nearly full. A committed buffer made there succeeds above the OS budget, so nothing else would have stopped them. A two-pass buffer is now made only if the bytes of those alive (held by recordings, waiting for their allocator, or free) stay within the cap: 1024 MiB by default, XCL_TWO_PASS_MB to choose. When they would not, the free ones in FREE_RES are let go first, oldest first, as many as it takes (the GPU is done with them). If that is not enough, the buffer is not made and the draw that asked for it is skipped, as one whose record does not fit the record buffer is today, with a warning the first 8 times and a count on the "two-pass buffers" line. The count is reserved before the buffer is made, so threads making them at once do not pass the cap together. Buffers held for a recording are never let go for the cap: when they go does not change. Tested on the software adapter only (unit test of the reservation and of making room). Not run with the title: whether 1 GiB skips draws in its world is not known. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The previous commit lowered the compute keep threshold to 20 ms, but translated_compute_pso reaches driver_cache::keep only when keep_compute_blob returns a blob, and keep_compute_blob returned none for a program under 16 KB of DXIL (COMPUTE_BLOB_MIN_DXIL). So the case that commit gave as its reason, a 4 KB program a retail title's thread spent 228 ms on in the driver, still kept no file and was compiled again in every run; its test called keep() directly and skipped that floor. The 16 KB floor now applies to the in-memory store only (compute_blob_kept): a compute build of the keep threshold or longer gives its blob to the disk cache whatever the program's size, and a small program's blob is not put in memory. A program of 16 KB or more is kept exactly as before. The graphics path keeps its floor. The blob of a small program goes through the same file and load path as the others (the driver refuses one of another driver, adapter or root signature, and the program is compiled as before). Tested with the unit tests only (software adapter): the new test of compute_blob_kept says a 4 KB program built in 228 ms goes to disk and not to memory. Not run on a GPU or on the title. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The previous commit wrote one line "<bytes> <setting>" per
XCL_COHERENT_HEAPS setting into <data>/cache/uma_coherent.txt. Every
build of a title shares that folder, and builds from before that commit
read the file with trim().parse::<usize>(): on the new text they got 0
and made a 512 MB coherent window with XCL_COHERENT_HEAPS unset, too
small for a retail title's 4.4 GB of GPU heaps, which then go to plain
memory where its shaders read zeros. They then wrote a bare number over
the file and dropped the other settings' sizes, so the two formats kept
overwriting each other, and a main run after a run of this build (as
the smoke comparison does) started with the small window.
uma_coherent.txt now stays one number, the size for the setting that
puts every heap in the window, read and written as before. The other
settings keep theirs in uma_coherent_<setting>.txt (':' as '_'), which
earlier builds never open. A uma_coherent.txt in the per-line format
reads as none here too and is written over with a number at the run's
first GPU heap.
Tested: cargo check -p xcl --tests; cargo test --release -p xcl --lib
coherent (7 passed, on the software adapter), with the changed test
the_stored_coherent_need_is_the_one_of_the_heaps_setting. Not run on
the title or on a hardware GPU.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…frees none Since freed pool tiles cool for 2 s before reuse, a pool can only be retired once its last tile has cooled. retire_free_pools was still called only right after flush_parked() freed tiles, and the tiles that flush freed were stamped with its own instant, so they could never complete a pool there. When the title stopped giving tiles back after a level unload or forget_mirrors, nothing called retire_free_pools again: the 64 MB heaps stayed (and retired heaps were not dropped) until some later give-back. A submit now also tries retire_free_pools when no tile was flushed but a tile in cooling has cooled or a retired heap waits to be dropped, at most once per COOL after the last try (retire_due, retire_tried), so a submit does not count the cooling queue every frame. A pool goes at most about 2 x COOL after its last tile was freed. The other call sites (the PARKED_MAX flushes while decommitting) are unchanged. Retiring later than the flush uses a fence value at least as new as the one the flush signalled after its unmap, so the heap is not dropped earlier than before. Tested through the software adapter only (no hardware GPU): a_submit_with_nothing_freed_retires_pools_once_tiles_cooled (pure, with an injected clock) and a_pool_goes_once_its_last_tile_cooled_with_nothing_parked (state on WARP: the pool's last tile is freed at a submit, then a submit COOL later with nothing parked retires it; it fails without the change). cargo test --release -p xcl --lib -- --test-threads=2: 1221 passed, 0 failed, 23 ignored, 52 tests that open the hardware GPU not run. Not run on a GPU or a title. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When a new two-pass buffer would take the buffers alive past XCL_TWO_PASS_MB, TwoPassBuf::make let the freed ones in FREE_RES go, oldest first, until they came to the bytes over the cap. It did so also when all of them came to less: the whole pool was let go, the second reserve still failed and the draw was skipped anyway. The recordings after it, which would have taken those buffers again and drawn, then found the pool empty, asked make() for new ones and were refused too. At the cap that skipped more draws than needed and sent a burst of resource destructions to the driver when the card is fullest. FreePool::take_room now gives nothing and keeps the pool when all it holds is less than asked, and make() works out the bytes over the cap with FREE_RES locked, so the free ones are in the load it compares. One attempt still (a buffer another thread reserves in between can make it fail after the free ones went, as before). Verified: the two_pass unit tests on the software adapter (take_room of more than the pool holds gives None and keeps it). Not run: a title, and the tests that open the hardware GPU. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The lane of compute pipelines no earlier run used, added two commits ago, came before the known graphics pipelines with no bound: every preload worker took from it while it held anything, and pipelines made later joined it ahead of all queued known graphics ones. A retail title makes ~1 600 compute pipelines it never used, some taking the driver a minute, and there are 2 to 4 preload workers, with one huge driver compile at a time behind the gate: all workers could sit on that lane (one compiling, the others parked at the gate) for the whole session, and no known graphics pipeline, not even one whose driver blob loads in milliseconds, would be built ahead. Each would then be built at its first draw on the title's thread. That commit's message said they are built "later than before"; they could be starved. Backlog::next now hands out one pipeline of that lane at a time (compute_out, cleared by Backlog::built when the worker's build is over or a bind took the job): while a worker builds one, the other workers take the known graphics pipelines and the rest in the order as before. The known compute pipelines still come first, and the lane is still under ahead_room, ahead_cap and the gate. Left out: when nothing else is queued the other workers stay idle rather than build more new compute pipelines; the lane drains at one worker's speed. A known huge graphics build can still wait at the gate while the lane's build holds the only huge slot (XCL_HUGE_PSO_CONCURRENCY default 1), as any two huge builds ahead of their use do. Tested with the unit tests only (software adapter): the new test takes pipelines from the backlog without finishing them and gets the known graphics ones while a new compute one is out, and the next new compute one only after it is built; the lane order test still passes. Not run on a GPU or on the title. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ings Since the per-setting sizes, a run that had lasted 60 s stored what it had put in the coherent window by then, also when that was less, with every XCL_COHERENT_HEAPS setting. With the default one (every GPU heap in the window) the size used to only grow. A run that stays in the menu, or a fixed-length smoke run that loads no level, has asked for about 1 GB of a full run's 4.5 GB by then: stored, it makes the next full run's window about 1.5 GB, and the heaps past it go to plain memory, where a retail title's shaders read zeros. The stale size of the incident only needed the per-setting split, so lowering is kept for the settings that send heaps to the sparse windows (sparse, sparse:N), where a size measured with more in the window cost video memory for nothing, and there it comes down by half at most per run, so one short run cannot take a full run's size away at once. The default setting only grows the stored size again. Tested: cargo test --release -p xcl --lib coherent (8 passed, on the software adapter), new test only_the_sparse_heaps_settings_lower_the_stored_coherent_need. Not run on the title or on a hardware GPU. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With XCL_LAZY_PSO=0, go_background sent a compute pipeline to the workers with pso_async::submit, which gave it no console program (record 0), although go_background had computed it for the lazy path. resolve_within writes the "compute pipeline of record X not built after N ms" line only for a known record, so with XCL_CS_PSO_WAIT_MS set a late pipeline on that path fell back to the generic line, which is written for the first 16 and then at powers of two: most late programs were not logged at all. The non-lazy path now passes the record (pso_async::submit_with). Nothing but the log line reads it. Tested with the unit tests only (software adapter): the new test says a pipeline sent to the workers when made carries its record. Not run on a GPU or on the title. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…zero samplers Review of d4624b7: its test covered only pc_samplers() and that D3D12 makes a 2 048-sampler shader-visible heap. Sizing the PC heap with the title's count again, or filling only the title's slots, passed every test; the second leaves indexes 128 to 2047 unwritten sampler descriptors, which D3D12 leaves undefined, the hazard d4624b7 removes. The PC heap's description moves into pc_descriptor_heap_desc and the zero sampler fill into zero_samplers, which now fills every sampler the PC heap holds (its own GetDesc, called from XCL, so the PC's) instead of a count passed beside it. No behaviour change. The new test a_shader_visible_sampler_heap_has_the_zero_sampler_at_every_index makes a shader-visible sampler heap of 128 slots through device xcl-dev#14 on a WARP device adopted as a title's, and checks that its PC heap holds 2 048 samplers and that the descriptor bytes of every one, 2047 included, are those of slot 0. Checked that it fails with the PC heap sized at the title's 128 ("the PC heap": 128, not 2048) and with the fill stopped at 128 ("PC sampler 128": zero bytes). Tested on the software adapter only (WARP). Not run on the hardware GPU or on a title. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
At the title's last Release of an allocator, alloc_pool::forget handed back (console_list::allocator_reset) only what the PC allocators made for it held, never what the allocator itself held. So the two-pass buffers in ALLOC_RES for it, and the unified-memory blocks in PENDING for it, went back only if a later allocator got the same address and was reset. Before the two-pass cap that was a leak; with the cap (XCL_TWO_PASS_MB, 1 GiB by default) the buffers stay counted alive, and a title that destroys and makes allocators again (level changes) could reach the cap and lose its two-pass draws for the rest of the session. forget now hands back what the allocator itself held when its backing is free: no list records on it and every submit of one is passed by the GPU (the fences `executed` set) - the same test a Reset of it passes before allocator_reset runs. It is taken before the loop, since the allocator may be both its own stand-in and put aside, and its backing goes at the first. Still left as before: an allocator a list still records on at its Release, or whose submits the GPU has not passed, keeps what it held (its backing is no longer tracked, so nothing says when the GPU is done with it); the next commit logs those bytes so a cap held by them can be seen. Test: a_released_allocator_gives_back_its_two_pass_buffers (WARP buffers, synthetic allocators): the released allocator's buffer goes to FREE_RES, that of one a list still records on stays in ALLOC_RES. It fails with the hand-back disabled. The d3d12x unit tests pass on the software adapter; the tests that open the hardware GPU and a title run were not run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The two-pass stats line said how many bytes are alive and how many of them are kept for reuse, but not where the rest wait. Bytes held in ALLOC_RES for an allocator that is never reset again (one released while a list still recorded on it or its submits were in flight, which alloc_pool::forget still leaves), or in UNKNOWN_RES, count against XCL_TWO_PASS_MB; the line now gives both, so a cap held by them can be told from one held by recordings. The locks are only tried, as FREE_RES already is: a buffer can be let go with ALLOC_RES locked on the same thread. Logging only; no test. Built and the two_pass unit tests run on the software adapter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… it with Review of d4624b7: the PC heap behind a shader-visible console sampler heap now holds 2 048 samplers, and descriptor heap xcl-dev#8 GetDesc was not hooked, so a title asking its 128-slot sampler heap for its description read 2 048. A title that sizes an allocator or a loop from that count makes samplers or copies at console handles past its 128 16-byte slots: console_heap::slot finds none there, dev_create_sampler_x hands the handle to the PC CreateSampler as it is, and the driver writes a sampler descriptor at that address in the title's memory. A view heap already read twice its slots, and one whose views are in the shared heap read no shader-visible flag. Whether the retail title calls GetDesc on these heaps was not checked (no trace taken). Device xcl-dev#14 now keeps the description each console CBV/SRV/UAV and sampler heap was made with (the title's type, 4 included, count, flags and node mask) until the heap's last Release, and xcl-dev#8 answers it to calls from the title's images, returned through the hidden pointer called the C++ way or the C way (this_first, as device xcl-dev#25 / xcl-dev#26). Other heaps, and every call from XCL itself (the split slot: list_x::pc_heaps reads the PC flags), get the PC description as before. New test a_console_heap_describes_itself_as_the_title_made_it, on a WARP device adopted as a title's: a shader-visible sampler heap of 128 made through device xcl-dev#14 answers [1, 128, 1, 0] both ways while XCL's own GetDesc says 2 048; a view heap answers the PC description until it is known as a console heap of type 4 and 64 slots, then that; both are forgotten when released; xcl-dev#8 is in the descriptor heap's console slots. Checked that it fails with the hook answering the PC description ("the sampler heap": [1, 2048, 1, 1]). The view heap's recording at creation is not covered (making a view heap through xcl-dev#14 makes the process-wide shared heap). Tested on the software adapter only (WARP). Not run on the hardware GPU or on a title. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d from what goes into it, free page pool heaps of title textures given back) Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…isible sampler heap, the null views for a view slot with no room, the shared heap's fill in the log) Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ve-loops PE loader: a title's CLZERO loops run as native code on a CPU without CLZERO
…half-headroom D3D12.X: a build the title already draws without waits for half the commit headroom
…ole-off-thread D3D12.X: an indirect dispatch does not build a split program's whole form in the call
|
What I do now: the runs on this head go on with AI use: Claude Code (Claude Fable 5.2) ran this and wrote it. |
…wave32 Options::default() is wave64, so the "HLSL wave32" form of gpu_compute_thread_limits_leave_the_lanes_past_them_out was the native wave64 form: on a GPU without wave64 (every NVIDIA card) CreateComputePipelineState refused it with E_INVALIDARG and the test failed before it checked anything. The test only ever ran on the software adapter, where it skips. With wave64 off it passes on an RTX 5090 in all six forms that card runs (HLSL, direct and per-lane; wave32 and split wave64). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With XCL_TEXTURE_LEVEL_PAGES=1 a streamed texture's level gets video memory pages at the first upload with texels for it, and kept them for as long as the texture lived. A streaming title takes the memory from under the large levels of textures it no longer shows at that size (its GPU-view pages unmapped), and the texture is uploaded again with those levels all zeros: the pages stayed, holding zeros. In a retail title's world on an 8 GB card the target pages grew from 2.7 GB to 4.2 GB in four minutes with 0 MB idle, more than the title's whole texture pool (63,632 pages, 3.98 GB), and video memory reached 10.2 GB on a 7.1 GB budget. Before such an upload a group of levels that has pages and is all zeros now gives them back (vram::unmap_levels: its tiles unmapped on the mapping queue, its pages released as a released texture's are, idle and then back to the pools when no other texture uses them). Tiles without memory read as zeros (tiled resources tier 2), as the zero texels the upload would have written; the level gets pages again with its next texels (map_levels). Test: the level-pages GPU test goes on: the title decommits mip 0 again, the next upload gives back mip 0's pages (86 -> 22 tiles with pages; 86 without this change), mip 0 reads zeros and the other levels keep their texels, the other texture on the same pages keeps them, and mip 0 gets them back with its texels. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
On our card, a compute pipeline created from its stored driver blob takes as long as a fresh compile (RTX 4080 16 GB, driver 621.40, Windows 11 26300; This explains two things we kept seeing on this head: the shader preparation takes 7-8 minutes at every launch (also directly after a launch that completed it), and the world shows no frame for the first 10 minutes. Measured with a local timing line in the preparation workers (one line per pipeline over 1 s; two launches, 192 lines):
So for these large programs the stored blob saves nothing here. Questions for the other NVIDIA testers: do you see "driver blob supplied" followed by a finish line over 10 s for compute pipelines on your driver version? If someone on an older driver sees them load in under a second, this is a driver regression and worth knowing before anyone tunes around it. What I can try next, unless someone already has: the same launch with the profile at 2048 MB; one launch with the NVIDIA cache folder for this exe cleared and rebuilt (in case the driver's own cache entry for these programs is rejected each time); and splitting, i.e. whether the pieces of a split program load fast where the whole form does not. Tell me which is most useful. Numbers are from logs of real runs on the hardware above. AI use: Claude Code (Claude Fable 5.2) ran the tests and wrote this; the timing line is a local diagnostic, not a PR. |
|
Re your question about other NVIDIA versions: in earlier runtime logs from a 12 GB RTX 5070 Ti Laptop on 621.24, 141 of 147 compute PSO calls of at least 750,000 B DXIL with
I paired start/finish lines by compile ID and verified matching thread and DXIL size. These are the title-runtime calls from the same release run on Windows 11: |
|
Follow-up to the stored-blob timing above: I posted a plan on #2088 for a small PR that lets the shader preparation skip records whose blob it has already verified (marker with driver identity and blob length), which should cut the 7-8 minutes per launch on NVIDIA to seconds: #2088 (latest comment). Starting now in a branch off |
|
@ettehn thank you, that is exactly the comparison I needed: under 1 s with a supplied blob on 621.24, against 15-20 s here on 621.40 for the same size class. So the blobs can load fast and something on this machine prevents it. What differs here besides the driver version: AI use: Claude Code (Claude Fable 5.2). |
Review note on xcl-dev#2927: unmap_levels searched the texture's page keys and swap_removed one for each key given back, under PAGES: quadratic in the pages of a large level. remove_once_each counts the keys to drop and takes one occurrence of each in a single retain. Test: remove_once_each_takes_one_occurrence_for_each_naming (duplicates, keys not named, nothing to take); the level-pages GPU test still passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Six tests fail on the clean
I have not looked into causes; posting so that nobody takes them for regressions of a PR tested on NVIDIA. If they pass for others on this head, tell me and I will dig into what differs here. AI use: Claude Code (Claude Fable 5.2) ran the tests and wrote this. |
|
Follow-up on the slow blob loads (RTX 4080, driver 621.40): the 1 GiB profile is not the cause. The same build under another exe name (no profile), second launch, so with the driver's own cache for that name warm: 67 creations from stored blobs at 750 KB-1 MB of DXIL took 19.7 s on average, 13 above 1 MB took 28.2 s (with the profile: 14.9 s and 19.7 s). The first launch under that name, with the driver's cache cold, took 50 s and 74 s for the same size classes, like a compile without a blob. So on this machine the stored blob never makes creation fast; whatever speed there is comes from the driver's own cache, and for the large programs that is 15-30 s each. @ettehn measured under 1 s on 621.24 and @andrewDoing milliseconds on 616.92 (small synthetic programs, on #2951), which leaves the driver version as the main suspect here. A rollback to 621.24 would settle it; that needs the machine's owner, so it will not happen tonight. AI use: Claude Code (Claude Fable 5.2) ran the tests and wrote this. |
Reverts accee0a (mesh stage views reach 1 MiB by default) and 4ac7558 (tiles asked for at a submit are filled within 1024 MB). With both, the scenes behind a title's full-screen title cards were not drawn at all; with the old values (XCL_VIEW_REACH_MB=0, XCL_MIRROR_FILL_MB=16) on the same binary they were. Neither change had fixed the heads it was meant for. Both values stay reachable through their switches. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A pipeline stream with a console mesh shader returns from translated_mesh_stream before note_pipeline_for_dump, so a dumped target drawn by mesh pipelines (a title's whole G-buffer) listed them as "not known" and their pixel shaders were not written. After the stream is made, its MS (also from the AS slot) and PS, render target 0's blend and the formats are noted as a graphics desc's are. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A title's G-buffer target is drawn by about 30 pipelines; with 12 the rest were cut off as "and N more", their shaders not written. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With 16 MB a submit, a close-up of a detailed mesh was drawn while part of the mesh data it asked for was still unfilled (it reads zero): heads came out as shards and slabs, on some runs and not others. A/B on one binary as a Series S: 16 MB, shards in 3 of 3 runs that reached the close-ups; 256 MB, none in 5 runs, the scenes behind full-screen title cards drawn, no change in frame rate. (1024 MB went out with build 16 together with a longer mesh view reach; the reach was what blanked those scenes, not the fill.) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Bisect result for the black world on our Intel + RTX 4080 machine: it is #2892 (CLZERO loops as native code on a CPU without CLZERO); |
|
Correction to my bisect result above: it is wrong. The "visible" builds before #2892 were still on the loading screens when their frame dumps were taken (loading takes 7+ minutes without that PR on this Intel CPU; draw counters confirm it), so #2892 is not shown to blacken anything. Details: #2892 (latest comment). What remains true here: the world is 100 % black in every build that reaches it on this RTX 4080 machine, with any heap placement, with and without #2929, and I have no world frame of any build that is not black. So the question I asked earlier is the open one: does anyone see a lit world on |
What is in it
Tested
cargo test --workspace -- --test-threads=4: N passed, N failed, N ignored (SKIPPED GPU tests: …)Regression run
main:
PR:
Not tested
AI use