VS-INPUT-SIGNATURE: select shared-hash vertex shaders by container signature #505

Closed
bobcatchris wants to merge 1 commit from upstream-pr/505 into main
bobcatchris commented 2026-11-24 06:32:14 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by bobcatchris on 2026-11-24T06:32:14Z.


Claimed in the coordination issue as: VS-INPUT-SIGNATURE

What and why

Two vertex shader containers can contain the same native program and the same semantic names while assigning POSITION and COLOR to different registers. The first entry in the shader index can then bind a translation whose input signature does not match the pipeline's input layout, and the draw produces the wrong result or nothing at all.

This records the ISG1 mask and rw_mask fields that shader_meta.py already emits, compares the PSO bytecode's ISG1 signature against shared-hash candidates, and keeps the existing layout-based fallback when the index has no complete match. It changes shader selection only where several candidates share a hash.

Carried from the source patch:
github.com/Sigtryggur-Mani-Gudmundsson/graphics-runtime-patches@33ab48d3ea/README.md (vertex-shader-selection-for-programs-with-shared-hashes)

No game data, keys, or decryption are included.

Tested

  • Built and ran shader_library_test from runtime with CMake/Ninja, RelWithDebInfo: OK
  • The added regression cases do not compile against unpatched main because the 3-argument candidates() API and signature comparison are absent; they pass with this change.
  • python -I tests/test_docs_links.py — OK
  • python -I tests/test_docs_cli_flags.py — OK
  • python -I tests/test_ci_registration.py — OK
  • python -m compileall -q tools tests — OK
  • git diff --check clean
  • patch and diff security sweeps: 0 hits

The source report measured a synthetic 64x64 Vulkan draw on an RTX 4070 Ti: the original lookup left all 4096 pixels at the clear color, while matching input signatures produced the expected output. I did not repeat that GPU measurement locally.

