[PR #289] [CLOSED] shader_disasm: hand llvm-mc its input in lines of 64 bytes, not one long line (up to ~380x faster, identical output) #340

Closed
opened 2026-11-26 20:17:33 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/289
Author: @Andretuta
Created: 11/24/2026
Status: ❌ Closed

Base: main ← Head: old-pr/10020


📝 Commits (1)

  • f550251 shader_disasm: hand llvm-mc its input in lines of 64 bytes, not one long line

📊 Changes

2 files changed (+76 additions, -1 deletions)

View changed files

➕ tests/test_shader_disasm_input_lines.py (+73 -0)
📝 tools/shader_disasm.py (+3 -1)

📄 Description

Carried over from old PR 10020 by beamdotdev in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/10020, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
beamdotdev: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

Item: new BUILD item, claimed in the coordination issue: https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7117003507

Depends on: none (applies to main).

Why

tools/shader_disasm.py's disasm() joins a program's bytes with spaces into one line of hex and hands it to llvm-mc. llvm-mc slows down sharply on one long input line, so large programs took tens of seconds each. That makes make_game.py's pipeline-library step (2,684 compute programs from shaders.rpf) run at about one program per minute: in one run, 994 programs in about an hour, with about 1,700 left.

What

  • disasm() passes the same bytes in lines of 64 bytes. Inputs of up to 64 bytes, the s_endpgm probe among them, are unchanged.
  • tests/test_shader_disasm_input_lines.py: stubs subprocess.run and checks the text llvm-mc would receive (lines of at most 64 bytes, the same bytes in order, a partial last line, no empty or trailing lines, short inputs unchanged). Standard library only; no llvm-mc, no game data. Red without the change (2 of 4 fail), green with it.

Same output

Byte-identical disassembly: the same .s text and the same count of undecodable words. Only the line/column numbers in llvm-mc's diagnostics differ. make_game.py already fingerprints shader_disasm.py for the library, FSPX, BVH and exe steps, so those rerun once after this; the main corpus's disassembly and translation do not.

Measured with the old and new disasm() side by side on six real library programs (own 1.0.2.1 copy; sizes and timings only):

program size before after output
256 B 0.02 s 0.01 s identical
1,536 B 0.02 s 0.01 s identical
13,568 B 4.45 s 0.03 s identical
60,904 B 2.37 s 0.06 s identical
88,128 B 42.35 s 0.11 s identical
120,064 B 28.39 s 0.12 s identical

The library step's unpack and disassembly then took about 1.5 minutes for all 2,684 programs.

Tested

Windows 11, i5-9600K, Python 3.14.10, native llvm-mc 21.1.8 (AMDGPU, built with scripts/build_llvm_mc.ps1).

  • python -I tests/test_shader_disasm_input_lines.py: 4/4.
  • test_shader_disasm.py (30), test_fssm_crosscheck.py (6), test_shader_stage_resume.py (46), test_fspx_shaders_stage.py (23): OK.
  • test_bvh_shaders_stage.py (test_the_builder_runs_after_fspx_and_alone_when_only_its_dll_changes) and test_rdna2_decode.py (test_parity_with_llvm_mc_on_shader_fixtures) fail once each, identically on main without this change.
  • python -m compileall -q make_game.py tools tests: clean.
  • A full make_game.py --stages check,shaders on a work folder (ladder-frame base): library 1,538 of 2,684 translated and all 1,538 pass spirv-val; BVH 52/52; exe 10/10. The untranslated library programs are translator gaps, unrelated to this change.

AI-assisted (Claude Code).

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/289 **Author:** [@Andretuta](https://github.com/Andretuta) **Created:** 11/24/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `old-pr/10020` --- ### 📝 Commits (1) - [`f550251`](https://github.com/ubiquitarianism/leonida/commit/f5502513a77eaeac5372eba5927f0d471f622691) shader_disasm: hand llvm-mc its input in lines of 64 bytes, not one long line ### 📊 Changes **2 files changed** (+76 additions, -1 deletions) <details> <summary>View changed files</summary> ➕ `tests/test_shader_disasm_input_lines.py` (+73 -0) 📝 `tools/shader_disasm.py` (+3 -1) </details> ### 📄 Description > Carried over from **old PR 10020** by `beamdotdev` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/10020`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > `beamdotdev`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): Item: new BUILD item, claimed in the coordination issue: https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7117003507 Depends on: none (applies to `main`). ## Why `tools/shader_disasm.py`'s `disasm()` joins a program's bytes with spaces into **one** line of hex and hands it to `llvm-mc`. `llvm-mc` slows down sharply on one long input line, so large programs took tens of seconds each. That makes `make_game.py`'s pipeline-library step (2,684 compute programs from `shaders.rpf`) run at about one program per minute: in one run, 994 programs in about an hour, with about 1,700 left. ## What - `disasm()` passes the same bytes in lines of 64 bytes. Inputs of up to 64 bytes, the `s_endpgm` probe among them, are unchanged. - `tests/test_shader_disasm_input_lines.py`: stubs `subprocess.run` and checks the text `llvm-mc` would receive (lines of at most 64 bytes, the same bytes in order, a partial last line, no empty or trailing lines, short inputs unchanged). Standard library only; no `llvm-mc`, no game data. Red without the change (2 of 4 fail), green with it. ## Same output Byte-identical disassembly: the same `.s` text and the same count of undecodable words. Only the line/column numbers in `llvm-mc`'s diagnostics differ. `make_game.py` already fingerprints `shader_disasm.py` for the library, FSPX, BVH and exe steps, so those rerun once after this; the main corpus's disassembly and translation do not. Measured with the old and new `disasm()` side by side on six real library programs (own 1.0.2.1 copy; sizes and timings only): | program size | before | after | output | |---:|---:|---:|---| | 256 B | 0.02 s | 0.01 s | identical | | 1,536 B | 0.02 s | 0.01 s | identical | | 13,568 B | 4.45 s | 0.03 s | identical | | 60,904 B | 2.37 s | 0.06 s | identical | | 88,128 B | 42.35 s | 0.11 s | identical | | 120,064 B | 28.39 s | 0.12 s | identical | The library step's unpack and disassembly then took about 1.5 minutes for all 2,684 programs. ## Tested Windows 11, i5-9600K, Python 3.14.10, native `llvm-mc` 21.1.8 (AMDGPU, built with `scripts/build_llvm_mc.ps1`). - `python -I tests/test_shader_disasm_input_lines.py`: 4/4. - `test_shader_disasm.py` (30), `test_fssm_crosscheck.py` (6), `test_shader_stage_resume.py` (46), `test_fspx_shaders_stage.py` (23): OK. - `test_bvh_shaders_stage.py` (`test_the_builder_runs_after_fspx_and_alone_when_only_its_dll_changes`) and `test_rdna2_decode.py` (`test_parity_with_llvm_mc_on_shader_fixtures`) fail once each, identically on `main` without this change. - `python -m compileall -q make_game.py tools tests`: clean. - A full `make_game.py --stages check,shaders` on a work folder (ladder-frame base): library 1,538 of 2,684 translated and all 1,538 pass `spirv-val`; BVH 52/52; exe 10/10. The untranslated library programs are translator gaps, unrelated to this change. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:17:33 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#340
No description provided.