GPU: copy into a placed twin of another format family through a buffer (#3901) #4080
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!4080
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-4080"
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?
@ShalakZ on GitHub · 2026-11-30 15:41 UTC · original
ShalakZ:pr/twin-family-buffer→main· +526 −8 · 2 files · 1 commits · closed without mergingFixes the
a host command list did not close (0x80070057)crash named in #3901: the placed-twinCopyTextureRegionacross format families (BC3_UNORM_SRGB levels into a BC7_UNORM_SRGB twin;placed_twinsmatches block size only).What it changes
twin_plan/twin_recordinlist.rschoose the route for each twin, comparing host formats:HostList::copy_scratch, fromuav_pool, returned once the list has run). The whole source subresource goes out in the source's format (GetCopyableFootprints); then the title's box of it goes into the twin, at the title's place, in the twin's format. A box that ends at the edge of a small BC level (right = 2on a 2x2 level) is rounded to whole blocks on the footprint. The buffer is leftCOMMON;twin_copy_left_out), never recorded as it is.Counted in
TWIN_ACROSS; an info line at powers of two.Compared with #3976 (same buffer route): this also covers boxed copies and copies placed elsewhere in a level, rather than leaving them out. It also keeps the title's copy whenever the block width differs, so a raw footprint is never retagged (the case found in review on #3976). #3979 skips all cross-family twins. This comparison comes from reading their diffs; I have not run them.
How it was tested
mainc71899d9+ this commit):twin_copies_across_bc_families_close_and_land_bit_for_bitrecords throughtwin_plan/twin_record: every BC3 level into a BC7 twin down to 1x1, a 32x32 box placed at 128,64, a buffer source, and the 2x2 and 1x1 levels with boxes of their size. The list closes and the twins read back bit for bit equal to the source blocks. Withtwin_planforced to the direct copy, or without the block rounding,Closefails with 0x80070057.twin_plan_keeps_the_title_copy_where_d3d12_allows_it: a raw footprint into a BC twin, and planar pairs, stay direct.a_copy_between_bc_families_fails_closekeeps the rule itself.cargo test -p victory-gpuon this branch: 1116 passed, 2 failed, 66 ignored.shader_cache::tests::every_switch_of_the_translator_is_in_the_key(VICTORY_ORACLE_RUNSno longer read) andlist::thin::tests::bindings_record_no_work(47 vs 49). Both also fail on baremainc71899d9.main's test target does not compile atc71899d9(card_passgained a 6th argument; two calls in host.rs tests pass 5). For these runs I added[0; 3]locally; that patch is not in this PR.cargo clippy -p victory-gpu --lib(default and--all-features) and--tests: no warnings in the changed lines.host_target; on currentmainonly the unit tests ran). RTX 4080, 2560x1440, DLSS off, RT off.Closeat 199-206 s in 11 runs and at 69-72 s in 2.Known limits
Refs #3901, #3880.
2f0522a777toeb981a6dee@ShalakZ on GitHub · 2026-11-30 17:29 UTC · original
In-game check on current
main(c71899d9) with this change:c71899d9merged with this fix plus our local switches. The placed-twin loop is this PR's, line for line, apart from a diagnostics-only note.Closeat 199-206 s in 11 runs.So the
host_targetlevel mapping and the family route work together on main, in game as well as in the unit tests.@ozigalko on GitHub · 2026-11-30 17:30 UTC · original
Crash counts from a second machine (RTX 5070 Ti, i7-13700K, 32 GB RAM; RT on, DLSS Quality, frame generation off;
scripts/bench.ps1, 30-210 s after the world starts, same save for every run).Before a family check, runs that reached the world and ended with
a host command list did not close (The parameter is incorrect. (0x80070057)):placed_twins)placed_twins)With a family check equivalent to #3979 (destination family vs twin family in
copy_texture_region, the twin left out) on v2026.11.30.01: 0 of 7, about 27-28 fps median and about 100 ms p99.The run with logging (run 7; runs 1-6 had the same check without the log line) said 16 times, within 9 s,
destination_family=Some(76) twin_family=Some(97): BC3_TYPELESS into BC7_TYPELESS, on 2 twin textures. That matches the caseresource::placed_twins' doc describes (a BC3 texture copied into, a BC7 view over the same memory that is sampled). If that copy is what fills the sampled view, skipping it can leave that view stale, so a route that keeps the copy, like this PR's buffer bounce, looks preferable to leaving it out. I have not run this PR itself, and the skipping runs were not checked on screen for a stale texture.@IRennie74 on GitHub · 2026-11-30 18:22 UTC · original · edited 2026-11-30 18:44 UTC
One more rig with the same signature, in case it helps weigh this. Ryzen 5 5600X, RTX 3060 12 GB, Series S at 960x540, DLSS Performance, walking route through the cell after the opening cutscene: 3 of 18 walking runs ended with
a host command list did not close(E_INVALIDARG), each with texture memory near full.We had suspected two shader-visible view heaps in one
SetDescriptorHeaps, because WARP gives that code for them, and added a per-type check indraw.rs'ssound_heaps. In 6 walking runs after it there was no abort, but its warning never printed. So that was not the cause we saw, and 6 clean runs are within chance at the earlier 1-in-6 rate. A cross-family placed-twin copy fits the symptom better. This PR is the obvious candidate on our side too, but we have not run it yet.On the diff: the
copy_resourcetwin path already requires the same family (family(pc_format(a[8])) == family(pc_format(b[8]))before itsCopyResource), so region copies are the only route left, and that is the one this covers. #4040 changes that whole-copy path and inherits the same family check, so the two should not step on each other.@tyr0nsur on GitHub · 2026-11-30 19:29 UTC · original
Independent hardware check on another card: RTX 4060 8 GB, driver 621.14, Windows 11 26300. This PR's head merged cleanly into current
main(e1251c31), thencargo test -p victory-gpu --lib twin_family_tests -- --test-threads=1:So the RTX 4060 refuses the same cross-family copy at
Close()with the sameE_INVALIDARG, and the copy through a buffer lands bit for bit there too. That matches the opendid not close (0x80070057)reports on RTX 4060 (#4246), RTX 5070 Ti (#4301) and #4319, and a 15-minute run of my own on an RTX 4060 that ended the same way. I've pointed those issues here.AI-assisted with Claude Code.
github-bot referenced this pull request2026-12-01 00:34:50 +00:00
@How-e on GitHub · 2026-12-01 02:11 UTC · original
I tested PR head
eb981a6dapplied tov2026.11.30.03(e1251c31) on an NVIDIA GeForce RTX 4080 Laptop GPU, driver 617.14, running Windows 11 build 26300. The crash occurred at the end of the opening scene.Gameplay results
0x80070057when closing the host command list.CopyTextureRegionfromBC3_TYPELESStoBC7_TYPELESS(id=874).BC3_UNORM_SRGB→BC7_UNORMcopies withthrough_a_buffer=true. The game continued for 5m 23s after the first logged buffered copy without the command-list error. I closed the window about 9 minutes after launch, and the process exited with code0.GPU regression tests
I ran the same BC3-to-BC7 copy cases on both builds. Before the patch, I adapted the PR’s fixture to use the original direct-copy path. The regression failed at
Close()with0x80070057, while the same-format BC3-to-BC3 control passed. With the patch applied, all threetwin_family_testspassed on the laptop GPU. The buffered copy closed successfully, and GPU readback matched the source blocks bit for bit, including boxed copies, small mip levels, and a buffer source.The patch resolved the opening-scene crash on my setup.
@upipibi on GitHub · 2026-12-01 03:46 UTC · original
Review of #4080 (head
eb981a6d) with an end-to-end test through the title's own copy: it closes the list, the D3D12 debug layer is quiet, and the code reads right to me. Synthetic only: no game files, no title run.What the test does. It goes in where the title does, rather than calling
twin_plan/twin_record. That makes it a check of the wiring this PR's tests don't reach:copy_texture_region, thenresource::placed_twins, thenhost_list(list).close(). Two textures sit at one address: a 256x256 BC3_UNORM texture with nine levels and a BC7_UNORM view over it, both made withresource::texture_at. There is a BC3 source of the same shape elsewhere. The test copies each level of the source into the BC3 texture with the title'scopy_texture_region, then closes the host list. The code is at the end.RTX 3070, driver 621.40, Windows 11, debug test builds. Each tree is
main5fabb46ewith that PR merged in (all three merge cleanly):VICTORY_D3D12_DEBUG=1list::maina host command list did not close (0x80070057)CopyTextureRegion: "The source format is BC3_TYPELESS and the destination format is BC7_TYPELESS"main,VICTORY_PLACED_COPIED=0a host command list did not reset (0x80070057)list::)The debug-layer line on
mainmatches the in-game one in #3911 (and in the comments on #2914) word for word. So this one copy, made in a unit test, is the refused command from those reports.Of the three mergeable PRs, #4080 is the one that fixes it.
self.reset(), as tyr0nsur, tillo88 and Lag0 reported on that PR. A list whoseClosefailed can't beReset.Code read.
retired_uavspath asindirect_scratch, so no new lifetime is added.COMMONascopy_scratchrequires.I didn't check the twin's bytes end to end. This PR's
twin_copies_across_bc_families_close_and_land_bit_for_bitcovers that, and two other cards have run it (RTX 4060, RTX 4080 Laptop).If it's useful as a regression test for the title path, it goes in
list.rs'smod tests:(I ran it under another name and with a line that printed
TWIN_COPIES_LEFT_OUT; otherwise it's the same.)Tested with the help of Claude Code (Claude Opus 5.5).
@tillo88 on GitHub · 2026-12-01 12:06 UTC · original
Crash and speed check of #4080 (head
eb981a6d) merged on top of v2026.11.30.03, against the bare release on the same bench and route.Crashes (warm-up runs included for the count):
Base errors were
a host command list did not close (0x80070057)(2) andrelay: the device was lost ... (0x887A0006)(3). With #4080 all 9 runs went past the cut and ran the whole ~6 min route. At the base rate (5 of 27), 0 of 9 by chance is about 16%, so on its own this is a good sign, not proof. Together with #4522, #3043 and #3979 (same kind of fix, same release), 0 of 30 runs stopped against 5 of 27 on the bare release, which would happen by chance about 2% of the time (Fisher's exact test).The PR's own line shows up in 1 of the 9 runs:
a copy into a placed twin of another format family (#452) copies=1 source=78 twin=98 through_a_buffer=true(then copies=2 with twin=99), 4 lines at +2:37. That is the second point where base runs fail, and that run went on to the end. In the other 8 runs the line never appears, so the cross-family twin copy did not happen in those runs.Speed (measured runs only, warm-up excluded):
+0.3% fps, inside the bench's ~2% run-to-run spread: no measurable difference in speed.
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: same save from the start of the game, prison cutscene, plane cutscene, first boat section, about 6 minutes per run.
Measured unattended on a replay bench (same save, recorded controller input via VICTORY_INPUT_REPLAY); numbers and text prepared with Claude.
@ShalakZ on GitHub · 2026-12-01 15:14 UTC · original
Thanks everyone for testing this. That's way more coverage than I could get on one machine: the 4060, How-e's 4080 Laptop on .03, upipibi's end-to-end test on a 3070, and tillo88's 0/9 vs 5/27 on a 5070 Ti with no change in fps.
@upipibi nice test. Going in through the title's own
copy_texture_regionis exactly the part my tests don't cover. I'd like to add it to this PR, credited to you. I'll do that once I've run it here (my machine is tied up with other tests right now).@hrk1337 on GitHub · 2026-12-01 16:43 UTC · original
Test Report for #4080 (
eb981a6d)v2026.11.30.03+eb981a6d(#4080) merged on top (release build with the D3D12 debug layer off)Background (#4934)
On unpatched
v2026.11.30.03, the game was reproducibly crashing with0x80070057(E_INVALIDARGat host command listClose()) at the exact same checkpoint during the Day Release mission. Running a diagnostics build withVICTORY_D3D12_DEBUG=1pinpointed the cause right before the crash: an incompatibleCopyTextureRegioncall fromBC3_TYPELESStoBC7_TYPELESS.Result with #4080
After merging
eb981a6don top ofv2026.11.30.03and loading the exact same save, the game passed the problematic Day Release checkpoint without crashing@trustno1-coder on GitHub · 2026-12-01 18:46 UTC · original
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