d3d12: preserve GPU writes to adjacent buffers in either address order #2352

Open
github-bot wants to merge 1 commit from github-bot/gh-2352 into main AGit
Owner

@⁠ecox982745 on GitHub · 2026-11-26 14:54 UTC · original
ecox982745:fix-adjacent-writeback-ranges → main · +63 −31 · 2 files · 1 commits · draft

Claimed as RT-TITLE-WRITEBACK-ADJACENT-RANGES. This is the follow-up requested after #2129 landed.

Depends on: #2129 (merged into main through #2350).

What changed

When a submission wrote two adjacent placed buffers in descending address order, the queued interval kept the higher starting address. The lower buffer’s GPU results never reached the CPU pages. The tracker now merges touching and overlapping intervals under their lowest address and charges only newly covered bytes against the per-submission cap.

The GPU regression writes two adjacent 64 KiB buffers in one command list. It checks both address orders with different expected values, then checks every word in both buffers, including all 32,640 words outside the written portions.

Verification

  • Before the fix. On main at fbf100b1b, the new RTX 4090 test failed on the first word of the lower buffer when the upper address was submitted first. Expected 0xa00000c7, read 0x00001770.
  • After the fix. Both address orders passed. The placed-buffer and window write-back tests each passed three times with Vulkan validation enabled and three times with it disabled on the integrated tree. All six related CTests passed with validation enabled on both the submitted commit and its integration with main.
  • CPU range accounting. A separate harness compared the production insertion code against a byte-set model over all 46,656 ordered triples of intervals in an eight-byte address space, with caps of five bytes and two ranges. The parent disagreed on 37,831 sequences. The fix matched at every insertion, including refused insertions.
  • The integrated tree passed the CPU translator suite (500 files, 6,365 tests, zero failed files). The changed-file game-data check and git diff --check passed.

GPUs tested: NVIDIA GeForce RTX 4090, driver 616.64, Windows 11. All test inputs were synthetic.

AI-assisted: Yes, OpenAI Codex (GPT-6).

Integration

The branch starts at the already-merged #2129 head 5fa864e53. The PR adds one commit, f3c29e4e7, touching two files. Its clean merge with main at fbf100b1b produced the exact tree used for integration testing (7dc0a1aec).

