d3d12: preserve GPU writes to adjacent buffers in either address order #2352
Closed
leonida/mandy
ecox982745 wants to merge 0 commits from
fix-adjacent-writeback-ranges into main
pull from: fix-adjacent-writeback-ranges
merge into: leonida:main
leonida:main
leonida:github-pr/3295
leonida:beta
leonida:docs/changelog-3483-3500
leonida:github-pr/3294
leonida:github-pr/2975
leonida:github-pr/2815
leonida:feat/gate-driver-start
leonida:feat/skip-pipelines-release
leonida:perf/lazy-compare
leonida:perf/mwaitx-wait
leonida:test/prio-ceiling-main
leonida:fix/ab-cpu-stdout
leonida:fix/gate-old-crashes
leonida:diag/ab-cpu
leonida:test/main-0312
leonida:github-pr/3291
leonida:diag/indirect-clamp-census
leonida:feat/barrier-enhanced
leonida:perf/texture-frame-ceiling
leonida:perf/dstorage-threads
leonida:fix/console-queue-dma-tables
leonida:fix/port-descriptors-record-parts
leonida:fix/frame-waits-fence
leonida:fix/console-sampler-words
leonida:fix/graphics-userdata-spill
leonida:fix/xg-reserved-layout-rotation
leonida:fix/barrier-console-flags
leonida:fix/switches-wait-test-child
leonida:test/list-value-waits
leonida:test/lot-gxdk-0412
leonida:fix/bvh-compacted-size
leonida:docs/i18n-quickstarts
leonida:feat/native-pipeline-slots
leonida:fix/clippy-leonida-gpu
leonida:fix/list-value-producers
leonida:fix/descriptor-page-straddle
leonida:fix/xmem-low-window
leonida:fix/ffx-jitter-never-zero
leonida:fix/run-stdout-closed
leonida:github-pr/2892
leonida:github-pr/2896
leonida:feat/warm-save-every
leonida:github-pr/2980
leonida:github-pr/2994
leonida:github-pr/3005
leonida:github-pr/3010
leonida:github-pr/3136
leonida:github-pr/3303
leonida:github-pr/3220
leonida:github-pr/3143
leonida:github-pr/3330
leonida:github-pr/3226
leonida:github-pr/3187
leonida:carry/3395
leonida:github-pr/2946
leonida:github-pr/2947
leonida:github-pr/2945
leonida:github-pr/2983
leonida:github-pr/3001
leonida:github-pr/3372
leonida:github-pr/3128
leonida:github-pr/3296
leonida:github-pr/2588
leonida:github-pr/3119
leonida:github-pr/3378
leonida:fix/crash-diagnostics
leonida:feat/dlss-mip-bias
leonida:fix/retired-out-of-order
leonida:fix/dxr-postbuild-barrier
leonida:fix/amd-relay-default
leonida:fix/removed-report-wait
leonida:feat/heap-twin
leonida:feat/vram-margin
leonida:github-pr/2472
leonida:github-pr/3123
leonida:github-pr/3088
leonida:assets/annonce-v1
leonida:github-pr/2794
leonida:github-pr/3300
leonida:github-pr/3304
leonida:github-pr/3308
leonida:github-pr/3367
leonida:github-pr/3369
leonida:fix/launcher-dlss-diagnostics
leonida:github-pr/3269
leonida:github-pr/2957
leonida:github-pr/3205
leonida:fix/crash-zero-guard
leonida:github-pr/3185
leonida:github-pr/3099
leonida:github-pr/3104
leonida:github-pr/3348
leonida:github-pr/3379
leonida:github-pr/3377
leonida:perf/darner-title-priority-ceiling
leonida:github-pr/3376
leonida:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
leonida:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
leonida:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
leonida:github-pr/3373
leonida:github-pr/3368
leonida:github-pr/3198
leonida:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
leonida:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
leonida:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
leonida:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
leonida:github-pr/3346
leonida:github-pr/3375
leonida:github-pr/2958
leonida:github-pr/3151
leonida:github-pr/3307
leonida:github-pr/3278
leonida:github-pr/3374
leonida:fix/runtime-test-conservative-fixtures
leonida:github-pr/3366
leonida:ci/shard-semantic-linux
leonida:github-pr/3354
leonida:docs/fg-limit-fps-switch
leonida:github-pr/3365
leonida:fix/read-file-hard-link
leonida:github-pr/3364
leonida:fix/book-slot-heap-never-read
leonida:github-pr/3361
leonida:github-pr/3263
leonida:github-pr/3360
leonida:github-pr/3353
leonida:github-pr/3331
leonida:fix/alias-later-queued-submissions
leonida:github-pr/3352
leonida:github-pr/3228
leonida:github-pr/3349
leonida:claude/gallant-sagan-aamatr
leonida:github-pr/3200
leonida:github-pr/3132
leonida:github-pr/3323
leonida:github-pr/3332
leonida:github-pr/3340
leonida:github-pr/3311
leonida:github-pr/3334
leonida:github-pr/3297
leonida:github-pr/3256
leonida:github-pr/2567
leonida:github-pr/2851
leonida:d3d12/agility-sdk-621
leonida:github-pr/3164
leonida:github-pr/3114
leonida:github-pr/3050
leonida:github-pr/3113
leonida:github-pr/3326
leonida:github-pr/3144
leonida:github-pr/2642
leonida:github-pr/3072
leonida:github-pr/2789
leonida:github-pr/2643
leonida:github-pr/3009
leonida:github-pr/3035
leonida:github-pr/3031
leonida:github-pr/2686
leonida:github-pr/2834
leonida:github-pr/3321
leonida:github-pr/3325
leonida:github-pr/3290
leonida:github-pr/3324
leonida:github-pr/3130
leonida:claude/fervent-curie-m19lnr
leonida:github-pr/3309
leonida:github-pr/3305
leonida:github-pr/3306
leonida:github-pr/3302
leonida:github-pr/3301
leonida:github-pr/3345
leonida:github-pr/3211
leonida:github-pr/3027
leonida:github-pr/3286
leonida:github-pr/3235
leonida:github-pr/3265
leonida:github-pr/3275
leonida:codex/skip-no-hit-ray-passes
leonida:github-pr/2823
leonida:github-pr/2911
leonida:github-pr/3262
leonida:github-pr/3125
leonida:github-pr/3206
leonida:github-pr/3250
leonida:github-pr/3238
leonida:github-pr/3188
leonida:github-pr/2952
leonida:github-pr/3217
leonida:github-pr/3168
leonida:t3/preserve-fsr-sdk-restart-path
leonida:t3/propagate-host-failure-hresult
leonida:github-pr/3209
leonida:t3/launcher-custom-parameters
leonida:github-pr/3207
leonida:github-pr/3183
leonida:github-pr/3160
leonida:github-pr/3201
leonida:ci/less-to-run
leonida:github-pr/2930
leonida:github-pr/2797
leonida:github-pr/2999
leonida:perf/native-compute-shader-forms
leonida:github-pr/3191
leonida:github-pr/3011
leonida:github-pr/3019
leonida:github-pr/2996
leonida:gh-readonly-queue/main/pr-2789-45dc41f95c1cd0dcc29c2c50582e0e9af8a77259
leonida:claude/blissful-franklin-ukp7ag
leonida:github-pr/3141
leonida:github-pr/3156
leonida:github-pr/3150
leonida:github-pr/3153
leonida:github-pr/3163
leonida:github-pr/3142
leonida:github-pr/3139
leonida:github-pr/2841
leonida:github-pr/3069
leonida:github-pr/3098
leonida:github-pr/3107
leonida:github-pr/3071
leonida:github-pr/2774
leonida:github-pr/2889
leonida:github-pr/3075
leonida:github-pr/2661
leonida:github-pr/3064
leonida:github-pr/3054
leonida:github-pr/3049
leonida:github-pr/2855
leonida:github-pr/2943
leonida:github-pr/3016
leonida:github-pr/2887
leonida:github-pr/3006
leonida:github-pr/3003
leonida:github-pr/2993
leonida:notes/card-time-and-plant-flicker
leonida:github-pr/2989
leonida:feat/vulkan-rs
leonida:github-pr/2985
leonida:github-pr/2951
leonida:github-pr/2982
leonida:github-pr/752
leonida:github-pr/792
leonida:github-pr/2877
leonida:github-pr/2654
leonida:github-pr/2893
leonida:github-pr/2948
leonida:github-pr/2944
leonida:github-pr/2919
leonida:github-pr/2915
leonida:archive/ci/less-to-run/20261202T1121Z
leonida:github-pr/2800
leonida:github-pr/2822
leonida:github-pr/2833
leonida:github-pr/2840
leonida:github-pr/2831
leonida:github-pr/2832
leonida:github-pr/2801
leonida:github-pr/2890
leonida:github-pr/2891
leonida:github-pr/2664
leonida:github-pr/2807
leonida:rt-call-trace
leonida:github-pr/2755
leonida:perf/ahead-split
leonida:github-pr/2587
leonida:github-pr/2698
leonida:github-pr/2609
leonida:github-pr/3219
leonida:docs/readme-runtime-proposal
leonida:github-pr/2017
leonida:github-pr/1741
leonida:github-pr/1667
leonida:codex/coord-claim-check-20261124-7e48
No reviewers
Assignees
Clear assignees
No assignees
Labels
Clear labels
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
enhancement
New feature or request
missing claim
Needs a claim in #14
needs rebase
Conflicts with the base branch: rebase it on main
needs-triage
Needs maintainer evaluation before the next triage state
question
Further information is requested
ready-for-agent
Fully specified and ready for an AFK agent
submodules
Pull requests that update submodules code
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
Projects
Clear projects
No items
No project
Milestone
Clear milestone
No items
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Reference
leonida/mandy!2352
Loading…
Reference in a new issue
No description provided.
Delete branch "fix-adjacent-writeback-ranges"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull request closed
This pull request cannot be reopened because the branch was deleted.
Claimed as RT-TITLE-WRITEBACK-ADJACENT-RANGES. This is the follow-up requested after #2129 landed.
Depends on: #2129 (merged into
mainthrough #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
mainatfbf100b1b, the new RTX 4090 test failed on the first word of the lower buffer when the upper address was submitted first. Expected0xa00000c7, read0x00001770.git diff --checkpassed.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 runtime fix is
f3c29e4e7. The test-only follow-upb27c441f98uses the same two-address submission helper as main. The fixture points its descriptor table at four untouched words in the first buffer so that changing submission order changes the expected output. The production diff is the same range-accounting change. Two-file diff against the tested mainGitHub's test merge
7a8508296dcombined mainef8fbf09f3and this PR atb27c441f98, producing the exact tree tested locally (e97148a439).0x00001770instead of0xa000d830. Running the lower-address-first case first passed all 32,768 words, then the higher-address-first case left word 0 at the prior result (0xa0001830).d3d12_placed_write_backandd3d12_title_window_write_backpassed three consecutive runs on the RTX 4090 with Khronos validation enabled, with no validation messages. Both CTests also passed on the PR head.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:I reran that target on an RTX 4090 after #2356 changed the runtime defaults. With the PR fixture on unpatched
mainat246791612, the higher-address-first case still failed on word 0 of the lower buffer (read0x00001770, expected0xa00000c7). With #2352 headf3c29e4e7merged locally onto that same main (tree6e0f2654f), 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).
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 atf3c29e4e73and #2404 at46aeaaefab(combined tree380ce092ad).00001770, expecteda00000c7.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.
#2352 still applies cleanly after #2404 entered main. I verified
46aeaaefis an ancestor ofd1dff7949be62b6609c3c2ca937df7f50fbf1305, and merged only #2352 atf3c29e4e7380a3851d1c54ce671e84e0eecb26dainto that receiver. It produced tree406a2eddf41bc16c01a40c83ed196ddd64dae47awithout 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$' -Vto 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.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_backpassed in both address orders. On plaind1dff7949bwith the identical test source, upper-address-first still failed at word 0: read00001770, expecteda00000c7.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.
d1dff7949bf3c29e4e73For
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-05137at teardown despite passing. The same message appeared when I rand3d12_existing_heapon plain main. These were synthetic GPU readbacks. AI-assisted verification.Reviewed head
b27c441f9and re-tested on Windows 11 + NVIDIA GeForce RTX 5070 12 GB (MSVC 19.44, Ninja Release).note_title_write_back()cleanly merges all overlapping/adjacent ranges[first, last)in either address order, charges only newly covered bytes (added_bytes = (merged_end - begin) - replaced_bytes) with an overflow-safe cap check (added_bytes > kTitleWriteBackBytes - title_write_back_bytes), and replaces the merged span viainsert_or_assign+erase.d3d12_title_va_testand ranctest --output-on-failure -V:d3d12_title_va: passedd3d12_title_va_shadow: passedd3d12_title_window_write_back: passedd3d12_placed_write_back: passed (0.19 s; both upper-first and lower-first adjacent buffer writes merged into one 128 KiB range and matched expected words).GPUs tested: NVIDIA GeForce RTX 5070 12 GB (Windows 11, driver 610.88, Vulkan 1.4.341;
VK_LAYER_KHRONOS_validationnot installed locally).AI-assisted (Antigravity, Gemini).
Physical RADV gfx906 (fixed subgroup 64), Wine, synchronization validation enabled. I ran the same
d3d12_placed_write_backfixture against main4a54aedcband this headb27c441f9merged with it. Main failed when the higher-address buffer was submitted first: all 64 output words in the lower buffer were wrong. The merge returned all 64 correctly. The upper buffer and all guard words matched on both builds; reversing the submission order also passed on both. Both fences completed in each ordering.The registered placed-write-back, window-write-back and shadow-keep/refill CTests went from 2/3 to 3/3; no validation errors, synchronization hazards or device loss in either build.
AI-assisted.
The conflict with main is resolved in
b922a2ca5. The only change since the reviewed head is in the test helper. It now matches main'ssubmit_writesignature and forwards the optional base constant. The adjacent-buffer test still uses its original inputs in both address orders. GitHub reports a clean merge withc8bf0e7b65.I checked that this fix is still needed after #2470. With the updated test on main's unchanged runtime, submitting the higher address first left word zero of the lower buffer at
0x00001770instead of0xa000d830. With this PR's runtime, the same test passed.I ran the CTests on Windows 11 with an RTX 4090, NVIDIA driver 616.64 and Vulkan validation enabled.
b922a2ca5c8bf0e7b65The integration run included main's same-page ranges test and this PR's adjacent-buffer test. All 33 runs completed with zero Vulkan validation errors. Integration tree
1f2a5b23f7272e11a656e8dff8ee1ef1c6276ec5. AI-assisted with OpenAI Codex (GPT-6).CI follow-up on
b922a2ca5. The Windows runtime job passed. The four failing general CI jobs reported the same cases on the PR and its exact main base,c8bf0e7b65. They cover loader stack size, pool-path deduplication and two f16 conversion cases. PR CI · Main CIThe Linux runtime job failed in
pipeline_workers. The macOS runtime job failed invk_bindless_dimensions,cs_imgatomic_extandps_exp_f32_denorm_rt. All four also failed in the earlier main runtime run at02944d4ca. PR runtime · Main runtimeRetested the updated head
b922a2ca5d8fb6094bc9bdba5e2d564f80015551onmainc8bf0e7b65, on an RTX 5070 (NVIDIA 610.88), Windows 10, MSVC 19.29, Khronos validation enabled. The build used pinned Agility headers and a static CRT.With the exact updated test fixture and main's runtime implementation, the upper-first adjacent-buffer case still failed on word 0. Main's same-page ranges case passed. With the PR implementation, all seven focused title-VA and write-back CTests passed, including the adjacent-buffer case in both orders and the same-page ranges case. Synthetic fixtures only.
AI-assisted. Codex (GPT-6).
mainnow covers the runtime fix through #2566. I resolved the conflict withd367675c7locally by takingruntime/shims/d3d12_vulkan_device.cppfrommainand retaining the adjacent-buffer regression as the sole file in the diff. The resulting tree is6e472c992. The original fixture detected the lost lower-buffer write when the upper address was submitted first. Both orders now pass with the merged runtime.On native Windows 11, MSVC 19.44 Release and RTX 4090 (NVIDIA 616.64),
d3d12_placed_write_back,d3d12_title_window_write_back, and itsfault,fault_tile, andrangesvariants passed three times each with Khronos validation 1.4.369 and zero errors. All inputs were synthetic.The branch still needs the merge from
main. GitHub rejected my fast-forward push because the incoming upstream.github/workflows/ci.ymlrevision requires OAuthworkflowscope. I recommend keeping the existing runtime frommainand carrying this PR forward as the regression test.AI-assisted with OpenAI Codex (GPT-6.2 Sol).
Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (
d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools,d3d12/, or general docs), please feel free to reopen it.