Merge candidate: triaged ready-to-merge PRs built and tested together (draft, in progress) #3327
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!3327
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3327"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@pes7 on GitHub · 2026-11-26 18:16 UTC · original
pes7:merge/best-2026-11-26→main· +12235 −2362 · 78 files · 284 commits · draftDraft, work in progress. A merge candidate:
mainplus the open pull requests that a triage marked ready to merge, merged together, built and tested together, conflicts between them resolved by hand. Posted so others can see the merge work and not repeat it; coordination in #1633.Nothing here closes or replaces any pull request: each one stays open and is closed only when it lands in
main. This PR is not meant to be merged as is; it shows which set works together and which pull requests need a rebase.How the set was chosen
1 494 open pull requests (26.11) → 1 004 mergeable into
main, with a greencheck, not drafts → 968 touching code. Left out: diagnostics and opt-in switches, benchmarks, CI, README/CLI, Wine/Linux-only, stacked pull requests, more than 600 changed lines or 6 files, known duplicates, build-profile changes. The rest scored on: a correctness/crash/performance fix, its author already merged upstream, small, has tests. 134 picked, merged oldest first after ours.Unlike the Forge train (#1624, every PR that merges and passes
cargo check), this is a triaged subset, and each step runs clippy and the full test suite, plus the title itself.Status (base
63bcca43c)merge/best-2026-11-26)merge/pass2, not yet builtChecked locally on Windows for this branch:
cargo build --release --workspace: okcargo clippy --workspace --all-targets --locked -- -D warnings, and with--all-features: okcargo test --workspace --locked --no-fail-fast: 30 test binaries, 1 019 passed, 0 failed, 10 ignoredTwo commits of mine on top, both needed by the set, not by any single PR:
lower.rsgrows past the 512 KiB asset policy with the set (520 563 → 544 760 bytes), so its tests move tolower_tests.rs, as #3097 does (#3097 itself conflicts with the set).In this branch (97)
Conflicts resolved on
merge/pass2(18, building next)Covered by a merged PR
Need a rebase onto this set
mainno longer has🤖 Generated with Claude Code
With the node's base taken from a root descriptor ("Built"), the node's byte offset was shifted and added in 32 bits and then zero-extended to 64: a BVH larger than 2 GiB has offsets that do not fit, and any negative intermediate (the adds are signed) became about 4 GiB too large instead of sign-extending. The explicit-descriptor path next to it already does the shift in 64 bits, so the two halves of the same instruction disagreed. The offset is now built in 64 bits for a raw (title-memory) base — shift, constant, and the computed part — and only the buffer-view path keeps the 32-bit form D3D12 takes for a buffer's offset. `intersections_with_64_bit_pointers_on_the_gpu_equal_the_reference` covers this path on the card; it and the rest of the lib suite are green (247 passed, 3 ignored). A case that *fails* before this needs a BVH of more than 2 GiB, which this machine does not hold, so the change is argued from the arithmetic rather than from a red test — if a title-side repro shows up, this is the first place to look.The title asks for 1 245 184 descriptor slots, more than the 1 000 000 a host heap holds, and it walks them in increasing order. "Log when the high-water mark moves" is therefore one line per distinct slot: 199 846 of the first 200 000 lines of a run, ~8 000 a second, on the thread recording the frame. That was the whole of the first frame's stall: before 310 932 lines in the run, first frame 21 433 ms after 231 lines in the run, first frame 33 ms Same build, same warm caches (926 MB pipeline library, 1 347 MB shader cache), same 150 s window. What the line said - that slots above the host heap's count are not mirrored - is what the one line now says. The underlying problem is not this change: 245 184 title slots can never be mirrored because they exceed the tier-2 heap limit, which needs either several host heaps with the index arithmetic adjusted or the views above 1 M placed elsewhere. That is why the first world frames get null views. cargo test --workspace --locked; both clippy configurations with -D warnings; cargo xtask policy.67e8ae1) into the value reuse branch b7e090c8a8Translated shaders clamp every heap index they compute below HEAP_VIEWS, and NULL_BUFFER_VIEW = HEAP_VIEWS - 2 is the slot a shader reads instead of a slot with no buffer view. HEAP_VIEWS was 1 << 21 = 2 097 152, the console-shaped heap the indices were first written for, but D3D12_MAX_SHADER_VISIBLE_DESCRIPTOR_HEAP_SIZE_TIER_2 is 1 000 000 (victory-gpu's PORTABLE_VIEWS): the clamp allowed an index 32 MB past the end of any heap that can exist, and what is there is read as a descriptor. The code knew - "a host that caps its heaps below HEAP_VIEWS (NVIDIA) faults on an index past them" - and on the title it never got as far as the null slots: host view heap capped at 1000000 count=1245184 no room for the null buffer views: ... count=934464 total=1000000 HEAP_VIEWS is now the largest heap a host may create (1 000 000), so every index the clamp can produce is inside the heap and NULL_BUFFER_VIEW is 999 998. A heap capped at PORTABLE_VIEWS keeps the top of itself for those two slots (MIN_DYNAMIC - NULL_RESERVE dynamic slots), so the title slots and the dynamic ones end below them and the warning above no longer happens; measured on the title, warm caches: "null buffer views: 0". The title asks for 1 245 184 slots, more than a host will hold, so slots above the capped heap's title region are still unmirrored - they read a null slot now, which is the safe answer the clamp was meant to give, not a read outside the heap. HEAP_VIEWS is baked into translated shaders, so the shader cache is translated once more (SOURCE_HASH changes); the pipeline library is keyed by the title's shaders and is unaffected. cargo test --workspace --locked; both clippy configurations with -D warnings; cargo xtask policy.`draw` and `dispatch` poll `fence.GetCompletedValue()` and call `GetDeviceRemovedReason` on every iteration while a thread spins. One event per submission, `SetEventOnCompletion`, and `WaitForSingleObject` in 100 ms slices: the same device-removal report, no CPU burned while the GPU works, and no device call in a hot loop. The 100 ms timeout is what keeps that check: a removed device never signals, so an INFINITE wait would hang the run instead of reporting it. `WAIT_FAILED` returns an error rather than looping. Interleaved A/B, 9 runs each, `emit::` with --test-threads=8: wall 9 080 ms -> 9 084 ms CPU (median) 5 562 ms -> 4 438 ms -20% Every event run stayed under 4.66 s of CPU; eight of the nine spin runs were at 4.88 s or above. `draw` and `dispatch` are `#[cfg(test)]`, so nothing in the game changes. Cargo.toml gains Win32_Security and Win32_System_Threading for the optional windows dependency (CreateEventW sits behind both); victory-gpu already enables them. cargo test --workspace --locked; both clippy configurations with -D warnings; cargo xtask policy.A dispatch made a new queue, allocator, list, fence and event every call. Making those five costs 4.19 ms of an 8.35 ms dispatch (200 iterations, release, hardware device), and emit::valu_tests runs hundreds of dispatches for one shader: every f16 pattern, two opcodes, two backends. Keep them in `Host`, bump the fence value per dispatch, and reset the list with the dispatch's own PSO. That is safe here because the GPU tests run one at a time (ONE_AT_A_TIME) and every dispatch waits for its fence, so the allocator is never in use when it is reset. `Drop for Reused` closes the event; `draw` still makes its own, since it is not on this path. v_cvt_norm_i16_and_u16_f16_round_the_exact_product 4.81 s -> 2.17 s emit:: suite, wall 9 084 -> 6 053 ms emit:: suite, CPU 4 438 -> 2 891 ms Together with the event wait, against the original code: emit:: wall 9 080 -> 6 053 ms and CPU 5 562 -> 2 891 ms. cargo test --workspace --locked; both clippy configurations with -D warnings; cargo xtask policy.The switch answers one question - "is this shader the one that removes the device (or paints the wrong picture)?" - and it could only be asked of a diagnostics build. That is the build in which the removal does not reproduce on the machines seen so far: a diagnostics build does more work per submission, so the frame that hangs the GPU in a release build never gets there (measured here: release removes the device 10 s in, the same build with `--features diagnostics` and no debug layer runs 180 s and does not remove it at all). So `is_skipped`, `skipped_shader` and `parse_skip_hashes` are no longer behind the feature, and the three call sites keep the skip but gate only their reporting (`note_drop`, `dropped`, `shaders_of`). A release build now answers the question testers are actually asking: VICTORY_SKIP_PIPELINES=0602c2384acbb3b2 -> dropped 1/frame in the menu and a skipped pipeline is dropped the way one with no host pipeline is (the frame's "dropped N without a host pipeline" counter moves). No behaviour change without the variable: `is_skipped` reads it once, and an empty list is the `false` it was before. cargo test --workspace --locked; both clippy configurations with -D warnings; cargo xtask policy.The library's pipelines are named after the shaders they are made from, so a change to the translator (`victory_shader::SOURCE_HASH`) makes every name in it useless - and the first run after one wrote the few pipelines it made over the old library. Measured on the title: warm: host pipeline library loaded bytes=970507898 ms=57 (926 MB, 27 160 pipelines) after a translator change, the next start-up says: host pipeline library loaded bytes=626800 (612 KB) That 926 MB was a 7.5 minute warm-up (`translate --cache --pipelines`, made=23057 on a cold library). It is not a truncated write - `write_atomically` is already there, and so is the translator hash in the pre build's list - the new library is simply small and replaces the old one. The cost lands on the loop that needs the cache most: bisecting between two builds paid the warm-up for each of them, in turn, every time. So each translation keeps its library in `dir/<SOURCE_HASH>`, and the two newest are kept (`KEPT`): the one in use and the previous build's, which is what a bisection needs. A run only ever writes its own directory, and pruning takes a directory only when its name is 16 lowercase hex digits and it holds `host-pipelines.bin`, so a `backup/` someone keeps in the cache directory is left alone (there is a test with a sentinel file in one). Measured (retail title, two runs in a row, `O:\tmp\victory-cache\pipelines`): run 1: host pipeline library saved bytes=3086 (no load: first use of this key) host pipeline library saved bytes=7488 run 2: host pipeline library loaded bytes=7488 ms=0 -> O:\tmp\victory-cache\pipelines\94ef170ae2f5e8da\host-pipelines.bin Nothing else moves: `use_pipeline_cache` still takes the same directory, and the pipeline library of a build that is not the current one is now left alone instead of being overwritten. Rebased onto today's `main`: the file gained `tag()` (which holds the translator hash for the pre build's list) and `write_atomically`, so this is the directory part only, applied to those. cargo test --release -p victory-gpu (229 tests); clippy clean; both `victory` configurations build.Three image instructions translated into DXIL operations the validator rejects (and a driver may refuse, or run wrongly), where refusing them is the right outcome: - a gather (`image_gather4_lz`, `_l`, `_lz_o`, `_l_o`) from a 1D or 3D image: "gather requires resource declared as texture/2D/Cube/2DArray/ CubeArray"; - a gather with offsets (`_o`) from a cube or cube array: "out of bound offset must be undef"; - `image_load_mip` from a UAV, which is one level of its resource: "uav load don't support mipLevel/sampleIndex" (and the typed-UAV-load flag was left out, so "Flags must match usage" too). They are now refused with those reasons, as the gathers DXIL cannot do already are ("a gather with implicit level", "a gather of several channels"). Found by validating random programs (the generator of #1335, with a validation pass, validator 1.6): 5 of 16,207 programs that translated out of 200,000; with this and #2056 every one of them validates. The new test lowers each into LDS, so the refusal ends the translation, and the 2D gather and the plain UAV load next to them, which still lower; it fails on `main`, and without either of the checks.`image_sample_c_lz` and the other comparison samples (`sampleCmp`, `sampleCmpLevelZero`) of a 3D image translated into a DXIL operation the validator rejects ("samplec requires resource declared as texture1D/2D/ Cube/1DArray/2DArray/CubeArray"): D3D compares samples of every kind of texture but 3D. They are now refused, as the other image forms DXIL has no form of. Found by the same random-program validation, over 2,000,000 more programs: 3 of 164,934 that translated. The image test now also lowers the same comparison sample of a 2D image, and refuses it of a 3D one (it translates on `main`).The title renders to a 2560x1440 B4G4R4A4_UNORM texture and makes a typed unordered view of a B5G5R5A1_UNORM one. D3D12 supports neither, and the debug layer says so while the run is going: CreateCommittedResource: A texture that has D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET set ... must be created with a format that either can be used as a render target, or cast to a format that could be CreateUnorderedAccessView: The format (0x56, B5G5R5A1_UNORM) cannot be used with a Typed Unordered Access View. This is because the current graphics implementation does not even support this Format. RemoveDevice: DXGI_ERROR_INVALID_CALL so the run ended a minute after the account screen, in the first scene of the prologue, with the device removed. (The 16-bit render target's creation was already failing quietly - `no host texture` - and the unordered view above removed the device.) `pc_format` now widens B5G6R5, B5G5R5A1 and B4G4R4A4 (85, 86, 115) to B8G8R8A8_UNORM (87): the same channel order, legal for render targets, unordered access and shader reads, and it is the one function resources, views, twins and pipeline target formats all go through, so they agree. The title loses the console's 5 or 4 bits a channel, not the picture's layout. With it the title reaches gameplay and the numbers the frame report then prints for the first time: 2 555 draws a frame (before: the device was removed in the loading screen), 3 969 ms a frame, 1 674 draws dropped for want of a host pipeline, 621 MB of title memory copied and 139 MB of textures uploaded a frame. That frame's 3.6 s on the GPU is the next problem - and, being over the 2 s TDR, the next removal. Found with the debug layer (`VICTORY_D3D12_DEBUG=1`) in a diagnostics build: `fail()` now drains the layer's stored messages, which name the call instead of only its code.842b0cb) into the pipeline wait budget branch a8316c9de9Two diagnostics (the `diagnostics` feature only) that answer why a cold shader cache costs the first gameplay frame 20-25 s: shader phases (us): stage=Cs blocks=1542 range=342 resource=99315 io=5255 emit=8126713 lowering passes: 74 blocks=1542 setup_us=5561 run_us=85672 - a translation is 74 % structurisation/resource tracing and 25 % lowering in the aggregate, but the *worst* shaders are lowering: 8.1 s of 8.2 s for the biggest one; - `emit::lower` re-runs the whole lowering once per phi that does not settle (`Stop::Retry`): 74 passes for one shader, 222 extra passes over 17 shaders in a batch of 1 725. At ~86 ms a pass on 1 542 blocks that is 6.7 s for one shader alone - the whole cold batch is 160 s of CPU across eight workers, 25 s of wall. Nothing changes in a release build (no `diagnostics`): the phases are `Instant`s behind `cfg` and the pass count is not compiled at all.VICTORY_DUMP_ARGUMENTS) 555a5d92eaA command that hangs the GPU cannot be read back afterwards: the breadcrumbs name it, the record dump (`read_indirect`) needs the list to have run, and that is exactly what it did not do. The arguments live in the *host copy* of title memory, though, and the refresh that fills it runs just before the list: so a deferred step logs the record's dwords at submission time, from the copy the GPU will read. indirect arguments {kind, max, count, dwords, name} For the two dispatches that stop the prologue (`00167d58cc5a78d7`, `f607780aa8e502d0`) and whatever the breadcrumbs name next, this says whether the long loops are fed by huge counts or by garbage, which is the question the read-back could not answer. Diagnostics only; nothing runs without the switch.`VICTORY_GPU_TIMING` gives per-command GPU times only by submitting every list on its own and waiting for it, which reads ~10x the real frame and therefore cannot say what a *batched* submission spent its time on. Its stamps did not help either: every list resolves into offset 0 of its read-back buffer, so only the list that closed last kept its times. `VICTORY_GPU_STAMPS` (diagnostics) turns the timestamps on without the one-list-per-submission mode, and a submission of all lists that takes over 200 ms now reports the two longest commands of every list in it: slow host submission ms=... slow list 7 command, 918.6 ms: dispatch 8x16x2 [compute ...] That is the report the loading needs: the frame is 15 s of GPU work with a batched submission, and nothing could name the command inside it. Diagnostics only; the release build is unchanged.\Map\ returns the start of a read-back resource, not of the range asked for, so after every list took its own slot the report read offset 0 - the slot of whichever list had id 0, or zeroes - and every command came out as 0.0 ms while 7 439 notes and a live timestamp heap were there. With the slot read, the loading says: 5251 ms: dispatch 1x1x1 [compute caa78b8ca62bc3d6] 123.1 ms: indirect kind 2 max 1 [compute 8bbcbda6008eaa37] 111.2 ms: draw 3x1 [vertex ce57291b5a1750ca, pixel ...] a single workgroup of 64 threads is what costs the loading its five seconds, and it is the same 2^20-iteration shape.The 6 s dispatch of \caa78b8ca62bc3d6\ binds neither a descriptor table (nothing printed) nor a root view (nothing printed either): its only bindings are the user-data dwords, which are now logged at submission - traced user data [compute caa78b8ca62bc3d6] user_data=[... 18816, 4294966592, 768 ...] traced user data [compute caa78b8ca62bc3d6] user_data=[... 27520, 4294966208, 1024 ...] 6 005 lines in one loading run, and the values are small and structured (an offset, a negative offset, a size: 18816 / -2048 / 768), not garbage. So the table the two searches walk is *title memory* (the page-table path), which puts the memory refresh and its withhold/miss accounting next in line.The title's 3 444 host copies of its memory span more than 1 030 distinct 256 MiB regions of its address space, while `CAPACITY` gave a list's page table room for 512 - "the world's ~4 100 copies use a few dozen", which held for the world and not for this title. Every region past the cap reads as absent, and the diagnostics said so plainly: title memory this frame: 18 447 withheld and 1 098.1 MB of views kept, missed 120 539 pages and 23 256 MiB regions with no copy A compute shader that searches a table in that memory then reads zeros, never matches its key and runs its loop to the 2^20 cap. The one that cost the loading its five seconds is `caa78b8ca62bc3d6` (64 threads, three nested loops), and with the capacity raised it does not appear in the slow-command report at all: before, CAPACITY 512 : dispatch 1x1x1 [compute caa78b8ca62bc3d6] 6 012.2 ms after, CAPACITY 2048: (below the report's threshold) loading run, no VICTORY_SKIP_PIPELINES and the default loop limit: 120 world frames, 0 device removals, the full 420 s window frames 1.8-2.6 s: GPU 1.2-1.7 s, copies 137-240 ms / 1.4-2.0 GB Until this, the prologue only ran with two dispatches skipped or with the loop limit cut to 1024 (both diagnostics); with the capacity raised it runs on an unmodified build. Cost: a table is `(CAPACITY + 1) * 32 KiB` beside the level-1 entries, so 67 MB instead of 17 MB per table, and the run keeps one or two of them. Raising it further only helps the remaining 6-19 regions and grows linearly, so the next change there is to allocate level-2 blocks per submission for the regions a submission's views reach, not a bigger constant. The corpus A/B is unchanged, as it must be - the translator is not touched: 25 889 per-program outcome lines, 0 differences, 47 s. cargo test --release --workspace: 30 suites, 0 failures; clippy -D warnings clean with diagnostics.Three prologue compute pipelines read a *root view's* offset while the title had bound that root as 32-bit constants, and every such draw or dispatch was dropped: dropped 1-2.4/frame without a host pipeline: dispatch: a root view's offset: no root view, or outside title buffers [compute 35e51bb27a463294], [compute f94e5d8bf4e1cf05], ... A diagnostics count of the two halves of that reason says which it is: over a whole run, `no_view` fires and `no_copy` never does - the slot holds `Root::Constants(...)`, not `Root::View(...)`. The console lets a title pass a descriptor itself as root constants, and the ones here hold their buffer's address in dword 0 (`Constants([1915200512, 13, 0, 0, 190980448, 16, 8, ...])`). `State::root_address` now answers "the title address this root stands for" for both forms: the view's address, or the first dword of the constants when that address lies in a host copy (`shadow::find`), and `root_view_at` binds the view at that address exactly as it did for a view root. When the address is in no copy the old drop stands, so nothing is invented. Measured on the prologue scenario (play driver, 560 s window, diagnostics): before: 2.4/frame dropped for this reason, run ends on the title's int3 after: 0 dropped for this reason after, with the diagnostic loop cap 1024 (so the unrelated 5-6 s loop class does not end the run first): 208 world frames, 0 device removals, 0 drops, the whole 560 s window, no title exception The visible checkerboard patches in the credits frame are the shape this should fix; the fix is not yet shown to remove them (the run above has no screenshots), which is the next check.translate --listnames the opcode a refusal points at 049c3f6457A refusal carries `at 0x14dc`, and until now the offset was all it said: the program is 12 000 words of native code and the instruction at that offset was the one thing the message did not have. It has it now, in the same line: bvh_skinning:CSComputeSkinningPedBlendShapesVelocity_1c34db0a_Wrapped Cs at 0x14dc [s_cbranch_execz Sopp { imm: 92 }] emit: a lane mask read as data That names the prologue's remaining functional hole instead of hinting at it: four programs of the whole pack (`CSComputeSkinningPedBlendShapes`, `...SecMotion`, `...Velocity`, `...SecMotionVelocity` - the character skinning with blend shapes) fail on the same opcode, and the one the prologue binds (`compute 82a2ad6d07417d36`) is dropped 4 times a frame in the interior scene that the play run then stands in for four minutes. The other three shader families that refuse at an offset get the same line for free.VICTORY_ONLYandVICTORY_TRACE_FAILSfor one program's refusals 433d49b165A program's refusal is usually not the instruction the message names: the emitter gives up on an instruction, marks its writes missing and goes on, so a branch can report a reason that came from something dozens of instructions earlier (the prologue's character skinning reports `s_cbranch_execz` at 0x14dc while the first thing it cannot do is a mask copy at 0x5c). Two switches for that: - `VICTORY_ONLY=@0x<offset>` (`translate --list`): translate only that container, so one program's log is its own; - `VICTORY_TRACE_FAILS=1`: log every instruction the emitter gives up on, with its offset, block, reason and reads. Together they give the ordered list, which is what says where to look: FAIL s_setreg_imm32_b32 at 0x1c (block 0): a register the emitter does not model FAIL s_mov_b32 at 0x5c (block 1): a lane mask read as data reads [(S(126), Value(8))] ... Both are read at run time only, so a normal run pays nothing.`sop()` refused every scalar instruction whose destination is a lane mask - if inst.write(Reg::S(EXEC)).is_some() || self.is_mask(lo) { return Err(LANE_MASK); } - so a program that copies exec before its first branch was refused at that branch, and the whole pipeline was dropped. That is the prologue's character skinning with blend shapes (`CSComputeSkinningPedBlendShapes`, `...SecMotion`, `...Velocity`, `...SecMotionVelocity`), dropped four dispatches a frame in the scene where the play run then stands still. Now the op lowers the mask the structure already has for what it writes, instead of refusing. Three details make it hold: * only the writes the structure names as masks get a bit; a write it does not name (the saved exec of an `s_and_saveexec`, a register the compiler reuses for data) carries the destination's mask, because the branch that follows would otherwise read a value with no definition at all; * a phi registered while such an evaluation runs is *lenient*: an edge the structure cannot name gives it no lanes instead of failing the program, so `a_scalar_result_needs_no_exec` (a copy of exec that only guards a `v_readlane`) keeps translating; * every other mask join keeps its refusal, so a mask holding lanes off its edge joined with data still does not translate (`a_compare_mask_joined_with_data_on_the_skip_edge_is_0_there`, second half). Measured over the whole shader pack (`translate --list`, 26 084 programs), against a baseline taken with this change stashed: before 25889 program lines, after 25889 only before: 4 only after: 4 (the same four, now emitted) compute programs 2658 -> 2662 Nothing else changes. `cargo test --release --workspace`: 30 suites, 0 failures; clippy `-D warnings` clean. `lower.rs` is at the repository's 512 KiB asset-policy limit, so the two new methods live in `emit/lower/masks.rs`.VICTORY_KEYSentries can hold a key, so a run needs no window focus a4228565e3`VICTORY_KEYS=<seconds>:<key>` held each key for 200 ms, which is enough for a menu press and not for walking. The entries now take a third field, the hold in milliseconds: VICTORY_KEYS=200:W:6000,215:A:1200,10:Enter:300,20:Enter:300 Both the keyboard device and the stand-in pad see the keys (the HLE merges them in `poll`), so a run can be driven while the title's window stays in the background: nothing calls `SetForegroundWindow` or `keybd_event`, and the person using the machine keeps their focus. Enter is the pad's A and W the left stick up, so the account screen, the menu and walking all work this way. First run with it (`nofocus`): the title reached the world without any window activation - 1 862 draws/frame at 153 s, 4 657 at 196 s - where every earlier driver had to attach to the window's input queue and steal focus at 15/40/70 s.VICTORY_GPU_REPORT) 621935a8caThe batched report named two commands a list, and only for submissions over 200 ms, so a frame's ~350 commands were ranked by their two longest - which is why the biggest pipeline looked like 44 % of the frame when it is 7 %. Two switches now say how much to list and when: VICTORY_GPU_REPORT=40 commands per list (default 2) VICTORY_GPU_REPORT_MIN_MS=250 submission length that triggers it (default 200) With 40, a 1 150 ms submission lists 354 commands summing to 1 144 ms, i.e. the report accounts for the submission's whole time. On the prologue's frames it gives the family table the next optimization needs - no single shader: indirect 25ebc92075b62822 2 453 ms (an indirect draw: geometry) dispatch 39f0e9aeb156a61c 2 019 indirect 7a071f906f98311b 1 749 draw 05e958b19269d596 1 126 dispatch 5cf00dc39042edaf 538 mesh 04b9be3756e8f41c 475 over the sampled submissions, each family 200-600 ms of a ~3 s frame: geometry and compute in similar measure, not one bad pass. Diagnostics only (the switches are read at run time, nothing changes without them); clippy `-D warnings` clean, `cargo test --release -p victory-gpu` 231 passed.VICTORY_ONE_BARRIER,VICTORY_NO_BARRIERS) 2810c8d98eEvery indirect command is clamped by a compute dispatch between two global unordered-access barriers, and the world runs 2 600 of them a frame - so the barriers are a candidate for a large part of a frame. Measuring them needs an A/B that keeps the commands running, which `VICTORY_NO_CLAMP` could not: it returned `None`, the command was dropped, and the run then compared a frame with 5 018 indirect commands against one with none. Two switches replace it, neither changing anything unless set: VICTORY_ONE_BARRIER=1 after the clamp, only the transition out of unordered access (which already flushes that buffer) - the global barrier after it ordered nothing the command needs; VICTORY_NO_BARRIERS=1 both global barriers gone: the ceiling of what they cost together, for the measurement only (the title's writes then need not be visible to the clamp). `VICTORY_NO_CLAMP` is removed: it measured a different program. No numbers claimed: the A/B was started and stopped early (base 47 and 13 world frames, one-barrier 3), so nothing here says the change is faster. It says how to find out.VICTORY_ALLOW_COPYBACK) 2fc6a2926aEvery world frame of every run so far reports the same three numbers: 0 pages copied back, 20 000-31 000 withheld, missed 70 000-112 000 pages and 27-50 region marks with no copy (first: 0x740000000 0x750000000 ...) `copy_back` withholds *all* of a frame's write-backs as soon as one page of title memory was read by a shader with no copy (`withholding()`), and that is the state of every frame: the title reads 0x740000000-0x780000000 - a gigabyte with no host copy - so * the title's memory never receives what its shaders wrote, and the host copy the title's own reads are answered from (and that a refresh pushes back) is what the GPU wrote a while ago or never; * the per-frame work is real: 100 000 page marks read back and walked, 20 000 pages dropped, every frame. Whether that is what keeps the game from advancing (the prologue's first scene waits for input and never moves on) cannot be told from the logs. The new switch copies back even while pages are missing, so one run says it: VICTORY_ALLOW_COPYBACK=1 Diagnostics only: the rule above is unchanged unless the switch is set. No behaviour change and no numbers claimed.Every world frame reports thousands of pages of title memory a shader read with no copy (`memory`'s frame line), and the first four addresses have been the same four gigabyte-apart regions for every run - so the next question is what those addresses are, which the line could not say. `shadow::describe(address)` answers it: the registered title buffer that holds the address and whether a copy of it was made, or how far the nearest registered buffers are. The first four missed pages of a frame log it at `debug`: title memory a shader read with no copy page=0x740000000 what="no registered title buffer at 0x740000000; nearest below ..." That separates "the title never registered a buffer there" (a use we do not translate into a buffer access at all, so no copy exists to make) from "the buffer is registered but its copy was never made or was released". Diagnostics only, no behaviour change, no numbers claimed.63bcca4while preserving launch paths be908d79b1`shadow`'s copies of title memory live in system memory (`Host::shared_buffer` is a `CUSTOM`/`L0` buffer): the title's memory is host memory, so the copy is something the CPU refreshes and compares, and every shader read of it crosses PCIe. On the console the same read is GDDR6. The one experiment so far (`VICTORY_COPIES_IN_VIDEO_MEMORY`) put them in a `GPU_UPLOAD` heap and measured *worse* (3 196 -> 4 289 ms a frame in the world): that is a BAR window, not video memory. This is the mechanism for the other arrangement, small enough to review on its own and not wired into the frame path: VramCopy::new(len) a buffer in D3D12_HEAP_TYPE_DEFAULT upload(list, offset, bytes) staged now, copied when the list runs read(list, offset, len) -> Read a readback after the list ran gpu() the address a shader reads Nothing is committed to using it yet - `#![allow(dead_code)]` and the module doc say where it plugs in (`Shadow` gaining an `Option<VramCopy>`, `Batch::flush` staging instead of memcpying, `Shadow::copy_back_page` reading through `read`). Landing it separately means the integration PR can be a measured before/after rather than a rewrite nobody can A/B. The tests are the semantics the integration depends on (and they are what found the one non-obvious rule): * `uploaded_bytes_reach_a_shader_and_its_result_reads_back` - bytes the host stages arrive at a shader that reads the copy by GPU address, and the shader's result reads back; * `what_a_shader_writes_reads_back` - what a shader writes is what the write-back path would see; * `two_ranges_in_one_list_do_not_overwrite_each_other` - staged ranges are not shared behind the caller's back; * `a_range_past_the_end_is_refused`, `a_copy_is_whole_pages`, `an_upload_reads_back_without_a_shader` - the edges, and the copy path with no shader in it at all. **What the tests found:** a copy from `COMMON` is not ordered against a shader access on either side of it. The first version of `upload`/`read` copied from `COMMON` and the readback came back zeroed - the shader read the buffer before the copy landed. Both now enter and leave an explicit state (`COMMON -> COPY_DEST -> COMMON`, `COMMON -> COPY_SOURCE -> COMMON`), which is the same shape `capture.rs` uses for its readback and the reason its comment says a title buffer's copy, never transitioned, is only ever read. Verification: `cargo test --release -p victory-gpu` - 237 passed, 1 ignored (the new six among them); clippy `--all-targets -D warnings` clean on `main`. No frame-time claim: nothing in the frame path changes here.A synthetic measurement, no title involved: the same copy of 128 MiB read by a compute shader, once from video memory (`VramCopy`) and once from the system memory `shadow`'s copies live in today (`Host::shared_buffer`), with two access shapes - a stride-1 scan and a random 16-byte line a thread - one 16-byte read a thread and no stores, so the timing is the reads. Measured here (RX 9070 XT, shared machine, best of three, ten dispatches a list): 128 MiB read video system ratio stride-1 scan 3.829ms 4.021ms 1.05x random lines 56.301ms 57.100ms 1.01x Earlier shapes agreed before the parallism was raised (1.21x / 1.04x), and the one in-game experiment that exists - `VICTORY_COPIES_IN_VIDEO_MEMORY`, a `GPU_UPLOAD` heap - measured *worse* (3 196 -> 4 289 ms a frame). So: on this machine, putting these copies in video memory does not make shader reads faster, in either access shape. Two readings of that, and both matter before anyone writes the integration: * either the reads are not what the frame spends its time on (then variant A would have bought nothing, and the frame's cost is elsewhere), or * the `CUSTOM`/`L0` copies already come back at PCIe speed on this machine (~32 GB/s measured) and video memory has no headroom left to give. Either way the number that decides the integration now exists, and it says no. The unit stays (its own tests hold the mechanism), and this test is the record of why it is not wired in - and the thing to re-run on a machine whose result differs. Verification: `cargo test --release -p victory-gpu` - 238 passed, 1 ignored; `clippy --all-targets -D warnings` clean.Whether a frame draws the scene several times over is not visible from the draw count: the world reports 5 000-10 000 draws a frame for a prison cell, which is a few hundred on a console, and the frame line said nothing about what those draws cover. `take_work` counts, per frame, vertices (`DrawInstanced`), indices (`DrawIndexedInstanced`), dispatch threads (groups x 64) and mesh groups (x 128), and the report logs them: work a frame: 96 000 vertices, 74 000 indices, 734 000 dispatch threads, 5 700 mesh groups The counters are the two atomics a draw already pays (`DRAWN`); the line is printed by the diagnostics report, beside the draw count and the dropped ones. Indirect records are not counted here - their arguments are read out by `VICTORY_DUMP_ARGUMENTS`, which names the work per record. No behaviour change; the numbers are what the next run is for.VICTORY_ALLOW_COPYBACK's comment carries what it did when run 1592af0c5bView command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.