Skip to content

rdna2spirv: refuse --out that is the input folder - #3633

Closed
Kam471 wants to merge 1 commit into
ItsNotRexed:mainfrom
Kam471:build-1044-rdna-out-input
Closed

Kam471 wants to merge 1 commit into
ItsNotRexed:mainfrom
Kam471:build-1044-rdna-out-input

Conversation

@Kam471

@Kam471 Kam471 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

What

tools/rdna2spirv.py wrote translations into the input folder when --out resolved to it (or a folder inside it), mixing generated files with the .s inputs and polluting a rerun.

The CLI now refuses that before makedirs, the index or any module is written:

  • --out equal to the input folder/file's folder, or inside it, prints one ERROR: line and exits 2.
  • The check uses the shared report_paths.same_report_path/path_key helpers (realpath, normcase, samefile, macOS case folding).
  • --merge is exempt: it does not read src, and merging shard outputs in place is the documented workflow.
  • Distinct output folders are unchanged.

Red before / green after

Red (tool stashed, new tests): 2 failures — return code 0 and translations written into disasm/; the distinct-output control passed.

Green: 3/3 new cases pass. tests/test_rdna2spirv_cli.py -> 28 OK, 1 skipped (no Windows symlink privilege); tests/test_rdna2spirv_merge.py -> 23 OK; tests/test_tool_startup.py -> 2 OK. tests/test_report_paths.py -> 14 OK, 1 skipped, 1 pre-existing Windows-only MacVolumeTests failure also present on the untouched base. compileall and git diff --check clean.

No game data. AI-assisted.

@javdc

javdc commented Nov 22, 2026

Copy link
Copy Markdown

Tested 05fe854 on Steam Deck LCD (Jupiter), AMD Custom GPU 0405 "Van Gogh", RADV Mesa 26.2.0-devel (git-5c65d4fc31), Vulkan 1.4.350, SteamOS 3.9.5 (holo), kernel 7.2.7-valve2-2-neptune-72-g31504582a073: pass

  • python3 -m pytest tests/test_rdna2spirv_cli.py -q -> 27 passed, 1 skipped, 22 subtests passed

CPU/CLI-only change; no GPU suite run.

AI-assisted (OpenCode).

@slopradish slopradish left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CPU-only review and local test run.

Checked out pull/3633/head in an isolated worktree and ran pytest -q tests/test_rdna2spirv_cli.py: 28 passed, 22 subtests passed.

The guard is placed correctly: after --merge (which is exempt because it writes in place) and before os.makedirs, so a refused run leaves no empty output folder. Using same_report_path for the equality case covers .., links and Windows case, and path_key for the containment test covers case-insensitive macOS volumes. The added test checks the negative cases and that a distinct output folder still translates, so the guard is not over-broad.

One observation, not a blocker: _out_inside_input computes folder = os.path.dirname(os.path.abspath(src)) for a single file, so an --out equal to the file's parent is refused — that is the documented intent ("a single file's folder is its input folder"), but worth keeping in the docstring, which it already is.

No GPU or game files used.

@TreXito

TreXito commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested 05fe8548 (base f847748c) on Linux (Ubuntu 26.04 container, Python 3.14.4), NVIDIA RTX 3060 Ti box: pass, and red/green reproduces.

AI-assisted (Claude Code). Synthetic test shaders only, no game files.

Translating with --out equal to the input disasm folder (or a folder inside it) wrote .spvasm/.spv/index.json among the .s inputs and exited 0. Resolve both paths and refuse with one ERROR line and exit 2 before mkdir or any output is written. The --merge path is exempt: it does not read src, and merging shard parts in place is how a shard run finishes.

Tests: out==input, out inside input, and a distinct out control.
@Kam471

Kam471 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (4c52ce2), clean. ests/test_rdna2spirv_cli.py 28 OK/1 skipped, est_rdna2spirv_merge.py 23 OK, est_tool_startup.py 2 OK. New head $new.

@JRamos1993

Copy link
Copy Markdown
Contributor

Tested 335f01a merged onto main aa2988c on an RTX 5090 (driver 616.92), Windows 11, Vulkan SDK 1.4.363. The GPU test programs were built from the same tree:

  • scripts/run_gpu_tests.py: 164/210 passed, 46 skipped, 0 failed. main aa2988c gives 164/210, 46 skipped, 0 failed. All 214 test shaders translate and pass spirv-val.
  • tests/test_rdna2spirv_cli.py: ran 28 tests in 9.119s; OK (skipped=1).

AI-assisted (Claude Code).

@Kam471

Kam471 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Already applied on main: tools/rdna2spirv.py has _out_inside_input and the --out refusal at lines 15806/15950 (with the --merge exemption), so rebasing this branch onto 7b7d73f89 leaves no commits. Closing as redundant.

@Kam471 Kam471 closed this Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants