fix(vk): storage buffers on 16-byte boundaries and bounds-checked texture decode stores (AMD, ported from Fritchii) #2442
No reviewers
Labels
No labels
accessibility
autorelease: pending
autorelease: tagged
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
question
testing wanted
wontfix
No milestone
No assignees
1 participant
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Hookshot!2442
Loading…
Reference in a new issue
No description provided.
Delete branch "port/fritchii-rendering"
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?
Two AMD problems that Lichii and Fritchii found in code Hookshot shares with them. Storage buffers bound at AMD's 4-byte alignment can make 8- and 16-byte shader reads return the wrong words. The ASTC decoder and the block-linear unswizzle store texels past the edge of the image.
What changes
storage_binding_aligningpu/vk/vk_internal.h, used bymake_profile/host_infoand the descriptor writer).offset >> 3,>> 4). These are exact only when the binding starts on a 16-byte boundary.vk_shader.cpp), so players prepare their shaders once again, before play. Nothing compiles during play.gpu/vk/host_shaders/astc_decoder.comp,block_linear_unswizzle_2d.comp; SPIR-V headers regenerated withscripts/host_shaders.py).robustImageAccess2is off, so those stores are undefined. NVIDIA drops them. On AMD they landed in other images' memory: black blocks and a crosshatch on an RX 6750 XT, and in the end a GPU fault.Verified (RTX 3090, Linux, my own dump)
tests/test_amd_subgroup_profiles.pynow also checks that the profile's storage alignment is 16 for a device that allows 4, that 64 stays 64, and that the alignment is in the program cache's stamp.tests/test_program_stamp_knobs.pypasses.tests/test_host_shaders.pypasses: the regenerated headers match their sources. Both shaders passspirv-val.tests/run_all.py: everything passes except 4 checks (13 skipped). Those 4 (test_wayland_libdecor_hint,test_nup_read_name,test_bake_portability,test_builder_log_read_only) fail the same way on main on this machine.Not tested
Tested on AMD: RX 580 (Polaris), Mesa 26.2.6 RADV, Linux. This PR (
2ea12bd4) against its base main3e95ca68, at the same spots: Kokiri Forest, then a teleport to Lake Hylia.RADV on this card reports
minStorageBufferOffsetAlignment = 4, so this PR does change the translation here.VK_ERRORor device loss in either run.Left is the base, right is this PR:
So: no regression on Polaris/RADV, but no symptom here for it to fix either. The light-colour bug was reported on RX 6000/7000 cards, possibly on Windows, and needs one of those to confirm the fix.
The precompile was skipped in both runs, because it runs out of memory on this card on every build, main included (two mesh-fallback compute programs never finish compiling in ACO). That's being looked into separately.
https://discord.com/channels/1568810484818378804/1569019786766188665/1570192658532536442
github-sync referenced this pull request2026-11-12 06:22:54 +00:00