Match interpolation modifiers between the pixel shader and the stage feeding it (PSO linkage #660/#662) #36
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
library
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/omonkeyz--xbox-emulator!36
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/36/head"
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?
@QuentinDanblon on GitHub · 2026-11-21 18:46 UTC · original
QuentinDanblon:fix/interp-modifiers-linked→main· +521 −68 · 8 files · 104 commits · closed without mergingLibrary / area: tombox-xshader (stage output signatures) + d3d12_xs (graphics/stream PSO translation, shader cache key), xreplay
Exports changed (exports.txt rows): none
Source of the behaviour: D3D12 signature linkage rules (DXC packs elements into one register only when their interpolation modes match). Ported and adapted from brcly/TomBox 6b49c14 (GDAgent; crates declare MIT OR Apache-2.0).
Bug
The translated pixel shader declares
_centroidinputs ascentroid(hlsl.rsSIn). The VS/GS/MS feeding it declared no modifiers on its outputs (hlsl.rsSOut,hlsl/mesh.rs), and nothing in d3d12_xs reconciled the two. As a result DXC packs the two signatures differently. Reproduced with DXC: TEXCOORD0 float2 linear + TEXCOORD1 float2 centroid puts TEXCOORD1 in r1.zw in the VS but r2.xy in the PS. D3D12 then rejects the pipeline (SHADER_LINKAGE_REGISTERINDEX #660 / REGISTERMASK #662) and every draw using it is lost. Integer varyings were already fine, because DXC defaults them to nointerpolation on both sides.Fix
hlsl::ps_input_interp(&ShaderExtract)derives the PS input modifiers from the PS extract alone. Unlike brcly's version, it does not need the PS translated first. It uses the sameps_input_modifierthe PS emitter uses. Only non-default modifiers are recorded, and SV_Position is left out. So a PSO without centroid/flat float inputs keeps exactly the same HLSL and cache key as today.hlsl::translate_linkedputs those modifiers on the matching outputs of the feeding stage (GS, else DS, else VS; MS for stream PSOs). Integer outputs only accept nointerpolation.create_gfx_pso_x, stream PSOs (mesh_pso.rs), hot reload and prefetch all translate the feeding stage with its PS link. Its cache key islink_key(cache_key(hash, rtfmt), link): unchanged when the link is empty, FNV-mixed otherwise. Linked variants are not written to the prewarm source directory, because prewarm cannot rebuild the link.xreplay --retranslatelinks the same way.Tests
New
tests/linkage.rs(3 tests) covers:hr < 0; linked: created).New d3d12_xs unit test
feeding_stage_key_follows_the_pixel_shader_modifiers: different modifier sets do not collide.cargo test -p tombox-xshader --release --lib --test opcodes --test synthetic --test linkage: 8 / 22 / 7 / 3 pass.Full
--test exec: 56 pass / 4 fail, same as main (thevop::basicfailures, fixed in #24).--test mesh: 12 / 2, same as main (fixture + #19).cargo build --release -p d3d12_xs -p xreplay: OK.cargo test -p d3d12_xs --lib shader_xlat:: mesh_pso::: 5 + 5 pass. This needed theCOND_POOL_TESTfix from #18 locally; that fix is not included here.Not run against a title.
cargo test -p tombox-xshaderpasses (except the failures already on main)No game or console files and no binaries included
No fake success; anything not possible is left
missingwith a note@QuentinDanblon on GitHub · 2026-11-21 22:02 UTC · original
Rebased onto
0fc7295, with the targeted tests re-run on the new base. #49 keeps the fused f16 FMA at VOP2 0x36-0x38 (gfx1013 v_fmac/fmamk/fmaak_f16) and updates the upstream ISA-sweep cases to the fused model. #36 adapts to upstream's TB_CEN_Q centroid qualifier. #48 now also includes the 4 regression scenarios from #28, credited.@QuentinDanblon on GitHub · 2026-11-21 23:09 UTC · original
Rebased onto
8491769; the conflict inshader_xlat.rsis resolved. Main replaced the per-blob disk cache with the pack keyed by the generated HLSL, so the linked variant no longer needs a disk key of its own: a linked translation produces different HLSL and therefore a different pack key. The in-memory cell still useslink_key, and the prewarm manifest still records unlinked shaders only.--test linkage: 3 / 3.d3d12_xs --lib shader_xlat: 8 / 8.d3d12_xs --lib: 410 passed, 1 failed,centroid_bind::tests::lowered_pixel_shader_compiles_with_fxc_in_both_variants. FXC rejectsuint64_tintb_nrm, a helper that comes from main and that this PR does not touch (the error #63 describes). I did not run that test on main itself.@QuentinDanblon on GitHub · 2026-11-22 11:36 UTC · original
Rebased onto
51f5319. One conflict inshader_xlat.rs(translate_mesh_with_root): main'sshader_dump::notecall is kept next to the linked cache cell.The mismatch is still on main.
hlsl.rs6222-6240 putscentroid/TB_CEN_Qon the pixel shader inputs, and the outputs of the stage feeding it (SOut, 6243-6256) carry no modifier.tests/linkage.rschecks both halves on this base: for the unlinked pair DXC assigns different registers and WARP refuses the PSO, the linked pair is created.Tests on this base:
cargo test -p tombox-xshader --release --lib --test linkage --test ps_linkage --test opcodes --test synthetic --test centroid: 60 / 3 / 1 / 22 / 11 / 1 pass.--test execon WARP: 73 of 73.--test mesh: 13 of 13.cargo test -p d3d12_xs --release --lib shader_xlat: 8 pass.mesh_pso: 6 pass.xshader_prelaunchandxprecompilestill translate each stage alone (hlsl::translate), so the linked variant of a feeding stage is not part of what they precompile.@omonkeyz on GitHub · 2026-11-22 13:12 UTC · original
Main's history was rewritten, which auto-closed this PR. It is applied in
0ad667f(merged in81a1252) with your authorship kept, thanks! The added comment lines were stripped on the applied copy (the project keeps code free of comment lines). brcly/TomBox is credited in the THIRD_PARTY files (14e873c).@omonkeyz on GitHub · 2026-11-22 13:15 UTC · original
Small follow-up: credits now live in one root file, so the per-crate THIRD_PARTY entry for this PR moved to THIRD_PARTY/CREDITS (
79a3b2f). CONTRIBUTING.md is updated to match.Pull request closed