shader: keep pixel kills in whole-quad mode (DARNER_KILL_QUADS) #510

Open
hingeowl wants to merge 1 commit from hingeowl/Darner:pr/kill-quads into Main
Contributor

What it changes

  • The problem on main: per-lane early-out s_cbranch_scc0 jumps to null export drop helper lanes before s_wqm, corrupting quad derivatives along triangle edges (e.g. windshield/glass wireframe edge artifacts).
  • Adapted from Lesloo/longroad (84f08fb891219e697d2ffef9f75f4fb818e2a733, renamed LONGROAD_KILL_QUADS -> DARNER_KILL_QUADS):
    • Adds ir::without_kill_outs to strip per-lane early-out s_cbranch_scc0 to null export when the fallthrough begins s_wqm from the same live mask, keeping helper lanes alive for quad derivatives.
    • Applies emit::pixel_form in emit::translate_plain and apps/darner/src/translate.rs, allows guarded non-final pixel colour exports under kill_quads(), and keys darner-gpu's shader_cache on DARNER_KILL_QUADS.
    • Controlled by DARNER_KILL_QUADS (on unless =0).

How it was tested

  • Tested revision: c67b322 (based on main c8258f9)
  • Commands and results:
    • cargo xtask policy — pass
    • cargo clippy --workspace --all-targets --locked -- -D warnings — pass
    • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings — pass
    • cargo test -p darner-gpu --locked -- shader_cache — pass
    • cargo test -p darner-shader --locked -- a_kill_goes_on_in_whole_quad_mode — pass (unit test added in ir.rs)
  • Changes a default: yes (on unless DARNER_KILL_QUADS=0; note this adds DARNER_KILL_QUADS to shader_cache::KEYED).
  • A/B result: visual correctness fix; ran clean in cam-city60 (RTX 4090 + Ryzen 9 7950X3D, Series X, HW RT) as part of our integration branch.
  • Gates run on that revision: cargo xtask policy, both workspace clippy gates, shader_cache + a_kill_goes_on_in_whole_quad_mode unit tests.
  • Hardware dependence: likely general.
  • Coverage gaps: standalone A/B FPS comparison not recorded.

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: #96 (DARNER_KILL_CONTINUE, separate opt-in glass stipple fix)
  • Replaces or overlaps: none found
## What it changes - The problem on main: per-lane early-out `s_cbranch_scc0` jumps to null export drop helper lanes before `s_wqm`, corrupting quad derivatives along triangle edges (e.g. windshield/glass wireframe edge artifacts). - Adapted from `Lesloo/longroad` (`84f08fb891219e697d2ffef9f75f4fb818e2a733`, renamed `LONGROAD_KILL_QUADS` -> `DARNER_KILL_QUADS`): - Adds `ir::without_kill_outs` to strip per-lane early-out `s_cbranch_scc0` to null export when the fallthrough begins `s_wqm` from the same live mask, keeping helper lanes alive for quad derivatives. - Applies `emit::pixel_form` in `emit::translate_plain` and `apps/darner/src/translate.rs`, allows guarded non-final pixel colour exports under `kill_quads()`, and keys `darner-gpu`'s `shader_cache` on `DARNER_KILL_QUADS`. - Controlled by `DARNER_KILL_QUADS` (on unless `=0`). ## How it was tested - Tested revision: `c67b322` (based on `main` `c8258f9`) - Commands and results: - `cargo xtask policy` — pass - `cargo clippy --workspace --all-targets --locked -- -D warnings` — pass - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` — pass - `cargo test -p darner-gpu --locked -- shader_cache` — pass - `cargo test -p darner-shader --locked -- a_kill_goes_on_in_whole_quad_mode` — pass (unit test added in `ir.rs`) - Changes a default: yes (on unless `DARNER_KILL_QUADS=0`; note this adds `DARNER_KILL_QUADS` to `shader_cache::KEYED`). - A/B result: visual correctness fix; ran clean in `cam-city60` (RTX 4090 + Ryzen 9 7950X3D, Series X, HW RT) as part of our integration branch. - Gates run on that revision: `cargo xtask policy`, both workspace `clippy` gates, `shader_cache` + `a_kill_goes_on_in_whole_quad_mode` unit tests. - Hardware dependence: likely general. - Coverage gaps: standalone A/B FPS comparison not recorded. ## 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: #96 (`DARNER_KILL_CONTINUE`, separate opt-in glass stipple fix) - Replaces or overlaps: none found
Adapted from Lesloo/longroad 84f08fb891219e697d2ffef9f75f4fb818e2a733 (renamed
LONGROAD_KILL_QUADS -> DARNER_KILL_QUADS for Darner):
- Add ir::without_kill_outs to remove per-lane early-out s_cbranch_scc0 to null
  export when the fallthrough begins s_wqm from the same live mask, keeping
  helper lanes alive for quad derivatives along triangle edges (fixes glass /
  windshield wireframe artifacts).
