Skip to content

test(shader): execute the untested LDS reads, writes and integer atomics against values measured on RDNA - #543

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
adriadam10:test/lds-ops
Oct 4, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
adriadam10:test/lds-ops

Conversation

@adriadam10

Copy link
Copy Markdown
Collaborator

What

Three execution tests for the LDS instructions that are decoded but that no test runs yet. Each runs as wave32, wave64 and wave64 split (ComputeTarget(32)). Every lane checks its returned values and then its dword of the whole LDS. The expected values were measured on hardware. No translator change: the recompiler matched the hardware everywhere.

  • agc_driver_lds_integer_atomics: ds_{add,sub,min_i32,max_i32,min_u32,max_u32,and,or,xor} without return, each lane on its own dword and then all lanes on one dword. Also the _rtn_ forms of these plus inc/dec, and ds_wrxchg_rtn_b32, run under a partial EXEC (inactive lanes keep their destination).
  • agc_driver_lds_read_write, under a partial EXEC:
    • reads: ds_read_{u8,i8,u16,i16} at every byte or half position (computed and constant offsets), ds_read2_b32, ds_read2st64_b32, ds_read_b64, ds_read2_b64, ds_read2st64_b64, ds_read_b96
    • writes: ds_write_b8, ds_write_b16, ds_write_b16_d16_hi, ds_write2_b32, ds_write2st64_b32, ds_write_b64, ds_write2_b64, ds_write2st64_b64, ds_write_b96
    • reads and writes that go past the end of the workgroup's LDS: reads return 0, writes are dropped.
  • agc_driver_lds_addtid: ds_read_addtid_b32 / ds_write_addtid_b32 with several M0 values and offsets, some lanes past the end. It is skipped on devices whose subgroups are narrower than the wave, like agc_driver_ds_permute, because the lane id comes from the subgroup.

Not covered: ds_append/ds_consume (#523), ds_wrxchg2* (#385), ds_swizzle_b32, the 64-bit atomics and the _src2_ forms (still not decoded), and GDS.

Behaviour measured on hardware

On an RDNA2 GPU (gfx1035, HSA, wave32 and wave64). A Python model of each test was checked against the hardware on 32 random sets of lanes per wave size (100% match), and then the rows were picked from it:

  • addtid address = M0[15:0] + instruction offset + lane * 4. M0[31:16] is ignored.
  • Past the end of the allocation (here lanes * 128 bytes), reads return 0 and writes are dropped, also for addtid and for each dword of ds_read_b64.

Tested

Linux (CachyOS), GCC, Release build, full ctest on RADV (Mesa 26.2): everything passes except agc_driver_pixel_helper_lanes, which already fails on main here. The three new tests also pass on lavapipe (local and the Ubuntu Mesa 25.2.8 that CI uses). agc_driver_lds_addtid is skipped there (8-lane subgroups).

Each test fails when the piece it covers is broken:

  • ds_min_i32 mapped to unsigned min
  • ds_dec_rtn_u32 mapped to inc
  • the _rtn_ result not written
  • ds_xor_b32 mapped to or
  • ds_read_i8 zero-extended
  • the second offset of ds_write2/ds_read2 ignored
  • the st64 scale wrong for b32 or b64
  • the LDS array 64 dwords larger than the allocation
  • addtid using M0[31:16], without the instruction offset, or with lane * 8

No title was run.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

@github-actions github-actions Bot added the agc libSceAgc* label Oct 4, 2026
…ics against values measured on RDNA

Co-Authored-By: Claude <noreply@anthropic.com>
@adriadam10

Copy link
Copy Markdown
Collaborator Author

Rebased on current main: the only Windows failure was guest_audio_in_no_device, fixed by #532. No other changes.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Thanks. I recomputed all three tables from the ISA semantics instead of taking them as given: I ran the llvm-mc gfx1013 disassembly of each shader through a small lane-by-lane model. Every cell matches for wave32 and wave64 (LdsIntegerAtomics, LdsReadWrite and LdsAddtid). The model reads past the end of the allocation as zero and drops the writes there, as the RDNA2 ISA's out-of-range rules for LDS say. Addtid uses M0[15:0] + offset + TID*4 from the DS_READ_ADDTID_B32 / DS_WRITE_ADDTID_B32 descriptions. The tables also come out the same with the lanes processed in reverse order, so the wave64 split runs don't depend on the order between the two halves.

No overlap with the existing LdsAtomics test or with #523 and #385. Test only, no change to the translation. Ready to merge from my side.

@oneandonlydean
oneandonlydean merged commit 3403c80 into boykopovar:main Oct 4, 2026
3 checks passed
@adriadam10
adriadam10 deleted the test/lds-ops branch October 5, 2026 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants