Twin copies take the host copy's own level: no CopyTextureRegion past a held copy's edge (0x80070057 at list close) #3792

Closed
github-bot wants to merge 1 commit from github-bot/gh-3792 into main AGit
Owner

@⁠Mikey970 on GitHub · 2026-11-30 07:18 UTC · original
Mikey970:pr/twin-levels → main · +184 −6 · 4 files · 2 commits · closed without merging

[pr-fix] Placed twins: copies take the twin's host level, not the title's index (0x80070057)

Fixes #2914 (its second case: "the destination region extends past ... only has 128 width")

What it changes

The copies into views placed over a texture the host copied into (resource::placed_twins,
VICTORY_PLACED_COPIED, both twin loops in list.rs) wrote into the twin's host copy at the
title's subresource index. A twin's host copy can begin at a later level (held levels,
VICTORY_HELD_LEVELS, on by default). Once the host has written the twin, want_level leaves the copy
as it is. That happens when texture::seed_later marks it at texture_at, or after an earlier copy.
seed_pending's own want_level(view, 0) returns early for such a twin, and the twin loops call
want_level only for twins that have not been written yet. So when a slot's mirror makes the view's host
copy at the viewed level before seed_pending runs, the copy keeps that base. A bake's copy into level 0
of a 1024x1024 BC7 texture then went into the twin's 128x128 level 0. D3D12 refuses that copy and the
host list does not close:

ID3D12CommandList::CopyTextureRegion: The destination region extends past, at least, one of the edges of
the destination subresource. When the destination format is BC7_TYPELESS, the source format is
R32G32B32A32_TYPELESS, ... SrcBox width is 256, height is 256 ... requires the destination subresource to
have 1024 width, 1024 height ... But the destination subresource only has 128 width, 128 height
  • resource::host_target maps title level L to host level L − base of the same slice
    (host_subresource). It also checks that the host level is as large as the title's (same_extent).
    A level the copy does not hold gets no copy. Such copies are counted, and the first 16 are logged
    (twin_copy_left_out): "a copy into a view placed over a texture the host copied into is left out".
  • A whole CopyResource into a twin is made only when both host textures are laid out alike.
  • seed_pending offsets the source level by the bases of both copies. Before, it compared footprints
    and refused the seed instead of crashing.

No switch: it only redirects copies to the right level, or leaves out ones D3D12 refuses.

