Shaders: a folded waterfall over a descriptor every lane copied from one scalar load is exact #526
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
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
TrustNo1/Darner!526
Loading…
Reference in a new issue
No description provided.
Delete branch "ntsthay/folded-waterfall"
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
On a 32-lane host,
vfx_proj_decal_vbuffer:CS_ProjDecalResolve_Scalarized(e4a9f58e3acfcf7bin 1.0.2.1) was refused by the folded form and ended in local waves (APPROXIMATE, any mask). The refusal was "a descriptor chosen by several conditions" at 0x5288.The program has four of LLVM's descriptor waterfalls over an 8-dword image descriptor (loop heads 0x5148, 0x5304, 0x56c4 and 0x5864). Every lane holds the same descriptor. v57..v64 are
v_mov_b32copies ofs[8:15], from ones_load_dwordx8reached by two paths, so each loop runs once. The fold turns each consolev_readfirstlane_b32into a read under each half of EXEC plus its owns_cmp_lg_u32 E.lo, 0ands_cselect_b32(fold.rs). That gives eight compares for one descriptor, and tracking refused them as eight conditions.Four rules in
resource.rsandstructure.rs. Each acts only where tracking refused before:same_condition). An SOPC is a pure function of its operands.Selectare the same source and that source is uniform (Source::is_uniform: noFetched,LanesorLanePhianywhere in it), theSelectis dropped. A per-lane descriptor keeps theSelect. There the high half would get the low half's copy.arm,read_known). The result is taken only if it is uniform.Structured::meet_boundedandstays_withinprove by induction that a lane mask joined at a loop head stays within a bound. The proof checks every incoming edge, and on back edges it takes the join as within the bound. The bound may only test values defined before the loop.runsuses this, so the copy before a waterfall counts for the lanes the loop narrows down to.v_cmp_eq_u32/u64of a first-lane read against the lane's own VGPRs is true in every lane when those VGPRs follow their copies to one scalar dword, and the read follows its own lanes' copies to the same dword (own_compares). It joinsWaterfall::compares, and the loop is lowered as written.How it was tested
c8258f9.resource.rs: a folded waterfall over a descriptor every lane copied from scalars is exact, with a Phi of two loads and all 8 compares proven. Two refusals are also checked: a waterfall over descriptors that differ between the halves proves no compare, and one whose retry widens the lanes (s_mov_b64 exec, -1) is refused.structure.rs:a_search_assuming_facts_answers_as_every_assignment_doeschecksmeet_assumingagainst all 256 assignments of 8 variables, 800 random cases.emit/waterfall_tests.rs, on the card:lanes_sample_the_texture_a_folded_waterfall_over_scalar_copies_namesis bit-exact for 64 console lanes.a_folded_waterfall_over_descriptors_that_differ_between_halves_is_refused_or_exactchecks that the result is never approximate.cargo clippy --workspace --all-targets --locked -- -D warnings, and the same with--all-features: clean.cargo test -p darner-shader --libon an RTX 4080 under Proton (proton-cachyos, driver 620.73): 574 passed, 0 failed, 16 ignored.darner translate --listof the wholeshaders.rpf,DARNER_HOST_WAVE=32, before and after, on our integration branch: 25,693 shaders emitted by each, and the module hash differs for exactly one of them,CS_ProjDecalResolve_Scalarized. WithDARNER_WAVE_WHY=1it now comes outfolded (before wave-wide); before, it was local waves (APPROXIMATE).Checklist
main.docs/asset-policy.md.Checked for overlap
DARNER_FIRSTLANE_UNIFORM) also deals with first-lane reads of values every lane holds. It excludes loaded values, so it does not cover this program, whose descriptor comes from ans_load.Shaders: a folded waterfall over a descriptor every lane copied from one scalar load is exactto [pr-fix][shaders] Shaders: a folded waterfall over a descriptor every lane copied from one scalar load is exact[pr-fix][shaders] Shaders: a folded waterfall over a descriptor every lane copied from one scalar load is exactto Shaders: a folded waterfall over a descriptor every lane copied from one scalar load is exactTest needed — commit
31582530; what to check:On a 32-lane host,
vfx_proj_decal_vbuffer:CS_ProjDecalResolve_Scalarized(e4a9f58e3acfcf7bin 1.0.2.1) was refused by the folded form and ended in local waves (APPROXIMATE, any mask). The refusal was "a descriptor chosen by several conditions" at 0x5288.The program has four of LLVM's descriptor waterfalls over an 8-dword image descriptor (loop heads 0x5148, 0x5304, 0x56c4 and 0x5864). Every lane holds the same descriptor. v57..v64 are
v_mov_b32copies ofs[8:15], from ones_load_dwordx8reached by two paths, so each loop runs once. The fold turns each consolev_readfirstlane_b32into a read under each half of EXEC plus its owns_cmp_lg_u32 E.lo, 0ands_cselect_b32(fold.rs). That gives eight compares for one descriptor, and tracking refused them as eight conditions.Four rules in
resource.rsandstructure.rs. Each acts only where tracking refused before:same_condition). An SOPC is a pure function of its operands.Selectare the same source and that source is uEvidence 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.