WIP: [pr-performance][shaders][NVIDIA] DARNER_FLOAT_FAST: plain float forms instead of exact RDNA emulation on non-AMD hosts (opt-in) #295

Closed
groster17800 wants to merge 2 commits from groster17800/Darner:pr/float-fast into Main
First-time contributor

Contributor role (optional)

  • Fluxer ID: —

What it changes

Not yet measured on this revision in the game: the A/B below is pending (two runs on this exact build). This is a draft until it is in.

  • The problem on main: on hosts that are not AMD, the translator keeps RDNA's exact float rules for every op (legacy multiplies where 0 × anything = 0, and the other forms named by the bits below). On an RTX 3060 that emulation is a large share of the card's time (earlier measurement below).

DARNER_FLOAT_FAST=<bits> (off by default): on non-AMD hosts the translator emits the plain float form for the RDNA ops named by the bits instead of the exact emulation. Bit 16 makes v_mul_legacy_f32 / v_mad_legacy_f32 plain products. The value is in the shader cache key (through host_rdna), so changing it rebuilds the pipelines once.

#76's DARNER_LEGACY_FINITE does a related thing on AMD only (it is read only in the AMD form of the legacy multiply); this is the NVIDIA/Intel side.

The idea and the original code are mrp1no's (mrp1no/victory-3060, GPL-3.0, commits 17a5251d and 7db51edb); this is a port to Darner's translator, with mrp1no as co-author of the commit.