- Apply emit::pixel_form in emit::translate_plain and apps/darner translate,
  allow guarded non-final pixel colour exports under kill_quads(), and key the
  shader cache on DARNER_KILL_QUADS.

Upstream-Repository: https://github.com/Lesloo/longroad
Upstream-Commit: 84f08fb891219e697d2ffef9f75f4fb818e2a733
Integration-Base: bd4e9e9049a19fba66db05b1c13a03493d226dce
Validation: cargo test --locked -p darner-shader -- a_kill_goes_on_in_whole_quad_mode (1 passed)

# Conflicts:
#	crates/darner-shader/src/emit/mod.rs
First-time contributor

A full-archive translation (darner.exe translate --list Game\shaders.rpf, 32-lane host) refuses 13 pixel programs with this PR applied that v2026.12.04.01 emits.

Machine: RTX 5090, driver 621.47, i9-14900K, 64 GB RAM (2 × 32 GB DDR4-3200), Windows 11 26300.9974.

build refusals in shaders.rpf
v2026.12.04.01 (stock) 1 — shadowmask:CS_TraceShadowRays_FullAdaptive #dbdbf36298727135, "a lane mask holding lanes elsewhere read as data" (pre-existing)
main c8258f9 + this PR (c67b322) 14 — that one, plus 13 × "a constant lane mask"

The 13 are all pixel programs:

  • PS_FPWeaponRedDot_* — #78c36346b0aabc8d at 0x31a4
  • PS_Textured_Eight_* — #325aec3834d8f883 at 0x3314
  • PS_MirrorReflectionTextured_Eight_* — #c37630c2eae24043 at 0x31cc

each as shader does not translate; its pipelines' draws are dropped, so those draws are missing — PS_FPWeaponRedDot is the weapon's red dot sight.

DARNER_KILL_QUADS=0 takes it back to 1 refusal (13 → 0); DARNER_WAVE_FOLDED=0 and DARNER_EXACT64=0 change nothing, so the form this PR applies is what refuses them.

Mechanism, as far as I can read it: the per-lane s_cbranch_scc0 that ir::without_kill_outs removes is also what left st.wide non-empty, i.e. what put the lowering on its console-lane route (lower.rs ~1596–1624). Without it the program takes the two-half-wave route, where a mask held as a number has no half wave to read it, and lower.rs:4937 refuses it.

In translate_plain I tried the form without the early-outs first and the program as it is when that refuses (same shape as the existing FIRST_HALF retry): the 13 translate again with DARNER_KILL_QUADS still on, and nothing else in shaders.rpf changes. A run on that build shows shader translated stage="pixel" hash=78c36346b0aabc8d, 0 constant lane mask lines, and the red dot sight drawing again in the game. Happy to send it as a patch on top of c67b322 if that is the shape you want.

Not tested: no other card or host wave size, no other archive. The containers cannot be attached (asset policy) — the counts are reproducible with the command above. Note that darner translate's stage-by-stage report applies pixel_form and calls emit::emit directly, so it will still list these 13 even with the fallback; a run's log is the check.

