victory-gpu: ray-tracing arenas count against their own most, not the windows' card room #971

Manually merged
github merged 3 commits from github-bot/gh-971 into main 2026-11-29 00:27:38 +00:00 AGit
Owner

@⁠eleboucher on GitHub · 2026-11-28 10:20 UTC · original
eleboucher:up-arena-card-budget → main · +140 −20 · 3 files · 3 commits · merged 2026-11-29 00:24 UTC

by_address in shadow.rs added every ray-tracing arena's length to WINDOW_CARD_BYTES, including arenas that spilled to PC memory, so the arenas used up the windows' card cap (window_card_most) and later windows went to shared memory. Its local USED counter was also never decremented when an arena was dropped or when the card buffer could not be made.

Arenas now count in their own ARENA_CARD_BYTES (held to the same 4 GiB / VICTORY_MEMORY_CARD_MB most as before), a Card remembers whether its arena is on the card or spilled, and drop subtracts from the right counter. The HUD and live-span totals include both counters. Unit test arenas_do_not_use_the_windows_room is added.

Tested on RTX 4070 Ti SUPER 16 GB, Ryzen 7 9800X3D, 16 GB RAM, Windows 11, ray tracing on (VICTORY_RT_NATIVE=1): several runs including 7-minute ones with no regressions. This branch type-checks for x86_64-pc-windows-msvc with and without victory-gpu/diagnostics; the unit test was not run here (Windows-only crate).

**@⁠eleboucher** on GitHub · 2026-11-28 10:20 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/971) `eleboucher:up-arena-card-budget` → `main` · +140 −20 · 3 files · 3 commits · merged 2026-11-29 00:24 UTC `by_address` in shadow.rs added every ray-tracing arena's length to `WINDOW_CARD_BYTES`, including arenas that spilled to PC memory, so the arenas used up the windows' card cap (`window_card_most`) and later windows went to shared memory. Its local `USED` counter was also never decremented when an arena was dropped or when the card buffer could not be made. Arenas now count in their own `ARENA_CARD_BYTES` (held to the same 4 GiB / VICTORY_MEMORY_CARD_MB most as before), a `Card` remembers whether its arena is on the card or spilled, and drop subtracts from the right counter. The HUD and live-span totals include both counters. Unit test `arenas_do_not_use_the_windows_room` is added. Tested on RTX 4070 Ti SUPER 16 GB, Ryzen 7 9800X3D, 16 GB RAM, Windows 11, ray tracing on (VICTORY_RT_NATIVE=1): several runs including 7-minute ones with no regressions. This branch type-checks for x86_64-pc-windows-msvc with and without victory-gpu/diagnostics; the unit test was not run here (Windows-only crate).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 14:30:59 +00:00
Author
Owner

@⁠Bj0rnis on GitHub · 2026-11-28 12:52 UTC · original

Independent Windows / RTX 5070 Ti 16 GB headless verification of bc34ae72 (Windows 11, Ryzen 7 9800X3D, 32 GB RAM, driver 621.24, Rust 1.98.1):

  • Clean merge-tree against main (63b902f).
  • Targeted new unit test (cargo test --locked -p victory-gpu --lib arenas_do_not_use_the_windows_room): 1 passed, 0 failed (0.00 s).
  • Full victory-gpu suite on RTX 5070 Ti (--features diagnostics --lib --locked): 507 passed, 0 failed, 36 ignored (7.07 s).
  • Full victory-gpu suite on WARP (VICTORY_D3D12_WARP=1, --features diagnostics --lib --locked): 506 passed, 1 failed (pipeline::host::tests::depth_bounds_pipeline_loads_and_filters_draws — confirmed pre-existing on main 63b902f, unrelated to shadow.rs).
  • Clippy (cargo clippy --locked -p victory-gpu --lib -- -D warnings): 0 new warnings in this PR's diff (1 pre-existing clippy::manual_is_multiple_of at untouched shadow.rs:1738).
  • cargo xtask policy: 294 files ok.

Not tested: live RT gameplay workload (VICTORY_BVH_BUILDER=1 / VICTORY_RT_NATIVE=1). No game data, logs, or captures attached.

