Shaders: match DXC ISG1/OSG1 row tie-break order and canonical SV names (fixes #53) #189

Open
gdawid9407 wants to merge 1 commit from upstream-pr/189 into main
gdawid9407 commented 2026-11-24 22:21:57 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by gdawid9407 on 2026-11-24T22:21:57Z.


Problem

dxil.dll validates ISG1/OSG1 by running DxilProgramSignatureWriter over the module's entry-point metadata and memcmp-ing the serialized part (VerifySignatureMatches). Three edge cases caused container::signature to diverge from DXC (validator 1.6):

  1. Same-register tie-breaking (sort_sig): DXC's signature packer often packs an earlier narrow HLSL element into the upper columns of a register occupied by a later wider element (e.g. TEXCOORD0 at row 1, col 3 and TEXCOORD1 at row 1, col 0). DxilContainerAssembler's sort_sig orders elements sharing a register by (Stream, Register, SemanticName) (string-table byte offset), whereas container::signature sorted by (row, col), swapping the two rows in ISG1 while PSV0 and the D3D12 runtime still accepted the pipeline (#53).
  2. System-value names: DxilSignatureElement::GetName() always emits the canonical Semantic::ms_SemanticTable string (SV_Position, SV_IsFrontFace, SV_SampleIndex, ...) for non-arbitrary kinds regardless of input casing.
  3. Unallocated masks: When row.is_none() (!IsAllocated()), DXC leaves Mask and UsageMask unshifted (StartCol = 0).

Changes

  • Sort ISG1/OSG1 rows by (row.unwrap_or(u32::MAX), offsets[i]).
  • Emit canonical system-value strings in SigElement::semantic_name.
  • Shift component and usage masks by col only when row.is_some().
  • Add unit test signature_matches_dxc_row_order_and_canonical_system_names.
<!-- greyfinch-sync:fxceless/victory-fork:issue:6592583205 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/189). Originally posted by [gdawid9407](https://github.com/gdawid9407) on 2026-11-24T22:21:57Z. --- ### Problem `dxil.dll` validates `ISG1`/`OSG1` by running `DxilProgramSignatureWriter` over the module's entry-point metadata and `memcmp`-ing the serialized part (`VerifySignatureMatches`). Three edge cases caused `container::signature` to diverge from DXC (validator 1.6): 1. **Same-register tie-breaking (`sort_sig`):** DXC's signature packer often packs an earlier narrow HLSL element into the upper columns of a register occupied by a later wider element (e.g. `TEXCOORD0` at `row 1, col 3` and `TEXCOORD1` at `row 1, col 0`). `DxilContainerAssembler`'s `sort_sig` orders elements sharing a register by `(Stream, Register, SemanticName)` (string-table byte offset), whereas `container::signature` sorted by `(row, col)`, swapping the two rows in `ISG1` while `PSV0` and the D3D12 runtime still accepted the pipeline (#53). 2. **System-value names:** `DxilSignatureElement::GetName()` always emits the canonical `Semantic::ms_SemanticTable` string (`SV_Position`, `SV_IsFrontFace`, `SV_SampleIndex`, ...) for non-arbitrary kinds regardless of input casing. 3. **Unallocated masks:** When `row.is_none()` (`!IsAllocated()`), DXC leaves `Mask` and `UsageMask` unshifted (`StartCol = 0`). ### Changes - Sort `ISG1`/`OSG1` rows by `(row.unwrap_or(u32::MAX), offsets[i])`. - Emit canonical system-value strings in `SigElement::semantic_name`. - Shift component and usage masks by `col` only when `row.is_some()`. - Add unit test `signature_matches_dxc_row_order_and_canonical_system_names`.
kaayzouee commented 2026-11-25 02:10:08 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by kaayzouee on 2026-11-25T01:37:02Z.


Duplicate of #110?

<!-- greyfinch-sync:fxceless/victory-fork:comment:7149755419 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/189#issuecomment-7149755419). Originally posted by [kaayzouee](https://github.com/kaayzouee) on 2026-11-25T01:37:02Z. --- Duplicate of #110?
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/189:upstream-pr/189'
git switch 'upstream-pr/189'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/189'
git switch 'upstream-pr/189'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/189'
git switch 'upstream-pr/189'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/189'
git switch 'main'
git merge --squash 'upstream-pr/189'
git switch 'main'
git merge --ff-only 'upstream-pr/189'
git switch 'main'
git merge 'upstream-pr/189'
git push origin 'main'
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
fxceless/victory-fork!189
No description provided.