Repository navigation
Conversation
…ff by default); live card buffers in the log Every card copy of a title buffer whose shader writes are declared had a committed buffer of its own for the hashes of its 64 KiB pieces, 48 bytes for most, and a small committed buffer costs the card far more than that (about 36 KiB for 256 bytes on an RTX 3070 Ti, small_buffers_cost_the_card). With the switch, hashes of up to 32 KiB take slots of shared 1 MiB buffers by size class; a slot given back is taken again 10 s later at the earliest. On 63b902f with the launcher as shipped, 5-minute run: card buffers alive asked for 4 KiB or less 4,135 -> 977, fps 22.1 -> 22.3. A line every 30 s counts the card buffers Host::uav_buffer made that are alive, by the size asked for, until their last release (a COM object kept as private data); no other line counts them alive. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017D5NZ3Fd7undwVFyu8fQN1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
Every card copy of a title buffer that shaders are declared to write gets a committed buffer of its own for the hashes of its 64 KiB pieces (
Shadow::card_make_before, made withHost::uav_buffer(card_hash_bytes(size))):(size / 64 KiB + 2) * 16bytes, 48 bytes for most copies. WithVICTORY_CARD_BUFFERS_MIN_KB=64, which both launchers set, there are thousands of them: onmainat 63b902f with the launcher as shipped, about 3,150 were alive near the end of a 5-minute run on my 8 GB card (see the table below).On this card a committed buffer takes far more than it asks for. The ignored test in this branch makes some and reads DXGI's
CurrentUsage: 2,000 buffers of 256 bytes raised it by 73 MB, about 36 KiB each. As a check, 20 buffers of 1 MiB read as about 947 KiB each, so these readings are approximate. If a 48-byte buffer costs what a 256-byte one does, the hashes held about 110 MB of the card.No line of the log shows this. "host copies in the card's memory: ... their bytes from before" counts the 48 bytes (it says 0 MB), and "made so far: ... card buffers" counts what was made since the start, not what is alive.
What changes
VICTORY_PACK_HASHES=1(off by default; unset, every copy keeps a buffer of its own, as now). Hashes of up to 32 KiB lie in slots of shared 1 MiB buffers, one set per size class (256 B, 512 B ... 32 KiB); larger ones keep their own buffer. A slot goes back when its copy goes and is taken again 10 s later at the earliest. A copy that gets a slot has all its pieces hashed into it first, as with a new buffer.Shadow::card_sidesnow gives the hashes' address on the card (Option<u64>) instead of a buffer, and the twoSetComputeRootUnorderedAccessView(2, ...)calls take it as it is. The hashes are only reached through that root view, and the barrier before the compare is a UAV barrier on no resource, so no barrier names a shared buffer (the reasoning ofVICTORY_BUDGET_PACK's slots). The shared buffers stay until the end of the run.Host::uav_buffermade that are alive, by the size asked for (4 KiB or less, over 4 KiB up to 64 KiB, larger), each with the bytes asked for rounded up to a multiple of 64 KiB (so more than the ~36 KiB measured above for the small ones). A buffer is counted until its last release, through a COM object kept as its private data, the waybook.rslearns when its objects go. No switch: it costs a box and oneSetPrivateDataInterfacecall per buffer made.small_buffers_cost_the_card, an ignored test for the cost above (cargo test -p victory-gpu small_buffers_cost_the_card -- --ignored --nocapture).small_buffers_costinhost/place.rsmeasures buffers of 64 KiB; this one measures 256 bytes against 1 MiB.With the switch unset, nothing changes but the new line.
Measured
RTX 3070 Ti 8 GB, i7-13700F, 32 GB RAM, Windows 11, driver 621.40. Series S profile, DLSS Quality, the title's ray tracing off (its 43 ray-tracing pipelines left out with
VICTORY_SKIP_PIPELINES),VICTORY_CARD_ROOM_FOR_TARGETS_MB=1600,VICTORY_TEXTURE_ROOM_PERCENT=85, diagnostics build throughplay-foxhound.ps1 -Build diag. The same save each time, keys sent by a script, 300 s from when the world starts. fps is the median of the frame-rate lines after the first minute and moves about ±1 between runs.On
mainat 63b902f with this branch, the launcher as shipped (memory stack on,VICTORY_INDIRECT_CARD_BUDGETat its default), one run each after a warm-up run; the two runs' switch lists differ only in this switch:VICTORY_PACK_HASHES=1presentCommon()line, which every run hasVICTORY_INDIRECT_CARD_BUDGET=0removes those, and this change does not touch them.Earlier, on my own tree (based on 0cef07e with the fxceless/victory-fork tree of 27 November merged in and changes of my own), the same switch took the count from 3,214 to 1 with
VICTORY_INDIRECT_CARD_BUDGET=0, fps 25.4 and 24.9 (one pair), and every later run that day had it on with no device loss. A review of the change by another AI model (GPT, through Codex) found no lifetime problem: when fences complete normally, a slot cannot be taken again while a submission that wrote it is in flight.Tests
cargo clippy --workspace --all-targets --locked -- -D warnings, plain and with--all-features: no warning from this change. On 63b902f clippy already stops on three warnings of main's own (clippy::let_and_returninvictory-shader/src/emit/mod.rs,clippy::manual_is_multiple_ofinvictory-gpu/src/shadow.rsand, with--all-features, invictory-gpu/src/descriptor.rs), the ones CI: clear the four clippy -D warnings errors on main #705 clears.cargo test --workspace --locked: all pass, no failure (victory-gpu: 453 passed, 37 ignored).small_buffers_cost_the_cardby hand on the RTX 3070 Ti: the 73 MB and 947 KiB above.Not tested
Notes
BudgetSlotgives its slots back throughretire. I kept the 10 s wait because that is what ran; I can switch toretireif you prefer.VICTORY_CARD_BUFFERS_MIN_KB=64still holds.Host::uav_buffer. Whichever lands second moves the onecount_uavcall to where the card buffer is made.Measured with AI assistance (Claude Code); the runs were made on my machine.
🤖 Generated with Claude Code
https://claude.ai/code/session_017D5NZ3Fd7undwVFyu8fQN1