d3d12: SYNC_COPY waits for the CLEAR stage too, ordering WriteBufferImmediate before copies (OLD-10048) #751

Manually merged
github merged 1 commit from gh-pr/751/head into gh-pr/751/base 2026-11-26 09:19:30 +00:00
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 13:29 UTC · original
abnalstlll-byte:restore/old-10048-sync-copy-clear-stage → main · +91 −5 · 4 files · 1 commits · merged 2026-11-24 18:38 UTC

Restore old upstream PR 10048 (OLD-10048 / D3D-838).

An enhanced barrier's D3D12_BARRIER_SYNC_COPY mapped to VK_PIPELINE_STAGE_2_COPY_BIT only. Two D3D12 copy-scope commands are not Vulkan copies: WriteBufferImmediate is recorded as vkCmdUpdateBuffer and ResolveQueryData's never-written queries as vkCmdFillBuffer, and synchronization2 runs both in the CLEAR stage. A SYNC_COPY barrier after either therefore did not order it, and a copy after the barrier could read the word before the write landed.

vulkan_sync now maps SYNC_COPY to COPY | CLEAR. vk_command_replay_test part K records WriteBufferImmediate, a SYNC_COPY -> SYNC_COPY buffer barrier and a CopyBufferRegion of the written word; under LEONIDA_VK_VALIDATION=1 it is a read-after-write hazard without this change. d3d12_state_map_test and docs/d3d12_vulkan.md follow the new mapping.

Clean-room verified; zero game data.

**@⁠abnalstlll-byte** on GitHub · 2026-11-24 13:29 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/751) `abnalstlll-byte:restore/old-10048-sync-copy-clear-stage` → `main` · +91 −5 · 4 files · 1 commits · merged 2026-11-24 18:38 UTC Restore old upstream PR 10048 (OLD-10048 / D3D-838). An enhanced barrier's D3D12_BARRIER_SYNC_COPY mapped to VK_PIPELINE_STAGE_2_COPY_BIT only. Two D3D12 copy-scope commands are not Vulkan copies: WriteBufferImmediate is recorded as vkCmdUpdateBuffer and ResolveQueryData's never-written queries as vkCmdFillBuffer, and synchronization2 runs both in the CLEAR stage. A SYNC_COPY barrier after either therefore did not order it, and a copy after the barrier could read the word before the write landed. vulkan_sync now maps SYNC_COPY to COPY | CLEAR. vk_command_replay_test part K records WriteBufferImmediate, a SYNC_COPY -> SYNC_COPY buffer barrier and a CopyBufferRegion of the written word; under LEONIDA_VK_VALIDATION=1 it is a read-after-write hazard without this change. d3d12_state_map_test and docs/d3d12_vulkan.md follow the new mapping. Clean-room verified; zero game data.
An enhanced barrier's D3D12_BARRIER_SYNC_COPY mapped to VK_PIPELINE_STAGE_2_COPY_BIT only. Two D3D12
copy-scope commands are not Vulkan copies: WriteBufferImmediate is recorded as vkCmdUpdateBuffer and
ResolveQueryData's never-written queries as vkCmdFillBuffer, and synchronization2 runs both in the CLEAR
stage. A SYNC_COPY barrier after either therefore did not order it, and a copy after the barrier could read
the word before the write landed.

vulkan_sync now maps SYNC_COPY to COPY | CLEAR. vk_command_replay_test part K records WriteBufferImmediate,
a SYNC_COPY -> SYNC_COPY buffer barrier and a CopyBufferRegion of the written word; under
LEONIDA_VK_VALIDATION=1 it is a read-after-write hazard without this change. d3d12_state_map_test and
docs/d3d12_vulkan.md follow the new mapping.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:19:29 +00:00
github manually merged commit a744fa8ab1 into gh-pr/751/base 2026-11-26 09:19:30 +00:00
Author
Owner

@⁠moffington on GitHub · 2026-11-24 14:13 UTC · original

Independently reviewed a744fa8ab against merge base 2d73c242f on Linux with an RTX 3060 and Vulkan synchronization validation enabled.

Applying the new part K regression test to the base reproduces the READ_AFTER_WRITE hazard between vkCmdUpdateBuffer and vkCmdCopyBuffer. On the PR head, all parts A–K pass with zero validation errors, including the 360 sync/access combinations.

The updated stage mapping is consistent across global, buffer and texture barriers, and the transfer-only queue mask remains intact.

Full suite: 70 passed, 1 skipped, 1 failed. The vk_queue failure produces the same 10 WAW validation errors on both revisions.

No regressions found. LGTM.

