Skip to content

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

Closed
ThiagoAlexsander wants to merge 1 commit into
Marvisak:mainfrom
ThiagoAlexsander:shader/signature-row-order
Closed

ThiagoAlexsander wants to merge 1 commit into
Marvisak:mainfrom
ThiagoAlexsander:shader/signature-row-order

Conversation

@ThiagoAlexsander

Copy link
Copy Markdown
Contributor

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

The validator rebuilds ISG1/OSG1 from the module's signatures and
compares bytes. It sorts rows by register, then by semantic name offset
(DXC's sort_sig), not by column: with validator 1.6 every arbitrary
semantic has its own name, so rows of one register keep element order.
We sorted them by column, and a register whose elements come in another
order (a w channel declared before the xyz of the same register) failed
with "Container part 'Program Input/Output Signature' does not match
expected for module".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Zipettte

Copy link
Copy Markdown

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 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 mercuryVM left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested 57e2cde 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).

mercuryVM added a commit to mercuryVM/VIctory that referenced this pull request Nov 24, 2026
…ter in the validator's order

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 24, 2026
github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 24, 2026
mercuryVM added a commit to mercuryVM/VIctory that referenced this pull request Nov 25, 2026
Where a fork-only change duplicates upstream's own version of a feature,
upstream's is kept and the fork's dropped:
- victory-shader is upstream's crate with the fork-only merges replayed
  onto it oldest first; those that do not apply onto upstream are dropped
  (37 of 63: among them Marvisak#704/raw views, gather4_l, the lane-mask and Marvisak#308
  ports, Marvisak#947, Marvisak#1022, Marvisak#1112, Marvisak#1090, Marvisak#1182). Marvisak#284 (legacy fused madds) and
  Marvisak#98 (permlane16 in whole-wave sections) are dropped too: the first
  disagrees with upstream's hardware-checked model, the second refused 46
  programs upstream translates.
- translate: upstream's --cache replaces Marvisak#254's write-cache and work queue;
  Marvisak#378, Marvisak#517, Marvisak#673 and the victory.toml console are re-applied.
- victory-gpu: upstream's stride table, page table and heap views replace
  the fork's Marvisak#704/stride-table wiring; fork-only fixes re-applied on top.

Package (shaders.rpf, translate --validate --list, counts): vertex/pixel
emitted 12559 -> 14295 of 14337, compute 2359 -> 2628 validated, mesh
2730 -> 2811 validated. Tests: the failures left (rect fourth corner,
two stride tests, row order, gather4 at a level, memory table, dynamic
heap slots) fail on upstream main as well on this host.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Marvisak

Copy link
Copy Markdown
Owner

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; 13091f6), 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.

@Marvisak Marvisak closed this Nov 25, 2026
github-actions Bot pushed a commit to KevinPratap/VIctory that referenced this pull request Nov 25, 2026
Validator 1.6 orders the rows of one register by semantic name offset
(DXC's `sort_sig`: stream, register, name). `signature` kept element
order, which is the same order except where a system value repeats: its
later elements share the first one's name, so they sort before an
arbitrary semantic declared between them. With SV_ClipDistance1 packed
into a row after a TEXCOORD, the validator refused the container
("Container part 'Program Output Signature' does not match expected for
module").

The key is the one Marvisak#1022 proposed.

Test: `packed_signature_rows_follow_system_value_name_order`, both
declaration orders through dxil.dll.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants