Repository navigation
d3d12: the PSV0 part's name table holds a copy of a name per element (SHADER-PSV0-NAME-PER-ELEMENT) - #2864
d3d12: the PSV0 part's name table holds a copy of a name per element (SHADER-PSV0-NAME-PER-ELEMENT)#2864Neutron-0 wants to merge 1 commit into
Conversation
|
One note about this account's side of it: GitHub allows this account one open pull request in this repository, so this pull request holds the slot that #2837 (the census fix, reviewed and verified) had to give up. #2837 is closed with the reason on the record and is reopened as soon as this one is merged; three other fixes (a switch page with a test that keeps it in step, a reported skip instead of a silent one, and a retry for a dropped connection in the conflict labeler) are queued behind it, each with its branch pushed and tested. Nothing about the four changes depends on each other, so they can be merged in any order; only the account's one-at-a-time limit orders them. |
ec12f9d to
571bd0c
Compare
|
Two practical notes for whoever looks at this: The workflow run is waiting for an approval ( The job cannot see what this fixes, and that is worth knowing before reading it as green. On a machine with the Windows SDK's The finding about the job not seeing this at all is in the coordination issue (#2570). |
571bd0c to
f615daf
Compare
KelboLive
left a comment
There was a problem hiding this comment.
Confirmed against DXC: SetPSVSigElement() appends a name for every arbitrary element, and pre-1.8 validators compare the PSV0 part byte-for-byte with a regenerated one, so the old find() shared offset was the rejection. The new writer matches DXC's input/output/prim order and keeps system values at offset 0, with offsets relative to the string-table start (including its leading NUL) and lengths including the terminator — I checked base, terminator and count against docs/design.md:745-752 and tools/ps_interp_modes.py:116-171, and both read either form correctly.
The new test is a real guard: reverting only the writer fails it at container.rs:536 (assert_ne!(name_of(0), name_of(1)), left: 1, right: 1), and leonida-shader --lib is 410/0/5 here, with tests/test_ps_interp_modes.py 32/32. This is a writer, not a parser, so there is no name-table read to overrun; the production readers are bounded (emit/mod.rs:1628-1637 with split_at_checked, ps_interp_modes.py:150-153 with 0 < noff < len).
Two notes, neither blocking:
- Memory now grows with element count, not unique names (
O(sum(len+1))): twoTEXCOORDs go 12 → 20 bytes. Bounded by D3D signature limits and no unbounded input, but worth one sentence in the commit message since it is the deliberate trade for byte-identity with DXC. - One divergence from DXC: DXC appends only for a non-empty arbitrary name; this code would append
\0and give an empty arbitrary name offset 1 instead of 0. Unreachable for valid modules (arbitrary semantics must be named), so not a blocker — but if the writer is ever used on a hand-built signature, that is the one case where it would differ again.
docs/design.md:745 describes the layout but not whether the table may be deduplicated; a clause saying it need not be would keep the next writer from reintroducing find().
f615daf to
3199126
Compare
|
I ran an explicit DXIL validator comparison at 3199126 + 0ff8a53. The synthetic rectangle geometry stage had SV_Position, TEXCOORD0, COLOR0 and TEXCOORD1, with and without a primitive-ID output. The fixture requires the validator to load and validates each result directly, rather than silently skipping if the DLL cannot be found. With the PR, both cases passed the x64 dxil.dll from Microsoft DXC v1.7.2308 and the newer validator used by the local harness. In a local control I restored only PSV0 name deduplication. The v1.7.2308 validator rejected both variants with “Pipeline State Validation” not matching the module. The newer validator accepted both control variants. The stock name-table test also passed with the PR. Win64 target under Wine 11.22, synthetic code only. Microsoft DXC v1.7.2308 release · MEASURED, AI-assisted (Codex). |
3199126 to
c864439
Compare
…(SHADER-PSV0-NAME-PER-ELEMENT) The validator compares the PSV0 part with the one it computes from the module, and that one's name table holds a copy of a semantic's name per element. Ours held one copy for all the elements that shared the name, so every later element's name offset differed from the module's and the validator refused the program with "Container part 'Pipeline State Validation' does not match expected for module". Every program with an arbitrary semantic (POSITION, TEXCOORD, ...) has one, so the 4 tests that validate such a program failed on Windows with any dxil.dll of DXC 1.5.2005 or newer. The validator block is #[cfg(windows)], so a Linux CI job cannot see it. Write one copy per element, as DXC writes it: the PSV0 of a geometry stage built by hand is now byte for byte the one DXC 1.7 writes for the same signature, apart from the dependency-mask table the validator does not compare. Test: the new test in emit/container.rs fails on main (both elements share the name offset 1) and passes with the change; the 4 validator tests pass with it (405 tests, 0 failed). Needs no game files and no GPU. AI-assisted: yes - MiniMax M3.1 Flash (OpenCode).
c864439 to
d9bc50c
Compare
Claimed in the coordination issue as: SHADER-PSV0-NAME-PER-ELEMENT (#2570 (comment))
What and why
d3d12/crates/leonida-shader/src/emit/container.rswrites thePSV0part of the DXIL container. Its name table held one copy of a semantic's name for all the elements that shared it, while the validator compares this part with the one it computes from the module - and that one's table holds a copy per element. Every element after the first then carried a name offset the module's table does not have, and the validator refused the program:Every program with an arbitrary semantic (
POSITION,TEXCOORD, ...) has such elements, so this is not a corner case.The fix writes one copy per element, in element order, as DXC writes it (the
ISG1/OSG1part above already did). ThePSV0of a geometry stage built by hand is now byte for byte the one DXC 1.7 writes for the same signature, apart from the dependency-mask table, which the validator does not compare.Where this shows, and where it does not. The validator runs in
validate()(emit/mod.rs), which is#[cfg(windows)]and only validates when adxil.dllloads; without one it returns without validating, and the test passes. On a machine with the Windows SDK'sdxil.dllthe four tests that validate such a program fail (the same message with DXC 1.5.2005, 1.6.2104, 1.6.2112 and 1.7.2308 - not a version quirk). The CI'swindows-latestrunner has nodxil.dllthat loads, so its job is green and cannot see this: the four tests readokthere without validating anything.So the CI is not the place this is caught; a developer machine with the SDK is. The container the translator writes is what the host's own D3D12 runtime validates, and a container the validator refuses is a pipeline the host refuses, so making the part byte for byte the one DXC writes is the safe shape regardless of which validator version the host has.
The shader cache key follows the translator's sources (
build.rs), so the key changes with this change and the caches built before it are rebuilt once.This touches
emit/container.rs, which #2581 also touches, but in another part of the file: #2581 changes theISG1/OSG1writer and the geometry block ofpsv(), this changes the name table further down in the same function.Tested
cargo test -p leonida-shader --locked- fails onmain27613ab6bin the 4 validator tests (the message above, withdxil.dll101.7.2308.24) and 415 tests OK, 0 failed, 5 ignored with the change on this pull request's head.emit::container::tests::the_psv_name_table_holds_a_copy_of_a_name_per_element- fails onmain(both elements share the name offset 1) and passes with the change.PSV0part of the geometry stage the test builds is now byte for byte DXC 1.7's own for the same signature (compared part by part; only the dependency-mask table differs).cargo test -p leonida-gpu --lib --locked -- --test-threads=1- 597 tests OK, 0 failed, 53 ignored.cargo test --workspace --locked --exclude leonida-gpu- everything green exceptxtask'spolicy::tests::repository_passes_policy, which fails onmainas well (3 violations aboutleonida-gpu/src/host.rs,emit/lower.rsandemit/indirect/amplify_dxil.rs; policy: a Rust source file is not data, whatever its size #2815 is the fix for that, and this change touches none of those files).dxil.dll).GPUs tested: n/a (the validator is the Windows SDK's
dxil.dll; no GPU, no game files)AI-assisted: yes - OpenCode (MiniMax M3.1 Flash)
Checklist
main(27613ab6b).docs/design.md, with how it was confirmed.Not applicable: no translator rule; the change is in the container the translator writes.