Prevent scalar raw-buffer loads from wrapping at 4 GiB #1145
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1148"
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?
Imported from fxceless/victory-fork. Originally posted by BradRoland on 2026-11-25T21:39:19Z.
A scalar buffer load can return the first words of a raw SRV when its byte offset crosses 4 GiB. On WARP, an eight-dword load starting at
0xfffffffcagainst a 48-byte view returned real data from the beginning of that view. With grouped loads enabled, the second DXIL call started at byte 12. Adding the instruction's immediate to its register offset could also wrap before the first load.The shared lowering for table-bound and heap-selected raw SRVs now tests for carry when adding a positive instruction immediate and when advancing to a later host load. It returns zero for the affected words. This preserves the individual and grouped load sizes selected by
VICTORY_SHADER_OPT.I extended the existing synthetic WARP test with offsets that cross the limit both ways. It failed before the fix and passed with
VICTORY_SHADER_OPT=63and127. The same test also checks reads that straddle the end of a small view. All 216 enabled shader crate tests passed (three ignored), as didcargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings. Gameplay and shader-pack performance remain unmeasured.Imported from fxceless/victory-fork. Originally posted by fladit123 on 2026-11-25T23:01:48Z.
I investigated the grouped-load boundary hypothesis mentioned in the README using synthetic raw SRVs on an RTX 4060 (driver 610.88) and WARP.
For the 340-byte view, a load starting at byte 328 preserved the three valid dwords in both modes. The out-of-range fourth component returned zero when consumed.
I could not reproduce the suspected boundary regression on this hardware with these fixtures.
Dynamic heap-selected descriptors, the actual affected shaders, and other GPU architectures remain untested. I have not independently confirmed the optimizer's elimination of unused scalar loads.
This is not a validation of the 4 GiB wrap fix itself.
AI-assisted investigation with ChatGPT; all tests executed locally using synthetic data.
Imported from fxceless/victory-fork. Originally posted by BradRoland on 2026-11-25T23:11:51Z.
Thanks for the RTX 4060 results. I tested the separate 4 GiB wrap on both a table-bound raw SRV and a
ResourceHeapview selected at runtime. The shader chooses between two slots with different lengths and contents. The heap case binds the renderer’s stride-table root SRV. The in-bounds controls distinguish the two buffers.With the original lowering, an eight-dword load starting at
0xfffffffcreturned several words from the start of the selected view. This reproduced on the RTX 4080 (621.14) and WARP, withVICTORY_SHADER_OPT=63and127, for both binding paths. Withe8f3e66each of the eight adapter/mode/binding combinations passed all ten offset cases. That includes carry in the register-plus-immediate addition and in the later words of a load.I published the test fixture as commit f908625 atop this PR. Run
cargo test --locked -p victory-shader --lib scalar_buffer_loads_ -- --nocapturewithVICTORY_WARP=0for hardware or1for WARP. These results establish the 4 GiB regression on hardware. The 328/340-byte water case has its own fixture and disassembly in #1179.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.