Shaders: signature rows of one register in the validator's order #1022

Closed
ThiagoAlexsander wants to merge 1 commit from upstream-pr/1022 into main
ThiagoAlexsander commented 2026-11-24 15:08:50 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by ThiagoAlexsander on 2026-11-24T15:08:50Z.


36 emitted programs fail validation with Container part 'Program Input Signature' does not match expected for module (15) or ... 'Program Output Signature' ... (21), reported in #201. The validator rebuilds ISG1/OSG1 from the module's signature metadata and compares the bytes. The two disagree on the order of rows within one register.

Cause

DXC's DxilProgramSignatureWriter sorts the rows with sort_sig: by stream, then register, then semantic name offset, not by column (lib/DxilContainer/DxilContainerAssembler.cpp). With validator 1.6 names are not deduplicated by content: each arbitrary semantic gets its own offset in element order, and system values share theirs, as the comment in signature already says. So rows of one register keep element order. signature sorted them by column.

The two orders differ when a register's elements are declared in another order than their columns. In VS_RasterizeWaterIndirectHW_MeshBased_Meshlets, for example, register 5 holds TEXCOORD3 in w, declared before NORMAL0 in xyz. The metadata lists TEXCOORD3 first and OSG1 listed NORMAL0 first.

Change

One sort key in container::signature: (register, name offset) instead of (register, column). The comment now says how the validator orders rows.

Results

victory translate --validate over the title's files (main ffe310e against this branch, Windows SDK dxil.dll 10.0.26100), compared program by program:

main this branch
vertex/pixel validated 12,167 12,199
mesh validated 8,152 8,156
Container part ... does not match 36 0

