Shaders: signature rows of one register follow their name offsets #2791
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2793"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by Moon0755 on 2026-11-25T20:42:33Z.
Follow-up to #1022, which was closed as already in
main. One case is not.Problem
container::signaturesorts the rows by register and keeps element order within a register (a stable sort). DXC orders them withsort_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_ClipDistance1packed into a row after aTEXCOORD,OSG1hasTEXCOORDfirst, the validator's rebuilt part hasSV_ClipDistance1first, and the container is refused:#1022 changed the key from
(register, column)to(register, name offset);mainarrived atregisteralone 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_orderbuilds the same vertex shader twice throughShaderand validates both withdxil.dll: withSV_ClipDistance1declared before theTEXCOORDit 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 tovictory-shaderandxtask; the validator ran in both (the control prints that it validated):270 passed; 1 failed;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.rswith DXC's assembler; Devin wrote the test and ran both arms.— Devin & Fable
Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T20:44:52Z.
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.
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T21:10:49Z.
Reviewed and verified
e1099890on Windows 11 (Windows SDK10.0.26100.0dxil.dll) againstmain(13f91ca).(elements[i].row.unwrap_or(u32::MAX), offsets[i])aligns with DXC'ssort_sigordering 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 withdxil.dllfor 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; cleangit merge-treevs13f91ca,#2798, and#2796.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T23:22:03Z.
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 asSV_ClipDistance1reuses an earlier name offset, so it has to come before a user element packed into the same register, which matches DXC'ssort_sigordering. The newpacked_signature_rows_follow_system_value_name_ordertest runs both declaration orders throughdxil.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
Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-26T00:49:44Z.
Review: APPROVED
Verified against
origin/main(63bcca4) on Windows 11 + NVIDIA GeForce RTX 5090:emit::testsandemit::shadertests cleanly.cargo test -p victory-shader emit::tests: 18/18 passed (includingpacked_signature_rows_follow_system_value_name_order).cargo clippy -p victory-shader --all-targets -- -D warnings: 0 warnings.cargo xtask policy: 192 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-27T00:17:49Z.
Review: APPROVED
LGTM — verified
rustfmton the changed hunks,cargo xtask policy,cargo clippy(--all-targetsand--all-features), andemit::tests::(18 passed, includingpacked_signature_rows_follow_system_value_name_ordervalidated againstdxil.dll1.6).Sorting by
(row.unwrap_or(u32::MAX), offsets[i])cleanly resolves cases where a later system-value element reuses an earlier semantic name offset and shares a packed register with a user semantic. (One interestingdxil.dll1.6 quirk observed while stress-testing synthetic signatures: for> 32total signature elements with two same-semantic system values sharing one register, DXC 1.6'sstd::sortswitches from insertion sort to unstable introsort on tied(Register, Name)keys, which is upstream non-determinism outside real<= 32-register signatures.)View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.