Skip to content

GPU: what shaders touch on the card's side in one switch, sizes by the card's budget (VICTORY_CARD_SIDE=1, off by default) - #1476

Open
PiloteCode wants to merge 1 commit into
fxceless:mainfrom
PiloteCode:pr/card-side
Open

PiloteCode wants to merge 1 commit into
fxceless:mainfrom
PiloteCode:pr/card-side

Conversation

@PiloteCode

Copy link
Copy Markdown

Based on main (9a9091d1), on its own: it needs none of our other PRs. One commit:

  • crates/victory-gpu/src/shadow/placement.rs (new): the switch, its table of sizes, how it meets the switches that already exist, and three tests;
  • four call sites in shadow.rs: card_limits, card_room_kept, window_card_most, and the room test of window_card_room;
  • one README line.

With the switch unset, nothing changes except one log line. With it, on an RTX 5090, main's frame was about 15 % shorter (see "Measured").

What was wrong

A host copy in the PC's memory is read and written by shaders across the bus: every load, store and atomic. On main two kinds of copies are there:

  • Title buffers under 1 MiB. card_limits' least size is 1 MiB. VICTORY_CARD_BUFFERS_MIN_KB=64 takes every title buffer to the card, but it is off by default.
  • Windows of title memory outside buffers that found no room on the card. Windows go to the card up to 1,280 MB, and only while the card is under 80 % of its budget. The texture queue keeps no room for them, so once textures fill the card, later windows stay in the PC's memory.

In another tree of this layer (PiloteBox, below), on an RTX 5090, the card's time was measured with GPU timestamps by command. The scene was one scene of about 4,850 draws a frame, with the Series X profile and a diagnostics build:

  • Small title buffers and the windows in the PC's memory: the card worked 53.8 ms a frame.
  • Every title buffer's copy and the windows on the card (the windows through the bus, in GPU upload heaps): 26.6 ms a frame.
  • Compute dispatches went from 29.9 to 7.5 ms.
  • Two programs that looked expensive went from 5.6 and 2.1 ms to 0.2 and 0.3 ms. Their loads reach 4 MiB windows: they were waiting for the PC's memory, not computing.

main's own default lies between those two cases: since b1d777a8 it puts up to 1,280 MB of windows on the card. Measured on main itself, the switch still took about 15 % off the frame.

What changes

VICTORY_CARD_SIDE=1 sets every size that no switch of its own sets:

  • Title buffers: a least size of 64 KiB, which takes every title buffer's copy (a copy is 64 KiB at least). The total depends on the card's budget.
  • Windows: the total depends on the card's budget. They go the way main sends them: one buffer in a GPU upload heap, which the CPU writes across the bus, where the device has such heaps; two sides where it has none, or with VICTORY_WINDOW_UPLOAD=0. A window goes to the card up to 97 % of the budget, as a title buffer's copy whose room was kept (80 % on main).
  • The texture queue's room (card_room_kept) counts both totals, less what they hold already. It keeps at most 1.5 GiB for buffers and 2 GiB for windows: what they came to with everything on the 32 GB card (1.3 GB of buffers in 3,714 copies; the windows filled a 2 GB limit).

The totals, by the budget the system gives (video_memory), which is about nine tenths of the card:

card budget buffers windows measured
8 GB up to 9 GiB 768 MB 512 MB no
12 GB up to 13 GiB 1 GB 1 GB no
16 GB up to 20 GiB 1.5 GB 1.5 GB no
24 GB up to 26 GiB 2 GB 2 GB no
32 GB and more more 3 GB 3 GB yes (RTX 5090, here and in the other tree)

On the smaller cards, the copies made first take the room and the later ones stay in the PC's memory, as today. With no budget known, nothing changes.

Each switch of its own still wins: VICTORY_CARD_BUFFERS_MIN_KB, VICTORY_CARD_BUFFERS_MIN_MB, VICTORY_CARD_BUFFERS_MB, VICTORY_CARD_WINDOWS_MB and VICTORY_WINDOW_UPLOAD. With VICTORY_CARD_ROOM_FOR_BUFFERS=0, no room is kept and the windows' line stays at 80 %.

At the first copy, one line says what was chosen:

  • with the switch: what shaders touch is on the card's side (VICTORY_CARD_SIDE=1): the card's budget … MB; title buffers' copies from 64 KiB up to … MB, windows up to … MB through the bus, in GPU upload heaps, …; switches of their own set, which win: none (with two sides where the device has no such heaps);
  • without it: what shaders touch is placed as before, by its own switches (…).

Switch unset: the same sizes and paths as main. card_limits gives main's values (a test checks them), windows still get 1,280 MB (in the upload heap where the device has one), and the line is still budget / 10 * 8. The room kept is the buffers' alone, as before.

Through the bus. The placement keeps main's way for windows. In the other tree, with the same build and scene, the median frame of each run's last minute, the two ways alternated:

  • through the bus: 62.1, 71.8 and 74.0 ms;
  • with two sides: 66.7, 69.6, 83.7 and 74.5 ms.

