Skip to content

Maintainability suggestions from a read-through of main (b0f3d399) #1928

Backlog

Description

@thegameur9740-code

Suggestions from a static read-through of main at b0f3d399. Nothing was built or run, and no game files were involved; the numbers are line/occurrence counts over tracked files. This write-up was AI-assisted. None of it is claimed work: take what is useful, close the rest.

1. Very large single files

File Lines
tools/rdna2spirv.py 19,750 (one method, _insn, is about 5,000 lines)
runtime/shims/d3d12_vulkan_device.cpp 18,465
runtime/shims/d3d12_xs_device.cpp 6,756
runtime/src/vulkan_replay.h 5,305 (implementation in a header)

Splitting by family (instruction groups in the translator; resources / pipelines / command lists in the device) would make reviews smaller and reduce the rebase conflicts that the needs rebase label exists to handle.

2. runtime/CMakeLists.txt is 295 KB

308 add_executable, 421 add_test, 246 target_link_libraries, and no function() or macro(). A helper such as leonida_add_test(name SOURCES ... LIBS ...) that also applies the common /W4 /permissive- /utf-8 options would shrink it a lot and keep flags consistent across targets.

3. Flat folders and repeated helpers

  • tests/ has 547 entries at one level, tools/ 287, runtime/test/ 378.
  • The same small helpers are redefined per tool: _u32 in 19 files, same_output_path in 13 (although tools/report_paths.py already exists for this), self_test in 43.
  • 1,051 Python files call sys.path.insert. A package layout with a shared module would remove most of them and still work with python -I.

4. No style or lint configuration

There is no pyproject.toml, ruff config, .clang-format, .clang-tidy or .editorconfig. The C++ targets use /W4 but I found no /WX / -Werror, so new warnings can land unnoticed. A formatter config alone would cut noise in diffs from many contributors.

5. CI

  • The standard-library tests run one file at a time in a serial bash loop on windows-latest with a 15-minute timeout; running them in parallel (as scripts/run_semantic_tests.py already does for the translator suite) would give headroom as the count grows.
  • Whether a file is a pytest file is decided by a regex over its contents (PYTEST_FILE_MARKERS). A naming convention or a folder would be less fragile.

6. Documentation

  • docs/design.md (605 KB) and docs/d3d12_vulkan.md (519 KB) are hard to read, diff and review as single files; splitting by topic with an index would help.
  • README.md still cites #166, #313 and links to ItsNotRexed/Leonida issue comments (#644, #881) as evidence, which CONTRIBUTING.md says no longer resolve.
  • Several cells of the README status table hold a full paragraph; a short status plus a link to the note would read better.

7. Small things

  • 27 broad except Exception: in make_game.py, tools/ and scripts/; some may hide real errors.
  • navmeshes.navmesh-decode.json sits at the repository root; it looks like it belongs under docs/ or outside the repo.
  • assets/logo.png is 447 KB next to a 140 KB SVG of the same logo.

What already looks good

Actions pinned by commit SHA, no shell=True / eval / pickle in the tools, viewer/serve.py binds to loopback and guards against DNS rebinding, and the no-game-data check in CI.

Activity

  1. BubsMcgee commented on Nov 25, 2026

    @BubsMcgee
    Contributor

    Verified the write-up against origin/main at 9e7720c9e (the base moved past b0f3d399; the line counts still hold within a few lines). Triage in the order I would take it, with what is safe while ~120 PRs are open:

    Safe now (taken)

    Needs one owner and a dedicated PR (do not batch)

    • runtime/CMakeLists.txt helper: mechanical and valuable, but it rewrites every target's declaration; needs a build + ctest parity check before/after and will collide with any PR adding a target.
    • CI: the serial stdlib loop and the PYTEST_FILE_MARKERS regex are real, but parallelising changes failure attribution and flake; measure one baseline run first.

    Wait for the PR queue (the split itself is the hazard)

    • tools/rdna2spirv.py, runtime/shims/d3d12_vulkan_device.cpp, d3d12_xs_device.cpp, runtime/src/vulkan_replay.h: splitting them now rebases most of the open D3D12/shader PRs. If a split is needed sooner, it must be pure move + no renames in one commit so git blame/-M can follow it, and it should be announced in the coordination issue first.
    • docs/design.md / docs/d3d12_vulkan.md splits have the same problem with the docs PRs; an index-only change is the low-risk half.

    Still true, separate docs PR

    • README dead evidence links: ItsNotRexed/Leonida#166, #313, #644, #881 (README lines 39, 64-66, 73, 92, 309, 318). CONTRIBUTING.md already explains they no longer resolve, and the GPU-results/lead content lives in docs/testing.md and docs/boot_leads.md now. Note d3d12: serialize and deserialize XDXR acceleration structures (RT-XDXR-SERIALIZE) #626 also edits README.md, so coordinate.
    • The except Exception: sites (27) are per-site decisions, not a batch: each needs to say what it now catches or converts to a narrower type.

    The two items in #1956 are deliberately the smallest ones; the rest is prioritisation, not discovery.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions