Shaders: PSV0 names every arbitrary element, as DXC does #3323

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

@⁠Moon0755 on GitHub · 2026-11-26 17:58 UTC · original
Moon0755:fix/psv0-semantic-names → main · +80 −13 · 1 files · 1 commits · open

Part of #1945 (the writer half).

What

container::psv looked a semantic name up in the string table before adding it, so a name used by two elements (TEXCOORD on an input and on an output) was written once and both elements pointed at it. Now every element with an arbitrary semantic and a non-empty name appends its own entry; system values and empty names still point at offset 0. find has no caller left and is removed. container.rs only; lower.rs is untouched.

Why

DXC does not share entries. SetPSVSigElement appends the name for each arbitrary element without searching (source). Validators before 1.8 rebuild the whole part from the module and memcmp it (v1.6.2112, v1.7.2308), so a shared entry gives Container part 'Pipeline State Validation' does not match expected for module. From 1.8 the check is by content and accepts both layouts, which is why CI never showed it. #1945 has the numbers for the validators that do reject it.

Evidence

  • DXC bytes. dxc.exe 1.9.2602.17, -T vs_6_6 -E main -validator-version 1.6, a vertex shader with POSITION, TEXCOORD0 in and SV_Position, TEXCOORD0 out: the string table is \0POSITION\0TEXCOORD\0TEXCOORD\0 and the fourth element's name offset is 0x13. The new test psv_appends_repeated_semantic_names_like_dxc compares the first 164 bytes of psv() (everything before the input-to-output table) with that output.
  • Red, then green. Test only: run 45868022065, 302 passed, 1 failed, the new test. With the change: run 45868065141, 303 passed, repository_passes_policy ... ok.
  • The rule on other shaders. Three more compiled the same way, parsed with a script: a pixel shader with NORMAL, BINORMAL, three TEXCOORD and COLOR; a geometry shader with two TEXCOORD in and out; a vertex shader with BINORMAL, NORMAL, WORLD_COLOR, COLOR in and NORMAL out. In all three the table is one entry per named element, in element order, nothing shared.
  • Locally, full victory-shader on three adapters, each one test up on unmodified 63bcca4 with the same tests failing as there: WARP 299 passed, 4 failed (298 and 4 before); AMD integrated Radeon 296 and 7 (295 and 7); NVIDIA RTX 2060 300 and 3 (299 and 3). The validator on this machine is the 1.9 one, so this shows the new layout is accepted, not that the old one was refused.

Other pull requests

  • #1208 made this same change among others and was closed as already in main; the part about the string table is not in main (63bcca4 still calls find). The fork has it as fxceless/victory-fork#61. The idea is theirs; this is the one change with a test against DXC's bytes.
  • #3088 touches the same lines and conflicts. It keeps sharing identical names and fixes a suffix match (NORMAL inside BINORMAL); with one entry per element there is no lookup, so that case cannot occur either. Its test psv_string_table_matches_whole_entries expects the output NORMAL at offset 10, shared with the input; DXC, for that signature, writes \0BINORMAL\0NORMAL\0WORLD_COLOR\0COLOR\0NORMAL\0 and puts it at 35. If #3088 goes in first I will rebase this onto it. I tried that locally on its head d7a9515: with find_string removed and that one test's table and offset set to DXC's, its two tests and the new one pass.

Not checked

  • No validator older than 1.8 was run here. That such validators reject the shared layout is from DXC's source and from the reports in #1945 and #3088, not from a run of ours.
  • The last 32 bytes of the part (the input-to-output table) are not compared: DXC computes it exactly and psv() sets every bit on purpose (#1985).
  • An arbitrary element with an empty name cannot be written in HLSL, so offset 0 for it follows DXC's source, not a compiled sample.

Synthetic tests only; no game files.

— Gemini & Fable

**@⁠Moon0755** on GitHub · 2026-11-26 17:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/3323) `Moon0755:fix/psv0-semantic-names` → `main` · +80 −13 · 1 files · 1 commits · open Part of #1945 (the writer half). ### What `container::psv` looked a semantic name up in the string table before adding it, so a name used by two elements (`TEXCOORD` on an input and on an output) was written once and both elements pointed at it. Now every element with an arbitrary semantic and a non-empty name appends its own entry; system values and empty names still point at offset 0. `find` has no caller left and is removed. `container.rs` only; `lower.rs` is untouched. ### Why DXC does not share entries. `SetPSVSigElement` appends the name for each arbitrary element without searching ([source](https://github.com/microsoft/DirectXShaderCompiler/blob/49fea47e722b14066d679e605e04b62ba0816b8d/lib/DxilContainer/DxilContainerAssembler.cpp#L1230-L1246)). Validators before 1.8 rebuild the whole part from the module and `memcmp` it ([v1.6.2112](https://github.com/microsoft/DirectXShaderCompiler/blob/v1.6.2112/lib/HLSL/DxilValidation.cpp#L5475-L5487), [v1.7.2308](https://github.com/microsoft/DirectXShaderCompiler/blob/v1.7.2308/lib/HLSL/DxilValidation.cpp#L5513-L5525)), so a shared entry gives `Container part 'Pipeline State Validation' does not match expected for module`. From 1.8 the check is by content and accepts both layouts, which is why CI never showed it. #1945 has the numbers for the validators that do reject it. ### Evidence - **DXC bytes.** `dxc.exe` 1.9.2602.17, `-T vs_6_6 -E main -validator-version 1.6`, a vertex shader with `POSITION`, `TEXCOORD0` in and `SV_Position`, `TEXCOORD0` out: the string table is `\0POSITION\0TEXCOORD\0TEXCOORD\0` and the fourth element's name offset is `0x13`. The new test `psv_appends_repeated_semantic_names_like_dxc` compares the first 164 bytes of `psv()` (everything before the input-to-output table) with that output. - **Red, then green.** Test only: [run 45868022065](https://github.com/Moon0755/VIctory/actions/runs/45868022065), 302 passed, 1 failed, the new test. With the change: [run 45868065141](https://github.com/Moon0755/VIctory/actions/runs/45868065141), 303 passed, `repository_passes_policy ... ok`. - **The rule on other shaders.** Three more compiled the same way, parsed with a script: a pixel shader with `NORMAL`, `BINORMAL`, three `TEXCOORD` and `COLOR`; a geometry shader with two `TEXCOORD` in and out; a vertex shader with `BINORMAL`, `NORMAL`, `WORLD_COLOR`, `COLOR` in and `NORMAL` out. In all three the table is one entry per named element, in element order, nothing shared. - **Locally, full `victory-shader` on three adapters,** each one test up on unmodified `63bcca4` with the same tests failing as there: WARP 299 passed, 4 failed (298 and 4 before); AMD integrated Radeon 296 and 7 (295 and 7); NVIDIA RTX 2060 300 and 3 (299 and 3). The validator on this machine is the 1.9 one, so this shows the new layout is accepted, not that the old one was refused. ### Other pull requests - #1208 made this same change among others and was closed as already in `main`; the part about the string table is not in `main` (`63bcca4` still calls `find`). The fork has it as fxceless/victory-fork#61. The idea is theirs; this is the one change with a test against DXC's bytes. - #3088 touches the same lines and conflicts. It keeps sharing identical names and fixes a suffix match (`NORMAL` inside `BINORMAL`); with one entry per element there is no lookup, so that case cannot occur either. Its test `psv_string_table_matches_whole_entries` expects the output `NORMAL` at offset 10, shared with the input; DXC, for that signature, writes `\0BINORMAL\0NORMAL\0WORLD_COLOR\0COLOR\0NORMAL\0` and puts it at 35. If #3088 goes in first I will rebase this onto it. I tried that locally on its head `d7a9515`: with `find_string` removed and that one test's table and offset set to DXC's, its two tests and the new one pass. ### Not checked - No validator older than 1.8 was run here. That such validators reject the shared layout is from DXC's source and from the reports in #1945 and #3088, not from a run of ours. - The last 32 bytes of the part (the input-to-output table) are not compared: DXC computes it exactly and `psv()` sets every bit on purpose (#1985). - An arbitrary element with an empty name cannot be written in HLSL, so offset 0 for it follows DXC's source, not a compiled sample. Synthetic tests only; no game files. — Gemini & Fable
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 17:59:59 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 18:07 UTC · original · approved these changes

