startup: forward occlusion queries on command-list slots 28 to 30 #2139
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2147"
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 NiiRoZz on 2026-11-25T01:39:41Z.
Change
Command-list slots 28, 29 and 30 are no-ops in the
d3d12_xsstand-in. This adds a diagnostic opt-in,X2W_D3D12_QUERY_SLOTS=1(render mode), that binds them asBeginQuery(heap, type, index),EndQuery(heap, type, index)andResolveQueryData(heap, type, start, count, buffer, offset)on the desktop list.Without the switch the three slots stay no-ops, exactly as before. Refs #870.
Which console methods sit at slots 28 to 30 is not established by any fixture here, so the bindings stay opt-in
until independent ABI evidence is available. The repository shows only that four console methods sit in 26 to 31
(32 is
SetDescriptorHeaps, desktop 28 plus four) and that the plus-four run has ended by 61 (ExecuteIndirect,desktop 59 plus two). The fixture calls those slots directly, so it checks the forwarding, the refusals and the end
at Close, not the numbering. The local observation below supports the numbering but cannot be reproduced from this
PR.
With the opt-in:
CreateQueryHeap) keeps forwarding the desc unchanged, and the desc is now kept on the heapwrapper (with or without the switch).
EndQueryof the same type on thecurrent recording. A new
BeginQueryon an index clears its completion, and Close clears all of them.x2w-render ... refused, the first 16 of each method):BeginQueryon an open index;EndQuerywithout itsBeginQueryon the same list;or still open;
the buffer's end.
COPY_DESTand is not moved through the list's COMMON state tracking.Scope:
Mapreturns that memory and adesktop resolve never reaches it. Only committed readback buffers work.
Known limit of this first slice: a resolve recorded on a later list than the
EndQuerycalls it covers isrefused. Whether a caller resolves on the same recording as its
EndQuerycalls has not been observed. The localobservation below was taken before this rule and counted calls only, not which recording they were on. If a caller
resolves on a later list, every resolve is refused and its buffer is left as the default leaves it.
Overlap: open PR #2048 places
SetPredicationat slot 59 "inside the shifted run", while this branch's hypothesiswould put the run's end before that.
command_list_slot_names.hstill names 56 to 58 as the query methods(unchanged here; only its comment now says the plus-four rule is unchecked past 52).
Verification
Commit
859e3e8d(on05f3e6cc, main8e8b0621). Windows 11 Pro 10.0.26300, MSVC x64,devpreset, D3D12 debuglayer enabled. Run on a separate, never-shown desktop.
5 of 5 passed (
startup_list_queries_{warp,hardware},startup_list_queries_default_{warp,hardware}_control,startup_command_list_slot_names); no skips.startup_list_queries_{warp,hardware}setX2W_D3D12_QUERY_SLOTS=1. Results:0xa5: never begun (query 3), a range witha hole (5 to 7, 6 never begun), the wrong type (query 4 ended as binary occlusion, resolved as occlusion), a
range over a still-open query, past the heap's count, and past the buffer's end;
startup_list_queries_default_{warp,hardware}_controlrun without the switch: the stand-in logs the three slotsas no-ops, and the probe reports
word 0: got 0xa5a5a5a5a5a5a5a5, which the test requires. This shows thedefault keeps the previous slot behaviour.
word 2: got 0x0000000000000000on WARP and hardware;EndQuerywithout itsBeginQuery: exit 3, the desktop Close fails;Evidence and follow-up
tests/startup_list_queries.cppis source-built:0xa5.It mixes console slots (device 8, 9, 27, 36, 39, 73; list 9, 28-30, 139; queue 10, 14; fence 8; resource 8) with
desktop calls for the draw.
Local observation, not reproducible from this PR: one local startup run of a console executable with the stand-ins,
with the earlier revision of this change (before the completion rule) plus a local counter that is not part of the
PR. Totals over about 5 minutes:
That is the call shape the hypothesis predicts. The resolved results were all zero, because no translated draw ran
in that run, so the values say nothing either way.
Not verified:
Follow-up: settle the numbering of 26 to 31 and of the shifted run past 52 (this branch, #2048 and #1972 depend on
it). If resolves turn out to arrive on a later recording, track completion per submitted recording.
Checklist
AI-assisted; the commands listed were run locally.
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T01:46:51Z.
Review: CHANGES_REQUESTED
list_resolve_queryexcludes indices still inopen_queries, so a never-begun index or one ended with the other occlusion type can reachResolveQueryData. An uninitialized resolve can remove the device. Please require an observed matching End for every index and type in the range. The first slice can limit this to Begin/End on the current DIRECT recording, clear the tracked completion on re-Begin/Reset, and refuse unsupported command-list types. Keep both successful result readbacks. Add untouched-sentinel controls for never begun, a range with a hole, and the wrong type. Microsoft ResolveQueryData contractThe test chooses slots 28–30 by construction. Since the console ABI is still a hypothesis explicitly called out in the PR, keep these bindings behind an explicit diagnostic opt-in until independent ABI evidence is available. The source-built readback can exercise that opt-in and demonstrate the default preserves the previous slot behavior.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T02:09:41Z.
Review: APPROVED
Rechecked
859e3e8d. Resolution now requires an ended query of the same type for every index on the current DIRECT recording. The candidate keeps the uncertain slots opt-in. Local Windows Release passed the WARP and RTX 4060 Laptop query cases and the two default-off controls (4/4, no skips). The source-built slot tests establish forwarding and refusal behavior.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:10:14Z.
Review: COMMENTED
Review of head
859e3e8d8f4d50a55649f887eb78dc36da54fa25(comment only, no approval).Result: no P1, no P2. Two nits.
What I checked
CMakeLists.txt,docs/startup-runtime.md,command_list_slot_names.h,d3d12_xs_device.cpp,tests/startup_list_queries.cpp).X2W_D3D12_QUERY_SLOTS=1(d3d12_xs_device.cpp:3933). The default path is unchanged, and a negative-control CTest (startup_list_queries_default_*_control) pins that.occlusion_heap(2010-2023) checks DIRECT list, heap kind, heap type, query type and range (count > Count - indexhas no overflow).BeginQueryrefuses a double begin and clears the ended entry for that index.EndQueryrequires a matching open query of the same type.end_open_queriesruns beforerelease_targetsinlist_close, so a dangling Begin cannot fail the desktop Close.release_targetsresetsPass{}, soended_queriesdoes not outlive a recording.ResolveQueryDatarequires every index in range to be ended with the same type. It also checks for a readback buffer, 8-byte offset alignment, bounds and no title memory.Commands executed locally (Linux worktree at the head SHA)
python3 tests/docs_links_check.py-> self-test passed, 18 files, 399 links OKpython3 tests/bidi_controls_check.py-> self-test passed, 1440 files, no bidi controlsgit diff --check origin/main...HEAD-> cleangh pr checks 2147-> all required jobs passNot run
startup_list_queriesneeds D3D12 (Windows only), so I did not run it or a source mutation on Linux. I read the test cases: they cover refused type, an End without a Begin, a Begin without an End (ended at Close), a resolve of a never-ended index, and an out-of-range offset. I relied on the green Windows CI job for execution. I did not request a separate Win2025 run.Nits (non-blocking)
d3d12_xs_device.cpp:2071: aResolveQueryDatawithcount == 0passes the end-check loop (empty range) and is forwarded as a zero-length resolve. Consider refusing it, or add a test that pins the intended behavior.docs/startup-runtime.mdwording is consistent with this.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by NiiRoZz on 2026-11-25T02:02:24Z.
Thanks. New commit
859e3e8d(on top of05f3e6cc, no force-push): a resolve is forwarded only if every index in its range has an observed EndQuery of the same type on the current DIRECT recording. Re-Begin clears an index's completion, Close clears all of them, and other list types are refused.The 28–30 bindings are now behind the diagnostic opt-in
X2W_D3D12_QUERY_SLOTS=1. Unset, the slots stay no-ops as on main, andstartup_list_queries_default_{warp,hardware}_controlchecks that (untouched sentinel, pinned by PASS_REGULAR_EXPRESSION).The fixture keeps both readbacks (64 and 0) and adds untouched-sentinel cases for never begun, a range with a hole, and the wrong type. 5/5 pass on WARP and an RTX 5090 with the debug layer on.
Known limit, stated in the docs: a resolve recorded on a later list than its EndQuery calls is refused. Whether callers resolve on the same recording is not yet observed.
AI-assisted (Claude Code).