[PR #505] VS-INPUT-SIGNATURE: select shared-hash vertex shaders by container signature #553

Open
opened 2026-11-26 20:18:16 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/505
Author: @bobcatchris
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: vertex-input-signature


📝 Commits (1)

  • bdc06d4 d3d12: select shared-hash vertex shaders by container signature

📊 Changes

4 files changed (+112 additions, -5 deletions)

View changed files

📝 docs/d3d12_vulkan.md (+6 -0)
📝 runtime/shims/d3d12_vulkan_device.cpp (+4 -3)
📝 runtime/src/shader_library.h (+49 -2)
📝 runtime/test/shader_library_test.cpp (+53 -0)

📄 Description

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.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/505 **Author:** [@bobcatchris](https://github.com/bobcatchris) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `vertex-input-signature` --- ### 📝 Commits (1) - [`bdc06d4`](https://github.com/ubiquitarianism/leonida/commit/bdc06d4c790d70a90a3e933ed244d976d1b989fd) d3d12: select shared-hash vertex shaders by container signature ### 📊 Changes **4 files changed** (+112 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `docs/d3d12_vulkan.md` (+6 -0) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+4 -3) 📝 `runtime/src/shader_library.h` (+49 -2) 📝 `runtime/test/shader_library_test.cpp` (+53 -0) </details> ### 📄 Description 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#553
No description provided.