feat: structured control flow in HLSL recompiler (#68) #116
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!116
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/116/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?
@Lewandox on GitHub · 2026-11-23 23:56 UTC · original
Lewandox:feat/hlsl-structured-cfg→main· +241 −20 · 12 files · 3 commits · merged 2026-11-24 10:14 UTCFirst part of #68: replaces the flat
while (pc != END_PC) { switch (pc) ... }loop in the HLSL recompiler with structured control flow ([loop] whileloops andif (pc == ...)guards) usingthird_party/leonida/cfg_structure.py(Leonida, GPL-3.0).Changes
PrototypeScarlett/emu/rdna2_hlsl.py: splits decoded instructions into basic blocks (_build_blocks), structures the CFG viacfg_structure.structure(succ), and emits nested loops/guards (_emit_tree). Straight-line shaders no longer emit any loop orswitch (pc); irreducible CFGs cleanly fall back towhile+switch (pc).PrototypeScarlett/emu/rdna2_hlsl_graphics.py: usesreturn o_out;/return;fors_endpgmintranslate_vertexandtranslate_pixelinstead ofbreak;(which is invalid outside a loop).tests/test_rdna2_hlsl_cfg.pyandtests/test_rdna2_hlsl.py: tests covering straight-line code, if/else diamonds, nested loops, irreducible CFG fallback toswitch (pc), VS/PS graphics stages, and GPU/WARP execution against the reference interpreter.README.mdanddocs/i18n/README.*.md: updated test count (555 -> 561).Local verification
.venv\Scripts\python.exe -m pytest tests/test_rdna2_hlsl_cfg.py tests/test_readme_sync.py -v: 9 passed, 2 skipped (dxc/anyxboxx_gpu_run.exenot installed locally; Windows CI runs the full suite including GPU/WARP tests)..venv\Scripts\python.exe -m pytest tests/test_rdna2_hlsl.py tests/test_rdna2_graphics.py tests/test_rdna2_image.py tests/test_shader_cache.py -v: 22 passed (non-GPU tests)..venv\Scripts\python.exe -m ruff check --select W605,F,E9 PrototypeScarlett tests tools: All checks passed!No game, console, or SDK files used. AI-assisted contribution.
@Lewandox on GitHub · 2026-11-24 08:51 UTC · original
Rebased onto \main\ (with #120) and added @gpu\ interpreter-vs-GPU comparisons for both the if/else diamond (\ est_if_else_diamond_matches_interpreter) and the irreducible-CFG \switch (pc)\ fallback (\ est_irreducible_cfg_fallback_matches_interpreter), with README counts synced (553 -> 561).
@LooperSalty on GitHub · 2026-11-24 08:31 UTC · original · reviewed
Thanks! Tested locally (full pytest with dxc + anyxboxx_gpu_run.exe, ruff): all new tests pass, GPU test included; the 5 failures in
tests/test_native.pycome from our local runtime build, they also fail on main.One point for rule 4 (every HLSL translation checked against the reference interpreter on GPU/WARP): only the nested-loop case runs on the GPU. The if/else diamond and the irreducible-CFG fallback to
switch (pc)are only checked by searching strings in the HLSL. Could you add GPU comparisons for those two shapes intests/test_rdna2_hlsl_cfg.py?Note: CI was failing for every PR because the Leonida submodule's upstream repo was deleted; this is fixed in #120. Once it is merged, a rebase will bring CI back.
🤖 Generated with Claude Code