test(shader): execute flat and global loads against hardware results #547
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/547"
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 boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-04T17:10:20Z.
What
Test only, no recompiler change. Adds an execution test for the 8
flat_load_*and 8global_load_*opcodes (ubyte,sbyte,ushort,sshort,dword,dwordx2,dwordx3,dwordx4). No execution test covered them onmain:D16Memorycovers only the D16 forms, and the cache-bit forms are in #495. The test found no bug.It runs two compute shaders on 32 lanes over a guest block. Each lane loads from its own address, and checks 16 result dwords against values measured on hardware. The rows cover:
v32, s[8:9]) and with a 64-bit VGPR address (v[34:35], off)-2048,2047) and small negative ones (-1,-3,-6)2047)ushort, unaligneddwordtodwordx4)Encodings come from
llvm-mc -mcpu=gfx1013 -show-encoding.Behaviour measured on HW
The same two kernels ran on a Radeon 660M (gfx1035, same FLAT encoding as gfx1013). All 64 rows (32 global, 32 flat) match a byte-level model:
base + offset, with the global offset sign-extendedsbyte/sshortsign-extend,ubyte/ushortzero-extendThe expected values in the test are the hardware outputs.
The HW ran under amdgpu's default unaligned access mode. The test therefore pins unaligned reads as byte-exact, which is what
EmitBdaDwordReadsalready does through its byte path.Tested
Arch Linux: RADV (Radeon 660M), lavapipe with local Mesa, and lavapipe with CI's version (Ubuntu Mesa 25.2.8). New test
agc_driver_flat_global_loads_testspasses on all three.Negative checks: the test fails if
sbyte/sshortare zero-extendeddwordx3drops its last dwordMapping an unaligned span through the aligned dword path is not caught, because RADV and lavapipe both handle a misaligned dword
OpLoad.The test runs wave32 only. Each lane's load depends only on its own address, so wave64 adds no case. On CI's lavapipe the two dispatches take ~70 s with a cold shader cache, which is how CI runs: almost all of it is LLVM compiling the BDA lookups. With a warm cache it takes a few seconds, and under a second on RADV. Wave64 would double the time.
Full Release build (GCC) plus
ctest: 183/184. The one failure,agc_driver_pixel_helper_lanes, also fails onmainon local RADV since #305.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T21:19:29Z.
Thanks. I checked all 64 rows against a byte-level model of the two kernels (llvm-mc gfx1013 disassembly) and every value matches. The model uses
base + offsetwith the global offset sign-extended, byte-exact unaligned reads, sign extension for sbyte/sshort, and the sentinels kept on EXEC-off lanes. Both the SADDR and the 64-bit VADDR global forms are covered, and the flat offsets go up to 2047.One note: the test runs with the shader cache off, so on CI's lavapipe it pays the roughly 70 s compile every time. That's fine under the default timeout, so I'm not asking for a change.
Test only, no change to the translation. Ready to merge from my side.