Findings: 649 pipelines are bound 2,550 times a frame, and switching between large translated programs costs the card about 1-3 us each (3-8 of 13.7 ms of draws; RTX 5060, Nsight trace + standalone test) #4761
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by plapha on 2026-12-01T05:59:20Z.
Setup. RTX 5060 8 GB (621.01), i5-14600KF, 32 GB, Windows 11. Series S profile, 540p internal, DLSS performance, frame generation off, ray tracing off. Build: a local branch of
63b902fwith later PRs ported, release. Same machine, spot and trace as #4751 (play logs are in a comment there). Nothing crashed; this is a measurement report.Searched first. Open and closed issues and PRs for pipeline switch / rebind cost, sorting or reordering draws by pipeline, redundant
SetPipelineState, shader code size. Found #2852 (fixes the attribution of rebinds in the per-pipeline card meter, no measurement of what a rebind costs) and the code-size work in #3148, #2703 and #2357 (measured as DXIL size and PSO build time, not as draw time). Nothing on what a switch costs the card or on how many a frame has.What the frame looks like
One frame in Nsight GPU Trace (53.9 ms, the one in #4751). The draws take 13.7 ms of it, and during them the card is nearly empty: 4.4 of 48 warps per SM, SM throughput 11%, every raster unit under 3%, video-memory L2 at 7%. So the draw time is not shading, raster or memory bandwidth. Per frame the mesh stage launches only 46 k warps (pixel 600 k, compute 3.24 M).
The timeline has every pipeline bind with its time. Over the draws:
Draw time by how many draws in a row share the pipeline:
What the counters say during the draws
Averaging the trace's hardware counters over the draw actions against the compute actions: during draws the instruction-cache traffic is 1.07 GB with 225 MB of misses (48 MB of misses during compute, which runs far more warps). A mesh warp lives about 12 µs, and about 10 meshlets are in flight on the whole card at a time. Register file use is 13% and ISBE is at 20 of 86 KB per SM, so the outputs are not what limits them (and declaring real mesh output counts changed nothing, as reported in #4751).
A standalone test reproduces a per-switch cost
A small D3D12 program (not the title): N mesh programs that differ from one another, generated to about 3,000 lines of HLSL each, one small draw each, same root signature and targets, GPU time per draw:
With programs of about 1,500 lines the figures are about half. So on this card a switch between large programs costs on the order of 1–1.5 µs by itself, and the cost follows the size of the code. An earlier version of the test with two tiny programs showed 0.26 µs and I had wrongly ruled switching out from it. The title's translated programs are large: the mesh programs here are 7,600–15,000 lines of disassembled DXIL, pixel programs up to about 10,000.
How much of the 13.7 ms this is: 3 to 8 ms, not settled
What could be done with it
Not tried, for discussion:
Limits
AI-assisted (Claude Code): measurements run on the machine above, write-up reviewed by the account owner.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by github-actions[bot] on 2026-12-01T05:59:36Z.
Please attach both logs from the run that went wrong. Without them we can only guess. Paste
%LOCALAPPDATA%into the address bar of File Explorer to get there.%LOCALAPPDATA%\victory\logs\: the newestvictory-nvidia-play-<date>-<time>-<number>.log(fromvictory.exe) orvictory-nvidia-<date>-<time>.log(from the script launcher). The window shows its path at the start, on the lineLog: ....%LOCALAPPDATA%\VIctory\data\7952987A\crashes.log, and, if there is one from that run, the newestvictory-<date>-<time>-<number>.crash.login%LOCALAPPDATA%\VIctory\data\7952987A\temp\.Also say which GPU you have and which Windows version (10 or 11).
If this issue needs logs and none are posted here within 12 hours, it will be closed. Add them by editing your post or in a comment.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by plapha on 2026-12-01T06:00:20Z.
Follow-up from the same trace: where the switches are, and a tighter bound. It lowers my estimate.
How far grouping could go. Cutting the frame into stretches of draws that have no compute, copy, barrier or command-list boundary inside them (220 stretches), and counting each pipeline once per stretch:
80% of the avoidable switches are in 13 of the 220 stretches. (Whether the draws inside a stretch may be reordered at all — blending, depth writes — is not checked.)
A switch is not a constant 3 µs here. Several stretches that switch on almost every draw are cheap as a whole:
700 of the frame's switches are in stretches where the whole time divided by the switches is under 1.5 µs. That agrees with the standalone test (1–1.7 µs between large programs) and with the same-pipeline comparison (1.15 µs), not with the 3.27 µs of the straight fit.
Bound on what grouping would save. Taking, per stretch, the smaller of (avoidable switches × cost) and the stretch's whole time: 1.8 ms at 1.15 µs a switch, 3.8 ms at 3.27 µs. So the realistic figure is about 2 ms of the 13.7, at most about 4, not the 8 the title's upper end suggests.
Where the draw time is instead. Two command lists hold 5.5 of the 13.7 ms with few pipelines: one has 904 draws on 11 pipelines in 2.8 ms, the other 982 draws on 59 pipelines in 2.8 ms, at 2.3–7 µs a draw even in long runs on one pipeline. Those draws are slow for a reason of their own that switching does not explain; I have not identified the passes yet.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by plapha on 2026-12-01T06:18:28Z.
Second follow-up, same trace: what the slow draws are. This moves the weight away from switching.
The draw time is in few draws. Of the 2,588 draw actions on the timeline, the slowest 100 hold 8.1 of the 13.7 ms (59%), the slowest 300 hold 83%.
The slow mesh draws run very large mesh programs. Shader-profiler samples over the two command lists that hold 5.5 ms:
c32dea401eb799a7MS(NC)_VS_PropFoliage(Skin)DeferredrawBufferLoad, 133createHandleFromHeap9c47842a484be3f4MS_VS_TransformD/MSNC_VS_TransformSkinDrawBufferLoad3b9785bcc1b2d12eMS(NC)_VS_PedTransform(Skin)DrawBufferLoadOne list (2.8 ms, almost no pixel work: 2.7 k pixel warps) has 69% of its samples in the first two. Its slowest action is 10 draws in 436 µs for 434 mesh warps (about 108 meshlets of 128 threads).
Where a mesh warp's time goes (stall reasons of the samples in these programs): Long Scoreboard (waiting for a memory read) 44–47%, Wait 20%, Selected (issuing) 16–19%, No Instructions 5–13%, Short Scoreboard 6%. The hottest lines are spread flat over the whole program (no line above 1.3%), many of them the
fcmp oeq float x, 0of the legacy-multiply guards (1,451fcmp+ 1,423selectof 14,254 instructions in the foliage program), which is what #3148 removes.Few warps are alive, and each lives long. During that list 1.5 mesh warps are alive per SM (of 48). The trace's VTG warp latency reads 164 k cycles for the foliage draws. So the cost is latency per meshlet, not volume.
The mesh output space (ISBE) is at its limit part of the time. In the foliage draws "ISBE Allocated" sits flat at 46,080 bytes per SM with about 3 KB unallocated and 3 VTG warps alive per SM, for stretches of 100 µs: nothing more fits. Over the frame that holds for 0.48 ms of that list and 0.27 ms elsewhere (0.75 ms in all), so it is a ceiling on how far these draws could overlap rather than the main cost today. Every mesh program declares 128 vertices and 128 primitives as its static maximum; the dynamic
SetMeshOutputCountschange reported in #4751 would not shrink a reservation made from the static maximum, which may be why it measured nothing.Ruled out: the shaders reading system memory during draws (PCIe RX with the copy engine idle is 194 MB/s during draws and 156 MB/s while the card is idle).
Not known yet: whether consecutive draws on these programs overlap or run one after another, and how many of the 628 loads depend on one another (which sets the latency floor).
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by plapha on 2026-12-01T06:23:29Z.
Third follow-up: a standalone test of what the mesh output reservation follows. It separates the static maxima a mesh program declares from the dynamic counts it passes to
SetMeshOutputCounts.Test (not the title): one mesh program, 128 threads, 48 real vertices and 16 real triangles per meshlet, each vertex-holding lane walking a 64-step dependent read chain in a 256 MB buffer, 8,192 meshlets in draws of 16, RTX 5060. Time per meshlet, ns:
SetMeshOutputCounts(48, 42)reads 1,641 against 1,653 for(128, 128)(10 attributes). That is what real-count changes do (dkdknight/Victory-Knight-HD#28, Marvisak/VIctory#586, and the port I measured in #4751), and would explain why they measure nothing.In the trace this fits the two cases looked at: the foliage program (11 vertex elements) holds the ISBE at 46,080 bytes per SM with 3 warps alive, the ped program (more elements) at 22,528 with about 1.
mesh_prologuetakes the maxima from the console container and only lowers them to the lane count when the outputs pass 32 KiB, so every program I looked at declares 128 / 128. What I do not know is how many vertices the title's meshlets really hold: if most are well under 128, a lower static maximum would be worth trying; if they fill 128, the only handle is the number of vertex elements.Limits: a test program, one card. Not tried in the title; my earlier test-program result on mesh counts did not carry over to the title, so this one needs the same check before it counts.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by nidea1 on 2026-12-01T10:33:34Z.
@plapha Thanks for the RTX 5060 Nsight GPU Trace on
MS(NC)_VS_PropFoliage(Skin)Deferred(c32dea401eb799a7) — seeing the exact1,451 fcmp + 1,423 selectbreakdown in the slowest mesh shaders is very helpful.One calibration note on what #3148 (
VICTORY_FLOAT_GUARDS, just updated/rebased at4d587846with 4zero_signsoundness fixes) will and won't remove in shaders likec32dea401eb799a7, since #3148 is strictly bit-exact (preserves0 * inf = +0,0 * NaN = +0, and observable-0.0on both FTZ hardware and non-FTZ WARP):legacy_mul(x, x), constant-factor or finite-provenlegacy_mulguards when zero-sign is unobserved (or both inputs are non-negative), one-sided finite guards (narrowed from two comparisons to one), plus redundantmax_minand zero-boundmed3guards. Across our earlier RTX 3060 Ti corpus (prior to4d587846's soundness tightening), that cut selects by-13.6%/ DXIL insts by-4.39%over 1,000 shaders (-14.0%selects /-7.54%DXIL insts on 20 GPU-hot shaders).legacy_mul(a, b)on unboundedrawBufferLoad/CBV/phi floats (very common in skinning and matrix transforms) remains2 fcmp oeq + or + selectbecause finiteness is unknown statically; similarly,legacy_mul(loaded_a, k)whose result flows into a vertex output or unknownfaddaccumulator keeps1 fcmp oeq + selectfor-0.0 * k = +0.0.mainfor profiling the remaining share:VICTORY_HOST_RDNA=1 VICTORY_RDNA_FLOAT=2(host.rs:1778-1782,lower.rs:4540-4561) works on NVIDIA today and measures the zero-sign-relaxedlegacy_mul(loaded, k)/ bounded-factor portion, though it still emits a 5-instructionmin(|a|, |b|) == 0guard for two unbounded loads. Fully dropping two-variable buffer-loadlegacy_mulguards on NVIDIA (assuming finite mesh/skinning inputs) would need a separate opt-in non-exact switch rather than #3148's exact pass.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by plapha on 2026-12-01T14:32:15Z.
@nidea1 Thank you for the careful explanation, and for picking up the profile.
A correction on my side: in the follow-up above I wrote that the
fcmp oeq … 0guards in the foliage mesh program are "what #3148 removes". As you explain, most of them are the two-variablelegacy_mulon buffer loads that #3148 keeps by design, so that sentence overstated it. Sorry for the confusion it may have caused in the cross-reference.For completeness, an in-game measurement of the version I had at the time (picked onto our base before your
4d587846rebase; RTX 5060, same save position, daytime, about 10,000 draws a frame, per-command GPU timing):VICTORY_FLOAT_GUARDS=1The differences are within the run-to-run scatter (about 1.5 ms here), and the foliage program's output did change, so the switch was active. This is consistent with your point that the remaining guards are the ones #3148 leaves alone; it says nothing about the newer revision.
Thanks also for the
VICTORY_HOST_RDNA=1 VICTORY_RDNA_FLOAT=2pointer; that looks like the right way to see how much the relaxed share is worth.