**@⁠moffington** on GitHub · 2026-11-24 14:13 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/751#issuecomment-7134036343) Independently reviewed `a744fa8ab` against merge base `2d73c242f` on Linux with an RTX 3060 and Vulkan synchronization validation enabled. Applying the new part K regression test to the base reproduces the `READ_AFTER_WRITE` hazard between `vkCmdUpdateBuffer` and `vkCmdCopyBuffer`. On the PR head, all parts A–K pass with zero validation errors, including the 360 sync/access combinations. The updated stage mapping is consistent across global, buffer and texture barriers, and the transfer-only queue mask remains intact. Full suite: 70 passed, 1 skipped, 1 failed. The `vk_queue` failure produces the same 10 WAW validation errors on both revisions. No regressions found. LGTM.
Author
Owner

@⁠Timon360SB on GitHub · 2026-11-24 14:21 UTC · original

Independent verification — Turing and Blackwell

Baseline: 2d73c242fddfe26d57b52ee150704e6c3b23cff4

PR head: a744fa8ab150c120babdbade56da470291d070cd

Environment

Configuration RTX 2060 SUPER RTX 5070
Architecture Turing Blackwell
NVIDIA driver 621.14 621.14
Windows 11 build 28000 26200
Vulkan SDK 1.4.363.0 1.4.363.0
MSVC 19.44.35230 19.44.35230
Configuration RelWithDebInfo RelWithDebInfo
Generator Ninja Multi-Config Ninja Multi-Config

Synchronization validation enabled. Three repetitions per revision on each GPU.

Results

Test 2060S BASE 2060S HEAD 5070 BASE 5070 HEAD
vk_command_replay 0/3 0/3 0/3 0/3
d3d12_state_map 3/3 3/3 3/3 3/3
vk_sync_validation 3/3 3/3 3/3 3/3
New part K N/A 3/3 N/A 3/3

Total: 36 CTest executions — 24 passed, 12 failed, 0 skipped.

Part K results are included in the vk_command_replay executions, not counted as separate CTests.

Targeted verification

All six HEAD executions successfully completed the new part K:

K: SYNC_COPY orders WriteBufferImmediate (vkCmdUpdateBuffer, CLEAR stage) before a copy

The updated state-map checks also passed on both architectures.

All 12 synchronization validation positive controls passed.

Existing failures

The overall vk_command_replay test fails on both revisions and both GPUs with the same reported depth-copy validation error:

VUID-vkCmdCopyBufferToImage-pRegions-07931
GPU BASE HEAD
RTX 2060 SUPER 30 30
RTX 5070 30 30

Each execution reports 10 instances, subject to the validation layer's duplicate message limit. Parts H and I report validation errors on both revisions.

Conclusion

  • The new WriteBufferImmediate regression scenario succeeds on Turing and Blackwell, with no new validation errors in part K.
  • No regression was observed in the selected tests.
  • The existing depth-copy failures remain unchanged.
  • Part K is absent from BASE, so this is independent verification of the fixed path, not a direct reproduction of the original hazard on the baseline.

Synthetic fixtures only. No game files used.

AI-assisted test automation and result analysis.

**@⁠Timon360SB** on GitHub · 2026-11-24 14:21 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/751#issuecomment-7134245559) ## Independent verification — Turing and Blackwell **Baseline:** `2d73c242fddfe26d57b52ee150704e6c3b23cff4` **PR head:** `a744fa8ab150c120babdbade56da470291d070cd` ### Environment | Configuration | RTX 2060 SUPER | RTX 5070 | | --- | --- | --- | | Architecture | Turing | Blackwell | | NVIDIA driver | 621.14 | 621.14 | | Windows 11 build | 28000 | 26200 | | Vulkan SDK | 1.4.363.0 | 1.4.363.0 | | MSVC | 19.44.35230 | 19.44.35230 | | Configuration | RelWithDebInfo | RelWithDebInfo | | Generator | Ninja Multi-Config | Ninja Multi-Config | Synchronization validation enabled. Three repetitions per revision on each GPU. ### Results | Test | 2060S BASE | 2060S HEAD | 5070 BASE | 5070 HEAD | | --- | --- | --- | --- | --- | | `vk_command_replay` | 0/3 | 0/3 | 0/3 | 0/3 | | `d3d12_state_map` | 3/3 | 3/3 | 3/3 | 3/3 | | `vk_sync_validation` | 3/3 | 3/3 | 3/3 | 3/3 | | New part K | N/A | 3/3 | N/A | 3/3 | **Total:** 36 CTest executions — 24 passed, 12 failed, 0 skipped. Part K results are included in the `vk_command_replay` executions, not counted as separate CTests. ### Targeted verification All six HEAD executions successfully completed the new part K: ```text K: SYNC_COPY orders WriteBufferImmediate (vkCmdUpdateBuffer, CLEAR stage) before a copy ``` The updated state-map checks also passed on both architectures. All 12 synchronization validation positive controls passed. ### Existing failures The overall `vk_command_replay` test fails on both revisions and both GPUs with the same reported depth-copy validation error: ```text VUID-vkCmdCopyBufferToImage-pRegions-07931 ``` | GPU | BASE | HEAD | | --- | ---: | ---: | | RTX 2060 SUPER | 30 | 30 | | RTX 5070 | 30 | 30 | Each execution reports 10 instances, subject to the validation layer's duplicate message limit. Parts H and I report validation errors on both revisions. ### Conclusion - The new `WriteBufferImmediate` regression scenario succeeds on Turing and Blackwell, with no new validation errors in part K. - No regression was observed in the selected tests. - The existing depth-copy failures remain unchanged. - Part K is absent from BASE, so this is independent verification of the fixed path, not a direct reproduction of the original hazard on the baseline. Synthetic fixtures only. No game files used. AI-assisted test automation and result analysis.
Author
Owner

