Skip to content

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

Merged
trustno1-coder merged 3 commits into
trustno1-coder:mainfrom
eleboucher:up-arena-card-budget
Nov 29, 2026
Merged

trustno1-coder merged 3 commits into
trustno1-coder:mainfrom
eleboucher:up-arena-card-budget

Conversation

@eleboucher

Copy link
Copy Markdown
Contributor

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).

MystifiedSky added a commit to MystifiedSky/VIctory-NVIDIA-Improved that referenced this pull request Nov 28, 2026
…#971)

Adapt upstream bc34ae7 with checked atomic reservations that preserve the accounting on failure.
@Bj0rnis

Bj0rnis commented Nov 28, 2026

Copy link
Copy Markdown

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.

@CuteBooty

Copy link
Copy Markdown
Contributor

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 63b902f, 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.)

@eleboucher

Copy link
Copy Markdown
Contributor Author

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.

@tupacfan04

Copy link
Copy Markdown

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).

@trustno1-coder
trustno1-coder merged commit 941f383 into trustno1-coder:main Nov 29, 2026
trustno1-coder added a commit that referenced this pull request Nov 29, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5CFykxe6G44cMPrmExrcw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants