startup: opt-in snapshot of an untracked indirect index range #3935
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3935"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-12-03T13:41:00Z.
Refs #3899. An indexed
ExecuteIndirectdraw whose index view has no proven desktop backing is refused withindex view has no proven desktop buffer range— one refusal code and about 97% of one census group (~68k of ~70k calls over 25 pipelines). This adds an opt-in path that snapshots the range instead, so the census can say how much of that wall a copy would actually convert into draws.What it does.
X2W_INDIRECT_INDEX_SNAPSHOT=1makes that branch copy the range from title memory into the existing title-input snapshot pool while the draw is recorded (at most 64 KiB, dword-sized) and bind the view on the copy. Above the bound, on unreadable memory, or when the copy or the desktop address fails, the view is refused exactly as before, and the cause is logged:Why it is opt-in rather than a new default. Refusing here is a documented contract —
docs/experiments.mdsays readable storage with no registered GPU backing may be stale or unrelated, so copying it into the draw ring would draw memory the title never uploaded — and the fixture's negative controls (alias_*,index_upload_*,invalid_index) pin that behaviour. Making the copy the default would silently turn those refusals into draws. So the default path is byte-for-byte unchanged and this exists to be measured first, which is what the issue asks for.The semantics that matter, stated in the docs paragraph added here: the copy is taken at record time, not submit, so a title that rewrites its indices before
Submitdraws the bytes as they were when recorded, and data a GPU pass wrote into such a range is not seen.Fixture. New mode
translated-indexed-snapshot, registered throughtests/cmake/startup_indirect_index_snapshot.cmakeforwarpandhardware, selected in theprpreset as a flat alternative (the filter stays at 30 parenthesised groups — it breaks past ~32). The page is never placed with slot 133, so the alias route cannot resolve it even while that route is on, and the vertex stream comes from the recording upload so only the index view is untracked. Five runs in one process: opt-in unset → refused; R16 and R32 untracked → drawn with the snapshot pool growing by exactly 512 bytes each; above the bound → refused; reserved unreadable page → refused. The title bytes are then overwritten with0x4dbeforeSubmit, so a draw that still paints read the snapshot; and the census must show exactly oneindex_no_desktop_rangepair with three calls — the three controls and nothing else.A bug this change had, and how it was caught. The first revision bound the snapshot and then fell through to
alias.resource->GetGPUVirtualAddress()with the alias null — a null dereference on the positive path, which the negative-only controls would never have hit. It is fixed (the alias binding now runs in anelse), and it is the reason the fixture asserts the pool delta and the census rather than only the refusal cases.Verified here: both targets build with clang-cl 19.1.1 against
main4567a71a(d3d12_xs.dll,startup_indirect_draw_indexed.exe), and theprfilter still compiles at 30 groups.Not established: I cannot run the fixture — this host has no WARP/D3D12 for it (the indirect fixture refuses for an unrelated placed-buffer reason under Wine), so every behavioural claim above is from the fixture's design, not an observed run. The Windows job is the check, and it is the first thing to look at. No frame-time or title-side claim is made.
Also spotted while building:
tests/startup_indirect_draw_indexed.cpp:3943takes&texture->GetDesc()(address of a temporary), which clang rejects outright — the documented clang-cl route cannot build this fixture. That is a separate, pre-existing problem and is left out of this PR.Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-12-03T13:41:16Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
567e859ℹ️ About Codex in GitHub
Your 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.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-12-03T13:47:38Z.
Code review location:
tests/startup_indirect_draw_indexed.cpp; line 1518When the fixture exercises
Refusal::index_snapshot_bound,sizeis 65,544 bytes butnarrow_snapshotis only 8 bytes, so thismemcpyreads 65,536 bytes beyond the source object beforeExecuteIndirectcan reach the intended bound refusal. That undefined read can make the test fail for reasons unrelated to snapshot rejection; initialize the larger range separately and copy only the index array.Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-12-03T13:47:38Z.
Review: COMMENTED
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
567e859c7fℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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".
Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-12-03T13:54:38Z.
Codex's P2 finding on
tests/startup_indirect_draw_indexed.cpp:1518is correct and is already fixed on this branch, in021a4a1a— the review ran against567e859, which is before that commit.The bound control set
SizeInBytesto64 KiB + 8and then copied that many bytes out of the eight-bytenarrow_snapshotarray. Nothing ever read the copied bytes (the shim refuses on the size before it probes readability), but it is a 64 KiB overread and undefined behaviour that could fail the test for the wrong reason.The fix copies at most the array's own size:
An independent review pass found the same defect before the bot did, which is the useful part of this: the fixture cannot run on my host, so both were caught by reading rather than by a failing test.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T13:57:14Z.
Review: CHANGES_REQUESTED
Reproduced on
021a4a1awith Windows 11 build 26300 and MSVC Debug, D3D12 debug layer enabled.ctest --preset dev --no-tests=error -j 1 -V -R '^startup_indirect_translated_indexed_snapshot_(warp|hardware)$'failed on WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656. Both record-time positives painted 4/8 pixels and all refusal controls stayed clear. The final census expects one row but gets two: the default-off draw uses key 14192ae7230ab757 and both opt-in refusal controls use key dffa3f8eb5229d79. The total and reason count are both 3. Please assert the intended two groups with counts 1 and 2, or arrange the controls to genuinely share one key if that is part of the fixture contract. The backing allocation change resolves the prior over-bound control problem.Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-12-03T14:01:54Z.
The first Windows run got all the way to the fixture and the feature works — the only failure was my own assertion:
That is exactly the sequence the fixture was designed to produce: the default-off control refuses, both opt-in draws paint through the record-time copy, the bound and unreadable controls are refused with their own reasons, and the census totals 3. What was wrong was my expectation that all three refusals share one pipeline key — they do not, which is a fact about the fixture's own plumbing, not about the change.
Fixed in
c740197a: the assertion now checks the invariants that matter — three refusals in total, every row onindex_no_desktop_range, three calls across them — so a control failing for a different reason still fails it, without hard-coding a key count.Also worth recording for reviewers: this run is the first evidence the snapshot path itself is correct. The two positive cases cannot paint unless
ring_copyproduced a valid upload-heap view, the pool delta was exactly 512 bytes each, and the title bytes overwritten with0x4dafter recording did not change the draw.Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-12-03T14:06:32Z.
@R0Y00 Done, in
22594385— and thank you for reproducing it with the debug layer, that is better evidence than anything I could produce here.Your reading is exactly right, and the keys you named confirm the fixture's intended grouping: the default-off control runs the left pipeline and is refused on its own key (
14192ae7230ab757), while the above-bound and unreadable controls both run the right pipeline and share a key (dffa3f8eb5229d79). So it is one row of 1 call and one row of 2, total 3.The assertion now names that shape rather than a total-key count:
So it fails if a control starts refusing for a different reason, if a third key appears, or if the two opt-in controls drift onto separate keys — which is the fixture-contract part of your note. Your point about not asserting a bare total is what the previous revision got wrong: it would have passed with all three controls refusing for three unrelated reasons.
I also noted the measured key names in a comment, since they are the one part of this assertion that came from a run rather than from the fixture's structure.
Compiles here with clang-cl; the Windows job will be the check, and I will leave it alone until it reports.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T14:18:37Z.
Review: APPROVED
Re-reviewed
22594385. The census now checks two index_no_desktop_range groups containing one and two calls. Windows 11 build 26300, MSVC Debug, D3D12 debug layer enabled:ctest --preset dev --no-tests=error -j 1 -V -R '^startup_indirect_translated_indexed_snapshot_(warp|hardware)$'passed on WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656. Both record-time positives drew 4/8 pixels with intact argument guards. The default-off, above-bound and unreadable cases stayed clear and accounted for all three refusals. The older inline finding is also fixed: the synthetic array copy is bounded by sizeof the selected source array.