[pr-performance][shaders] Six translator levers on by default (+9 % fps, -5.0 ms of GPU time a frame, on an RTX 2080 Ti) #76
Loading…
Reference in a new issue
No description provided.
Delete branch "cafe/shader-levers"
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?
Contributor role (optional)
Cafe#9189What it changes
+9 % fps, -5.0 ms of GPU time a frame on an RTX 2080 Ti (same build, the six off against on).
Re-filed from CodeFloe PR 295 (that repo is gone; nothing was migrated). CodeFloe numbers are written without "#" here, since numbers restarted on this host. Brought up to
main1a5286a78by mergingmainin, without conflicts.Six translator changes, each measured on its own, on by default. Four are new, two change existing defaults. Each has a switch to turn it off by itself.
DARNER_LEGACY_FINITE=31(new; before, only values proven bounded)DARNER_HOST_RDNA=1): it is read only in the AMD form of the legacy multiply, so on NVIDIA and Intel with the defaults it changes no shader math (corrected after review). On the RTX 2080 Ti withDARNER_HOST_RDNA=1 DARNER_RDNA_FLOAT=3: -1.5 ms of the 3.9 ms the zero guards cost a frameDARNER_MOVREL_WATERFALL(new, on unless0)v_movrels/v_movreld) run once per lane instead of once per distinct index, each pass a select over the whole register range.DARNER_LICM_CBUF=1(new;0off,2also descriptor handles)DARNER_SHADER_OPT=511(was 447)WIDEpass: up to 4 dwords of a console load in one call.DARNER_SHADER_LOOP_LIMIT_OF(new), default7b2c3c1db2298f44:1024CS_ShadowTileBalanceRTCostwalks an index range whose loop ran toward the 4,096-round compute cap; 1,024 is 4 times what the scene needed. Empty removes it.CS_ShadowRenderTiled,CS_GenerateShadowMasks_HairOnlylightAtlasalready does.LEGACY_FINITE,MOVREL_WATERFALLandLICM_CBUFare added to the shader cache key. The translated shaders change, so every player's pipelines are rebuilt once after this update.How it was tested
7e96ad684(main4a92569fbwith the six merged in);main1a5286a78merged in since as581ee600f, without conflicts and with no translator change between the two.DARNER_LEGACY_FINITE=0 DARNER_MOVREL_WATERFALL=0 DARNER_LICM_CBUF=0 DARNER_SHADER_OPT=447 DARNER_WAVE_FOLDED_SKIP=lightAtlas, and the loop limit pointed at no program.LEGACY_FINITEdid nothing in these runs (NVIDIA card, Darner's defaults): the gain is the other five levers'.WIDEand hair masks together, +1.4 forLICM_CBUF. The replayed frames' pictures were unchanged.cargo test --release --locked -p darner-shader --lib: 490 passed, 68 failed;mainalone: 488 passed and the same 68 failed (the 2 more are this change's tests). The 68 need a Shader Model 6.6 device, which this Windows 10 PC can't give a test program.-p darner-gpu --libstops after 143 tests with exit code 3 here, the same onmainalone.LEGACY_FINITEacts only on AMD cards or withDARNER_HOST_RDNA=1; the others apply everywhere). Risk to watch:LEGACY_FINITEtakes texture and buffer values as finite. If a game texture holds an infinity or NaN, 0 times it now gives NaN where it gave 0: look for black or bright specks.DARNER_LEGACY_FINITE=0brings back the old behaviour.Checklist
main.docs/asset-policy.md.Checked for overlap
4a92569fb7e96ad6840Nice. @TrustNo1 merge it
Would love to get some feedback on this too btw for folks that are GPU bound (or otherwise, just give me gpu time if you can).
I do pretty extensive correctness test even on my own captures, but still only just with my hardware and my driver.
Most of those optis should at least not hurt anybody though, like worst thing that hoisting a constant can do is that the compiler still just decides to read it in the loop anyway. 🤷♂️
Sup Cafe! Just compiled your PR and tested it.
Specs : 3060 ti (8 gig) 11700k I7 and 48 gig of DDR4.
FPS before was around 17-19 (without FG of course) and after running your PR it just jumped up to 21-23. Frame gen time also dropped by 5-6ms.
Very impressive buddy! If you need any more info I'll keep my eyes out. I'm also testing some tweaks and modifications to the code but have come up with NOTHING like this!
AMD numbers, as asked: RX 7900 XTX (24 GB, driver 32.0.32029.2010), Ryzen 7 7800X3D, Windows 11.
Card time in the title's lists: -2.5 ms a frame standing still (19.1 to 16.6 ms, -13 %), -2.3 ms on a walk. No fps change here: this PC is CPU-bound in this scene (the submitting thread 22-28 ms a frame), so the card's saving doesn't show as frame rate.
Setup: PR head
581ee600fbuilt as is (diag profile), the same build both ways. Old defaults set as in your description (DARNER_LEGACY_FINITE=0 DARNER_MOVREL_WATERFALL=0 DARNER_LICM_CBUF=0 DARNER_SHADER_OPT=447 DARNER_WAVE_FOLDED_SKIP=lightAtlas,DARNER_SHADER_LOOP_LIMIT_OFpointed at no program; the "these programs' loops stop sooner" warning was in every on-run's log and in none of the off-runs). Series S profile (1920x1080, no upscaler), hardware ray tracing, no frame generation, frame rate uncapped,DARNER_RELAY=2 DARNER_PORT_CBV=1. A heavy downtown save, pipelines warmed for both arms beforehand, the last 120 s of each run measured, arms alternated. No device losses, no pipelines compiled during the measured part.Standing still (same view every run, 5.5k draws a frame), two pairs (off, on, on, off):
Walking (a scripted 140 s walk; it wanders, so draws differ between runs by up to a third), three pairs (off, on, on, off, off, on):
The card was faster with the six on in all five pairs. Pair 2 of the walk had the smallest gap; its off-run walked a lighter stretch (5.6k against 7.6k draws).
Not covered: I measured the levers together, not one by one. Nobody has checked the picture by eye on this card yet (the specks risk you mention for
LEGACY_FINITE). I'll add a note here if we see any. I didn't check whether the unfolded list does anything on a wave64 AMD host; I'd expect it not to.@TrustNo1
Tested #76 merged onto
bd0de0c(the v2026.12.03.01 release commit) together with #23, #36, #37, #92 and #98. RTX 5090, driver 621.14, hardware RT, DLSS Quality, Series X profile, 1440p.With all six changes at their new defaults, roads showed large dark blotches with blocky, speckled edges, spreading around cars, most visible at sunset (long shadows). With
DARNER_LEGACY_FINITE=0and the other five still on, they were gone during an 8½-minute drive.This matches the risk the PR names: a value that isn't finite reaches a legacy multiply, and the temporal passes spread the resulting NaN. Maybe keep
LEGACY_FINITEoff by default until the source is found. The other five gave no picture problems we noticed.A/B of this PR on an RTX 2070 SUPER (Turing, 8 GB). The six levers on give about +27 % fps here (13.2 to 16.7). Two runs per arm.
Setup. PR head
581ee600f, built as our measuring build (diag profile, diagnostics feature, DLSS SDK), not the release/PGO exe. The same exe in both arms:DARNER_LEGACY_FINITE=0 DARNER_MOVREL_WATERFALL=0 DARNER_LICM_CBUF=0 DARNER_SHADER_OPT=447 DARNER_WAVE_FOLDED_SKIP=lightAtlas, withDARNER_SHADER_LOOP_LIMIT_OFpointed at no program.Xbox Series S profile, DLSS Performance (720p to 1440p), the
darner playset of 68 switches from play.rs at581ee600f, no frame generation. PC: Ryzen 7 5800X, 32 GB, driver 621.40, Windows 11 build 26320, Resizable BAR off, GPU clocks unlocked. The same save each run, 240 s in the world, scored on the last 180 per-second frame lines. One unscored warm run per arm first (each arm did its own full shader preload, since the switches change the cache key). Then A1, B1, B2, A2. The warm runs (the first run after each cache-key change, 77 s to the world) scored 14.99 fps (A) and 15.04 fps (B); we left them out under our settle rule because compiles and caches were still settling, and we can't say why they show no gap.A averages 13.17 fps, B 16.71 fps: +26.9 %, and the median frame is 23.6 ms shorter. Both B runs are above both A runs, and A2 is lower than A1, so the order did not favour B. The save loaded to a frame line in about 60 s with B and 69 to 80 s with A.
Not measured: GPU time per frame (we did not extract it, so this is frame time, not card time), any split between the six levers (all six were switched together), and more than two runs per arm.
Picture: we compared screenshots of A1 and B1 at the same point of the run, and played about four minutes on the PR defaults. To our eyes it looked the same. This is a visual check, not an image diff.
On this NVIDIA card
DARNER_LEGACY_FINITEshould do nothing: in581ee600fit is read only in the RDNA branch oflegacy_mul(crates/darner-shader/src/emit/lower.rslines 4670 and 4676), which needshost_rdna(), and that is on only for an AMD card (orDARNER_HOST_RDNA=1). We read this in the code and did not test it with that switch off alone, so the gain here comes from the other five levers. It also means this run says nothing about the dark road blotches f41 reported.Spec dependence: measured on one PC only (Turing, wave32, 8 GB near its memory budget), with all six levers switched together; untested on other cards.
Logs are not attached because this is a test report. We can attach the four logs, with user and PC names removed, if you want them.
Drafted with AI assistance (Claude Code).
@f41 Thanks, I couldn't reproduce this myself, but it could be related. I've had some funkiness with shadows and reflections myself, but they're unchanged by those changes. Can you try this PR alone (idk if #23 could be part of it too) at the same spot?
I can't quite pin down what the issue is here, there's still some roughness to HW RT and quite a few race conditions that are a pain to track down or provoke, so if you could run a couple more A/B just to be sure,
If you're confident that this setting is the cause, I'll narrow the switch down to constant buffers only (or some other subset where Infinite just doesn't make sense).
Addendum, as Jesper pointed out above (and I checked in the code):
DARNER_LEGACY_FINITEis only read in the AMD form of the legacy multiply (legacy_mulinlower.rs), which is on only for AMD cards or withDARNER_HOST_RDNA=1. On an NVIDIA card with the defaults it changes no shader math; changing it only changes the shader cache key, so every shader is rebuilt fresh. @f41, did you haveDARNER_HOST_RDNA=1set? If not, this switch can't have caused the blotches, and the clean drive after changing it was more likely the fresh rebuild or one of the races I mentioned.On my side (RTX 2080 Ti, hardware RT), the glitches I see (a flashing mirror, grainy shadows) are unchanged with
DARNER_LEGACY_FINITE=0, and unchanged with the AMD forms off entirely. I'll also correct the PR description:LEGACY_FINITEonly counts on AMD cards (or withDARNER_HOST_RDNA=1), so the +9 % on my card comes from the other five levers.You're both right; I checked it in
lower.rs.DARNER_LEGACY_FINITEis read only in the RDNA form oflegacy_mul, andDARNER_HOST_RDNAwas not set on this RTX 5090. So setting it to 0 changed only the shader cache key here, and my attribution was wrong. Sorry for the noise.A/B since then, same settings both ways (Series X profile, 1440p, DLSS Quality, frame generation off, hardware RT), same area:
main57dea7fwith #23, and the combined build with #76. No blotches in either, but these were short runs (under a minute each in the world). I can't reproduce the blotches on demand, so I can't tie them to #76. Both earlier runs had freshly rebuilt shader caches, so a rebuild alone doesn't explain the clean drive either. More likely a different spot, time of day, or one of the HW RT races you mention. If I catch them again, I'll post the log and the spot.Test report on an RTX 5080.
Hardware: RTX 5080 (NVIDIA 621.40), Ryzen 7 9800X3D, 32 GB, Windows 11 build 26300.
Setup: both builds from source (
cargo build --release --locked -p darner), same settings both ways (1440p, DLSS, frame generation 2x, Series X), the same save (Jason's house), one manual ~5 minute drive per build, pipelines warm, F1 closed while driving. I scored only gameplay frame lines from the logs (dropped loading/menu lines: frame time < 10 ms).57dea7f581ee600fThat is +1.1 fps (+4 %) and -1.4 ms a frame (-0.8 ms of card time) here: the same direction as the other reports, a smaller gain than on the Turing cards. The card is still the limit in this scene on this PC.
Not measured: one run per arm, the six levers not split apart, the two drives were not the same route, no image diff. No picture faults noticed in either drive.
Drafted with AI assistance (OpenCode).
On an RTX 4070 Ti SUPER, the warmed reverse-order pair showed 0.26 ms less GPU work per frame on average across its two intervals. The FPS differences were +0.26 and +0.01. The first pair showed a larger difference but also had substantially different draw counts, so I could not establish a repeatable FPS gain on this scene.
These are archived runs from the original CodeFloe PR 295. Base
28ef3ddb, patched8e4b9cd0. Git stable patch IDf97fc5a772fc822ae6c2a9b6ac117aabef728e70matches the six-file diff at581ee600. The Forgejo head has a different base and still needs a fresh run.Windows 11, i5-13600KF, 32 GB RAM, RTX 4070 Ti SUPER 16 GB, driver 617.14. Series X, native 2560×1440, 30 FPS cap, hardware RT off, DLSS off, FG off. Same copied save, same keyed input by a parked car, separate cache per build. Each launch waited for clear shader/pipeline counters for 10 s, warmed up for 45 s, then recorded two 45 s intervals. FPS uses frame count divided by summed frame intervals. GPU work uses summed
card_lists_msper frame. The final two launches had zero shader misses, pipeline builds or waits in their scored intervals, and median sampled GPU load was 99%. Traffic varied.