gpu: close guard, aliasing barriers, copy repairs, and naming/surviving a failed Close (0x80070057) #3488

Closed
github-bot wants to merge 23 commits from github-bot/gh-3488 into main AGit
Owner

@⁠CubeB on GitHub · 2026-11-29 23:50 UTC · original
CubeB:close/guard-stack → main · +4255 −279 · 41 files · 23 commits · closed without merging

Branch: CubeB:close/guard-stack. Builds on #3043; review after it lands. The branch is #3043's head
(097b5070) merged with main at 41adb551 (no conflicts), then four commits. Until #3043 lands the diff
against main also shows #3043's changes.

Problem

One invalid command makes ID3D12GraphicsCommandList::Close return 0x80070057 for 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: CopyTextureRegion with BC7_TYPELESS source and BC6H_TYPELESS
destination, 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 the
same 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 recorded
unjudged and Close compared with the validator's verdict. It also passes on the first hardware adapter with
VICTORY_GUARD_ORACLE_HARDWARE=1. Things the measurement settled:

  • An empty or inverted box skips the format and bounds checks, but not the kind, subresource and sample-count ones.
  • R9G9B9E5 copies into every R32 format, D32_FLOAT included.
  • A footprint may copy into a footprint. A buffer copy of zero bytes is never refused.
  • A resolve refuses integer formats and any format other than a typed texture's own or its sRGB twin; its
    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.
  • Both states of a transition are checked. A buffer in an upload heap takes no write state, one in a read-back
    heap no read state.
  • Aliasing barriers pass for null/null, placed and reserved resources; any committed resource on either side fails.

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 recorders
copy_texture, copy_buffer, resolve, resolve_region and barriers judge, then record. Every
CopyTextureRegion, CopyBufferRegion, ResolveSubresource[Region] and ResourceBarrier outside replay/
goes through them: barstat::rb ends in checked::barriers, and the direct ResourceBarrier calls now go
through rb. A refused command is logged and not recorded, so one copy or barrier is missing for a frame
instead of the run ending.

Not judged: CopyResource (no mismatch failed Close), 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_barrier kind 1 (list.rs) forwarded a title aliasing barrier unchecked. It is now forwarded only if every
host texture it names lies in a heap (checked::aliasing_allowed: a pool piece, or a reserved texture marked at
creation). 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

  • One statement of the geometry rules: #3043's copy_geometry_fits() now returns through copy_geometry(),
    which says why, and the guard's judge() calls the same function. One rule is stricter than in #3043: a
    far 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() in record_texture_copy: far edges of a box in a block-compressed source are rounded up
    to 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() in read_back: console depth-stencil format numbers become the PC's; a depth plane is
    read as R32_TYPELESS; a same-size format that does not copy is read as the texture's own; a source larger
    than 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).
  • Cross-format bounce: depth-stencil planes are named by plane format; the second leg is recorded only if the
    first was.
  • A resolve between different sizes clips to the subresource sizes, not the top-level sizes.

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

  • Name: checked::ring keeps what went through the recorders as the numbers the guard judged, per recording
    thread, 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 its
    description 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.
  • Survive: measured, a list whose Close failed is dead (Reset fails with its allocator, with that allocator
    reset, and with a new one); a new list works and the device is unharmed. HostList::survive() puts a new
    closed 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::list became a ListCell (derefs to
    the D3D12 list).

Adapted from the original commit: survive() forgets the list's pending upscaling with upscale.store(0), as
reset() does in main; 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

Switch Default Other values
VICTORY_CLOSE_GUARD on 0 records everything as before; log judges and logs but still records
VICTORY_TITLE_ALIASING only barriers on resources in a heap all forwards every one (the guard still drops illegal ones unless it is 0 too)
VICTORY_COPY_REPAIR on 0 passes boxes and footprints on as given
VICTORY_CLOSE_SURVIVE on 0 ends the run at the failure, after naming the command
VICTORY_CLOSE_RING on 0 keeps nothing (nothing can be named)

Log strings

close guard: a command D3D12 would refuse (Close would fail with 0x80070057)
title aliasing barrier: forwarded to the host
title aliasing barrier: left out, it names a committed host texture
copy repair: a source box D3D12 refuses was brought to the one it takes
copy repair: a read back D3D12 refuses was brought to the one it takes
close failure: a host command list did not close: a command recorded into it was invalid
close failure: this command fails Close when recorded alone
close failure: the list's copies, resolves and barriers in the ring were each recorded alone and closed
close failure: no command in the ring fails Close alone
close failure: among the last commands of the list
close survive: the list that did not close was replaced by an empty one

close guard: carries method, why, count, dropped and the whole command; first 16 per reason, then
every 1024th. Naming runs for the first 4 failures and every 64th after. #3043's
skipping out-of-bounds or unaligned CopyTextureRegion still 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:

describe + judge with the ring
transition 22 ns 38 ns
buffer copy 34 ns 50 ns
texture copy 56-66 ns about 80 ns

GetDesc alone is 15 ns, noting a command in the ring 16 ns. No allocation, no lock. Commands per frame in play
were 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) and
host::survive_tests::a_list_that_does_not_close_is_replaced_and_used_again (host device: a bad command
recorded 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 937
    passed, 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 the
    translator any more"), which fails the same way on main at 41adb551. The other,
    host::card_steps::tests::places_written_after_sending_are_learned, failed once in the full run and passed
    in 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 main here.
  • cargo xtask policy: only the existing crates/victory-loader/src/heap_sites/frame_users.rs hit, as on main.
  • Only the head was built and tested here; the intermediate commits were not built one by one on this base.

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.

The state sanitiser (CubeB:close/state-sanitiser) is a separate, independent change on main: it makes
illegal texture states legal before they reach a barrier, so the guard does not have to drop the transition.

🤖 Generated with Claude Code

**@⁠CubeB** on GitHub · 2026-11-29 23:50 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3488) `CubeB:close/guard-stack` → `main` · +4255 −279 · 41 files · 23 commits · closed without merging Branch: `CubeB:close/guard-stack`. **Builds on #3043; review after it lands.** The branch is #3043's head (`097b5070`) merged with `main` at `41adb551` (no conflicts), then four commits. Until #3043 lands the diff against `main` also shows #3043's changes. ## Problem One invalid command makes `ID3D12GraphicsCommandList::Close` return `0x80070057` for 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: `CopyTextureRegion` with BC7_TYPELESS source and BC6H_TYPELESS destination, 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 the same 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 recorded unjudged and `Close` compared with the validator's verdict. It also passes on the first hardware adapter with `VICTORY_GUARD_ORACLE_HARDWARE=1`. Things the measurement settled: - An empty or inverted box skips the format and bounds checks, but not the kind, subresource and sample-count ones. - `R9G9B9E5` copies into every `R32` format, `D32_FLOAT` included. - A footprint may copy into a footprint. A buffer copy of zero bytes is never refused. - A resolve refuses integer formats and any format other than a typed texture's own or its sRGB twin; its 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. - Both states of a transition are checked. A buffer in an upload heap takes no write state, one in a read-back heap no read state. - Aliasing barriers pass for null/null, placed and reserved resources; any committed resource on either side fails. ## 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 recorders `copy_texture`, `copy_buffer`, `resolve`, `resolve_region` and `barriers` judge, then record. Every `CopyTextureRegion`, `CopyBufferRegion`, `ResolveSubresource[Region]` and `ResourceBarrier` outside `replay/` goes through them: `barstat::rb` ends in `checked::barriers`, and the direct `ResourceBarrier` calls now go through `rb`. A refused command is logged and not recorded, so one copy or barrier is missing for a frame instead of the run ending. Not judged: `CopyResource` (no mismatch failed `Close`), 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_barrier` kind 1 (`list.rs`) forwarded a title aliasing barrier unchecked. It is now forwarded only if every host texture it names lies in a heap (`checked::aliasing_allowed`: a pool piece, or a reserved texture marked at creation). 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 - One statement of the geometry rules: #3043's `copy_geometry_fits()` now returns through `copy_geometry()`, which says why, and the guard's `judge()` calls the same function. **One rule is stricter than in #3043:** a far 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()` in `record_texture_copy`: far edges of a box in a block-compressed source are rounded up to 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()` in `read_back`: console depth-stencil format numbers become the PC's; a depth plane is read as `R32_TYPELESS`; a same-size format that does not copy is read as the texture's own; a source larger than 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). - Cross-format bounce: depth-stencil planes are named by plane format; the second leg is recorded only if the first was. - A resolve between different sizes clips to the subresource sizes, not the top-level sizes. 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 - Name: `checked::ring` keeps what went through the recorders as the numbers the guard judged, per recording thread, 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 its description 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. - Survive: measured, a list whose `Close` failed is dead (`Reset` fails with its allocator, with that allocator reset, and with a new one); a new list works and the device is unharmed. `HostList::survive()` puts a new closed 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::list` became a `ListCell` (derefs to the D3D12 list). Adapted from the original commit: `survive()` forgets the list's pending upscaling with `upscale.store(0)`, as `reset()` does in `main`; 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 | Switch | Default | Other values | |---|---|---| | `VICTORY_CLOSE_GUARD` | on | `0` records everything as before; `log` judges and logs but still records | | `VICTORY_TITLE_ALIASING` | only barriers on resources in a heap | `all` forwards every one (the guard still drops illegal ones unless it is `0` too) | | `VICTORY_COPY_REPAIR` | on | `0` passes boxes and footprints on as given | | `VICTORY_CLOSE_SURVIVE` | on | `0` ends the run at the failure, after naming the command | | `VICTORY_CLOSE_RING` | on | `0` keeps nothing (nothing can be named) | ## Log strings ``` close guard: a command D3D12 would refuse (Close would fail with 0x80070057) title aliasing barrier: forwarded to the host title aliasing barrier: left out, it names a committed host texture copy repair: a source box D3D12 refuses was brought to the one it takes copy repair: a read back D3D12 refuses was brought to the one it takes close failure: a host command list did not close: a command recorded into it was invalid close failure: this command fails Close when recorded alone close failure: the list's copies, resolves and barriers in the ring were each recorded alone and closed close failure: no command in the ring fails Close alone close failure: among the last commands of the list close survive: the list that did not close was replaced by an empty one ``` `close guard:` carries `method`, `why`, `count`, `dropped` and the whole command; first 16 per reason, then every 1024th. Naming runs for the first 4 failures and every 64th after. #3043's `skipping out-of-bounds or unaligned CopyTextureRegion` still 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: | | describe + judge | with the ring | |---|---|---| | transition | 22 ns | 38 ns | | buffer copy | 34 ns | 50 ns | | texture copy | 56-66 ns | about 80 ns | `GetDesc` alone is 15 ns, noting a command in the ring 16 ns. No allocation, no lock. Commands per frame in play were 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) and `host::survive_tests::a_list_that_does_not_close_is_replaced_and_used_again` (host device: a bad command recorded 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 937 passed, 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 the translator any more"), which fails the same way on `main` at `41adb551`. The other, `host::card_steps::tests::places_written_after_sending_are_learned`, failed once in the full run and passed in 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 `main` here. - `cargo xtask policy`: only the existing `crates/victory-loader/src/heap_sites/frame_users.rs` hit, as on `main`. - Only the head was built and tested here; the intermediate commits were not built one by one on this base. 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 on `main`: it makes illegal texture states legal before they reach a barrier, so the guard does not have to drop the transition. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
One invalid command makes ID3D12GraphicsCommandList::Close return
0x80070057 for the whole host list, minutes after it was recorded and
without naming it: "a host command list did not close" (upstream #452,
#2237, #2276, #2355; seven crashes here after 7 to 83 minutes). The
debug layer that would name the command does not start on this machine.

So the rules were measured: one command into a fresh list, then Close.
278 cases on 2026-11-29 gave the same answer on an RTX 5070 Ti (621.40)
and on WARP, so the checks are the runtime's own. crate::checked holds
them as judge() over plain numbers (descriptions, subresources, boxes,
states), and the_runtime_agrees_with_every_verdict asks the software
adapter again for 466 cases (263 refused) (the 278, less the commands not judged,
plus the ones needed to settle a rule). Running it found rules the
first measurement had wrong or lacked:
- an empty box skips the format and bounds checks, not the kind,
  subresource and sample-count ones;
- R9G9B9E5 copies into every R32 format, D32_FLOAT too;
- a footprint may copy into a footprint; a buffer copy of no bytes is
  never refused;
- a resolve refuses integer formats and a format other than a typed
  texture's own (or its sRGB twin), and holds its rectangle against the
  destination only;
- GENERIC_READ (0xAC3) is taken on a texture, whole and alone, though
  each of its buffer bits is refused there; bit 0x800000 is taken alone;
- a buffer in an upload heap takes no write state, one in a read-back
  heap no read state;
- both states of a transition are checked, not only the new one.

The recorders (copy_texture, copy_buffer, resolve, resolve_region,
barriers) judge and then record. Every CopyTextureRegion,
CopyBufferRegion, ResolveSubresource[Region] and ResourceBarrier of the
layer outside the replay tools goes through them: barstat::rb now ends
in checked::barriers, and the 74 direct ResourceBarrier calls moved to
rb. A refused command is logged ("close guard: a command D3D12 would
refuse", first 16 of each reason, then every 1024th, with the whole
command) and not recorded: one copy or barrier is missing for a frame
instead of the run ending. Aliasing barriers are legal only on
resources in a heap, so reserved textures are marked at creation
(checked::mark_placed) and pool pieces are known by pool::is_pooled.

Switch: VICTORY_CLOSE_GUARD, on by default; =0 records everything as
before, =log judges and logs but still records.

Cost (the_guard_costs_little, release, 9800X3D): GetDesc 15 ns; describe
and judge 22 ns a transition, 34 ns a buffer copy, 56 ns a texture copy;
no allocation, no lock. 5,000 barriers and 5,000 buffer copies a frame
are 0.3 ms over the recording threads.

Not judged: CopyResource (no mismatch failed Close), enhanced barriers,
clears, draws and state calls.

Tests: victory-gpu lib 941 passed (the oracle also passes on the first
hardware adapter with VICTORY_GUARD_ORACLE_HARDWARE=1).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JzsiBtxAuHxjYfCpTzVV3h
(cherry picked from commit aa75928e8e0a6fdc028ad74b38d5ede8246b7f91)
host_barrier() forwarded a title's legacy aliasing barrier (type 1) to
the host textures of the two resources it names, unchecked. D3D12 takes
an aliasing barrier only for resources that lie in a heap: with a
committed resource on either side Close fails for the whole list
(0x80070057, "a host command list did not close"). Measured: null/null
and placed resources pass; null -> committed, committed -> null,
committed -> committed, placed -> committed and a committed buffer all
fail (RTX 5070 Ti and WARP alike). pool.rs already says so and the two
internal sites ask pool::is_pooled first; this third site did not. A
host copy is committed whenever it was not cut from a pool block: large
textures, the fallbacks of a full pool, and render targets with
VICTORY_ALIAS_TARGETS=0.

The barrier is now forwarded only if every host texture it names is
known to lie in a heap (checked::aliasing_allowed: a pool piece, or a
reserved texture marked at creation). A committed texture shares its
memory with nothing, so leaving its barrier out loses nothing. Both
outcomes are counted and logged: "title aliasing barrier: forwarded to
the host" (first 4, so a log shows whether the title uses such barriers
at all) and "title aliasing barrier: left out, it names a committed host
texture" (first 16, then every 1024th, with both descriptions).