How it was tested

  • Our fork's evidence (labelled as such: fork Mikey970/VIctory-NVIDIA, which carries a port of e530c003
    plus small host copies that also begin past level 0): RTX 4080 16 GB, Series X, 1080p. Every run died
    about 107 s into the world with a host command list did not close (0x80070057). The D3D12 debug layer
    named the copy above (run R48-debug). The build before the e530c003 port ran the full route repeatedly.
    Our fix commit is the same change as this one.
  • Before: list close failure ~107 s in, every run (fork).
  • After: IN-GAME-ON-FORK: pending
  • In game on main (41adb551 + this change, together with #3749 and #3750), RTX 4080, Series X profile, DLSS Performance via Streamline, 375 s Chapter 1 route: the route completed with no a host command list did not close error. Without this change, 3 of 5 of our runs of main-based builds that reached the shore ended there with a host command list did not close (0x80070057), and a diagnostics build with VICTORY_D3D12_DEBUG=1 named it: ID3D12CommandList::CopyTextureRegion: The destination region extends past … the destination format is BC7_TYPELESS, the source format is R32G32B32A32_TYPELESS … the operation requires the destination subresource to have 1024 width, 1024 height … But the destination subresource only has 128 width, 128 height. On our fork, where held-level and small host copies are more common, the same error ended every run about 107 s into the world until this change; with it the full route completed (34.4 FPS, no errors).
  • cargo test passed for the crates it touches: yes. With VICTORY_WARP=1,
    cargo test -p victory-gpu --lib -- held_copy placed alias passed 24 of 24. That includes the new
    resource::tests::a_copy_into_a_held_copy_takes_its_own_level, which checks the subresource mapping
    and extent check: title level 0 of a copy beginning at level 3 maps to none, level 3 to 0, and slices
    map to the copy's own slices.
  • cargo clippy -p victory-gpu --all-targets (with and without diagnostics): no finding in the
    changed lines. main's own findings are unchanged.
  • cargo xtask policy --staged: 3 files ok.

What to look for in a run on main: the log line a copy into a view placed over a texture the host copied into is left out (fields base, why). With the debug layer on, there should be no
CopyTextureRegion ... only has 128 width and no failed Close.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related:
    • #3062 (held copies: held_sub for title copies, plus fit_copy). It says "the placed twins and
      bakes still read the title's indices". Its fit_copy would cut such a twin copy to the smaller
      level's room, which avoids the crash but writes level-0 texels into the twin's first held level.
      This PR maps twins to the right level. The two touch the same twin lines in list.rs and would need a
      small merge.
    • #3488 (close guard) and #3043 (cross-format bounce) catch refused copies or format mismatches
      generically. This PR fixes where this copy comes from.

🤖 Generated with Claude Code

**@⁠Mikey970** on GitHub · 2026-11-30 07:18 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3792) `Mikey970:pr/twin-levels` → `main` · +184 −6 · 4 files · 2 commits · closed without merging [pr-fix] Placed twins: copies take the twin's host level, not the title's index (0x80070057) Fixes #2914 (its second case: "the destination region extends past ... only has 128 width") ## What it changes The copies into views placed over a texture the host copied into (`resource::placed_twins`, `VICTORY_PLACED_COPIED`, both twin loops in `list.rs`) wrote into the twin's host copy at the **title's** subresource index. A twin's host copy can begin at a later level (held levels, `VICTORY_HELD_LEVELS`, on by default). Once the host has written the twin, `want_level` leaves the copy as it is. That happens when `texture::seed_later` marks it at `texture_at`, or after an earlier copy. `seed_pending`'s own `want_level(view, 0)` returns early for such a twin, and the twin loops call `want_level` only for twins that have not been written yet. So when a slot's mirror makes the view's host copy at the viewed level before `seed_pending` runs, the copy keeps that base. A bake's copy into level 0 of a 1024x1024 BC7 texture then went into the twin's 128x128 level 0. D3D12 refuses that copy and the host list does not close: ``` ID3D12CommandList::CopyTextureRegion: The destination region extends past, at least, one of the edges of the destination subresource. When the destination format is BC7_TYPELESS, the source format is R32G32B32A32_TYPELESS, ... SrcBox width is 256, height is 256 ... requires the destination subresource to have 1024 width, 1024 height ... But the destination subresource only has 128 width, 128 height ``` - `resource::host_target` maps title level L to host level L − base of the same slice (`host_subresource`). It also checks that the host level is as large as the title's (`same_extent`). A level the copy does not hold gets no copy. Such copies are counted, and the first 16 are logged (`twin_copy_left_out`): "a copy into a view placed over a texture the host copied into is left out". - A whole `CopyResource` into a twin is made only when both host textures are laid out alike. - `seed_pending` offsets the source level by the bases of both copies. Before, it compared footprints and refused the seed instead of crashing. No switch: it only redirects copies to the right level, or leaves out ones D3D12 refuses. ## How it was tested - Our fork's evidence (labelled as such: fork `Mikey970/VIctory-NVIDIA`, which carries a port of e530c003 plus small host copies that also begin past level 0): RTX 4080 16 GB, Series X, 1080p. Every run died about 107 s into the world with `a host command list did not close (0x80070057)`. The D3D12 debug layer named the copy above (run R48-debug). The build before the e530c003 port ran the full route repeatedly. Our fix commit is the same change as this one. - Before: list close failure ~107 s in, every run (fork). - After: IN-GAME-ON-FORK: pending - **In game on `main` (41adb551 + this change, together with #3749 and #3750), RTX 4080, Series X profile, DLSS Performance via Streamline, 375 s Chapter 1 route:** the route completed with no `a host command list did not close` error. Without this change, 3 of 5 of our runs of `main`-based builds that reached the shore ended there with `a host command list did not close (0x80070057)`, and a diagnostics build with `VICTORY_D3D12_DEBUG=1` named it: `ID3D12CommandList::CopyTextureRegion: The destination region extends past … the destination format is BC7_TYPELESS, the source format is R32G32B32A32_TYPELESS … the operation requires the destination subresource to have 1024 width, 1024 height … But the destination subresource only has 128 width, 128 height`. On our fork, where held-level and small host copies are more common, the same error ended every run about 107 s into the world until this change; with it the full route completed (34.4 FPS, no errors). - `cargo test` passed for the crates it touches: yes. With `VICTORY_WARP=1`, `cargo test -p victory-gpu --lib -- held_copy placed alias` passed 24 of 24. That includes the new `resource::tests::a_copy_into_a_held_copy_takes_its_own_level`, which checks the subresource mapping and extent check: title level 0 of a copy beginning at level 3 maps to none, level 3 to 0, and slices map to the copy's own slices. - `cargo clippy -p victory-gpu --all-targets` (with and without `diagnostics`): no finding in the changed lines. main's own findings are unchanged. - `cargo xtask policy --staged`: 3 files ok. What to look for in a run on main: the log line `a copy into a view placed over a texture the host copied into is left out` (fields `base`, `why`). With the debug layer on, there should be no `CopyTextureRegion ... only has 128 width` and no failed Close. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: - #3062 (held copies: `held_sub` for title copies, plus `fit_copy`). It says "the placed twins and bakes still read the title's indices". Its `fit_copy` would cut such a twin copy to the smaller level's room, which avoids the crash but writes level-0 texels into the twin's first held level. This PR maps twins to the right level. The two touch the same twin lines in `list.rs` and would need a small merge. - #3488 (close guard) and #3043 (cross-format bounce) catch refused copies or format mismatches generically. This PR fixes where this copy comes from. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The copies into views placed over a texture the host copied into
(placed_twins, VICTORY_PLACED_COPIED) wrote into the twin's host copy
at the title's subresource index. A twin's host copy can begin at a
later level (held levels, VICTORY_HELD_LEVELS, on by default), and once
the host wrote the twin (seed_later marks it at texture_at, or an
earlier copy) want_level keeps it as it is: seed_pending's own
want_level(view, 0) returns early for it, and the twin loops ask
want_level only for twins not written yet. A bake's copy into level 0
of a 1024x1024 BC7 texture then went into the twin's 128x128 level 0;
D3D12 refuses it and the host list does not close ("The destination
region extends past ... BC7_TYPELESS ... only has 128 width", issue
#2914's second case).

resource::host_target maps title level L to host level L - base of the
same slice (host_subresource) and checks the host level is as large as
the title's (same_extent); a level the copy does not hold gets no copy
(twin_copy_left_out: counted, the first 16 said). A whole CopyResource
into a twin is made only when both host textures are laid out alike.
seed_pending offsets the source's level by the bases of both copies (it
compared footprints and refused the seed instead). No switch: it only
leaves out or redirects copies D3D12 refuses. Test:
resource::tests::a_copy_into_a_held_copy_takes_its_own_level.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 07:23:39 +00:00
Author
Owner

