shader: deduplicate sampled-texture marks along dominated IR paths #2702
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!2702
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2702"
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?
@nidea1 on GitHub · 2026-11-29 16:17 UTC · original
nidea1:perf/dedup-sampled-marks-in-shader→main· +356 −11 · 2 files · 1 commits · merged 2026-11-30 14:12 UTCSummary
Deduplicates redundant
SLOT_SAMPLEDmarking blocks emitted underVICTORY_SAMPLED_MARKS=1along dominated IR paths incrates/victory-shader/src/emit/lower.rs.Previously, every
image_sample*/image_load*emitted its own 4-blockWaveIsFirstLane+rawBufferLoad+atomicBinOpdiamond intoSLOT_SAMPLED, even when the exact same texture heap slot was sampled dozens of times in the same block or along a dominated path. On large Wave64-folded compute shaders with heavy texture sampling, this bloated DXIL basic blocks by >2.5x and added >200 KB of bitcode and >1,300 redundant per-wave UAV loads/branches.Changes
MarkKey(LoadedExpr,LoadedSite,FetchedSite,Select) andir_dominatesreusingLower::idom.marked_slots: HashMap<(MarkKey, bool), Vec<usize>>keyed by(MarkKey, per_lane)and skipped emitting duplicatemark_sampledblocks whenever a dominating IR blockprev_balready marked the same slot and every SSA definition feedingMarkKeydominatesprev_b(so loop-carried descriptor reloads still re-mark per iteration).Source::Phi,Source::Lanes,Source::LanePhi, distinct slots, and non-dominated siblingif/elsebranches.sampled_marks_deduplicated_along_dominated_paths_onlyincrates/victory-shader/src/emit/waterfall_tests.rscovering same-block reload dedup, dominated-block dedup, sibling branch non-dedup, and distinct-slot marking, withdxil.dllvalidation.Measured Impact (RTX 3060 Ti,
VICTORY_SAMPLED_MARKS=1, coldCreateComputePipelineState)Measured across the 10 largest Wave64-folded compute shaders (
main829188e9vs this PR alone):1,808,720 B->1,601,164 B(-207.6 KB/-11.5%)8,548->2,988(-65.0%)SLOT_SAMPLEDatomics:1,547->157(-89.9%)36,963 ms->26,460 ms(-28.4%/-10.5 s)87,039 ms->65,694 ms(-24.5%/-21.3 s)8.45 MB->7.75 MB(-8.3%), blocks41,896->23,212(-44.6%), translation time4,697 ms->3,925 ms(-16.4%).main55d06914):#1cold PSO29,080 ms->19,078 ms(-34.4%/1.52x); top-3 total66,055 ms->48,087 ms(-27.2%/1.37x).Verification
cargo test -p victory-shader -j 4 --lib— 463 passed, 0 failed (including DXIL validation + hardware/WARP GPU tests and new dedup test); combined with#2703+#2623+#2357onmain(55d06914): 470 passed, 0 failed, plus full pipeline preload (2,720/2,720 compiled cleanly) and live runtime validation (0 shader errors).cargo clippy -p victory-shader -j 4 --tests— 0 new warnings.cargo xtask policy --staged— clean.