spirv_asm: refuse an output that aliases the source (OLD-10025) #1254

Closed
github-bot wants to merge 4 commits from gh-pr/1254/head into gh-pr/1254/base
Owner

@⁠wetw0rks-c0ding on GitHub · 2026-11-24 20:55 UTC · original
wetw0rks-c0ding:restore/old-10025-spirv-asm-alias → main · +0 −0 · 0 files · 0 commits · closed without merging

Claimed in the coordination issue as: OLD-10025

What and why

tools/spirv_asm.py would overwrite its input file if the requested output aliased the source, destroying the assembly input. It now refuses such an output and a regression test pins the behaviour.

Tested

  • python3 -m unittest tests/test_spirv_asm.py -> Ran 38 tests, OK (exit 0)
  • python -I scripts/check_no_game_data.py tools/spirv_asm.py tests/test_spirv_asm.py -> clean (exit 0)
  • Environment: Linux (CachyOS), CPU-only tests, no GPU required

AI-assisted: Yes. This work was done with OpenCode agents.

**@⁠wetw0rks-c0ding** on GitHub · 2026-11-24 20:55 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1254) `wetw0rks-c0ding:restore/old-10025-spirv-asm-alias` → `main` · +0 −0 · 0 files · 0 commits · closed without merging Claimed in the coordination issue as: OLD-10025 ### What and why `tools/spirv_asm.py` would overwrite its input file if the requested output aliased the source, destroying the assembly input. It now refuses such an output and a regression test pins the behaviour. ### Tested - `python3 -m unittest tests/test_spirv_asm.py` -> Ran 38 tests, OK (exit 0) - `python -I scripts/check_no_game_data.py tools/spirv_asm.py tests/test_spirv_asm.py` -> clean (exit 0) - Environment: Linux (CachyOS), CPU-only tests, no GPU required AI-assisted: Yes. This work was done with OpenCode agents.
CommandList::barrier(TextureBarrier) refused LayoutAfter = UNDEFINED from a
defined layout, so the list's Close failed. D3D12 allows it: the contents are
no longer needed, as before the memory is aliased. WARP closes such a list
(measured on Windows 11 26340 in #984), and #984 reports that the retail title
ends a depth buffer's use this way and takes the failed Close as fatal.

The rule goes. Vulkan has no transition into UNDEFINED
(VUID-VkImageMemoryBarrier2-newLayout-01198), so replay gives each piece a
barrier with oldLayout = newLayout, the layout the tracker has for it, which
orders the accesses and changes nothing in the image; the tracker keeps the
layouts. A piece that was never used gets no barrier and is not zero-filled
for it. The next barrier starts from UNDEFINED and discards, as before.

UNDEFINED -> UNDEFINED is not touched here: that is #600.

The barrier half of item 2 of the split proposed in #984, carried onto main
from Moriz82's integration branch (command_list.h, the emit change and the
command_list_test, replay_texture_barrier_test and d3d12_close_parity_test
cases), restricted to a defined LayoutBefore, with more cases and two GPU
tests added.

Tests:
- command_list_test, replay_texture_barrier_test (CPU): the recorded barrier;
  kept layouts over mips in two layouts, with the discard flag and without a
  tracker; an unused image released without a barrier or a zero-fill; the
  barrier from UNDEFINED that follows.
- d3d12_close_parity_test: three enhanced-barrier rows (116 cases, 85 match).
- vk_command_replay_test part K (GPU): a colour target, a depth buffer whose
  planes are in two layouts and an unused image released; the target used
  again and read back.
- d3d12_com_test (GPU, D3D12 list and queue): a depth buffer cleared,
  released, taken from UNDEFINED again, cleared and read back.