@⁠tyr0nsur on GitHub · 2026-11-30 08:52 UTC · original

I found a valid copy that the new host_target bound drops. In D3D12, subresource / mip_levels is array_slice + plane_slice * array_size. Comparing that quotient with just the array size drops the stencil plane. The placed-twin path can pass a plane-bearing subresource index through when the title layouts have the same array size.

Follow-up commit 95f9b2a, based on 523485b, counts the host DXGI format's planes in the bound. The mip remapping and extent checks are retained.

I added a synthetic D24S8 array test with two slices and one mip. The D3D12 format query reported two planes. With only the test added to this PR head, host_target refused the first stencil subresource (index 2). With the follow-up, it accepted indices 2 and 3, the driver returned valid 16×16 footprints, and index 4 was still refused. The regression passed on the RTX 4060 (621.14) and Microsoft WARP (VICTORY_D3D12_WARP=1 in the diagnostics build). The diagnostics resource suite reported 46 passed and one ignored, and staged asset policy passed. Review assisted by Claude Opus 5.5.

**@⁠tyr0nsur** on GitHub · 2026-11-30 08:52 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3792#issuecomment-7273449685) I found a valid copy that the new host_target bound drops. In D3D12, `subresource / mip_levels` is `array_slice + plane_slice * array_size`. Comparing that quotient with just the array size drops the stencil plane. The placed-twin path can pass a plane-bearing subresource index through when the title layouts have the same array size. [Follow-up commit `95f9b2a`](https://github.com/tyr0nsur/VIctory-NVIDIA/commit/95f9b2a233d91d175e24271219f13e6b8cf7e438), based on `523485b`, counts the host DXGI format's planes in the bound. The mip remapping and extent checks are retained. I added a synthetic D24S8 array test with two slices and one mip. The D3D12 format query reported two planes. With only the test added to this PR head, `host_target` refused the first stencil subresource (index 2). With the follow-up, it accepted indices 2 and 3, the driver returned valid 16×16 footprints, and index 4 was still refused. The regression passed on the RTX 4060 (621.14) and Microsoft WARP (`VICTORY_D3D12_WARP=1` in the diagnostics build). The diagnostics resource suite reported 46 passed and one ignored, and staged asset policy passed. Review assisted by Claude Opus 5.5.
Author
Owner

