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

Open
github-bot wants to merge 1 commit from github-bot/gh-505 into main AGit
Owner

@⁠bobcatchris on GitHub · 2026-11-24 06:32 UTC · original
bobcatchris:vertex-input-signature → main · +112 −5 · 4 files · 1 commits · open

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.
**@⁠bobcatchris** on GitHub · 2026-11-24 06:32 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/505) `bobcatchris:vertex-input-signature` → `main` · +112 −5 · 4 files · 1 commits · open 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.
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. Compare the ISG1 input signature recorded by shader_meta.py against the PSO bytecode when several candidates share a hash, and keep the existing layout-based fallback when no indexed signature matches.

Carried from the source patch by the graphics-runtime-patches collection:
33ab48d3ea/README.md (vertex-shader-selection-for-programs-with-shared-hashes)

AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:04:41 +00:00
Author
Owner

@⁠PierreEbele on GitHub · 2026-11-24 21:54 UTC · original

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

**@⁠PierreEbele** on GitHub · 2026-11-24 21:54 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/505#issuecomment-7145536668) 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
Author
Owner

@⁠bobcatchris on GitHub · 2026-11-24 23:42 UTC · original

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

**@⁠bobcatchris** on GitHub · 2026-11-24 23:42 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/505#issuecomment-7147710938) Rebased on current main. Verified: shader_library_test passes, test_shader_meta.py 28/28, no-game-data and security checks clean.
Author
Owner

@⁠PierreEbele on GitHub · 2026-11-24 23:50 UTC · original

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

**@⁠PierreEbele** on GitHub · 2026-11-24 23:50 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/505#issuecomment-7147850000) 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
This pull request has changes conflicting with the target branch.
  • runtime/shims/d3d12_vulkan_device.cpp
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/505/head:github-bot/gh-505'
git switch 'github-bot/gh-505'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-505'
git switch 'github-bot/gh-505'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-505'
git switch 'github-bot/gh-505'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-505'
git switch 'main'
git merge --squash 'github-bot/gh-505'
git switch 'main'
git merge --ff-only 'github-bot/gh-505'
git switch 'main'
git merge 'github-bot/gh-505'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.