The later runs of both ways had other programs on the card. With the bus, the thread that prepares submissions worked about 7 ms less a frame. So the bus is the faster way or an equal one, and it spares the PC's memory a second copy of each window, as main's run 273 found.

Why it is off. main's test machine is a 12 GB card at 9.2 to 9.6 GB of a 10.3 GB budget. On that card, main's run 295 (diagnostics/README.md) traced black surfaces to 2 GB of windows on the card: textures waited for room. With 512 MB of windows, the surfaces were textured again. The 12 GB row here (1 GB of buffers and 1 GB of windows, their room kept) has not run, and neither have the 8, 16 and 24 GB rows. Issue #1163 adds a second risk on small cards: with small buffers allowed under a flat cap, small copies fill the cap before the large ones come. On the 32 GB card the buffers came to 1.2 to 1.3 GB of a 3 GB cap, so that case did not arise there. Before this could be on by default for a size of card, a run on that card should read what is listed under "Not tested".

A follow-up could turn it on by default where the budget is over 26 GiB, the one row measured (32 GB cards), once the pictures there have been looked at.

Measured

This branch on main

Build: main 9a9091d1 with #854 (so that the title's 64-lane programs run on a 32-lane card), #1450 (so that a new cache reaches the world) and this branch. Diagnostics build, Series X profile, RTX 5090 (32 GB) and i9-14900KF.

Method:

  • every run with VICTORY_BVH_BUILDER=0 VICTORY_PIPELINE_COMPUTE_WAIT=0;
  • the same scene, save and keys in every run;
  • the process at high priority, no captures;
  • four minutes each, alternated A, B, A2, B2;
  • the median frame of each run's last minute;
  • another program was drawing on the card during all four runs.

The pipeline library had been filled before, by two warm-up runs with the same switches.

run placement the frame
A main's own 183.1 ms (5.5 fps)
B VICTORY_CARD_SIDE=1 154.2 ms (6.5 fps)
A2 main's own 186.2 ms (5.4 fps)
B2 VICTORY_CARD_SIDE=1 158.1 ms (6.3 fps)

That is about 15 % off the frame. No fault and no device loss in the four runs.

From the lines of A and B. The first three come from the frame log's usual frame (184 and 138 ms); the others are each run's last such line:

  • Waiting for the card: 47.7 → 11.9 ms a frame.
  • Copying back what shaders wrote: 96.0 → 66.0 ms.
  • Preparing submissions: 84.3 → 91.3 ms.
  • The card: a list of ours running 81.8 → 58.4 ms a frame (the card meter).
  • Title buffers' copies on the card: 98 (945 MB) → 3,939 (1,213 MB). In A, 3,805 copies (265 MB) were read over the bus; in B, none.
  • Windows on the card: 335 → 877, at their limits of 1,280 and 3,072 MB. Both runs reached their limit; in B, 1,152 windows were still turned down for it.
  • Memory:
    • the card: 14,253 → 16,731 MB in use, of a 31,419 MB budget;
    • textures: no pass went without room in either run;
    • the PC's memory shared with the card: 4,701 → 3,042 MB.