@⁠tillo88 on GitHub · 2026-11-30 12:44 UTC · original

Tested on top of v2026.11.29.05 (head 523485b, merges cleanly, builds) against #2237's crash, the a host command list did not close (0x80070057) at the prison -> plane cutscene cut, on an unattended replay bench: same save restored before every run, controller input played back with VICTORY_INPUT_REPLAY, release build, Series X 1440p, DLSS Quality, FG off, RT off, Ryzen 7 9800X3D + RTX 5070 Ti 16 GB (driver 621.40), 32 GB RAM, Windows 11.

v2026.11.29.05 Runs stopped at the prison → plane cut (+2:13 to +2:17) at +2:37 at +6:00 other passed
as released 41 8 (5 list close, 3 device lost) 6 1 1 (device lost at +1:43) 25
with this PR 13 3 (3 list close) 0 1 1 (game access violation at +4:57) 8

"list close" is a host command list did not close (0x80070057), "device lost" is relay: the device was lost. Runs include the warm-up runs, as only crashes are counted here; one #3792 launch that ended after 3 s is left out.

The three crashes with this PR are the same failure at the same second as on the release: +2:16 to +2:17, one second after the masked twin [mesh 480d53fc48107a50, pixel f41ec9d9437c021c-mask] is made. The line a copy into a view placed over a texture the host copied into is left out did not appear in any of the 14 runs. So on this route the list-close failure is not, or not only, the held-copy case this fixes. That doesn't say the change is wrong: no new failure showed up with it (the game access violation at +4:57 also happened once with #2305), and the +6:00 one came after the replay had left the route. These runs used the head before the stencil-plane follow-up 95f9b2a mentioned above. Details and timings in #2237.

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 12:44 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3792#issuecomment-7278866003) Tested on top of **v2026.11.29.05** (head `523485b`, merges cleanly, builds) against #2237's crash, the `a host command list did not close (0x80070057)` at the prison -> plane cutscene cut, on an unattended replay bench: same save restored before every run, controller input played back with `VICTORY_INPUT_REPLAY`, release build, Series X 1440p, DLSS Quality, FG off, RT off, Ryzen 7 9800X3D + RTX 5070 Ti 16 GB (driver 621.40), 32 GB RAM, Windows 11. | v2026.11.29.05 | Runs | stopped at the prison → plane cut (+2:13 to +2:17) | at +2:37 | at +6:00 | other | passed | |---|---|---|---|---|---|---| | as released | 41 | 8 (5 list close, 3 device lost) | 6 | 1 | 1 (device lost at +1:43) | 25 | | with this PR | 13 | 3 (3 list close) | 0 | 1 | 1 (game access violation at +4:57) | 8 | "list close" is `a host command list did not close (0x80070057)`, "device lost" is `relay: the device was lost`. Runs include the warm-up runs, as only crashes are counted here; one #3792 launch that ended after 3 s is left out. The three crashes with this PR are the same failure at the same second as on the release: +2:16 to +2:17, one second after the masked twin `[mesh 480d53fc48107a50, pixel f41ec9d9437c021c-mask]` is made. The line `a copy into a view placed over a texture the host copied into is left out` did not appear in any of the 14 runs. So on this route the list-close failure is not, or not only, the held-copy case this fixes. That doesn't say the change is wrong: no new failure showed up with it (the game access violation at +4:57 also happened once with #2305), and the +6:00 one came after the replay had left the route. These runs used the head before the stencil-plane follow-up `95f9b2a` mentioned above. Details and timings in #2237. Measured unattended on a replay bench (same save, recorded controller input via VICTORY_INPUT_REPLAY); numbers and text prepared with Claude.
The index divided by the mip count includes both array and plane slices.
Count the host format's planes when validating the mapped subresource,
so a legal stencil copy reaches the twin. Test both stencil slices of a
depth-stencil array and reject the index past the last plane.
Author
Owner

