GPU: prevent overflow and enforce workload bounds in indirect execution #40

Closed
github-bot wants to merge 5 commits from gh-pr/40/head into gh-pr/40/base
Owner

@⁠aycow on GitHub · 2026-11-23 23:39 UTC · original
aycow:fix/indirect-workload-validation → main · +1100 −129 · 6 files · 5 commits · closed without merging

What

The sanitizer introduced in 8c26061f3 multiplied compute dimensions in 32-bit arithmetic before capping the result. It capped the charged cost while leaving oversized grids in the argument buffer. Its budget counter also added rejected costs, so it could wrap and admit work after the limit was reached.

The original shader left [2048, 2048, 1024] intact after the 2^32 product wrapped to zero. It also retained [1025, 1024, 1] above the 2^20 group limit. The synthetic tests run the sanitizer and inspect the resulting arguments and budget. They never execute the oversized dispatches.

  • Check the D3D12 axis limits and the compute group limit before multiplying. Preserve valid grids and empty excessive dispatches.
  • Use a Shader Model 5.1 compare-exchange loop so rejected work leaves the budget available. Reset the budget under the submission lock. The branch incorporates main at 35b054e, including its 2^27 budget and the single-pass dispatch mapping.

Review changes

  • Argument and count shadows start in COMMON but may already have been used for shader or other buffer accesses by the time indirect execution runs. A prelude selects enhanced buffer barriers at the start of each native submission, including when GPU timing submits lists individually. The barriers order previous accesses, validation, indirect reads, and later uses. An argument and count that share a native resource are synchronized together. On the legacy path, only the argument resource transitions from UAV to INDIRECT_ARGUMENT around execution and returns to COMMON afterward, including on early exit. A distinct count can promote from COMMON. The fallback preserves explicit title barriers between UAV or COPY_DEST and INDIRECT_ARGUMENT for existing buffer shadows by handing them off through COMMON. A write earlier in the same native submission still requires a handoff. Buffers decay at submission boundaries.
  • Title validation and host shadow resolution use the same span through the last argument. Two 12-byte dispatch records with a 16-byte stride need 28 bytes. The old check required 32. Zero records take zero bytes, and alignment, minimum stride, dispatch size, and shader addressing are still checked.

Tested

Check on 22b9ed1 Enhanced Forced legacy
AMD Radeon Graphics, D3D12 debug layer 14 passed 14 passed
AMD Radeon Graphics, debug layer and full GPU-based validation 14 passed 14 passed
Microsoft WARP, D3D12 debug layer 14 passed 14 passed
Microsoft WARP, debug layer and full GPU-based validation 14 passed 14 passed

The app-local Microsoft Agility SDK 1.620.2 enabled the debug layer. The validation run checked device configuration for active GPU-based validation with resource-state tracking and failed on D3D12 InfoQueue errors. The matrix covers CPU-generated counts, shared argument/count resources, same-submission UAV and copy producers, and repeated executions across submission boundaries. With the legacy handoff deliberately omitted, a same-list negative control reported the count buffer still in COPY_DEST or UAV when ExecuteIndirect required INDIRECT_ARGUMENT. Restoring the handoff passed on AMD and WARP.

Run cargo test -p victory-gpu --features diagnostics indirect -- --nocapture --test-threads=1 with an active debug runtime. Set VICTORY_D3D12_DEBUG=1 and VICTORY_TEST_D3D12_VALIDATE=1, and add VICTORY_D3D12_GBV=1 for full validation. Use VICTORY_TEST_LEGACY_INDIRECT=1 to force legacy barriers and VICTORY_D3D12_WARP=1 for WARP. Workspace tests passed (240 passed, 3 ignored), as did cargo check --workspace --all-targets. The prior diagnostics Clippy, policy and diff checks passed on this same commit.

The bounds tests reject a buffer one byte short and execute a final record at a nonzero offset with no trailing padding. A separate native D3D12 probe used explicit COPY_DEST-to-INDIRECT_ARGUMENT transitions, verified the count and recorded shader invocations. On AMD Radeon Graphics (PCI 1002:1114, driver 32.0.22042.1), a zero count still executed the first dispatch. A two-record call also executed only its first dispatch, even without a count buffer. The native probe matched 44 of 88 expectations on AMD and all 88 on WARP and NVIDIA RTX 5070 Laptop with full GPU-based validation, with no debug errors. The AMD result also reproduced with the inbox runtime. This establishes reproduction outside VIctory on the tested adapter and driver. The cause within the driver or runtime remains undetermined.

DaviTostes independently tested the exact head on Arch Linux with an RX 9060 XT, RADV 26.3.1, Wine 11.22, vkd3d-proton 3.1 and native Microsoft d3dcompiler_47. All 13 indirect tests included by that build passed. The victory_gpu suite was 50 passed and two failed for the separately reported pipeline-library and mapped-memory cases. On the preceding a2ab63d revision, Wine’s built-in compiler rejected RWByteAddressBuffer.Load before the tests could exercise the indirect path. Exact-head Proton run · Compiler control

A separate composition with #178 at f435ad1 exercises its DXC fallback. In-process Windows SDK 26100 DXC returned unsigned bytecode even with its companion dxil.dll in the compiler folder. The review patch uses the existing DXIL validator to sign that output. On Windows, all 14 cases passed on AMD and WARP with enhanced and forced legacy barriers, under both FXC and forced DXC, with full GPU-based validation. The composition is available for the #178 review. Compiler proposal · Test branch · Signer patch

Scope

The sanitizer still scans MaxCommandCount for counted calls. Reading the actual GPU count before charging records is a separate follow-up. PR #24 covers the distinct DispatchMeshX entry point. The title watchdog and world rendering remain unverified.

This contribution was AI-assisted with OpenAI Codex.

