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

Merged
jeremygold02 merged 1 commit from upstream-pr/1 into main 2026-11-26 14:09:53 +00:00
jeremygold02 commented 2026-11-26 06:59:19 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by jeremygold02 on 2026-11-26T06:59:19Z.


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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5505505631 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1). Originally posted by [jeremygold02](https://github.com/jeremygold02) on 2026-11-26T06:59:19Z. --- ## 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.
LucaruluDev commented 2026-11-26 10:55:12 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by LucaruluDev on 2026-11-26T10:55:12Z.


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?

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7190014539 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1#issuecomment-7190014539). Originally posted by [LucaruluDev](https://github.com/LucaruluDev) on 2026-11-26T10:55:12Z. --- 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?
jeremygold02 commented 2026-11-26 14:45:41 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by jeremygold02 on 2026-11-26T14:45:41Z.


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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7195286964 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1#issuecomment-7195286964). Originally posted by [jeremygold02](https://github.com/jeremygold02) on 2026-11-26T14:45:41Z. --- 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://github.com/trustno1-coder/VIctory-NVIDIA/pull/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.
LucaruluDev commented 2026-11-26 14:53:16 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by LucaruluDev on 2026-11-26T14:53:16Z.


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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7195477577 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1#issuecomment-7195477577). Originally posted by [LucaruluDev](https://github.com/LucaruluDev) on 2026-11-26T14:53:16Z. --- 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 commented 2026-11-26 17:29:12 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by LucaruluDev on 2026-11-26T17:29:12Z.


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?


Update: The standalone fixture is now publicly available:

https://github.com/LucaruluDev/d3d12-buffer-state-decay

The repository includes the C++17 source, WARP reproduction instructions, an explicit-barrier control, archived results from WARP and RTX 5070, and debug-layer diagnostics.

The reproduction is independent of VIctory and uses only synthetic buffer copies on a DIRECT queue. Its coverage is limited to the buffer-copy path.

Released under the MIT license.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7199099411 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1#issuecomment-7199099411). Originally posted by [LucaruluDev](https://github.com/LucaruluDev) on 2026-11-26T17:29:12Z. --- 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? --- **Update:** The standalone fixture is now publicly available: https://github.com/LucaruluDev/d3d12-buffer-state-decay The repository includes the C++17 source, WARP reproduction instructions, an explicit-barrier control, archived results from WARP and RTX 5070, and debug-layer diagnostics. The reproduction is independent of VIctory and uses only synthetic buffer copies on a DIRECT queue. Its coverage is limited to the buffer-copy path. Released under the MIT license.
Sign in to join this conversation.
No reviewers
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
trustno1-coder/VIctory-NVIDIA!1
No description provided.