shader: avoid duplicate NaN check when NAN_SCRUB and HDR_CLAMP are both active #439
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
hle
input
INTEL
lighting
linux-proton
memory
MULDER
needs-info
needs-logs
needs-rebase
NVIDIA
performance
post-merge
pr-diagnostics
pr-docs
pre-merge
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
relevance
high
relevance
low
relevance
medium
relevance
very-high
rendering
report
roadmap-proposal
saves
series-s
shaders
startup
status
blocked-by-rework
status
needs-test-report
status
needs-triage
status
ready-for-review
status
stale
status
superseded
status
wip
tools
ui
upstream
wontfix
No milestone
No project
No assignees
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
TrustNo1/Darner!439
Loading…
Reference in a new issue
No description provided.
Delete branch "Paliton/Darner-fork:pr/shader-dedup-scrub-clamp"
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)
What it changes
crates/darner-shader/src/emit/lower.rs). On every pixel shader float colour export,emit_exportcalled{ let f = self.scrub_nan(f); self.clamp_hdr(f) }. In play mode bothDARNER_NAN_SCRUB=1andDARNER_HDR_CLAMP(default on) are enabled, soscrub_nan_valuealready replaced NaN/Inf with0.0via integer bit-test + select, and thenclamp_hdr_valueran a second redundantis_nan_f32bitcast/mask/compare/select on the already-finite value for every RGBA channel.Replaces the chained call with
scrub_and_clamp_colour(f): when bothnan_scrub()andhdr_clamp()are active, it runsscrub_nan_value(f)once followed byFMax/FMinclamping to[-HDR_MAX, HDR_MAX]. When only one or neither switch is active, behaviour is identical to before.How it was tested
Tested revision:
7e24699(based onf3840d7)Commands and results:
cargo xtask policy->asset policy: 555 files okcargo clippy --workspace --all-targets --locked -- -D warnings-> ok (0 warnings)cargo clippy --workspace --all-targets --all-features --locked -- -D warnings-> ok (0 warnings)cargo test -p darner-shader --lib --locked scrub -- --test-threads=1->1 passed; 0 failed(scrub_nan_uses_bitwise_iuge_and_clamp_hdr_replaces_nan_with_zero)cargo test --workspace --locked-> all non-flaky tests pass (1772/1773indarner-gpu; the single failure is the pre-existinggpu_owned::tests::concurrent_faults_on_same_block_serialize_single_readbackflake fixed by #261)Changes a default: yes (eliminates 4 redundant DXIL instructions per pixel colour export channel when both switches are on; bit-exact equivalence).
A/B result: 2 runs each of 240 s automated opening sequence from the same snapshot,
--profile diag --features diagnostics(generic x86-64 build), pureplay-defaults(DARNER_NAN_SCRUB=1and defaultDARNER_HDR_CLAMPon), RTX 5070 12 GB + i7-14700KF, Series X, 1440p -> 4K, DLSS off, FG off, RT off. Both B runs beat both A runs across Window 2 and Window 3:f3840d7)7e24699)card_lists_ms)Gates run on that revision: all three
AGENTS.mdgates +cargo xtask policyon7e24699.Gameplay, when relevant: RTX 5070 12 GB, Series X, 1440p -> 4K, DLSS off, FG off, RT off. Clean visuals with zero NaN/HDR artefacts.
Shader wave sizes tested, when relevant: 32 lanes (RTX 5070).
Hardware dependence: general (translator IR only).
Coverage gaps: tested on NVIDIA RTX 5070 (32-lane) only; untested on AMD/Intel or 64-lane wave size.
Checklist
main.docs/asset-policy.md.Checked for overlap
crates/darner-shader/src/emit/lower.rs, non-overlapping functions)Test report on an RTX 4080, together with #438: no measurable change in card time here.
PC: RTX 4080 16 GB (driver 621.40), i7-13700K, 64 GB, Windows 11 26300. Series X profile, 1440p with DLSS Quality, frame generation off, hardware ray tracing on, Reflex off.
Builds: A = main
47d21cd+ #334, #337, #457, #274, #397, #312, #304, #303. B = A + #438 (9483e65) + #439 (77add49); both change the translations, so B had two warm-up runs first (the process building pipelines at about 22 logical processors) and the table has the third.Method: the opening scene of one save, entered the same way every run (no input after the start screen); medians of per-second values from the host log in three 45-second windows from the moment the world appears.
0.1 to 0.2 ms, within the run-to-run spread (about 0.3 ms); the driver's compiler may already fold the repeated handles and checks. Picture 60 s in matches A; no errors in the log besides Streamline's
presentCommon() was not observedonce at start, which A logs too.Not tested: each PR on its own, more than one run each, other cards.
Merged onto
c8258f9, passedcargo xtask policy,clippy --all-features --all-targets -- -D warnings(0 warnings), and1,819 darner-gpu+219 darnerunit tests, then verified through a full 16-minute release shader preload (DARNER_RDNA_FLOAT=2) and two 30,000+ frame Series X sessions (DLSS Quality + MFG 3x) on RTX 5070 Ti / 64 GB DDR5-6400 with zero color/NaN artifacts, crashes, or shader regressions.[pr-performance][shaders] shader: avoid duplicate NaN check when NAN_SCRUB and HDR_CLAMP are both activeto shader: avoid duplicate NaN check when NAN_SCRUB and HDR_CLAMP are both activeTest needed — commit
77add497; what to check:crates/darner-shader/src/emit/lower.rs). On every pixel shader float colour export,emit_exportcalled{ let f = self.scrub_nan(f); self.clamp_hdr(f) }. In play mode bothDARNER_NAN_SCRUB=1andDARNER_HDR_CLAMP(default on) are enabled, soscrub_nan_valuealready replaced NaN/Inf with0.0via integer bit-test + select, and thenclamp_hdr_valueran a second redundantis_nan_f32bitcast/mask/compare/select on the already-finite value for every RGBA channel.Replaces the chained call with
scrub_and_clamp_colour(f): when bothnan_scrub()andhdr_clamp()are active, it runsscrub_nan_value(f)once followed byFMax/FMinclamping to[-HDR_MAX, HDR_MAX]. When only one or neither switch is active, behaviour is identical to before.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
testingto take this run; it's free again after 24 h with no results.View command line instructions
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.