How it was tested

  • Tested revision: d53d435 (on main f3840d7)

  • Commands and results: gate 1 cargo clippy --workspace --all-targets --locked -- -D warnings: clean. Gate 2, the same with --all-features: clean. Gate 3 cargo test --workspace --locked: 3,344 passed, 2 failed, 121 ignored; neither failure comes from this change: emit::waterfall_tests::sampled_marks_restore_early_depth_only_when_safe_in_pixel_shaders fails the same way on main f3840d7 (also noted in #164), and watch::tests::ask_once_by_res_splits_reservations_without_refusals failed once in the full parallel run and passes on its own, 3 of 3 on this branch and 3 of 3 on main (also noted in #52 and #164).

  • Changes a default: no

  • A/B result: pending. Plan: this build, RTX 3060, Series X, DLSS Balanced, RT off, no FG, play's defaults otherwise, standing 4 min at one spot; A without the variable, B with DARNER_FLOAT_FAST=23, each after its own preload --used.

    Earlier, not on this revision and not this change alone: on a Darner build of 2026-12-02 (v2026.12.02.01 + this change + one other opt-in switch, AMBIENT_LEAN), Series S + DLSS Quality, Jason's balcony, two runs: both off, then DARNER_FLOAT_FAST=23 and AMBIENT_LEAN=7 together: card meter 55.2 → 45.2 ms (−18 %), frame median 69.6 → 61.0 ms. The A/B above will give this change's own share.

  • Gates run on that revision: all three (results above).

  • Gameplay: RTX 3060 12 GB (driver 621.47), Ryzen 7 5700X, 32 GB RAM, Windows 11, Resizable BAR on; with DARNER_FLOAT_FAST=23 in every run since 2026-12-02 (Series S and Series X, DLSS, RT off).

  • Shader wave sizes tested: 32 lanes (NVIDIA).

  • Hardware dependence: any non-AMD host; untested on Intel.

  • Coverage gaps: a shader relying on the exact legacy rule (0 × inf = 0) may show NaN or black pixels with bit 16; none seen with 23 in several hours of play (water, skin, lights, city). Not tested with ray tracing on.

Checklist

  • I ran this change in the game.
  • This PR contains one change based on main.
  • The diff follows docs/asset-policy.md.
  • I recorded this PR's dependencies below.
    • Depends on: none

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs: #76 (LEGACY_FINITE, AMD side)
  • Replaces or overlaps: none found

🤖 Generated with Claude Code

## Contributor role (optional) - Fluxer ID: — ## What it changes **Not yet measured on this revision in the game: the A/B below is pending (two runs on this exact build). This is a draft until it is in.** - The problem on main: on hosts that are not AMD, the translator keeps RDNA's exact float rules for every op (legacy multiplies where 0 × anything = 0, and the other forms named by the bits below). On an RTX 3060 that emulation is a large share of the card's time (earlier measurement below). `DARNER_FLOAT_FAST=<bits>` (off by default): on non-AMD hosts the translator emits the plain float form for the RDNA ops named by the bits instead of the exact emulation. Bit 16 makes `v_mul_legacy_f32` / `v_mad_legacy_f32` plain products. The value is in the shader cache key (through `host_rdna`), so changing it rebuilds the pipelines once. #76's `DARNER_LEGACY_FINITE` does a related thing on AMD only (it is read only in the AMD form of the legacy multiply); this is the NVIDIA/Intel side. The idea and the original code are mrp1no's (mrp1no/victory-3060, GPL-3.0, commits 17a5251d and 7db51edb); this is a port to Darner's translator, with mrp1no as co-author of the commit. ## How it was tested - Tested revision: d53d435 (on main f3840d7) - Commands and results: gate 1 `cargo clippy --workspace --all-targets --locked -- -D warnings`: clean. Gate 2, the same with `--all-features`: clean. Gate 3 `cargo test --workspace --locked`: 3,344 passed, 2 failed, 121 ignored; neither failure comes from this change: `emit::waterfall_tests::sampled_marks_restore_early_depth_only_when_safe_in_pixel_shaders` fails the same way on main f3840d7 (also noted in #164), and `watch::tests::ask_once_by_res_splits_reservations_without_refusals` failed once in the full parallel run and passes on its own, 3 of 3 on this branch and 3 of 3 on main (also noted in #52 and #164). - Changes a default: no - A/B result: pending. Plan: this build, RTX 3060, Series X, DLSS Balanced, RT off, no FG, play's defaults otherwise, standing 4 min at one spot; A without the variable, B with `DARNER_FLOAT_FAST=23`, each after its own `preload --used`. Earlier, not on this revision and not this change alone: on a Darner build of 2026-12-02 (v2026.12.02.01 + this change + one other opt-in switch, `AMBIENT_LEAN`), Series S + DLSS Quality, Jason's balcony, two runs: both off, then `DARNER_FLOAT_FAST=23` and `AMBIENT_LEAN=7` together: card meter 55.2 → 45.2 ms (−18 %), frame median 69.6 → 61.0 ms. The A/B above will give this change's own share. - Gates run on that revision: all three (results above). - Gameplay: RTX 3060 12 GB (driver 621.47), Ryzen 7 5700X, 32 GB RAM, Windows 11, Resizable BAR on; with `DARNER_FLOAT_FAST=23` in every run since 2026-12-02 (Series S and Series X, DLSS, RT off). - Shader wave sizes tested: 32 lanes (NVIDIA). - Hardware dependence: any non-AMD host; untested on Intel. - Coverage gaps: a shader relying on the exact legacy rule (0 × inf = 0) may show NaN or black pixels with bit 16; none seen with `23` in several hours of play (water, skin, lights, city). Not tested with ray tracing on. ## Checklist - [x] I ran this change in the game. - [x] This PR contains one change based on `main`. - [x] The diff follows `docs/asset-policy.md`. - [x] I recorded this PR's dependencies below. - Depends on: none ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs: #76 (LEGACY_FINITE, AMD side) - Replaces or overlaps: none found 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Ported from mrp1no/victory-3060 (GPL-3.0), commits 17a5251d and 7db51edb, via VIctory-NVIDIA 1f4e6f1b; the shader cache keys it through host_rdna.

Co-authored-by: mrp1no <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor

One compatibility edge in d53d435: the AMD option still defaults to EXACT_ALL, but its accepted mask is now ALL. That lets an explicit DARNER_RDNA_FLOAT=16 select the new plain legacy multiply on AMD. Main masks that bit out; 0x1f similarly used to resolve to 15 and now resolves to 31.

The one-line follow-up restricts the accepted AMD bits to EXACT_ALL. Fresh-process fixtures covered unset, 0, 16, 0x1f and an invalid value. The old AMD results were restored, and DARNER_FLOAT_FAST still accepts the additional bit on the non-AMD parsing path. The focused shader check and asset policy passed.

One compatibility edge in `d53d435`: the AMD option still defaults to `EXACT_ALL`, but its accepted mask is now `ALL`. That lets an explicit `DARNER_RDNA_FLOAT=16` select the new plain legacy multiply on AMD. Main masks that bit out; `0x1f` similarly used to resolve to `15` and now resolves to `31`. The [one-line follow-up](https://git.gtahub.st/andrewpozdnakov7-jpg/Darner/commit/b64e6b020e284d92989b78252aa2321f75479a18) restricts the accepted AMD bits to `EXACT_ALL`. Fresh-process fixtures covered unset, `0`, `16`, `0x1f` and an invalid value. The old AMD results were restored, and `DARNER_FLOAT_FAST` still accepts the additional bit on the non-AMD parsing path. The focused shader check and asset policy passed.
Use the existing AMD mask for both the default and the accepted bits of DARNER_RDNA_FLOAT. The additional plain legacy multiply bit belongs to DARNER_FLOAT_FAST on other hosts.

#295
https://git.gtahub.st/andrewpozdnakov7-jpg
https://github.com/andrewpozdnakov7-jpg
Author
First-time contributor

Thanks, you're right: main masked DARNER_RDNA_FLOAT to 15 and this widened it to 31, so an explicit value on AMD could pick up bit 16. I've taken your commit as it is (b64e6b0, your authorship kept) into the branch: DARNER_RDNA_FLOAT is back to EXACT_ALL for both the default and the accepted bits, and bit 16 stays with DARNER_FLOAT_FAST on other hosts.

I haven't re-run the gates on b64e6b0 yet (no power here for a few hours); I'll add the results to the description when I have them.

Thanks, you're right: main masked `DARNER_RDNA_FLOAT` to 15 and this widened it to 31, so an explicit value on AMD could pick up bit 16. I've taken your commit as it is (b64e6b0, your authorship kept) into the branch: `DARNER_RDNA_FLOAT` is back to `EXACT_ALL` for both the default and the accepted bits, and bit 16 stays with `DARNER_FLOAT_FAST` on other hosts. I haven't re-run the gates on b64e6b0 yet (no power here for a few hours); I'll add the results to the description when I have them.
Contributor

Tried b64e6b0 on top of main f3840d7 with #334, #337, #274, #397, #312 and #304. It conflicts with #304 in host_rdna; I kept #304's host-neutral bits and OR-ed float_fast() on top. RTX 4080 16 GB (driver 621.40), i7-13700K, Series X profile, 1440p DLSS Quality, frame generation off, hardware ray tracing on.

  • DARNER_FLOAT_FAST=23: 34 fps against 33 for the same build without #312, #304 and this (card time in the title's lists 23.5 against 25.9 ms a frame; one run each, same manual route). But indoor scenes and cutscenes came out over-exposed, close to white; outdoors looked right.
  • DARNER_FLOAT_FAST=7: lighting broken in dark scenes (a 36-minute run through the opening, 30 fps median).

So on this card neither value is usable as it is. The card-time gain in the first run also includes #312 and #304, added in the same step.

Tried b64e6b0 on top of main f3840d7 with #334, #337, #274, #397, #312 and #304. It conflicts with #304 in `host_rdna`; I kept #304's host-neutral bits and OR-ed `float_fast()` on top. RTX 4080 16 GB (driver 621.40), i7-13700K, Series X profile, 1440p DLSS Quality, frame generation off, hardware ray tracing on. - `DARNER_FLOAT_FAST=23`: 34 fps against 33 for the same build without #312, #304 and this (card time in the title's lists 23.5 against 25.9 ms a frame; one run each, same manual route). But indoor scenes and cutscenes came out over-exposed, close to white; outdoors looked right. - `DARNER_FLOAT_FAST=7`: lighting broken in dark scenes (a 36-minute run through the opening, 30 fps median). So on this card neither value is usable as it is. The card-time gain in the first run also includes #312 and #304, added in the same step.
Author
First-time contributor

Thanks @MesoPlz for the run. I measured this revision too, and I'm closing this PR.

RTX 3060 12 GB (driver 621.47), Ryzen 7 5700X, Windows 11, Resizable BAR on. Build: this branch as it is (b64e6b0 on main f3840d7), release. Series X, 2560×1440 output, DLSS Balanced (preset K), no frame generation, ray tracing off, play's defaults otherwise, each side after its own preload --used. Jason's balcony, standing. Card time is the card meter's "title's lists" median.

frame median, ms card, ms
A: no variable (same 40 s window early in a 3-min stand) 66.2 61.4
A: the whole 3-min stand 65.3 61.1
B: DARNER_FLOAT_FAST=23 (40 s) 59.6 54.7

So about -6.5 ms of card time a frame (-10 %), from one run each, B's window only 40 s long.

Picture, ray tracing off: inside Jason's house the white speckle and blown-out surfaces of #206 / #207 are there without the variable too (door, bed, curtains), but with =23 they are clearly stronger: the door glows almost white and the bed is washed out. That matches the over-exposure reported above, so it is not only a ray-tracing interaction.

Since #304 now gives every card the safe part (the legacy products' short form, DARNER_RDNA_FLOAT=2), what is left here is exactly the part that changes the picture. I'm closing it rather than rebasing; if someone wants to go after the remaining time, finding which of MAX_MIN, MED3, FRACT or the plain legacy product brightens the interiors would be the place to start.

Thanks @MesoPlz for the run. I measured this revision too, and I'm closing this PR. RTX 3060 12 GB (driver 621.47), Ryzen 7 5700X, Windows 11, Resizable BAR on. Build: this branch as it is (b64e6b0 on main f3840d7), release. Series X, 2560×1440 output, DLSS Balanced (preset K), no frame generation, ray tracing off, play's defaults otherwise, each side after its own `preload --used`. Jason's balcony, standing. Card time is the card meter's "title's lists" median. | | frame median, ms | card, ms | |---|---|---| | A: no variable (same 40 s window early in a 3-min stand) | 66.2 | 61.4 | | A: the whole 3-min stand | 65.3 | 61.1 | | B: `DARNER_FLOAT_FAST=23` (40 s) | 59.6 | 54.7 | So about -6.5 ms of card time a frame (-10 %), from one run each, B's window only 40 s long. Picture, ray tracing off: inside Jason's house the white speckle and blown-out surfaces of #206 / #207 are there without the variable too (door, bed, curtains), but with `=23` they are clearly stronger: the door glows almost white and the bed is washed out. That matches the over-exposure reported above, so it is not only a ray-tracing interaction. Since #304 now gives every card the safe part (the legacy products' short form, `DARNER_RDNA_FLOAT=2`), what is left here is exactly the part that changes the picture. I'm closing it rather than rebasing; if someone wants to go after the remaining time, finding which of MAX_MIN, MED3, FRACT or the plain legacy product brightens the interiors would be the place to start.
groster17800 closed this pull request 2026-12-05 09:41:28 +00:00

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
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
TrustNo1/Darner!295
No description provided.