Shaders: signature rows of one register follow their name offsets #2793

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

@⁠Moon0755 on GitHub · 2026-11-25 20:42 UTC · original
Moon0755:fix/signature-row-name-offset → main · +79 −2 · 2 files · 1 commits · open

Follow-up to #1022, which was closed as already in main. One case is not.

Problem

container::signature sorts the rows by register and keeps element order within a register (a stable sort). DXC orders them with sort_sig: stream, then register, then semantic name offset (lib/DxilContainer/DxilContainerAssembler.cpp). With validator 1.6 each arbitrary semantic gets its own name in element order and a system value's elements share one name, so the two orders are the same until a system value repeats. Its later elements carry the offset of the first one, written before the names of everything declared in between, and DXC puts them first.

So with SV_ClipDistance1 packed into a row after a TEXCOORD, OSG1 has TEXCOORD first, the validator's rebuilt part has SV_ClipDistance1 first, and the container is refused:

error: Container part 'Program Output Signature' does not match expected for module.

#1022 changed the key from (register, column) to (register, name offset); main arrived at register alone with element order kept, and the triage note there says the two are the same. They differ in this case only.

Fix

The key #1022 proposed: (register, name offset). One line.

Test

emit::tests::packed_signature_rows_follow_system_value_name_order builds the same vertex shader twice through Shader and validates both with dxil.dll: with SV_ClipDistance1 declared before the TEXCOORD it shares a row with (a control: both orders agree), and after it.

Verification

GitHub Actions on windows-latest, on the fork, with the jobs narrowed to victory-shader and xtask; the validator ran in both (the control prints that it validated):

  • the test without the change (run 45694251414): the control validates, the second order fails with the message above, 270 passed; 1 failed;
  • with the change (run 45695097663): both validate, clippy in both profiles passed, 271 passed; 0 failed; 3 ignored.

Not checked: the title's shaders. The case is synthetic; I do not know whether a program of the title declares its elements in this order, nor whether any of the signature mismatches still listed in #201 are this one.

Credit

The sort key is ThiagoAlexsander's from #1022. The case that tells it from a stable sort came out of comparing emit/container.rs with DXC's assembler; Devin wrote the test and ran both arms.

— Devin & Fable

**@⁠Moon0755** on GitHub · 2026-11-25 20:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/2793) `Moon0755:fix/signature-row-name-offset` → `main` · +79 −2 · 2 files · 1 commits · open Follow-up to #1022, which was closed as already in `main`. One case is not. ### Problem `container::signature` sorts the rows by register and keeps element order within a register (a stable sort). DXC orders them with `sort_sig`: stream, then register, then **semantic name offset** (`lib/DxilContainer/DxilContainerAssembler.cpp`). With validator 1.6 each arbitrary semantic gets its own name in element order and a system value's elements share one name, so the two orders are the same until a system value repeats. Its later elements carry the offset of the first one, written before the names of everything declared in between, and DXC puts them first. So with `SV_ClipDistance1` packed into a row after a `TEXCOORD`, `OSG1` has `TEXCOORD` first, the validator's rebuilt part has `SV_ClipDistance1` first, and the container is refused: ``` error: Container part 'Program Output Signature' does not match expected for module. ``` #1022 changed the key from `(register, column)` to `(register, name offset)`; `main` arrived at `register` alone with element order kept, and the triage note there says the two are the same. They differ in this case only. ### Fix The key #1022 proposed: `(register, name offset)`. One line. ### Test `emit::tests::packed_signature_rows_follow_system_value_name_order` builds the same vertex shader twice through `Shader` and validates both with `dxil.dll`: with `SV_ClipDistance1` declared before the `TEXCOORD` it shares a row with (a control: both orders agree), and after it. ### Verification GitHub Actions on `windows-latest`, on the fork, with the jobs narrowed to `victory-shader` and `xtask`; the validator ran in both (the control prints that it validated): - the test without the change ([run 45694251414](https://github.com/Moon0755/VIctory/actions/runs/45694251414)): the control validates, the second order fails with the message above, `270 passed; 1 failed`; - with the change ([run 45695097663](https://github.com/Moon0755/VIctory/actions/runs/45695097663)): both validate, clippy in both profiles passed, `271 passed; 0 failed; 3 ignored`. Not checked: the title's shaders. The case is synthetic; I do not know whether a program of the title declares its elements in this order, nor whether any of the signature mismatches still listed in #201 are this one. ### Credit The sort key is ThiagoAlexsander's from #1022. The case that tells it from a stable sort came out of comparing `emit/container.rs` with DXC's assembler; Devin wrote the test and ran both arms. — Devin & Fable
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 #1022 proposed.

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

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:14:22 +00:00
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 20:44 UTC · original