AI-assisted test run and summary.

**@⁠Bj0rnis** on GitHub · 2026-11-28 12:52 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/971#issuecomment-7239528226) Independent Windows / RTX 5070 Ti 16 GB headless verification of `bc34ae72` (Windows 11, Ryzen 7 9800X3D, 32 GB RAM, driver `621.24`, Rust 1.98.1): - **Clean merge-tree** against `main` (`63b902f`). - **Targeted new unit test (`cargo test --locked -p victory-gpu --lib arenas_do_not_use_the_windows_room`):** **1 passed, 0 failed** (`0.00 s`). - **Full `victory-gpu` suite on RTX 5070 Ti (`--features diagnostics --lib --locked`):** **507 passed, 0 failed, 36 ignored** (`7.07 s`). - **Full `victory-gpu` suite on WARP (`VICTORY_D3D12_WARP=1`, `--features diagnostics --lib --locked`):** **506 passed, 1 failed** (`pipeline::host::tests::depth_bounds_pipeline_loads_and_filters_draws` — confirmed pre-existing on `main` `63b902f`, unrelated to `shadow.rs`). - **Clippy (`cargo clippy --locked -p victory-gpu --lib -- -D warnings`):** **0 new warnings** in this PR's diff (1 pre-existing `clippy::manual_is_multiple_of` at untouched `shadow.rs:1738`). - **`cargo xtask policy`:** **294 files ok**. *Not tested:* live RT gameplay workload (`VICTORY_BVH_BUILDER=1` / `VICTORY_RT_NATIVE=1`). No game data, logs, or captures attached. *AI-assisted test run and summary.*
Author
Owner

@⁠CuteBooty on GitHub · 2026-11-28 15:02 UTC · original

I ran this in the game with ray tracing on, on an 8 GB card: RTX 3070 8 GB (driver 621.24, PCIe 3.0), Ryzen 7 5800X3D, 32 GB, Windows 11 26200. Build: main 63b902fe, my local patches, and this PR. VICTORY_BVH_BUILDER=1, VICTORY_MEMORY_CARD_MB=768, Series S, DLSS performance, frame generation 2x. Played for 6.6 minutes, no crash.

Against an earlier ray-tracing session without this PR (same card, 11.3 minutes, no VICTORY_MEMORY_CARD_MB setting; that session also had the water light left out and a keep-awake helper on, and drew 6-7k draws a frame against 4.7-6k here, so not like for like):

Without #971 With #971
Card use against its budget never over (6,691 / 6,874 MB at minute 9) first over at about 2 minutes, over in 49 of 70 lines (7,303 / 6,934 MB at minute 5)
DLSS "out of VRAM, upscaling not recorded" 0 2,916 (from 2 s before usage first exceeded the budget)
"title memory by address: N MB in N arenas" 617 -> 866 MB over 11 min 324 -> 889 MB over 6.6 min
Frame, minutes 1-3 (means) 72-152 ms 93-131 ms
Frame, minutes 4-5 72-73 ms 67-76 ms (minute 5 has 4 lines)

What differed: the earlier session slowed from minute 8. In this one, usage exceeded the reported budget by minute 2, and DLSS started refusing to record upscales. The arenas line passed 768 MB although VICTORY_MEMORY_CARD_MB=768 was set. The log doesn't say how much of the arenas sat on the card and how much spilled to shared memory, so I can't tell whether the refunds let arenas take card room sooner. A line with both counters would settle it.

What the player saw:

  • The water looked really good.
  • Inside a house, the lighting seemed worse than without ray tracing: grainy lights at an aquarium, everything washed out, and not very detailed.
  • The performance hit wasn't worth it to them with this approach.

One run, so I'm not crediting or blaming the PR for the frame times. The memory curve and the DLSS warnings differed most between the runs.

(Measurements and text prepared with my AI assistants, Claude Code and Codex. No game files.)

