Skip to content

startup: match descriptor shadow slots on a descriptor boundary - #3563

Merged
R0Y00 merged 2 commits into
R0Y00:mainfrom
Jess-Doit:startup/shadow-slot-tagged-handles
Nov 30, 2026
Merged

R0Y00 merged 2 commits into
R0Y00:mainfrom
Jess-Doit:startup/shadow-slot-tagged-handles

Conversation

@Jess-Doit

@Jess-Doit Jess-Doit commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Refs #2468. Refs #3558.

Change

shadow_slot in src/startup_stubs/d3d12_capture.inl found a descriptor's tracking slot by checking whether the desktop CPU handle lay inside a heap's span. Desktop CPU handles need not be addresses. On a GTX 1060, CPU-only view heaps get small tagged handles whose spans interleave, for example three two-descriptor heaps at 0x3, 0x4 and 0x5 with a 0x20 increment. A handle in one heap therefore fell inside an earlier heap's span and was tracked in the wrong slot.

The lookup now prefers the heap where the handle sits on a descriptor boundary, and searches the heaps newest first. A released heap keeps its entry, so when a new heap is handed the same tag or address, the new heap is the one the handle names. Handles that are real addresses (WARP and the other adapters measured so far) resolve as before, apart from that reuse case.

The choice lives in src/startup_stubs/descriptor_heap_match.h so it can be tested without a device. The handle alone cannot settle two cases: several heaps with the handle on a boundary (starts that differ by a multiple of the increment), or no heap with it on a boundary. The header documents both, and two counters report them in the periodic x2w-d3d12 log, printed only when nonzero.

Verification

Windows 10 19045, NVIDIA GTX 1060 6GB driver 32.0.15.6094, in-box WARP 10.0.19041. Dev build of this branch (b359ac71) on main 44a3ad5a.

Check Before After
Budget and retire families, GTX 1060 and WARP 31 passed, 7 failed 34 passed, 4 failed
startup_descriptor_heap_match and its two controls — 3 passed (both controls fail as required)
ctest --preset pr — 72 passed, 0 failed, 14 capability skips

startup_descriptor_heap_match checks the three interleaved heaps from the GTX 1060, a fourth heap at 0x23 that shares a boundary, address handles, and a reused tag and address. The first-contains control is the lookup on main and fails 8 cases; the oldest-first control fails the 4 shared-boundary and reuse cases.

Now passing on the GTX 1060:

All three already passed on WARP and still do.

The four remaining failures are the startup_resource_retire_views_*_hardware crashes. They are a separate problem: a descriptor copy from a shader-visible heap, tracked in #3558.

$env:XBOX2WINDOWS_ADAPTER = '1060'
ctest --preset dev --no-tests=error -j 1 -R '^startup_resource_(budget|retire)'
ctest --preset dev --no-tests=error -R '^startup_descriptor_heap_match'
ctest --preset pr --no-tests=error -j 2

🤖 Generated with Claude Code

Desktop CPU descriptor handles need not be addresses. On an NVIDIA GTX
1060, CPU-only view heaps get small tagged handles whose spans interleave
(0x3, 0x4, 0x5 with a 0x20 increment), so a handle inside one heap's span
could select another heap's shadow slot. Prefer the heap the handle sits
on a descriptor boundary of, and keep the previous containing-heap match
as the fallback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@lukaslw-lab lukaslw-lab left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed ac6d858d by reading the diff; not built or run.

Verdict: approve. On adapters whose CPU handles are real addresses, the lookup gives the same result as before. On interleaved tagged handles it picks the right heap whenever only one heap has the handle on a descriptor boundary. No MUST.

  • Unchanged for address handles (d3d12_capture.inl:258-269). Real heap spans don't overlap, so at most one heap contains a handle. That heap is returned whether or not the handle is on a boundary, with the same floor index and room as before.- SHOULD: the boundary test still has blind spots, and they are silent. Two heaps whose start handles differ by a multiple of the increment (0x3 and 0x23 with 0x20) both match on a boundary, and whichever registered first wins. Released heaps also never leave heap_infos(): retire_drop_heap_views (d3d12_xs_device.cpp:6344) only clears their shadow. So if the driver reuses a tag, the stale entry comes first and takes the new heap's descriptors. The stale-entry problem predates this PR, but tagged handles make reuse of small values likelier. With tagged handles the fallback to the first containing heap is also wrong by construction. A counter for multi-heap matches and fallbacks would show whether either happens in a run, and the comment could name the limit.
  • SHOULD: no test on CI reaches the new branch. WARP hands out address handles, so no CI case has overlapping spans. The fixed cases (startup_resource_retire_reasons_hardware, ..._title_hardware_debug0/1) need the GTX 1060. A small check of the lookup with the body's three heaps (0x3/0x4/0x5, increment 0x20, two descriptors each) would pin the boundary preference, and a fourth heap at 0x23 would pin the limit above.

CI: Windows passed. The red Linux job is tests/startup_triage_run_check.py, which fails on main 44a3ad5a too (the output UAV element-limit reason #3546 adds). It is not caused by this PR.

Moves the shadow_slot heap choice into descriptor_heap_match.h so it can be
checked without a device. Heaps are now searched newest first: a released heap
keeps its entry, so a new heap handed the same tag or address is the one the
handle names. Two counters report the cases the handle cannot settle (several
heaps on a boundary, or none), logged only when nonzero.

startup_descriptor_heap_match covers the interleaved 0x3/0x4/0x5 heaps, a fourth
heap at 0x23, address handles and reused handles. The first-contains control
(the lookup before this branch) and the oldest-first control must fail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Jess-Doit

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Both SHOULDs are addressed in b359ac71:

  • Stale heaps and shared boundaries. The lookup now searches the heaps newest first, so a heap handed a released heap's tag or address wins over the stale entry. That reuse case could already happen with address handles on main. The two cases the handle cannot settle (several heaps on a boundary, or none) are documented in the new src/startup_stubs/descriptor_heap_match.h. Each has a counter in the periodic x2w-d3d12 log, printed only when nonzero.
  • A test CI can reach. The heap choice moved into that header. startup_descriptor_heap_match checks it without a device, covering the 0x3/0x4/0x5 heaps, a fourth heap at 0x23, address handles, and a reused tag and address. Two controls must fail: first-contains is the lookup on main and fails 8 cases, and oldest-first fails the 4 shared-boundary and reuse cases.

Rerun on the same host (GTX 1060, driver 32.0.15.6094, Windows 10 19045):

Ready for more review

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent re-review of b359ac71. The revised lookup prefers a boundary match and then the newest registration, and reports ambiguous boundaries and off-boundary fallbacks. ctest --preset release --no-tests=error -R '^startup_descriptor_heap_match' passed 3/3, including both expected-failure controls for first-contains and oldest-first. These are source-built span tests, with no GPU dependency. The earlier review's two follow-ups are addressed.

@R0Y00
R0Y00 merged commit 29b27fd into R0Y00:main Nov 30, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants