shader: a strided region's lane privacy is bounded by the LDS window #585
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!585
Loading…
Reference in a new issue
No description provided.
Delete branch "qnjk/Darner:lds-private-window"
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
The problem on main:
region_strided_private(crates/darner-shader/src/emit/lds.rs:726) accepted a region whose every access is(counter << shift) + offon one condition:justified by "an address that wraps keeps its residue, as
mdivides 2^32". LDS has no 2^32-wide window to wrap in: a thread group's shared memory is at most 32 KiB on the host (HOST_LDS_DWORDS= 8,192 dwords,lower.rs:881; more is refused atlower.rs:2722) and 64 KiB on the console. An address that wraps keeps its residue modulomonly whenmdivides that window, so any period past it aliases two threads the proof called private. The shape the finding gives — threads[64, 1, 1],shift = 11, so a 2 KiB slot andm = 128 KiB— has threadtand threadt + 32writing the same dword, yet the region was accepted and the!allregion split across the two host waves: a silent write/write or read/write miscompile.This change bounds the period by the group's LDS window instead of 2^32.
LDS_WINDOW = 1 << 15is 32 KiB, D3D12's group-shared limit and the only window the translated program has; because it is a power of two it divides the console's 64 KiB window as well, so a period that fits here keeps its property under either reading. A period past the window returnsfalse, so the caller keeps the guard instead of splitting on a false proof, and the doc comment now states why the divisor is the window.How it was tested
16dfa4e(one commit onc8258f9).cargo test --locked -p darner-shader --lib -- a_stride_cycle_past_the_lds_window— 1 passed.emit::lds::tests::a_stride_cycle_past_the_lds_window_is_not_lane_privatepins both sides of the bound on 64 threads:shift = 9(512-byte slot,m = 32 KiB, exactly the window) is still private;shift = 10(1 KiB slot, 64 KiB) andshift = 11(2 KiB slot, 128 KiB) are not, because threadtand threadt + 32are the same dword once the address passes the window.cargo clippy --locked -p darner-shader --all-targets -- -D warningspasses.cargo clippy --workspace --all-targets --locked -- -D warnings: passes.cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passes.cargo test --workspace --locked: not run to completion here.darner-shader's full lib suite takes ~40 minutes on this machine and containsemit::waterfall_tests, which fails on a cleanmain(#227); the change was gated by its own test plus clippy.darner-shaderis the only crate touched.region_disjoint_ranges(lds.rs:745),region_same_constants(:696) andhas_provable_shared_waw(:812); they compare constant offsets and do not take the window into account. They are deliberately untouched here (one change per commit) and are the same class of defect — worth a follow-up.Checklist
main; no frame-rate or visual claim is made.main.docs/asset-policy.md. (cargo xtask policy: 576 files ok.)Checked for overlap
crates/darner-shader/src/emit/lds.rs(checked against the file list of all 189 open pull requests), and no open or closed issue mentionsregion_strided_private, the LDS window or lane privacy.[pr-fix][shaders] shader: a strided region's lane privacy is bounded by the LDS windowto shader: a strided region's lane privacy is bounded by the LDS windowTest needed — commit
16dfa4ef; what to check:The problem on main:
region_strided_private(crates/darner-shader/src/emit/lds.rs:726) accepted a region whose every access is(counter << shift) + offon one condition:justified by "an address that wraps keeps its residue, as
mdivides 2^32". LDS has no 2^32-wide window to wrap in: a thread group's shared memory is at most 32 KiB on the host (HOST_LDS_DWORDS= 8,192 dwords,lower.rs:881; more is refused atlower.rs:2722) and 64 KiB on the console. An address that wraps keeps its residue modulomonly whenmdivides that window, so any period past it aliases two threads the proof called private. The shape the finding gives — threads[64, 1, 1],shift = 11, so a 2 KiB slot andm = 128 KiB— has threadtand threadt + 32writing the same dword, yet the region was accepted and the!allregion split across the two host waves: a silent write/write or read/write miscompile.This change bounds the period by the group's LDS window instead of 2^32.
LDS_WINDOW = 1 << 15is 32 KiB, D3D12's group-shared limit and the only window the translated progEvidence 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.