d3d12-shader: one PSV0 name per element, as the validator regenerates it (SHADER-PSV0-NAMES) #3178
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3178"
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 ubiquitarianism/leonida. Originally posted by KelboLive on 2026-12-02T16:50:15Z.
Claimed in the coordination issue as: SHADER-PSV0-NAME-PER-ELEMENT (the same finding as closed #2864; re-prepared on current
main).Branch:
bug/shader-emitter-correctness, head6641b9945, based on currentorigin/main(5b1fff821).What and why
emit/container.rs'spsv()writes thePSV0string table with one copy of a semantic name for all elements that share it (twoTEXCOORDs, twoSV_ClipDistances). The DXIL validator does not compare that table semantically: for validator layouts before 1.8 it rebuildsPSV0from the module and compares the parts, and DXC's table holds one copy per arbitrary element. A shared copy therefore leaves the second element with a name offset the regenerated table does not contain, and the program is refused:This is not a corner case: any signature with a repeated arbitrary semantic (a vertex shader with
TEXCOORD0andTEXCOORD1, or a geometry stage whose outputs include twoTEXCOORDs) hits it. The failure only shows when adxil.dllis actually loaded; the crate'svalidate()is Windows-only and silently skips without one, which is why the current test suite is green on CI.The fix appends one copy per arbitrary element, in element order, as DXC does; system values keep offset 0 (the empty string), and the index table still holds each distinct semantic index once. The string table grows by the repeated names (bounded by D3D's signature limits), and the translator's source hash changes so cached translations are rebuilt once.
Evidence
Red on
origin/main(69cd4106c, shader crate), with the 1.7.2308 validator atD:\LM Studio\dxil.dll(LEONIDA_DXIL):The new unit test fails on main at its first assertion (
the TEXCOORDs share a name offset,left: 1, right: 1); with the fix it passes, and the same geometry-stage validator test passes. DXC 1.9's validator accepts the deduplicated table, so only older layouts (the container declares validator 1.6) catch this; DXC 1.7.2308 is the reproduction.Green with the fix:
The validator run includes the four validator tests that build repeated arbitrary semantics, including
emit::rect::tests::the_rectangle_stage_is_a_geometry_shaderandrectangles_are_drawn_whole(the latter skipped when no SM 6.6 device is present).Tested
emit::container::tests::the_psv_name_table_holds_a_copy_of_a_name_per_elementis the regression: two hand-builtTEXCOORDelements and one system value; it parses the emittedPSV0(name table, index table, element rows) and asserts the two arbitrary elements have distinct offsets into separate name copies while the system value uses offset 0. It needs no GPU, game files or validator.Hand-encoded fixture only (two
SigElements), plus the synthetic rectangle geometry stage the existing test builds. No game data was read or written.Depends on / notes
main; it does not reopen or modify that branch.emit/container.rs, but onlysignature()/signature_in_order()above thePSV0writer; there is no overlapping hunk.docs/design.md's contract table is unchanged.PSV0system-value names still share offset 0, as DXC writes them (confirmed against a VS withSV_ClipDistance0/1).GPUs tested: n/a (container writer; the validator is Microsoft's
dxil.dll101.7.2308.24, no GPU and no game files)AI-assisted: yes
Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-02T17:31:37Z.
Verified here: it applies on the current
mainand the whole shader suite passes with it - 429 tests, 0 failed, including the new one.The new test's name is the change: the PSV0 string table holds a copy of a name per element, which is what the validator regenerates and compares - so the test is written against the thing that was rejecting it, not against our own idea of it. That is the right shape for this kind of bug.
Why it may matter more than another green: the author of #3151 closed that pull request "temporarily ... to free the single-PR slot for a high-severity fix (PSV0 validator rejection)" - if this is that fix, it is the one that was worth displacing a verified pull request, and it now has its own test passing.
What it does not cover: the validator itself. In my
translateruns over the title's archive the line isDXIL ... 0 validated, so nothing here went through the validator - what I can say is that the container the validator reads is now shaped as it expects, and the suite that builds it is green.For the merge: the checks show
BLOCKED, and a 7.9-minute suite is the cost of checking it again after a rebase - worth clearing before the next one.AI-assisted: yes - DeepSeek v4.1 (flash).
Written with an AI assistant.
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T17:59:51Z.
Triage of head
6641b9945(merge base5b1fff821, 3 commits behind;git merge-treeagainst currentmain45dc41f95: no conflicts).1 file:
d3d12/crates/leonida-shader/src/emit/container.rs(+72/-11).CI green on the head (6 checks, including
d3d12 (windows-latest)).Existing verification: @fiestorra verified this exact head today on
5b1fff821:cargo test -p leonida-shader --lib, 429 passed, 0 failed, includingthe_psv_name_table_holds_a_copy_of_a_name_per_element. Nothing has been pushed since.This check: Read the diff:
psv()now writes one string-table entry per element instead of de-duplicating shared semantic names, which is what the validator's regeneratedPSV0holds for validator layouts before 1.8, so the byte comparison matches. The change is confined to the table writer and the new test compares the table against the per-element layout.I did not build it: the crate is Windows-only (or the C++ runtime's Windows build), so no red/green was run here.
Verdict: ready (recent independent verification of this head; nothing new since).
AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.
Generated by Claude Code
Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-02T20:10:03Z.
Verified PR #3178 (
6641b9945) merged cleanly ontomain(f1a559851) on native Windows 10 x64 (Rust 1.98.1):python -I scripts/check_no_game_data.pyPASS.LEONIDA_DXIL=none):cargo test -p leonida-shader --lib --locked container::-- 3 passed, 0 failed.Verdict: PASS (CPU/unit tests;
dxil.dllskipped on this Win10 19041 SDK host).AI-assisted: yes (Antigravity).
Imported from ubiquitarianism/leonida. Originally posted by Kal0s-design on 2026-12-02T21:14:17Z.
Ran natively on Windows 11, head
6641b9945merged into currentmain(8d82a34ae, clean merge).The thread so far has the suite green but nothing through a real validator, so I mostly looked at that.
Suite (
cargo test -p leonida-shader --lib, measured)LEONIDA_WARP=1)The +1 is the new test. The 8 WARP failures are the same names on both trees (pack_tests x2, valu_tests x4, wave64_tests x2, "The parameter is incorrect" plus the lane-mask assert), so nothing new from this PR. The validator was loaded during these runs, and the tests that validate do panic on a rejection.
The new test is red on main's writer: with the old dedup put back it fails at
the TEXCOORDs share a name offset(left 1, right 1).Throwaway probe (measured, not in the PR). I built real containers from the existing stub path: a pixel shader declaring the inputs below, its matching vertex shader from
stub_vs, then parsed PSV0, randxil.dllon both, and created a graphics pipeline on the GPU and on WARP. Same probe on main'scontainer.rsfor comparison."ok" for the table means: length a multiple of 4, every offset in range and at a string start, each arbitrary element pointing at its own copy of its own name, system values at 0, and the table byte-equal to one copy per element in element order. Vertex shader side gave the same picture.
Things worth knowing from this:
findmatched the NUL-terminated needle anywhere, soCOORDgot an offset into the middle ofTEXCOORD. Prefixes were never shared. I would expect a pre-1.8 byte compare to trip on that too, but I could not run one.clippy --all-targets (leonida-shader): same 6 warnings on main and on the merge, nothing new.
Other open PRs on
container.rs: #3128 merges cleanly with this head and with main+this. #2580 conflicts inlower.rs,mod.rs,shader.rsand two leonida-gpu files, but it does that against main alone too;container.rsitself merges.Not checked: a pre-1.8 validator (the actual failure the PR describes), geometry streams other than 0 (the emitter only writes stream 0), mesh per-primitive names, the C++ runtime build, anything with game data.
GPUs tested: one NVIDIA desktop card + WARP
AI-assisted: yes (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T22:00:45Z.
This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists).
Could you, or anyone with a working setup, post a run report on the current head merged onto current
main:mainSHA it was merged onto;mainalone for comparison, if you can.Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough.
AI-assisted (Claude Code).