A full-archive translation (`darner.exe translate --list Game\shaders.rpf`, 32-lane host) refuses 13 pixel programs with this PR applied that v2026.12.04.01 emits. Machine: RTX 5090, driver 621.47, i9-14900K, 64 GB RAM (2 × 32 GB DDR4-3200), Windows 11 26300.9974. | build | refusals in `shaders.rpf` | |---|---| | `v2026.12.04.01` (stock) | 1 — `shadowmask:CS_TraceShadowRays_FullAdaptive` `#dbdbf36298727135`, "a lane mask holding lanes elsewhere read as data" (pre-existing) | | `main` `c8258f9` + this PR (`c67b322`) | 14 — that one, plus **13 × "a constant lane mask"** | The 13 are all pixel programs: - `PS_FPWeaponRedDot_*` — `#78c36346b0aabc8d` at `0x31a4` - `PS_Textured_Eight_*` — `#325aec3834d8f883` at `0x3314` - `PS_MirrorReflectionTextured_Eight_*` — `#c37630c2eae24043` at `0x31cc` each as `shader does not translate; its pipelines' draws are dropped`, so those draws are missing — `PS_FPWeaponRedDot` is the weapon's red dot sight. `DARNER_KILL_QUADS=0` takes it back to 1 refusal (13 → 0); `DARNER_WAVE_FOLDED=0` and `DARNER_EXACT64=0` change nothing, so the form this PR applies is what refuses them. Mechanism, as far as I can read it: the per-lane `s_cbranch_scc0` that `ir::without_kill_outs` removes is also what left `st.wide` non-empty, i.e. what put the lowering on its console-lane route (`lower.rs` ~1596–1624). Without it the program takes the two-half-wave route, where a mask held as a number has no half wave to read it, and `lower.rs:4937` refuses it. In `translate_plain` I tried the form without the early-outs first and the program as it is when that refuses (same shape as the existing `FIRST_HALF` retry): the 13 translate again with `DARNER_KILL_QUADS` still on, and nothing else in `shaders.rpf` changes. A run on that build shows `shader translated stage="pixel" hash=78c36346b0aabc8d`, 0 `constant lane mask` lines, and the red dot sight drawing again in the game. Happy to send it as a patch on top of `c67b322` if that is the shape you want. Not tested: no other card or host wave size, no other archive. The containers cannot be attached (asset policy) — the counts are reproducible with the command above. Note that `darner translate`'s stage-by-stage report applies `pixel_form` and calls `emit::emit` directly, so it will still list these 13 even with the fallback; a run's log is the check.
TrustNo1 changed title from [pr-fix][shaders] shader: keep pixel kills in whole-quad mode (DARNER_KILL_QUADS) to shader: keep pixel kills in whole-quad mode (DARNER_KILL_QUADS) 2026-12-06 03:27:50 +00:00
Owner

Test needed — commit c67b3228; what to check:

  • The problem on main: per-lane early-out s_cbranch_scc0 jumps to null export drop helper lanes before s_wqm, corrupting quad derivatives along triangle edges (e.g. windshield/glass wireframe edge artifacts).
  • Adapted from Lesloo/longroad (84f08fb891219e697d2ffef9f75f4fb818e2a733, renamed LONGROAD_KILL_QUADS -> DARNER_KILL_QUADS):
    • Adds ir::without_kill_outs to strip per-lane early-out s_cbranch_scc0 to null export when the fallthrough begins s_wqm from the same live mask, keeping helper lanes alive for quad derivatives.
    • Applies emit::pixel_form in emit::translate_plain and apps/darner/src/translate.rs, allows guarded non-final pixel colour exports under kill_quads(), and keys darner-gpu's shader_cache on DARNER_KILL_QUADS.
    • Controlled by DARNER_KILL_QUADS (on unless =0).

Evidence to post: card + driver, settings, commit tested, before/after (switch off vs on, two runs each), fps median and p99, and one line saying you looked at the picture.

Reply testing to take this run; it's free again after 24 h with no results.

**Test needed** — commit `c67b3228`; what to check: - The problem on main: per-lane early-out `s_cbranch_scc0` jumps to null export drop helper lanes before `s_wqm`, corrupting quad derivatives along triangle edges (e.g. windshield/glass wireframe edge artifacts). - Adapted from `Lesloo/longroad` (`84f08fb891219e697d2ffef9f75f4fb818e2a733`, renamed `LONGROAD_KILL_QUADS` -> `DARNER_KILL_QUADS`): - Adds `ir::without_kill_outs` to strip per-lane early-out `s_cbranch_scc0` to null export when the fallthrough begins `s_wqm` from the same live mask, keeping helper lanes alive for quad derivatives. - Applies `emit::pixel_form` in `emit::translate_plain` and `apps/darner/src/translate.rs`, allows guarded non-final pixel colour exports under `kill_quads()`, and keys `darner-gpu`'s `shader_cache` on `DARNER_KILL_QUADS`. - Controlled by `DARNER_KILL_QUADS` (on unless `=0`). Evidence to post: card + driver, settings, commit tested, before/after (switch off vs on, two runs each), fps median and p99, and one line saying you looked at the picture. Reply `testing` to take this run; it's free again after 24 h with no results.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'pr/kill-quads:hingeowl-pr/kill-quads'
git switch 'hingeowl-pr/kill-quads'

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.

git switch 'Main'
git merge --no-ff 'hingeowl-pr/kill-quads'
git switch 'hingeowl-pr/kill-quads'
git rebase 'Main'
git switch 'Main'
git merge --ff-only 'hingeowl-pr/kill-quads'
git switch 'hingeowl-pr/kill-quads'
git rebase 'Main'
git switch 'Main'
git merge --no-ff 'hingeowl-pr/kill-quads'
git switch 'Main'
git merge --squash 'hingeowl-pr/kill-quads'
git switch 'Main'
git merge --ff-only 'hingeowl-pr/kill-quads'
git switch 'Main'
git merge 'hingeowl-pr/kill-quads'
git push origin 'Main'
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!510
No description provided.