docs: re-source the Leonida citations in the RDNA 2 code and credit the frozen Leonida translators #252

Open
github-bot wants to merge 2 commits from github-bot/gh-252 into main AGit
Owner

@⁠KainanP on GitHub · 2026-11-25 21:34 UTC · original
KainanP:docs/leonida-citations-in-tree → main · +73 −49 · 9 files · 2 commits · open

Change

Follow-up to the review of #230, #232 and #235, and to the review of this PR. The Leonida docs (ubiquitarianism/leonida docs/design.md) were taken down on 2026-11-24 after a DMCA notice, and rule 2 asks for AMD's ISA, LLVM's tests, Microsoft Learn or our own measurements. This PR handles every Leonida reference listed in the review: citations of Leonida measurements are re-sourced or labelled assumed, and code taken from Leonida is credited as frozen GPL-3.0 code. Comments and THIRD_PARTY.md only; no behaviour change.

AMD's RDNA 2 ISA below is the November 2020 reference guide (Wayback copy, SHA-256 22aec03f…, see docs/research/rdna2-sources.md); page numbers are the printed ones.

  • emu/rdna2_exec_cmp16.py (#226): inline floats on 16-bit integer sources now cite LLVM 20.1.8, Utils/AMDGPUBaseInfo.cpp getInlineEncodingV216 ("for UI16 instructions: corresponding single-precision float value"), and test/CodeGen/AMDGPU/add.v2i16.ll, where GFX10 encodes <0, 16256> as 1.0. The SDWA case is labelled assumed. Both stay requested in akimfomin/PortBridge#83.
  • emu/rdna2_buffer_format.py and emu/rdna2_exec_format.py (#150):
    • Section 8.1.4, table 31 (p. 59): MTBUF takes the instruction's format and the identity DST_SEL. An INVALID resource format means "unbound resource".
    • Section 8.1.5, notes 1 and 3 (p. 62): out-of-range reads return zero, except SEL_1 components, which return 1. Load/store-format accesses are range-checked "all or nothing".
    • AMD XML: formatted loads "convert the data to 32 bit integral or floating point format".
    • Labelled assumed (not measured): the UNORM/SNORM quotient rounded to nearest, the 16-bit FLOAT NaN widening, the UINT/SINT store saturation, and 1.0 against 1 for DST_SEL = 1. MUBUF stores with DST_SEL_Z = Z or W on a two-component format stay refused, now because nothing documents them.
  • emu/rdna2_hlsl_format.py: the BufUnorm comment states the identity it uses (m / (2^n − 1) = 0.mmm… in base 2^n) instead of naming Leonida.
  • tests/test_rdna2_exec_format.py: one comment.
  • emu/rdna2_image.py: each T#/S# field the code reads cites section 8.2.6, table 45 (p. 75) and section 8.2.7, table 46 (p. 76-77); format codes cite section 8.2.8, table 47 (p. 78-79). Every position and value in the code matches the tables. Table 46 names the border colour types without values, so 0/1/2 = transparent black / opaque black / opaque white cite Mesa's SQ_TEX_BORDER_COLOR enum (src/amd/registers/gfx6.json, MIT, read statically). The positions were first ported from Leonida's gfx10_descriptors.h (GPL-3.0), which stays credited. data/gfx10_formats.json stays credited as a copy of Leonida's table; it is identical to Mesa's GFX10_FORMAT enum (gfx10-rsrc.json), and the 105 codes in table 47 have the same names there.
  • emu/rdna2_hlsl.py (cfg_structure import) and emu/rdna2_spirv.py: the comments credit cfg_structure.py and rdna2spirv.py as frozen, unmodified GPL-3.0 copies in third_party/leonida/ (commit 1cc6e3c121, THIRD_PARTY.md), a code dependency rather than a source of measurements. What rdna2_spirv.py says about the translator's inputs is read from that code. The import and the SPIR-V path are unchanged: removing the code dependency is #262, as you suggested.
  • THIRD_PARTY.md: rdna2_hlsl.py is listed as importing cfg_structure.py; the typed-memory row no longer says "measured by Leonida"; the Leonida and Mesa descriptor rows say what the code now cites.

Overlap: #230 also edits rdna2_buffer_format.py and rdna2_exec_format.py (different lines). Whichever PR merges second gets a small rebase.

Verification

On main 3e258c8:

python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools → All checks passed!
python -m pytest (full suite, RTX) → 1404 passed, 17 skipped (GPU tests on the RTX; the 2 SPIR-V validation tests skip without spirv-as/spirv-val)

ISA tables 45-47 and Mesa gfx10-rsrc.json / gfx6.json were compared with the code by a script (field positions, enum values, and the 160 format names). There is no behaviour change, so no new test.

Checklist

  • The PR covers a single reviewable behaviour. (Sources of existing comments.)
  • A test fails without this change and passes with it. (Not applicable: comments only.)
  • The commands and results of each check are given above.
  • An unimplemented function returns an error (E_NOTIMPL), never a fake success.
  • README: the same change in all 9 languages (test_readme_sync.py checks it). (No README change.)
  • No game, console or SDK file, no key, no dump, no download link.
  • Findings drawn from a title: none.
  • Code taken from another project: none new; existing Leonida code stays credited in THIRD_PARTY.md.

Made with AI assistance: Claude Code with Claude Opus 5.5, for KainanP.

🤖 Generated with Claude Code

**@⁠KainanP** on GitHub · 2026-11-25 21:34 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/252) `KainanP:docs/leonida-citations-in-tree` → `main` · +73 −49 · 9 files · 2 commits · open ## Change Follow-up to the review of #230, #232 and #235, and to the review of this PR. The Leonida docs (`ubiquitarianism/leonida` `docs/design.md`) were taken down on 2026-11-24 after a DMCA notice, and rule 2 asks for AMD's ISA, LLVM's tests, Microsoft Learn or our own measurements. This PR handles every Leonida reference listed in the review: citations of Leonida measurements are re-sourced or labelled assumed, and code taken from Leonida is credited as frozen GPL-3.0 code. Comments and THIRD_PARTY.md only; no behaviour change. AMD's RDNA 2 ISA below is the November 2020 reference guide (Wayback copy, SHA-256 `22aec03f…`, see `docs/research/rdna2-sources.md`); page numbers are the printed ones. - `emu/rdna2_exec_cmp16.py` (#226): inline floats on 16-bit integer sources now cite LLVM 20.1.8, `Utils/AMDGPUBaseInfo.cpp` `getInlineEncodingV216` ("for UI16 instructions: corresponding single-precision float value"), and `test/CodeGen/AMDGPU/add.v2i16.ll`, where GFX10 encodes `<0, 16256>` as `1.0`. The SDWA case is labelled assumed. Both stay requested in akimfomin/PortBridge#83. - `emu/rdna2_buffer_format.py` and `emu/rdna2_exec_format.py` (#150): - Section 8.1.4, table 31 (p. 59): MTBUF takes the instruction's format and the identity DST_SEL. An INVALID resource format means "unbound resource". - Section 8.1.5, notes 1 and 3 (p. 62): out-of-range reads return zero, except SEL_1 components, which return 1. Load/store-format accesses are range-checked "all or nothing". - AMD XML: formatted loads "convert the data to 32 bit integral or floating point format". - Labelled **assumed (not measured)**: the UNORM/SNORM quotient rounded to nearest, the 16-bit FLOAT NaN widening, the UINT/SINT store saturation, and 1.0 against 1 for DST_SEL = 1. MUBUF stores with DST_SEL_Z = Z or W on a two-component format stay refused, now because nothing documents them. - `emu/rdna2_hlsl_format.py`: the `BufUnorm` comment states the identity it uses (m / (2^n − 1) = 0.mmm… in base 2^n) instead of naming Leonida. - `tests/test_rdna2_exec_format.py`: one comment. - `emu/rdna2_image.py`: each T#/S# field the code reads cites section 8.2.6, table 45 (p. 75) and section 8.2.7, table 46 (p. 76-77); format codes cite section 8.2.8, table 47 (p. 78-79). Every position and value in the code matches the tables. Table 46 names the border colour types without values, so 0/1/2 = transparent black / opaque black / opaque white cite Mesa's `SQ_TEX_BORDER_COLOR` enum (`src/amd/registers/gfx6.json`, MIT, read statically). The positions were first ported from Leonida's `gfx10_descriptors.h` (GPL-3.0), which stays credited. `data/gfx10_formats.json` stays credited as a copy of Leonida's table; it is identical to Mesa's `GFX10_FORMAT` enum (`gfx10-rsrc.json`), and the 105 codes in table 47 have the same names there. - `emu/rdna2_hlsl.py` (`cfg_structure` import) and `emu/rdna2_spirv.py`: the comments credit `cfg_structure.py` and `rdna2spirv.py` as frozen, unmodified GPL-3.0 copies in `third_party/leonida/` (commit `1cc6e3c121`, THIRD_PARTY.md), a code dependency rather than a source of measurements. What `rdna2_spirv.py` says about the translator's inputs is read from that code. The import and the SPIR-V path are unchanged: removing the code dependency is #262, as you suggested. - `THIRD_PARTY.md`: `rdna2_hlsl.py` is listed as importing `cfg_structure.py`; the typed-memory row no longer says "measured by Leonida"; the Leonida and Mesa descriptor rows say what the code now cites. Overlap: #230 also edits `rdna2_buffer_format.py` and `rdna2_exec_format.py` (different lines). Whichever PR merges second gets a small rebase. ## Verification On `main` `3e258c8`: ``` python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools → All checks passed! python -m pytest (full suite, RTX) → 1404 passed, 17 skipped (GPU tests on the RTX; the 2 SPIR-V validation tests skip without spirv-as/spirv-val) ``` ISA tables 45-47 and Mesa `gfx10-rsrc.json` / `gfx6.json` were compared with the code by a script (field positions, enum values, and the 160 format names). There is no behaviour change, so no new test. ## Checklist - [x] The PR covers a single reviewable behaviour. (Sources of existing comments.) - [ ] A test fails without this change and passes with it. (Not applicable: comments only.) - [x] The commands and results of each check are given above. - [x] An unimplemented function returns an error (`E_NOTIMPL`), never a fake success. - [x] README: the same change in all 9 languages (`test_readme_sync.py` checks it). (No README change.) - [x] No game, console or SDK file, no key, no dump, no download link. - [x] Findings drawn from a title: none. - [x] Code taken from another project: none new; existing Leonida code stays credited in THIRD_PARTY.md. Made with AI assistance: Claude Code with Claude Opus 5.5, for KainanP. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The Leonida docs (ubiquitarianism/leonida docs/design.md) were taken down
on 2026-11-24 after a DMCA notice, and rule 2 asks for AMD's ISA, LLVM's
tests, Microsoft Learn or our own measurements. This replaces the Leonida
citations that our merged PRs #150 and #226 left on main.

- emu/rdna2_exec_cmp16.py (#226): inline floats on 16-bit integer sources
  now cite LLVM 20.1.8, Utils/AMDGPUBaseInfo.cpp getInlineEncodingV216
  ("for UI16 instructions: corresponding single-precision float value")
  and test/CodeGen/AMDGPU/add.v2i16.ll (GFX10 encodes <0, 16256> as 1.0),
  next to the SIInstrInfo comment already quoted. The SDWA case is labelled
  assumed; both stay requested in akimfomin/PortBridge#83.
- emu/rdna2_buffer_format.py, emu/rdna2_exec_format.py (#150): AMD RDNA 2
  ISA (November 2020) section 8.1.4, table 31 (p. 59): MTBUF takes the
  instruction's format and the identity DST_SEL; an INVALID resource format
  means an unbound resource. Section 8.1.5 (p. 62), notes 1 and 3:
  out-of-range reads return zero except SEL_1 components, which return 1,
  and load/store-format accesses are range-checked all or nothing. AMD XML:
  formatted loads "convert the data to 32 bit integral or floating point
  format". Labelled assumed (not measured): the UNORM/SNORM quotient
  rounded to nearest, the 16-bit FLOAT NaN widening, the UINT/SINT store
  saturation, 1.0 against 1 for DST_SEL = 1. MUBUF stores whose DST_SEL_Z
  is Z or W on a two-component format stay refused, now because nothing
  documents them.
- emu/rdna2_hlsl_format.py: the BufUnorm comment states the identity it
  uses (m / (2^n - 1) = 0.mmm... in base 2^n) instead of naming Leonida.
- tests/test_rdna2_exec_format.py: one comment.

Comments only; no behaviour change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Follow-up to the review of #252: the remaining Leonida references in
rdna2_image.py, rdna2_hlsl.py and rdna2_spirv.py.

- emu/rdna2_image.py: every T# and S# field the code reads now cites AMD's
  RDNA 2 ISA (November 2020), section 8.2.6 table 45 (p. 75) and section
  8.2.7 table 46 (p. 76-77); format codes cite section 8.2.8 table 47
  (p. 78-79). Table 46 names the border colour types without values, so
  0/1/2 = transparent black / opaque black / opaque white cite Mesa's
  SQ_TEX_BORDER_COLOR enum (src/amd/registers/gfx6.json, MIT). Field and
  constant names come from Mesa gfx10-rsrc.json and gfx6.json. The positions
  were first ported from Leonida's gfx10_descriptors.h (GPL-3.0), which stays
  credited. data/gfx10_formats.json is still credited as a copy of Leonida's
  table; it is identical to Mesa's GFX10_FORMAT enum, and its 105 codes
  listed in table 47 have the same names.
- emu/rdna2_hlsl.py, emu/rdna2_spirv.py: comments credit cfg_structure.py
  and rdna2spirv.py as frozen, unmodified GPL-3.0 copies in
  third_party/leonida/ (commit 1cc6e3c121, THIRD_PARTY.md), a code
  dependency rather than a source of measurements; what rdna2_spirv.py says
  about the translator's inputs is read from that code. The import stays;
  removing it is #262.
- THIRD_PARTY.md: rdna2_hlsl.py is listed as importing cfg_structure.py; the
  typed-memory row no longer says "measured by Leonida"; the Leonida and
  Mesa descriptor rows say what the code now cites.

Comments only; no behaviour change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:40:36 +00:00
Author
Owner

@⁠LooperSalty on GitHub · 2026-11-25 21:45 UTC · original

Thanks for taking this on. Some Leonida references remain outside the files this PR touches: rdna2_buffer_format.py (lines 18-27, 163, 258), rdna2_exec_format.py (7-18), rdna2_hlsl_format.py (49), rdna2_image.py (6-9), rdna2_hlsl.py (5, 288-290) and rdna2_spirv.py (1-5, 22, 57-117, code that imports third_party/leonida), and tests/test_rdna2_exec_format.py (157). Could you re-source these to AMD's RDNA 2 ISA, LLVM's tests or our own measurements (saying how each was obtained), or narrow this PR's title to the files it covers and open a follow-up for the rest? Removing the code dependency on third_party/leonida can be a separate PR.

**@⁠LooperSalty** on GitHub · 2026-11-25 21:45 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/252#issuecomment-7175501717) Thanks for taking this on. Some Leonida references remain outside the files this PR touches: `rdna2_buffer_format.py` (lines 18-27, 163, 258), `rdna2_exec_format.py` (7-18), `rdna2_hlsl_format.py` (49), `rdna2_image.py` (6-9), `rdna2_hlsl.py` (5, 288-290) and `rdna2_spirv.py` (1-5, 22, 57-117, code that imports `third_party/leonida`), and `tests/test_rdna2_exec_format.py` (157). Could you re-source these to AMD's RDNA 2 ISA, LLVM's tests or our own measurements (saying how each was obtained), or narrow this PR's title to the files it covers and open a follow-up for the rest? Removing the code dependency on `third_party/leonida` can be a separate PR.
Author
Owner

@⁠KainanP on GitHub · 2026-11-25 22:22 UTC · original

Updated (one commit, 50edfe1, rebased on main 9a06443):

  • rdna2_buffer_format.py (18-27, 163, 258) and rdna2_exec_format.py (7-18): Leonida is gone. MTBUF format and selectors, the INVALID format, SEL_1 out of range and the all-or-nothing range check now cite AMD's RDNA 2 ISA, §8.1.4 table 31 (p. 59) and §8.1.5 notes 1 and 3 (p. 62). The UNORM rounding, 16-bit FLOAT NaN widening, integer store saturation and the 1.0/1 value of SEL_1 are labelled assumed. DST_SEL_Z = Z/W stores stay refused, because nothing documents them.
  • rdna2_hlsl_format.py (49): the comment states the identity it uses instead of naming Leonida.
  • tests/test_rdna2_exec_format.py (157): comment reworded.
  • Title narrowed to these files. rdna2_image.py, rdna2_hlsl.py (cfg_structure import) and rdna2_spirv.py are other contributors' code and a code dependency, so they are listed in follow-up issue #262.

AI use: Claude Code (Claude Opus 5.5).

**@⁠KainanP** on GitHub · 2026-11-25 22:22 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/252#issuecomment-7176281653) Updated (one commit, `50edfe1`, rebased on main `9a06443`): - `rdna2_buffer_format.py` (18-27, 163, 258) and `rdna2_exec_format.py` (7-18): Leonida is gone. MTBUF format and selectors, the INVALID format, SEL_1 out of range and the all-or-nothing range check now cite AMD's RDNA 2 ISA, §8.1.4 table 31 (p. 59) and §8.1.5 notes 1 and 3 (p. 62). The UNORM rounding, 16-bit FLOAT NaN widening, integer store saturation and the 1.0/1 value of SEL_1 are labelled assumed. DST_SEL_Z = Z/W stores stay refused, because nothing documents them. - `rdna2_hlsl_format.py` (49): the comment states the identity it uses instead of naming Leonida. - `tests/test_rdna2_exec_format.py` (157): comment reworded. - Title narrowed to these files. `rdna2_image.py`, `rdna2_hlsl.py` (`cfg_structure` import) and `rdna2_spirv.py` are other contributors' code and a code dependency, so they are listed in follow-up issue #262. _AI use: Claude Code (Claude Opus 5.5)._
Author
Owner

@⁠KainanP on GitHub · 2026-11-25 23:25 UTC · original

Updated: rebased on main 3e258c8, with a new commit 6fb5569 on top of 18a7bc0. The PR now covers every file in your list, so I widened the title again.

  • rdna2_buffer_format.py, rdna2_exec_format.py, rdna2_hlsl_format.py, tests/test_rdna2_exec_format.py: unchanged since my last reply (RDNA 2 ISA §8.1.4/§8.1.5, or labelled assumed).
  • rdna2_image.py (6-9): each T#/S# field now cites the RDNA 2 ISA, §8.2.6 table 45 (p. 75) and §8.2.7 table 46 (p. 76-77). The format codes cite §8.2.8 table 47 (p. 78-79). Every position and value in the code matches these tables. Table 46 gives no values for the border colour types, so 0/1/2 cite Mesa's SQ_TEX_BORDER_COLOR enum (gfx6.json, MIT). Leonida's gfx10_descriptors.h and the copied gfx10_formats.json stay credited as GPL-3.0 code and data. The JSON is identical to Mesa's GFX10_FORMAT enum.
  • rdna2_hlsl.py (5, 288-290) and rdna2_spirv.py (1-5, 22, 57-117): the comments now describe cfg_structure.py and rdna2spirv.py as frozen, unmodified GPL-3.0 copies in third_party/leonida/ (credited in THIRD_PARTY.md), not as a measurement source. The import and the SPIR-V path are unchanged; as you suggested, removing that dependency is left to #262.
  • THIRD_PARTY.md: lists rdna2_hlsl.py as importing cfg_structure.py, and no longer says "measured by Leonida".

No behaviour change. Nothing new is labelled assumed in this round. Full suite on the RTX: 1404 passed, 17 skipped. Ruff passes.

AI use: Claude Code (Claude Opus 5.5).

**@⁠KainanP** on GitHub · 2026-11-25 23:25 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/252#issuecomment-7177550645) Updated: rebased on main `3e258c8`, with a new commit `6fb5569` on top of `18a7bc0`. The PR now covers every file in your list, so I widened the title again. - `rdna2_buffer_format.py`, `rdna2_exec_format.py`, `rdna2_hlsl_format.py`, `tests/test_rdna2_exec_format.py`: unchanged since my last reply (RDNA 2 ISA §8.1.4/§8.1.5, or labelled assumed). - `rdna2_image.py` (6-9): each T#/S# field now cites the RDNA 2 ISA, §8.2.6 table 45 (p. 75) and §8.2.7 table 46 (p. 76-77). The format codes cite §8.2.8 table 47 (p. 78-79). Every position and value in the code matches these tables. Table 46 gives no values for the border colour types, so 0/1/2 cite Mesa's `SQ_TEX_BORDER_COLOR` enum (`gfx6.json`, MIT). Leonida's `gfx10_descriptors.h` and the copied `gfx10_formats.json` stay credited as GPL-3.0 code and data. The JSON is identical to Mesa's `GFX10_FORMAT` enum. - `rdna2_hlsl.py` (5, 288-290) and `rdna2_spirv.py` (1-5, 22, 57-117): the comments now describe `cfg_structure.py` and `rdna2spirv.py` as frozen, unmodified GPL-3.0 copies in `third_party/leonida/` (credited in THIRD_PARTY.md), not as a measurement source. The import and the SPIR-V path are unchanged; as you suggested, removing that dependency is left to #262. - `THIRD_PARTY.md`: lists `rdna2_hlsl.py` as importing `cfg_structure.py`, and no longer says "measured by Leonida". No behaviour change. Nothing new is labelled assumed in this round. Full suite on the RTX: 1404 passed, 17 skipped. Ruff passes. _AI use: Claude Code (Claude Opus 5.5)._
Author
Owner

@⁠LooperSalty on GitHub · 2026-11-26 00:06 UTC · original

Thanks for starting this. Rule 2 needs the Leonida references gone, and 224 remain on this branch (242 on main), including live imports of third_party/leonida: PrototypeScarlett/emu/rdna2_hlsl.py:288-294 and :358, emu/rdna2_spirv.py:62-64, scarlett.py:287, tests/test_rdna2_hlsl_cfg.py:3, plus the THIRD_PARTY rows and site/index.html. Could you rewrite it so the code no longer imports third_party/leonida (replace or drop the paths that need it, with tests), re-source the remaining claims to AMD's RDNA 2 ISA, LLVM's tests or our own measurements (saying how each was obtained), and remove the folder and its credits? Splitting it into a code PR and a docs PR is fine.

**@⁠LooperSalty** on GitHub · 2026-11-26 00:06 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/252#issuecomment-7178408746) Thanks for starting this. Rule 2 needs the Leonida references gone, and 224 remain on this branch (242 on main), including live imports of `third_party/leonida`: `PrototypeScarlett/emu/rdna2_hlsl.py:288-294` and `:358`, `emu/rdna2_spirv.py:62-64`, `scarlett.py:287`, `tests/test_rdna2_hlsl_cfg.py:3`, plus the THIRD_PARTY rows and `site/index.html`. Could you rewrite it so the code no longer imports `third_party/leonida` (replace or drop the paths that need it, with tests), re-source the remaining claims to AMD's RDNA 2 ISA, LLVM's tests or our own measurements (saying how each was obtained), and remove the folder and its credits? Splitting it into a code PR and a docs PR is fine.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/252/head:github-bot/gh-252'
git switch 'github-bot/gh-252'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-252'
git switch 'github-bot/gh-252'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-252'
git switch 'github-bot/gh-252'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-252'
git switch 'main'
git merge --squash 'github-bot/gh-252'
git switch 'main'
git merge --ff-only 'github-bot/gh-252'
git switch 'main'
git merge 'github-bot/gh-252'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.