gpu: close guard, aliasing barriers, copy repairs, and naming/surviving a failed Close (0x80070057) #3488
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3488"
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?
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by CubeB on 2026-11-29T23:50:59Z.
Branch:
CubeB:close/guard-stack. Builds on #3043; review after it lands. The branch is #3043's head(
097b5070) merged withmainat41adb551(no conflicts), then four commits. Until #3043 lands the diffagainst
mainalso shows #3043's changes.Problem
One invalid command makes
ID3D12GraphicsCommandList::Closereturn0x80070057for the whole host list:"a host command list did not close: a command recorded into it was invalid" (#452, #2237, #2276, #2355, #2914).
D3D12 does not say which command, the failure shows minutes after the command was recorded, and the run ends.
In #2914 the debug layer named one command:
CopyTextureRegionwith BC7_TYPELESS source and BC6H_TYPELESSdestination, which #3043 handles. The same issue has a second, open case of the same kind: a raw source box
given in destination texels ("requires the destination subresource to have 1024 width ... only has 128"). The
debug layer does not start on every machine, and the format mismatch is one rule among many.
So the rules were measured instead: one command recorded into a fresh list, then
Close. 278 cases gave thesame answer on an RTX 5070 Ti and on WARP. The set is kept as a test,
checked::tests::the_runtime_agrees_with_every_verdict: 466 cases on WARP, 263 of them refused, each recordedunjudged and
Closecompared with the validator's verdict. It also passes on the first hardware adapter withVICTORY_GUARD_ORACLE_HARDWARE=1. Things the measurement settled:R9G9B9E5copies into everyR32format,D32_FLOATincluded.rectangle is checked against the destination only.
GENERIC_READ(0xAC3) passes on a texture as the whole state, although each of its buffer bits alone fails.Bit 0x800000 passes only alone.
heap no read state.
Commits
1. Close guard: commands D3D12 would refuse are logged and left out
New module
crate::checked.judge()holds the measured rules over plain numbers. The recorderscopy_texture,copy_buffer,resolve,resolve_regionandbarriersjudge, then record. EveryCopyTextureRegion,CopyBufferRegion,ResolveSubresource[Region]andResourceBarrieroutsidereplay/goes through them:
barstat::rbends inchecked::barriers, and the directResourceBarriercalls now gothrough
rb. A refused command is logged and not recorded, so one copy or barrier is missing for a frameinstead of the run ending.
Not judged:
CopyResource(no mismatch failedClose), enhanced barriers, clears, draws, state calls.Risk: a rule that is too strict drops a legal command; the oracle test bounds that for the 466 cases. A dropped
transition leaves the tracked state ahead of the real one.
2. Title aliasing barriers are left out for committed host textures
host_barrierkind 1 (list.rs) forwarded a title aliasing barrier unchecked. It is now forwarded only if everyhost texture it names lies in a heap (
checked::aliasing_allowed: a pool piece, or a reserved texture marked atcreation). A committed texture shares its memory with nothing, so leaving its barrier out loses nothing.
3. Copy path: boxes and read backs D3D12 refuses are brought to ones it takes
copy_geometry_fits()now returns throughcopy_geometry(),which says why, and the guard's
judge()calls the same function. One rule is stricter than in #3043: afar box edge on a small block-compressed mip must be on the block grid (box 0..2 on a 2x2 mip is refused,
0..4 passes; 0..8 on a 6x6 mip). The runtime refuses 0..2. #3043's unit test for that case was updated. The
guard, the copy repair and their tests depend on this.
copy_box_repaired()inrecord_texture_copy: far edges of a box in a block-compressed source are rounded upto whole blocks; a box in a raw source for a block-compressed destination is divided by the block size when
the box as given is refused and the quarter is legal (the open case in #2914). A box neither reading makes
legal is skipped as before.
read_back_repaired()inread_back: console depth-stencil format numbers become the PC's; a depth plane isread as
R32_TYPELESS; a same-size format that does not copy is read as the texture's own; a source largerthan the footprint is clipped to it; the box is rounded. Stand-in host formats and other texel sizes are
refused with a reason. If the guard still refuses the copy, the read back is no longer deferred (title memory
used to receive whatever the pooled buffer held).
first was.
Risk: the divide-by-block reading is a guess at what the title meant. It applies only to a copy that would
otherwise be dropped. A 256x256 raw into 128x128 BC3 copy with no box cannot be repaired and is still skipped.
Not repaired: footprint sources with console-only format numbers (116-120, 189-191), zero-size footprints.
4. Close failure: the command is named, and the run goes on without the list
checked::ringkeeps what went through the recorders as the numbers the guard judged, per recordingthread, a ring per kind (512 barriers, 256 texture copies/resolves, 128 buffer copies). On a failed
Close,checked::replay::name()records each of the list's entries alone on stand-in resources built from itsdescription and closes that list. The oracle test replays all 466 cases this way and each matches the
original answer. Only commands that go through the recorders can be named.
Closefailed is dead (Resetfails with its allocator, with that allocatorreset, and with a new one); a new list works and the device is unharmed.
HostList::survive()puts a newclosed list in the dead one's place, holding only the first-to-last state transitions of the recording, so
later lists find every texture in the state the tracking has.
HostList::listbecame aListCell(derefs tothe D3D12 list).
Adapted from the original commit:
survive()forgets the list's pending upscaling withupscale.store(0), asreset()does inmain; the original called a helper that is not in this tree.Survive caveat. The dead list's draws and copies for that submission are lost. A texture whose first upload
was in the dead list stays empty until the title writes it again. Read backs of the list are dropped; queries it
was to resolve keep old values; timing meters for that list are wrong. A list that fails every frame gives a
broken picture, with the cause in the log. Survival is covered by a unit test only.
Switches and defaults
VICTORY_CLOSE_GUARD0records everything as before;logjudges and logs but still recordsVICTORY_TITLE_ALIASINGallforwards every one (the guard still drops illegal ones unless it is0too)VICTORY_COPY_REPAIR0passes boxes and footprints on as givenVICTORY_CLOSE_SURVIVE0ends the run at the failure, after naming the commandVICTORY_CLOSE_RING0keeps nothing (nothing can be named)Log strings
close guard:carriesmethod,why,count,droppedand the whole command; first 16 per reason, thenevery 1024th. Naming runs for the first 4 failures and every 64th after. #3043's
skipping out-of-bounds or unaligned CopyTextureRegionstill marks what could not be repaired.Measured cost
checked::tests::the_guard_costs_little(ignored benchmark; release, Ryzen 7 9800X3D, RTX 5070 Ti), per command:GetDescalone is 15 ns, noting a command in the ring 16 ns. No allocation, no lock. Commands per frame in playwere not counted; 5,000 barriers plus 5,000 buffer copies a frame would be about 0.3 ms (0.44 ms with the ring, by the table)
spread over the recording threads. These numbers were taken on the original commits, not re-run on this branch.
Tests
New:
checked::tests(13 tests, one of them the ignored benchmark; WARP where a device is needed) andhost::survive_tests::a_list_that_does_not_close_is_replaced_and_used_again(host device: a bad commandrecorded past the guard,
close(), culprit named, then the same host list reset, recorded, closed and executed).On this branch (Windows, stable toolchain):
cargo build --release --locked -p victory: builds.cargo test -p victory-gpu --lib -- --test-threads=1, two runs: 938 passed, 1 failed, 61 ignored; and 937passed, 2 failed. The constant failure is
shader_cache::tests::every_switch_of_the_translator_is_in_the_key("VICTORY_SCALAR_SPLITS is not read by thetranslator any more"), which fails the same way on
mainat41adb551. The other,host::card_steps::tests::places_written_after_sending_are_learned, failed once in the full run and passedin the second full run and three times alone. We had seen it fail intermittently before these commits
existed, on our fork's base; it was not re-checked on
mainhere.cargo xtask policy: only the existingcrates/victory-loader/src/heap_sites/frame_users.rshit, as onmain.After this lands, new code that calls
.ResourceBarrier(,.CopyTextureRegion(or.CopyBufferRegion(directly bypasses the guard. On this branch such calls remain only in
replay/,checked*and tests.Not yet play-tested
Nothing here has been run against the game. The rules come from the one-command measurements and the tests.
Related
The state sanitiser (
CubeB:close/state-sanitiser) is a separate, independent change onmain: it makesillegal texture states legal before they reach a barrier, so the guard does not have to drop the transition.
🤖 Generated with Claude Code
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by tillo88 on 2026-11-30T17:58:51Z.
Crash count on the replay bench: #3488 merged on top of v2026.11.29.05, 6 complete runs, against the #2237 crash rate of the same release.
(One more #3488 run closed 3 s after launch, before the game started; it is left out.)
None of the PR's log lines appeared in any of the 6 runs: no
close guard:, nocopy repair:, notitle aliasing barrier: left out, noclose failure:and noclose survive:. So in these runs the guard never had to drop or repair a command and no list failed to close. With the base failing in about 1 run of 3, 0 of 6 happens by chance about 9% of the time, so this does not show that #3488 prevents the crash; it only shows the runs did not hit it. For comparison, #3792 was also 0 of 6 at first on this bench and ended at 3 of 13.Speed, for completeness (5 measured runs; base 19 runs of v2026.11.29.05): 29.02 fps vs 29.42 (base sd 0.69, range 27.79-30.56), submitting thread 32.1 vs 31.4 ms, refreshes 8.6 vs 8.2 ms, p95/p99 61.4/141.7 vs 57.4/138.8 ms. No measurable difference (one run at 26.97 fps pulls the mean down).
I will run it again on v2026.11.30.01, where the release now contains #3792 and #3776.
Setup: Ryzen 7 9800X3D, RTX 5070 Ti 16 GB (driver 621.40), 32 GB RAM, Windows 11, release build, Series X 1440p, DLSS Quality, frame generation off, ray tracing off. Route: the same save restored before each run, prison cutscene, plane cutscene, first boat section (about 6 minutes).
Measured unattended on a replay bench (same save, recorded controller input via VICTORY_INPUT_REPLAY); numbers and text prepared with Claude.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by tillo88 on 2026-12-01T12:06:51Z.
Follow-up to my earlier comment: #3488 (head
7f63dc99) no longer merges on top of v2026.11.30.03 (merge conflict), so it could not be measured on that release.Measured unattended on a replay bench (same save, recorded controller input via VICTORY_INPUT_REPLAY); numbers and text prepared with Claude.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-12-01T18:51:48Z.
Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.
Pull request closed