@⁠Freeman022026 on GitHub · 2026-11-30 13:53 UTC · original

Tested on v2026.11.29.05 (41adb551) with the stencil-plane follow-up included, in a patched build alongside #3043, #3487, #3730, and #3816. System: Ryzen 7 7800X3D, RTX 4090 24 GB (driver 621.14), 64 GB RAM, Windows 11, Series X profile, 2560x1440, DLSS Performance, 2x Frame Generation, RT off.

Prior runs on this setup hit a host command list did not close (0x80070057) in 7 of 8 sessions, including a 47-minute stock .05 run entering the city center. With this PR applied, an 81-minute run through the city center finished with 0 crashes.

During the run, the guard fired 15 times (why="level not held", subresource=0..2, base=Some(3)), leaving out placed-twin copies whose host copy began at a later mip level. The unit test resource::tests::a_copy_into_a_held_copy also passes on the RTX 4090.

**@⁠Freeman022026** on GitHub · 2026-11-30 13:53 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3792#issuecomment-7280525764) Tested on v2026.11.29.05 (`41adb551`) with the stencil-plane follow-up included, in a patched build alongside #3043, #3487, #3730, and #3816. System: Ryzen 7 7800X3D, RTX 4090 24 GB (driver 621.14), 64 GB RAM, Windows 11, Series X profile, 2560x1440, DLSS Performance, 2x Frame Generation, RT off. Prior runs on this setup hit `a host command list did not close (0x80070057)` in 7 of 8 sessions, including a 47-minute stock `.05` run entering the city center. With this PR applied, an 81-minute run through the city center finished with 0 crashes. During the run, the guard fired 15 times (`why="level not held"`, `subresource=0..2`, `base=Some(3)`), leaving out placed-twin copies whose host copy began at a later mip level. The unit test `resource::tests::a_copy_into_a_held_copy` also passes on the RTX 4090.
Author
Owner

@⁠Mikey970 on GitHub · 2026-11-30 13:54 UTC · original

@⁠tyr0nsur thanks, confirmed: the subresource index over the mip count is array_slice + plane_slice * array_size, so bounding it by the array size alone refused the stencil plane. I took your 95f9b2a onto this branch as-is (fast-forward, your authorship), so the bound is now slices * planes with the mip remap and extent checks unchanged.

