Repository navigation
fix(recompiler): match image-table T# halves offset before and after readfirstlane - #8991
Conversation
|
Tested on AMD Ryzen 7 9800X3D and AMD Radeon RX 7900 XTX (Fedora Linux, Mesa 26.2.5):
|
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
…readfirstlane A T# loaded as two s_load_dwordx4 halves from a pointer table, where the second half's offset is formed per lane (v_lshl_add_u32 key, 5, 16) before v_readfirstlane and the first half's after it (readfirstlane(key) << 5), was refused: the second half's +16 sat inside ReadFirstLane(Select(exec, ..., old), exec), so TryMakeTableColumn saw a different base and a zero addend. Compare such offsets in a first-lane normal form (lane value, mask, shift, addend), peeling selects the mask implies as the SRT walker already does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… test Co-Authored-By: Claude <noreply@anthropic.com>
2c77b0f to
78178e9
Compare
|
AMD result for this PR: Marvel's Guardians of the Galaxy (PPSA01748) on a Radeon Pro V620 (RADV, Mesa 25.2.8, Ubuntu 24.04, kernel 6.8), built from this PR's head 2c77b0f with GCC 13.
Tested and written by Claude (AI assistant) on a contributor's machine. |
|
Checked the diff: Added on top: removed the three code comments from |
Brings #8991 (match image-table T# halves offset before and after readfirstlane). ResourceTracker.cpp: main's FirstLaneOffset, ParseFirstLaneOffset and SameFirstLaneOffset go before TryMakeTableColumn, which keeps this branch's signature with the buffer parameter. Main's first-lane base check in the column loop merged on its own.
What
Marvel's Guardians of the Galaxy (PPSA01748) stops about 4.5 minutes into boot, after the opening menus, on compute shader 0x3b91c3e00 (#7362):
Cause: the key's range is not what blocks this shader, as #7362 assumed. The shader runs a waterfall loop and loads its 8-dword T# from a table behind a 64-bit pointer, in two
s_load_dwordx4halves:The first half's offset is
ReadFirstLane(key, exec) << 5. The second half's offset isReadFirstLane(Select(exec, (key << 5) + 16, old), exec): its +16 is added before the lane read.TryMakeTableColumnsplits immediate addends only at the top of the offset, so the second half got a different base and a zero addend. The column was refused, andGetHandlethrew. The key bound (#7388) and the select condition validation were not involved.Fix: when the existing base comparison fails,
TryMakeTableColumncompares both offsets in one first-lane form: (lane value, mask, shift, addend).v_readfirstlanecommutes with a left shift and an immediate add, and it reads the active arm of a select whose condition the mask implies. The select is peeled withDetail::ActiveMaskImplies, the same rule the SRT walker uses since #7388. Two offsets match only when the lane value, mask and shift are equivalent. The parsed addend replaces the zero one, so the existing checkoffset + addend == first + 4 * dwordstill decides whether the words form one record. The column's key stays dword 0's real offset; nothing else in the plan changes.The column has no key domain, so it binds the snapshot domain (up to 65536 records), as unkeyed pointer tables already do. The assumption about inactive lanes is the one #7388 documented, and I extended that entry in
docs/dev/debt/shader.md: with no active lane the hardware reads lane 0 of the inactive arm, and the table still binds the whole record.Tested
Linux (CachyOS, kernel 7.2.9), GCC 16.2.1, Release,
BUILD_TESTING=ON, RTX 4090 (NVIDIA 615.78.08).verifySplitWaterfallImageTableintests/ShaderMemory.cpp, run byagc_shader_memoryandagc_shader_bindless. A waterfall loop loads one T# as twos_load_dwordx4halves, the second offset formed per lane withv_lshl_add_u32 key, 5, 16. The test checks that the T# is planned as one pointer-table column (stride 32, 8 words, the second half's addend folded) and that record 0's snapshot holds the stored T#. With +32 (the next record) or +8 (a misaligned half) instead of +16, the column must still be refused.ResourceTracker.cpprestored tomain, bothagc_shader_memoryandagc_shader_bindlessfail with the title's message (GetImageResource dword 0 is not a valid runtime value).ctest -R '^agc_shader': 31 of 31 pass.ctest -R '^agc_': 849 of 849 pass (1 skipped,agc_driver_stencil_ref_export).python3 tools/check_conventions.py --base origin/mainandtools/check_test_registration.py: pass.main6830c91 with no other changes:main6830c91LoadAddressU32@pc=0x4380main+ this changeThe shader is large (1,722,971 SPIR-V words), and its first pipeline build holds the warning screen at about 0.3 FPS for a few minutes on a cold cache. The run then stops later, in the first level, on a separate
AGC graphics: CB metadata pass over part of a color target. That is not part of this change; I'll report it separately.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Tested and written by Claude (AI assistant) on a contributor's machine.