Switch: VICTORY_TITLE_ALIASING=all forwards every one as before (the
close guard of VICTORY_CLOSE_GUARD then still drops the illegal ones;
set that to 0 as well for the old behaviour).

Test: aliasing_is_allowed_where_close_takes_it records each of eight
before/after combinations unjudged on WARP and compares Close with the
predicate. victory-gpu lib: 947 passed.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JzsiBtxAuHxjYfCpTzVV3h
(cherry picked from commit c1f1b8906f2e9cc745bdde80ab805d1947da1df8)
The close guard drops a copy D3D12 would refuse. Some of those are a
legal copy asked in a way only the console takes; this brings them to
the form the PC takes instead of losing them. All rules are measured
(Close after one command, RTX 5070 Ti and WARP alike) and the repaired
commands are recorded unjudged on WARP in repaired_boxes_pass_close: as
asked each fails Close, repaired each passes.

One statement of the geometry rules. upstream 097b5070's
copy_geometry_fits() now returns through copy_geometry(), which says why,
and the guard's judge() uses the same function, so the copy path and the
guard cannot disagree; the guard's oracle test holds it against the
runtime. One rule changed: every edge of a box in a block-compressed
source lies on the block grid, the far ones on a small mip too. The
port let a far edge at the mip's own size pass (box 0..2 on a 2x2 mip);
the runtime refuses that and takes 0..4, and 0..8 on a 6x6 mip.

