d3d12: do not wrap large allocations for unplaced memory SRVs #2611

Manually merged
github merged 1 commit from gh-pr/2611/head into gh-pr/2611/base 2026-11-27 01:07:17 +00:00
Owner

@⁠lukaslw-lab on GitHub · 2026-11-25 23:18 UTC · original
lukaslw-lab:gpu/unplaced-srv-large-allocation → main · +72 −8 · 8 files · 1 commits · merged 2026-11-25 23:42 UTC

Change

Fixes #2610 (startup stall of ~120 s since #2395).

unplaced_memory_buffer (device slot 70, #2395) wraps the whole allocation holding a view with OpenExistingHeapFromAddress. Now it creates that wrap only when the allocation is at most 256 MiB, the limit unplaced_buffer_extent already applies to the span. Larger allocations take the existing upload copy. A heap that is already wrapped for the same base is still reused.

  • memory_srv_buffer.h: unplaced_max_span and unplaced_existing_heap_allowed(allocation_bytes) (0 = unknown → no wrap).
  • placed_buffer_range.h: allocation_bytes(address) gets the allocation size from one region-information call, without a page-table scan.
  • Overlap: draft #2603 replaces this call with an opt-in standin_memory_buffer path. This PR keeps the current design and only bounds it.

Verification

Windows 10 22H2, RTX 3080 Ti (driver 32.0.16.1047), WARP; dev and release; commit 0a40a0fd (on a6967446).

ctest --preset dev     -R '^startup_memory_srv_buffer|^startup_address_buffer_srv_|^startup_address_srv_|^startup_placed_buffer_range|^startup_memory_srv_diag'
ctest --preset release -R (same)

17/17 passed in each, with no capability skips (dev at b45a19e4 on f03cf16f; rerun at 0a40a0fd after the rebase: result to follow in a comment).

  • startup_memory_srv_buffer: limit cases (64 KiB, 256 MiB, 256 MiB + 64 KiB, 2 GiB, unknown size). New negative control startup_memory_srv_buffer_unplaced-heap-limit_control (it accepts 2 GiB) fails as expected.
  • startup_placed_buffer_range case 10: allocation_bytes on 64 KiB and 256 MiB + 64 KiB reservations with only their first page committed, queried at the base and at the last byte.
  • startup_address_buffer_srv_{warp,hardware} column 7: a view in a 256 MiB + 64 KiB allocation still publishes the right value, now through the upload copy.
  • Limitation: column 7 cannot tell the heap path from the upload copy, because both show the value at the slot 70 call. A variant that wrote again after the call also passed with the limit removed, so I dropped it. The path choice was checked once with a temporary log in unplaced_memory_buffer (not in this PR). Without the limit, both the 64 KiB and the large allocation are wrapped (WARP and hardware). With it, 64 KiB is wrapped and the large one takes the upload copy.
  • Startup run (release, warm cache, same input script as in the issue): at 0a40a0fd, 3,254 DirectStorage requests completed at 10 s and first input poll at 5.8 s (with #2395 alone: 0 at 30 s, first poll ~122 s); no device removal in 180 s.

Evidence and follow-up

  • Fixtures are source-built (VirtualAlloc in the test); no title data.
  • Cost: an unplaced view in an allocation above 256 MiB now gets the upload copy, which is refreshed on each slot 70 call, instead of a zero-copy alias. In this title that affects the two small views in the ~2.15 GiB block. Why the wrap slows later VirtualQuery calls over that allocation is not proven (see the issue).

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed. (none changed)
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted: the change, tests and this description were written with Claude; I ran the bisect and the startup runs.

🤖 Generated with Claude Code

**@⁠lukaslw-lab** on GitHub · 2026-11-25 23:18 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2611) `lukaslw-lab:gpu/unplaced-srv-large-allocation` → `main` · +72 −8 · 8 files · 1 commits · merged 2026-11-25 23:42 UTC ## Change Fixes #2610 (startup stall of ~120 s since #2395). `unplaced_memory_buffer` (device slot 70, #2395) wraps the whole allocation holding a view with `OpenExistingHeapFromAddress`. Now it creates that wrap only when the allocation is at most 256 MiB, the limit `unplaced_buffer_extent` already applies to the span. Larger allocations take the existing upload copy. A heap that is already wrapped for the same base is still reused. - `memory_srv_buffer.h`: `unplaced_max_span` and `unplaced_existing_heap_allowed(allocation_bytes)` (0 = unknown → no wrap). - `placed_buffer_range.h`: `allocation_bytes(address)` gets the allocation size from one region-information call, without a page-table scan. - Overlap: draft #2603 replaces this call with an opt-in `standin_memory_buffer` path. This PR keeps the current design and only bounds it. ## Verification Windows 10 22H2, RTX 3080 Ti (driver 32.0.16.1047), WARP; dev and release; commit `0a40a0fd` (on `a6967446`). ``` ctest --preset dev -R '^startup_memory_srv_buffer|^startup_address_buffer_srv_|^startup_address_srv_|^startup_placed_buffer_range|^startup_memory_srv_diag' ctest --preset release -R (same) ``` 17/17 passed in each, with no capability skips (dev at `b45a19e4` on `f03cf16f`; rerun at `0a40a0fd` after the rebase: result to follow in a comment). - `startup_memory_srv_buffer`: limit cases (64 KiB, 256 MiB, 256 MiB + 64 KiB, 2 GiB, unknown size). New negative control `startup_memory_srv_buffer_unplaced-heap-limit_control` (it accepts 2 GiB) fails as expected. - `startup_placed_buffer_range` case 10: `allocation_bytes` on 64 KiB and 256 MiB + 64 KiB reservations with only their first page committed, queried at the base and at the last byte. - `startup_address_buffer_srv_{warp,hardware}` column 7: a view in a 256 MiB + 64 KiB allocation still publishes the right value, now through the upload copy. - Limitation: column 7 cannot tell the heap path from the upload copy, because both show the value at the slot 70 call. A variant that wrote again after the call also passed with the limit removed, so I dropped it. The path choice was checked once with a temporary log in `unplaced_memory_buffer` (not in this PR). Without the limit, both the 64 KiB and the large allocation are wrapped (WARP and hardware). With it, 64 KiB is wrapped and the large one takes the upload copy. - Startup run (release, warm cache, same input script as in the issue): at `0a40a0fd`, 3,254 DirectStorage requests completed at 10 s and first input poll at 5.8 s (with #2395 alone: 0 at 30 s, first poll ~122 s); no device removal in 180 s. ## Evidence and follow-up - Fixtures are source-built (`VirtualAlloc` in the test); no title data. - Cost: an unplaced view in an allocation above 256 MiB now gets the upload copy, which is refreshed on each slot 70 call, instead of a zero-copy alias. In this title that affects the two small views in the ~2.15 GiB block. Why the wrap slows later `VirtualQuery` calls over that allocation is not proven (see the issue). ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. (none changed) - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted: the change, tests and this description were written with Claude; I ran the bisect and the startup runs. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
An unplaced buffer memory SRV (device slot 70, #2395) wrapped the whole
allocation holding the view with OpenExistingHeapFromAddress. A 6 KiB view
in a ~2.15 GiB title startup block wrapped the block; afterwards each
VirtualQuery over it took seconds and DirectStorage requests stalled for
~120 s. Wrap only allocations up to the existing 256 MiB span limit (size
from one region-information call); larger ones take the upload copy.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 01:07:15 +00:00
github manually merged commit 0a40a0fd7e into gh-pr/2611/base 2026-11-27 01:07:17 +00:00
Author
Owner

@⁠lukaslw-lab on GitHub · 2026-11-25 23:19 UTC · original

Rerun after the rebase, at 0a40a0fd (on a6967446), same selection (^startup_memory_srv_buffer|^startup_address_buffer_srv_|^startup_address_srv_|^startup_placed_buffer_range|^startup_memory_srv_diag): dev 17/17 passed, release 17/17 passed, no capability skips.

**@⁠lukaslw-lab** on GitHub · 2026-11-25 23:19 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2611#issuecomment-7177410305) Rerun after the rebase, at `0a40a0fd` (on `a6967446`), same selection (`^startup_memory_srv_buffer|^startup_address_buffer_srv_|^startup_address_srv_|^startup_placed_buffer_range|^startup_memory_srv_diag`): dev 17/17 passed, release 17/17 passed, no capability skips.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-25 23:21 UTC · original · reviewed

Review of head 0a40a0fd (comment only, no approval).

Code looks sound:

  • unplaced_existing_heap_allowed (memory_srv_buffer.h): 0 (unknown) and anything above 256 MiB fall back to the upload copy; an already wrapped heap is still reused (the existing_heaps lookup runs before the new check in d3d12_memory_srv.inl).
  • allocation_bytes (placed_buffer_range.h): one region-information call, returns 0 on a missing or failed call, so it fails closed.
  • unplaced_max_span is now shared with unplaced_buffer_extent, so the two limits cannot drift apart.
  • Test: startup_memory_srv_buffer covers 64 KiB, 256 MiB, 256 MiB + 64 KiB, 2 GiB and unknown size. The unplaced-heap-limit mutation flips only the 2 GiB case, so it is a real negative control. I read it; I did not build it (Windows-only tests).
  • Sibling checks (startup_address_buffer_srv_check.py, startup_address_srv.cpp, startup_placed_buffer_range_check.cpp) are extended consistently.
  • No other open or merged PR covers the same slice except draft #2603, which the body already names as overlapping; the choice between the two is for @⁠R0Y00.

Not verified by me, and why it is not merged by this review:

  • The PR fixes a ~120 s startup stall seen while running the title (#2610). We do not run the title, so that claim needs verification by MasterDomino or @⁠R0Y00 on the game.
  • CI was still pending and there is no Win2025 receipt on this head yet at the time of review.

Linux commands run: git diff --stat origin/main...HEAD, git diff --check origin/main...HEAD (clean), python3 tests/docs_links_check.py (19 files, 506 links ok), python3 tests/bidi_controls_check.py (ok).

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-25 23:21 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2611#pullrequestreview-6066341865) · **reviewed** Review of head `0a40a0fd` (comment only, no approval). Code looks sound: - `unplaced_existing_heap_allowed` (`memory_srv_buffer.h`): 0 (unknown) and anything above 256 MiB fall back to the upload copy; an already wrapped heap is still reused (the `existing_heaps` lookup runs before the new check in `d3d12_memory_srv.inl`). - `allocation_bytes` (`placed_buffer_range.h`): one region-information call, returns 0 on a missing or failed call, so it fails closed. - `unplaced_max_span` is now shared with `unplaced_buffer_extent`, so the two limits cannot drift apart. - Test: `startup_memory_srv_buffer` covers 64 KiB, 256 MiB, 256 MiB + 64 KiB, 2 GiB and unknown size. The `unplaced-heap-limit` mutation flips only the 2 GiB case, so it is a real negative control. I read it; I did not build it (Windows-only tests). - Sibling checks (`startup_address_buffer_srv_check.py`, `startup_address_srv.cpp`, `startup_placed_buffer_range_check.cpp`) are extended consistently. - No other open or merged PR covers the same slice except draft #2603, which the body already names as overlapping; the choice between the two is for @⁠R0Y00. Not verified by me, and why it is not merged by this review: - The PR fixes a ~120 s startup stall seen while running the title (#2610). We do not run the title, so that claim needs verification by MasterDomino or @⁠R0Y00 on the game. - CI was still pending and there is no Win2025 receipt on this head yet at the time of review. Linux commands run: `git diff --stat origin/main...HEAD`, `git diff --check origin/main...HEAD` (clean), `python3 tests/docs_links_check.py` (19 files, 506 links ok), `python3 tests/bidi_controls_check.py` (ok). AI-assisted; commands listed were executed locally.
This discussion has been locked. Commenting is limited to contributors.
No description provided.