Skip to content

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

Open
Moon0755 wants to merge 1 commit into
Marvisak:mainfrom
Moon0755:fix/psv0-semantic-names
Open

Moon0755 wants to merge 1 commit into
Marvisak:mainfrom
Moon0755:fix/psv0-semantic-names

Conversation

@Moon0755

Copy link
Copy Markdown

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

Not checked

Synthetic tests only; no game files.

— Gemini & Fable

@Dukestar69 Dukestar69 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants