Shaders: match DXIL validator layout for ISG1/OSG1 signatures #124

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

@⁠vicennpacheco on GitHub · 2026-11-24 21:40 UTC · original
vicennpacheco:fix/isg1-validation → main · +174 −6 · 2 files · 1 commits · open

Summary

Addresses dxil.dll signature validation failures of the form:

Container part 'Program Input Signature' does not match expected for module.

(and the matching Program Output Signature error), as reported in #53.

Root causes found against dxil.dll 10.0.26100.0

In crates/victory-shader/src/emit/container.rs (signature()), three differences from DXIL's reconstructed ISG1/OSG1 triggered validation failures even when D3D12 still created the pipeline:

  1. Same-row sort order: rows were sorted by (row, col) instead of row alone. When two packed elements share a register with the higher column listed first (e.g. col = 2 before col = 0), dxil.dll keeps element order within the row.
  2. System-value name casing: system values (kind != 0) wrote e.name verbatim (e.g. SV_POSITION, SV_TARGET, SV_ISFRONTFACE), whereas dxil.dll writes DXIL's canonical mixed-case semantic names (SV_Position, SV_Target, SV_IsFrontFace, ...).
  3. Unallocated element column shift: when row == None (StartRow = -1, StartCol = -1 in signature_md), mask() and usage still shifted by e.col instead of 0.

(Note: this was reproduced and verified with synthetic shaders and dxil.dll 10.0.26100.0 without game files, so I have not tested the specific shader hash from #53 directly — hence linking #53 rather than auto-closing it.)

Tests

Tested on Windows 11, AMD Radeon Vega 8 iGPU (Ryzen 7 5825U, GCN 5 / gfx90c, AMD driver 31.0.21921.13001), Windows SDK dxil.dll 10.0.26100.0, Rust 1.98.1 (x86_64-pc-windows-msvc), without game files:

  • Added emit::container::tests::signature_keeps_same_row_order_canonical_sv_names_and_unalloc_mask
  • Added emit::barycentric_tests::signature_parts_match_dxil_validator (all 3 cases failed with the exact #53 error before the fix and pass after)
  • cargo test -p victory-shader --lib -- emit::container emit::barycentric_tests emit::tests: 23 passed, 0 failed
  • cargo clippy -p victory-shader --tests -- -D warnings: clean

(AI-assisted investigation and patch.)

**@⁠vicennpacheco** on GitHub · 2026-11-24 21:40 UTC · [original](https://github.com/fxceless/victory-fork/pull/124) `vicennpacheco:fix/isg1-validation` → `main` · +174 −6 · 2 files · 1 commits · open ### Summary Addresses `dxil.dll` signature validation failures of the form: ```text Container part 'Program Input Signature' does not match expected for module. ``` (and the matching `Program Output Signature` error), as reported in #53. ### Root causes found against `dxil.dll` 10.0.26100.0 In `crates/victory-shader/src/emit/container.rs` (`signature()`), three differences from DXIL's reconstructed `ISG1`/`OSG1` triggered validation failures even when D3D12 still created the pipeline: 1. **Same-row sort order:** rows were sorted by `(row, col)` instead of `row` alone. When two packed elements share a register with the higher column listed first (e.g. `col = 2` before `col = 0`), `dxil.dll` keeps element order within the row. 2. **System-value name casing:** system values (`kind != 0`) wrote `e.name` verbatim (e.g. `SV_POSITION`, `SV_TARGET`, `SV_ISFRONTFACE`), whereas `dxil.dll` writes DXIL's canonical mixed-case semantic names (`SV_Position`, `SV_Target`, `SV_IsFrontFace`, ...). 3. **Unallocated element column shift:** when `row == None` (`StartRow = -1`, `StartCol = -1` in `signature_md`), `mask()` and `usage` still shifted by `e.col` instead of `0`. *(Note: this was reproduced and verified with synthetic shaders and `dxil.dll` 10.0.26100.0 without game files, so I have not tested the specific shader hash from #53 directly — hence linking #53 rather than auto-closing it.)* ### Tests Tested on Windows 11, AMD Radeon Vega 8 iGPU (Ryzen 7 5825U, GCN 5 / `gfx90c`, AMD driver `31.0.21921.13001`), Windows SDK `dxil.dll` `10.0.26100.0`, Rust `1.98.1` (`x86_64-pc-windows-msvc`), without game files: - Added `emit::container::tests::signature_keeps_same_row_order_canonical_sv_names_and_unalloc_mask` - Added `emit::barycentric_tests::signature_parts_match_dxil_validator` (all 3 cases failed with the exact `#53` error before the fix and pass after) - `cargo test -p victory-shader --lib -- emit::container emit::barycentric_tests emit::tests`: 23 passed, 0 failed - `cargo clippy -p victory-shader --tests -- -D warnings`: clean *(AI-assisted investigation and patch.)*
`dxil.dll` rejects containers with
"Container part 'Program Input/Output Signature' does not match expected
for module" when `ISG1`/`OSG1` diverges from what DXIL reconstructs from
the module metadata.

Fix three mismatches in `container::signature`:
- Sort signature rows by register only (preserving element order within
  the same register instead of sorting by `(row, col)`).
- Emit DXIL's canonical system-value semantic names when `kind != 0`
  (e.g. `SV_Position`, `SV_Target`, `SV_IsFrontFace`) instead of raw
  input casing (e.g. `SV_POSITION`, `SV_TARGET`).
- Do not shift `mask` or `usage` by `col` for unallocated elements
  (`row == None`), matching `StartCol = -1` in the module metadata.

Related to #53.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:36:34 +00:00
Author
Owner

@⁠adriaespii on GitHub · 2026-11-24 21:52 UTC · original

Independent test run on commit 3ed5e89 (AMD RDNA4):

  • Hardware: AMD Radeon RX 9070 (driver 32.0.32015.7029), AMD Ryzen 5 7600, Windows 11 Pro, Rust 1.98.1 (x86_64-pc-windows-msvc)
  • cargo clippy --workspace --all-targets -- -D warnings: 0 warnings
  • cargo test --workspace: 498 passed, 0 failed, 7 ignored (victory-shader: 212 passed, 0 failed, 2 ignored; victory-gpu: 110 passed, 0 failed, 1 ignored)
  • Not tested: retail shader pack / live game run (no game files on this machine)

AI use: Antigravity (Gemini 4 Neon) ran clippy/tests locally and wrote this report.

**@⁠adriaespii** on GitHub · 2026-11-24 21:52 UTC · [original](https://github.com/fxceless/victory-fork/pull/124#issuecomment-7145493292) Independent test run on commit `3ed5e89` (AMD RDNA4): - **Hardware:** AMD Radeon RX 9070 (driver 32.0.32015.7029), AMD Ryzen 5 7600, Windows 11 Pro, Rust 1.98.1 (`x86_64-pc-windows-msvc`) - `cargo clippy --workspace --all-targets -- -D warnings`: 0 warnings - `cargo test --workspace`: 498 passed, 0 failed, 7 ignored (`victory-shader`: 212 passed, 0 failed, 2 ignored; `victory-gpu`: 110 passed, 0 failed, 1 ignored) - **Not tested:** retail shader pack / live game run (no game files on this machine) *AI use: Antigravity (Gemini 4 Neon) ran clippy/tests locally and wrote this report.*
Author
Owner

@⁠arminkhaleghirod on GitHub · 2026-11-24 22:23 UTC · original

Merged onto main 90228a7 and ran victory translate --validate over the full title (26,148 programs) on Windows 11 / RTX 4080.

Clears the 39 Program Output Signature and 33 Program Input Signature mismatches. On main those 72 programs then fall into the blanket PSV mismatch (17,359 → 17,431), so the gain only shows on top of #61. #124, #110 and #112 give identical counts here, so they look like they overlap.

**@⁠arminkhaleghirod** on GitHub · 2026-11-24 22:23 UTC · [original](https://github.com/fxceless/victory-fork/pull/124#issuecomment-7146175985) Merged onto main 90228a7 and ran `victory translate --validate` over the full title (26,148 programs) on Windows 11 / RTX 4080. Clears the 39 `Program Output Signature` and 33 `Program Input Signature` mismatches. On main those 72 programs then fall into the blanket PSV mismatch (17,359 → 17,431), so the gain only shows on top of #61. #124, #110 and #112 give identical counts here, so they look like they overlap.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

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