**@⁠CuteBooty** on GitHub · 2026-11-28 15:02 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/971#issuecomment-7241157618) I ran this in the game with ray tracing on, on an 8 GB card: RTX 3070 8 GB (driver 621.24, PCIe 3.0), Ryzen 7 5800X3D, 32 GB, Windows 11 26200. Build: main 63b902fe, my local patches, and this PR. `VICTORY_BVH_BUILDER=1`, `VICTORY_MEMORY_CARD_MB=768`, Series S, DLSS performance, frame generation 2x. Played for 6.6 minutes, no crash. **Against an earlier ray-tracing session without this PR** (same card, 11.3 minutes, no `VICTORY_MEMORY_CARD_MB` setting; that session also had the water light left out and a keep-awake helper on, and drew 6-7k draws a frame against 4.7-6k here, so not like for like): | | Without #971 | With #971 | |---|---:|---:| | Card use against its budget | never over (6,691 / 6,874 MB at minute 9) | first over at about 2 minutes, over in 49 of 70 lines (7,303 / 6,934 MB at minute 5) | | DLSS "out of VRAM, upscaling not recorded" | 0 | 2,916 (from 2 s before usage first exceeded the budget) | | "title memory by address: N MB in N arenas" | 617 -> 866 MB over 11 min | 324 -> 889 MB over 6.6 min | | Frame, minutes 1-3 (means) | 72-152 ms | 93-131 ms | | Frame, minutes 4-5 | 72-73 ms | 67-76 ms (minute 5 has 4 lines) | **What differed:** the earlier session slowed from minute 8. In this one, usage exceeded the reported budget by minute 2, and DLSS started refusing to record upscales. The arenas line passed 768 MB although `VICTORY_MEMORY_CARD_MB=768` was set. The log doesn't say how much of the arenas sat on the card and how much spilled to shared memory, so I can't tell whether the refunds let arenas take card room sooner. A line with both counters would settle it. **What the player saw:** - The water looked really good. - Inside a house, the lighting seemed worse than without ray tracing: grainy lights at an aquarium, everything washed out, and not very detailed. - The performance hit wasn't worth it to them with this approach. One run, so I'm not crediting or blaming the PR for the frame times. The memory curve and the DLSS warnings differed most between the runs. (Measurements and text prepared with my AI assistants, Claude Code and Codex. No game files.)
Author
Owner

@⁠eleboucher on GitHub · 2026-11-28 16:00 UTC · original

Thanks @⁠Bj0rnis for the checks and @⁠CuteBooty for the 8 GB run. The run found a real problem, and I pushed two commits for it.

Why card use went up with this PR. Before, the arenas counted their bytes against the windows' 1024 MB limit, and that count never went down when an arena was freed. So it acted as a lifetime cap: after enough arenas had come and gone, new ones stopped going to the card. This PR gave the arenas their own count and refunded freed bytes, which removed that accidental cap. But the arenas could then fill the card up to 97% of the budget, which leaves no room for the textures and DLSS. That matches your log: usage over budget from about minute 2, then DLSS refusing to record.

What the new commits change:

  • 43a998a8: arenas and windows go to the card only below the texture queue's line (budget minus the larger of 768 MB and 5%, never under 90%), the same line the texture queue already keeps. Past it, they go to shared memory. The arenas line now says how much is on the card and how much is in shared memory: N MB in N arenas (X MB on the card of at most Y, Z MB in shared memory).
  • 11cb2ddc: windows also keep a fifth of the budget free, as title buffers do.

About VICTORY_MEMORY_CARD_MB=768. The old line counted every arena, including the ones that had spilled to shared memory. So passing 768 MB on that line did not mean the card held more than 768 MB. The new line shows the two parts separately.

Tested here: copies_stop_at_the_texture_line and arenas_do_not_use_the_windows_room pass on an RTX 4070 Ti SUPER 16 GB. I couldn't get a live number on this PC. It has 16 GB of system RAM, and with VICTORY_RT_NATIVE=1 plain main 63b902fe already fails while loading, before the arenas fill: a host command list did not close (0x8007000E). The PR build fails at the same point. That failure is system RAM and is unrelated to this PR.

Not tested on an 8 GB card. @⁠CuteBooty, if you can rerun your session on 11cb2ddc, the new arenas line plus the DLSS out-of-VRAM count would show whether usage now stays under the budget.