Checked here on WARP (VICTORY_WARP=1): your a_placed_copy_target_keeps_the_stencil_plane fails with the old bound (index 2 refused) and passes with 95f9b2a; a_copy_into_a_held_copy_takes_its_own_level still passes. Clippy on victory-gpu --all-targets adds no warning in the touched code (the CI check failure is the pre-existing unwind_copy one on main 41adb551).

@⁠tillo88 thanks for the replay bench. Noted: on your route the list-close at the prison → plane cut is a different failure from the held-copy case (the left-out line never fired), and nothing new failed with this PR. On our route the debug layer named the out-of-bounds BC7 CopyTextureRegion that this fixes, so I'd read it as one cause of that error, not the only one.

🤖 Generated with Claude Code

**@⁠Mikey970** on GitHub · 2026-11-30 13:54 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3792#issuecomment-7280545805) @⁠tyr0nsur thanks, confirmed: the subresource index over the mip count is `array_slice + plane_slice * array_size`, so bounding it by the array size alone refused the stencil plane. I took your `95f9b2a` onto this branch as-is (fast-forward, your authorship), so the bound is now `slices * planes` with the mip remap and extent checks unchanged. Checked here on WARP (`VICTORY_WARP=1`): your `a_placed_copy_target_keeps_the_stencil_plane` fails with the old bound (index 2 refused) and passes with `95f9b2a`; `a_copy_into_a_held_copy_takes_its_own_level` still passes. Clippy on `victory-gpu --all-targets` adds no warning in the touched code (the CI `check` failure is the pre-existing `unwind_copy` one on `main` 41adb551). @⁠tillo88 thanks for the replay bench. Noted: on your route the list-close at the prison → plane cut is a different failure from the held-copy case (the left-out line never fired), and nothing new failed with this PR. On our route the debug layer named the out-of-bounds BC7 `CopyTextureRegion` that this fixes, so I'd read it as one cause of that error, not the only one. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-bot referenced this pull request from a commit 2026-11-30 14:14:18 +00:00
github-bot closed this pull request 2026-11-30 14:18:56 +00:00
Author
Owner

@⁠Mikey970 on GitHub · 2026-11-30 14:44 UTC · original

Note: this PR had already been merged into main before this follow-up was pushed, so 3a9e9a69 is only on the fork branch, not in main. It will come as a separate PR.

Follow-up 3a9e9a69: a whole CopyResource into a title texture whose placed twin's host copy holds fewer levels was left out, so that twin kept stale contents. It now compares the copy's real ends (the twin's host copy and the source's, not the destination's). When they are laid out alike it stays one CopyResource. When they differ, every subresource both ends hold at the same size (host_target at both ends: level, array slice and plane) gets its own CopyTextureRegion, and the copy is left out only when no subresource is held alike.

Tested: new a_whole_copy_into_a_held_twin_takes_the_levels_both_hold plus the existing held-copy and stencil-plane tests pass (WARP); clippy on victory-gpu --all-targets adds no warnings.

🤖 Generated with Claude Code

**@⁠Mikey970** on GitHub · 2026-11-30 14:44 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3792#issuecomment-7281850788) **Note:** this PR had already been merged into `main` before this follow-up was pushed, so `3a9e9a69` is only on the fork branch, not in `main`. It will come as a separate PR. Follow-up `3a9e9a69`: a whole `CopyResource` into a title texture whose placed twin's host copy holds fewer levels was left out, so that twin kept stale contents. It now compares the copy's real ends (the twin's host copy and the source's, not the destination's). When they are laid out alike it stays one `CopyResource`. When they differ, every subresource both ends hold at the same size (`host_target` at both ends: level, array slice and plane) gets its own `CopyTextureRegion`, and the copy is left out only when no subresource is held alike. Tested: new `a_whole_copy_into_a_held_twin_takes_the_levels_both_hold` plus the existing held-copy and stencil-plane tests pass (WARP); clippy on `victory-gpu --all-targets` adds no warnings. 🤖 Generated with [Claude Code](https://claude.com/claude-code)

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!3792
No description provided.