copy_box_repaired(), used by record_texture_copy for the title's box:
- far edges of a box in a block-compressed source are rounded up to
  whole blocks (what the copy moves anyway);
- a box in a raw source for a block-compressed destination that is given
  in the destination's texels (BC3 from R32G32B32A32, upstream #2914's
  open case: "requires the destination subresource to have 1024 width
  ... only has 128") is divided by the block size, if the quarter is a
  legal copy and the box as given is not.
A box that is legal, or that neither reading makes legal, stays as it is
and is skipped as before.

read_back_repaired(), used by read_back: the footprint format is
checked before anything is recorded. The console's 16-bit depth-stencil
numbers become the PC's; a depth plane is read as R32_TYPELESS (D3D12
refuses a depth-stencil format in a footprint); a format of the same
texel size that does not copy reads the texture's own bytes; a source
larger than the footprint is read up to the footprint's size; a box off
the block grid is rounded. A host copy in a stand-in format, a console
format of another texel size and a format of another texel size are
refused with a reason. And when the guard refuses the copy after all,
the read back is no longer deferred: title memory keeps what it has
instead of receiving what the pooled buffer held before.

The cross-format bounce names a depth-stencil plane by the plane's
format, and its second leg is recorded only if the first was. A resolve
between different sizes clips to the sizes of the two subresources, not
of the top levels (a resolve into a lower level got a rectangle outside
it, which Close refuses).

