Repository navigation
startup: forward occlusion queries on command-list slots 28 to 30 - #2147
Conversation
Command-list slots 28, 29 and 30 were no-ops in the d3d12_xs stand-in. As a
hypothesis they are now implemented as BeginQuery(heap, type, index),
EndQuery(heap, type, index) and ResolveQueryData(heap, type, start, count,
buffer, offset) on the desktop list. Which console methods sit at those
slots is not established by any fixture here: 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 the slots directly, so it checks the
forwarding, the refusals and the end at Close, not the numbering.
Device slot 39 (CreateQueryHeap) keeps the desktop desc on the heap wrapper.
Only occlusion and binary-occlusion queries on an occlusion heap are
forwarded. Refused and logged (the first 16 of each method): a call outside
the heap's count, an EndQuery without its BeginQuery on the same list, and a
resolve over a query still open on the list, to anything but a committed
readback buffer without title memory, or past its end. A query still open at
Close is ended there, because the desktop Close would otherwise fail and
drop the whole list. The readback buffer stays in COPY_DEST and is not moved
through the list's COMMON state tracking.
startup_list_queries_{warp,hardware} resolves a query around a draw over an
8x8 target and an empty one into a sentinel-filled readback buffer, reads it
through the console Map (64 and 0, sentinel elsewhere), checks that six
mismatched calls reach no desktop validation, and leaves one query open at
Close. The startup_list_queries_ignored_*_control cases set
X2W_TEST_QUERY_IGNORE=1, which leaves the slots as no-ops, and must report
the untouched sentinel in the first word.
The comment in command_list_slot_names.h now says that the plus-four names
past slot 52 are unchecked; the 56 to 58 names are unchanged.
Refs R0Y00#870
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
R0Y00
left a comment
There was a problem hiding this comment.
list_resolve_query excludes indices still in open_queries, so a never-begun index or one ended with the other occlusion type can reach ResolveQueryData. 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 contract
The 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.
…opt-in
Review follow-up. A resolve that covered a never-begun index, or one ended
with the other occlusion type, could reach ResolveQueryData and read
uninitialized query data.
- A resolve is forwarded only if every index in its range has an observed
EndQuery of the same type on the current recording. A new BeginQuery on
the index clears its completion; Close clears all of them with the rest of
the recording state.
- The query slots refuse every command-list type other than DIRECT.
- Which console methods sit at slots 28 to 30 is still a hypothesis, so the
bindings are now a diagnostic opt-in, X2W_D3D12_QUERY_SLOTS=1 (render
mode). Unset, the three slots stay no-ops as before. The test-only
X2W_TEST_QUERY_IGNORE is removed.
- startup_list_queries sets the opt-in and keeps both successful readbacks.
New untouched-sentinel cases cover a never-begun index, a range with a
hole and the wrong type. The control is now
startup_list_queries_default_{warp,hardware}_control: it runs without the
switch and must report the untouched sentinel in the first word.
- Known limit: a resolve recorded on a later list than the EndQuery calls it
covers is refused.
Refs R0Y00#870
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Thanks. New commit 859e3e8 (on top of 05f3e6c, 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 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). |
R0Y00
left a comment
There was a problem hiding this comment.
Rechecked 859e3e8. 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.
tedin7
left a comment
There was a problem hiding this comment.
Review of head 859e3e8d8f4d50a55649f887eb78dc36da54fa25 (comment only, no approval).
Result: no P1, no P2. Two nits.
What I checked
- Diff: 5 files, +489/-6 (
CMakeLists.txt,docs/startup-runtime.md,command_list_slot_names.h,d3d12_xs_device.cpp,tests/startup_list_queries.cpp). - Opt-in only: slots 28 to 30 are bound only with
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. - D3D12 semantics, read against the code:
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.
- Title is neutral. The PR is mergeable. CI is green: Windows build and test, Python checks on Linux, gfx1013 fixtures.
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 pass
Not 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.- The slot numbering 28/29/30 is stated as a hypothesis, and the PR says so clearly. Keep the opt-in until ABI evidence exists. The
docs/startup-runtime.mdwording is consistent with this.
AI-assisted; commands listed were executed locally.
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 859e3e8 (on 05f3e6c, main 8e8b062). 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