GPU: one aligned copy per unaligned SRV range per list (follow-up to #986) #1260

Closed
github-bot wants to merge 2 commits from gh-pr/1260/head into gh-pr/1260/base
Owner

@⁠DaemonSimon on GitHub · 2026-11-24 16:52 UTC · original
DaemonSimon:fix-986-copy-once → main · +173 −11 · 3 files · 2 commits · closed without merging

Depends on: #986 (this branch is #986 plus one commit; only the last commit is new).

What

#986 copies an unaligned buffer SRV's bytes into fresh scratch memory for every draw that reads it. In the world that adds up fast: about 286k copies (35 GB) within a few minutes. GTT filled to 15 GB, RADV refused further submissions ("not enough memory") and the device was removed.

This commit makes draws of one command list that read the same unaligned range share a single aligned copy, kept until the list is reset. The fix #986 brings (no shader reading address 0 through an empty view) is unchanged.

Result

  • Without #986: the hit-detection compute pass read an empty view and page-faulted the GPU about 80 s into the world.
  • #986 alone: no page fault, but GPU memory ran out after a few minutes (device removed).
  • #986 + this commit: 6.4 minutes in the world with no page fault and no device removal; GTT stays at about 4.6 GB. Frame rate is close to the baseline (3.4 vs 4.0 fps).

Testing

  • Linux, AMD RX 9070 XT (RADV), Wine 11 with Proton Experimental's vkd3d-proton and DXVK's dxgi, on top of #994. Retail boot through the start screen into the first mission.
  • cargo check -p victory-gpu --target x86_64-pc-windows-msvc on this branch (#986 + this commit) is clean.
  • No game data, logs or captures are included.

AI-assisted: written and tested with Claude Code.

🤖 Generated with Claude Code

**@⁠DaemonSimon** on GitHub · 2026-11-24 16:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/1260) `DaemonSimon:fix-986-copy-once` → `main` · +173 −11 · 3 files · 2 commits · closed without merging Depends on: #986 (this branch is #986 plus one commit; only the last commit is new). ## What #986 copies an unaligned buffer SRV's bytes into fresh scratch memory for every draw that reads it. In the world that adds up fast: about 286k copies (35 GB) within a few minutes. GTT filled to 15 GB, RADV refused further submissions ("not enough memory") and the device was removed. This commit makes draws of one command list that read the same unaligned range share a single aligned copy, kept until the list is reset. The fix #986 brings (no shader reading address 0 through an empty view) is unchanged. ## Result - Without #986: the hit-detection compute pass read an empty view and page-faulted the GPU about 80 s into the world. - #986 alone: no page fault, but GPU memory ran out after a few minutes (device removed). - #986 + this commit: 6.4 minutes in the world with no page fault and no device removal; GTT stays at about 4.6 GB. Frame rate is close to the baseline (3.4 vs 4.0 fps). ## Testing - Linux, AMD RX 9070 XT (RADV), Wine 11 with Proton Experimental's vkd3d-proton and DXVK's dxgi, on top of #994. Retail boot through the start screen into the first mission. - `cargo check -p victory-gpu --target x86_64-pc-windows-msvc` on this branch (#986 + this commit) is clean. - No game data, logs or captures are included. AI-assisted: written and tested with Claude Code. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Placed structured buffer SRVs sub-allocated inside a larger title buffer can land at shadow offsets not divisible by StructureByteStride (e.g. offset % 56 != 0 in GTA VI hit detection). buffer_srv() rejected these views, leaving null_buffer_view (zeros) in the host descriptor slot. Detect unaligned buffer SRVs, promote their descriptor table to fresh dynamic slots, copy their bytes at submission into an element-aligned upload scratch slice, and bind an SRV with FirstElement = at / element.
PR #986 copied an unaligned buffer SRV's bytes into fresh scratch memory
for every draw reading it: 286k copies (35 GB) in a few minutes of the
world, GTT filled to 15 GB and RADV refused submissions (not enough
memory, device removed). Draws of one list reading the same range now
share one copy, kept until the list is reset. GTT stays at ~4.6 GB.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:25:28 +00:00
github-bot closed this pull request 2026-11-26 04:25:28 +00:00
Author
Owner

@⁠justlovett0 on GitHub · 2026-11-24 17:32 UTC · original

Verified on Win10 21H2 / RTX 3080 (driver 621.24) stacked with #986 and #1267: world went ~1 fps → 20 fps, copies 270–400 MB/frame → 0.4 MB, and the ~2–3 min device removal disappeared (0 in a ~2.3 min world run). Combined result and setup detailed on #986. AI use: Qwen Code (model name not disclosed); user-confirmed.

**@⁠justlovett0** on GitHub · 2026-11-24 17:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/1260#issuecomment-7139352520) Verified on Win10 21H2 / RTX 3080 (driver 621.24) stacked with #986 and #1267: world went ~1 fps → 20 fps, copies 270–400 MB/frame → 0.4 MB, and the ~2–3 min device removal disappeared (0 in a ~2.3 min world run). Combined result and setup detailed on #986. AI use: Qwen Code (model name not disclosed); user-confirmed.
Author
Owner

@⁠BitWuehler on GitHub · 2026-11-24 20:06 UTC · original

Confirmed on Linux (GE-Proton11-14 via umu-run) + NVIDIA RTX 5080 (driver 620.73.04, CachyOS 7.3.6-1-cachyos, retail 1.0.2.1, diag build):

  • Merged cleanly with #994 + #177 + #454 + #1267 (plus a local MIN_DYNAMIC = 1 << 18 #747 test).
  • The buffer view not on an element of its host copy warning (offset=10561216 element=12) seen on our earlier #206 run dropped to 0.
  • 0 GPU faults, 0 device removals (0x887A0006), and 0 kernel Xids/OOMs over ~4.5 min of active world rendering (up to frame=1443, median 2,076 draws/frame, before a silent title hang with VICTORY_NO_WATCHDOG=1).

(Detailed A/B metrics posted in #1267 and #747. AI-assisted log summary; own retail copy, no game files or raw logs attached.)

**@⁠BitWuehler** on GitHub · 2026-11-24 20:06 UTC · [original](https://github.com/Marvisak/VIctory/pull/1260#issuecomment-7143053325) Confirmed on **Linux (`GE-Proton11-14` via `umu-run`) + NVIDIA RTX 5080** (`driver 620.73.04`, CachyOS `7.3.6-1-cachyos`, retail `1.0.2.1`, `diag` build): - Merged cleanly with `#994 + #177 + #454 + #1267` (plus a local `MIN_DYNAMIC = 1 << 18` #747 test). - The `buffer view not on an element of its host copy` warning (`offset=10561216 element=12`) seen on our earlier `#206` run dropped to **`0`**. - **0** GPU faults, **0** device removals (`0x887A0006`), and **0** kernel Xids/OOMs over ~4.5 min of active world rendering (up to `frame=1443`, median `2,076` draws/frame, before a silent title hang with `VICTORY_NO_WATCHDOG=1`). *(Detailed A/B metrics posted in #1267 and #747. AI-assisted log summary; own retail copy, no game files or raw logs attached.)*
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:35 UTC · original

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

Follow-up to #986 (one aligned copy per range per list); main keeps one copy per view range held by its slot (shadow::exact).

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.

**@⁠Marvisak** on GitHub · 2026-11-25 00:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/1260#issuecomment-7148678857) Automated triage for the maintainers. Closing because this change is already in `main`, or `main` has since replaced the code it patches. Follow-up to #986 (one aligned copy per range per list); main keeps one copy per view range held by its slot (shadow::exact). 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

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/Marvisak--VIctory!1260
No description provided.