@⁠SweatierKey on GitHub · 2026-11-24 14:33 UTC · original · approved these changes

Independent Windows 11 + NVIDIA GeForce RTX 5070 Ti (driver 616.92) verification applied cleanly on main@d0da7dade (portable clang-cl 23.1.6 + Windows SDK 10.0.26100):

  • d3d12_state_map_test.exe: PASS (RC=0, confirms SYNC_COPY maps to COPY | CLEAR).
  • vk_command_replay_test.exe on RTX 5070 Ti: PASS (RC=0, Parts A–K including new Part K ordering WriteBufferImmediate/vkCmdUpdateBuffer before CopyBufferRegion).
  • python3 -I scripts/check_no_game_data.py: PASS.

Clean, minimal fix; no game data. AI-assisted: yes.

**@⁠SweatierKey** on GitHub · 2026-11-24 14:33 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/751#pullrequestreview-6041146151) · **approved these changes** Independent Windows 11 + NVIDIA GeForce RTX 5070 Ti (driver 616.92) verification applied cleanly on `main@d0da7dade` (portable `clang-cl 23.1.6` + Windows SDK 10.0.26100): - `d3d12_state_map_test.exe`: PASS (`RC=0`, confirms `SYNC_COPY` maps to `COPY | CLEAR`). - `vk_command_replay_test.exe` on RTX 5070 Ti: PASS (`RC=0`, Parts A–K including new Part K ordering `WriteBufferImmediate`/`vkCmdUpdateBuffer` before `CopyBufferRegion`). - `python3 -I scripts/check_no_game_data.py`: PASS. Clean, minimal fix; no game data. AI-assisted: yes.
Author
Owner

@⁠QemmHD on GitHub · 2026-11-24 18:38 UTC · original

Merging.

Why merged: OLD-10048: SYNC_COPY maps to COPY|CLEAR, so WriteBufferImmediate (vkCmdUpdateBuffer) and the query zero-fill are ordered before later copies. moffington reproduced the read-after-write hazard on the base, and Timon360SB and SweatierKey checked it independently. Part K of vk_command_replay_test covers it.

Why it's good: vk_command_replay, d3d12_state_map and replay_query_edges pass both plain and under validation.

Tested on Windows 11 / RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0. Merged alone onto main 32950551e, its ctests pass both plain and with LEONIDA_VK_VALIDATION=1. Cumulative: #516, #535, #751, #935 and #662 merged onto main 955d9be34. There the repo-consistency set gives 571 passed / 5 skipped / 0 failed, compileall is clean, and full ctest is 307/309. The 2 failures are the same pre-existing ones as main (d3d12_execute_indirect_validation, d3d12_depth_resolve), with the same 11 skips. git merge-tree against current main 71f99e224: no conflicts, and none of these touch the files #891/#882 changed. Security read of the three-dot diff: no binaries, game data, downloads, network calls or CI changes.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠QemmHD** on GitHub · 2026-11-24 18:38 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/751#issuecomment-7140933852) Merging. **Why merged:** OLD-10048: SYNC_COPY maps to COPY|CLEAR, so WriteBufferImmediate (vkCmdUpdateBuffer) and the query zero-fill are ordered before later copies. moffington reproduced the read-after-write hazard on the base, and Timon360SB and SweatierKey checked it independently. Part K of vk_command_replay_test covers it. **Why it's good:** vk_command_replay, d3d12_state_map and replay_query_edges pass both plain and under validation. Tested on Windows 11 / RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0. Merged alone onto main 32950551e, its ctests pass both plain and with LEONIDA_VK_VALIDATION=1. Cumulative: #516, #535, #751, #935 and #662 merged onto main 955d9be34. There the repo-consistency set gives 571 passed / 5 skipped / 0 failed, compileall is clean, and full ctest is 307/309. The 2 failures are the same pre-existing ones as main (d3d12_execute_indirect_validation, d3d12_depth_resolve), with the same 11 skips. git merge-tree against current main 71f99e224: no conflicts, and none of these touch the files #891/#882 changed. Security read of the three-dot diff: no binaries, game data, downloads, network calls or CI changes. AI-assisted (Claude Code, Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.