Direct DXIL: compute_deps() poisons memo tables on cyclic phis/loops and omits store pointer/control dependencies in dx.viewIdState / PSV0 #1882

Open
opened 2026-11-24 22:37:51 +00:00 by microwave805 · 3 comments
microwave805 commented 2026-11-24 22:37:51 +00:00 (Migrated from github.com)
Contributor

Imported from ivall/xcl. Originally posted by microwave805 on 2026-11-24T22:37:51Z.


Static audit on main @ 689f2db found two soundness bugs in compute_deps() (crates/xcl/src/gpu/dxil/graphics.rs:755-861), which computes the input-to-output dependency tables written into DXIL dx.viewIdState metadata and the PSV0 container part. (Note: open PR #1770 preserves 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

  1. Memo poisoning on cyclic PHIs and loops (graphics.rs:786-808, 859)
    To break recursion cycles, value_deps inserts an empty BTreeSet::new() into memo before recursing (graphics.rs:808), and block_deps does the same for ctrl_memo (graphics.rs:790):

    • Suppose a loop has PHI A (depending on loadInput(in0) on the preheader edge and B on the back-edge) and PHI/value B (depending on A).
    • If value_deps(A) starts first, memo[A] is seeded with {}. When value_deps(A) recurses into B, B reads memo[A] (getting {}), computes B's dependencies without in0, and permanently caches that incomplete set in memo[B].
    • Any output derived from B then omits in0 from dx.viewIdState / PSV0, which causes DXIL validation failures or broken shader-stage linkage / interpolation optimization on drivers.
    • The same happens in block_deps for mutually control-dependent blocks inside loops.
  2. Incomplete memory / control dependencies for Store and Alloca/TGSM loads (graphics.rs:758-771, 843-858)

    • root_stores (graphics.rs:760-762) only records the stored value v — it omits the store's pointer operand p (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 dependency block_deps(store_block) (so a conditional store gated by an input-dependent branch is lost on subsequent loads).
    • block_of is built across all instructions (graphics.rs:755-759) and then explicitly ignored at graphics.rs:858 (let _ = cx.block_of;).

Fix direction

  • Replace the single-pass recursive memoization with a monotone worklist / fixed-point propagation over (value_deps, block_deps) (or Tarjan SCC condensation) so cyclic PHIs and loops converge to the exact union of dependencies without memo poisoning.
  • Include p and block_deps(store_block) in root_stores entries (and for atomics in graphics.rs:763-770) so loads from alloca / TGSM capture pointer-index and control-flow dependencies.

AI use

  • Antigravity (Gemini 4 Neon): static code audit on main @ 689f2db and issue drafting.
<!-- greyfinch-sync:ivall/xcl:issue:6592813344 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/issues/1892). Originally posted by [microwave805](https://github.com/microwave805) on 2026-11-24T22:37:51Z. --- Static audit on `main @ 689f2db` found two soundness bugs in `compute_deps()` (`crates/xcl/src/gpu/dxil/graphics.rs:755-861`), which computes the input-to-output dependency tables written into DXIL `dx.viewIdState` metadata and the `PSV0` container part. *(Note: open PR `#1770` preserves 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 1. **Memo poisoning on cyclic PHIs and loops (`graphics.rs:786-808, 859`)** To break recursion cycles, `value_deps` inserts an empty `BTreeSet::new()` into `memo` before recursing (`graphics.rs:808`), and `block_deps` does the same for `ctrl_memo` (`graphics.rs:790`): - Suppose a loop has PHI `A` (depending on `loadInput(in0)` on the preheader edge and `B` on the back-edge) and PHI/value `B` (depending on `A`). - If `value_deps(A)` starts first, `memo[A]` is seeded with `{}`. When `value_deps(A)` recurses into `B`, `B` reads `memo[A]` (getting `{}`), computes `B`'s dependencies **without `in0`**, and permanently caches that incomplete set in `memo[B]`. - Any output derived from `B` then omits `in0` from `dx.viewIdState` / `PSV0`, which causes DXIL validation failures or broken shader-stage linkage / interpolation optimization on drivers. - The same happens in `block_deps` for mutually control-dependent blocks inside loops. 2. **Incomplete memory / control dependencies for `Store` and `Alloca`/TGSM loads (`graphics.rs:758-771, 843-858`)** - `root_stores` (`graphics.rs:760-762`) only records the stored value `v` — it omits the store's pointer operand `p` (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 dependency `block_deps(store_block)` (so a conditional store gated by an input-dependent branch is lost on subsequent loads). - `block_of` is built across all instructions (`graphics.rs:755-759`) and then explicitly ignored at `graphics.rs:858` (`let _ = cx.block_of;`). ### Fix direction - Replace the single-pass recursive memoization with a monotone worklist / fixed-point propagation over `(value_deps, block_deps)` (or Tarjan SCC condensation) so cyclic PHIs and loops converge to the exact union of dependencies without memo poisoning. - Include `p` and `block_deps(store_block)` in `root_stores` entries (and for atomics in `graphics.rs:763-770`) so loads from `alloca` / TGSM capture pointer-index and control-flow dependencies. ### AI use - Antigravity (Gemini 4 Neon): static code audit on `main @ 689f2db` and issue drafting.
Decodere commented 2026-11-25 00:09:09 +00:00 (Migrated from github.com)
Author
Contributor

Imported from ivall/xcl. Originally posted by Decodere on 2026-11-24T23:55:25Z.


Stepping back from #1892 in favor of #1966 (just opened) to avoid duplicate/overlapping edits in graphics.rs.

<!-- greyfinch-sync:ivall/xcl:comment:7147942841 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/issues/1892#issuecomment-7147942841). Originally posted by [Decodere](https://github.com/Decodere) on 2026-11-24T23:55:25Z. --- Stepping back from `#1892` in favor of `#1966` (just opened) to avoid duplicate/overlapping edits in `graphics.rs`.
JJAutoCompare commented 2026-11-25 01:11:04 +00:00 (Migrated from github.com)
Author
Contributor

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 6567c5ffa38fbc7039b2d6bf520154689cc1f482 and PR #1966 head 25298fb70155f9b7c724560b7af4455bc9a4a450. Windows 11 build 26200.9974, Ryzen 7 3800X, Rust 1.100.0 MSVC. The two harnesses used the same fixture and matching auxiliary source modules.

  • harness.exe loop ran 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.dxil completed 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 mask 0b10 in dx.viewIdState and PSV0. These cases expect 0b11 because 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 of git diff --full-index --binary for the tested patch is f1be92ad2039df7c881954b06e10e02bced44bc7652e648cdd62da7b099d7ce6.

Windows 11 build 26200.9974, Ryzen 7 3800X, Rust 1.100.0 MSVC debug, DXC and DXIL 1.9.2609.5. The isolated checkout, Cargo target and temporary directory were under L:/XclTooling/1892-store-deps with CARGO_BUILD_JOBS=2 and CARGO_INCREMENTAL=0. The draw run used Intel Arc A770 driver 32.0.101.9175 with XCL_ADAPTER=A770.

  • Base plus tests, 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 emitted 0b10 in both dx.viewIdState and PSV0.
  • Patched CPU and DXC, 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 asserted 0b11 in both encodings and passed DXC validation. The existing loop and DXC PSV0 comparison regressions passed.
  • Patched Arc draws, & '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.

<!-- greyfinch-sync:ivall/xcl:comment:7148952256 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/issues/1892#issuecomment-7148952256). Originally posted by [JJAutoCompare](https://github.com/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 `6567c5ffa38fbc7039b2d6bf520154689cc1f482` and PR #1966 head `25298fb70155f9b7c724560b7af4455bc9a4a450`. Windows 11 build `26200.9974`, Ryzen 7 3800X, Rust `1.100.0` MSVC. The two harnesses used the same fixture and matching auxiliary source modules. - `harness.exe loop` ran 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.dxil` completed 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 mask `0b10` in `dx.viewIdState` and PSV0. These cases expect `0b11` because 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 of `git diff --full-index --binary` for the tested patch is `f1be92ad2039df7c881954b06e10e02bced44bc7652e648cdd62da7b099d7ce6`. Windows 11 build `26200.9974`, Ryzen 7 3800X, Rust `1.100.0` MSVC debug, DXC and DXIL `1.9.2609.5`. The isolated checkout, Cargo target and temporary directory were under `L:/XclTooling/1892-store-deps` with `CARGO_BUILD_JOBS=2` and `CARGO_INCREMENTAL=0`. The draw run used Intel Arc A770 driver `32.0.101.9175` with `XCL_ADAPTER=A770`. - Base plus tests, `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 emitted `0b10` in both `dx.viewIdState` and `PSV0`. - Patched CPU and DXC, `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 asserted `0b11` in both encodings and passed DXC validation. The existing loop and DXC PSV0 comparison regressions passed. - Patched Arc draws, `& '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.
thehollowedone commented 2026-11-28 10:48:36 +00:00 (Migrated from github.com)
Author
Contributor

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_deps regression, two separate memory roots receive different input components. The shader then exports the old values returned by atomic_rmw and cmpxchg. On unchanged #2035, the first output's dependency set was {} instead of {0} (0 passed, 1 failed). A simpler version also failed on current main e429936. 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 Other operations 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} for atomic_rmw and {1} for cmpxchg (1 passed, 0 failed). The 29 gpu::dxil::graphics::tests passed; cargo build --offline --locked -j 4 --workspace passed. cargo test --offline --locked -j 4 --workspace --no-fail-fast -- --test-threads=4 reported 1,426 passed, 1 failed, 46 ignored, and 25 GPU skip notices. The failure was console_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
diff --git a/crates/xcl/src/gpu/dxil/graphics.rs b/crates/xcl/src/gpu/dxil/graphics.rs
index bb913c80..f0e0eb99 100644
--- a/crates/xcl/src/gpu/dxil/graphics.rs
+++ b/crates/xcl/src/gpu/dxil/graphics.rs
@@ -833,6 +833,16 @@ fn compute_deps(s: &Shader, inputs: &[Placed], outputs: &[Placed], prims: &[Plac
         }
         Sets::close(&mut st.blocks, b, d, st.pass, &mut st.grew)
     }
+    fn add_root_write_deps(cx: &Cx, p: Value, st: &mut Sets, d: &mut BTreeSet<u32>) {
+        if let Some(writes) = cx.root_stores.get(&root(cx.s, p)) {
+            for (operands, block) in writes {
+                for &x in operands {
+                    d.extend(value_deps(cx, x, st));
+                }
+                d.extend(block_deps(cx, *block, st));
+            }
+        }
+    }
     fn value_deps(cx: &Cx, v: Value, st: &mut Sets) -> BTreeSet<u32> {
         let Value::Inst(i) = v else { return BTreeSet::new() };
         if let Some(d) = Sets::known(&st.values, &v, st.pass, &mut st.cut) {
@@ -875,16 +885,15 @@ fn compute_deps(s: &Shader, inputs: &[Placed], outputs: &[Placed], prims: &[Plac
             }
             InstInfo::Load(p) => {
                 d.extend(value_deps(cx, p, st));
-                if let Some(writes) = cx.root_stores.get(&root(cx.s, p)) {
-                    for (operands, block) in writes {
-                        for &x in operands {
-                            d.extend(value_deps(cx, x, st));
-                        }
-                        d.extend(block_deps(cx, *block, st));
-                    }
+                add_root_write_deps(cx, p, st, &mut d);
+            }
+            InstInfo::Atomic(ops) => {
+                for &x in &ops {
+                    d.extend(value_deps(cx, x, st));
                 }
+                add_root_write_deps(cx, ops[0], st, &mut d);
             }
-            InstInfo::Atomic(ops) | InstInfo::Other(ops) => {
+            InstInfo::Other(ops) => {
                 for x in ops {
                     d.extend(value_deps(cx, x, st));
                 }
diff --git a/crates/xcl/src/gpu/dxil/graphics_tests.rs b/crates/xcl/src/gpu/dxil/graphics_tests.rs
index 492ad83b..95e59265 100644
--- a/crates/xcl/src/gpu/dxil/graphics_tests.rs
+++ b/crates/xcl/src/gpu/dxil/graphics_tests.rs
@@ -828,6 +828,30 @@ fn store_all(io: &mut GraphicsIo, s: &mut Shader, stores: &[(Sig, u8, Value)]) {
     }
 }
 
+#[test]
+fn atomic_old_values_depend_on_stores_to_their_roots() {
+    let mut s = Shader::new(Stage::Vertex, (6, 6));
+    let mut io = GraphicsIo::new(Stage::Vertex);
+    let input = io.input(SigElement::user("VALUE", 0, CompType::U32, 2));
+    let output = io.output(SigElement::user("OLD", 0, CompType::U32, 2));
+    let x0 = io.load_input(&mut s, input, 0, 0);
+    let x1 = io.load_input(&mut s, input, 0, 1);
+    let i32 = s.m.i32();
+    let p0 = s.m.global("scratch0", i32, 3, None, false, 4);
+    let p1 = s.m.global("scratch1", i32, 3, None, false, 4);
+    let one = s.m.i32c(1);
+    s.m.store(p0, x0, 4);
+    s.m.store(p1, x1, 4);
+    let old0 = s.m.atomic_rmw(RmwOp::Add, p0, one);
+    let old1 = s.m.cmpxchg(p1, one, one);
+    io.store_output(&mut s, output, 0, 0, old0);
+    io.store_output(&mut s, output, 0, 1, old1);
+
+    let deps = compute_deps(&s, &io.place(Dir::In), &io.place(Dir::Out), &[]);
+    assert_eq!(deps.out[&(0, 0)], BTreeSet::from([0]), "atomic_rmw old value depends only on the first root");
+    assert_eq!(deps.out[&(0, 1)], BTreeSet::from([1]), "cmpxchg old value depends only on the second root");
+}
+
 #[test]
 fn store_dependency_includes_the_address_input() {
     let mut s = Shader::new(Stage::Vertex, (6, 6));

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.

<!-- greyfinch-sync:ivall/xcl:comment:7238136274 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/issues/1892#issuecomment-7238136274). Originally posted by [thehollowedone](https://github.com/thehollowedone) on 2026-11-28T10:48:36Z. --- Remaining #1892 dependency case, tested on [#2035 head `045a439`](https://github.com/xcl-dev/xcl/commit/045a439ab37b27014e5b833a3edf1de3e118134b). #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](https://github.com/xcl-dev/xcl/pull/2035#issuecomment-7237995491). In a CPU-only `compute_deps` regression, two separate memory roots receive different input components. The shader then exports the old values returned by `atomic_rmw` and `cmpxchg`. On unchanged #2035, the first output's dependency set was `{}` instead of `{0}` (0 passed, 1 failed). A simpler version also failed on current `main` [`e429936`](https://github.com/xcl-dev/xcl/commit/e429936c10a5b8aa09470ff99dfc8c8d3d8c56fd). 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 `Other` operations 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](https://github.com/microsoft/DirectXShaderCompiler/blob/main/lib/HLSL/ComputeViewIdStateBuilder.cpp#L543-L592). On the candidate, the exact sets were `{0}` for `atomic_rmw` and `{1}` for `cmpxchg` (1 passed, 0 failed). The 29 `gpu::dxil::graphics::tests` passed; `cargo build --offline --locked -j 4 --workspace` passed. `cargo test --offline --locked -j 4 --workspace --no-fail-fast -- --test-threads=4` reported 1,426 passed, 1 failed, 46 ignored, and 25 GPU skip notices. The failure was `console_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. <details><summary>Tested candidate diff against #2035</summary> ```diff diff --git a/crates/xcl/src/gpu/dxil/graphics.rs b/crates/xcl/src/gpu/dxil/graphics.rs index bb913c80..f0e0eb99 100644 --- a/crates/xcl/src/gpu/dxil/graphics.rs +++ b/crates/xcl/src/gpu/dxil/graphics.rs @@ -833,6 +833,16 @@ fn compute_deps(s: &Shader, inputs: &[Placed], outputs: &[Placed], prims: &[Plac } Sets::close(&mut st.blocks, b, d, st.pass, &mut st.grew) } + fn add_root_write_deps(cx: &Cx, p: Value, st: &mut Sets, d: &mut BTreeSet<u32>) { + if let Some(writes) = cx.root_stores.get(&root(cx.s, p)) { + for (operands, block) in writes { + for &x in operands { + d.extend(value_deps(cx, x, st)); + } + d.extend(block_deps(cx, *block, st)); + } + } + } fn value_deps(cx: &Cx, v: Value, st: &mut Sets) -> BTreeSet<u32> { let Value::Inst(i) = v else { return BTreeSet::new() }; if let Some(d) = Sets::known(&st.values, &v, st.pass, &mut st.cut) { @@ -875,16 +885,15 @@ fn compute_deps(s: &Shader, inputs: &[Placed], outputs: &[Placed], prims: &[Plac } InstInfo::Load(p) => { d.extend(value_deps(cx, p, st)); - if let Some(writes) = cx.root_stores.get(&root(cx.s, p)) { - for (operands, block) in writes { - for &x in operands { - d.extend(value_deps(cx, x, st)); - } - d.extend(block_deps(cx, *block, st)); - } + add_root_write_deps(cx, p, st, &mut d); + } + InstInfo::Atomic(ops) => { + for &x in &ops { + d.extend(value_deps(cx, x, st)); } + add_root_write_deps(cx, ops[0], st, &mut d); } - InstInfo::Atomic(ops) | InstInfo::Other(ops) => { + InstInfo::Other(ops) => { for x in ops { d.extend(value_deps(cx, x, st)); } diff --git a/crates/xcl/src/gpu/dxil/graphics_tests.rs b/crates/xcl/src/gpu/dxil/graphics_tests.rs index 492ad83b..95e59265 100644 --- a/crates/xcl/src/gpu/dxil/graphics_tests.rs +++ b/crates/xcl/src/gpu/dxil/graphics_tests.rs @@ -828,6 +828,30 @@ fn store_all(io: &mut GraphicsIo, s: &mut Shader, stores: &[(Sig, u8, Value)]) { } } +#[test] +fn atomic_old_values_depend_on_stores_to_their_roots() { + let mut s = Shader::new(Stage::Vertex, (6, 6)); + let mut io = GraphicsIo::new(Stage::Vertex); + let input = io.input(SigElement::user("VALUE", 0, CompType::U32, 2)); + let output = io.output(SigElement::user("OLD", 0, CompType::U32, 2)); + let x0 = io.load_input(&mut s, input, 0, 0); + let x1 = io.load_input(&mut s, input, 0, 1); + let i32 = s.m.i32(); + let p0 = s.m.global("scratch0", i32, 3, None, false, 4); + let p1 = s.m.global("scratch1", i32, 3, None, false, 4); + let one = s.m.i32c(1); + s.m.store(p0, x0, 4); + s.m.store(p1, x1, 4); + let old0 = s.m.atomic_rmw(RmwOp::Add, p0, one); + let old1 = s.m.cmpxchg(p1, one, one); + io.store_output(&mut s, output, 0, 0, old0); + io.store_output(&mut s, output, 0, 1, old1); + + let deps = compute_deps(&s, &io.place(Dir::In), &io.place(Dir::Out), &[]); + assert_eq!(deps.out[&(0, 0)], BTreeSet::from([0]), "atomic_rmw old value depends only on the first root"); + assert_eq!(deps.out[&(0, 1)], BTreeSet::from([1]), "cmpxchg old value depends only on the second root"); +} + #[test] fn store_dependency_includes_the_address_input() { let mut s = Shader::new(Stage::Vertex, (6, 6)); ``` </details> 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.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl#1882
No description provided.