Repository navigation
startup: read translated compute inputs that live only in title memory from a snapshot - #2862
Conversation
…y from a snapshot, and bind unbound inputs as zeros A compute input in a placed buffer that does not alias title memory is a committed default buffer that holds zeros, so the bytes the title wrote exist only in title memory. With X2W_TRANSLATED_TITLE_INPUT_SNAPSHOT=1 (opt-in) the range (at most 16 MiB) is copied into a dedicated upload pool (128 MiB) so draw and texture uploads cannot starve it. A compute input whose four descriptor words are all zero is an unbound buffer: it reads zeros (16 bytes) instead of refusing the dispatch; an empty range with any non-zero word is still refused. The log names the source of each input and the render totals count GPU copies and snapshots.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d9fbfc86a3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…rect the launcher doc
|
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
AI-assisted; commands listed were executed locally. |
KelboLive
left a comment
There was a problem hiding this comment.
Good work on this. The approach is sound:
-
Dual upload pools (snapshot 128 MiB vs draw/texture 256 MiB) correctly prevents snapshots from starving draw uploads
-
Resolution order is correct: GPU copy (from X2W_TRANSLATED_INDIRECT_COPY_RANGES) -> snapshot -> refusal. The fallback chain is safe and the 16 MiB cap on snapshots is reasonable
-
Null descriptor handling: correctly produces 16 bytes of zeros for all-zero descriptor words, matching hardware behavior. The readable_window check before ring_copy is the right guard
-
indirect_table_buffer API expansion: added allow_title_snapshot parameter cleanly propagated from record_translated_dispatch
-
Tracking counters: atomic counters with snapshot KiB tracking gives good observability
Minor notes:
- The InputSource source field in IndirectBufferView is a clear 4-value enum. When this stabilizes consider a typed enum (similar to NullCause) rather than int, but not urgent
- The 128 MiB / 256 MiB split is hardcoded. If title pressure shows the pool balance needs tuning, make the split configurable. Not needed today
Looks good to merge. This unblocks #2860 and forms a solid foundation for the upload ring reuse work in #2847.
|
A run report for this PR, combined with #2902, on a local capture (counts only). The build and the run were done in an offline Windows Sandbox:
Without this PR (#2902 alone), the three compute pipelines that #2902 translates are all refused at Dispatch with With this PR:
One difference from this PR as written: the merge with #2849 conflicted in In an earlier run of the same merge, the title went past its first screen:
That run used the shared ring above, so it says nothing direct about the separate pool. AI-assisted. |
|
@Leyukaka thank you for this run report, and for testing this PR together with #2902 on top of current main. Two things we take from it:
This PR currently conflicts with main in AI-assisted; commands listed were executed locally. |
…ts get their own recycled pool Main's shared upload ring (reused once no recording can submit a chunk and every queue that used it has finished) is kept as it is. The snapshots take a second pool built the same way (128 MiB, chunks numbered after the ring's in the recording mask and the per-queue table) instead of the shared ring or a never-reused one, so a long run is not stopped by a full pool; the long-run case dispatches 384 MiB of snapshots over 48 frames.
… alias title memory, and asserts the snapshot log line
|
Stage-2 gate on the redesigned head (own recycled snapshot pool on top of #2849): Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
Mutant check (snapshot pool never recycled, AI-assisted; commands listed were executed locally. |
pigalot
left a comment
There was a problem hiding this comment.
I tried to review 73b2d0ff over current main 454fc0ed, but the trial merge (git merge --no-ff --no-commit) conflicts in four files:
src/startup_stubs/upload_reservation.handtests/upload_reservation_check.cpp: #2949 (98e4a2ee, opt-in release of upload ring chunks at a fenced submit) is the only change to these files since the PR's base6ee878d8. It changes the same chunk-reuse code the snapshot pool is built on, so the snapshot chunks probably need to follow the new fenced-release rule as well, not only a textual merge.src/startup_stubs/d3d12_xs_device.cpp:mainhas since taken #2833, #2919, #3028 and #2920 in this file.tests/startup_stream_consumer.cpp:mainhas since taken #2882, #2874, #2902 and #2953.
I'll review it once it is updated with main.
This reply was AI-assisted.
|
Updated with Not yet built or run on Windows after the merge. Commands run locally: AI-assisted; commands listed were executed locally. |
|
Verification: head Environment: Windows Server 2025 (build 26100), MSVC 14.44, D3D12 WARP and the hardware adapter, dev and release legs in parallel. Commands (the same selection in both legs): Result: 31/31 passed in both legs (2 native compute cases skipped by capability); includes AI-assisted; commands listed were executed locally. |
|
Updated with Verification:
AI-assisted; commands listed were executed locally. |
pigalot
left a comment
There was a problem hiding this comment.
Reviewed e5af9a66 merged over current main fad97f47. The merge is clean and git diff --cached --check is clean. The conflicts from my comment on 73b2d0ff are resolved.
What I traced.
- Snapshot pool numbering: the snapshot pool's chunks are numbered from
snapshot_chunk_base(=max_upload_chunks, 32).UploadChunkMaskis now 64-bit,static_asserted against the 40 bits. The per-queuelast_useandReleasedUploadChunks::generationarrays are sized to all 40 bits.hold,reuse_upload_chunk,discard_upload_chunks,release_upload_chunks_at_submitandresubmitted_upload_chunksall go throughbase + index/upload_chunk_at. So a recording's mask, the queue fence table and the fenced-release rule from #2949 cover both pools, and the two pools can't collide. I found no 32-bit mask left: the resubmit log line is now%llx. - Budgets and statistics: the snapshot pool has its own budget (128 MiB) and never takes the release-at-submit growth path. The ring statistics and
upload_ring_refusalscount only the ring. - The snapshot path: it runs only for compute inputs (
allow_title_snapshot), withX2W_TRANSLATED_TITLE_INPUT_SNAPSHOT=1, for a placed buffer that doesn't alias title memory. It comes after the GPU-copy proof and needs a range of at most 16 MiB. It refuses an unreadable range beforering_copy. - Null descriptors: an all-zero descriptor binds 16 zero bytes from the snapshot pool. Compute inputs go through descriptor-table raw SRVs with
NumElements = bytes / 4, so reads past those 16 bytes also return zero. An empty range with any non-zero word is still refused.
What I ran. I did a full build in dev and release, then ran
ctest --test-dir out/build/<preset> --no-tests=error -j 4 -E '(_hardware$|startup_audio_)' -R '^(upload_reservation.*|startup_compute_dispatch.*|startup_slot67_indirect.*|startup_upload.*|startup_stream_(check|draw.*|consumer.*)|startup_frame_copy.*|startup_null.*|startup_indirect_translated.*|startup_compute_request.*)$'
# with X2W_TEST_DEBUG_LAYER=1, one at a time
ctest --test-dir out/build/<preset> --no-tests=error -j 1 -R '^(startup_compute_dispatch|startup_slot67_indirect|startup_upload|startup_stream_draw|startup_frame_copy|startup_null|startup_indirect_translated|startup_compute_request).*_hardware$'The results were the same in both presets:
- Without
_hardware: 32 of 33 pass. _hardware: 23 of 24 pass.- The two failures are
startup_compute_dispatch_native_warpand_hardware(the native route left ['revision.txt'] in the cache). They're a pre-existing regression onmainfrom #2820, not this PR.main's own Windows run on14d56502fails the same way; I reported it on #2820. This PR doesn't touch that test or the cache writer. - This PR's own tests pass in both presets and both adapters:
upload_reservation,startup_compute_dispatch_input_{warp,hardware}(including bothdispatch-input-snapshot-longmodes) and the stream and null checks.
Mutants. For each, I rebuilt dev and ran upload_reservation, startup_compute_dispatch_input_warp, startup_stream_draw_warp and startup_null_cause_labels:
| Mutant | Result |
|---|---|
| snapshot chunks never reused | killed (dispatch-input-snapshot-long: consumer exit 85 after snapshot pool reservation refused) |
snapshot chunks numbered from 0 like the ring (base = 0 in reserve_upload_ring) |
killed (startup_compute_dispatch_input_warp) |
snapshot_chunk_base = 0 in the header |
killed (upload_reservation) |
the snapshot ignores X2W_TRANSLATED_TITLE_INPUT_SNAPSHOT |
killed (dispatch-input-copied: a refused Dispatch wrote the output) |
| all-zero descriptor refused as before | killed (dispatch-input-null) |
| any empty range treated as null | killed (dispatch-input-empty: a refused Dispatch wrote the output) |
snapshot skips the readable_window check |
survives |
Restored and rebuilt afterwards; git diff --quiet is clean.
Non-blocking.
- The unreadable-range refusal is unpinned. No case points a snapshot input at unmapped title memory. Without the check,
ring_copy's plainmemcpywould fault in the stand-in. A case with a freed range would pinan input range in title memory is not readable. - The null-descriptor change is on by default. It isn't behind
X2W_TRANSLATED_TITLE_INPUT_SNAPSHOT:dispatch-input-nullruns without the flag, and the PR description says so. But thedocs/experiments.mdparagraph describes only the opt-in snapshot. One sentence there, saying that an all-zero compute input descriptor now binds 16 zero bytes by default, would help the next reader.
Verdict: approve on e5af9a66.
Environment: NVIDIA GeForce RTX 5090, driver 32.0.16.1088; D3D12 WARP; Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10; debug layer on for the hardware runs.
CI: Build and test on Windows, Assemble and translate gfx1013 fixtures and Run platform-independent Python checks on Linux pass on e5af9a66.
This reply was AI-assisted.
|
The refreshed #3224 startup census puts this refusal first for 35 of the 45 keys that published a manifest (10,555 dispatches in run 74). That makes it worth retesting #2862 against those same keys. The receipt here is for source-built fixtures only. I trial-merged e5af9a6 onto main 2d6dad1 (tree ab42ca48cd3164819cb09e68c53a9157d984d716). The only conflict is in tests/startup_stream_consumer.cpp. I kept main's indirect-pixel group counts and copied-output case, and this PR's long-run allocation, snapshot input initialization, and copied-input cases. Debug 9/9, Release /O2 9/9, no skips. Inbox WARP 10.0.26100.9818 and RTX 4060 Laptop (32.0.16.1656), Windows 11 26200.9974, D3D12 debug layer enabled for the input fixture. With the flag off the copied input was refused and the sentinel stayed intact. With it on, all 320 words matched, the zero-input control changed the output, and both 48-frame snapshot-reuse tests passed. The existing copied-output refusal and indirect graphics controls passed. Please refresh this PR with the latest main, keeping both fixture edits. Once the head is updated, the useful runtime follow-up is a matched flag-off/on run using run 74's cache and an output reference for any newly accepted key. |
Conflict resolved by keeping both sides: - tests/startup_stream_consumer.cpp: main's dispatch-output-* and dispatch-indirect-pixel-* modes, with this branch's snapshot modes, long-run buffer size and null-descriptor case.
|
I merged current Conflict. Both sides added
What I ran on
A different reviewer will re-review the merged head. Environment: NVIDIA GeForce RTX 5090, driver 32.0.16.1088; D3D12 WARP; Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10. This reply was AI-assisted. |
R0Y00
left a comment
There was a problem hiding this comment.
I reviewed 4d417f02 and tested its integration with main 0fe4cebc (tree 910ad5a6). The conflict resolution keeps the new indirect-pixel group counts and copied-output case, and the long-run snapshot allocation and input initialization.
Debug and Release /O2 each passed 9/9, zero skips, with the shim, stream consumer and reservation test rebuilt:
ctest --test-dir <build> --no-tests=error --output-on-failure -j 1 -R '^(upload_reservation|startup_compute_dispatch_(input_|output_)?(warp|hardware)|startup_slot67_indirect_dispatch_(warp|hardware))$'Windows 11 26200.9974, WARP 10.0.26100.9818 and RTX 4060 Laptop driver 32.0.16.1656. The input fixture requests the D3D12 debug layer. The source-built cases cover copied and zero input, flag-off refusal, 48-frame snapshot-pool reuse, and the adjacent copied-output and indirect paths. The remaining checkout is a matched opt-in startup run for the keys reported in #3224.
pigalot
left a comment
There was a problem hiding this comment.
Re-reviewed 4d417f02 (the merge of main fdb6faaa into e5af9a66) integrated over the current main 0637fced (tree cbd79d55). The trial merge is clean and git diff --cached --check origin/main is clean. The earlier approval on e5af9a66 was from another session on this account; I didn't push this merge.
What I checked in the merge.
tests/startup_stream_consumer.cpp, the only file resolved by hand:- The
groupsexpression takesmain'sdispatch-indirect-pixel-*cases. - The
VirtualAllockeeps this branch's long-run size,0x28000 + long_records * 4. - The third placed buffer is created for this branch's snapshot and long modes and for
main'sdispatch-output-copied. - The long-run loop starts after
main'ssubmit(pixel ? 2 : 1), which signals fence 1 for a non-pixel mode, so its frames still wait on 2 to 48.
- The
- Runtime: this branch's runtime changes don't collide with
main's newer compute-dispatch code.- The new
allow_title_snapshotparameter ofindirect_table_buffergoes last, with a default, and only the table-input call inrecord_translated_dispatchpasses it. - The other callers, and
main's output-descriptor refusals, keep their behaviour. IndirectBufferView::sourceis appended afterupload, so the existing five-field initialisers still mean the same.
- The new
What I ran. I did a full build in dev and release, then ran:
ctest --test-dir out/build/<preset> --no-tests=error -j 4 -E '(_hardware$|startup_audio_)' -R '^(upload_reservation.*|startup_compute_dispatch.*|startup_slot67_indirect.*|startup_upload.*|startup_stream_(check|draw.*|consumer.*)|startup_frame_copy.*|startup_null.*|startup_indirect_translated.*|startup_compute_request.*)$'
# X2W_TEST_DEBUG_LAYER=1, under the GPU lock
ctest --test-dir out/build/<preset> --no-tests=error -j 1 -R '^(startup_compute_dispatch|startup_slot67_indirect|startup_upload|startup_stream_draw|startup_frame_copy|startup_null|startup_indirect_translated|startup_compute_request).*_hardware$'- Without
_hardware: 33 of 34 pass in Debug and Release/O2.startup_compute_dispatch_native_warpreports a capability skip (77). _hardware: 25 of 25 pass in Debug and Release on the RTX 5090, with the debug layer on.- The full non-hardware suite in
dev(-j 8 -E '(_hardware$|startup_audio_)'): 2000 tests.- 1941 pass.
- 57 report capability skips.
pixel_aot_warpandpixel_aot_core_vector_warptimed out at-j 8; alone at-j 1they pass in 18 s and 10 s.- The
revision.txtfailures from #2820 no longer appear on thismain.
Mutants in the resolved tests/startup_stream_consumer.cpp. Each was applied alone, then startup_stream_consumer was rebuilt in dev and startup_compute_dispatch_{input,output}_warp run. The source was restored and rebuilt afterwards, with git diff --quiet clean and both tests passing again.
| Mutant | Result |
|---|---|
third buffer not placed for main's dispatch-output-copied |
killed: dispatch-output-copied gets another refusal reason |
| long-run modes don't write their input into title memory | killed: dispatch-input-snapshot-long reads other words |
The earlier mutant table on e5af9a66 covers the runtime change. The merge doesn't touch it.
Verdict: approve on 4d417f02.
Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088 and WARP 10.0.26100.9818, Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Python 3.12.10; debug layer on for the hardware runs.
CI: Build and test on Windows, Assemble and translate gfx1013 fixtures and Run platform-independent Python checks on Linux pass on 4d417f02.
This reply was AI-assisted.
Part of #870
Fixes #2860
What this unblocks: translated compute dispatches whose input buffers were written by the title (placed buffers that do not alias title memory) and dispatches with an unbound input run instead of being refused, also in a long run.
Change
Runtime only (
d3d12_draw.inl,d3d12_xs_device.cpp,upload_reservation.h), plus a docs paragraph and test modes:X2W_TRANSLATED_TITLE_INPUT_SNAPSHOT=1(opt-in): an input in a placed buffer that does not alias title memory is read from a GPU copy this list made, else from a snapshot of at most 16 MiB copied from title memory at the dispatch.snapshot ring reservation refused: no unused capacity(report), and a pool that is never reused fills up over time. A reservation the pool cannot serve logsx2w-draw snapshot pool reservation refused: no unused capacity.Verification
Linux (executed locally):
git diff --check origin/main...HEAD: cleancmake -S . -B <dir> -DDXC_EXECUTABLE=/bin/true: configure rc 0tests/upload_reservation_check.cpp(newcheck_snapshot_pool: pool numbering, holds and discard in both pools, per-queue completion of a snapshot chunk, reuse of a finished unheld chunk) built with g++ and run: passesx86_64-w64-mingw32-g++ -fsyntax-only -std=c++20ond3d12_xs_device.cpp: no error in the changed code (the MinGW headers stop on MSVC-only constructs thatorigin/mainhas too)Win2025 (Windows Server 2025, Build 26100, MSVC 14.44.35207, D3D12 WARP) at
73b2d0ff73921cce81188d3e11cda6064ac3de87:ctest --preset dev -R '^(startup_compute_dispatch_input_|upload_reservation$)' --no-tests=error --output-on-failure: 3/3 passed (startup_compute_dispatch_input_warp,startup_compute_dispatch_input_hardware,upload_reservation)ctest --preset release -R '^(startup_compute_dispatch_input_|upload_reservation$)' --no-tests=error --output-on-failure: 3/3 passeddev:startup_compute_dispatch_input_warpand_hardwarefail withAssertionError: dispatch-input-snapshot-long: consumer exit 85afterx2w-draw snapshot pool reservation refused: no unused capacity;upload_reservationpasses.Tests:
startup_compute_dispatch_inputkeepsdispatch-input-snapshot(off: refused; on: all 320 words match; zero title memory runs on zeros) anddispatch-input-null, and addsdispatch-input-snapshot-long: 48 frames of dispatches whose 8 MiB title-memory input is snapshotted each frame with the queue completed between frames (384 MiB in all, three times the pool). Every frame must translate and give the first frame's words, the last frame must match the CPU reference on the D3D12 adapter, and no reservation may be refused.Real-hardware testing: @Makto94 - thanks for the help.
Source: Microsoft D3D12 documentation (placed resources, upload heaps, raw buffer SRVs).