Skip to content

rdna2spirv: refuse a shader named by two --merge parts - #3306

Open
bobcatchris wants to merge 1 commit into
ItsNotRexed:mainfrom
bobcatchris:build/merge-duplicate-name
Open

bobcatchris wants to merge 1 commit into
ItsNotRexed:mainfrom
bobcatchris:build/merge-duplicate-name

Conversation

@bobcatchris

Copy link
Copy Markdown
Contributor

merge_shard_parts() combined the part documents with merged.update(doc). A shader listed by two index.part<i>.json files was silently last-wins: the later part's metadata and module were published under the name, the other part's .spv stayed behind under the same name, and the index said the corpus was complete. That only happens when the parts come from different runs, e.g. a re-carve that keeps the shard count and leaves older parts in place.

A name in two parts is now a ShardSetError naming the shader and both part files, with the fix (delete the parts and run every shard again): exit 2, no index.json. Independent of #2964 (a complete but empty set) and #3196 (an unreadable part); each touches different code in the same function.

python -I tests/test_rdna2spirv_merge.py — 25 tests OK (unit case for both differing and identical duplicates); python -I tests/test_rdna2spirv_cli.py — 18 OK. Synthetic parts only, no game files or GPU.

AI-assisted.

@Flyander Flyander left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed at 56019d7d6f17cca5c1fbf5612399aa0da83ab9e5.

  • python -I tests/test_rdna2spirv_merge.py — 25 tests passed.
  • python -I tests/test_rdna2spirv_cli.py — 18 tests passed.
  • Synthetic shard parts only; no game files or GPU used.

The duplicate-name check reports both source parts and refuses to publish a merged index before the conflicting data can be mislabeled. I found no correctness issue in this change.

@bobcatchris

Copy link
Copy Markdown
Contributor Author

Independent CPU verification of e64d05860d0025af4c1c45610b2238a1f600f86a against current main 03b09a086592a197db64d91655c6e65c30764d96 (AI-assisted, no GPU/game data).

I used a lightweight snapshot instead of a full worktree: git archive of tools/ from main into two scratch dirs, with only tools/rdna2spirv.py and tests/test_rdna2spirv_merge.py replaced by the PR blobs in the PR side.

  • PR snapshot: python -I tests/test_rdna2spirv_merge.py → 27/27 OK.
  • Base snapshot with the same test file: 25 passed / 2 failed. Both failures are the new duplicate-name cases (ShardSetError not raised), for differing and identical duplicate metadata.
  • No other merge tests changed behavior.

This confirms the duplicate-shader check lands exactly where intended and leaves the other 25 merge cases intact.

@rgvxsthi

Copy link
Copy Markdown
Contributor

Tested e64d0586 merged onto main d0835dd9 (6 commits behind; merges cleanly) on Windows 11 Pro 10.0.26300, Python 3.14.10, pytest from tests/requirements.txt: pass.

  • pytest tests/test_rdna2spirv_merge.py: 27 passed.
  • Negative control: the same tests with main's tools/rdna2spirv.py: 2 failed, 25 passed (the two new cases), so they catch the last-wins merge.

Heads-up: this and #3196 (also yours) both add tests at the same place in tests/test_rdna2spirv_merge.py. Merged together they conflict in that file only; tools/rdna2spirv.py merges automatically. Whichever lands second needs a trivial rebase. No game files. AI-assisted (Claude Code).

@bobcatchris

Copy link
Copy Markdown
Contributor Author

Rebased onto #3196's head at b943a296 so the two rdna2spirv --merge PRs no longer conflict with each other. The test conflict was purely additive: both test_a_part_that_is_not_json_is_named and test_a_shader_named_by_two_parts_is_refused are kept. python -m pytest -q tests/test_rdna2spirv_merge.py → 29 passed on Windows / CPython 3.12.0; compileall and scoped git diff --check clean; git merge-tree against both #3196's head and current main is clean. Merge order: #3196 first, then this one — that keeps #3306's own diff to the duplicate-name guard.

@cxchhh

cxchhh commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested b943a296 on Tesla V100-SXM2-32GB (Volta, subgroup 32..32), NVIDIA 580.95.05, Ubuntu 24.04 (kernel 6.14.11), Python 3.12: pass.

Setup: the PR diff applied to main 98fa503f (applies cleanly), Linux Vulkan test programs built from that tree (cmake -S runtime -G Ninja), compared against an untouched main 98fa503f built the same way.

  • scripts/run_gpu_tests.py: native 161/217 passed, 56 skipped; LEONIDA_W64_EMULATE=1 LEONIDA_BARY_FALLBACK=1 194/217 passed, 23 skipped. 0 failures, and the same per-test result as main in both modes (the skips are the 64-wide, mesh-shader (Volta has no VK_EXT_mesh_shader), barycentric-only and run by d3d12_* tests).
  • python -m unittest discover -s tests/semantic (llvm-mc 23.1.6, SPIRV-Tools 2026.4 on PATH): 6245 tests, failures=3, errors=2: the same five test_loop_ballot_barrier cases that fail on main here, nothing new.
  • tests/test_rdna2spirv_merge.py: 30 OK (main: 26). The PR's test file on main's tools/: 3 failures + 1 error, so the new cases catch the last-wins merge.

