fix: drop the code dependency on third_party/leonida (HLSL structurer, SPIR-V path) #342
No reviewers
Labels
No labels
accessibility
bloqué : binaire console
bug
chargeur
console-dll
cpu
documentation
duplicate
enhancement
good first issue
gpu
help wanted
invalid
performance
question
runtime-gdk
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LooperSalty--AnyXboxX!342
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/342/head"
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?
@KainanP on GitHub · 2026-11-26 09:38 UTC · original
KainanP:fix/drop-leonida-code→main· +87 −27395 · 36 files · 1 commits · merged 2026-11-26 10:42 UTCChange
Code half of the Leonida removal asked on #252 (rule 2): nothing imports
third_party/leonidaany more, and the folder is gone. The docs and credits half is #252 (it is rebased on this branch).emu/rdna2_hlsl.py): thecfg_structureimport and the structured path are removed. What is left is our own lowering:pc), as before;[loop] while (pc != END_PC)with anif (pc == <offset>u) { ... }guard per basic block; each block ends withpc = <next>u; continue;, a branch, orfinish.switch (pc)fallback because WARP crashes on theswitch: with aswitchinside that loop,anyxboxx_gpu_run.exeexits with 0xC0000005 on WARP when a block holds a group barrier (the wave64Ballot64). Measured:test_vccnz_loop_runs_until_every_lane_is_done,test_divergent_exec_across_both_halves_matches(wave64) andtest_gpu_matches_interpreter_and_exact_rounding_on_memory_operandsfailed on WARP with theswitchversion and pass with the guards; RTX and Intel passed with both.cible de branchement invalide : <offset>). The oldswitchfallback had lost that check when the structured path was added.emu/rdna2_spirv.py(a wrapper around Leonida's translator),tools/fssm_mesure.py(it only measured that translator) and their tests.scarlett.py --rdna2 <shader.bin> --spirvis refused by name (exit 2,--spirv : le traducteur SPIR-V a été retiré (#262) ; utilisez --hlsl) and not silently ignored (rule 3).third_party/leonida/deleted, with its THIRD_PARTY.md row, its AGENTS.md layout row and the SPIR-V row of the nine READMEs (row counts stay in sync).Linked issue: Fixes #262. Refs #252.
Cost of dropping the structurer
All the HLSL handed to dxc during a full RTX run was recorded, before (
mainc4c93bd) and after. 132 distinct shaders each time; 123 are byte-identical (every straight-line program). The 9 that differ are the programs with branches:test_gpu_matches_interpreter_and_exact_rounding_on_memory_operands(was structured)test_scalar_loop_and_divergence_match(was structured)test_nested_loops_and_branch_match_interpreter(was structured)test_if_else_diamond_matches_interpreter, s4 = 0 / 1 (was structured)test_irreducible_cfg_matches_interpreter, two inputs (wasswitch)test_divergent_exec_across_both_halves_matches(wave64, was structured)test_vccnz_loop_runs_until_every_lane_is_done(wave64, was structured)So: DXIL +2 % to +11 % on branchy programs, dxc +0 to +7 ms, and no GPU parity difference (every parity test passes on the three adapters, below). These are small test programs; on large console shaders the dispatch loop could cost more at run time (one loop iteration and a guard chain per block taken, which the driver may or may not fold). That is not measured here. A clean-room structurer written from published algorithms (for example reducible-CFG structuring from the compiler literature, not from Leonida's code) could come later as a separate PR, measured against this baseline.
Verification
Full suite, one adapter at a time, runtime built from this branch's
runtime/(unchanged frommain):(The WARP and Intel runs were taken before the last test,
test_spirv_option_is_refused_by_name, was added; it does not touch the GPU.) The count drops by the removed SPIR-V andfssm_mesuretests (2 of the skips werespirv-as/spirv-valchecks); 1654 collected, so the READMEs' "1600+" stays.Oracle and test data
HLSL translation: compared with the reference interpreter, byte for byte, by the existing parity tests (unchanged: nested loops, if/else diamond, two-entry loop, wave64 loops, FMA on memory operands).
tests/test_rdna2_hlsl_cfg.pynow checks the lowering itself: straight-line programs (wave32 and wave64) have nopcloop; a branch back to the start, if/else, nested loops and a two-entry loop give onewhile (pcloop withif (pc == ...)guards and noswitch; a branch past the end is refused; graphics stages have noswitchorbreak;. All test programs are built in the tests.Failure cases: without the guard chain, the three WARP tests above fail; without the target check,
test_branch_outside_the_program_is_refusedfails; without the--spirvrefusal,test_spirv_option_is_refused_by_namefails.Checklist
third_party/leonida).E_NOTIMPL), never a fake success:--spirvis refused by name.test_readme_sync.pychecks it).Made with AI assistance: Claude Code with Claude Opus 5.5, for KainanP.
🤖 Generated with Claude Code