Before this branch ran, in other trees

  • Our tree (PiloteBox), RTX 5090, Series X profile, one scene of about 4,850 draws a frame:
    • the card's work 53.8 → 26.6 ms a frame and the dispatches' 29.9 → 7.5 ms (GPU timestamps by command, diagnostics build);
    • the frame (the median of each run's last minute, the same build and scene): 85.5 ms without the placement; with it, 62.1 to 74.0 ms in three runs with the windows through the bus, and 66.7 to 83.7 ms in four runs with two sides (the later runs of both had other programs on the card).
    • That tree places windows by its own code, which main does not share line for line.
  • TaynanGT's tree, their figures (Series S profile; their "4070" preset against their "4090" one):
    • an RTX 3080 10 GB: 135 → 68 ms a frame;
    • an RTX 5070 Ti, standing still: 16.49 → 21.56 fps.
    • The preset sets VICTORY_CARD_BUFFERS_MIN_KB=64, VICTORY_CARD_BUFFERS_MB=1536 and VICTORY_CARD_WINDOWS_MB=1024, a reservation switch of that tree, and other thread counts, so its figures are not of the placement alone.

Tested

The branch was checked as it is, on 9a9091d1, on the software adapter (no card), with the commands of main's CI:

  • cargo test -p victory-gpu --locked -- --test-threads=1 with VICTORY_D3D12_WARP=1: 245 passed, 0 failed, 7 ignored. The three new tests are among them:
    • the_set_grows_with_the_card: the table;
    • a_switch_of_its_own_wins_over_the_set: main's limits without the set, and each switch over it;
    • the_room_kept_counts_the_windows_with_the_set.
  • cargo test --workspace --locked --exclude victory-gpu -- --test-threads=1 with VICTORY_WARP=1: every package passes except victory-shader, which has 247 passed and 5 failed. They are the same five that fail on main: ds_min_max_f32_order_floats_and_return_the_old_value, legacy_mad_fuses_its_product_and_flushes_its_sources, v_permlane16_and_x16_read_the_lanes_their_selectors_pick, whole_wave_f64_sum_and_cvt_f32_f64 and a_lane_mask_joined_with_a_number_is_read_as_the_number_it_is.
  • cargo clippy --workspace --all-targets --locked -- -D warnings, and the same with --all-features: the only errors are main's own 7 lints in victory-shader's tests (valu_tests.rs, wave64_after_loop.rs). victory-gpu is clean both ways.

The switch itself runs in no test: it is read once per process.

Overlaps with open pull requests

Not tested

Where this also lives

The placement this ports is in PiloteBox (https://github.com/PiloteCode/PiloteBox), a tree kept up to date for NVIDIA cards. There it is on by default on NVIDIA cards and, since its 0.13.1, sends windows through the bus as here; this branch is its port to main's code. Its 0.13.1 runs the Series X profile at about 21 frames a second on an RTX 5090 (46.6 and 48.8 ms a frame in one scene; its changelog says how that was measured).

…es by the card's budget

Every title buffer's copy (a least of 64 KiB) and the windows of title
memory outside buffers go to the card, up to totals chosen by the card's
budget (8 GB: 768/512 MB; 12 GB: 1/1 GB; 16 GB: 1.5/1.5 GB; 24 GB: 2/2 GB;
32 GB and more: 3/3 GB). Windows go main's way: one buffer in a GPU upload
heap where the device has such heaps, two sides where it has none. A window
goes to the card up to 97 hundredths of the budget, and the texture queue
keeps the room of both totals (at most 1.5 GiB of buffers and 2 GiB of
windows).

Every switch of its own still wins: VICTORY_CARD_BUFFERS_MIN_KB, _MIN_MB,
_MB, VICTORY_CARD_WINDOWS_MB, VICTORY_WINDOW_UPLOAD,
VICTORY_CARD_ROOM_FOR_BUFFERS. Off, nothing changes. A line at the first
copy says what was chosen.

On an RTX 5090 with fxceless#854 and fxceless#1450, four alternated runs of four minutes:
183.1 and 186.2 ms a frame without the switch, 154.2 and 158.1 ms with it.
KomanderDG88 added a commit to KomanderDG88/VIniVIdiVIci that referenced this pull request Nov 27, 2026
…dget

fxceless#1476 lets a title buffer's copy and a window go to the card up to 97
hundredths of the budget. On an 8 GB card that leaves about 215 MB for
what no kept room counts (our lists, staging, descriptor heaps), and
past the budget the driver moves allocations to shared memory, slower
than the bus the placement saves. With the switch the line is now 90
hundredths, the texture queue's own (resource::room); without it,
copies keep 97 as before and windows 80. The start line names the line
and the most room the texture queue keeps for both.

Ours, not in fxceless#1476.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
KomanderDG88 added a commit to KomanderDG88/VIniVIdiVIci that referenced this pull request Nov 27, 2026
Brings, each behind its own switch and off unless set: VI-BR-PORT's held
levels (VICTORY_HELD_LEVELS), copies and refreshes (SEND_OWN, UNDER_WORDS,
UNDER_WIDE, WIDE_FILLS, REFRESH_AHEAD), page parts and guards (PAGE_PARTS,
GUARD_REST, OPEN_ONE_VIEW), the heap pass aside (HEAP_PASS_ASIDE); from
fxceless/victory-fork fxceless#1450 (PIPELINE_COMPUTE_WAIT_MS), fxceless#1461
(SAMPLER_ORDER), fxceless#1468 (CARD_READ_COPY), fxceless#1476 (CARD_SIDE), fxceless#1424
(WIDE_READS), fxceless#1427; Belobug's FidelityFX bridge (VICTORY_FIDELITYFX_DIR);
a local window icon (VICTORY_WINDOW_ICON); and fixes to LAZY_REMAP's
copies and clean pages. Nothing derived from XCL.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Aniseto

Aniseto commented Nov 28, 2026

Copy link
Copy Markdown

Ran the card-side budget tests at e408259 on an NVIDIA Blackwell desktop part:

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, Rust 1.98.1 (pinned by rust-toolchain.toml), MSVC 14.44.35207, DXC 1.9.2609.5 (shared env), debug build.

cargo test -p victory-gpu --lib shadow::placement -- --test-threads=1
3 passed; 0 failed; 0 ignored; 0 measured; 249 filtered out      (exit 0)

All three tests pass: the set grows with the card, a switch of its own overrides the set, and the room kept counts the windows in the set. They are helper unit tests; the VICTORY_CARD_SIDE=1 switch is off by default and I did not enable it in a real session. The PR has no comments yet, so this is the first datapoint in the thread and the first from an RTX 5070 Ti.

Not tested: a real frame with VICTORY_CARD_SIDE=1, the 15% frame-time comparison from the description, a paired smoke run, the full workspace suite, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.

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.

2 participants