Direct DXIL: compute_deps() poisons memo tables on cyclic phis/loops and omits store pointer/control dependencies in dx.viewIdState / PSV0 #1882
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 ivall/xcl. Originally posted by microwave805 on 2026-11-24T22:37:51Z.
Static audit on
main @ 689f2dbfound two soundness bugs incompute_deps()(crates/xcl/src/gpu/dxil/graphics.rs:755-861), which computes the input-to-output dependency tables written into DXILdx.viewIdStatemetadata and thePSV0container part. (Note: open PR#1770preserves the exact same traversal and memoization algorithm, so these bugs apply there too.)Where
crates/xcl/src/gpu/dxil/graphics.rs:755-861(compute_deps,block_deps,value_deps)Root causes
Memo poisoning on cyclic PHIs and loops (
graphics.rs:786-808, 859)To break recursion cycles,
value_depsinserts an emptyBTreeSet::new()intomemobefore recursing (graphics.rs:808), andblock_depsdoes the same forctrl_memo(graphics.rs:790):A(depending onloadInput(in0)on the preheader edge andBon the back-edge) and PHI/valueB(depending onA).value_deps(A)starts first,memo[A]is seeded with{}. Whenvalue_deps(A)recurses intoB,Breadsmemo[A](getting{}), computesB's dependencies withoutin0, and permanently caches that incomplete set inmemo[B].Bthen omitsin0fromdx.viewIdState/PSV0, which causes DXIL validation failures or broken shader-stage linkage / interpolation optimization on drivers.block_depsfor mutually control-dependent blocks inside loops.Incomplete memory / control dependencies for
StoreandAlloca/TGSM loads (graphics.rs:758-771, 843-858)root_stores(graphics.rs:760-762) only records the stored valuev— it omits the store's pointer operandp(so an input-dependent array index used to select which slot is written is lost on subsequent loads) AND omits the store's enclosing block control dependencyblock_deps(store_block)(so a conditional store gated by an input-dependent branch is lost on subsequent loads).block_ofis built across all instructions (graphics.rs:755-759) and then explicitly ignored atgraphics.rs:858(let _ = cx.block_of;).Fix direction
(value_deps, block_deps)(or Tarjan SCC condensation) so cyclic PHIs and loops converge to the exact union of dependencies without memo poisoning.pandblock_deps(store_block)inroot_storesentries (and for atomics ingraphics.rs:763-770) so loads fromalloca/ TGSM capture pointer-index and control-flow dependencies.AI use
main @ 689f2dband issue drafting.Imported from ivall/xcl. Originally posted by Decodere on 2026-11-24T23:55:25Z.
Stepping back from
#1892in favor of#1966(just opened) to avoid duplicate/overlapping edits ingraphics.rs.Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T00:51:10Z.
Standalone CPU regression check for #1892
I reran a local Rust harness using the DXIL graphics code from
6567c5ffa38fbc7039b2d6bf520154689cc1f482and PR #1966 head25298fb70155f9b7c724560b7af4455bc9a4a450. Windows 11 build26200.9974, Ryzen 7 3800X, Rust1.100.0MSVC. The two harnesses used the same fixture and matching auxiliary source modules.harness.exe loopran the PR regression. Main failed with “output B depends on input X through the loop; its inputs: {}” (exit 101). The PR head passed (exit 0).harness.exe memory <out-dir> tests/data/dxil/dxc_vs_control.dxilcompleted on both heads (exit 0). The existing VS control case produced the same PSV0 bytes as its DXC reference. For a load influenced by an input-dependent write index and for a load influenced by a conditional write, both heads emitted the dependency mask0b10indx.viewIdStateand PSV0. These cases expect0b11because both outputs depend on the input. The harness printed these masks and did not assert their expected value, hence the successful process exits.These are harness checks. No Cargo suite, GPU execution, or DXIL validation was run. Test and report prepared with Codex in T3 Code (
gpt-6.2-sol).Cargo and DXC follow-up on #1966
Base
25298fb70155f9b7c724560b7af4455bc9a4a450. The base run added only the two regression tests. The patched runs used the local, uncommitted diff on that same base. SHA-256 ofgit diff --full-index --binaryfor the tested patch isf1be92ad2039df7c881954b06e10e02bced44bc7652e648cdd62da7b099d7ce6.Windows 11 build
26200.9974, Ryzen 7 3800X, Rust1.100.0MSVC debug, DXC and DXIL1.9.2609.5. The isolated checkout, Cargo target and temporary directory were underL:/XclTooling/1892-store-depswithCARGO_BUILD_JOBS=2andCARGO_INCREMENTAL=0. The draw run used Intel Arc A770 driver32.0.101.9175withXCL_ADAPTER=A770.cargo test -p xcl --lib vs_load_depends_on_store_ -- --nocapture --test-threads=1. 0 passed, 2 failed as expected, 0 ignored, 0 skipped, 967 filtered, exit 101. The input-dependent write index and conditional write each emitted0b10in bothdx.viewIdStateandPSV0.cargo test -p xcl --lib gpu::dxil::graphics::tests:: -- --nocapture --test-threads=1 --skip emitted_. 23 passed, 0 failed, 0 ignored, 0 skipped, 946 filtered, exit 0. Both new fixtures asserted0b11in both encodings and passed DXC validation. The existing loop and DXC PSV0 comparison regressions passed.& 'L:/XclTooling/Invoke-ArcTest.ps1' -Test { cargo test -p xcl --lib gpu::dxil::graphics::tests::emitted_ -- --nocapture --test-threads=1 }. 4 passed, 0 failed, 0 ignored, 0 skipped, 965 filtered, exit 0. The wrapper acquired and released the Arc lock. It ran with a process-scoped PowerShell execution policy override.Not tested
GPU execution of the two new fixtures, other adapters, retail shaders, title smoke, and the full workspace suite.
AI use
Codex in T3 Code (
gpt-6.2-sol) wrote the local patch and tests, ran them, and prepared this report.upstream-sync referenced this issue2026-11-25 04:08:41 +00:00
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-28T10:48:36Z.
Remaining #1892 dependency case, tested on #2035 head
045a439. #2035 fixes dependencies of later loads; this follow-up concerns an atomic instruction's returned old value used directly by a graphics output. It does not change my scoped #2035 merge check.In a CPU-only
compute_depsregression, two separate memory roots receive different input components. The shader then exports the old values returned byatomic_rmwandcmpxchg. On unchanged #2035, the first output's dependency set was{}instead of{0}(0 passed, 1 failed). A simpler version also failed on currentmaine429936. The fixture exercises the dependency analysis directly; its synthetic vertex/TGSM combination was not validated as a runnable shader.The candidate below makes loads and atomic results traverse the same per-root write operands and control blocks. It keeps
Otheroperations unchanged and writes into the existing dependency set, avoiding a second set allocation per call. This follows DXC's handling of load and atomic results. On the candidate, the exact sets were{0}foratomic_rmwand{1}forcmpxchg(1 passed, 0 failed). The 29gpu::dxil::graphics::testspassed;cargo build --offline --locked -j 4 --workspacepassed.cargo test --offline --locked -j 4 --workspace --no-fail-fast -- --test-threads=4reported 1,426 passed, 1 failed, 46 ignored, and 25 GPU skip notices. The failure wasconsole_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk, also seen on untouched main in this environment.This is an uncommitted suggestion against #2035's head, not a new PR or a clean-commit smoke run. I have not measured shader translation time or validated a legal GPU shader exercising this exact path.
Tested candidate diff against #2035
AI use: Codex (GPT-6.2 Sol) wrote and ran the regression and candidate and drafted this report; Codex (GPT-6.2 Astra) independently reviewed the dependency traversal.