fix(gpu): resolve D3D12 error 538 in buffer comparisons #1

Manually merged
github merged 1 commit from github-bot/gh-1 into main 2026-11-26 14:14:28 +00:00 AGit
Owner

@⁠jeremygold02 on GitHub · 2026-11-26 06:59 UTC · original
jeremygold02:codex/d3d12-buffer-compare-state-decay → main · +11 −5 · 1 files · 1 commits · merged 2026-11-26 14:09 UTC

Problem

The host appends its GPU buffer-comparison command list to the title's command lists. A title list can leave a buffer implicitly promoted to COPY_DEST. The comparison reads that buffer as a shader resource while it is still in the copy-destination state, triggering Direct3D 12 debug-layer error 538.

Buffers can decay to COMMON when the work from an ExecuteCommandLists call completes. Command lists submitted together share that boundary. Microsoft Learn: Resource state decay to common

Change

  • Submit the comparison list in a separate ExecuteCommandLists call on the same queue, after the title's lists and before signaling the existing fence.
  • Apply that order in both deferred and synchronous submission. The synchronous path sends the comparison after the final group even when GPU timing splits the title's lists.
  • Only submissions carrying a comparison list need the extra queue call. That list still completes under the original submission fence, with no additional CPU wait.

Test setup

  • GPU: NVIDIA GeForce RTX 5070 (12 GB VRAM)
  • Driver: NVIDIA 621.01
  • CPU: Intel Core Ultra 7 265K (20 cores, 20 threads)
  • Memory: 32 GB RAM
  • OS: Windows 11 Home 64-bit, build 26200

Verification

Built a clean Windows diagnostics checkpoint containing this fix with cargo build --offline --locked --target-dir target --jobs 2 --profile diag -p victory --features diagnostics. Ran both NVIDIA launcher presets with VICTORY_D3D12_DEBUG=1.

Preset Result D3D12 error 538
Series S Rendered the prologue and continued into later shots 0 occurrences
Series X Rendered the prologue and continued into later shots 0 occurrences

Both validation runs used the integrated local checkpoint. This PR contains only the buffer-comparison change in crates/victory-gpu/src/host.rs. Frame-rate impact was outside the scope of these checks.

**@⁠jeremygold02** on GitHub · 2026-11-26 06:59 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1) `jeremygold02:codex/d3d12-buffer-compare-state-decay` → `main` · +11 −5 · 1 files · 1 commits · merged 2026-11-26 14:09 UTC ## Problem The host appends its GPU buffer-comparison command list to the title's command lists. A title list can leave a buffer implicitly promoted to `COPY_DEST`. The comparison reads that buffer as a shader resource while it is still in the copy-destination state, triggering Direct3D 12 debug-layer error **538**. Buffers can decay to `COMMON` when the work from an `ExecuteCommandLists` call completes. Command lists submitted together share that boundary. [Microsoft Learn: Resource state decay to common](https://learn.microsoft.com/en-us/windows/win32/direct3d12/using-resource-barriers-to-synchronize-resource-states-in-direct3d-12#state-decay-to-common) ## Change - Submit the comparison list in a separate `ExecuteCommandLists` call on the same queue, after the title's lists and before signaling the existing fence. - Apply that order in both deferred and synchronous submission. The synchronous path sends the comparison after the final group even when GPU timing splits the title's lists. - Only submissions carrying a comparison list need the extra queue call. That list still completes under the original submission fence, with no additional CPU wait. ## Test setup - **GPU:** NVIDIA GeForce RTX 5070 (12 GB VRAM) - **Driver:** NVIDIA 621.01 - **CPU:** Intel Core Ultra 7 265K (20 cores, 20 threads) - **Memory:** 32 GB RAM - **OS:** Windows 11 Home 64-bit, build 26200 ## Verification Built a clean Windows diagnostics checkpoint containing this fix with `cargo build --offline --locked --target-dir target --jobs 2 --profile diag -p victory --features diagnostics`. Ran both NVIDIA launcher presets with `VICTORY_D3D12_DEBUG=1`. | Preset | Result | D3D12 error 538 | | --- | --- | --- | | Series S | Rendered the prologue and continued into later shots | 0 occurrences | | Series X | Rendered the prologue and continued into later shots | 0 occurrences | Both validation runs used the integrated local checkpoint. This PR contains only the buffer-comparison change in `crates/victory-gpu/src/host.rs`. Frame-rate impact was outside the scope of these checks.
Submit the comparison list separately before signaling the fence so implicitly promoted title buffers can decay to COMMON. This fixes D3D12 error 538.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 12:32:41 +00:00
Author
Owner