Reviewed the diff and verified locally on Windows 11 x64 (dxil.dll validation enabled):

  • Appending each non-empty arbitrary semantic name to the PSV0 string table (while keeping empty names at offset 0) matches DXC's exact PSV0 output and removes the linear find() scan.
  • cargo test -p victory-shader --lib emit::container:: -- --test-threads=1: 2 passed, 0 failed (including psv_appends_repeated_semantic_names_like_dxc).
  • cargo test -p victory-shader --lib emit::tests:: -- --test-threads=1: 17 passed, 0 failed.
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 18:07 UTC · [original](https://github.com/Marvisak/VIctory/pull/3323#pullrequestreview-6078782027) · **approved these changes** Reviewed the diff and verified locally on Windows 11 x64 (`dxil.dll` validation enabled): - Appending each non-empty arbitrary semantic name to the PSV0 string table (while keeping empty names at offset 0) matches DXC's exact PSV0 output and removes the linear `find()` scan. - `cargo test -p victory-shader --lib emit::container:: -- --test-threads=1`: 2 passed, 0 failed (including `psv_appends_repeated_semantic_names_like_dxc`). - `cargo test -p victory-shader --lib emit::tests:: -- --test-threads=1`: 17 passed, 0 failed. - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 18:26 UTC · original

I verified the legacy-validator result directly on Windows. The existing synthetic shader test emit::tests::elements_sharing_a_row_keep_their_order emits two TEXCOORD elements, then validates the full container. I ran the same test on 63bcca4 and exact PR head ba7f9e6, with the loaded DLL path and version observed in each test process.

Loaded validator 63bcca4 ba7f9e6
Microsoft DXC 1.7.2308, dxil.dll 101.7.2308.12 Fails on Pipeline State Validation part mismatch Pass
dxil.dll 1.9.2609.5 Pass Pass

The new psv_appends_repeated_semantic_names_like_dxc golden test also passes on the exact head. This reproduces the #1945 writer defect on a synthetic shader and verifies that the change fixes what the older validator rejects. Microsoft's signed 1.7.2308 release · AI-assisted with Codex.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 18:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/3323#issuecomment-7200462374) I verified the legacy-validator result directly on Windows. The existing synthetic shader test `emit::tests::elements_sharing_a_row_keep_their_order` emits two `TEXCOORD` elements, then validates the full container. I ran the same test on `63bcca4` and exact PR head `ba7f9e6`, with the loaded DLL path and version observed in each test process. | Loaded validator | `63bcca4` | `ba7f9e6` | | --- | --- | --- | | Microsoft DXC 1.7.2308, `dxil.dll` 101.7.2308.12 | Fails on `Pipeline State Validation` part mismatch | Pass | | `dxil.dll` 1.9.2609.5 | Pass | Pass | The new `psv_appends_repeated_semantic_names_like_dxc` golden test also passes on the exact head. This reproduces the #1945 writer defect on a synthetic shader and verifies that the change fixes what the older validator rejects. [Microsoft's signed 1.7.2308 release](https://github.com/microsoft/DirectXShaderCompiler/releases/tag/v1.7.2308) · AI-assisted with Codex.
Author
Owner

@⁠borosf on GitHub · 2026-11-26 19:03 UTC · original

Independent local verification on Windows 11 x64, Intel Arc B580 12 GB (12 cores), at this PR's head ba7f9e6:

cargo test -p victory-shader --lib --locked --no-fail-fast -- --test-threads=1
cargo clippy -p victory-shader --all-targets --locked -- -D warnings
cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings

Result: victory-shader lib: 301 passed / 2 failed (both known baseline); the new psv_appends_repeated_semantic_names_like_dxc test passed.

Both clippy runs exit 0 (-D warnings, both feature sets). The B580 baseline failures pristine main also hits are: victory-gpu descriptor::host::tests::dynamic_slots_are_held_until_released + memory::tests::lists_share_a_table_and_copies_keep_their_views (#1744/#1829); victory-shader emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros + emit::valu_tests::fspx_programs_run_with_the_hardwares_dot_products. No PR regressions.

Synthetic tests only; no game data used. Full log kept locally. — borosf

**@⁠borosf** on GitHub · 2026-11-26 19:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/3323#issuecomment-7201148531) Independent local verification on Windows 11 x64, Intel Arc B580 12 GB (12 cores), at this PR's head `ba7f9e6`: ``` cargo test -p victory-shader --lib --locked --no-fail-fast -- --test-threads=1 cargo clippy -p victory-shader --all-targets --locked -- -D warnings cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings ``` Result: victory-shader lib: 301 passed / 2 failed (both known baseline); the new psv_appends_repeated_semantic_names_like_dxc test passed. Both clippy runs exit 0 (-D warnings, both feature sets). The B580 baseline failures pristine main also hits are: victory-gpu descriptor::host::tests::dynamic_slots_are_held_until_released + memory::tests::lists_share_a_table_and_copies_keep_their_views (#1744/#1829); victory-shader emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros + emit::valu_tests::fspx_programs_run_with_the_hardwares_dot_products. No PR regressions. Synthetic tests only; no game data used. Full log kept locally. — borosf
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 20:14 UTC · original · approved these changes

Looks good to me — appending each non-empty Arbitrary (kind == 0) semantic name without deduplicating matches DXC's PSV0 string-table writer while keeping empty names and system values at offset 0.

Verified locally on Windows 11 with head ba7f9e61 cleanly merged onto main (63bcca43):

  • Audited crates/victory-shader/src/emit/container.rs:243-250 and 436-510: the golden bytes match SDK DXC PSV0 header, string table, index table, and 16-byte element records, and the added lines match rustfmt --edition 2024.
  • cargo run -p xtask -- policy (191 files ok) and cargo clippy --locked -p victory-shader --all-targets -- -D warnings (both default and --all-features) pass.
  • cargo test --locked -p victory-shader --lib emit::container: 2 passed; 0 failed (0.00s).
  • cargo test --locked -p victory-shader --lib emit::tests: 17 passed; 0 failed under both VICTORY_WARP=0 and VICTORY_WARP=1 (with Windows Kits\10\bin\10.0.26100.0\x64\dxil.dll present).
**@⁠fuzeofficlal** on GitHub · 2026-11-26 20:14 UTC · [original](https://github.com/Marvisak/VIctory/pull/3323#pullrequestreview-6080026138) · **approved these changes** Looks good to me — appending each non-empty `Arbitrary` (`kind == 0`) semantic name without deduplicating matches DXC's `PSV0` string-table writer while keeping empty names and system values at offset `0`. Verified locally on Windows 11 with head `ba7f9e61` cleanly merged onto `main` (`63bcca43`): - Audited `crates/victory-shader/src/emit/container.rs:243-250` and `436-510`: the golden bytes match SDK DXC `PSV0` header, string table, index table, and 16-byte element records, and the added lines match `rustfmt --edition 2024`. - `cargo run -p xtask -- policy` (`191 files ok`) and `cargo clippy --locked -p victory-shader --all-targets -- -D warnings` (both default and `--all-features`) pass. - `cargo test --locked -p victory-shader --lib emit::container`: `2 passed; 0 failed` (`0.00s`). - `cargo test --locked -p victory-shader --lib emit::tests`: `17 passed; 0 failed` under both `VICTORY_WARP=0` and `VICTORY_WARP=1` (with `Windows Kits\10\bin\10.0.26100.0\x64\dxil.dll` present).
This pull request can be merged automatically.
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/3323/head:github-bot/gh-3323'
git switch 'github-bot/gh-3323'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3323'
git switch 'github-bot/gh-3323'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3323'
git switch 'github-bot/gh-3323'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3323'
git switch 'main'
git merge --squash 'github-bot/gh-3323'
git switch 'main'
git merge --ff-only 'github-bot/gh-3323'
git switch 'main'
git merge 'github-bot/gh-3323'
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!3323
No description provided.