Skip to content

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

Draft
ecox982745 wants to merge 1 commit into
ProjectLeonida:mainfrom
ecox982745:fix-adjacent-writeback-ranges
Draft

ecox982745 wants to merge 1 commit into
ProjectLeonida:mainfrom
ecox982745:fix-adjacent-writeback-ranges

Conversation

@ecox982745

Copy link
Copy Markdown

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).

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).

@lixonik lixonik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@ecox982745

Copy link
Copy Markdown
Author

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

Copy link
Copy Markdown
Author

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.

@akimfomin

Copy link
Copy Markdown
Contributor

#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.

@ecox982745

Copy link
Copy Markdown
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs rebase Conflicts with the base branch: rebase it on main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants