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

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

@⁠gdawid9407 on GitHub · 2026-11-24 22:21 UTC · original
gdawid9407:fix/isg1-signature-order → main · +109 −7 · 1 files · 1 commits · open

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.
**@⁠gdawid9407** on GitHub · 2026-11-24 22:21 UTC · [original](https://github.com/fxceless/victory-fork/pull/189) `gdawid9407:fix/isg1-signature-order` → `main` · +109 −7 · 1 files · 1 commits · open ### 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`.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:37:51 +00:00
Author
Owner

@⁠kaayzouee on GitHub · 2026-11-25 01:37 UTC · original

Duplicate of #110?

**@⁠kaayzouee** on GitHub · 2026-11-25 01:37 UTC · [original](https://github.com/fxceless/victory-fork/pull/189#issuecomment-7149755419) Duplicate of #110?
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/189/head:github-bot/gh-189'
git switch 'github-bot/gh-189'

Merge

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