GPU: a placed buffer view that starts off an element of its host copy is left null, and hit detection removes the device; fix on a fork #981

Closed
opened 2026-11-26 04:15:41 +00:00 by github-bot · 2 comments
Owner

@⁠SantannaCarlos on GitHub · 2026-11-24 14:37 UTC · original

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. When such a buffer shader view started off an element of its host copy, buffer_srv left the slot null and shaders read zeros through it. CS_ComputeHitDetectionSkinnedResults (eeed82b877b44b5f) reads one of these (a structured view, stride 56) and took down both GPUs right after its first use in the world (details in #71).

Such a view now reads a copy of just its bytes that starts at the view: made on first use, keyed by (start, length), held by the slot. The copy is a host copy like the others, so its own refresh copies the pages the title wrote, from title memory. Unordered access views off an element stay null, as before.

Known limit, commented as a shortcut in the code: the copy is prepared from title memory, so it does not see what a shader of the same submission wrote in that range before the read. Getting that right needs host buffer states tracked across the whole submission (#334), so the bytes can be copied on the GPU inside the list.

Also in the commit: one view_range_of now gives the view's range to both buffer_srv and readable, which computed it differently; the warning for a null buffer shader view names its kind (placed or registered), stride and range; a diagnostics build nulls the views of the strides listed in VICTORY_NULL_VIEW_STRIDES.

Branch: https://github.com/SantannaCarlos/VIctory/tree/fix/view-off-element, one commit on ffe310e (compare: https://github.com/Marvisak/VIctory/compare/main...SantannaCarlos:fix/view-off-element).

Tested

  • cargo clippy --workspace --all-targets -- -D warnings, with and without --all-features; cargo test --workspace; cargo xtask policy.
  • 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 With the view readable
4070, mesh off TDR 3.4–11.8 s after the pass's first use no stop; the pass ran ~10 min, to the time limit (this 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, same behaviour)
iGPU, compute only page fault 1.3–1.4 s after first use (3/3) no stop; 494 s in the world, the pass ran 379 s (earlier revision, same behaviour)

Per world frame on the 4070 (mesh off), preparation took a median of 357–367 ms with this refresh path (605 ms with an earlier revision of this branch that copied each view twice).

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

Not tested: unordered access views off an element (still null); the case where a shader of the same submission writes the view's range before reading it.

#912 adds a zero-element check at the top of buffer_srv; the two branches conflict there only textually (both checks belong, the zero-element one first). #334 is what the shortcut above waits for.

**@⁠SantannaCarlos** on GitHub · 2026-11-24 14:37 UTC · [original](https://github.com/Marvisak/VIctory/issues/981) ## 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. When such a buffer shader view started off an element of its host copy, `buffer_srv` left the slot null and shaders read zeros through it. `CS_ComputeHitDetectionSkinnedResults` (`eeed82b877b44b5f`) reads one of these (a structured view, stride 56) and took down both GPUs right after its first use in the world (details in #71). Such a view now reads a copy of just its bytes that starts at the view: made on first use, keyed by (start, length), held by the slot. The copy is a host copy like the others, so its own refresh copies the pages the title wrote, from title memory. Unordered access views off an element stay null, as before. Known limit, commented as a shortcut in the code: the copy is prepared from title memory, so it does not see what a shader of the same submission wrote in that range before the read. Getting that right needs host buffer states tracked across the whole submission (#334), so the bytes can be copied on the GPU inside the list. Also in the commit: one `view_range_of` now gives the view's range to both `buffer_srv` and `readable`, which computed it differently; the warning for a null buffer shader view names its kind (placed or registered), stride and range; a diagnostics build nulls the views of the strides listed in `VICTORY_NULL_VIEW_STRIDES`. Branch: https://github.com/SantannaCarlos/VIctory/tree/fix/view-off-element, one commit on `ffe310e` (compare: https://github.com/Marvisak/VIctory/compare/main...SantannaCarlos:fix/view-off-element). ## Tested - `cargo clippy --workspace --all-targets -- -D warnings`, with and without `--all-features`; `cargo test --workspace`; `cargo xtask policy`. - 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 | With the view readable | |---|---|---| | 4070, mesh off | TDR 3.4–11.8 s after the pass's first use | no stop; the pass ran ~10 min, to the time limit (this 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, same behaviour) | | iGPU, compute only | page fault 1.3–1.4 s after first use (3/3) | no stop; 494 s in the world, the pass ran 379 s (earlier revision, same behaviour) | Per world frame on the 4070 (mesh off), preparation took a median of 357–367 ms with this refresh path (605 ms with an earlier revision of this branch that copied each view twice). Two alternatives were measured and dropped. Leaving the view null when its submission writes its range brought the stop back: the range that covers these views is the whole 174 MB buffer that holds them, declared written in every submission, so 470–1,340 views per frame were nulled. Copying the bytes on the GPU inside the list before each read kept both cards running too, but its barriers had the wrong before state in about 28% of the copies (the buffer had already been promoted earlier in the same list) and it copied ~3 GB per frame. Not tested: unordered access views off an element (still null); the case where a shader of the same submission writes the view's range before reading it. ## Related #912 adds a zero-element check at the top of `buffer_srv`; the two branches conflict there only textually (both checks belong, the zero-element one first). #334 is what the shortcut above waits for.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:15:41 +00:00
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-24 15:01 UTC · original

I reproduced a publication race in the aligned-shadow cache at 17c27b3ad81f9521101266156365633fe18588d1. Concurrent recorders can get different live buffers for the same range. The cache then refreshes one buffer while another descriptor can still hold the other.

The WARP fixture uses eight concurrent requests and inspects the mapped bytes after refreshing the cached copy. On the author head the test fails because a caller retains a different buffer. With the follow-up, every caller retains the refreshed buffer and reads the expected value. The focused test passed eight repeated runs. Full GPU diagnostics: 58 passed, 1 ignored. Clippy and the asset policy check passed.

The fix rechecks the cache under its lock when publishing a copy. One commit directly on the author head. Fix and regression

Synthetic buffer fixture on native Windows D3D12 WARP. AI-assisted.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-24 15:01 UTC · [original](https://github.com/Marvisak/VIctory/issues/981#issuecomment-7135331692) I reproduced a publication race in the aligned-shadow cache at `17c27b3ad81f9521101266156365633fe18588d1`. Concurrent recorders can get different live buffers for the same range. The cache then refreshes one buffer while another descriptor can still hold the other. The WARP fixture uses eight concurrent requests and inspects the mapped bytes after refreshing the cached copy. On the author head the test fails because a caller retains a different buffer. With the follow-up, every caller retains the refreshed buffer and reads the expected value. The focused test passed eight repeated runs. Full GPU diagnostics: 58 passed, 1 ignored. Clippy and the asset policy check passed. The fix rechecks the cache under its lock when publishing a copy. One commit directly on the author head. [Fix and regression](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/583de0a8dd7738e5417f9d4bb93824f5277ee5af) Synthetic buffer fixture on native Windows D3D12 WARP. AI-assisted.
Author
Owner

@⁠SantannaCarlos on GitHub · 2026-11-24 15:06 UTC · original

Now a PR, with a second commit for unordered views of the same kind: #1019.

**@⁠SantannaCarlos** on GitHub · 2026-11-24 15:06 UTC · [original](https://github.com/Marvisak/VIctory/issues/981#issuecomment-7135481734) Now a PR, with a second commit for unordered views of the same kind: #1019.
This discussion has been locked. Commenting is limited to contributors.
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/Marvisak--VIctory#981
No description provided.