Shaders: one interpolation mode per signature row #554
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/554"
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 Marvisak/VIctory. Originally posted by SAitken91 on 2026-11-24T04:49:58Z.
The console packs signature elements of different interpolation modes into one row, for example a constant
SV_IsFrontFaceor uint beside a linearTEXCOORD. The DXIL validator rejects this with "signature element ... has interpolation mode that differs from another element packed into the same row".Change
container::separate_interpolation, run on the inputs and outputs inShader::finishbefore any signature is written. The first mode seen in a row keeps the row. Each later mode moves to a new free row, and that row's elements of the same mode share it.Results
victory translate --validate shaders.rpf, before → after:No interpolation-row errors remain. A few programs now report the "Container part 'Program Input/Output Signature' does not match" errors already in the list, which the packing error had hidden.
Testing
cargo test -p victory-shader: 70 passed, including the newrows_of_mixed_interpolation_are_separated. Clippy and rustfmt are clean.This is independent of #539 (64-bit image atomics), and the two can merge in either order.
Written with the help of Claude (AI).
🤖 Generated with Claude Code
Imported from Marvisak/VIctory. Originally posted by KoLolX3 on 2026-11-24T05:32:52Z.
Check on Linux, not Windows: pass. Head
9152a1beemerged ontomaind2a4bae1f(clean merge).core,formats,game,loader,pe,pipeline,shader): PR93 passed, 7 failed,main92 passed, 7 failed.cargo xwin check --workspace --target x86_64-pc-windows-msvc, coversvictory-gpu,victory-hleand the app): PR ok,mainok.main168.mainhere as well (not this PR): 7 tests invictory-loaderandvictory-pethat parse their own test binary as a PE image, which is an ELF file on Linux.victory-gpu/victory-hletests and the game itself.On: AMD Ryzen 7 5700, 62 GB RAM, Artix Linux 7.3.4-artix1-2, rustc 1.98.1 (the repo's pinned toolchain), cargo-xwin 0.24.1. No game data. Automated check only: the code itself was not reviewed.
Imported from Marvisak/VIctory. Originally posted by slint6614-dev on 2026-11-24T07:47:12Z.
Measured on the full retail shader pack (26,503 containers) with
victory translate --validate, against maind2a4bae(emitted / validated). Windows 11, dxil.dll from SDK 10.0.26100.cargo test -p victory-shaderpasses on all four.Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T09:50:10Z.
Review: COMMENTED
Tested
9152a1bon Windows 11, RTX 5070, MSVC: the workspace passes (195 outsidevictory-shader;victory-shader --libsingle-threaded: 70).victory translate <title exe> --validate --pipelinesgives the same counts before and after: 12 of 12 programs emitted, 12 validated, 12 pipelines. None of the 12 mixes modes in a row.Splitting rows by interpolation mode fixes the validator error, and the algorithm is fine: the first mode keeps its row, and each later
(row, mode)gets one shared new row. One linkage question before I'd approve:interp == 0stays put).translate --pipelinescan't catch this: for a pixel program it builds the VS withhost::stub_vs(&ps)(apps/victory/src/translate.rs:441), which is derived from the PS's own (already moved) signature, so it always links.Could you check one real VS/PS pair from the title where the PS moves a row, with the actual VS output signature? Or move the same elements in the producing stage's outputs (keyed by semantic), so both sides agree. If D3D12 turns out to link these by semantic alone in DXIL, a note saying so would settle it.
AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by alexander-src on 2026-11-24T10:16:00Z.
Review: COMMENTED
Tested
9152a1bmerged ontomain(8e79c80andffe310e, clean merge) on Windows 11 (10.0.26200.0), NVIDIA GeForce RTX 5090 (driver621.24), WARP, Rust1.98.1,dxil.dll 10.0.26100.0.cargo clippy --workspace --all-targets --locked -- -D warnings: passcargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passcargo test -p victory-shader --locked -- --test-threads=1(on8e79c80): 90 passed, 0 failed, 1 ignoredEmpirical answer to @mercuryVM's VS/PS linkage question (blocking)
Confirmed with a synthetic VS+PS test validated through
dxil.dll 10.0.26100.0and run throughHost::pipeline+Host::drawon both RTX 5090 and WARP: D3D12 rejects VS/PS pairs whose(row, col)disagree atCreateGraphicsPipelineState, even when semantics match.Setup:
PSdeclaresSV_Position(row 0),TEXCOORD0(f32, row 1 col 0,interp=2linear),TEXCOORD1(f32, row 1 col 1,interp=1constant).separate_interpolationmovesTEXCOORD1to row 2 col 1.VSoutputsSV_Position(row 0),TEXCOORD0(f32, row 1 col 0,interp=2=0.25), andTEXCOORD1(f32, col 1 =0.75) in three variants:row 1, interp=2(exactemit/mod.rsVS default when both outputs aref32, soseparate_interpolationleaves VS unchanged)row 2, interp=2(same row as moved PS, differentinterp)row 2, interp=1(same row andinterpas moved PS)Results (all four containers validated cleanly with
dxil.dll):621.24)VS (row 1, interp 2)+PS (row 2, interp 1)CreateGraphicsPipelineState->E_INVALIDARG("The parameter is incorrect.")CreateGraphicsPipelineState->E_INVALIDARG("The parameter is incorrect.")VS (row 2, interp 2)+PS (row 2, interp 1)[0.25, 0.75, 0.5, 1.0][0.25, 0.75, 0.5, 1.0]VS (row 2, interp 1)+PS (row 2, interp 1)[0.25, 0.75, 0.5, 1.0][0.25, 0.75, 0.5, 1.0]Why this will hit real VS+PS and MS+PS pairs at runtime (while
victory translate --pipelinesmisses it viahost::stub_vs(&ps)):crates/victory-shader/src/emit/mod.rs:232-243, VS/MS outputs only get default modes (f32->2, integer ->1), whereas PS inputs havee.interpoverridden by barycentrics during lowering (flat,centroid,noperspective,sample) and can carry PS-onlySV_IsFrontFace(kind=13,interp=1). Any row mixing modes only on the PS side moves in the PS and stays put in the VS/MS.f32+u32),separate_interpolationpicksnext = max(row) + 1per stage. Whenever a VS/MS exports extra trailing rows the PS does not declare, the two stages assign different destination rows and PSO creation fails withE_INVALIDARG.Note that the second row of the table also shows D3D12 allows VS
interp=2to link with PSinterp=1as long as(row, col)stay identical — which is why keeping rows in place (like #306'sharmonize_row_interp, when the mixed sibling is unread) preserves stage linkage, whereas moving rows in one stage breaks it unless both stages agree on the exact layout at PSO link time.No game files used in the linkage probe. AI-assisted (Antigravity) analysis and test authoring; all builds, validation, and GPU/WARP runs executed on this machine.
Imported from Marvisak/VIctory. Originally posted by SAitken91 on 2026-11-24T10:46:26Z.
@alexander-src thank you — that's decisive, and it breaks the premise of this PR ("stages link by semantic"): moving rows in one stage changes
(row, col)andCreateGraphicsPipelineStaterejects the pair, whichtranslate --pipelinescan't see because it pairs the PS with a stub VS. Your second table row (VS interp 2 + PS interp 1 at the same row links fine) points to the safer approach #306 takes: keep rows in place and harmonize the mode. I'm converting this to a draft so it isn't merged as is; it would need both stages to derive the same layout, which a per-stagemax(row) + 1can't guarantee.Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T12:38:16Z.
Review: APPROVED
Sound fix for a real DXIL constraint (one interpolation mode per signature row).
separate_interpolationkeeps each row's first-seen mode in place and moves later modes to fresh rows (nextstarts above the max existing row, so no collisions), reusing one new row per (old row, mode) pair — the test shows B and D (both constant) sharing row 2 while A/E stay on row 0. Elements with mode 0 or no row are untouched, which is correct since they carry no interpolation semantics.Calling it from
Shader::finishfor both inputs and outputs is the right place: lowering already happened, and DXIL links stages by semantic, so only the ISG1/OSG1 signature blobs change — the comment says exactly this and it's accurate.Verified locally: test-merge with current main (
ffe310e) clean;cargo test -p victory-shader --locked(macOS arm64, rustc 1.98.1) → 97 passed / 0 failed / 1 ignored, including the newrows_of_mixed_interpolation_are_separatedunit test (runs on macOS, not Windows-gated).Imported from Marvisak/VIctory. Originally posted by SAitken91 on 2026-11-24T12:42:13Z.
@catminou4 thanks for the review — note the blocker above, though: @alexander-src showed on an RTX 5090 and WARP that D3D12 rejects VS/PS pairs whose
(row, col)differ (CreateGraphicsPipelineState→E_INVALIDARG). This PR moves rows per stage (next = max(row) + 1in each), so a PS can end up with rows its VS doesn't have, which the validator andtranslate --pipelines(stub VS) can't catch. That's why it's a draft; #306's approach (keep rows, harmonize the mode) avoids it.Imported from Marvisak/VIctory. Originally posted by SAitken91 on 2026-11-24T14:56:35Z.
Closing in favour of #306, which keeps signature rows in place and harmonizes the interpolation mode instead, so VS/PS (row, col) stay identical and pipelines link (per @alexander-src's RTX 5090/WARP results above). Thanks to everyone who tested and reviewed this.
Pull request closed