Repository navigation
GPU: an opt-in constant takes the place of a named program that does not run (VICTORY_STAND_IN) - #2620
GPU: an opt-in constant takes the place of a named program that does not run (VICTORY_STAND_IN)#2620r4tedx wants to merge 5 commits into
Conversation
|
Reviewed: superset of #2619 — adds |
9d73ed6 to
af1973b
Compare
|
Automated triage for the maintainers. Needs the maintainer's decision. This PR's own commit is On your reply: the rebase onto the split-out #2871 is noted. It doesn't change the open points: the scope decision on #2619 applies here too, and the evidence for this part is weaker. CI Generated by Claude Code |
clear_unordered took a dynamic slot of the bound view heap on every call and held it until the list was reset, so a list that clears the same view many times (a per-frame clear inside a loop of passes, say) took one slot per clear from the capped heap; when the pool runs out, later draws and dispatches that need dynamic slots are dropped. The list's draw state now keeps the slot it made per view (view heap, view, host resource) and clears of that view reuse it. The cache lives with the slots: it goes when the list is reset (or released) and at a cut of the list, where root views are made again too. The host resource in the key is one the list keeps, so its address names no other while the slot is held. The view is now made before a slot is taken, so a view the host cannot make takes none. The clear itself moves into State::clear_view (taking the resolved view, returning whether it was recorded), which clear_unordered calls after it looks the title's CPU handle up; the test drives it directly. Test (WARP): eight clears of a view take one slot, another view one more, a further clear of the first none; the views hold their last clears; the slots come back at reset. HostHeap::dynamic_free (tests only) counts the free slots. Split from Marvisak#2619 at the maintainer's triage. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…held A view cleared on both sides of a cut (a wait that moves the recording on to a new host list), both segments submitted in order: the first segment's clears share one slot, the cut gives none back, the second segment takes one slot of its own (its view heap is bound afresh) and shares it for its next clear, and both stay held until the list is reset, when both come back. A read in each segment sees the last clear recorded before it in that segment. Suggested in review of Marvisak#2871. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… (VICTORY_AMBIENT) Some outputs have inputs the host never fills: light gathered by rays walks structures that are not built yet, so the program that resolves it leaves black (or whatever its memory held), and shaded surfaces read it. VICTORY_AMBIENT=<program>:<view>:<value> clears one unordered view after every dispatch, direct or indirect, of the program whose shader hash the log prints, to a constant: - the view as the console code addresses it: root parameter and table offset in dwords (s1+176, the diagnostics' notation). It comes from the shader, so it holds across translator versions; the n-th view would shift as the translator finds more; - the value: r,g,b[,a]. A float or normalized view takes it as it is (ClearUnorderedAccessViewFloat); an integer view takes it packed: R9G9B9E5 or R11G11B10 into a 32-bit word, RGBA16F into R16G16B16A16_UINT or R32G32_UINT, by the texture's format or as named (rgb9e5=, r11g11b10=, rgba16f=); 0x..., mask (all ones) or zero is a raw word for an integer view of any width (zero clears floats too). The clear goes through the existing UAV clear path (a dynamic slot of the bound view heap), between UAV barriers on the resource. Nothing runs while the variable is unset. The first dispatch of a named program logs its table views, formats, size and the packed value; counts are logged every 5 s. Tests (WARP): a program writes three views of a title table; after it, the two its rules name hold the R9G9B9E5 word and the RGBA16F colour, the third keeps what it wrote, and a program no rule names changes nothing. CPU: R9G9B9E5 against a reference encoder (smallest shared exponent whose mantissas fit), small floats against a nearest-code search, the rules' parsing and the packing chosen per format. The idea, and R9G9B9E5 held as 32-bit words, come from the Belobug fork (github.com/Belobug/VIctory-Belobug-AMD, 0603123 and 4f45ab8, GPL-3.0-or-later), which matches its program by name; here the user names it by hash, so no program is named in the code. The masks and zeros for narrower integer outputs follow ScarlettPort's stand-in encodings (github.com/ZigZagBoi1/ScarlettPort, emit/stand_in.rs, GPL-3.0-or-later). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ords ran An indirect dispatch with a host pipeline and a count of zero runs no records, but the stand-ins after it still cleared the named views, over what the title expected them to keep (review of Marvisak#2619). The stand-ins follow shader work, so after an indirect dispatch: - at most no records (MaxCommandCount 0): no clears; - a record count in a buffer: the clears are predicated on it (SetPredication, D3D12_PREDICATION_OP_EQUAL_ZERO), so a count of zero skips them on the GPU. A predicate is a 64-bit value at an 8-byte aligned offset while the count is a 32-bit word anywhere, so the count is copied into the low half of the list's own predicate word (8 bytes of video memory, zeroed at creation, common between uses). The copy is recorded just before the execution, where it reads the count, so the word holds the count it read whatever its records then write; the clears after it move the word to PREDICATION and back. Only the Clear call is predicated, not the copies and barriers that ready its view. Without that word the clears are skipped and logged once; - no count: every clear, as before. Direct dispatches are unchanged. Test (WARP): a view seeded with a sentinel, a host ExecuteIndirect of a program that writes it (at most one record), then the stand-in. Count 0 (at offset 4, a nonzero word after it): the sentinel survives. Count 1: the stand-in's value. At most no records: the sentinel. No count: the stand-in's value. Tests count their own stand-ins: under test, ambient::filled() is the count of this thread (each test runs on its own), not the run's, which the stand-in tests running alongside add to. The stand-in tests' deltas of the shared count failed when they ran in parallel. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…not run (VICTORY_STAND_IN) A program can be held back (one walking acceleration structures the builder has not built), dropped, or left without a host pipeline (it does not translate). Whatever it would have written then holds what the memory held, and passes that read it see garbage: a shadow mask that nothing writes can read as "in shadow" everywhere. VICTORY_STAND_IN takes rules written as VICTORY_AMBIENT's (<program hash>:<view>:<value>, separated by ;). Where a dispatch of a named program, direct or indirect, does not run, its named views are cleared to the values in its place. Nothing of the program runs, so it needs no translation, walks no structure, and holds back nothing that is held back now. Only named programs are touched, and nothing happens while the variable is unset. Every way a dispatch does not run reaches it: dispatch() and execute_indirect() are wrappers over their old bodies. A direct dispatch records whether it ran in the list state, so an early return of any kind (skipped, held back, no host pipeline, tables not made) leaves it unset; an indirect dispatch returns false. Indirect draws are left alone. The program's hash comes from the title pipeline without asking for a translation (pipeline::compute_hash). Since the program's views are not known when it does not run, the rules are not checked against them; the first match logs the view, formats and value as before. An indirect dispatch that does not run stands in for the records it would have run, as VICTORY_AMBIENT does after one that runs: at most no records, no clears; a record count in a title buffer, the clears predicated on it (its host copy brought up to date first, as the execution would have; a count outside title buffers skips them, logged once); no count, every clear. Test (WARP): three programs that do not translate (no host pipeline, the gate a held-back program meets too). A named one's direct dispatch clears its two views (R16_FLOAT to 1, R8_UINT to a mask), a named one's indirect dispatch clears its view (0.5), and an indirect draw and a program no rule names clear nothing; no dispatch runs. Read back after the list: 1.0, 0xff, 0.5. And a program that does not translate, dispatched indirectly over a view seeded with a sentinel: at most one record with a count of 0 (at offset 4 of a title buffer, a nonzero word after it) keeps the sentinel, a count of 1 clears; at most no records keeps it, no count clears. The idea of standing in for a ray-traced shadow pass with "lit" comes from ScarlettPort's shadow-mask stand-in (github.com/ZigZagBoi1/ScarlettPort, emit/stand_in.rs, GPL-3.0-or-later), which rewrites the program's stores at translation; here the program does not run at all. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
af1973b to
33df069
Compare
|
Rebased with #2619, which is now stacked on #2871 (the slot sharing, split out at triage). This PR's own commit is the last one, 33df069 (the same change as af1973b). The merge order is #2871, #2619, then this. WARP at 33df069 (on AI-assisted |
Stacked on #2619 (VICTORY_AMBIENT), which is stacked on #2871 (clears of one view share one dynamic slot). Only the last commit is new here; merge order is #2871, #2619, then this.
A program can be held back (one walking acceleration structures the builder has not built yet), dropped, or left without a host pipeline (it does not translate). Its outputs then keep whatever the memory held, and the passes that read them see garbage: a shadow mask nothing writes can read as "in shadow" everywhere. This adds a run-time switch that clears the views a named program would have written, in place of a dispatch of it that did not run.
Opt-in, off by default. Nothing happens while
VICTORY_STAND_INis unset, and only named programs are touched. No title program names or hashes appear in the code: the user names the program by the shader hash the log already prints.Syntax
VICTORY_STAND_IN=<program>:<view>:<value>, rules separated by;, written exactly as forVICTORY_AMBIENT:<program>: the 16-hex-digit shader hash the log prints for the compute program.<view>: root parameter and table offset in dwords,s1+0or1+0.<value>:r,g,b[,a], optionallyrgb9e5=/r11g11b10=/rgba16f=for an integer view; or0x...,mask,zero.Example (a "lit" R16_FLOAT mask and an all-ones R8_UINT one):
VICTORY_STAND_IN=0123456789abcdef:s1+0:1,1,1;0123456789abcdef:s1+8:mask. An integer view whose format does not say how a colour packs takes a raw word (0x...,mask,zero).What it does
dispatch()andexecute_indirect()become thin wrappers over their old bodies (run_dispatch()/run_indirect()), so every way a dispatch does not run reaches the stand-in. A direct dispatch records in the list state whether it ran, so an early return of any kind (skipped, held back, no host pipeline, tables not made) leaves the flag unset. An indirect dispatch returns false. Indirect draws are left alone.pipeline::compute_hash). The program's views are not known when it does not run, so the rules are not checked against them. The first match logs the view, formats and value (withran = false), as forVICTORY_AMBIENT.VICTORY_AMBIENT, including its one dynamic slot per view per list.Tests
The title was not used in these tests.
stand_ins_take_the_place_of_dispatches_that_do_not_run(WARP): three programs that do not translate, so they get no host pipeline, the same gate a held-back program meets. A named program's direct dispatch clears its two views (R16_FLOAT to 1, R8_UINT to a mask). A named program's indirect dispatch clears its view (0.5). An indirect draw, and a program no rule names, clear nothing, and no dispatch runs. Read back after the list: 1.0, 0xff, 0.5.mainf3578e3, WARP):cargo clippy -p victory-gpu --all-targets --locked -- -D warningsand the same with--all-features, both clean;VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --features diagnostics --lib --locked: 253 passed, 0 failed, 1 ignored (an existing benchmark).In game
In our play build (RTX 5070, local title data used for the in-game measurement; only log lines and a description of the picture are reported), with #2311 holding back the BVH walks:
Credits
runtime/victory/crates/victory-shader/src/emit/stand_in.rs, GPL-3.0-or-later). That version rewrites the program's stores at translation. Here the program does not run at all.🤖 Generated with Claude Code