Co-authored-by: Moriz82 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
main gained its own Part K in vk_command_replay_test and a sentence in the
same bullet of docs/d3d12_vulkan.md (D3D-838, pull request 751). Both stay as
they are on main; this branch's release test becomes Part L, and the doc
bullet for LayoutAfter = UNDEFINED names it so.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Brings the branch up to date with main 68d1331e5. No conflicts; the merged tree was tested before the push (every standalone
test file under tests/ passes except tests/test_ci_registration.py, which fails on main alone since #930).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
d3d12: an enhanced texture barrier into LAYOUT_UNDEFINED closes and keeps the layout (D3D-BARRIER-INTO-UNDEFINED)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:44:40 +00:00
github-bot closed this pull request 2026-11-26 09:44:40 +00:00
Author
Owner

@⁠fin-github on GitHub · 2026-11-24 21:48 UTC · original

This makes the same change as #938 (SPIRV-ASM-INPUT-ALIAS), which was opened about 5½ hours earlier: the added lines in tools/spirv_asm.py and tests/test_spirv_asm.py are identical. They probably both come from old upstream PR 10025. Only one of the two can merge. Could we keep #938 and close this one? If you'd rather carry it, say so and I'll close mine. AI-assisted (Claude Code).

**@⁠fin-github** on GitHub · 2026-11-24 21:48 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1254#issuecomment-7145421117) This makes the same change as #938 (`SPIRV-ASM-INPUT-ALIAS`), which was opened about 5½ hours earlier: the added lines in `tools/spirv_asm.py` and `tests/test_spirv_asm.py` are identical. They probably both come from old upstream PR 10025. Only one of the two can merge. Could we keep #938 and close this one? If you'd rather carry it, say so and I'll close mine. AI-assisted (Claude Code).
Author
Owner

@⁠nicoco23 on GitHub · 2026-11-24 22:09 UTC · original · requested changes

Reviewed the diff and ran the tests: python -m unittest tests/test_spirv_asm.py on Windows 11, Python 3.12, 38 tests, OK.

The check is in the right place (right after argument parsing, before the source is read), exits with 2 through ap.error and leaves the source untouched. same_report_path resolves both paths with realpath and falls back to samefile, so the hard link and symlink subtests are real checks rather than string comparisons.

Notes, none blocking:

  • The symlink and hard link subtests are skipped when the OS refuses them (typically symlinks on Windows without developer mode), so they may not run on every machine.
  • The test does not cover two paths that differ only by case on Windows or macOS. [same_report_path may already handle that through _resolved_key; a subtest would pin it.]
  • [One check is failing on the PR: . It looks unrelated to this change / I did not look into it.]

NOT AI-assisted review.

**@⁠nicoco23** on GitHub · 2026-11-24 22:09 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1254#pullrequestreview-6048199702) · **requested changes** Reviewed the diff and ran the tests: `python -m unittest tests/test_spirv_asm.py` on Windows 11, Python 3.12, 38 tests, OK. The check is in the right place (right after argument parsing, before the source is read), exits with 2 through ap.error and leaves the source untouched. same_report_path resolves both paths with realpath and falls back to samefile, so the hard link and symlink subtests are real checks rather than string comparisons. Notes, none blocking: - The symlink and hard link subtests are skipped when the OS refuses them (typically symlinks on Windows without developer mode), so they may not run on every machine. - The test does not cover two paths that differ only by case on Windows or macOS. [same_report_path may already handle that through _resolved_key; a subtest would pin it.] - [One check is failing on the PR: <name>. It looks unrelated to this change / I did not look into it.] NOT AI-assisted review.
Author
Owner

@⁠wetw0rks-c0ding on GitHub · 2026-11-24 23:33 UTC · original

Closing this as a duplicate: another contributor's #938 (spirv_asm: refuse an output that aliases the source, SPIRV-ASM-INPUT-ALIAS / DRAFT-293) came first and is already merged. Thanks for the contribution.

**@⁠wetw0rks-c0ding** on GitHub · 2026-11-24 23:33 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1254#issuecomment-7147530103) Closing this as a duplicate: another contributor's #938 (spirv_asm: refuse an output that aliases the source, SPIRV-ASM-INPUT-ALIAS / DRAFT-293) came first and is already merged. Thanks for the contribution.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.