@⁠LucaruluDev on GitHub · 2026-11-26 10:55 UTC · original

I reviewed this PR against the D3D12 resource state promotion and decay rules, and the separate ExecuteCommandLists submission appears consistent with the documented behavior.

One observation: moving the comparison submission also appears to change the scope of the VICTORY_TIMELINE and VICTORY_CARD_SPANS diagnostics, as their end markers now precede the comparison.

Was this change intentional?

I also noticed that the existing tests do not appear to cover the original resource-state transition scenario. Would a standalone synthetic regression test be a useful follow-up contribution?

**@⁠LucaruluDev** on GitHub · 2026-11-26 10:55 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1#issuecomment-7190014539) I reviewed this PR against the D3D12 resource state promotion and decay rules, and the separate ExecuteCommandLists submission appears consistent with the documented behavior. One observation: moving the comparison submission also appears to change the scope of the VICTORY_TIMELINE and VICTORY_CARD_SPANS diagnostics, as their end markers now precede the comparison. Was this change intentional? I also noticed that the existing tests do not appear to cover the original resource-state transition scenario. Would a standalone synthetic regression test be a useful follow-up contribution?
github manually merged commit ebf3d3c9e5 into main 2026-11-26 14:14:28 +00:00
Author
Owner

@⁠jeremygold02 on GitHub · 2026-11-26 14:45 UTC · original

Thanks for catching this, @⁠LucaruluDev. The separate queue call was intentional for resource-state decay. The narrower timing scope was a side effect I missed.

I opened PR #3 to put both end markers after the comparison while keeping the separate call and the existing fence.

A standalone debug-layer regression test would be a useful follow-up. If you're still interested, I'd welcome a fixture that compares the same buffer write/read sequence with one queue call versus two and checks for error 538.

**@⁠jeremygold02** on GitHub · 2026-11-26 14:45 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1#issuecomment-7195286964) Thanks for catching this, @⁠LucaruluDev. The separate queue call was intentional for resource-state decay. The narrower timing scope was a side effect I missed. I opened [PR #3](https://git.gtahub.st/github/trustno1-coder--VIctory-NVIDIA/pulls/3) to put both end markers after the comparison while keeping the separate call and the existing fence. A standalone debug-layer regression test would be a useful follow-up. If you're still interested, I'd welcome a fixture that compares the same buffer write/read sequence with one queue call versus two and checks for error 538.
Author
Owner

@⁠LucaruluDev on GitHub · 2026-11-26 14:53 UTC · original

Thanks for the follow-up and for addressing the timing issue! I'm still interested in the standalone regression test. I'll look into it and share the results if I can get a reliable reproduction.

**@⁠LucaruluDev** on GitHub · 2026-11-26 14:53 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1#issuecomment-7195477577) Thanks for the follow-up and for addressing the timing issue! I'm still interested in the standalone regression test. I'll look into it and share the results if I can get a reliable reproduction.
Author
Owner

@⁠LucaruluDev on GitHub · 2026-11-26 17:29 UTC · original

I finished the standalone regression fixture and successfully reproduced error 538 on both WARP and an RTX 5070.

Results on both adapters:

  • Single submission without a barrier: exactly one error 538.
  • Two separate submissions: no errors, correct data.
  • Single submission with an explicit barrier: no errors, correct data.

All six cases completed their fence successfully.

The fixture uses synthetic buffer copies without shaders, reproducing the resource-state issue independently of VIctory's specific shader path.

Would you prefer a standalone fixture or integration into the existing test suite?

**@⁠LucaruluDev** on GitHub · 2026-11-26 17:29 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1#issuecomment-7199099411) I finished the standalone regression fixture and successfully reproduced error 538 on both WARP and an RTX 5070. Results on both adapters: - Single submission without a barrier: exactly one error 538. - Two separate submissions: no errors, correct data. - Single submission with an explicit barrier: no errors, correct data. All six cases completed their fence successfully. The fixture uses synthetic buffer copies without shaders, reproducing the resource-state issue independently of VIctory's specific shader path. Would you prefer a standalone fixture or integration into the existing test suite?
This discussion has been locked. Commenting is limited to contributors.
No description provided.