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) #4762

Open
opened 2026-12-01 06:03:51 +00:00 by github-bot · 6 comments
Owner

@⁠plapha on GitHub · 2026-12-01 05:59 UTC · original

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 63b902f with later PRs ported, release. Same machine, spot and trace as #4752 (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 #4752). 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:

  • 7,460 draws in 2,550 bound stretches, over 649 distinct pipelines. A stretch is 2.9 draws long on average; 1,567 of them are a single draw.
  • 54% of the switches go back to one of the last four pipelines used (A, B, A, B…).

Draw time by how many draws in a row share the pipeline:

draws in a row on one pipeline stretches draws µs per draw ms
1 1,567 1,567 2.99 4.69
2–3 595 1,384 2.23 3.08
4–9 255 1,374 1.72 2.37
10–49 109 2,231 1.41 3.14
50 and more 9 904 0.49 0.44

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

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:

µs per draw
one program for every draw 0.13
2 programs, alternating 0.47–0.71
512 programs, a switch every second draw 1.10
128–512 programs, a switch on every draw 1.66

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

  • A straight fit over the stretches (time = a × draws + b × stretches) gives 0.73 µs a draw and 3.27 µs a switch, which would be 8.3 ms. The fit is poor (R² 0.07; draw times vary widely), and a pipeline bind in the title often comes with other state (targets, root arguments), so this is an upper figure.
  • Same pipeline, alone against in a row: for the 36 pipelines that appear both as single draws and in stretches of four or more, a draw costs 2.35 µs alone and 1.20 µs in a row (426 and 3,222 draws). That is 1.15 µs a switch, close to the standalone test, and about 3 ms over the frame. Per pipeline the ratio is noisy (median 1.5, 44% of them under 1).

What could be done with it

Not tried, for discussion:

  1. Fewer switches. 649 pipelines are bound 2,550 times. Where a pass is opaque and depth-tested, draws on the same pipeline could be replayed together. I am looking next at which passes the alternating pipelines belong to and how many of the switches are inside such passes; I will add that here.
  2. Smaller programs. If the cost follows code size, the size work (#3148 and the folds) pays at draw time too, not only at pipeline creation. A measure of translated size against the console's original per program would show where the growth is.
  3. A counter. Pipeline binds per frame and distinct pipelines per frame in the frame-rate line would let other cards and scenes be compared without a trace.

Limits

  • One frame, one card, one spot (about 7,400 draws). Other vendors and larger cards may differ.
  • The in-title attribution is a correlation; no build with fewer switches was run, so no before/after.
  • The standalone test switches mesh programs only (not pixel programs) and tried two code sizes.
  • This machine's frame rate is bound by the submitting thread (about 46 ms), so a saving here would show as card idle time, not as frames.
  • Old base, not main.

AI-assisted (Claude Code): measurements run on the machine above, write-up reviewed by the account owner.

**@⁠plapha** on GitHub · 2026-12-01 05:59 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4761) **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 63b902f with later PRs ported, release. Same machine, spot and trace as #4752 (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 #4752). 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: - 7,460 draws in 2,550 bound stretches, over **649 distinct pipelines**. A stretch is 2.9 draws long on average; 1,567 of them are a single draw. - 54% of the switches go back to one of the last four pipelines used (A, B, A, B…). Draw time by how many draws in a row share the pipeline: | draws in a row on one pipeline | stretches | draws | µs per draw | ms | |---|---|---|---|---| | 1 | 1,567 | 1,567 | 2.99 | 4.69 | | 2–3 | 595 | 1,384 | 2.23 | 3.08 | | 4–9 | 255 | 1,374 | 1.72 | 2.37 | | 10–49 | 109 | 2,231 | 1.41 | 3.14 | | 50 and more | 9 | 904 | 0.49 | 0.44 | ## 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 #4752). ## 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: | | µs per draw | |---|---| | one program for every draw | 0.13 | | 2 programs, alternating | 0.47–0.71 | | 512 programs, a switch every second draw | 1.10 | | 128–512 programs, a switch on every draw | 1.66 | 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 - A straight fit over the stretches (time = a × draws + b × stretches) gives 0.73 µs a draw and 3.27 µs a switch, which would be 8.3 ms. The fit is poor (R² 0.07; draw times vary widely), and a pipeline bind in the title often comes with other state (targets, root arguments), so this is an upper figure. - Same pipeline, alone against in a row: for the 36 pipelines that appear both as single draws and in stretches of four or more, a draw costs 2.35 µs alone and 1.20 µs in a row (426 and 3,222 draws). That is 1.15 µs a switch, close to the standalone test, and about 3 ms over the frame. Per pipeline the ratio is noisy (median 1.5, 44% of them under 1). ## What could be done with it Not tried, for discussion: 1. Fewer switches. 649 pipelines are bound 2,550 times. Where a pass is opaque and depth-tested, draws on the same pipeline could be replayed together. I am looking next at which passes the alternating pipelines belong to and how many of the switches are inside such passes; I will add that here. 2. Smaller programs. If the cost follows code size, the size work (#3148 and the folds) pays at draw time too, not only at pipeline creation. A measure of translated size against the console's original per program would show where the growth is. 3. A counter. Pipeline binds per frame and distinct pipelines per frame in the frame-rate line would let other cards and scenes be compared without a trace. ## Limits - One frame, one card, one spot (about 7,400 draws). Other vendors and larger cards may differ. - The in-title attribution is a correlation; no build with fewer switches was run, so no before/after. - The standalone test switches mesh programs only (not pixel programs) and tried two code sizes. - This machine's frame rate is bound by the submitting thread (about 46 ms), so a saving here would show as card idle time, not as frames. - Old base, not main. AI-assisted (Claude Code): measurements run on the machine above, write-up reviewed by the account owner.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 06:03:51 +00:00
Author
Owner