No game files. AI-assisted (Claude Code); I ran the commands above and checked the numbers against the logs.

@kapitche

Copy link
Copy Markdown
Contributor

Tested b943a29 merged with main 98fa503 (merged tree 7997391277) on Windows 11, RTX 4080 SUPER + Intel UHD 770 (MSVC 14.51), Python 3.13.1: pass.

  • tests/test_rdna2spirv_merge.py: 30 tests OK (the 4 new ones included).
  • scripts/run_gpu_tests.py with the PR's translator and a runtime built from main, per-case diff against main's run: NVIDIA 170/217 passed, 47 skipped, 0 failed; Intel 150/217 passed, 67 skipped, 0 failed. Both lists are identical to main's, case for case.
  • Control: main's tools/rdna2spirv.py with the PR's test file: 4 of the 30 fail (3 failures and 1 error: the two non-JSON-part tests and the two duplicate-shader tests).

@lunarminus

Copy link
Copy Markdown

Tested b943a296 merged onto main d0835dd9 on an AMD Radeon 760M (RDNA3 iGPU, gfx1103, subgroup 32..64), RADV Mesa 26.3.1, CachyOS Linux: pass

  • Merges cleanly. The merge brings in the three commits 9c6cf193, 4ffbc4e8 (both from rdna2spirv: name a part --merge cannot read instead of tracebacking #3196) and b943a296. The PR changes nothing under runtime/, so the GPU suite used the test programs built from d0835dd9.
  • python -I tests/test_rdna2spirv_merge.py: 29 tests OK (25 on d0835dd9).
  • Control: the PR's test file run against d0835dd9's tools/ gives 3 failures and 1 error. These are the two non-JSON-part tests and the two duplicate-shader tests, so the new cases catch the old behaviour.
  • python -I tests/test_rdna2spirv_cli.py: 25 OK, 1 skipped. pytest on both files: 53 passed, 1 skipped.
  • scripts/run_gpu_tests.py: 196/210 passed, 14 skipped, both with emulation off and with LEONIDA_W64_EMULATE=1. Every test has the same PASS/FAIL/SKIP result as d0835dd9 without the PR, in both modes. The PR adds no GPU fixtures.

No game files. AI-assisted (Claude Code).

@memorypressure

Copy link
Copy Markdown

Verified against main 3faac55: the branch merges cleanly and tests/test_rdna2spirv_merge.py runs 30/30 green under python -I (re-run on the merged tree), including the four new cases for a part that is not JSON and a shader named by two parts, at both API and CLI level. Main today has neither check (merge_shard_parts only names the plan/marker files on error), so this is not superseded. Nice touch that the refusals exit 2 with delete-this-part guidance and never write index.json. CI pending. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

@bobcatchris
bobcatchris force-pushed the build/merge-duplicate-name branch from b943a29 to 9320312 Compare November 23, 2026 15:41
@bobcatchris

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (56e607a) after #1864 and #1797 touched scripts/run_gpu_tests.py / tools/rdna2spirv.py; no conflicts.

Re-ran at this head: tests/test_rdna2spirv_merge.py 32 OK.

AI-assisted.

@ilyasssif

Copy link
Copy Markdown

Tested 932031269 on Fedora Linux 43 (CPython 3.14, CPU-only, no game files): pass.

  • python3 -m compileall -q tools/rdna2spirv.py tests/test_rdna2spirv_merge.py: pass
  • python3 -I tests/test_rdna2spirv_merge.py: 32/32 OK

AI-assisted.

@thiefyzheng

Copy link
Copy Markdown

checked: #3306 @ 9320312 — CPU only, no GPU: python3 -I tests/test_rdna2spirv_merge.py → exit 0, "Ran 32 tests in 3.329s / OK" (both new tests named ok: test_a_shader_named_by_two_parts_is_refused, test_cli_refuses_a_shader_named_by_two_parts). Ran in a fresh worktree at the PR head. AI-assisted.

@bobcatchris

Copy link
Copy Markdown
Contributor Author

Independent macOS code read and test run at head 9320312 (Apple M2, Python 3.13.18, llvm-mc 21.1.8). The translator now refuses a --merge part that names a shader already named by another part, before publishing an index that would silently drop one of them.

  • pytest -q tests/test_rdna2spirv_merge.py tests/test_translate.py: 674 passed, 2 subtests passed, 0 failed.
  • Full GPU suite with a shared harness binary: 176/237 passed, 59 skipped, 2 failed (cs_fma_fused, ps_ssharp); 0 per-test status differences against the same harness with current main's runner. The PR's base is older, hence the smaller total.

No issue found; synthetic listings only.

AI-assisted.

@SquishyGithub

Copy link
Copy Markdown

Tested 932031269 merged into main dde82f27e on NVIDIA GeForce RTX 3070 (Ampere), driver 620.70.06, Vulkan 1.4.357, subgroup 32..32, Linux (Bazzite 45; Fedora 45 distrobox, GCC 16.2.1, LLVM 23.1.5, SPIRV-Tools 2026.2, Python 3.15.2): pass

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.

10 participants