**@⁠eleboucher** on GitHub · 2026-11-28 16:00 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/971#issuecomment-7241897182) Thanks @⁠Bj0rnis for the checks and @⁠CuteBooty for the 8 GB run. The run found a real problem, and I pushed two commits for it. **Why card use went up with this PR.** Before, the arenas counted their bytes against the windows' 1024 MB limit, and that count never went down when an arena was freed. So it acted as a lifetime cap: after enough arenas had come and gone, new ones stopped going to the card. This PR gave the arenas their own count and refunded freed bytes, which removed that accidental cap. But the arenas could then fill the card up to 97% of the budget, which leaves no room for the textures and DLSS. That matches your log: usage over budget from about minute 2, then DLSS refusing to record. **What the new commits change:** - `43a998a8`: arenas and windows go to the card only below the texture queue's line (budget minus the larger of 768 MB and 5%, never under 90%), the same line the texture queue already keeps. Past it, they go to shared memory. The arenas line now says how much is on the card and how much is in shared memory: `N MB in N arenas (X MB on the card of at most Y, Z MB in shared memory)`. - `11cb2ddc`: windows also keep a fifth of the budget free, as title buffers do. **About `VICTORY_MEMORY_CARD_MB=768`.** The old line counted every arena, including the ones that had spilled to shared memory. So passing 768 MB on that line did not mean the card held more than 768 MB. The new line shows the two parts separately. **Tested here:** `copies_stop_at_the_texture_line` and `arenas_do_not_use_the_windows_room` pass on an RTX 4070 Ti SUPER 16 GB. I couldn't get a live number on this PC. It has 16 GB of system RAM, and with `VICTORY_RT_NATIVE=1` plain main `63b902fe` already fails while loading, before the arenas fill: `a host command list did not close (0x8007000E)`. The PR build fails at the same point. That failure is system RAM and is unrelated to this PR. **Not tested on an 8 GB card.** @⁠CuteBooty, if you can rerun your session on `11cb2ddc`, the new arenas line plus the DLSS out-of-VRAM count would show whether usage now stays under the budget.
Author
Owner

@⁠tupacfan04 on GitHub · 2026-11-28 23:36 UTC · original

Test data from an RTX 5070 12 GB, in case it helps judge this one.

Setup: RTX 5070 12 GB (driver 621.40), i9-14900F, 32 GB, Windows 11. Series X, 2560x1440, DLSS Quality (model K), frame generation 2x, VICTORY_BVH_BUILDER=1. Unattended 6-minute runs on one walking route, built from source.

What I ran: not this branch as is. I ported only the counter part (by-address copies counted against their own most, not the windows' card room) onto a local branch behind a switch, so I could A/B it inside one build. Treat it as a test of the idea, not of your exact diff.

Run fps at 6–8k draws median frame by-address copies on the card in PC memory
builder on, old counting 10.4 85 ms 657 MB 448–576 MB
builder on, own room 8.0 139 ms 529 MB 960 MB

(An earlier own-room run gave 7.7 fps and the same 529 / 960 MB split, but a compile was running on the PC during it, so I only count its memory figures.)

Reading: on a 12 GB card the arena counter is not what sends these copies off the card; it showed 529–657 of 4096 MB. By reading resource.rs, the deciding test is the card's budget (use + the copy + targets to come under 97 %). With own room on, the windows take up to about 1 GB of the card, and the budget test then refuses more arenas, so more of them land in PC memory and the frame gets slower even though memory::ready itself gets cheaper (12–13 ms per frame against 15–24). The budget-test explanation is from reading the code; I have not confirmed it with a run yet.

So on 12 GB this change alone looks like a loss; on a card with more room it may well be the win you measured. The per-frame timings I quote come from the log line in #1468. Run summaries: https://gist.github.com/tupacfan04/0dbd2a5d33dd78e208d4914306dd175b (the full play logs of these runs have rotated out; I can attach fresh ones on request).

**@⁠tupacfan04** on GitHub · 2026-11-28 23:36 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/971#issuecomment-7247545270) Test data from an RTX 5070 12 GB, in case it helps judge this one. **Setup:** RTX 5070 12 GB (driver 621.40), i9-14900F, 32 GB, Windows 11. Series X, 2560x1440, DLSS Quality (model K), frame generation 2x, `VICTORY_BVH_BUILDER=1`. Unattended 6-minute runs on one walking route, built from source. **What I ran:** not this branch as is. I ported only the counter part (by-address copies counted against their own most, not the windows' card room) onto a local branch behind a switch, so I could A/B it inside one build. Treat it as a test of the idea, not of your exact diff. | Run | fps at 6–8k draws | median frame | by-address copies on the card | in PC memory | |---|---|---|---|---| | builder on, old counting | 10.4 | 85 ms | 657 MB | 448–576 MB | | builder on, own room | 8.0 | 139 ms | 529 MB | 960 MB | (An earlier own-room run gave 7.7 fps and the same 529 / 960 MB split, but a compile was running on the PC during it, so I only count its memory figures.) **Reading:** on a 12 GB card the arena counter is not what sends these copies off the card; it showed 529–657 of 4096 MB. By reading `resource.rs`, the deciding test is the card's budget (use + the copy + targets to come under 97 %). With own room on, the windows take up to about 1 GB of the card, and the budget test then refuses more arenas, so more of them land in PC memory and the frame gets slower even though `memory::ready` itself gets cheaper (12–13 ms per frame against 15–24). The budget-test explanation is from reading the code; I have not confirmed it with a run yet. So on 12 GB this change alone looks like a loss; on a card with more room it may well be the win you measured. The per-frame timings I quote come from the log line in #1468. Run summaries: https://gist.github.com/tupacfan04/0dbd2a5d33dd78e208d4914306dd175b (the full play logs of these runs have rotated out; I can attach fresh ones on request).
github-bot referenced this pull request from a commit 2026-11-29 00:27:22 +00:00
github manually merged commit 941f38380b into main 2026-11-29 00:27:38 +00:00
Author
Owner

@⁠eleboucher on GitHub · 2026-11-29 13:28 UTC · original

@⁠tupacfan04 thanks for the A/B, and sorry for the late answer.

Your reading fits the code as I understand it. Before this change the arenas were charged to the windows' room, which capped how much card memory the windows could take; that cap kept room free that the budget test later gave to arenas. With the double count removed, windows can take up to their own cap, and on a 12 GB card the budget test (use + copy + targets under 97 %) then refuses arenas first. Arenas are read by every ray-walk step, so arenas in PC memory cost more than windows in PC memory: a loss on 12 GB, as you measured.

The exact fix is not to restore the double count but to order the two: when the budget is short, arenas keep their card room ahead of windows (a window spills, or is refused, before an arena does). I'll try that and A/B it here with the card's budget held near a 12 GB card's. I'll post the numbers in this thread, or in a new PR referencing this one.

If you still have the 529 / 960 MB runs' setup, one log of each with the "title memory by address" and "card room" lines around 6 minutes would let me check that the refused arenas are the ones the walks read.

**@⁠eleboucher** on GitHub · 2026-11-29 13:28 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/971#issuecomment-7256564546) @⁠tupacfan04 thanks for the A/B, and sorry for the late answer. Your reading fits the code as I understand it. Before this change the arenas were charged to the windows' room, which capped how much card memory the windows could take; that cap kept room free that the budget test later gave to arenas. With the double count removed, windows can take up to their own cap, and on a 12 GB card the budget test (use + copy + targets under 97 %) then refuses arenas first. Arenas are read by every ray-walk step, so arenas in PC memory cost more than windows in PC memory: a loss on 12 GB, as you measured. The exact fix is not to restore the double count but to order the two: when the budget is short, arenas keep their card room ahead of windows (a window spills, or is refused, before an arena does). I'll try that and A/B it here with the card's budget held near a 12 GB card's. I'll post the numbers in this thread, or in a new PR referencing this one. If you still have the 529 / 960 MB runs' setup, one log of each with the "title memory by address" and "card room" lines around 6 minutes would let me check that the refused arenas are the ones the walks read.
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!971
No description provided.