@⁠github-actions[bot] on GitHub · 2026-12-01 05:59 UTC · original

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.

  1. The play log, in %LOCALAPPDATA%\victory\logs\: the newest victory-nvidia-play-<date>-<time>-<number>.log (from victory.exe) or victory-nvidia-<date>-<time>.log (from the script launcher). The window shows its path at the start, on the line Log: ....
  2. The crash log: %LOCALAPPDATA%\VIctory\data\7952987A\crashes.log, and, if there is one from that run, the newest victory-<date>-<time>-<number>.crash.log in %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.

**@⁠github-actions[bot]** on GitHub · 2026-12-01 05:59 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4761#issuecomment-7302357133) 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. 1. The play log, in `%LOCALAPPDATA%\victory\logs\`: the newest `victory-nvidia-play-<date>-<time>-<number>.log` (from `victory.exe`) or `victory-nvidia-<date>-<time>.log` (from the script launcher). The window shows its path at the start, on the line `Log: ...`. 2. The crash log: `%LOCALAPPDATA%\VIctory\data\7952987A\crashes.log`, and, if there is one from that run, the newest `victory-<date>-<time>-<number>.crash.log` in `%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.
Author
Owner

@⁠plapha on GitHub · 2026-12-01 06:00 UTC · original

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:

draws may be regrouped within switches now floor avoidable
a command list 2,535 757 1,778
…and not across compute or copies 2,550 899 1,651
…and not across barriers 2,588 1,008 1,580

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:

stretch switches draws ms so a switch costs at most
A 129 256 0.09 0.70 µs
B 372 543 0.37 1.00 µs
C 84 142 0.09 1.13 µs
D 176 176 0.27 1.53 µs

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.

**@⁠plapha** on GitHub · 2026-12-01 06:00 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4761#issuecomment-7302370261) 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: | draws may be regrouped within | switches now | floor | avoidable | |---|---|---|---| | a command list | 2,535 | 757 | 1,778 | | …and not across compute or copies | 2,550 | 899 | 1,651 | | …and not across barriers | 2,588 | 1,008 | 1,580 | 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: | stretch | switches | draws | ms | so a switch costs at most | |---|---|---|---|---| | A | 129 | 256 | 0.09 | 0.70 µs | | B | 372 | 543 | 0.37 | 1.00 µs | | C | 84 | 142 | 0.09 | 1.13 µs | | D | 176 | 176 | 0.27 | 1.53 µs | 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.
Author
Owner

@⁠plapha on GitHub · 2026-12-01 06:18 UTC · original

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:

module hash (Nsight) family (matched by output signature and size against a dump) console program translated NVIDIA instructions
c32dea401eb799a7 MS(NC)_VS_PropFoliage(Skin)Deferred 5,959 instructions 14,254 DXIL instructions, 628 rawBufferLoad, 133 createHandleFromHeap 11,864
9c47842a484be3f4 MS_VS_TransformD / MSNC_VS_TransformSkinD — 13,386 DXIL, 629 rawBufferLoad 11,336
3b9785bcc1b2d12e MS(NC)_VS_PedTransform(Skin)D — 11,359 DXIL, 544 rawBufferLoad 11,592