**@⁠aycow** on GitHub · 2026-11-23 23:39 UTC · [original](https://github.com/Marvisak/VIctory/pull/40) `aycow:fix/indirect-workload-validation` → `main` · +1100 −129 · 6 files · 5 commits · closed without merging ## What The sanitizer introduced in 8c26061f3 multiplied compute dimensions in 32-bit arithmetic before capping the result. It capped the charged cost while leaving oversized grids in the argument buffer. Its budget counter also added rejected costs, so it could wrap and admit work after the limit was reached. The original shader left `[2048, 2048, 1024]` intact after the 2^32 product wrapped to zero. It also retained `[1025, 1024, 1]` above the 2^20 group limit. The synthetic tests run the sanitizer and inspect the resulting arguments and budget. They never execute the oversized dispatches. - Check the D3D12 axis limits and the compute group limit before multiplying. Preserve valid grids and empty excessive dispatches. - Use a Shader Model 5.1 compare-exchange loop so rejected work leaves the budget available. Reset the budget under the submission lock. The branch incorporates `main` at 35b054e, including its 2^27 budget and the single-pass dispatch mapping. ## Review changes - Argument and count shadows start in COMMON but may already have been used for shader or other buffer accesses by the time indirect execution runs. A prelude selects enhanced buffer barriers at the start of each native submission, including when GPU timing submits lists individually. The barriers order previous accesses, validation, indirect reads, and later uses. An argument and count that share a native resource are synchronized together. On the legacy path, only the argument resource transitions from UAV to INDIRECT_ARGUMENT around execution and returns to COMMON afterward, including on early exit. A distinct count can promote from COMMON. The fallback preserves explicit title barriers between UAV or COPY_DEST and INDIRECT_ARGUMENT for existing buffer shadows by handing them off through COMMON. A write earlier in the same native submission still requires a handoff. Buffers decay at submission boundaries. - Title validation and host shadow resolution use the same span through the last argument. Two 12-byte dispatch records with a 16-byte stride need 28 bytes. The old check required 32. Zero records take zero bytes, and alignment, minimum stride, dispatch size, and shader addressing are still checked. ## Tested | Check on `22b9ed1` | Enhanced | Forced legacy | | --- | --- | --- | | AMD Radeon Graphics, D3D12 debug layer | 14 passed | 14 passed | | AMD Radeon Graphics, debug layer and full GPU-based validation | 14 passed | 14 passed | | Microsoft WARP, D3D12 debug layer | 14 passed | 14 passed | | Microsoft WARP, debug layer and full GPU-based validation | 14 passed | 14 passed | The app-local Microsoft Agility SDK 1.620.2 enabled the debug layer. The validation run checked device configuration for active GPU-based validation with resource-state tracking and failed on D3D12 InfoQueue errors. The matrix covers CPU-generated counts, shared argument/count resources, same-submission UAV and copy producers, and repeated executions across submission boundaries. With the legacy handoff deliberately omitted, a same-list negative control reported the count buffer still in COPY_DEST or UAV when ExecuteIndirect required INDIRECT_ARGUMENT. Restoring the handoff passed on AMD and WARP. Run `cargo test -p victory-gpu --features diagnostics indirect -- --nocapture --test-threads=1` with an active debug runtime. Set `VICTORY_D3D12_DEBUG=1` and `VICTORY_TEST_D3D12_VALIDATE=1`, and add `VICTORY_D3D12_GBV=1` for full validation. Use `VICTORY_TEST_LEGACY_INDIRECT=1` to force legacy barriers and `VICTORY_D3D12_WARP=1` for WARP. Workspace tests passed (240 passed, 3 ignored), as did `cargo check --workspace --all-targets`. The prior diagnostics Clippy, policy and diff checks passed on this same commit. The bounds tests reject a buffer one byte short and execute a final record at a nonzero offset with no trailing padding. A separate native D3D12 probe used explicit COPY_DEST-to-INDIRECT_ARGUMENT transitions, verified the count and recorded shader invocations. On AMD Radeon Graphics (PCI 1002:1114, driver 32.0.22042.1), a zero count still executed the first dispatch. A two-record call also executed only its first dispatch, even without a count buffer. The native probe matched 44 of 88 expectations on AMD and all 88 on WARP and NVIDIA RTX 5070 Laptop with full GPU-based validation, with no debug errors. The AMD result also reproduced with the inbox runtime. This establishes reproduction outside VIctory on the tested adapter and driver. The cause within the driver or runtime remains undetermined. DaviTostes independently tested the exact head on Arch Linux with an RX 9060 XT, RADV 26.3.1, Wine 11.22, vkd3d-proton 3.1 and native Microsoft `d3dcompiler_47`. All 13 indirect tests included by that build passed. The `victory_gpu` suite was 50 passed and two failed for the separately reported pipeline-library and mapped-memory cases. On the preceding `a2ab63d` revision, Wine’s built-in compiler rejected `RWByteAddressBuffer.Load` before the tests could exercise the indirect path. [Exact-head Proton run](https://git.gtahub.st/github/Marvisak--VIctory/pulls/40) · [Compiler control](https://git.gtahub.st/github/Marvisak--VIctory/pulls/40) A separate composition with #178 at `f435ad1` exercises its DXC fallback. In-process Windows SDK 26100 DXC returned unsigned bytecode even with its companion `dxil.dll` in the compiler folder. The review patch uses the existing DXIL validator to sign that output. On Windows, all 14 cases passed on AMD and WARP with enhanced and forced legacy barriers, under both FXC and forced DXC, with full GPU-based validation. The composition is available for the #178 review. [Compiler proposal](https://git.gtahub.st/github/Marvisak--VIctory/pulls/178) · [Test branch](https://github.com/aycow/VIctory/tree/test/indirect-dxc-178) · [Signer patch](https://github.com/aycow/VIctory/commit/f7411d0) ## Scope The sanitizer still scans `MaxCommandCount` for counted calls. Reading the actual GPU count before charging records is a separate follow-up. PR #24 covers the distinct `DispatchMeshX` entry point. The title watchdog and world rendering remain unverified. This contribution was AI-assisted with OpenAI Codex.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:47:42 +00:00
github-bot closed this pull request 2026-11-26 03:47:42 +00:00
Author
Owner

@⁠DaviTostes on GitHub · 2026-11-24 01:04 UTC · original

Tested a2ab63d under Wine 11.22 on Arch Linux x86_64 (AMD RX 9060 XT, RADV 26.3.1), Windows build with cargo xwin ... --target x86_64-pc-windows-msvc. Two environments, and the PR is fine in both — the first run's failures were a compiler gap:

  1. vkd3d-proton 3.1 + Wine's builtin d3dcompiler_47: 39 passed, 13 failed. All 13 are assert!(bound(...)) in indirect::tests::* (the 12 new tests plus argument_clamp_builds), because Wine's compiler rejects the clamp shader (E5005: Method 'Load' is not defined on type 'RWByteAddressBuffer'), clamp() returns None, and bound returns false.
  2. Same vkd3d-proton, with a native Microsoft d3dcompiler_47.dll on the DLL search path (WINEDLLOVERRIDES=d3dcompiler_47=n): 50 passed, 2 failed. The 12 new indirect tests and argument_clamp_builds all pass. The two remaining failures are environment-only:
    • a_rejected_blob_gives_an_empty_library — vkd3d-proton needs a non-empty blob for CreatePipelineLibrary;
    • buffer_data_reaches_the_host_texture — #128 (vkd3d-proton's mapped memory is invisible to VirtualQuery).
  3. Cross-check on Wine's built-in D3D12 (fresh prefix, no vkd3d-proton): 52/52 pass, including #128's test.

So the new indirect tests do run and pass against a real D3D12 implementation here; under Proton the native d3dcompiler_47 is the missing piece. Note that the test module adds 12 tests and is a strong addition — it exercised the bounds/barrier paths end to end.

No game data used. AI-assisted (DeepSeek V4.1 Flash coding agent).

**@⁠DaviTostes** on GitHub · 2026-11-24 01:04 UTC · [original](https://github.com/Marvisak/VIctory/pull/40#issuecomment-7118720063) Tested `a2ab63d` under Wine 11.22 on Arch Linux x86_64 (AMD RX 9060 XT, RADV 26.3.1), Windows build with `cargo xwin ... --target x86_64-pc-windows-msvc`. Two environments, and the PR is fine in both — the first run's failures were a compiler gap: 1. **vkd3d-proton 3.1 + Wine's builtin `d3dcompiler_47`**: 39 passed, **13 failed**. All 13 are `assert!(bound(...))` in `indirect::tests::*` (the 12 new tests plus `argument_clamp_builds`), because Wine's compiler rejects the clamp shader (`E5005: Method 'Load' is not defined on type 'RWByteAddressBuffer'`), `clamp()` returns `None`, and `bound` returns false. 2. **Same vkd3d-proton, with a native Microsoft `d3dcompiler_47.dll` on the DLL search path** (`WINEDLLOVERRIDES=d3dcompiler_47=n`): **50 passed, 2 failed**. The 12 new indirect tests and `argument_clamp_builds` all pass. The two remaining failures are environment-only: - `a_rejected_blob_gives_an_empty_library` — vkd3d-proton needs a non-empty blob for `CreatePipelineLibrary`; - `buffer_data_reaches_the_host_texture` — #128 (vkd3d-proton's mapped memory is invisible to `VirtualQuery`). 3. Cross-check on **Wine's built-in D3D12** (fresh prefix, no vkd3d-proton): **52/52 pass**, including #128's test. So the new indirect tests do run and pass against a real D3D12 implementation here; under Proton the native `d3dcompiler_47` is the missing piece. Note that the test module adds 12 tests and is a strong addition — it exercised the bounds/barrier paths end to end. No game data used. AI-assisted (DeepSeek V4.1 Flash coding agent).
Author
Owner

@⁠DaviTostes on GitHub · 2026-11-24 01:23 UTC · original

Re-checked the new head 22b9ed1 ("preserve legacy indirect count buffer handoffs") under Wine 11.22 + vkd3d-proton 3.1 (AMD RX 9060 XT, RADV 26.3.1), Windows build with a native Microsoft d3dcompiler_47: pass, no regression.

  • victory_gpu: 50 passed, 2 failed — the two environment-only failures (a_rejected_blob_gives_an_empty_library and #128). The 12 indirect tests plus argument_clamp_builds pass.
  • Same numbers as a2ab63d before this commit, so the handoff change did not disturb the suite here.

No game data used.

**@⁠DaviTostes** on GitHub · 2026-11-24 01:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/40#issuecomment-7119045211) Re-checked the new head `22b9ed1` ("preserve legacy indirect count buffer handoffs") under **Wine 11.22 + vkd3d-proton 3.1** (AMD RX 9060 XT, RADV 26.3.1), Windows build with a native Microsoft `d3dcompiler_47`: **pass, no regression**. - `victory_gpu`: **50 passed, 2 failed** — the two environment-only failures (`a_rejected_blob_gives_an_empty_library` and #128). The 12 indirect tests plus `argument_clamp_builds` pass. - Same numbers as `a2ab63d` before this commit, so the handoff change did not disturb the suite here. No game data used.
Author
Owner

@⁠aycow on GitHub · 2026-11-24 04:44 UTC · original

@⁠ifBars merge?

**@⁠aycow** on GitHub · 2026-11-24 04:44 UTC · [original](https://github.com/Marvisak/VIctory/pull/40#issuecomment-7122302336) @⁠ifBars merge?
Author
Owner

@⁠raffclar on GitHub · 2026-11-23 23:54 UTC · original · edited 2026-11-23 23:56 UTC
On crates/victory-gpu/src/indirect.rs line 217 (outdated):

@@ -159,31 +211,33 @@ pub(crate) fn bound(
         l.SetPipelineState(&c.pso);
         l.SetComputeRoot32BitConstants(0, 4, constants.as_ptr().cast(), 0);
         l.SetComputeRootUnorderedAccessView(1, gpu);
-        l.SetComputeRootUnorderedAccessView(2, budget);
-        l.Dispatch(records.div_ceil(64), 1, 1);
-        l.ResourceBarrier(&[
-            uav_barrier(),
-            transition(
+        l.SetComputeRootUnorderedAccessView(2, budget.GetGPUVirtualAddress());
+        l.Dispatch(records.div_ceil(THREADS_PER_GROUP), 1, 1);
+        l.ResourceBarrier(&[uav_barrier()]);
+        for buffer in [Some(buffer), count].into_iter().flatten() {

You need to track the count buffer's real state, or switch it from COMMON.

Before the indirect call, a barrier switches the count buffer to the state the call needs. The barrier says the buffer starts in the UAV state but the count buffer usually starts in COMMON instead because nothing in the list wrote to it as a UAV first. I'd first this before merging but verify yourself too.

**@⁠raffclar** on GitHub · 2026-11-23 23:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/40#discussion_r4673635324) · edited 2026-11-23 23:56 UTC On `crates/victory-gpu/src/indirect.rs` line 217 (outdated): ```diff @@ -159,31 +211,33 @@ pub(crate) fn bound( l.SetPipelineState(&c.pso); l.SetComputeRoot32BitConstants(0, 4, constants.as_ptr().cast(), 0); l.SetComputeRootUnorderedAccessView(1, gpu); - l.SetComputeRootUnorderedAccessView(2, budget); - l.Dispatch(records.div_ceil(64), 1, 1); - l.ResourceBarrier(&[ - uav_barrier(), - transition( + l.SetComputeRootUnorderedAccessView(2, budget.GetGPUVirtualAddress()); + l.Dispatch(records.div_ceil(THREADS_PER_GROUP), 1, 1); + l.ResourceBarrier(&[uav_barrier()]); + for buffer in [Some(buffer), count].into_iter().flatten() { ``` You need to track the count buffer's real state, or switch it from COMMON. Before the indirect call, a barrier switches the count buffer to the state the call needs. The barrier says the buffer starts in the UAV state but the count buffer usually starts in COMMON instead because nothing in the list wrote to it as a UAV first. I'd first this before merging but verify yourself too.
@ -1193,0 +1265,4 @@
/// may include other memory or padding beyond the title's buffer.
fn indirect_address(buffer: Option<(*mut u8, u64)>, offset: u64, len: u64) -> Option<u64> {
let (base, size) = buffer?;
if !offset.is_multiple_of(4) || offset.checked_add(len)? > size {
Author
Owner

@⁠raffclar on GitHub · 2026-11-23 23:56 UTC · original

The new size check assumes the last record in the argument buffer is a full stride long however.. it's often the buffer ends right after the last record's actual data.

I'd check against the start of the last record plus the argument size. I think byte_len already uses that rule

**@⁠raffclar** on GitHub · 2026-11-23 23:56 UTC · [original](https://github.com/Marvisak/VIctory/pull/40#discussion_r4673644402) The new size check assumes the last record in the argument buffer is a full stride long however.. it's often the buffer ends right after the last record's actual data. I'd check against the start of the last record plus the argument size. I think byte_len already uses that rule
Author
Owner

@⁠aycow on GitHub · 2026-11-24 00:14 UTC · original
On crates/victory-gpu/src/indirect.rs line 217 (outdated):

@@ -159,31 +211,33 @@ pub(crate) fn bound(
         l.SetPipelineState(&c.pso);
         l.SetComputeRoot32BitConstants(0, 4, constants.as_ptr().cast(), 0);
         l.SetComputeRootUnorderedAccessView(1, gpu);
-        l.SetComputeRootUnorderedAccessView(2, budget);
-        l.Dispatch(records.div_ceil(64), 1, 1);
-        l.ResourceBarrier(&[
-            uav_barrier(),
-            transition(
+        l.SetComputeRootUnorderedAccessView(2, budget.GetGPUVirtualAddress());
+        l.Dispatch(records.div_ceil(THREADS_PER_GROUP), 1, 1);
+        l.ResourceBarrier(&[uav_barrier()]);
+        for buffer in [Some(buffer), count].into_iter().flatten() {

Thanks for flagging the state assumption. A shadow may already have GPU reads or writes, and it does not decay between lists submitted together. The revision selects enhanced barriers at the start of each native submission, orders the producer and indirect accesses, and leaves buffers available for their next use. A shared argument/count resource is handled once. CPU, UAV and copy producers, resubmission, and split timing submissions passed on AMD and WARP. The debug layer was unavailable here.

**@⁠aycow** on GitHub · 2026-11-24 00:14 UTC · [original](https://github.com/Marvisak/VIctory/pull/40#discussion_r4673794748) On `crates/victory-gpu/src/indirect.rs` line 217 (outdated): ```diff @@ -159,31 +211,33 @@ pub(crate) fn bound( l.SetPipelineState(&c.pso); l.SetComputeRoot32BitConstants(0, 4, constants.as_ptr().cast(), 0); l.SetComputeRootUnorderedAccessView(1, gpu); - l.SetComputeRootUnorderedAccessView(2, budget); - l.Dispatch(records.div_ceil(64), 1, 1); - l.ResourceBarrier(&[ - uav_barrier(), - transition( + l.SetComputeRootUnorderedAccessView(2, budget.GetGPUVirtualAddress()); + l.Dispatch(records.div_ceil(THREADS_PER_GROUP), 1, 1); + l.ResourceBarrier(&[uav_barrier()]); + for buffer in [Some(buffer), count].into_iter().flatten() { ``` Thanks for flagging the state assumption. A shadow may already have GPU reads or writes, and it does not decay between lists submitted together. The revision selects enhanced barriers at the start of each native submission, orders the producer and indirect accesses, and leaves buffers available for their next use. A shared argument/count resource is handled once. CPU, UAV and copy producers, resubmission, and split timing submissions passed on AMD and WARP. The debug layer was unavailable here.
@ -1193,0 +1265,4 @@
/// may include other memory or padding beyond the title's buffer.
fn indirect_address(buffer: Option<(*mut u8, u64)>, offset: u64, len: u64) -> Option<u64> {
let (base, size) = buffer?;
if !offset.is_multiple_of(4) || offset.checked_add(len)? > size {
Author
Owner

@⁠aycow on GitHub · 2026-11-24 00:14 UTC · original

Thanks for catching the trailing stride. The title bounds check and shadow lookup now use the same last-record span. The regression returned 32 bytes before and now accepts 28 while rejecting 27. The native test executes the final record at a nonzero offset with zero trailing padding on AMD and WARP. I also recorded the separate AMD two-dispatch observation in the PR description.

**@⁠aycow** on GitHub · 2026-11-24 00:14 UTC · [original](https://github.com/Marvisak/VIctory/pull/40#discussion_r4673794962) Thanks for catching the trailing stride. The title bounds check and shadow lookup now use the same last-record span. The regression returned 32 bytes before and now accepts 28 while rejecting 27. The native test executes the final record at a nonzero offset with zero trailing padding on AMD and WARP. I also recorded the separate AMD two-dispatch observation in the PR description.
Author
Owner

@⁠raffclar on GitHub · 2026-11-24 00:28 UTC · original
On crates/victory-gpu/src/indirect.rs line 221 (outdated):

@@ -158,95 +158,151 @@ fn make() -> windows::core::Result<Clamp> {
 
 const THREADS_PER_GROUP: u32 = 64;
 
-/// Full record span, limited by the validator's dispatch size and 32-bit
-/// byte offsets. Native signatures also require a whole argument per record.
+fn argument_size(kind: u32) -> Option<u32> {
+    match kind {
+        0 => Some(16),
+        1 => Some(20),
+        2 | 10 => Some(12),
+        _ => None,
+    }
+}
+
+/// Span through the last argument, subject to the validator's dispatch
+/// size and 32-bit byte offsets.
 pub(crate) fn byte_len(kind: u32, stride: u32, records: u32) -> Option<u64> {
-    let minimum = match kind {
-        0 => 16,
-        1 => 20,
-        2 | 10 => 12,
-        _ => return None,
-    };
+    let minimum = argument_size(kind)?;
     if stride < minimum
         || !stride.is_multiple_of(4)
         || records.div_ceil(THREADS_PER_GROUP) > D3D12_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION
     {
         return None;
     }
-    let stride = u64::from(stride);
-    let last = u64::from(records.saturating_sub(1)) * stride;
-    if last + u64::from(minimum) > (1 << 32) {
-        return None;
+    if records == 0 {
+        return Some(0);
     }
-    Some(stride * u64::from(records))
+    let end = u64::from(records - 1) * u64::from(stride) + u64::from(minimum);
+    (end <= 1 << 32).then_some(end)
 }
 
-/// Records, in `list`, the clamp of `records` records of `kind` (PC
-/// argument numbering) `stride` bytes apart at host address `gpu` in
-/// `buffer`, and leaves the buffers ready to be read as arguments. `count`
-/// is the count buffer if it is distinct from `buffer`. Replaces
-/// the list's compute root signature and pipeline (callers bind theirs
-/// after). False if the clamp is not available.
+fn enhanced_barriers() -> bool {
+    static SUPPORTED: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
+    *SUPPORTED.get_or_init(|| {
+        let Some(host) = host() else { return false };
+        let mut options = D3D12_FEATURE_DATA_D3D12_OPTIONS12::default();
+        // SAFETY: the feature query writes the matching options structure.
+        let supported = unsafe {
+            host.device.CheckFeatureSupport(
+                D3D12_FEATURE_D3D12_OPTIONS12,
+                (&raw mut options).cast(),
+                size_of_val(&options) as u32,
+            )
+        }
+        .is_ok()
+            && options.EnhancedBarriersSupported.as_bool();
+        if !supported {
+            tracing::warn!("indirect execution requires enhanced buffer barriers");
+        }
+        supported
+    })
+}
+
+/// Validates the arguments in place and makes the native inputs readable.
+/// Replaces the list's compute root signature and pipeline.
 pub(crate) fn bound(
     list: &HostList,
     buffer: &ID3D12Resource,
-    gpu: u64,
+    offset: u64,
     count: Option<&ID3D12Resource>,
     (kind, stride, records): (u32, u32, u32),
 ) -> bool {
-    if !gpu.is_multiple_of(4) {
+    let Some(len) = byte_len(kind, stride, records) else {
+        return false;
+    };
+    if len == 0 || !offset.is_multiple_of(4) || !enhanced_barriers() {

If the GPU setup doesn't support enhanced barriers, this will fail.

Keep the old barrier code as a fallback when enhanced barriers are missing for our older GPUs

**@⁠raffclar** on GitHub · 2026-11-24 00:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/40#discussion_r4673897869) On `crates/victory-gpu/src/indirect.rs` line 221 (outdated): ```diff @@ -158,95 +158,151 @@ fn make() -> windows::core::Result<Clamp> { const THREADS_PER_GROUP: u32 = 64; -/// Full record span, limited by the validator's dispatch size and 32-bit -/// byte offsets. Native signatures also require a whole argument per record. +fn argument_size(kind: u32) -> Option<u32> { + match kind { + 0 => Some(16), + 1 => Some(20), + 2 | 10 => Some(12), + _ => None, + } +} + +/// Span through the last argument, subject to the validator's dispatch +/// size and 32-bit byte offsets. pub(crate) fn byte_len(kind: u32, stride: u32, records: u32) -> Option<u64> { - let minimum = match kind { - 0 => 16, - 1 => 20, - 2 | 10 => 12, - _ => return None, - }; + let minimum = argument_size(kind)?; if stride < minimum || !stride.is_multiple_of(4) || records.div_ceil(THREADS_PER_GROUP) > D3D12_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION { return None; } - let stride = u64::from(stride); - let last = u64::from(records.saturating_sub(1)) * stride; - if last + u64::from(minimum) > (1 << 32) { - return None; + if records == 0 { + return Some(0); } - Some(stride * u64::from(records)) + let end = u64::from(records - 1) * u64::from(stride) + u64::from(minimum); + (end <= 1 << 32).then_some(end) } -/// Records, in `list`, the clamp of `records` records of `kind` (PC -/// argument numbering) `stride` bytes apart at host address `gpu` in -/// `buffer`, and leaves the buffers ready to be read as arguments. `count` -/// is the count buffer if it is distinct from `buffer`. Replaces -/// the list's compute root signature and pipeline (callers bind theirs -/// after). False if the clamp is not available. +fn enhanced_barriers() -> bool { + static SUPPORTED: std::sync::OnceLock<bool> = std::sync::OnceLock::new(); + *SUPPORTED.get_or_init(|| { + let Some(host) = host() else { return false }; + let mut options = D3D12_FEATURE_DATA_D3D12_OPTIONS12::default(); + // SAFETY: the feature query writes the matching options structure. + let supported = unsafe { + host.device.CheckFeatureSupport( + D3D12_FEATURE_D3D12_OPTIONS12, + (&raw mut options).cast(), + size_of_val(&options) as u32, + ) + } + .is_ok() + && options.EnhancedBarriersSupported.as_bool(); + if !supported { + tracing::warn!("indirect execution requires enhanced buffer barriers"); + } + supported + }) +} + +/// Validates the arguments in place and makes the native inputs readable. +/// Replaces the list's compute root signature and pipeline. pub(crate) fn bound( list: &HostList, buffer: &ID3D12Resource, - gpu: u64, + offset: u64, count: Option<&ID3D12Resource>, (kind, stride, records): (u32, u32, u32), ) -> bool { - if !gpu.is_multiple_of(4) { + let Some(len) = byte_len(kind, stride, records) else { + return false; + }; + if len == 0 || !offset.is_multiple_of(4) || !enhanced_barriers() { ``` If the GPU setup doesn't support enhanced barriers, this will fail. Keep the old barrier code as a fallback when enhanced barriers are missing for our older GPUs
Author
Owner

@⁠raffclar on GitHub · 2026-11-24 00:29 UTC · original
On crates/victory-gpu/src/indirect.rs line 217 (outdated):

@@ -159,31 +211,33 @@ pub(crate) fn bound(
         l.SetPipelineState(&c.pso);
         l.SetComputeRoot32BitConstants(0, 4, constants.as_ptr().cast(), 0);
         l.SetComputeRootUnorderedAccessView(1, gpu);
-        l.SetComputeRootUnorderedAccessView(2, budget);
-        l.Dispatch(records.div_ceil(64), 1, 1);
-        l.ResourceBarrier(&[
-            uav_barrier(),
-            transition(
+        l.SetComputeRootUnorderedAccessView(2, budget.GetGPUVirtualAddress());
+        l.Dispatch(records.div_ceil(THREADS_PER_GROUP), 1, 1);
+        l.ResourceBarrier(&[uav_barrier()]);
+        for buffer in [Some(buffer), count].into_iter().flatten() {

Ok good, one problem with enhanced barriers. Comment is below

**@⁠raffclar** on GitHub · 2026-11-24 00:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/40#discussion_r4673905379) On `crates/victory-gpu/src/indirect.rs` line 217 (outdated): ```diff @@ -159,31 +211,33 @@ pub(crate) fn bound( l.SetPipelineState(&c.pso); l.SetComputeRoot32BitConstants(0, 4, constants.as_ptr().cast(), 0); l.SetComputeRootUnorderedAccessView(1, gpu); - l.SetComputeRootUnorderedAccessView(2, budget); - l.Dispatch(records.div_ceil(64), 1, 1); - l.ResourceBarrier(&[ - uav_barrier(), - transition( + l.SetComputeRootUnorderedAccessView(2, budget.GetGPUVirtualAddress()); + l.Dispatch(records.div_ceil(THREADS_PER_GROUP), 1, 1); + l.ResourceBarrier(&[uav_barrier()]); + for buffer in [Some(buffer), count].into_iter().flatten() { ``` Ok good, one problem with enhanced barriers. Comment is below
Author
Owner

@⁠aycow on GitHub · 2026-11-24 00:32 UTC · original
On crates/victory-gpu/src/indirect.rs line 221 (outdated):

@@ -158,95 +158,151 @@ fn make() -> windows::core::Result<Clamp> {
 
 const THREADS_PER_GROUP: u32 = 64;
 
-/// Full record span, limited by the validator's dispatch size and 32-bit
-/// byte offsets. Native signatures also require a whole argument per record.
+fn argument_size(kind: u32) -> Option<u32> {
+    match kind {
+        0 => Some(16),
+        1 => Some(20),
+        2 | 10 => Some(12),
+        _ => None,
+    }
+}
+
+/// Span through the last argument, subject to the validator's dispatch
+/// size and 32-bit byte offsets.
 pub(crate) fn byte_len(kind: u32, stride: u32, records: u32) -> Option<u64> {
-    let minimum = match kind {
-        0 => 16,
-        1 => 20,
-        2 | 10 => 12,
-        _ => return None,
-    };
+    let minimum = argument_size(kind)?;
     if stride < minimum
         || !stride.is_multiple_of(4)
         || records.div_ceil(THREADS_PER_GROUP) > D3D12_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION
     {
         return None;
     }
-    let stride = u64::from(stride);
-    let last = u64::from(records.saturating_sub(1)) * stride;
-    if last + u64::from(minimum) > (1 << 32) {
-        return None;
+    if records == 0 {
+        return Some(0);
     }
-    Some(stride * u64::from(records))
+    let end = u64::from(records - 1) * u64::from(stride) + u64::from(minimum);
+    (end <= 1 << 32).then_some(end)
 }
 
-/// Records, in `list`, the clamp of `records` records of `kind` (PC
-/// argument numbering) `stride` bytes apart at host address `gpu` in
-/// `buffer`, and leaves the buffers ready to be read as arguments. `count`
-/// is the count buffer if it is distinct from `buffer`. Replaces
-/// the list's compute root signature and pipeline (callers bind theirs
-/// after). False if the clamp is not available.
+fn enhanced_barriers() -> bool {
+    static SUPPORTED: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
+    *SUPPORTED.get_or_init(|| {
+        let Some(host) = host() else { return false };
+        let mut options = D3D12_FEATURE_DATA_D3D12_OPTIONS12::default();
+        // SAFETY: the feature query writes the matching options structure.
+        let supported = unsafe {
+            host.device.CheckFeatureSupport(
+                D3D12_FEATURE_D3D12_OPTIONS12,
+                (&raw mut options).cast(),
+                size_of_val(&options) as u32,
+            )
+        }
+        .is_ok()
+            && options.EnhancedBarriersSupported.as_bool();
+        if !supported {
+            tracing::warn!("indirect execution requires enhanced buffer barriers");
+        }
+        supported
+    })
+}
+
+/// Validates the arguments in place and makes the native inputs readable.
+/// Replaces the list's compute root signature and pipeline.
 pub(crate) fn bound(
     list: &HostList,
     buffer: &ID3D12Resource,
-    gpu: u64,
+    offset: u64,
     count: Option<&ID3D12Resource>,
     (kind, stride, records): (u32, u32, u32),
 ) -> bool {
-    if !gpu.is_multiple_of(4) {
+    let Some(len) = byte_len(kind, stride, records) else {
+        return false;
+    };
+    if len == 0 || !offset.is_multiple_of(4) || !enhanced_barriers() {

Thanks. Commit a2ab63d restores the legacy UAV and INDIRECT_ARGUMENT transitions when enhanced barriers or command list 7 are unavailable. It also restores the buffers if pipeline preparation drops the call. The forced legacy path passed 13 focused tests on AMD and WARP, and the enhanced path passed all 14 on each.

**@⁠aycow** on GitHub · 2026-11-24 00:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/40#discussion_r4673926991) On `crates/victory-gpu/src/indirect.rs` line 221 (outdated): ```diff @@ -158,95 +158,151 @@ fn make() -> windows::core::Result<Clamp> { const THREADS_PER_GROUP: u32 = 64; -/// Full record span, limited by the validator's dispatch size and 32-bit -/// byte offsets. Native signatures also require a whole argument per record. +fn argument_size(kind: u32) -> Option<u32> { + match kind { + 0 => Some(16), + 1 => Some(20), + 2 | 10 => Some(12), + _ => None, + } +} + +/// Span through the last argument, subject to the validator's dispatch +/// size and 32-bit byte offsets. pub(crate) fn byte_len(kind: u32, stride: u32, records: u32) -> Option<u64> { - let minimum = match kind { - 0 => 16, - 1 => 20, - 2 | 10 => 12, - _ => return None, - }; + let minimum = argument_size(kind)?; if stride < minimum || !stride.is_multiple_of(4) || records.div_ceil(THREADS_PER_GROUP) > D3D12_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION { return None; } - let stride = u64::from(stride); - let last = u64::from(records.saturating_sub(1)) * stride; - if last + u64::from(minimum) > (1 << 32) { - return None; + if records == 0 { + return Some(0); } - Some(stride * u64::from(records)) + let end = u64::from(records - 1) * u64::from(stride) + u64::from(minimum); + (end <= 1 << 32).then_some(end) } -/// Records, in `list`, the clamp of `records` records of `kind` (PC -/// argument numbering) `stride` bytes apart at host address `gpu` in -/// `buffer`, and leaves the buffers ready to be read as arguments. `count` -/// is the count buffer if it is distinct from `buffer`. Replaces -/// the list's compute root signature and pipeline (callers bind theirs -/// after). False if the clamp is not available. +fn enhanced_barriers() -> bool { + static SUPPORTED: std::sync::OnceLock<bool> = std::sync::OnceLock::new(); + *SUPPORTED.get_or_init(|| { + let Some(host) = host() else { return false }; + let mut options = D3D12_FEATURE_DATA_D3D12_OPTIONS12::default(); + // SAFETY: the feature query writes the matching options structure. + let supported = unsafe { + host.device.CheckFeatureSupport( + D3D12_FEATURE_D3D12_OPTIONS12, + (&raw mut options).cast(), + size_of_val(&options) as u32, + ) + } + .is_ok() + && options.EnhancedBarriersSupported.as_bool(); + if !supported { + tracing::warn!("indirect execution requires enhanced buffer barriers"); + } + supported + }) +} + +/// Validates the arguments in place and makes the native inputs readable. +/// Replaces the list's compute root signature and pipeline. pub(crate) fn bound( list: &HostList, buffer: &ID3D12Resource, - gpu: u64, + offset: u64, count: Option<&ID3D12Resource>, (kind, stride, records): (u32, u32, u32), ) -> bool { - if !gpu.is_multiple_of(4) { + let Some(len) = byte_len(kind, stride, records) else { + return false; + }; + if len == 0 || !offset.is_multiple_of(4) || !enhanced_barriers() { ``` Thanks. Commit a2ab63d restores the legacy UAV and INDIRECT_ARGUMENT transitions when enhanced barriers or command list 7 are unavailable. It also restores the buffers if pipeline preparation drops the call. The forced legacy path passed 13 focused tests on AMD and WARP, and the enhanced path passed all 14 on each.
Author
Owner

@⁠raffclar on GitHub · 2026-11-24 00:40 UTC · original
On crates/victory-gpu/src/indirect.rs line 282 (outdated):

@@ -255,22 +272,62 @@ pub(crate) fn bound(
         l.SetComputeRootUnorderedAccessView(2, budget.GetGPUVirtualAddress());
         l.Dispatch(records.div_ceil(THREADS_PER_GROUP), 1, 1);
     }
-    buffer_barriers(&l, written, uav, all);
-    // A count in the source allocation was already synchronized above.
-    buffer_barriers(&l, count.filter(|&count| count != buffer), all, all);
+    if let Some(enhanced) = &enhanced {
+        buffer_barriers(enhanced, written, COMPUTE_UAV, COMMON_ACCESS);
+        buffer_barriers(enhanced, separate_count, COMMON_ACCESS, COMMON_ACCESS);
+    } else {
+        uav_barrier(l);
+        // Older hosts use the existing COMMON promotion/UAV convention
+        // for shadow buffers. The sanitizer leaves arguments in UAV.
+        for buffer in [Some(buffer), separate_count].into_iter().flatten() {

Remove separate_count from both legacy loops, so only buffer is switched. I think your machine is missing the original barrier fault; a wrong starting state is only reported by the D3D12 debug layer and your machine didn't have it (DXGI_ERROR_SDK_COMPONENT_MISSING) based on your PR description.

**@⁠raffclar** on GitHub · 2026-11-24 00:40 UTC · [original](https://github.com/Marvisak/VIctory/pull/40#discussion_r4673980838) On `crates/victory-gpu/src/indirect.rs` line 282 (outdated): ```diff @@ -255,22 +272,62 @@ pub(crate) fn bound( l.SetComputeRootUnorderedAccessView(2, budget.GetGPUVirtualAddress()); l.Dispatch(records.div_ceil(THREADS_PER_GROUP), 1, 1); } - buffer_barriers(&l, written, uav, all); - // A count in the source allocation was already synchronized above. - buffer_barriers(&l, count.filter(|&count| count != buffer), all, all); + if let Some(enhanced) = &enhanced { + buffer_barriers(enhanced, written, COMPUTE_UAV, COMMON_ACCESS); + buffer_barriers(enhanced, separate_count, COMMON_ACCESS, COMMON_ACCESS); + } else { + uav_barrier(l); + // Older hosts use the existing COMMON promotion/UAV convention + // for shadow buffers. The sanitizer leaves arguments in UAV. + for buffer in [Some(buffer), separate_count].into_iter().flatten() { ``` Remove separate_count from both legacy loops, so only buffer is switched. I think your machine is missing the original barrier fault; a wrong starting state is only reported by the D3D12 debug layer and your machine didn't have it (DXGI_ERROR_SDK_COMPONENT_MISSING) based on your PR description.
Author
Owner

@⁠raffclar on GitHub · 2026-11-24 00:41 UTC · original
On crates/victory-gpu/src/indirect.rs line 282 (outdated):

@@ -255,22 +272,62 @@ pub(crate) fn bound(
         l.SetComputeRootUnorderedAccessView(2, budget.GetGPUVirtualAddress());
         l.Dispatch(records.div_ceil(THREADS_PER_GROUP), 1, 1);
     }
-    buffer_barriers(&l, written, uav, all);
-    // A count in the source allocation was already synchronized above.
-    buffer_barriers(&l, count.filter(|&count| count != buffer), all, all);
+    if let Some(enhanced) = &enhanced {
+        buffer_barriers(enhanced, written, COMPUTE_UAV, COMMON_ACCESS);
+        buffer_barriers(enhanced, separate_count, COMMON_ACCESS, COMMON_ACCESS);
+    } else {
+        uav_barrier(l);
+        // Older hosts use the existing COMMON promotion/UAV convention
+        // for shadow buffers. The sanitizer leaves arguments in UAV.
+        for buffer in [Some(buffer), separate_count].into_iter().flatten() {

The argument buffer really is in the UAV state because the clamp shader just wrote it

**@⁠raffclar** on GitHub · 2026-11-24 00:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/40#discussion_r4673985257) On `crates/victory-gpu/src/indirect.rs` line 282 (outdated): ```diff @@ -255,22 +272,62 @@ pub(crate) fn bound( l.SetComputeRootUnorderedAccessView(2, budget.GetGPUVirtualAddress()); l.Dispatch(records.div_ceil(THREADS_PER_GROUP), 1, 1); } - buffer_barriers(&l, written, uav, all); - // A count in the source allocation was already synchronized above. - buffer_barriers(&l, count.filter(|&count| count != buffer), all, all); + if let Some(enhanced) = &enhanced { + buffer_barriers(enhanced, written, COMPUTE_UAV, COMMON_ACCESS); + buffer_barriers(enhanced, separate_count, COMMON_ACCESS, COMMON_ACCESS); + } else { + uav_barrier(l); + // Older hosts use the existing COMMON promotion/UAV convention + // for shadow buffers. The sanitizer leaves arguments in UAV. + for buffer in [Some(buffer), separate_count].into_iter().flatten() { ``` The argument buffer really is in the UAV state because the clamp shader just wrote it
Author
Owner

@⁠aycow on GitHub · 2026-11-24 01:16 UTC · original
On crates/victory-gpu/src/indirect.rs line 282 (outdated):

@@ -255,22 +272,62 @@ pub(crate) fn bound(
         l.SetComputeRootUnorderedAccessView(2, budget.GetGPUVirtualAddress());
         l.Dispatch(records.div_ceil(THREADS_PER_GROUP), 1, 1);
     }
-    buffer_barriers(&l, written, uav, all);
-    // A count in the source allocation was already synchronized above.
-    buffer_barriers(&l, count.filter(|&count| count != buffer), all, all);
+    if let Some(enhanced) = &enhanced {
+        buffer_barriers(enhanced, written, COMPUTE_UAV, COMMON_ACCESS);
+        buffer_barriers(enhanced, separate_count, COMMON_ACCESS, COMMON_ACCESS);
+    } else {
+        uav_barrier(l);
+        // Older hosts use the existing COMMON promotion/UAV convention
+        // for shadow buffers. The sanitizer leaves arguments in UAV.
+        for buffer in [Some(buffer), separate_count].into_iter().flatten() {

Thanks for catching this. In 22b9ed1, the legacy transitions apply only to the argument resource, including when it also contains the count. A separate count can promote from COMMON. For a UAV or copy write in the same native submission, the fallback now preserves the title's explicit handoff through COMMON. Decay only occurs after a native submission.

AMD and WARP each passed 14 focused tests in both enhanced and forced legacy modes, including the CPU count, UAV and copy producers, shared resources, and resubmission. D3D12 debug-layer and GPU-based validation are still outstanding. The Graphics Tools install hit CBS_E_SOURCE_MISSING, and the strict probe confirmed the layer was not active.

**@⁠aycow** on GitHub · 2026-11-24 01:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/40#discussion_r4674246520) On `crates/victory-gpu/src/indirect.rs` line 282 (outdated): ```diff @@ -255,22 +272,62 @@ pub(crate) fn bound( l.SetComputeRootUnorderedAccessView(2, budget.GetGPUVirtualAddress()); l.Dispatch(records.div_ceil(THREADS_PER_GROUP), 1, 1); } - buffer_barriers(&l, written, uav, all); - // A count in the source allocation was already synchronized above. - buffer_barriers(&l, count.filter(|&count| count != buffer), all, all); + if let Some(enhanced) = &enhanced { + buffer_barriers(enhanced, written, COMPUTE_UAV, COMMON_ACCESS); + buffer_barriers(enhanced, separate_count, COMMON_ACCESS, COMMON_ACCESS); + } else { + uav_barrier(l); + // Older hosts use the existing COMMON promotion/UAV convention + // for shadow buffers. The sanitizer leaves arguments in UAV. + for buffer in [Some(buffer), separate_count].into_iter().flatten() { ``` Thanks for catching this. In `22b9ed1`, the legacy transitions apply only to the argument resource, including when it also contains the count. A separate count can promote from COMMON. For a UAV or copy write in the same native submission, the fallback now preserves the title's explicit handoff through COMMON. Decay only occurs after a native submission. AMD and WARP each passed 14 focused tests in both enhanced and forced legacy modes, including the CPU count, UAV and copy producers, shared resources, and resubmission. D3D12 debug-layer and GPU-based validation are still outstanding. The Graphics Tools install hit `CBS_E_SOURCE_MISSING`, and the strict probe confirmed the layer was not active.
Author
Owner

@⁠aycow on GitHub · 2026-11-24 02:24 UTC · original
On crates/victory-gpu/src/indirect.rs line 282 (outdated):

@@ -255,22 +272,62 @@ pub(crate) fn bound(
         l.SetComputeRootUnorderedAccessView(2, budget.GetGPUVirtualAddress());
         l.Dispatch(records.div_ceil(THREADS_PER_GROUP), 1, 1);
     }
-    buffer_barriers(&l, written, uav, all);
-    // A count in the source allocation was already synchronized above.
-    buffer_barriers(&l, count.filter(|&count| count != buffer), all, all);
+    if let Some(enhanced) = &enhanced {
+        buffer_barriers(enhanced, written, COMPUTE_UAV, COMMON_ACCESS);
+        buffer_barriers(enhanced, separate_count, COMMON_ACCESS, COMMON_ACCESS);
+    } else {
+        uav_barrier(l);
+        // Older hosts use the existing COMMON promotion/UAV convention
+        // for shadow buffers. The sanitizer leaves arguments in UAV.
+        for buffer in [Some(buffer), separate_count].into_iter().flatten() {

Thanks for pointing out the missing validation. I reran 22b9ed1 on AMD and WARP with Agility SDK 1.620.2. All 14 focused tests passed on each adapter in both enhanced and forced legacy modes, with the D3D12 debug layer and full GPU-based state tracking active.

I also omitted the legacy handoff in a same-list control. On both adapters, validation reported the separate count still in COPY_DEST or UAV when ExecuteIndirect required INDIRECT_ARGUMENT. Restoring the handoff cleared both errors. The separate CPU count can promote from COMMON, and the clamp-written argument resource retains its own transition.

The AMD zero-count dispatch also reproduces in a standalone native D3D12 test with explicit states and no validation errors. WARP and NVIDIA observed zero dispatches. The PR description has the adapter, driver and test details.

**@⁠aycow** on GitHub · 2026-11-24 02:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/40#discussion_r4674734584) On `crates/victory-gpu/src/indirect.rs` line 282 (outdated): ```diff @@ -255,22 +272,62 @@ pub(crate) fn bound( l.SetComputeRootUnorderedAccessView(2, budget.GetGPUVirtualAddress()); l.Dispatch(records.div_ceil(THREADS_PER_GROUP), 1, 1); } - buffer_barriers(&l, written, uav, all); - // A count in the source allocation was already synchronized above. - buffer_barriers(&l, count.filter(|&count| count != buffer), all, all); + if let Some(enhanced) = &enhanced { + buffer_barriers(enhanced, written, COMPUTE_UAV, COMMON_ACCESS); + buffer_barriers(enhanced, separate_count, COMMON_ACCESS, COMMON_ACCESS); + } else { + uav_barrier(l); + // Older hosts use the existing COMMON promotion/UAV convention + // for shadow buffers. The sanitizer leaves arguments in UAV. + for buffer in [Some(buffer), separate_count].into_iter().flatten() { ``` Thanks for pointing out the missing validation. I reran `22b9ed1` on AMD and WARP with Agility SDK 1.620.2. All 14 focused tests passed on each adapter in both enhanced and forced legacy modes, with the D3D12 debug layer and full GPU-based state tracking active. I also omitted the legacy handoff in a same-list control. On both adapters, validation reported the separate count still in COPY_DEST or UAV when ExecuteIndirect required INDIRECT_ARGUMENT. Restoring the handoff cleared both errors. The separate CPU count can promote from COMMON, and the clamp-written argument resource retains its own transition. The AMD zero-count dispatch also reproduces in a standalone native D3D12 test with explicit states and no validation errors. WARP and NVIDIA observed zero dispatches. The PR description has the adapter, driver and test details.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!40
No description provided.