Subtle but right: validator 1.6 orders packed rows sharing a register by semantic-name offset, and the system-value name dedup means clip1 can reuse clip0's earlier offset - so a register-only sort misorders them relative to an intervening user element. The (row, name-offset) key matches, and the test builds the exact packing that exposes it against the real validator.

**@⁠kotekompotek** on GitHub · 2026-11-25 20:44 UTC · [original](https://github.com/Marvisak/VIctory/pull/2793#issuecomment-7174132239) Subtle but right: validator 1.6 orders packed rows sharing a register by semantic-name offset, and the system-value name dedup means clip1 can reuse clip0's earlier offset - so a register-only sort misorders them relative to an intervening user element. The (row, name-offset) key matches, and the test builds the exact packing that exposes it against the real validator.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 21:10 UTC · original

Reviewed and verified e1099890 on Windows 11 (Windows SDK 10.0.26100.0 dxil.dll) against main (13f91ca).

  • Sorting signature rows by (elements[i].row.unwrap_or(u32::MAX), offsets[i]) aligns with DXC's sort_sig ordering so shared system-value names (e.g. SV_ClipDistance0/1) stay ordered before user semantics (TEXCOORD) packed into the same register.
  • packed_signature_rows_follow_system_value_name_order (validated with dxil.dll for both control and reordered cases) + container::: 2/2 passed.
  • cargo clippy --locked -p victory-shader --all-targets -- -D warnings (default & --features host): 0 warnings; cargo xtask policy: 184 files ok; clean git merge-tree vs 13f91ca, #2798, and #2796.
**@⁠fuzeofficlal** on GitHub · 2026-11-25 21:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/2793#issuecomment-7174718848) Reviewed and verified `e1099890` on Windows 11 (Windows SDK `10.0.26100.0` `dxil.dll`) against `main` (`13f91ca`). - Sorting signature rows by `(elements[i].row.unwrap_or(u32::MAX), offsets[i])` aligns with DXC's `sort_sig` ordering so shared system-value names (e.g. `SV_ClipDistance0`/`1`) stay ordered before user semantics (`TEXCOORD`) packed into the same register. - `packed_signature_rows_follow_system_value_name_order` (validated with `dxil.dll` for both control and reordered cases) + `container::`: **2/2 passed**. - `cargo clippy --locked -p victory-shader --all-targets -- -D warnings` (default & `--features host`): **0 warnings**; `cargo xtask policy`: **184 files ok**; clean `git merge-tree` vs `13f91ca`, `#2798`, and `#2796`.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 23:22 UTC · original

Automated triage for the maintainers.

This PR changes the row sort key in container::signature (crates/victory-shader/src/emit/container.rs) from register alone to (register, name offset). A repeated system value such as SV_ClipDistance1 reuses an earlier name offset, so it has to come before a user element packed into the same register, which matches DXC's sort_sig ordering. The new packed_signature_rows_follow_system_value_name_order test runs both declaration orders through dxil.dll, and the linked fork runs show it failing without the change and passing with it. CI passes.

This is a recommendation for a maintainer to look, not an approval.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 23:22 UTC · [original](https://github.com/Marvisak/VIctory/pull/2793#issuecomment-7177462864) <!-- victory-triage v1 head=e109989053a94be4e1a867d7b2a9e7ebfedb9781 verdict=merge-candidate at=2026-11-25T23:21:55Z --> Automated triage for the maintainers. This PR changes the row sort key in `container::signature` (`crates/victory-shader/src/emit/container.rs`) from register alone to `(register, name offset)`. A repeated system value such as `SV_ClipDistance1` reuses an earlier name offset, so it has to come before a user element packed into the same register, which matches DXC's `sort_sig` ordering. The new `packed_signature_rows_follow_system_value_name_order` test runs both declaration orders through `dxil.dll`, and the linked fork runs show it failing without the change and passing with it. CI passes. This is a recommendation for a maintainer to look, not an approval. --- _Generated by [Claude Code](https://claude.ai/code)_
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/2793/head:github-bot/gh-2793'
git switch 'github-bot/gh-2793'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2793'
git switch 'github-bot/gh-2793'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2793'
git switch 'github-bot/gh-2793'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2793'
git switch 'main'
git merge --squash 'github-bot/gh-2793'
git switch 'main'
git merge --ff-only 'github-bot/gh-2793'
git switch 'main'
git merge 'github-bot/gh-2793'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2793
No description provided.