All 36 now validate. No other program changes. The D3D12 runtime already created pipelines for these modules (#201), so this makes the container agree with the module rather than unblock pipelines.

Testing

  • New rows_of_one_register_keep_element_order_not_column_order in emit/container.rs: a w element declared before an xyz element of the same register is written first. With main's key it fails ([(0, 0), (0, 1), (3, 1)] against [(0, 0), (3, 1), (0, 1)]).
  • cargo test --workspace --locked: 343 passed, 0 failed, 6 ignored (342 on main plus the new test). That includes the GPU tests that create graphics pipelines from translated signatures.
  • cargo clippy --workspace --all-targets --locked -- -D warnings, with and without --all-features: clean. rustfmt --edition 2024 --check on container.rs: clean. cargo xtask policy: 154 files ok.

Related: #554 makes rows of one interpolation mode and notes that it uncovers some of these errors. It changes how elements get their rows, this changes the order they are written in, so the two fit together.

AI use: Claude Code (Claude Opus 5.5) traced the mismatch by comparing one failing module's metadata with its OSG1, checked DXC's sort, wrote the change and the test, and ran everything above. I reviewed the diff and the results.

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:6584909426 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1022). Originally posted by [ThiagoAlexsander](https://github.com/ThiagoAlexsander) on 2026-11-24T15:08:50Z. --- 36 emitted programs fail validation with `Container part 'Program Input Signature' does not match expected for module` (15) or `... 'Program Output Signature' ...` (21), reported in #201. The validator rebuilds `ISG1`/`OSG1` from the module's signature metadata and compares the bytes. The two disagree on the order of rows within one register. ## Cause DXC's `DxilProgramSignatureWriter` sorts the rows with `sort_sig`: by stream, then register, then **semantic name offset**, not by column (`lib/DxilContainer/DxilContainerAssembler.cpp`). With validator 1.6 names are not deduplicated by content: each arbitrary semantic gets its own offset in element order, and system values share theirs, as the comment in `signature` already says. So rows of one register keep element order. `signature` sorted them by column. The two orders differ when a register's elements are declared in another order than their columns. In `VS_RasterizeWaterIndirectHW_MeshBased_Meshlets`, for example, register 5 holds `TEXCOORD3` in w, declared before `NORMAL0` in xyz. The metadata lists `TEXCOORD3` first and `OSG1` listed `NORMAL0` first. ## Change One sort key in `container::signature`: `(register, name offset)` instead of `(register, column)`. The comment now says how the validator orders rows. ## Results `victory translate --validate` over the title's files (`main` `ffe310e` against this branch, Windows SDK `dxil.dll` 10.0.26100), compared program by program: | | `main` | this branch | |---|---|---| | vertex/pixel validated | 12,167 | 12,199 | | mesh validated | 8,152 | 8,156 | | `Container part ... does not match` | 36 | 0 | All 36 now validate. No other program changes. The D3D12 runtime already created pipelines for these modules (#201), so this makes the container agree with the module rather than unblock pipelines. ## Testing - New `rows_of_one_register_keep_element_order_not_column_order` in `emit/container.rs`: a w element declared before an xyz element of the same register is written first. With `main`'s key it fails (`[(0, 0), (0, 1), (3, 1)]` against `[(0, 0), (3, 1), (0, 1)]`). - `cargo test --workspace --locked`: 343 passed, 0 failed, 6 ignored (342 on `main` plus the new test). That includes the GPU tests that create graphics pipelines from translated signatures. - `cargo clippy --workspace --all-targets --locked -- -D warnings`, with and without `--all-features`: clean. `rustfmt --edition 2024 --check` on `container.rs`: clean. `cargo xtask policy`: 154 files ok. Related: #554 makes rows of one interpolation mode and notes that it uncovers some of these errors. It changes how elements get their rows, this changes the order they are written in, so the two fit together. AI use: Claude Code (Claude Opus 5.5) traced the mismatch by comparing one failing module's metadata with its `OSG1`, checked DXC's sort, wrote the change and the test, and ran everything above. I reviewed the diff and the results. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Zipettte commented 2026-11-24 16:05:17 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T15:40:16Z.


Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 57e2cde: cargo test -p victory-shader passes, 121 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7136416379 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1022#issuecomment-7136416379). Originally posted by [Zipettte](https://github.com/Zipettte) on 2026-11-24T15:40:16Z. --- Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 57e2cde: `cargo test -p victory-shader` passes, 121 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed). _Tested with AI assistance (Claude)._
catminou4 commented 2026-11-24 17:03:00 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T16:28:55Z.

Review: APPROVED


Signature rows of one register now sort by name offset (element order) instead of column, matching the validator's sort_sig; comment documents the rule precisely. New container test pins TEXCOORD-before-NORMAL ordering. Local verification: macOS arm64, rustc 1.98.1, PR head merged into main ffe310e, cargo test -p <crate> --locked. Shader execution tests (valu_tests/host) are #[cfg(all(test, windows))], so macOS covers lowering/decode/unit tests only. victory-shader: 97 passed, 0 failed.

<!-- greyfinch-sync:Marvisak/VIctory:review:6043261982 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1022#pullrequestreview-6043261982). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T16:28:55Z. **Review:** APPROVED --- Signature rows of one register now sort by name offset (element order) instead of column, matching the validator's sort_sig; comment documents the rule precisely. New container test pins TEXCOORD-before-NORMAL ordering. Local verification: macOS arm64, rustc 1.98.1, PR head merged into main ffe310e, `cargo test -p <crate> --locked`. Shader execution tests (valu_tests/host) are `#[cfg(all(test, windows))]`, so macOS covers lowering/decode/unit tests only. victory-shader: 97 passed, 0 failed.
mercuryVM commented 2026-11-24 17:03:00 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T16:44:07Z.

Review: APPROVED


Tested 57e2cdee on Windows 11, RTX 5070, MSVC:

  • cargo test -p victory-shader -- --test-threads=1 passes on the head (121 passed, 1 ignored).
  • Merged into our fork: workspace tests, shader tests and clippy -D warnings (default and all features) are all clean.

The change matches DXC. sort_sig in DxilContainerAssembler orders by stream, then register, then the SemanticName field, which is the name's offset in the string table. It does not sort by column, so keying the sort on offsets[i] reproduces it, including system values sharing their first offset. The new test checks the case that mattered: a .w element declared before the .xyz of the same register.

A static measurement on a full game package, counts only, with translate --validate --list before and after this PR:

  • Programs failing with Program Input/Output Signature does not match: 53 → 0.
  • All 53 now stop at the next container check, Pipeline State Validation does not match. So this frees no program yet, but it removes the first blocker.
  • No program that validated before stops validating.

The PSV part probably needs the same row order in its signature element table, if that table is built from a separately ordered list.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6043497868 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1022#pullrequestreview-6043497868). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T16:44:07Z. **Review:** APPROVED --- Tested 57e2cdee on Windows 11, RTX 5070, MSVC: - `cargo test -p victory-shader -- --test-threads=1` passes on the head (121 passed, 1 ignored). - Merged into our fork: workspace tests, shader tests and `clippy -D warnings` (default and all features) are all clean. The change matches DXC. `sort_sig` in DxilContainerAssembler orders by stream, then register, then the `SemanticName` field, which is the name's offset in the string table. It does not sort by column, so keying the sort on `offsets[i]` reproduces it, including system values sharing their first offset. The new test checks the case that mattered: a `.w` element declared before the `.xyz` of the same register. A static measurement on a full game package, counts only, with `translate --validate --list` before and after this PR: - Programs failing with `Program Input/Output Signature does not match`: 53 → 0. - All 53 now stop at the next container check, `Pipeline State Validation does not match`. So this frees no program yet, but it removes the first blocker. - No program that validated before stops validating. The PSV part probably needs the same row order in its signature element table, if that table is built from a separately ordered list. AI-assisted (Claude Code).
upstream-sync closed this pull request 2026-11-25 01:05:18 +00:00
Marvisak commented 2026-11-25 01:07:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:30:26Z.


Automated triage for the maintainers. Closing because this change is already in main, or main has since replaced the code it patches.

Signature rows are sorted by register only with element order kept in main (emit/container.rs signature(), stable sort; 13091f6e), which is what this PR arrives at.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148579522 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1022#issuecomment-7148579522). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:30:26Z. --- Automated triage for the maintainers. Closing because this change is already in `main`, or `main` has since replaced the code it patches. Signature rows are sorted by register only with element order kept in main (emit/container.rs signature(), stable sort; 13091f6e), which is what this PR arrives at. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

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
Marvisak/VIctory!1022
No description provided.