Shaders: scalar and dword buffer addresses ignore their two low bits, as the hardware does (misaligned access under Aftermath) #3894
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!3894
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3894"
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?
@eleboucher on GitHub · 2026-11-30 10:47 UTC · original
eleboucher:smem-align→main· +83 −1 · 4 files · 1 commits · merged 2026-11-30 14:12 UTCScalar memory reads (
S_LOAD_DWORD*,S_BUFFER_LOAD_DWORD*) ignore the two low address bits on the console. Our DXIL passed them through torawBufferLoad(declared 4-byte aligned), so an offset the title computes or loads that is not a multiple of 4 became a misaligned access on the host.AMD RDNA2 ISA reference:
SH_MEM_CONFIG.alignment_modeDWORD)What changes (
crates/victory-shader/src/emit/lower.rs):align4helper (& !3, folded away for constants already aligned).s_loadby address (memory_smem) ands_buffer_load(after offset + soffset). The page number comes from the high bits, so it is unchanged.VICTORY_VMEM_ALIGN4(default on,=0restores the old lowering), in the shader cache key, in case a title runs with the UNALIGNED mode.scalar_load_clears_the_two_low_address_bits, covers ans_load_dwordat offset 4k+2.How it showed up: with NVIDIA Aftermath's shader error reporting on,
main(41adb551) lost the device in every run, always "Misaligned Address Error" in the same compute program (title89d08e561897d4e5,dxil:8519). There, byte offsets loaded bys_buffer_loadare reused as SGPR offsets of laters_buffer_loads. Without error reporting, NVIDIA silently ignores the misalignment; per D3D12 it is undefined.Tested on an RTX 4070 Ti SUPER (driver 621.24), native 1440p with ray tracing, under Aftermath shader error reporting:
cargo test -p victory-shader: 296 passed.cargo xwin check/clippywith and withoutvictory-gpu/diagnostics: no new warnings in the touched files.What it does not do: it is not the cause of the device losses
mainhas with ray tracing on and error reporting off. Those still happen here with this change (2 of 2 runs, lost at 120-240 s). It makes the translation exact and removes undefined behaviour, so that the remaining fault reports point at real problems.@akimfomin on GitHub · 2026-11-30 11:07 UTC · original
@eleboucher Independent source-only check on the exact
844200e9lowering carried to the pinned Lab branch. I added a generateds_buffer_load_dwordcase with SGPR offsets 2, 3, 4, 7 and 11 plus immediate 1. The requested dwords at(SGPR + 1) >> 2all matched on Windows WARP in both the normal CBV and raw-twin paths. The3 + 1and7 + 1cases would select a different dword if the components were aligned before adding. Your scalar test and all 11 Lab shader-cache tests also passed. This isolates the scalar semantics; the VMEM mode and the separate device-loss path still have their own validation. I can share the generated Rust fixture upstream.@eleboucher on GitHub · 2026-11-30 11:09 UTC · original
Thanks for the independent check, and especially the
3 + 1/7 + 1carry cases: that is exactly where masking before the add would differ. Yes please, a generated fixture upstream would be welcome; if it fits as a test incrates/victory-shader/src/emit/lower/tests.rsnext toscalar_load_clears_the_two_low_address_bits, a suggestion or a small follow-up PR both work for me.@akimfomin on GitHub · 2026-11-30 11:15 UTC · original
@eleboucher Here is the small generated address-carry fixture and recipe for reuse. The patch applies cleanly to the exact #3894 head. The ten dispatches ran on the Lab backport with this fix. The fixture covers both the CBV and raw-twin routes and needs no title files.
@eleboucher on GitHub · 2026-11-30 11:23 UTC · original
Thanks, the fixture looks like the right regression test for this. Since it is your work, it would be cleanest as your own follow-up PR on top of #3894 (or straight onto main once this lands), so the authorship stays yours. I'm happy to review and run it on my 4070 Ti SUPER. The red
checkhere isunwind_copy is never usedinvictory-loader, which is on main already (this diff touches onlyvictory-shaderandshader_cache.rs); #2048 clears it.