[removed by author] #327

Manually merged
github merged 6 commits from gh-pr/327/head into gh-pr/327/base 2026-11-26 21:43:16 +00:00
Owner

@⁠thegl0w on GitHub · 2026-11-21 22:17 UTC · original
gpu-alias/device-attach → main · +833 −6 · 11 files · 6 commits · merged 2026-11-22 04:51 UTC

[removed by author]

**@⁠thegl0w** on GitHub · 2026-11-21 22:17 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/327) `gpu-alias/device-attach` → `main` · +833 −6 · 11 files · 6 commits · merged 2026-11-22 04:51 UTC [removed by author]
On the console a graphics allocation is GPU-visible at its CPU address
as soon as it exists. era_title_gpu is a process-wide registry that the
desktop xmem.dll now routes its graphics memory types through:
- track and untrack register the region with era_query, as before;
- once a D3D12 device is attached, every tracked allocation is opened
  as an era_gpu_alias heap and mapped in an era_title_va::Table, and
  later allocations are aliased when they are tracked;
- translate, locate (buffer and offset) and shader_view (packed ranges
  with buffers in slot order for TitleLookup) serve a D3D12 layer.
An allocation that cannot be aliased stays tracked without a
translation, and attach reports the first such failure after trying
every allocation. detach drops the aliases and keeps tracking.

xmem.dll keeps its four exports and imports and does not load D3D12;
xmem_shim_exports now checks that. How a separate D3D12 layer reaches
the registry across the DLL boundary is left to the lead's export
decision.

gpu_alias_registry_{warp,hardware} track allocations before and after
attach, including unaliasable interior blocks, and drive TitleLookup on
the GPU from the registry's shader view: 15 addresses, 12 hits, matching
CPU reads. untrack, detach and re-attach are checked against the same
translations.

era_gpu_alias.h now guards WIN32_LEAN_AND_MEAN and NOMINMAX, since
xmem_shim.cpp defines them too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The registry check needs a free 64 KB block below its first graphics allocation, so attach
meets the unaliasable block before an allocation it must still alias. The fixed search tried
only the 4095 blocks (256 MB) directly below and failed in about 1 of 40 runs on an RTX 3070,
when that whole span was already taken. commit_below walks down region by region instead and
skips each allocation through its AllocationBase.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
era_title_gpu created its state with a throwing new behind noexcept entry points, so a failed
first allocation while xmem.dll serviced XMemAlloc ended the process. The state is now created
by the first track or attach through a retryable, non-throwing step: track returns false and
attach E_OUTOFMEMORY, with nothing registered. The other entry points never create it and behave
as for an empty registry. The state is still never destroyed, so module unload releases no
D3D12 object.

era_title_gpu_alloc replaces operator new to fail every allocation of a first and a later track
in turn. Each failure must leave nothing tracked or registered with era_query, and the call is
retried. It also found that shader_view's empty result allocated under the debug STL inside a
noexcept function; it now clears the caller's vectors.

The registry stays private to the module that links it; xmem.dll keeps its four exports.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 21:43:14 +00:00
github manually merged commit 348b785515 into gh-pr/327/base 2026-11-26 21:43:16 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-22 03:45 UTC · original

state() first allocates State with throwing new, but the public registry paths are noexcept. In particular, track() calls state() before entering its bad_alloc handler. If that first allocation fails while servicing XMemAlloc, the process terminates instead of following the allocation-failure path. Please make first-use initialization safe for these entry points and keep registry/device destruction out of DLL teardown. A focused failure-path check should demonstrate that a failed first track leaves no partial registration and can be retried.

**@⁠R0Y00** on GitHub · 2026-11-22 03:45 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/327#issuecomment-7073753684) `state()` first allocates `State` with throwing `new`, but the public registry paths are `noexcept`. In particular, `track()` calls `state()` before entering its `bad_alloc` handler. If that first allocation fails while servicing XMemAlloc, the process terminates instead of following the allocation-failure path. Please make first-use initialization safe for these entry points and keep registry/device destruction out of DLL teardown. A focused failure-path check should demonstrate that a failed first track leaves no partial registration and can be retried.
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-22 03:49 UTC · original

For this PR, keep the registry private to the module that owns it (option c) and preserve the four XMem exports. The direct-linked fixture can claim attach/lookup behavior within that module. A D3D12 client in another DLL needs a single shared registry and a two-DLL fixture proving it sees allocations from the real xmem provider. Please leave that cross-module ABI for the first such consumer. The outstanding noexcept allocation-failure review still applies.

**@⁠R0Y00** on GitHub · 2026-11-22 03:49 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/327#issuecomment-7073810486) For this PR, keep the registry private to the module that owns it (option c) and preserve the four XMem exports. The direct-linked fixture can claim attach/lookup behavior within that module. A D3D12 client in another DLL needs a single shared registry and a two-DLL fixture proving it sees allocations from the real xmem provider. Please leave that cross-module ABI for the first such consumer. The outstanding noexcept allocation-failure review still applies.
github-bot changed title from runtime: give xmem graphics allocations desktop GPU addresses on attach to [removed by author] 2026-12-02 09:38:36 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.