shader: cache immediate sampler handles in the entry block #438
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!438
Loading…
Reference in a new issue
No description provided.
Delete branch "Paliton/Darner-fork:pr/shader-sampler-cache"
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/shader.rs). Unlikeroot_cbv,root_srv, androot_uav— which emit theircreateHandleFromBinding+annotateHandleonce inself.entryand cache the handle —Shader::sampler_handleemitted a freshcreateHandleFromBinding+annotateHandlepair in the caller's block on every texture sample call.Caches immediate sampler handles keyed by
(slot, is_cmp)inShader::sampler_handlesand emits them once inself.entry, matchingroot_cbv/root_srv/root_uav. Purely exact (no semantic or visual change); adds a unit testsampler_handle_is_cached_in_entry_block.How it was tested
Tested revision:
1efcf68(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 sampler_handle -- --test-threads=1->1 passed; 0 failedcargo test --workspace --locked-> all non-flaky tests pass (1772/1773indarner-gpu; the single failure is the pre-existingwatch::tests::ask_once_by_res_splits_reservations_without_refusalsflake fixed by #262)Changes a default: yes (emitted DXIL reuses cached entry-block sampler handles; exact equivalence, no behaviour change).
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, RTX 5070 12 GB + i7-14700KF, Series X, 1440p -> 4K, DLSS off, FG off, RT off. Both B runs beat both A runs in Window 2 and Window 3 (steady-state GPU-bound):f3840d7)1efcf68)card_lists_ms)Gates run on that revision: all three
AGENTS.mdgates +cargo xtask policyon1efcf68.Gameplay, when relevant: RTX 5070 12 GB, Series X, 1440p -> 4K, DLSS off, FG off, RT off. Visuals verified clean across captured frames.
Shader wave sizes tested, when relevant: 32 lanes (RTX 5070).
Hardware dependence: general (translator IR only); driver impact depends on how aggressively the GPU compiler already hoists
createHandleFromBinding.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/shader.rs, non-overlapping lines)Test report on an RTX 4080, together with #439: 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 on RTX 5070 Ti (16 GB) / Core Ultra 7 265KF / 64 GB DDR5-6400 with zero sampler-binding issues, crashes, or shader regressions.[pr-performance][shaders] shader: cache immediate sampler handles in the entry blockto shader: cache immediate sampler handles in the entry blockTest needed — commit
9483e652; what to check:crates/darner-shader/src/emit/shader.rs). Unlikeroot_cbv,root_srv, androot_uav— which emit theircreateHandleFromBinding+annotateHandleonce inself.entryand cache the handle —Shader::sampler_handleemitted a freshcreateHandleFromBinding+annotateHandlepair in the caller's block on every texture sample call.Caches immediate sampler handles keyed by
(slot, is_cmp)inShader::sampler_handlesand emits them once inself.entry, matchingroot_cbv/root_srv/root_uav. Purely exact (no semantic or visual change); adds a unit testsampler_handle_is_cached_in_entry_block.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.