d3d12: most of the card's busy time is "thin" (few warps resident); the largest share is mesh output space, and wrapped VS meshlets run 2-5x faster as indexed VS draws (RTX 5060) #3180
Labels
No labels
accessibility
area: ci
area: d3d12
area: docs
area: launcher
area: runtime (legacy)
area: shader translator
area: tools
area: viewer
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs in-game run
needs rebase
needs-triage
question
ready-for-agent
submodules
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida#3180
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?
@plapha on GitHub · 2026-12-02 16:56 UTC · original
findings.md already notes that the card waits inside its work. We tried to put numbers on it and found one mechanism behind it. Setup: RTX 5060 8 GB, a foxhound/VIctory-based build (the translator differs from mandy's, but the title's wrapped programs are the same). The frame is a light one: 960×540 internal, ray tracing skipped, so it does less work than the console's 720p frame.
1. Thin and thick time (one captured frame, hardware samples every 4.8 µs)
Sampled command time is 34.06 ms. We split it by resident warps per SM (mesh + vertex + pixel + compute):
With the threshold at 2 or 8 instead of 4, thin time stays at 18–24 ms. The clocks stay up (median 2785 MHz) and the card draws about 50 W of its 145 W. Of the warps that are resident, 10 % issue and 46 % wait on memory.
Thin time by layer: geometry 10.5 ms, copies 4.1 ms (98 % of copy time is thin), chains of short commands 7.2 ms.
This also explains a pattern we kept seeing: removing one kind of work saves less than its share of the per-command cost, because the thin time is spread over all commands rather than owned by any one of them.
2. Geometry: the wrapped vertex programs are held by output space, not by their code
Bench (no game; the same captured meshlets of one foliage program with 9 outputs, 600 and 900 groups, warm caches), µs per meshlet:
Cutting only the outputs gives most of the gain, so the limit is output space, not the shader body.
Nsight on the same bench, VTG warps resident per SM: mesh 1.4, VS 7.0–7.4, position-only mesh 5.5. The output buffer (ISBE) is near full in all three: the mesh warps finish early, and their outputs hold the buffer until rasterization takes them. Low occupancy is the consequence, not the cause.
This would also explain why
LEONIDA_MESH_COUNTSgained nothing (d183/d184): the reservation follows the declared output size × the maxima, not the counts.In game, moving two programs (≈7.4 % of sampled time) to the VS path gave −0.9 ± 0.6 ms of GPU busy (same-run A/B, 95 %). With the real pixel program, the bench predicts 1.4–1.75 ms. A build with ten such programs is waiting for a timing run.
3. What would help
LEONIDA_MESH_COMPUTE=1) on an NVIDIA card. It ends in an ordinary VS draw, so it may show the same gain.Caveats: one card, one frame; bench numbers are per meshlet on warm caches, not frame time; draws that pick their meshlets from a per-draw table (about a third of the share) are not covered yet. We do not claim that thin time equals the translation's cost against native: our frame is lighter than the console's, so that comparison needs a matched workload first.
@Default0009 on GitHub · 2026-12-03 00:06 UTC · original
Card: RTX 2070 Super 8 GB (Turing, no mesh shaders), Windows, 32 GB DDR4. Build: PR #3128 head (
32039d441, main merged in), diag profile with diagnostics,mimalloc.What I timed: the item in section 3 of the issue, LEONIDA_MESH_COMPUTE=1 forced on, against the default (=0). Same save, same standing spot, about 3 minutes in the world per run, run in the order A B B A. The first A was a throwaway warm-up. The switch is read once at device creation, so this is separate runs, not LEONIDA_AB. The settings line and mesh programs run as compute: true ... forced=true confirm which path each run used.
MEASURED (n = 2 runs per side, plus 1 warm-up). Windows of the leonida_gpu::host fps line with at least 200 draws a frame:
Forcing the path on costs about 70–80 ms a frame (about 12 fps down to about 6). The two runs on each side differ by 2–10 ms, so the gap is far larger than the run-to-run spread. With two runs a side it is below the minimum abba takes, so there is no standard error.
Checks: in all B runs the log ends with 0 being made, so the pipelines were done and this is not warm-up. Draws dropped for lack of a host pipeline are the same on both sides (about 300 of about 6,500). Draws a frame are similar (5.9–7.1k on B, 6.4–6.7k on A). The frame's GPU time was 95 ms in the one B run I read it for.
READ IN CODE / ASSUMED: the cost looks like a compute pass plus a separate vertex draw for each of the 6k or more mesh draws, so the per-draw fixed cost swamps any output-space gain. I haven't profiled the compute path, so this is a guess.
What it means for the issue: on a card with no mesh shaders, the global switch is not a speed-up. The gain the issue measured came from moving a few heavy wrapped programs to the vertex path. That needs a per-program choice, not a switch for every program. Caveats: one card, one scene, a debug-info diag build, clocks not locked.
@plapha on GitHub · 2026-12-03 00:26 UTC · original
Thanks for timing it. Two runs a side with a 2–10 ms spread against a 70–80 ms gap is clear.
You're right that #2580 was the wrong stand-in, and suggesting it was my mistake. It runs the whole mesh program as compute on every draw and then draws the result, so each draw pays twice. What we measured works differently:
So I agree with your conclusion: it has to be a per-program choice, not a global switch.
Patches and a write-up: https://gist.github.com/plapha/11dfa9c33d1af9ffbdabc71401770e32. They're against a VIctory-based tree, so they won't apply to mandy as-is; read them as a reference.
A small note: Turing does have mesh shaders (D3D12 tier 1), and your
=0runs were drawing through native mesh pipelines. That doesn't change your result, only the label.A timing run with ten allowlisted programs is next; I'll post the frame numbers here.
@MoonEyes on GitHub · 2026-12-03 16:26 UTC · original
Triage Notes
What we've established so far:
LEONIDA_MESH_COMPUTE=1test on an RTX 2070 is not an equivalent validation: the reporter confirms it runs a compute pass on every draw, unlike the proposed cached index-buffer and per-program allowlist approach.What we still need from you (@plapha):