Shader counters: VICTORY_SHADER_COUNTERS=<hash> counts what named programs do per draw and dispatch (diagnostics builds) #4939
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!4939
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-4938"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@bentsignal on GitHub · 2026-12-01 14:45 UTC · original
bentsignal:diag-shader-counters→main· +1422 −5 · 12 files · 1 commits · openWhat it changes
The card meter and the timing runs say how long a program takes, not what it does in that time: whether its loops run away, how many lanes stop at a loop's limit, how much title memory it reads by address and whether those pages had a copy. This adds counters to the programs one names, and leaves every other program as it is.
VICTORY_SHADER_COUNTERS=<hash>[,<hash>...](the 16-digit hashes the logs name programs by; diagnostics builds only). Those programs alone are translated with counters (victory_shader::emit::tally, a raw root UAV at u249, a register no other root view of ours takes, so nothing is shared withSLOT_SAMPLEDat u251 or the others at 250-255). The shader cache keys the counted translations apart; every other program's translation is byte for byte as before (a test checks the same program translates to the same bytes without the switch).crates/victory-gpu/src/host/counters.rs): each draw, dispatch, mesh dispatch and indirect execution of a named program gets a block of 18 KiB of the list's own, cleared before the command and copied back after it in the same list (three barriers), and read when the list is reset after its last submission has run, as the timing stamps are: nothing waits for the card. EveryVICTORY_SHADER_COUNTERS_EVERYs (10;0= every frame) one line per program, targetvictory_gpu::host::counters: a frame's average and the window's heaviest command.draw.rsandHostList::resetare compiled only withdiagnosticsand are one cached load each. The counted programs themselves run slower (a wave operation and an atomic at each loop header, node test and access by address).How it was tested
e29c1c1d, on5fabb46e), the open-world save standing at the player's house, started withscripts\bench.ps1; numbers from the run's log (every frame from the frame log, 30-150 s after the first frame line with 3,000+ draws).VICTORY_SHADER_COUNTERS=f22a76fcb967ee59,6d7fe7745ab9c6d8(two of the title's ray-tracing compute programs), one line per program every 10 s. A real excerpt (the heaviest command's part of the second line cut):(In this build neither program runs long loops or reads pages without a copy. On our fork in November the first one's far-trace loop ran 330-360 iterations a lane, many of them over nodes read as zeros: that is what the counters were made to find.) In that run (another view of the house: 8,900 draws a frame against 6,400 in the runs below, so not comparable) the frames came at 25.0 fps.
main(5fabb46e), 1stmain, 6th (last)About 3,300-3,400 frames each (120 s). The two
mainruns, first and last of the six, differ by as much as any branch does from them: no cost is seen.cargo test -p victory-shader --lib -- tally: 2 passed (new: the counters are only in a counted translation and the plain one is unchanged; a loop of known counts per lane, one lane cut at the limit, run on WARP and every counter checked, validated bydxil.dllwhen present).cargo test -p victory-gpu --lib --features diagnostics -- counters:: shader_cache::: 14 passed (2 new: the switch's parsing, a block read as the shader wrote it).cargo clippy -p victory-shader -p victory-gpu --all-targets -- -D warnings, with and without--features victory-gpu/diagnostics: nothing in the files this touches. The 5 errors left are onmainalready (host/font.rs213 and 260,host/menu.rs667,host/panel.rs602 and 668).cargo build --locked --release -p victoryand--profile diag --features diagnostics: both build.VICTORY_HOST_WAVE=32); the WARP test is a wave32 program. Not tested with 64-lane host waves, nor on AMD.Checked for overlap
VICTORY_SHADER_LOOP_LIMIT(main) changes the limit; this counts what reaches it.This change and its testing were done with an AI assistant (Claude Code), and the results were checked on my machine.
🤖 Generated with Claude Code
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.