Switch: VICTORY_COPY_REPAIR, on by default; =0 passes boxes and read
back footprints on as the title gave them (the geometry check and the
close guard then skip what is illegal). Log: "copy repair: a source box
D3D12 refuses was brought to the one it takes" and "copy repair: a read
back D3D12 refuses was brought to the one it takes" (first 16, then
every 1024th).

Also removes trailing blanks the call-site conversion of the close
guard commit left in four files.

Tests: boxes_d3d12_refuses_are_repaired_or_left (no GPU),
repaired_boxes_pass_close (WARP). victory-gpu lib: 949 passed.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JzsiBtxAuHxjYfCpTzVV3h
(cherry picked from commit b3f374cdffaca5d8f4cee7396d271b3e989224a4)
When a host list's Close fails, the layer could only say "a host command
list did not close ... a command recorded into it was invalid" and end
the run. D3D12 does not say which command, and the debug layer that
would does not start on this machine: seven crashes gave no name.

Name it. Every command that goes through the guard's recorders is kept
as the plain numbers the guard judged, in a ring per recording thread
(crate::checked:💍 512 barriers, 256 texture copies and resolves,
128 buffer copies, a ring per kind so one bad copy is not pushed out by
the barriers after it). Each entry says which host list it went into
and whether it was recorded; a host list remembers where its recording
begins. Nothing is formatted or allocated when a command is noted: 16 ns
(the_guard_costs_little; with describing and judging, a transition is
38 ns, a buffer copy 50 ns, a texture copy about 80 ns).

