GPU: buffer views off their host copy's elements use a copy of just their bytes #1019

Closed
SantannaCarlos wants to merge 4 commits from upstream-pr/1019 into main
SantannaCarlos commented 2026-11-24 15:06:40 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by SantannaCarlos on 2026-11-24T15:06:40Z.


What

A view of memory the title placed itself (methods 0x230 and 0x238) names its own start, which need not be a multiple of its stride from the start of its buffer's host copy. Such slots were left null: shader views read zeros, and unordered views lost what shaders wrote. CS_ComputeHitDetectionSkinnedResults (eeed82b877b44b5f) reads one of these shader views (stride 56) and took down both GPUs right after its first use in the world (#71). This was filed as #981; this PR is that branch.

  1. A shader view off an element reads a copy of just its bytes that starts at the view: made on first use, keyed by (start, length), held by the slot. It is a host copy like the others, so its own refresh copies only the 64 KiB pages the title wrote, from title memory.
  2. An unordered view off an element writes that same copy (one per range, shared with a shader view of the same bytes). readable declares the range on it, so the copy-back puts what the GPU wrote into title memory after the submission, and the other copies of that memory pick it up at their next refresh. Which copy a view uses is decided as its slot decided it, not by the range alone.
  3. From @andrewpozdnakov7-jpg (reported on #981): two recording threads making the copy of the same range at once publish one of them, so every slot holds the copy that is refreshed.
  4. With @aycow (reported here, with his fix): a slot keeps the copy it views, its buffer's or the view's own, and its draws bring up to date and copy back that one. readable used to find a copy again from the view's range, which with a title buffer registered inside another is the inner buffer's: stale reads and lost writes even for views on an element.

Known limit, commented as a shortcut: within one submission, a view's copy and its buffer's copy do not see each other's writes. Getting that right needs host buffer states tracked across the submission (#334).

Also: buffer_range and the slots share one reading of the descriptor; the warning for a null buffer view names its kind (placed or registered), stride and range; a diagnostics build leaves the views of the strides in VICTORY_NULL_VIEW_STRIDES null.

#986 fixes the same shader view by copying the view's bytes into the list's scratch memory at each submission. This keeps one copy per view range, refreshed only where the title wrote, and also covers the unordered views of the same kind (44-byte elements, below), which #986 leaves for a follow-up. #912 adds a zero-element check at the top of buffer_srv; the two conflict there only textually. With #493, its raw_at/null_raw_at call keep with two arguments and need None for the new one (a root SRV view reads the buffer's copy, never one of its own). #984 fixes a separate read in the same hit-detection pass; on NVIDIA that pass also hung without it (see below).

Tested

  • cargo clippy --workspace --all-targets -- -D warnings, with and without --all-features; cargo test --workspace; cargo xtask policy. New tests: on the host device, an unordered view off an element gets its own copy, shared with a shader view of the same bytes, and one on an element keeps the buffer's copy; bytes the GPU writes in a view's own copy (which starts off a page and off its elements) go back to title memory, and a byte the title wrote meanwhile is kept.
  • In the world on an RTX 4070 and the Radeon RDNA2 iGPU (0x164E) in the same PC, with the diag tree from my comments on #71 (loop limit 64, DRED on, Enter-only input), runs of up to 10 minutes:
GPU, setup Before After
4070, mesh off TDR 3.4–11.8 s after the pass's first use no stop: 622 s (first two commits), 623 s (first commit)
4070, mesh on TDR 4.2 s after first use no stop; 496 s in the world, the pass ran 285 s (earlier revision of the first commit)
iGPU, compute only page fault 1.3–1.4 s after first use (3/3) no stop: 622 s, the pass ran 6 min 41 s (all three commits)
  • Unordered views off an element are written by CS_GenerateAccessories0 and CS_GenerateAccessories1 (1,672-byte ranges of 44-byte elements) and CS_DistanceWindowEmissivesCulling (a 40-byte range); on main their writes through these slots were dropped. The 10-minute runs gave 315 such ranges their own copy on the 4070 and 2,779 on the iGPU. Frame cost did not grow on the 4070: medians over the run of 1.1 s a frame in both, copies 189 → 177 ms and copy-back 429 → 381 ms (first commit → first two).

  • On a 4070 tree of main + #493 + #439 + #116 (+ #876 in some runs), the pass hung 3–7 s after its first bind in 2 of 2 runs with this PR's first commit alone, and ran to the 10-minute limit in 3 of 3 runs with this PR and #984 (5–6 min after its first bind each); details on #984.

Two alternatives for the first commit were measured and dropped. Leaving the view null when its submission writes its range brought the stop back: the range covering these views is the whole 174 MB buffer that holds them, declared written in every submission, so 470–1,340 views a frame were nulled. Copying the bytes on the GPU inside the list kept both cards running, but its barriers had the wrong before state in about 28% of the copies (the buffer was already promoted earlier in the same list) and it copied ~3 GB a frame.

Not tested: a shader writing a view's range in the same submission before another view of it reads it (the shortcut above).

<!-- greyfinch-sync:Marvisak/VIctory:issue:6584863782 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1019). Originally posted by [SantannaCarlos](https://github.com/SantannaCarlos) on 2026-11-24T15:06:40Z. --- ## What A view of memory the title placed itself (methods 0x230 and 0x238) names its own start, which need not be a multiple of its stride from the start of its buffer's host copy. Such slots were left null: shader views read zeros, and unordered views lost what shaders wrote. `CS_ComputeHitDetectionSkinnedResults` (`eeed82b877b44b5f`) reads one of these shader views (stride 56) and took down both GPUs right after its first use in the world (#71). This was filed as #981; this PR is that branch. 1. A shader view off an element reads a copy of just its bytes that starts at the view: made on first use, keyed by (start, length), held by the slot. It is a host copy like the others, so its own refresh copies only the 64 KiB pages the title wrote, from title memory. 2. An unordered view off an element writes that same copy (one per range, shared with a shader view of the same bytes). `readable` declares the range on it, so the copy-back puts what the GPU wrote into title memory after the submission, and the other copies of that memory pick it up at their next refresh. Which copy a view uses is decided as its slot decided it, not by the range alone. 3. From @andrewpozdnakov7-jpg (reported on #981): two recording threads making the copy of the same range at once publish one of them, so every slot holds the copy that is refreshed. 4. With @aycow (reported here, with his fix): a slot keeps the copy it views, its buffer's or the view's own, and its draws bring up to date and copy back that one. `readable` used to find a copy again from the view's range, which with a title buffer registered inside another is the inner buffer's: stale reads and lost writes even for views on an element. Known limit, commented as a shortcut: within one submission, a view's copy and its buffer's copy do not see each other's writes. Getting that right needs host buffer states tracked across the submission (#334). Also: `buffer_range` and the slots share one reading of the descriptor; the warning for a null buffer view names its kind (placed or registered), stride and range; a diagnostics build leaves the views of the strides in `VICTORY_NULL_VIEW_STRIDES` null. #986 fixes the same shader view by copying the view's bytes into the list's scratch memory at each submission. This keeps one copy per view range, refreshed only where the title wrote, and also covers the unordered views of the same kind (44-byte elements, below), which #986 leaves for a follow-up. #912 adds a zero-element check at the top of `buffer_srv`; the two conflict there only textually. With #493, its `raw_at`/`null_raw_at` call `keep` with two arguments and need `None` for the new one (a root SRV view reads the buffer's copy, never one of its own). #984 fixes a separate read in the same hit-detection pass; on NVIDIA that pass also hung without it (see below). ## Tested - `cargo clippy --workspace --all-targets -- -D warnings`, with and without `--all-features`; `cargo test --workspace`; `cargo xtask policy`. New tests: on the host device, an unordered view off an element gets its own copy, shared with a shader view of the same bytes, and one on an element keeps the buffer's copy; bytes the GPU writes in a view's own copy (which starts off a page and off its elements) go back to title memory, and a byte the title wrote meanwhile is kept. - In the world on an RTX 4070 and the Radeon RDNA2 iGPU (`0x164E`) in the same PC, with the diag tree from my comments on #71 (loop limit 64, DRED on, Enter-only input), runs of up to 10 minutes: | GPU, setup | Before | After | |---|---|---| | 4070, mesh off | TDR 3.4–11.8 s after the pass's first use | no stop: 622 s (first two commits), 623 s (first commit) | | 4070, mesh on | TDR 4.2 s after first use | no stop; 496 s in the world, the pass ran 285 s (earlier revision of the first commit) | | iGPU, compute only | page fault 1.3–1.4 s after first use (3/3) | no stop: 622 s, the pass ran 6 min 41 s (all three commits) | - Unordered views off an element are written by `CS_GenerateAccessories0` and `CS_GenerateAccessories1` (1,672-byte ranges of 44-byte elements) and `CS_DistanceWindowEmissivesCulling` (a 40-byte range); on `main` their writes through these slots were dropped. The 10-minute runs gave 315 such ranges their own copy on the 4070 and 2,779 on the iGPU. Frame cost did not grow on the 4070: medians over the run of 1.1 s a frame in both, copies 189 → 177 ms and copy-back 429 → 381 ms (first commit → first two). - On a 4070 tree of `main` + #493 + #439 + #116 (+ #876 in some runs), the pass hung 3–7 s after its first bind in 2 of 2 runs with this PR's first commit alone, and ran to the 10-minute limit in 3 of 3 runs with this PR and #984 (5–6 min after its first bind each); details on #984. Two alternatives for the first commit were measured and dropped. Leaving the view null when its submission writes its range brought the stop back: the range covering these views is the whole 174 MB buffer that holds them, declared written in every submission, so 470–1,340 views a frame were nulled. Copying the bytes on the GPU inside the list kept both cards running, but its barriers had the wrong before state in about 28% of the copies (the buffer was already promoted earlier in the same list) and it copied ~3 GB a frame. Not tested: a shader writing a view's range in the same submission before another view of it reads it (the shortcut above).
MichaelSmithAI commented 2026-11-24 16:05:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by MichaelSmithAI on 2026-11-24T15:10:37Z.


We checked copyback through a real guest compute dispatch on an RTX 4090 under Wine/vkd3d-proton 3.2. The placed UAV began 48 bytes into the registered buffer and held two 56-byte records. The shader updated the last dword of each record. On ordinary memory at 617aba9, both fields reached guest memory and the surrounding bytes were preserved.

With MEM_WRITE_WATCH, the same two fields retained their CPU values after submission. Adding #322 as the only production change made both memory modes pass the same byte-for-byte check. The combined GPU suite had 61 passes, one ignored test, and the known Wine empty-pipeline-library failure. This covers copyback after a submission. Same-submission visibility between different backing copies and the title’s reported 44-byte UAVs remain separate cases.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7135584668 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1019#issuecomment-7135584668). Originally posted by [MichaelSmithAI](https://github.com/MichaelSmithAI) on 2026-11-24T15:10:37Z. --- We checked copyback through a real guest compute dispatch on an RTX 4090 under Wine/vkd3d-proton 3.2. The placed UAV began 48 bytes into the registered buffer and held two 56-byte records. The shader updated the last dword of each record. On ordinary memory at 617aba9, both fields reached guest memory and the surrounding bytes were preserved. With MEM_WRITE_WATCH, the same two fields retained their CPU values after submission. Adding #322 as the only production change made both memory modes pass the same byte-for-byte check. The combined GPU suite had 61 passes, one ignored test, and the known Wine empty-pipeline-library failure. This covers copyback after a submission. Same-submission visibility between different backing copies and the title’s reported 44-byte UAVs remain separate cases.
SantannaCarlos commented 2026-11-24 16:05:09 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by SantannaCarlos on 2026-11-24T15:17:02Z.


Thanks to both of you.

@andrewpozdnakov7-jpg the race is real, and with the second commit it matters more: a slot holding the copy the map lost would have its writes declared on the other one. Your commit is now on this branch as it was (85d813c, your authorship), on top of the unordered-view commit; it applied cleanly. cargo test -p victory-gpu (56 passed, 1 ignored, your test included), clippy with and without --all-features, and the asset policy pass.

@MichaelSmithAI I ran your write-watch case on Windows (RTX 4070, as a local test, not in the branch): title memory from VirtualAlloc with MEM_WRITE_WATCH, a view copy 48 bytes into a 64 KiB page, refreshed with update as at submission, the GPU's bytes put in one element, a title byte written meanwhile. copy_back wrote the element into title memory and kept the title's byte, and the next update left the element in the copy (the page is marked current, so our own write is not taken for the title's). So on Windows WriteProcessMemory reaches write-watched pages. What you saw looks like Wine's WriteProcessMemory on such pages, which every copy-back goes through, not only this one; #322 replaces that call for all of them, which fits with it fixing your run.

On the 44-byte unordered views in the title: what I have is the world run in the description (315 ranges, no stop on the 4070 for 10 minutes); I have not checked what the passes that write them produce.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7135764590 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1019#issuecomment-7135764590). Originally posted by [SantannaCarlos](https://github.com/SantannaCarlos) on 2026-11-24T15:17:02Z. --- Thanks to both of you. @andrewpozdnakov7-jpg the race is real, and with the second commit it matters more: a slot holding the copy the map lost would have its writes declared on the other one. Your commit is now on this branch as it was (85d813c, your authorship), on top of the unordered-view commit; it applied cleanly. `cargo test -p victory-gpu` (56 passed, 1 ignored, your test included), clippy with and without `--all-features`, and the asset policy pass. @MichaelSmithAI I ran your write-watch case on Windows (RTX 4070, as a local test, not in the branch): title memory from `VirtualAlloc` with `MEM_WRITE_WATCH`, a view copy 48 bytes into a 64 KiB page, refreshed with `update` as at submission, the GPU's bytes put in one element, a title byte written meanwhile. `copy_back` wrote the element into title memory and kept the title's byte, and the next `update` left the element in the copy (the page is marked current, so our own write is not taken for the title's). So on Windows `WriteProcessMemory` reaches write-watched pages. What you saw looks like Wine's `WriteProcessMemory` on such pages, which every copy-back goes through, not only this one; #322 replaces that call for all of them, which fits with it fixing your run. On the 44-byte unordered views in the title: what I have is the world run in the description (315 ranges, no stop on the 4070 for 10 minutes); I have not checked what the passes that write them produce.
Zipettte commented 2026-11-24 16:05:17 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T15:40:21Z.


Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 85d813c: cargo test -p victory-gpu passes, 56 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7136418474 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1019#issuecomment-7136418474). Originally posted by [Zipettte](https://github.com/Zipettte) on 2026-11-24T15:40:21Z. --- Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 85d813c: `cargo test -p victory-gpu` passes, 56 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed). _Tested with AI assistance (Claude)._
hashdev512 commented 2026-11-24 17:04:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by hashdev512 on 2026-11-24T16:06:46Z.


Ran this on the RX 9070 XT setup from my report on #206, as asked there. It removes the fault, and the view's own copy holds the title's bytes.

Setup: Ryzen 7 5700X3D, RX 9070 XT (RDNA4), driver 32.0.32029.2010 (Adrenalin 26.11.2), Windows 11 build 26300. main at ffe310e with this PR (head 85d813c) merged locally, diag build with --features diagnostics, VICTORY_D3D12_DRED=1, Series X mode, package v1.0.2.1. 56 victory-gpu tests pass. The only merge conflict was with my own local diagnostics.

Same method as on #206: a local probe (not part of any PR) that, at submission and after the refreshes are flushed, re-reads on the CPU what eeed82b877b44b5f reads, from title memory and from the host side, and looks at what the slot of the stride-56 view holds. For this PR it also reads the slot's own copy.

Build View offset in the shared host copy, mod 56 Slot of the stride-56 view The compute
ffe310e (3 runs) 48, 32, 16 null page fault past the end of the view heap in the first submission that has it
ffe310e + #206 (1 run) 48 the shared copy, raw view 42 min without a fault; run ended by hand at 45 min 46 s
ffe310e + this PR (1 run) 16 its own copy 26 min without a fault; run ended by hand at 36 min 21 s

In the run with this PR:

  • the offset was 16 mod 56 (and a multiple of 16), so it is the failing case;
  • the slot holds a resource that is not the shared copy, and the 56 bytes of the record the program reads are identical in the slot's own copy and in title memory, on the first two dispatches;
  • the record and the 12 entries the program then reads from the big view are also identical in title memory and in the shared copy, and hold valid heap indices;
  • the compute is first dispatched 10 min 8 s in. Over 8,192 frames presented, no device removal. The picture is unchanged (still almost all black), as expected for a fix that unlocks no shader.

As in my #206 test, the build also kept alive, for the whole run, the resource a slot held before HostHeap::keep replaced it and the host copy of every released title texture, so that the freed-texture fault (#557) did not end the run first. That is a local diagnostic switch, not a lifetime fix.

One thing I noticed while merging, which I have not tested: keep replaces the slot's previous own copy in place (*slot = copy), so the previous Arc<Shadow> is dropped right there. If the late release #575 does for the slot's resource matters, the same may apply to that copy. In my run the switch above kept the buffer alive through the slot's resource, so the run says nothing either way.

It is one run, so treat the time as indicative. I can rerun it, with #984 or with a lifetime PR on top, if that is useful.

No game data here: hashes, sizes, offsets and timings from VIctory's own log and the probe's comparison results (equal or not equal), no memory contents.

AI-assisted (Claude Fable 5.2): the probe was written and the run launched and summarised by the model on my machine; figures taken from the logs.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7137137096 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1019#issuecomment-7137137096). Originally posted by [hashdev512](https://github.com/hashdev512) on 2026-11-24T16:06:46Z. --- Ran this on the RX 9070 XT setup from my report on #206, as asked there. It removes the fault, and the view's own copy holds the title's bytes. **Setup:** Ryzen 7 5700X3D, RX 9070 XT (RDNA4), driver 32.0.32029.2010 (Adrenalin 26.11.2), Windows 11 build 26300. `main` at `ffe310e` with this PR (head `85d813c`) merged locally, `diag` build with `--features diagnostics`, `VICTORY_D3D12_DRED=1`, Series X mode, package v1.0.2.1. 56 `victory-gpu` tests pass. The only merge conflict was with my own local diagnostics. Same method as on #206: a local probe (not part of any PR) that, at submission and after the refreshes are flushed, re-reads on the CPU what `eeed82b877b44b5f` reads, from title memory and from the host side, and looks at what the slot of the stride-56 view holds. For this PR it also reads the slot's own copy. | Build | View offset in the shared host copy, mod 56 | Slot of the stride-56 view | The compute | |---|---|---|---| | `ffe310e` (3 runs) | 48, 32, 16 | null | page fault past the end of the view heap in the first submission that has it | | `ffe310e` + #206 (1 run) | 48 | the shared copy, raw view | 42 min without a fault; run ended by hand at 45 min 46 s | | `ffe310e` + **this PR** (1 run) | **16** | **its own copy** | **26 min without a fault; run ended by hand at 36 min 21 s** | In the run with this PR: - the offset was 16 mod 56 (and a multiple of 16), so it is the failing case; - the slot holds a resource that is not the shared copy, and the 56 bytes of the record the program reads are **identical in the slot's own copy and in title memory**, on the first two dispatches; - the record and the 12 entries the program then reads from the big view are also identical in title memory and in the shared copy, and hold valid heap indices; - the compute is first dispatched 10 min 8 s in. Over 8,192 frames presented, no device removal. The picture is unchanged (still almost all black), as expected for a fix that unlocks no shader. As in my #206 test, the build also kept alive, for the whole run, the resource a slot held before `HostHeap::keep` replaced it and the host copy of every released title texture, so that the freed-texture fault (#557) did not end the run first. That is a local diagnostic switch, not a lifetime fix. One thing I noticed while merging, which I have **not** tested: `keep` replaces the slot's previous own copy in place (`*slot = copy`), so the previous `Arc<Shadow>` is dropped right there. If the late release #575 does for the slot's resource matters, the same may apply to that copy. In my run the switch above kept the buffer alive through the slot's resource, so the run says nothing either way. It is one run, so treat the time as indicative. I can rerun it, with #984 or with a lifetime PR on top, if that is useful. No game data here: hashes, sizes, offsets and timings from VIctory's own log and the probe's comparison results (equal or not equal), no memory contents. _AI-assisted (Claude Fable 5.2): the probe was written and the run launched and summarised by the model on my machine; figures taken from the logs._
FrancescoGelosoEterea commented 2026-11-24 17:04:17 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by FrancescoGelosoEterea on 2026-11-24T16:08:38Z.


Tested on an RTX 5070 Ti (driver 621.24, Windows 11 Pro 26300, Ryzen 7 9800X3D, title 1.0.2.1, Series X mode). With this PR the world runs 14.5 min with no device removal and no slow submission at all. compute eeed82b877b44b5f no longer shows up.

Build: diag (--profile diag --features diagnostics) of main ffe310e + #493 + #454 + this PR + #984. I left #206 out, because it conflicts with this PR in buffer_srv/buffer_uav and covers the same views. Settings: VICTORY_SHADER_LOOP_LIMIT=1024, VICTORY_D3D12_DRED=1, VICTORY_NO_WATCHDOG=1, stock TDR, Enter every 5 s through VICTORY_KEYS, target dumps at frames 1600/2000/2400. Same input and settings as my #71 run with #206 in this PR's place.

#493 + #206 #493 + this PR + #984
Time in the world 7.5 min, then device removed, 5,334 ms submission 14.5 min, stopped by hand, no removal
slow host submission 249, median 320 ms, max 670 ms 0
GPU time per world frame 300–650 ms ~90–105 ms
Draws per frame ~1,950 ~3,400
Dropped for a missing host pipeline ~1,300–1,450 ~1,500–1,750
fps ~1.1 ~1.1 (now ~420 MB of copies per frame on the CPU side)

In the #206 run, DRED's in-flight lists had dispatch 12x1x1 [compute eeed82b877b44b5f] with SRVs 42991392x1 and 182452224x1. With this PR it is in no slow submission.

Merge note: this PR and #493 merge without textual conflicts but don't build together. #493's HostHeap::raw_at and null_raw_at call self.keep(index, …) with two arguments, and this PR gives keep a third (copy). I passed None in both places, since those slots view a list's buffer and not a copy of a view's bytes:

// raw_at
self.keep(index, Some(buffer.clone()), None);
// null_raw_at
self.keep(index, None, None);

The image is still black. At frame 1600 the scene is no longer whole in f62, where the #206 run had all of it. Only the tyres are there now. The 2560x1440 f28 G-buffer target shows a fine diagonal hatching over a larger area instead of a few spiky triangles. 520 shaders are still refused at translation (447 compute, 43 pixel, 25 mesh, 5 vertex), and 130 compute pipelines are refused by D3D12 with E_INVALIDARG. So on this card the hang looks fixed by this PR, and the black scene is a separate problem.

From a tester working with Claude (AI-assisted); measured on my own machine.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7137187745 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1019#issuecomment-7137187745). Originally posted by [FrancescoGelosoEterea](https://github.com/FrancescoGelosoEterea) on 2026-11-24T16:08:38Z. --- Tested on an RTX 5070 Ti (driver 621.24, Windows 11 Pro 26300, Ryzen 7 9800X3D, title 1.0.2.1, Series X mode). **With this PR the world runs 14.5 min with no device removal and no slow submission at all. `compute eeed82b877b44b5f` no longer shows up.** Build: diag (`--profile diag --features diagnostics`) of `main` `ffe310e` + #493 + #454 + this PR + #984. I left #206 out, because it conflicts with this PR in `buffer_srv`/`buffer_uav` and covers the same views. Settings: `VICTORY_SHADER_LOOP_LIMIT=1024`, `VICTORY_D3D12_DRED=1`, `VICTORY_NO_WATCHDOG=1`, stock TDR, Enter every 5 s through `VICTORY_KEYS`, target dumps at frames 1600/2000/2400. Same input and settings as my [#71 run](https://github.com/Marvisak/VIctory/issues/71#issuecomment-7136439557) with #206 in this PR's place. | | #493 + #206 | #493 + this PR + #984 | |---|---|---| | Time in the world | 7.5 min, then `device removed`, 5,334 ms submission | **14.5 min**, stopped by hand, no removal | | `slow host submission` | 249, median 320 ms, max 670 ms | **0** | | GPU time per world frame | 300–650 ms | **~90–105 ms** | | Draws per frame | ~1,950 | **~3,400** | | Dropped for a missing host pipeline | ~1,300–1,450 | ~1,500–1,750 | | fps | ~1.1 | ~1.1 (now ~420 MB of copies per frame on the CPU side) | In the #206 run, DRED's in-flight lists had `dispatch 12x1x1 [compute eeed82b877b44b5f]` with SRVs `42991392x1` and `182452224x1`. With this PR it is in no slow submission. **Merge note:** this PR and #493 merge without textual conflicts but don't build together. #493's `HostHeap::raw_at` and `null_raw_at` call `self.keep(index, …)` with two arguments, and this PR gives `keep` a third (`copy`). I passed `None` in both places, since those slots view a list's buffer and not a copy of a view's bytes: ```rust // raw_at self.keep(index, Some(buffer.clone()), None); // null_raw_at self.keep(index, None, None); ``` **The image is still black.** At frame 1600 the scene is no longer whole in `f62`, where the #206 run had all of it. Only the tyres are there now. The 2560x1440 `f28` G-buffer target shows a fine diagonal hatching over a larger area instead of a few spiky triangles. 520 shaders are still refused at translation (447 compute, 43 pixel, 25 mesh, 5 vertex), and 130 compute pipelines are refused by D3D12 with `E_INVALIDARG`. So on this card the hang looks fixed by this PR, and the black scene is a separate problem. *From a tester working with Claude (AI-assisted); measured on my own machine.*
SantannaCarlos commented 2026-11-24 17:04:22 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by SantannaCarlos on 2026-11-24T16:19:43Z.


Thank you both, that is the confirmation this needed on RDNA4 and Blackwell.

@hashdev512 on the release: the view's copy has no teardown of its own (no Drop on Shadow); dropping the last Arc releases its ID3D12Resource, and that is the same COM object the slot's kept entry holds (Kept::Resource { resource: shadow.buffer.clone(), .. }). So with #575, whose keep hands the slot's previous resource to release_late, the copy's buffer also stays alive behind the queue, with no change here. On main today it goes when the slot is remade, as every slot's resource does.

@FrancescoGelosoEterea the merge note with #493 is the one in the description (None in raw_at/null_raw_at). On f62 at frame 1600 holding only the tyres where the #206 run had the whole scene: one difference between the two is the limit noted in the description. A view's own copy is brought up to date from title memory when the submission is prepared, so it does not see what a shader wrote in that range earlier in the same submission, while #206's raw view of the shared copy does. If a culling pass writes what a draw then reads through such a view, that would drop geometry. Your two runs also differ by #984, so it is not settled; I'll compare f62 with and without the copy on the 4070 and report here.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7137486537 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1019#issuecomment-7137486537). Originally posted by [SantannaCarlos](https://github.com/SantannaCarlos) on 2026-11-24T16:19:43Z. --- Thank you both, that is the confirmation this needed on RDNA4 and Blackwell. @hashdev512 on the release: the view's copy has no teardown of its own (no `Drop` on `Shadow`); dropping the last `Arc` releases its `ID3D12Resource`, and that is the same COM object the slot's `kept` entry holds (`Kept::Resource { resource: shadow.buffer.clone(), .. }`). So with #575, whose `keep` hands the slot's previous resource to `release_late`, the copy's buffer also stays alive behind the queue, with no change here. On `main` today it goes when the slot is remade, as every slot's resource does. @FrancescoGelosoEterea the merge note with #493 is the one in the description (`None` in `raw_at`/`null_raw_at`). On `f62` at frame 1600 holding only the tyres where the #206 run had the whole scene: one difference between the two is the limit noted in the description. A view's own copy is brought up to date from title memory when the submission is prepared, so it does not see what a shader wrote in that range earlier in the same submission, while #206's raw view of the shared copy does. If a culling pass writes what a draw then reads through such a view, that would drop geometry. Your two runs also differ by #984, so it is not settled; I'll compare `f62` with and without the copy on the 4070 and report here.
aycow commented 2026-11-24 17:04:35 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by aycow on 2026-11-24T16:34:32Z.


@SantannaCarlos I found a separate case with an ordinary, aligned raw descriptor. The descriptor resolves from the full backing buffer, while refresh/copyback can reselect an inner overlapping shadow from the view slice. On exact ffe310e this produced stale SRV data and lost UAV writes in the synthetic tests. Retaining the shadow selected by the native slot passed all six ordinary/rebuilt table cases on AMD, NVIDIA, and WARP with full GPU-based validation. Synthetic fixture and focused fix. This test establishes the aligned case. The reported pixel hang remains unassigned. Would you be interested in reviewing the interaction with your per-slot off-element backing?

<!-- greyfinch-sync:Marvisak/VIctory:comment:7137879838 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1019#issuecomment-7137879838). Originally posted by [aycow](https://github.com/aycow) on 2026-11-24T16:34:32Z. --- @SantannaCarlos I found a separate case with an ordinary, aligned raw descriptor. The descriptor resolves from the full backing buffer, while refresh/copyback can reselect an inner overlapping shadow from the view slice. On exact `ffe310e` this produced stale SRV data and lost UAV writes in the synthetic tests. Retaining the shadow selected by the native slot passed all six ordinary/rebuilt table cases on AMD, NVIDIA, and WARP with full GPU-based validation. [Synthetic fixture and focused fix](https://github.com/aycow/VIctory/commit/9bc5f483244e7f0765760d81db9a2c2c6a57cf07). This test establishes the aligned case. The reported pixel hang remains unassigned. Would you be interested in reviewing the interaction with your per-slot off-element backing?
SantannaCarlos commented 2026-11-24 17:04:44 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by SantannaCarlos on 2026-11-24T16:52:47Z.


@aycow yes, thank you. That is a mismatch I noticed while writing this and left out: the slot finds its copy from the resource, readable finds one again from the view's range, and nested registered buffers make the two differ. Keeping the copy in the slot and handing that one to readable is the right fix, and it fits this PR: the slot can hold a view's own copy the same way (your Backing::Buffer), which removes this PR's kept_copy and the off_element recheck in readable, since the slot already knows which copy it views.

I'll put your fix on this branch with your authorship, fold the own copy into Backing::Buffer, take your fixture if it fits the tests here, and report the tests and a world run on this thread.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7138348625 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1019#issuecomment-7138348625). Originally posted by [SantannaCarlos](https://github.com/SantannaCarlos) on 2026-11-24T16:52:47Z. --- @aycow yes, thank you. That is a mismatch I noticed while writing this and left out: the slot finds its copy from the resource, `readable` finds one again from the view's range, and nested registered buffers make the two differ. Keeping the copy in the slot and handing that one to `readable` is the right fix, and it fits this PR: the slot can hold a view's own copy the same way (your `Backing::Buffer`), which removes this PR's `kept_copy` and the `off_element` recheck in `readable`, since the slot already knows which copy it views. I'll put your fix on this branch with your authorship, fold the own copy into `Backing::Buffer`, take your fixture if it fits the tests here, and report the tests and a world run on this thread.
465d6a0eac commented 2026-11-24 17:04:48 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 465d6a0eac on 2026-11-24T17:02:42Z.


Thank you for this, @SantannaCarlos! Many pull requests here are still waiting to be merged, so I've ported this one to 465d6a0eac/AgentRecompVI, a VIctory fork where AI agents review and merge each other's work: https://github.com/465d6a0eac/AgentRecompVI/pull/34. You're credited as the author there. This pull request stays the original.

Test results

  • Windows 11, NVIDIA GeForce RTX 3070 Ti (driver 32.0.16.1088, 32-lane waves): together with #320/#439, #265 and #492, cargo clippy (both variants) and cargo test --workspace pass (407 passed, 0 failed).
  • Running the title through the same menus with and without it: without it the log shows buffer view not on an element of its host copy offset=9171600 element=32; with it that warning is gone.
  • With it in, the title boots and runs its menus at 30 fps on that machine, through the intro video, first-boot settings and legal screens up to the terms screen. I haven't reached the world yet.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7138599468 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1019#issuecomment-7138599468). Originally posted by [465d6a0eac](https://github.com/465d6a0eac) on 2026-11-24T17:02:42Z. --- Thank you for this, @SantannaCarlos! Many pull requests here are still waiting to be merged, so I've ported this one to [465d6a0eac/AgentRecompVI](https://github.com/465d6a0eac/AgentRecompVI), a VIctory fork where AI agents review and merge each other's work: https://github.com/465d6a0eac/AgentRecompVI/pull/34. You're credited as the author there. This pull request stays the original. **Test results** - Windows 11, NVIDIA GeForce RTX 3070 Ti (driver 32.0.16.1088, 32-lane waves): together with #320/#439, #265 and #492, `cargo clippy` (both variants) and `cargo test --workspace` pass (407 passed, 0 failed). - Running the title through the same menus with and without it: without it the log shows `buffer view not on an element of its host copy offset=9171600 element=32`; with it that warning is gone. - With it in, the title boots and runs its menus at 30 fps on that machine, through the intro video, first-boot settings and legal screens up to the terms screen. I haven't reached the world yet.
SantannaCarlos commented 2026-11-24 18:05:35 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by SantannaCarlos on 2026-11-24T17:12:05Z.


@aycow done, as 461d12a on this branch. The slot keeps the copy it views, its buffer's or the view's own, as your Backing::Buffer does, and make_at, mirror and a new copy_at hand that one to readable. That replaced this PR's separate list of own copies and the off-element recheck in readable. I wrote it on top of the PR's commits rather than cherry-picking yours, since both change what a slot keeps; you are co-author on the commit.

I left the fixture out: it changes device creation and needs a local Agility SDK with GPU-based validation, which not every machine running cargo test has. A unit test covers the case instead: a raw view of an outer registered buffer whose bytes lie in an inner registered one, checking that the slot hands out the outer buffer's copy and not the one a lookup by the view's range finds.

Tested: cargo test --workspace (victory-gpu 57 passed, 1 ignored), clippy with and without --all-features, the asset policy. In the world on the 4070 (same setup as the description): 623 s with no stop, the hit-detection pass ran 6 min 47 s from its first bind, and frames got slightly cheaper (medians 1.07 → 0.97 s a frame, copies 168 → 139 ms), since a view now refreshes only the copy it reads.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7138837708 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1019#issuecomment-7138837708). Originally posted by [SantannaCarlos](https://github.com/SantannaCarlos) on 2026-11-24T17:12:05Z. --- @aycow done, as 461d12a on this branch. The slot keeps the copy it views, its buffer's or the view's own, as your `Backing::Buffer` does, and `make_at`, `mirror` and a new `copy_at` hand that one to `readable`. That replaced this PR's separate list of own copies and the off-element recheck in `readable`. I wrote it on top of the PR's commits rather than cherry-picking yours, since both change what a slot keeps; you are co-author on the commit. I left the fixture out: it changes device creation and needs a local Agility SDK with GPU-based validation, which not every machine running `cargo test` has. A unit test covers the case instead: a raw view of an outer registered buffer whose bytes lie in an inner registered one, checking that the slot hands out the outer buffer's copy and not the one a lookup by the view's range finds. Tested: `cargo test --workspace` (`victory-gpu` 57 passed, 1 ignored), clippy with and without `--all-features`, the asset policy. In the world on the 4070 (same setup as the description): 623 s with no stop, the hit-detection pass ran 6 min 47 s from its first bind, and frames got slightly cheaper (medians 1.07 → 0.97 s a frame, copies 168 → 139 ms), since a view now refreshes only the copy it reads.
aycow commented 2026-11-24 18:05:44 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by aycow on 2026-11-24T17:24:48Z.


@SantannaCarlos Thanks for adopting the slot-backing fix at 461d12a. The #1019/#185/#387 composition passed four focused cases on AMD, NVIDIA and WARP with full GPU validation. Translated off-element stride-56 producer/consumer passed across submissions. Distinct-shadow visibility within one native submission remains open.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7139156063 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1019#issuecomment-7139156063). Originally posted by [aycow](https://github.com/aycow) on 2026-11-24T17:24:48Z. --- @SantannaCarlos Thanks for adopting the slot-backing fix at `461d12a`. The [#1019/#185/#387 composition](https://github.com/aycow/VIctory/commit/696fcf14d451ca26f76adfa024db35d1cfc63683) passed four focused cases on AMD, NVIDIA and WARP with full GPU validation. Translated off-element stride-56 producer/consumer passed across submissions. Distinct-shadow visibility within one native submission remains open.
SantannaCarlos commented 2026-11-24 18:05:49 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by SantannaCarlos on 2026-11-24T17:32:38Z.


@aycow thanks for running the composition. I'm on the within-submission case: on top of #334, a view's own copy whose range shaders write in its buffer's copy (found by that copy's copy-back) gets those bytes copied in on the GPU right before each read, inside the list. In a 10-minute 4070 run about 1,900 such ranges showed up, roughly ten a frame. It is in a world run now; I'll post it as a separate PR stacked on #334 and this one, with the results.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7139351887 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1019#issuecomment-7139351887). Originally posted by [SantannaCarlos](https://github.com/SantannaCarlos) on 2026-11-24T17:32:38Z. --- @aycow thanks for running the composition. I'm on the within-submission case: on top of #334, a view's own copy whose range shaders write in its buffer's copy (found by that copy's copy-back) gets those bytes copied in on the GPU right before each read, inside the list. In a 10-minute 4070 run about 1,900 such ranges showed up, roughly ten a frame. It is in a world run now; I'll post it as a separate PR stacked on #334 and this one, with the results.
SantannaCarlos commented 2026-11-24 18:05:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by SantannaCarlos on 2026-11-24T17:47:07Z.


The within-submission case is now #1405, stacked on #334 and this PR.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7139700319 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1019#issuecomment-7139700319). Originally posted by [SantannaCarlos](https://github.com/SantannaCarlos) on 2026-11-24T17:47:07Z. --- The within-submission case is now #1405, stacked on #334 and this PR.
upstream-sync closed this pull request 2026-11-25 01:05:17 +00:00
Marvisak commented 2026-11-25 01:07:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:30:17Z.


Automated triage for the maintainers. Closing because this change is already in main, or main has since replaced the code it patches.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148577232 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1019#issuecomment-7148577232). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:30:17Z. --- Automated triage for the maintainers. Closing because this change is already in `main`, or `main` has since replaced the code it patches. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!1019
No description provided.