GPUs tested: n/a locally; source report used NVIDIA GeForce RTX 4070 Ti

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly.
  • One topic.
  • No game data, keys or decryption.
  • Regression tests added for shared-hash input-signature selection.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5467325346 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/505). Originally posted by [bobcatchris](https://github.com/bobcatchris) on 2026-11-24T06:32:14Z. --- Claimed in the coordination issue as: VS-INPUT-SIGNATURE ### What and why Two vertex shader containers can contain the same native program and the same semantic names while assigning POSITION and COLOR to different registers. The first entry in the shader index can then bind a translation whose input signature does not match the pipeline's input layout, and the draw produces the wrong result or nothing at all. This records the ISG1 mask and rw_mask fields that `shader_meta.py` already emits, compares the PSO bytecode's ISG1 signature against shared-hash candidates, and keeps the existing layout-based fallback when the index has no complete match. It changes shader selection only where several candidates share a hash. Carried from the source patch: https://github.com/Sigtryggur-Mani-Gudmundsson/graphics-runtime-patches/blob/33ab48d3ea90f9925351aeee8708181a71fb9634/README.md#vertex-shader-selection-for-programs-with-shared-hashes No game data, keys, or decryption are included. ### Tested - Built and ran `shader_library_test` from `runtime` with CMake/Ninja, RelWithDebInfo: OK - The added regression cases do not compile against unpatched `main` because the 3-argument `candidates()` API and signature comparison are absent; they pass with this change. - `python -I tests/test_docs_links.py` — OK - `python -I tests/test_docs_cli_flags.py` — OK - `python -I tests/test_ci_registration.py` — OK - `python -m compileall -q tools tests` — OK - `git diff --check` clean - patch and diff security sweeps: 0 hits The source report measured a synthetic 64x64 Vulkan draw on an RTX 4070 Ti: the original lookup left all 4096 pixels at the clear color, while matching input signatures produced the expected output. I did not repeat that GPU measurement locally. GPUs tested: n/a locally; source report used NVIDIA GeForce RTX 4070 Ti AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly. - [x] One topic. - [x] No game data, keys or decryption. - [x] Regression tests added for shared-hash input-signature selection.
PierreEbele commented 2026-11-24 21:54:02 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by PierreEbele on 2026-11-24T21:54:02Z.


Reviewed c0dd667e. Built shader_library_test natively on Linux arm64 (GCC, Ninja, Release) and ran it: passes (SHA-256, inflate ..., FSPX programs and index lookup OK). The PR's 3-arg candidates(...) call does not compile against main's runtime/src/shader_library.h, so the new test really exercises the change. Also: tests/test_shader_meta.py passes on PR and main; check_no_game_data is clean on the changed files; the test's synthetic container is read by shader_meta as COLOR/reg1/mask3/rw_mask1, matching every field matches_isg1 compares; a Python port of the filter reproduces the new test's outcomes and the fallback cases I could construct; git merge-tree into current main is clean.

One ask: cite the corpus count behind the shared-hash/divergent-register claim in docs/d3d12_vulkan.md (how many of the 789 shared-FSSM groups actually diverge), or state it as a hypothesis, per AGENTS.md. AI-assisted review.

Recommendation: Fix first

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7145536668 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/505#issuecomment-7145536668). Originally posted by [PierreEbele](https://github.com/PierreEbele) on 2026-11-24T21:54:02Z. --- Reviewed c0dd667e. Built `shader_library_test` natively on Linux arm64 (GCC, Ninja, Release) and ran it: passes (`SHA-256, inflate ..., FSPX programs and index lookup OK`). The PR's 3-arg `candidates(...)` call does not compile against main's `runtime/src/shader_library.h`, so the new test really exercises the change. Also: `tests/test_shader_meta.py` passes on PR and main; `check_no_game_data` is clean on the changed files; the test's synthetic container is read by `shader_meta` as COLOR/reg1/mask3/rw_mask1, matching every field `matches_isg1` compares; a Python port of the filter reproduces the new test's outcomes and the fallback cases I could construct; `git merge-tree` into current main is clean. One ask: cite the corpus count behind the shared-hash/divergent-register claim in `docs/d3d12_vulkan.md` (how many of the 789 shared-FSSM groups actually diverge), or state it as a hypothesis, per AGENTS.md. AI-assisted review. **Recommendation:** Fix first
bobcatchris commented 2026-11-24 23:42:47 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by bobcatchris on 2026-11-24T23:42:47Z.


Rebased on current main. Verified: shader_library_test passes, test_shader_meta.py 28/28, no-game-data and security checks clean.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7147710938 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/505#issuecomment-7147710938). Originally posted by [bobcatchris](https://github.com/bobcatchris) on 2026-11-24T23:42:47Z. --- Rebased on current main. Verified: shader_library_test passes, test_shader_meta.py 28/28, no-game-data and security checks clean.
PierreEbele commented 2026-11-24 23:50:15 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by PierreEbele on 2026-11-24T23:50:15Z.


Follow-up on bdc06d4c: it is a clean rebase of c0dd667e. The PR diff is the same apart from hunk offsets, and git merge-tree into current main is still clean, so the earlier shader_library_test result still applies. The one open item from the previous review isn't addressed yet. The new docs/d3d12_vulkan.md paragraph ("Several vertex shaders can share that payload ... assigning its semantics to different registers") still gives no corpus count (how many of the shared-FSSM groups actually diverge on input registers). Either add the count or word the paragraph as a hypothesis, per AGENTS.md. AI-assisted review.

Recommendation: Fix first

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7147850000 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/505#issuecomment-7147850000). Originally posted by [PierreEbele](https://github.com/PierreEbele) on 2026-11-24T23:50:15Z. --- Follow-up on bdc06d4c: it is a clean rebase of c0dd667e. The PR diff is the same apart from hunk offsets, and `git merge-tree` into current main is still clean, so the earlier `shader_library_test` result still applies. The one open item from the previous review isn't addressed yet. The new `docs/d3d12_vulkan.md` paragraph ("Several vertex shaders can share that payload ... assigning its semantics to different registers") still gives no corpus count (how many of the shared-FSSM groups actually diverge on input registers). Either add the count or word the paragraph as a hypothesis, per AGENTS.md. AI-assisted review. **Recommendation:** Fix first
MoonEyes commented 2026-11-28 17:58:24 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T17:58:24Z.


Hi @bobcatchris, thanks for this pull request. It currently conflicts with main (conflicting file(s): runtime/shims/d3d12_vulkan_device.cpp), so it carries the needs rebase label. CONTRIBUTING.md asks authors to rebase their branch on main; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7243429639 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/505#issuecomment-7243429639). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T17:58:24Z. --- Hi @bobcatchris, thanks for this pull request. It currently conflicts with `main` (conflicting file(s): `runtime/shims/d3d12_vulkan_device.cpp`), so it carries the `needs rebase` label. CONTRIBUTING.md asks authors to rebase their branch on `main`; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here. AI-assisted (Claude Code, Claude Opus 5.5).
bobcatchris commented 2026-11-29 13:11:09 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by bobcatchris on 2026-11-29T13:11:09Z.


Rebased cleanly onto current main (cc0f662a7, head cff9f5468). Re-verified shader_library_test (PASS) on Windows 11. AI-assisted: Antigravity (Gemini 4 Neon).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7256350862 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/505#issuecomment-7256350862). Originally posted by [bobcatchris](https://github.com/bobcatchris) on 2026-11-29T13:11:09Z. --- Rebased cleanly onto current main (cc0f662a7, head cff9f5468). Re-verified shader_library_test (PASS) on Windows 11. AI-assisted: Antigravity (Gemini 4 Neon).
bobcatchris commented 2026-11-29 16:28:53 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by bobcatchris on 2026-11-29T16:28:53Z.


@PierreEbele Addressed your review item in 17bde25e: measured across the full 1.0.2.1 shaders.rpf corpus (2,236 vertex shaders) — 78 FSSM hashes are shared across 196 containers, with

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7258936877 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/505#issuecomment-7258936877). Originally posted by [bobcatchris](https://github.com/bobcatchris) on 2026-11-29T16:28:53Z. --- @PierreEbele Addressed your review item in 17bde25e: measured across the full 1.0.2.1 shaders.rpf corpus (2,236 vertex shaders) — 78 FSSM hashes are shared across 196 containers, with
bobcatchris commented 2026-11-29 18:50:16 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by bobcatchris on 2026-11-29T18:50:16Z.


Temporarily closing to free the open-PR slot for fresh d3d12 fixes; rebased branch ertex-input-signature (17bde25e) remains intact and can be reopened anytime.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7260798285 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/505#issuecomment-7260798285). Originally posted by [bobcatchris](https://github.com/bobcatchris) on 2026-11-29T18:50:16Z. --- Temporarily closing to free the open-PR slot for fresh d3d12 fixes; rebased branch ertex-input-signature (17bde25e) remains intact and can be reopened anytime.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!505
No description provided.