Shaders: match whole entries in the PSV0 string table #3088
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!3088
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3088"
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?
@scoresby13 on GitHub · 2026-11-26 07:18 UTC · original
scoresby13:shader/psv-string-table-boundaries→main· +116 −7 · 1 files · 1 commits · openSummary
container::psvinterned arbitrary semantic names (e.kind == 0) usingfind(&strings, &needle)viawindows(needle.len()).position(...). Becausefindmatches at any byte offset rather than only at NUL-delimited entry starts (table[at - 1] == 0), an arbitrary semantic name that is a proper suffix of an earlier one (for example, standard HLSLBINORMALfollowed byNORMAL, orWORLD_COLORfollowed byCOLOR) reused a mid-string offset (such as offset3inside\0BINORMAL\0) instead of appending its own entry.In Microsoft DXC (
lib/DxilValidation/DxilContainerValidation.cpp),StringTableVerifierpopulatesOffsetToUseCountMaponly at NUL-terminated entry starts (0andi + 1after each'\0'), soPSVContentVerifier::VerifySignatureElementrejects mid-stringSemanticNameoffsets viaMarkUse, and pre-1.8dxil.dllvalidators reject the mismatchingPSV0part.Fix
findwithfind_string(table, name), which walks whole NUL-delimited entries starting at index1and only matches when the entire entry equalsname.0without allocating a temporaryVec<u8>, while keeping identical full semantic names shared (matchingmain's layout per #1208).Verification
main(63bcca4):cargo test -p victory-shader --lib emit::container::tests:psv_string_table_matches_whole_entriesfailed: emitted\0BINORMAL\0WORLD_COLOR\0\0\0(skippingNORMALandCOLOR).psv_suffix_semantics_validate_with_dxilfailed against Windows SDK10.0.22621.0\x64\dxil.dll(101.6.2112.13):error: Container part 'Pipeline State Validation' does not match expected for module.\nValidation failed.cargo test -p victory-shader --lib emit::container::tests: 3 passed, 0 failed (including livedxil.dllvalidation).cargo test -p victory-shader --lib emit::tests::constant_color_validates: 1 passed, 0 failed.cargo test -p victory-shader --lib -- --test-threads=1: 292 passed, 3 ignored, 12 pre-existing failures unrelated to this change (10 Intel UHD 730 hardware GPU mismatches where WARP passes; 2 pre-existing repeated-TEXCOORDtests rejected by localdxil.dll1.6101.6.2112.13instead of validator 1.8).cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo clippy -p victory-shader --all-targets --all-features -- -D warnings: clean.cargo xtask policy:asset policy: 191 files ok.Claim comment: #1633
AI-assisted. No game data used.
@Dukestar69 on GitHub · 2026-11-26 07:27 UTC · original · approved these changes
Tested locally merged onto
origin/main(63bcca4) on Windows 11 x64 (withdxil.dllvalidator):cargo test -p victory-shader psv: 3 passed, 0 failed (includingpsv_string_table_matches_whole_entriesandpsv_suffix_semantics_validate_with_dxil).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).
@oni-swr on GitHub · 2026-11-26 08:16 UTC · original
Independent verification for my claim #1633. Test report only; no source review. Disclosure: checks run by Claude Code (Claude Sonnet 5.5), coordinated by Codex (gpt-6.2-sol).
Tested: PR head
d7a95153c8088516273b8e30fdc4f68cb8548dd2, parent63bcca43c6a00a758510398fa43096ce7e4f7df0(currentmain). Windows 11 x64, Rust 1.98.1 (pinned),cargo -j 4 --locked. Synthetic inputs only: no game files, dumps or shader names.Validator:
dxil.dll1.8.2502.11 from the installed Windows SDK 10.0.26100.0, which the test'sdefault_path()selects. The live test skips silently when the DLL cannot be loaded (if let Ok(...)), so I checked with a throwaway probe in a scratch copy that it did not skip. At the head it printed path = the 26100 DLL, loaded = true, validate OK, container hash unchanged. WithVICTORY_DXILpointing at a nonexistent path the same test still reportsokwithout validating, so a bareokdoes not prove validation ran.Results at the head (
cargo test -p victory-shader --lib psv):psv_string_table_matches_whole_entries: okpsv_suffix_semantics_validate_with_dxil: ok (validator loaded and validated, per the probe)sample_interpolated_inputs_set_psv_sample_frequency: okvictory-shader --libat the head withVICTORY_WARP=1andVICTORY_D3D12_WARP=1, adapter confirmed as "Microsoft Basic Render Driver" (software): 300 passed, 4 failed, 3 ignored. The 4 failures areemit::synthetic_tests::{gathers_at_a_level_match_the_hardware, permutes_mask_high_address_bits_and_divergent_branches, permutes_read_the_lane_named_and_zero_from_lanes_left_out, a_mask_joined_with_data_at_a_uniform_loop_is_its_number}. The same 4 fail identically at the parent on WARP, twice in a row. They are pre-existing, unrelated tocontainer.rs, and none uses the PSV path.Baseline control (parent source plus the PR's two new tests, no other change):
psv_string_table_matches_whole_entries: fails at the parent. The table is\0BINORMAL\0WORLD_COLOR\0\0instead of\0BINORMAL\0NORMAL\0WORLD_COLOR\0COLOR\0\0, because suffix matches resolveNORMALintoBINORMALandCOLORintoWORLD_COLOR. It passes at the head.psv_suffix_semantics_validate_with_dxil: passes at the parent too. With the 1.8.2502.11 validator this container validates either way, so on this validator the live test does not discriminate parent from head. The synthetic table test is the one that demonstrates the fix.Notes: the older SDK 10.0.19041.0
dxil.dll(10.0.19041.5609) is not usable for this test. It rejects the container with "Unknown shader model 'vs_6_6'", independent of this PR. The PSV tests themselves create no D3D12 device; the device-backed run above used WARP only. Scratch worktree, fixtures and cargo target directory were removed afterwards.One disclosure: before I set the WARP variables, I ran the full
victory-shader --libonce with no WARP switch, so that run may have used this machine's physical adapter. It is not counted above. The reported WARP run is the repeat with the switches set and a software adapter.@Marvisak on GitHub · 2026-11-26 08:21 UTC · original
Automated triage for the maintainers.
Merge candidate. In
emit/container.rs(psv), arbitrary semantic names were interned withfind, a substring search. A name that is a suffix of an earlier one (NORMALafterBINORMAL) got an offset in the middle of the earlier entry.find_stringnow matches only whole NUL-terminated entries from offset 1, and empty names still map to offset 0, so the layout for names without such a collision is unchanged. Names come from the title's own signature parts (emit/mod.rs,String::from_utf8_lossy(name)), so this collision can happen. Whole-entry dedup is what DXC's PSV string table and validator expect.psv_string_table_matches_whole_entrieschecks the exact table and offsets, andpsv_suffix_semantics_validate_with_dxilruns the validator when one is present.CI: passing (check).
Generated by Claude Code
@fuzeofficlal on GitHub · 2026-11-26 08:29 UTC · original · reviewed
The whole-entry lookup in
find_string(crates/victory-shader/src/emit/container.rs:239-255) cleanly fixes the PSV0 suffix-reuse bug and preserves 4-byte alignment and empty/system-value offset0.Verified locally on Windows 11 with Windows SDK
10.0.26100.0\x64\dxil.dll:cargo clippy -p victory-shader --all-targets --locked -- -D warnings: cleancargo test -p victory-shader --lib --locked -- emit::container::tests: 3/3 passed (includingpsv_string_table_matches_whole_entriesandpsv_suffix_semantics_validate_with_dxil)Two small notes for consideration:
psv_suffix_semantics_validate_with_dxil(emit/container.rs:544-550),if let Ok(validator) = Validator::load()silently passes ifVICTORY_DXILpoints to a missing/broken DLL. RequiringValidator::load()to succeed whenVICTORY_DXILis explicitly set (or logging the skip reason otherwise) would prevent false-green validator runs.TEXCOORDin both) still deduplicate to one entry here. Older DXC validators (such asv1.8.2407) rebuild PSV0 by appending a string per arbitrary signature element and byte-comparing the result, whereas newer DXC compares by semantic content. Worth adding a note or a duplicate-name test case if compatibility with olderdxil.dllbuilds is targeted.@futurepro62 on GitHub · 2026-11-26 11:01 UTC · original
NVIDIA full-suite run, to go with the reports above by Dukestar69, fuzeofficlal, oni-swr, since none of them names a GPU run. Tested exact head
d7a9515(on its base63bcca4).Tested
dxil.dllfrom Windows SDK 10.0.26100 (the loader's default), debug.cargo build --workspace --locked, thencargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 868 passed, 0 failed, 10 ignored.psv_string_table_matches_whole_entries,psv_suffix_semantics_validate_with_dxil.--skipleaves out tests that fail on main63bcca4on this card too, not because of this PR:heap_direct_texture_reads_mark_their_heap_indexends thevictory-shadertest process with0xc0000005(#2571), so without the skip the rest of that crate never reports;dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_viewsand the twostride_testshit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317);gathers_at_a_level_match_the_hardwarefails on lane 0 (#1744).Not tested
AI use
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.