One 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, 0 of the legacy-multiply guards (1,451 fcmp + 1,423 select of 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 SetMeshOutputCounts change reported in #4752 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).

**@⁠plapha** on GitHub · 2026-12-01 06:18 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4761#issuecomment-7302723421) 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: | module hash (Nsight) | family (matched by output signature and size against a dump) | console program | translated | NVIDIA instructions | |---|---|---|---|---| | `c32dea401eb799a7` | `MS(NC)_VS_PropFoliage(Skin)Deferred` | 5,959 instructions | 14,254 DXIL instructions, 628 `rawBufferLoad`, 133 `createHandleFromHeap` | 11,864 | | `9c47842a484be3f4` | `MS_VS_TransformD` / `MSNC_VS_TransformSkinD` | — | 13,386 DXIL, 629 `rawBufferLoad` | 11,336 | | `3b9785bcc1b2d12e` | `MS(NC)_VS_PedTransform(Skin)D` | — | 11,359 DXIL, 544 `rawBufferLoad` | 11,592 | One 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, 0` of the legacy-multiply guards (1,451 `fcmp` + 1,423 `select` of 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 `SetMeshOutputCounts` change reported in #4752 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).
Author
Owner

@⁠plapha on GitHub · 2026-12-01 06:23 UTC · original

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:

extra float4 attributes the pixel program reads static 128 v static 96 v static 64 v static 48 v
0 790 787 788 793
2 814 796 798 796
4 931 830 802 797
7 1,518 1,134 880 877
10 1,631 1,632 1,012 1,030
14 3,332 1,838 1,378 1,355
  • The dynamic counts do nothing. Static 128/128 with 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 #4752), and would explain why they measure nothing.
  • The static vertex maximum times the attributes does. With 14 attributes, 128 static vertices cost 4.2 times the position-only program, 64 cost 1.7 times.
  • The static primitive maximum does not matter: 128 v / 42 p reads as 128 / 128, 48 v / 128 p as 48 / 48.
  • Only attributes the pixel program reads count. The same mesh program (128 v, 14 attributes) with a pixel program that reads none of them is back at 788: the driver drops them at link. So depth-only pairs are already cheap; the G-buffer pairs pay.

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_prologue takes 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.

**@⁠plapha** on GitHub · 2026-12-01 06:23 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4761#issuecomment-7302817675) 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: | extra float4 attributes the pixel program reads | static 128 v | static 96 v | static 64 v | static 48 v | |---|---|---|---|---| | 0 | 790 | 787 | 788 | 793 | | 2 | 814 | 796 | 798 | 796 | | 4 | 931 | 830 | 802 | 797 | | 7 | 1,518 | 1,134 | 880 | 877 | | 10 | 1,631 | 1,632 | 1,012 | 1,030 | | 14 | 3,332 | 1,838 | 1,378 | 1,355 | - **The dynamic counts do nothing.** Static 128/128 with `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 #4752), and would explain why they measure nothing. - **The static vertex maximum times the attributes does.** With 14 attributes, 128 static vertices cost 4.2 times the position-only program, 64 cost 1.7 times. - **The static primitive maximum does not matter**: 128 v / 42 p reads as 128 / 128, 48 v / 128 p as 48 / 48. - **Only attributes the pixel program reads count.** The same mesh program (128 v, 14 attributes) with a pixel program that reads none of them is back at 788: the driver drops them at link. So depth-only pairs are already cheap; the G-buffer pairs pay. 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_prologue` takes 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.
Author
Owner

@⁠nidea1 on GitHub · 2026-12-01 10:33 UTC · original

@⁠plapha Thanks for the RTX 5060 Nsight GPU Trace on MS(NC)_VS_PropFoliage(Skin)Deferred (c32dea401eb799a7) — seeing the exact 1,451 fcmp + 1,423 select breakdown in the slowest mesh shaders is very helpful.

One calibration note on what #3148 (VICTORY_FLOAT_GUARDS, just updated/rebased at 4d587846 with 4 zero_sign soundness fixes) will and won't remove in shaders like c32dea401eb799a7, since #3148 is strictly bit-exact (preserves 0 * inf = +0, 0 * NaN = +0, and observable -0.0 on both FTZ hardware and non-FTZ WARP):

  • What #3148 removes / narrows: legacy_mul(x, x), constant-factor or finite-proven legacy_mul guards when zero-sign is unobserved (or both inputs are non-negative), one-sided finite guards (narrowed from two comparisons to one), plus redundant max_min and zero-bound med3 guards. Across our earlier RTX 3060 Ti corpus (prior to 4d587846'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).
  • What #3148 intentionally keeps: two-variable legacy_mul(a, b) on unbounded rawBufferLoad/CBV/phi floats (very common in skinning and matrix transforms) remains 2 fcmp oeq + or + select because finiteness is unknown statically; similarly, legacy_mul(loaded_a, k) whose result flows into a vertex output or unknown fadd accumulator keeps 1 fcmp oeq + select for -0.0 * k = +0.0.
  • What is already testable on main for 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-relaxed legacy_mul(loaded, k) / bounded-factor portion, though it still emits a 5-instruction min(|a|, |b|) == 0 guard for two unbounded loads. Fully dropping two-variable buffer-load legacy_mul guards on NVIDIA (assuming finite mesh/skinning inputs) would need a separate opt-in non-exact switch rather than #3148's exact pass.
**@⁠nidea1** on GitHub · 2026-12-01 10:33 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4761#issuecomment-7308369446) @⁠plapha Thanks for the RTX 5060 Nsight GPU Trace on `MS(NC)_VS_PropFoliage(Skin)Deferred` (`c32dea401eb799a7`) — seeing the exact `1,451 fcmp + 1,423 select` breakdown in the slowest mesh shaders is very helpful. One calibration note on what #3148 (`VICTORY_FLOAT_GUARDS`, just updated/rebased at `4d587846` with 4 `zero_sign` soundness fixes) will and won't remove in shaders like `c32dea401eb799a7`, since #3148 is strictly **bit-exact** (preserves `0 * inf = +0`, `0 * NaN = +0`, and observable `-0.0` on both FTZ hardware and non-FTZ WARP): - **What #3148 removes / narrows:** `legacy_mul(x, x)`, constant-factor or finite-proven `legacy_mul` guards when zero-sign is unobserved (or both inputs are non-negative), one-sided finite guards (narrowed from two comparisons to one), plus redundant `max_min` and zero-bound `med3` guards. Across our earlier RTX 3060 Ti corpus (prior to `4d587846`'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). - **What #3148 intentionally keeps:** two-variable `legacy_mul(a, b)` on unbounded `rawBufferLoad`/CBV/phi floats (very common in skinning and matrix transforms) remains `2 fcmp oeq + or + select` because finiteness is unknown statically; similarly, `legacy_mul(loaded_a, k)` whose result flows into a vertex output or unknown `fadd` accumulator keeps `1 fcmp oeq + select` for `-0.0 * k = +0.0`. - **What is already testable on `main` for 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-relaxed `legacy_mul(loaded, k)` / bounded-factor portion, though it still emits a 5-instruction `min(|a|, |b|) == 0` guard for two unbounded loads. Fully dropping two-variable buffer-load `legacy_mul` guards on NVIDIA (assuming finite mesh/skinning inputs) would need a separate opt-in non-exact switch rather than #3148's exact pass.
Author
Owner

@⁠plapha on GitHub · 2026-12-01 14:32 UTC · original

@⁠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 … 0 guards in the foliage mesh program are "what #3148 removes". As you explain, most of them are the two-variable legacy_mul on 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 4d587846 rebase; RTX 5060, same save position, daytime, about 10,000 draws a frame, per-command GPU timing):

VICTORY_FLOAT_GUARDS=1 off
per-command total 31.0 ms 31.1 ms
indirect draws 16.1 ms 16.4 ms
mesh draws 3.9 ms 3.7 ms
compute dispatches 8.3 ms 8.4 ms

The 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=2 pointer; that looks like the right way to see how much the relaxed share is worth.

**@⁠plapha** on GitHub · 2026-12-01 14:32 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4761#issuecomment-7314422247) @⁠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 … 0` guards in the foliage mesh program are "what #3148 removes". As you explain, most of them are the two-variable `legacy_mul` on 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 `4d587846` rebase; RTX 5060, same save position, daytime, about 10,000 draws a frame, per-command GPU timing): | | `VICTORY_FLOAT_GUARDS=1` | off | |---|---|---| | per-command total | 31.0 ms | 31.1 ms | | indirect draws | 16.1 ms | 16.4 ms | | mesh draws | 3.9 ms | 3.7 ms | | compute dispatches | 8.3 ms | 8.4 ms | The 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=2` pointer; that looks like the right way to see how much the relaxed share is worth.
This discussion has been locked. Commenting is limited to contributors.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA#4762
No description provided.