[pr-performance][shaders] Shaders: four exact translator forms, on by default (MASK_RECIPES, GUARD_FACTS, FIRSTLANE_UNIFORM, FOLD_MOVREL; =0 turns each off) #312
Loading…
Reference in a new issue
No description provided.
Delete branch "cafe/translator-forms"
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)
1577752157942198273(Cafe#9189)What it changes
simplify_guarded_useskeeps depending on the order it visits the code, first-lane reads of values every lane already holds, andCS_WriteRasterClassificationResultscannot be folded because ofv_movrel(1,637 group barriers in it). Together about 1.25 ms of GPU time a frame on an RTX 2080 Ti.Four translator forms, each giving the same results as now by construction, each on by default and turned off with
=0. All four are in the shader cache key; each has a README row.DARNER_MASK_RECIPESDARNER_GUARD_FACTSsimplify_guarded_useskeeps what it knows about each guard as two small sets (known true, known false) joined by intersection: the same fixed point whatever the visiting order, and more guard selects removed.DARNER_FIRSTLANE_UNIFORMv_readfirstlaneof a value every lane holds alike (no loads, no LDS reads) is the lane's own value: noWaveReadLaneFirst.DARNER_FOLD_MOVRELv_movrels/d/sdare folded like other VALU instructions (M0 indexes from the encoded register; the upper copy's is its twin, so each copy stays in its half).CS_WriteRasterClassificationResultsthen folds: 1,637 group barriers -> 4. Checked on the CPU: 64 inputs, the same results.How it was tested
Tested revision:
mainf3840d73d+ these commits (c55f1ace7), release build.Changes a default: yes, for every card (the shaders are rebuilt once).
A/B result (RTX 2080 Ti, house save, the same 30 s from 20 s after the world shows, pipelines warm, the same exe, runs in turn):
=0, as main)About -1.25 ms a frame. In the heavier opening pan: 69.7/69.8 -> 69.6/67.7 ms.
Picture: a recorded frame of the house translated again with each switch on and off: the same picture to the pixel every time (the replay has no ray tracing). In play: checked by eye in a free run on the house save with these defaults (and
DARNER_JOIN_CALLS=1): no visual change seen.Gates run on
c55f1ace7:cargo build --locked --release -p darnerok;cargo clippy --locked --release -p darner-shader -p darner-gpu --all-targets -- -D warningsok (on the same code with the switches off);cargo test --locked --release -p darner-shader --lib -- --skip oracle64with the new defaults: 489 passed, 67 failed, the same 67 as onmainf3840d73don this PC (they need a Shader Model 6.6 device, which Windows 10's own D3D12 lacks, or DXIL validation). Not run this time: thedarner-gputests (they create a D3D12 device), and the whole-workspace gates.Gameplay: RTX 2080 Ti, Windows 10 22H2, Series S profile, 2560x1440 output, DLSS Performance, hardware ray tracing, no frame generation.
Shader wave sizes tested: 32 lanes (NVIDIA). The forms act on 64-wide console shaders run in waves of 32; on 64-lane AMD cards fewer shaders are folded, so less changes there.
Hardware dependence: untested on AMD and Intel.
Coverage gaps: only the house scene; no game run of each switch alone (each was judged alone in the replay).
Checklist
main. (Four translator forms of one kind, each with its own switch; easy to split if you prefer.)docs/asset-policy.md.Checked for overlap
fold.rs,structure.rs,emit/bitcode/opt.rs,lower/analysis.rs. #76 (merged) is the earlier set of translator levers.Independent Windows build, gate, and code-read review of
c55f1ace72ae(full headc55f1ace72ae75fff56e4cc147b5ba2ca8a887a6), based onmainf3840d73d3504c30218debfbc8795b9225447317. Not run in-game.Environment
x86_64-pc-windows-msvc), MSVC 19.44.35230.Measured results
cargo clippy --workspace --all-targets --locked -- -D warnings): PASS.cargo clippy --workspace --all-targets --all-features --locked -- -D warnings): PASS.cargo xtask policy: PASS (asset policy: 556 files ok).cargo test --locked -p darner-gpu --lib shader_cache::tests: PASS (13 passed; 0 failed; 0 ignored).cargo test --locked -p darner-shader --lib structure::tests: PASS (15 passed; 0 failed; 0 ignored).cargo test --locked -p darner-shader --lib emit::bitcode::opt::tests: PASS (32 passed; 0 failed; 1 ignored).cargo test --locked -p darner-shader --lib emit::lower::tests: PASS (30 passed; 0 failed; 1 ignored).cargo test --locked -p darner-shader --lib emit::folded_tests: PASS (20 passed; 0 failed; 0 ignored).cargo test --locked -p darner-shader --lib emit::wave64_tests: PASS (48 passed; 0 failed; 1 ignored).cargo test --workspace --locked) and gameplay/performance A/B were not run in this review.Code-read audit
crates/darner-shader/src/structure.rs:55-89,313-335;crates/darner-shader/src/emit/lower.rs:4740-4780,4830-4895).given_recipekeeps a bounded fallback and has a test-only equality check against node restriction (structure.rs:501-565).=0retaining the old path (crates/darner-shader/src/emit/bitcode/opt.rs:2740-2755). Its joins intersect facts across uses, propagation excludes integer division/remainder and non-speculatable calls, phi facts are filtered by dominance, and rewriting visits consumers before definitions (emit/bitcode/opt/guarded_facts.rs:143-160,246-337,357-462). The new order-sensitive regression and existing trap/read negative controls passed (opt.rs:8040-8073; optimizer test results above).crates/darner-shader/src/emit/lower.rs:1919-1923,10864-10880). The uniform analysis skips guarded instructions and, with its normal defaults, does not infer uniformity from loads or LDS reads (emit/lower/analysis.rs:500-684). All four new translation switches are included in the shader cache key (crates/darner-gpu/src/shader_cache.rs:71-137).v_swaprel_b32remains rejected, and the cache key includesDARNER_FOLD_MOVREL(crates/darner-shader/src/fold.rs:56-68,370-380,1611-1617;shader_cache.rs:134-137). I found no dedicated folded-output regression test forv_movrel; the PR description reports a 64-input CPU check, which I did not independently reproduce. No game/performance A/B was run here.No blocking issue found.
Verdict: PASS.
AI-assisted: yes (GitHub Copilot, Auto mode).
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.