On a failed Close, crate::checked::replay records each of the list's
entries alone into a list of its own, on stand-in resources made from
the entry's descriptions, and closes that: the ones that fail are the
ones that failed the title's list. No pointer of the failed list is
touched. What Close looks at of a command is those descriptions and
numbers and nothing else, which the oracle test now checks too: all 466
cases are replayed this way and each gets the answer the original got.
Log: "close failure: this command fails Close when recorded alone" with
the whole command, then a summary line; if nothing in the ring fails,
"close failure: no command in the ring fails Close alone" (the invalid
command is of a kind the guard does not judge, or older than the ring)
and the list's last twelve commands. Done for the first four failures
and every 64th after.

Survive it. Measured: a list whose Close failed is dead. Reset fails on
its allocator, on that allocator reset, and on a new one, so the list's
next reset ended the run anyway; a new list works and the device is
unharmed. HostList::survive() therefore puts a new, closed list in the
dead one's place (HostList::list becomes a ListCell, read as the list it
holds everywhere, replaced only here by the one thread that closes the
list). The new list holds only the transitions from the state each
texture has at the list's start to the one the recording left it in, so
later lists find every texture where the tracking says it is. The
list's read backs are dropped rather than taken from buffers nothing
wrote, and a pending upscale is discarded as at a reset. Lost: the
list's draws and copies for that submission. Not handled: a texture
whose first upload was among those copies stays without its contents
until the title writes it again, and queries the list was to resolve
keep old values.

Switches: VICTORY_CLOSE_SURVIVE, on by default; =0 ends the run at the
failure as before, after naming the command. VICTORY_CLOSE_RING, on by
default; =0 keeps nothing (then nothing can be named).
Log: "close survive: the list that did not close was replaced by an
empty one" (first 16, then every 64th).

Tests: the_ring_gives_a_list_its_commands_back,
the_command_that_fails_close_is_named (WARP), and on the host device
a_list_that_does_not_close_is_replaced_and_used_again: a host list with
a command D3D12 refuses is closed, the command is named, and the same
host list is reset, recorded, closed and executed again.
victory-gpu lib: 952 passed.

Adapted for upstream main: survive() forgets the list's pending
upscaling with upscale.store(0), as upstream's reset() does; the fork's
streamline::discard_pending is not in this tree. The conflict in host.rs
was with the state sanitiser's tests (a separate change, not in this
branch): resolved to upstream's legal_for() plus survive_tests only.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JzsiBtxAuHxjYfCpTzVV3h
(cherry picked from commit bd99eae9a0b6b0a092cef0333731151a2014a93d)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 23:55:00 +00:00
Author
Owner

@⁠tillo88 on GitHub · 2026-11-30 17:58 UTC · original

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.

runs 0x80070057 list close / device lost at the prison -> plane cut (+2:13-2:16) same, ~20 s later (+2:33-2:37) finished the route
v2026.11.29.05 43 7 7 27
#3488 6 0 0 6

(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:, no copy repair:, no title aliasing barrier: left out, no close failure: and no close 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.

**@⁠tillo88** on GitHub · 2026-11-30 17:58 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3488#issuecomment-7287134135) 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. | | runs | 0x80070057 list close / device lost at the prison -> plane cut (+2:13-2:16) | same, ~20 s later (+2:33-2:37) | finished the route | |---|---:|---:|---:|---:| | v2026.11.29.05 | 43 | 7 | 7 | 27 | | #3488 | 6 | 0 | 0 | 6 | (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:`, no `copy repair:`, no `title aliasing barrier: left out`, no `close failure:` and no `close 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.
Author
Owner

@⁠tillo88 on GitHub · 2026-12-01 12:06 UTC · original

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.

**@⁠tillo88** on GitHub · 2026-12-01 12:06 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3488#issuecomment-7310668786) 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.
github-bot force-pushed github-bot/gh-3488 from 7f63dc9992 to 686b1e1a7b 2026-12-01 17:40:58 +00:00 Compare
github-bot closed this pull request 2026-12-01 18:58:31 +00:00

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!3488
No description provided.