**@⁠ecox982745** on GitHub · 2026-11-26 14:54 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2352) `ecox982745:fix-adjacent-writeback-ranges` → `main` · +63 −31 · 2 files · 1 commits · draft Claimed as [RT-TITLE-WRITEBACK-ADJACENT-RANGES](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608). This is the [follow-up requested after #2129 landed](https://git.gtahub.st/github/ubiquitarianism--leonida/pulls/2129). Depends on: #2129 (merged into `main` through #2350). ### What changed When a submission wrote two adjacent placed buffers in descending address order, the queued interval kept the higher starting address. The lower buffer’s GPU results never reached the CPU pages. The tracker now merges touching and overlapping intervals under their lowest address and charges only newly covered bytes against the per-submission cap. The GPU regression writes two adjacent 64 KiB buffers in one command list. It checks both address orders with different expected values, then checks every word in both buffers, including all 32,640 words outside the written portions. ### Verification - **Before the fix.** On `main` at `fbf100b1b`, the new RTX 4090 test failed on the first word of the lower buffer when the upper address was submitted first. Expected `0xa00000c7`, read `0x00001770`. - **After the fix.** Both address orders passed. The placed-buffer and window write-back tests each passed three times with Vulkan validation enabled and three times with it disabled on the integrated tree. All six related CTests passed with validation enabled on both the submitted commit and its integration with main. - **CPU range accounting.** A separate harness compared the production insertion code against a byte-set model over all 46,656 ordered triples of intervals in an eight-byte address space, with caps of five bytes and two ranges. The parent disagreed on 37,831 sequences. The fix matched at every insertion, including refused insertions. - The integrated tree passed the CPU translator suite (500 files, 6,365 tests, zero failed files). The changed-file game-data check and `git diff --check` passed. GPUs tested: NVIDIA GeForce RTX 4090, driver 616.64, Windows 11. All test inputs were synthetic. AI-assisted: Yes, OpenAI Codex (GPT-6). ### Integration The branch starts at the already-merged #2129 head `5fa864e53`. The PR adds one commit, `f3c29e4e7`, touching two files. Its clean merge with `main` at `fbf100b1b` produced the exact tree used for integration testing (`7dc0a1aec`).
Merge all touching intervals under their lowest address. Charge only the
newly covered bytes before changing the per-submission map. Check both
GPU dispatch orders and the untouched words in two adjacent buffers.

AI-assisted by OpenAI Codex (GPT-6).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 14:59:04 +00:00
Author
Owner

@⁠lixonik on GitHub · 2026-11-26 15:35 UTC · original · reviewed

Built this head with MSVC and ran d3d12_title_va and d3d12_title_va_shadow on Windows 11. Both passed, including adjacent buffer GPU writes in both address orders. GPU: NVIDIA GeForce RTX 5070, driver 610.88. No findings from these checks.

AI-assisted.

**@⁠lixonik** on GitHub · 2026-11-26 15:35 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2352#pullrequestreview-6076849881) · **reviewed** Built this head with MSVC and ran `d3d12_title_va` and `d3d12_title_va_shadow` on Windows 11. Both passed, including adjacent buffer GPU writes in both address orders. GPU: NVIDIA GeForce RTX 5070, driver 610.88. No findings from these checks. AI-assisted.
Author
Owner

@⁠ecox982745 on GitHub · 2026-11-26 15:47 UTC · original

Thanks for the RTX 5070 run. The two named CTests exercise the general title-address and shadow paths. The adjacent-buffer checks run in a separate CTest, d3d12_placed_write_back, which invokes the same executable with --placed-writeback. For a 5070 result on both address orders, the command from a configured build directory is:

ctest -V -R "^d3d12_placed_write_back$"

I reran that target on an RTX 4090 after #2356 changed the runtime defaults. With the PR fixture on unpatched main at 246791612, the higher-address-first case still failed on word 0 of the lower buffer (read 0x00001770, expected 0xa00000c7). With #2352 head f3c29e4e7 merged locally onto that same main (tree 6e0f2654f), both orders passed and all six related CTests passed with Vulkan validation enabled. Windows 11, NVIDIA 616.64, synthetic buffers.

AI-assisted verification by OpenAI Codex (GPT-6).

**@⁠ecox982745** on GitHub · 2026-11-26 15:47 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2352#issuecomment-7196761377) Thanks for the RTX 5070 run. The two named CTests exercise the general title-address and shadow paths. The adjacent-buffer checks run in a separate CTest, `d3d12_placed_write_back`, which invokes the same executable with `--placed-writeback`. For a 5070 result on both address orders, the command from a configured build directory is: ```sh ctest -V -R "^d3d12_placed_write_back$" ``` I reran that target on an RTX 4090 after #2356 changed the runtime defaults. With the PR fixture on unpatched `main` at `246791612`, the higher-address-first case still failed on word 0 of the lower buffer (read `0x00001770`, expected `0xa00000c7`). With #2352 head `f3c29e4e7` merged locally onto that same main (tree `6e0f2654f`), both orders passed and all six related CTests passed with Vulkan validation enabled. Windows 11, NVIDIA 616.64, synthetic buffers. AI-assisted verification by OpenAI Codex (GPT-6).
Author
Owner

@⁠ecox982745 on GitHub · 2026-11-26 21:49 UTC · original

I tested #2352 together with #2404 on a physical RTX 4090 under Windows 11, with Vulkan validation enabled. Both changes applied cleanly to 55e2bd9e9e. The build used #2352 at f3c29e4e73 and #2404 at 46aeaaefab (combined tree 380ce092ad).

Runtime under test Result with the same adjacent-buffer regression
Base + #2404 Upper-address-first failed at word 0. Read 00001770, expected a00000c7.
Base + #2404 + #2352 Both address orders passed. Each order checked all 32,768 words across the two adjacent buffers, including the untouched words.

All eight related CTests passed on the combined build, covering title addresses, shadow buffers, geometry views, title-window limits, and write-back. The test log contained no Vulkan validation errors. These were synthetic GPU tests. A story-mode run is still needed to establish the gameplay impact.

**@⁠ecox982745** on GitHub · 2026-11-26 21:49 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2352#issuecomment-7204087501) I tested #2352 together with #2404 on a physical RTX 4090 under Windows 11, with Vulkan validation enabled. Both changes applied cleanly to `55e2bd9e9e`. The build used #2352 at `f3c29e4e73` and #2404 at `46aeaaefab` (combined tree `380ce092ad`). | Runtime under test | Result with the same adjacent-buffer regression | | --- | --- | | Base + #2404 | Upper-address-first failed at word 0. Read `00001770`, expected `a00000c7`. | | Base + #2404 + #2352 | Both address orders passed. Each order checked all 32,768 words across the two adjacent buffers, including the untouched words. | All eight related CTests passed on the combined build, covering title addresses, shadow buffers, geometry views, title-window limits, and write-back. The test log contained no Vulkan validation errors. These were synthetic GPU tests. A story-mode run is still needed to establish the gameplay impact.
Author
Owner

@⁠akimfomin on GitHub · 2026-11-26 23:30 UTC · original

#2352 still applies cleanly after #2404 entered main. I verified 46aeaaef is an ancestor of d1dff7949be62b6609c3c2ca937df7f50fbf1305, and merged only #2352 at f3c29e4e7380a3851d1c54ce671e84e0eecb26da into that receiver. It produced tree 406a2eddf41bc16c01a40c83ed196ddd64dae47a without conflicts. This updates the receiving baseline from the previous paired RTX 4090 run.

On that tree the exact entry point is ctest -R '^d3d12_placed_write_back$' -V to assert both adjacent-buffer orders. No extra #2404 cherry-pick is needed. My separate Windows configuration stopped at the root-signature 1.2 SDK requirement, so I have a Git result only for this new baseline. PortBridge · AI-assisted comparison.

**@⁠akimfomin** on GitHub · 2026-11-26 23:30 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2352#issuecomment-7205599124) #2352 still applies cleanly after #2404 entered main. I verified `46aeaaef` is an ancestor of `d1dff7949be62b6609c3c2ca937df7f50fbf1305`, and merged only #2352 at `f3c29e4e7380a3851d1c54ce671e84e0eecb26da` into that receiver. It produced tree `406a2eddf41bc16c01a40c83ed196ddd64dae47a` without conflicts. This updates the receiving baseline from the [previous paired RTX 4090 run](https://git.gtahub.st/github/ubiquitarianism--leonida/pulls/2352). On that tree the exact entry point is `ctest -R '^d3d12_placed_write_back$' -V` to assert both adjacent-buffer orders. No extra #2404 cherry-pick is needed. My separate Windows configuration stopped at the root-signature 1.2 SDK requirement, so I have a Git result only for this new baseline. [PortBridge](https://github.com/akimfomin/PortBridge/issues/98) · AI-assisted comparison.
Author
Owner

@⁠ecox982745 on GitHub · 2026-11-26 23:48 UTC · original

I ran the requested CTest on the exact integration tree 406a2eddf41bc16c01a40c83ed196ddd64dae47a, which includes #2404 and #1867. On a physical RTX 4090 (Windows 11, NVIDIA 616.64, Vulkan validation enabled), d3d12_placed_write_back passed in both address orders. On plain d1dff7949b with the identical test source, upper-address-first still failed at word 0: read 00001770, expected a00000c7.

I also extended the fixture locally to three adjacent 64 KiB buffers on one allocation. Each order ran in a fresh process. Here 0, 1, and 2 are the low, middle, and high buffers. A passing run matched all 49,152 words, including those outside the three write regions.

Runtime Passing submission orders Failing submission orders
d1dff7949b 012, 021, 201 102, 120, 210
Same main + #2352 at f3c29e4e73 All six None

For 210, the first mismatch on main was word 16,384, the first word of the middle buffer. The three-buffer runs logged no Vulkan validation errors.

All eight title-address and write-back CTests passed on the integration, along with the three existing-heap variants. Those three variants logged VUID-vkDestroyDevice-device-05137 at teardown despite passing. The same message appeared when I ran d3d12_existing_heap on plain main. These were synthetic GPU readbacks. AI-assisted verification.

**@⁠ecox982745** on GitHub · 2026-11-26 23:48 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2352#issuecomment-7205880035) I ran the [requested CTest](https://git.gtahub.st/github/ubiquitarianism--leonida/pulls/2352) on the exact integration tree `406a2eddf41bc16c01a40c83ed196ddd64dae47a`, which includes #2404 and #1867. On a physical RTX 4090 (Windows 11, NVIDIA 616.64, Vulkan validation enabled), `d3d12_placed_write_back` passed in both address orders. On plain `d1dff7949b` with the identical test source, upper-address-first still failed at word 0: read `00001770`, expected `a00000c7`. I also extended the fixture locally to three adjacent 64 KiB buffers on one allocation. Each order ran in a fresh process. Here 0, 1, and 2 are the low, middle, and high buffers. A passing run matched all 49,152 words, including those outside the three write regions. | Runtime | Passing submission orders | Failing submission orders | | --- | --- | --- | | `d1dff7949b` | 012, 021, 201 | 102, 120, 210 | | Same main + #2352 at `f3c29e4e73` | All six | None | For `210`, the first mismatch on main was word 16,384, the first word of the middle buffer. The three-buffer runs logged no Vulkan validation errors. All eight title-address and write-back CTests passed on the integration, along with the three existing-heap variants. Those three variants logged `VUID-vkDestroyDevice-device-05137` at teardown despite passing. The same message appeared when I ran `d3d12_existing_heap` on plain main. These were synthetic GPU readbacks. AI-assisted verification.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2352/head:github-bot/gh-2352'
git switch 'github-bot/gh-2352'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2352'
git switch 'github-bot/gh-2352'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2352'
git switch 'github-bot/gh-2352'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2352'
git switch 'main'
git merge --squash 'github-bot/gh-2352'
git switch 'main'
git merge --ff-only 'github-bot/gh-2352'
git switch 'main'
git merge 'github-bot/gh-2352'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.