fix(shader): clamp cbufferLoadLegacy row, keep WaveSize(64) on AMD, and sync water LDS (#288) #457
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/gamingwithhomie--larp!457
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-457"
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?
@ZerefDragnee1l on GitHub · 2026-12-06 01:07 UTC · original
ZerefDragnee1l:fix/shader-cbv-clamp-wave64-and-water-lds→main· +346 −20 · 5 files · 2 commits · openShader-translator fixes split out cleanly from #408.
Causal mapping & evidence
play.logrecords0x887A0004/0x887A0006device removal with breadcrumbs off.shader.rs,bitcode/opt.rs,lower.rs):cbufferLoadLegacyrow clamping (0x0FFF, 4096 vectors / 64 KiB) +Effect::Readsfor dynamic rows prevents dynamic/corrupt CBV row indices from indexing past a CBV or being hoisted/merged across writes asPure, while constant rows (including out-of-range constants clamped at emit time) remainEffect::Pure.WaveSize(64)on multi-wave Wave64 compute shaders (group % 64 == 0) on Wave64 hosts prevents SM 6.6 drivers such asamdxc64from defaulting unannotated multi-wave shaders to Wave32.lower.rs,by_hash/idle_lds_reads.rs) — companion to the water PR (independent of #288/#280):lds_meetings()now rejects region-boundary-only meetings when a single divergent region mixes plainds_write*and atomic LDS writes so Wave32 lowering keeps per-access barriers.CS_TV_Tiled,CS_AlphaTransmissionDepthTileGenerationMip1, andCS_AlphaTransmissionDepthTileGenerationMip25toidle_lds_reads.rs.Verification
git diff --check-> cleancargo check -p larp-> exited 0cargo test -p larp-shader --lib -- --skip buffer_tests::gpu->5 passed; 0 failed(emit::shader::tests::cbuffer_load_legacy_clamps_rows_and_preserves_constant_pure_vs_dynamic_reads,emit::lower::tests::lds_meetings_refuses_mixed_plain_and_atomic_writes_but_allows_same_class_writes,emit::lower::tests::emitted_wave_size_differs_between_wave32_and_wave64_hosts_for_multi_wave_groups, plus the 2 existing CPU tests). The 4emit::buffer_tests::gpu::*tests are filtered out (skipped/ require an SM 6.6 GPU device).@vanya890 on GitHub · 2026-12-06 01:11 UTC · original
Thanks for putting these AMD fixes together. One review gap before this is ready to merge: the validation listed does not exercise the new paths. The two passing CPU tests are existing unrelated tests, while the four GPU tests could not run; there are no CI checks on the head commit.
Could you add focused regression coverage for at least the CPU-side decisions: (1)
cbufferLoadLegacyclamps the row operand to 4095 and classifies dynamic rows asReadswhile constant rows remainPure; (2)lds_meetingsadds a barrier for mixedds_write*/atomic LDS writes but not for same-class writes; and (3) the emitted wave-size annotation for multi-wave Wave64 groups differs correctly between Wave32 and Wave64 hosts?Also, could you map each change to the evidence in #288/#280? The #288 DRED report points at view/sampler heap indices past their ends, while the attached #280
play.logI checked only records device removal (0x887A0004/0x887A0006) with breadcrumbs disabled. I can see how the cbuffer bound and Wave64 changes might be relevant, but the causal link to the reported failures is not yet clear from the PR description. A short explanation plus CPU-side tests would make this much easier to review without requiring the author's hardware to reproduce every case.@ZerefDragnee1l on GitHub · 2026-12-06 01:17 UTC · original
for sure
@vanya890 on GitHub · 2026-12-06 01:19 UTC · original · reviewed
The dynamic
cbufferLoadLegacyrow clamp is the key correctness boundary: the row operand is a vector index, so limiting it to0x0FFFkeeps constant-buffer access within the 4,096-row / 64 KiB CBV range. Keeping constant-index calls pure while treating dynamic calls as reads is also the right direction for the optimizer's effect model. Please ensure regression coverage exercises both a constant row (which should retain the pure path) and a dynamic/out-of-range row (which must be clamped and remain observable to optimization).@ZerefDragnee1l on GitHub · 2026-12-06 01:33 UTC · original
Thank you for the thorough review! I have updated this PR with both the constant-row fold fix and focused CPU-side regression tests, plus an explicit evidence mapping in the PR description:
Constant vs. dynamic
cbufferLoadLegacyrow clamping & effects (shader.rs,bitcode/opt.rs):dx.op.binary.i32unconditionally for constant rows turned the row operand into aV::Instprior toFOLD, which would causeModule::classto classify even constant-row calls asEffect::Readsbefore optimization.Shader::opnow folds constant operands directly (k.min(0x0FFF)) so both in-range and out-of-range constant rows stayV::Const(Effect::Pure) and merge across writes duringModule::optimise, while dynamic rows emitdx.op.binary.i32(..., 40, ..., 0x0FFF)and stayEffect::Readsacross intervening writes.emit::shader::tests::cbuffer_load_legacy_clamps_rows_and_preserves_constant_pure_vs_dynamic_reads.lds_meetingsmixed plain vs. atomic LDS writes & Wave64 annotation (lower.rs,structure.rs):emit::lower::tests::lds_meetings_refuses_mixed_plain_and_atomic_writes_but_allows_same_class_writesverifieslds_meetingsreturnsNonewhen a divergent block mixesds_write_b32andds_add_u32, while returning region-boundary meetings for same-classds_write_b32ords_add_u32pairs.emit::lower::tests::emitted_wave_size_differs_between_wave32_and_wave64_hosts_for_multi_wave_groupsverifies multi-wave Wave64 groups annotateSome(64)on Wave64 hosts andNoneon Wave32 hosts.Evidence mapping:
play.logonly shows0x887A0004/0x887A0006device removal with breadcrumbs disabled.cbufferLoadLegacyclamp/effect fix and Wave64 multi-wave annotation are presented here as defensive shader-side hardening for AMD RDNA 2 (#288/#280), while thelds_meetingsmixed-write fix andidle_lds_reads.rswater shaders specifically address Wave32 split-wave LDS synchronization for the water dark-block issue.Verification:
cargo check -p larpexited 0;cargo test -p larp-shader --lib -- --skip buffer_tests::gpu->5 passed; 0 failed; 4 filtered out(the 4emit::buffer_tests::gpu::*tests require an SM 6.6 device).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.