gpu: export D3D12ConfigureVirtualMemoryX and add the GPU range it describes #961

Merged
lukaslw-lab merged 6 commits from upstream-pr/968 into main 2026-11-23 20:54:08 +00:00
lukaslw-lab commented 2026-11-23 19:14:31 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-23T19:14:31Z.


Change

Refs #874. Two parts. Attaching the range at device creation waits for an owner of the title's device.

1. D3D12ConfigureVirtualMemoryX export in d3d12_xs.dll.

  • It accepts only the observed call shape: the DWORD at +4 is 3 or 4, and the other 28 bytes are zero.
  • It accepts one configuration per process, before the shim has created a device. Otherwise it returns E_POINTER (null), E_INVALIDARG (other content) or DXGI_ERROR_INVALID_CALL (second call, or after the device).
  • It only reads the block, and a refusal changes no state.
  • The accepted value is recorded and does not change device creation yet. D3D12XboxCreateDevice returns an ordinary ID3D12Device that a caller can release without any extra protocol, so the range is not attached there.

2. The GPU range the configuration describes, on an owning handle (src/d3d12_xs_range.h, src/d3d12_xs_range.cpp).

  • d3d12_xs_range::create reserves (value - 2) × 16 GiB as reserved buffers ("windows") of at most 4 GiB, or less where the adapter's per-resource limit is lower: 32 GiB for the 4 sample.
  • It returns an owning IX2WGpuRange reference. A caller maps tiles with UpdateTileMappings, as the title does through a copy queue (static read on #874; #986 covers COPY → DIRECT ordering).
  • The windows hold the device until the range releases them, on Close() or on the range's last release. Nothing else holds the range, so there is no device private data and no reference cycle.
  • Close() is serialized with the queries through an SRW lock: a query that overlaps it sees either the open range or an empty one. The owner waits for GPU work that uses the windows before Close() or the final release.
  • A failed window creation releases every window created so far and returns the HRESULT with no range.

Tests in tests/vm_translation_check.cpp:

  • vm_translation_sequence_{warp,hardware}: configure → D3D12XboxCreateDevice → first default DIRECT queue, with configuration, device and queue refusals. The #912 range checks and the 64 KiB shifted-window witness then run on that queue.
  • vm_translation_range_{warp,hardware}: a 32 GiB range. It maps three tiles on the queue (range start, first tile of window 1, last tile), fills each by copy from a 64 KiB pagefile section, and reads them back by dispatch at the range's GPU address. It also covers the one-tile shift, staging writes after the copy, spans across a window edge or past the end returning 0, and Close() after idle.
  • vm_translation_range_lifetime_{warp,hardware}: ID3DDestructionNotifier on each device. A configured device from d3d12_xs.dll carries no range, and its last ordinary release destroys it. An open range's windows keep a released device alive, and releasing the range destroys it. Close() overlapping a reader thread gives consistent reads, and the device's last release afterwards destroys it.
  • vm_translation_range_partial_{warp,hardware}: window creation failing at window 1 or 3.

The window limit comes from the #874 probe. On an RTX 3080 Ti, tile mappings at or above 4 GiB inside one reserved buffer had no effect, and in-box WARP 10.0.19041 refuses a 4 GiB reserved buffer.

Not covered:

  • attaching the range at device creation, which needs an owner of the title's device that can close it before the final release, including failed initialization and a fence/idle boundary;
  • the parameter-block (Device11) path, which main still refuses;
  • connecting the CPU range A.

Verification

Commit c4a42d26 (main merged at 23d2e93), Windows 10 22H2 (build 19045), D3D12 10.0.19041.7291, Visual Studio 2026 18.12 (MSVC 19.52), Windows SDK 10.0.26100, CMake 4.3.1, Python 3.13.7. Adapters: in-box WARP 10.0.19041.7811 and NVIDIA GeForce RTX 3080 Ti (driver 32.0.16.1047). The fixture does not enable the debug layer. The CTest selections were run through a local wrapper that builds the preset's folder and calls the same ctest selection.

ctest --preset dev --no-tests=error -R '^(vm_translation_|d3d12_xs_shim_|cpu_native_configure_vm$|cpu_native_shim_startup$|cpu_shim_chain_|cpu_shim_draw_)'
100% tests passed, 0 tests failed out of 21
The following tests did not run:
    vm_translation_range_warp (Skipped)
    cpu_shim_chain_warp (Skipped)

ctest --preset release --no-tests=error -R '^(vm_translation_|d3d12_xs_shim_)'
100% tests passed, 0 tests failed out of 15
The following tests did not run:
    vm_translation_range_warp (Skipped)

Capability skips:

  • vm_translation_range_warp: on in-box WARP 10.0.19041.7811, a dispatch does not read a copied tile of a test-owned reserved buffer. The check runs before the range is used. With WARP 1.0.22 loaded app-locally (same binaries), range_warp, range_lifetime_warp, range_partial_warp, sequence_warp and device_warp all pass. The maintainer's Windows 11 26200 run had no skips on in-box WARP.
  • cpu_shim_chain_warp: it also skips on main before this change.
Adapter GPU VA bits per resource / process Range
In-box WARP 10.0.19041.7811 32 / 47 nine 4095 MiB windows; a released device with the range open keeps 9 references
RTX 3080 Ti 40 / 40 eight 4 GiB windows; 8 references

Negative controls, run in dev and not committed. After reverting, each selection passes again.

  • The export returning S_OK for any non-null block: both sequence cases fail.

  • The export attaching a reserved buffer to the configured device as private data: both lifetime cases fail, and the exported device keeps a reference with no destruction callback.

  • Close() doing nothing: both lifetime cases and vm_translation_range_hardware fail.

  • Already-created windows kept on a failed creation: both partial cases fail.

    .\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py
    Checked 13 Markdown files and 201 links.
    .\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py
    Checked 818 tracked source, script and build/CI files: no bidirectional controls.
    .\out\pe-env\Scripts\python.exe -B tests/hardware_reports_check.py
    OK
    .\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py
    form coverage checks passed

Evidence and follow-up

Source-built fixture (MIT), no game files. The call shape comes from the static read in #874 and the recording fixture from #891. The range size and window split are desktop policy: the DWORD's meaning and the other 28 bytes remain open, and the export accepts only the observed samples. IX2WGpuRange's GUID is new to this repository and should stay fixed once merged.

Follow-up on #874:

  • an owner of the title's device that creates the range at device creation and closes it before the final release, covering failed initialization and a fence/idle boundary;
  • connecting the title's B reservation (xmem.dll) and page pool to the windows;
  • the parameter-block device path once it is on main;
  • the queue-capacity task posted on #874.

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.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted: prepared with Claude Code; the commands and results above were run on the author's PC.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6566896733 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/968). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-11-23T19:14:31Z. --- ## Change Refs #874. Two parts. Attaching the range at device creation waits for an owner of the title's device. **1. `D3D12ConfigureVirtualMemoryX` export in `d3d12_xs.dll`.** - It accepts only the observed call shape: the DWORD at `+4` is 3 or 4, and the other 28 bytes are zero. - It accepts one configuration per process, before the shim has created a device. Otherwise it returns `E_POINTER` (null), `E_INVALIDARG` (other content) or `DXGI_ERROR_INVALID_CALL` (second call, or after the device). - It only reads the block, and a refusal changes no state. - The accepted value is recorded and does not change device creation yet. `D3D12XboxCreateDevice` returns an ordinary `ID3D12Device` that a caller can release without any extra protocol, so the range is not attached there. **2. The GPU range the configuration describes, on an owning handle** (`src/d3d12_xs_range.h`, `src/d3d12_xs_range.cpp`). - `d3d12_xs_range::create` reserves `(value - 2) × 16 GiB` as reserved buffers ("windows") of at most 4 GiB, or less where the adapter's per-resource limit is lower: 32 GiB for the 4 sample. - It returns an owning `IX2WGpuRange` reference. A caller maps tiles with `UpdateTileMappings`, as the title does through a copy queue (static read on #874; #986 covers COPY → DIRECT ordering). - The windows hold the device until the range releases them, on `Close()` or on the range's last release. Nothing else holds the range, so there is no device private data and no reference cycle. - `Close()` is serialized with the queries through an SRW lock: a query that overlaps it sees either the open range or an empty one. The owner waits for GPU work that uses the windows before `Close()` or the final release. - A failed window creation releases every window created so far and returns the HRESULT with no range. Tests in `tests/vm_translation_check.cpp`: - `vm_translation_sequence_{warp,hardware}`: configure → `D3D12XboxCreateDevice` → first default DIRECT queue, with configuration, device and queue refusals. The #912 range checks and the 64 KiB shifted-window witness then run on that queue. - `vm_translation_range_{warp,hardware}`: a 32 GiB range. It maps three tiles on the queue (range start, first tile of window 1, last tile), fills each by copy from a 64 KiB pagefile section, and reads them back by dispatch at the range's GPU address. It also covers the one-tile shift, staging writes after the copy, spans across a window edge or past the end returning 0, and `Close()` after idle. - `vm_translation_range_lifetime_{warp,hardware}`: `ID3DDestructionNotifier` on each device. A configured device from `d3d12_xs.dll` carries no range, and its last ordinary release destroys it. An open range's windows keep a released device alive, and releasing the range destroys it. `Close()` overlapping a reader thread gives consistent reads, and the device's last release afterwards destroys it. - `vm_translation_range_partial_{warp,hardware}`: window creation failing at window 1 or 3. The window limit comes from the #874 probe. On an RTX 3080 Ti, tile mappings at or above 4 GiB inside one reserved buffer had no effect, and in-box WARP 10.0.19041 refuses a 4 GiB reserved buffer. Not covered: - attaching the range at device creation, which needs an owner of the title's device that can close it before the final release, including failed initialization and a fence/idle boundary; - the parameter-block (Device11) path, which `main` still refuses; - connecting the CPU range A. ## Verification Commit `c4a42d26` (`main` merged at `23d2e93`), Windows 10 22H2 (build 19045), D3D12 10.0.19041.7291, Visual Studio 2026 18.12 (MSVC 19.52), Windows SDK 10.0.26100, CMake 4.3.1, Python 3.13.7. Adapters: in-box WARP 10.0.19041.7811 and NVIDIA GeForce RTX 3080 Ti (driver 32.0.16.1047). The fixture does not enable the debug layer. The CTest selections were run through a local wrapper that builds the preset's folder and calls the same `ctest` selection. ctest --preset dev --no-tests=error -R '^(vm_translation_|d3d12_xs_shim_|cpu_native_configure_vm$|cpu_native_shim_startup$|cpu_shim_chain_|cpu_shim_draw_)' 100% tests passed, 0 tests failed out of 21 The following tests did not run: vm_translation_range_warp (Skipped) cpu_shim_chain_warp (Skipped) ctest --preset release --no-tests=error -R '^(vm_translation_|d3d12_xs_shim_)' 100% tests passed, 0 tests failed out of 15 The following tests did not run: vm_translation_range_warp (Skipped) Capability skips: - `vm_translation_range_warp`: on in-box WARP 10.0.19041.7811, a dispatch does not read a copied tile of a test-owned reserved buffer. The check runs before the range is used. With WARP 1.0.22 loaded app-locally (same binaries), `range_warp`, `range_lifetime_warp`, `range_partial_warp`, `sequence_warp` and `device_warp` all pass. The maintainer's Windows 11 26200 run had no skips on in-box WARP. - `cpu_shim_chain_warp`: it also skips on `main` before this change. | Adapter | GPU VA bits per resource / process | Range | |---|---|---| | In-box WARP 10.0.19041.7811 | 32 / 47 | nine 4095 MiB windows; a released device with the range open keeps 9 references | | RTX 3080 Ti | 40 / 40 | eight 4 GiB windows; 8 references | Negative controls, run in `dev` and not committed. After reverting, each selection passes again. - The export returning `S_OK` for any non-null block: both sequence cases fail. - The export attaching a reserved buffer to the configured device as private data: both lifetime cases fail, and the exported device keeps a reference with no destruction callback. - `Close()` doing nothing: both lifetime cases and `vm_translation_range_hardware` fail. - Already-created windows kept on a failed creation: both partial cases fail. .\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py Checked 13 Markdown files and 201 links. .\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py Checked 818 tracked source, script and build/CI files: no bidirectional controls. .\out\pe-env\Scripts\python.exe -B tests/hardware_reports_check.py OK .\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py form coverage checks passed ## Evidence and follow-up Source-built fixture (MIT), no game files. The call shape comes from the static read in #874 and the recording fixture from #891. The range size and window split are desktop policy: the DWORD's meaning and the other 28 bytes remain open, and the export accepts only the observed samples. `IX2WGpuRange`'s GUID is new to this repository and should stay fixed once merged. Follow-up on #874: - an owner of the title's device that creates the range at device creation and closes it before the final release, covering failed initialization and a fence/idle boundary; - connecting the title's B reservation (`xmem.dll`) and page pool to the windows; - the parameter-block device path once it is on `main`; - the queue-capacity task posted on #874. ## 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. - [x] I did not include game files, dumps, distribution links or secrets. _AI-assisted: prepared with Claude Code; the commands and results above were run on the author's PC._ 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-24 06:45:38 +00:00
R0Y00 commented 2026-11-24 06:49:32 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T19:22:44Z.


The source-built device → DIRECT queue → readback sequence is useful on its own. At this head the new export validates the input and sets a process-wide flag, but the selected configuration never reaches device creation or address binding. The shifted-window witness still exercises the fixture's own mapping, so it would also pass if the production setup ignored the configuration payload.

Please keep the sequence as a focused source-built fixture, or connect the export to an observable configuration state. For the production path, hold the adapter and inputs fixed and show a device/queue operation that distinguishes a valid configuration from a missing or rejected configuration. Also verify that a failed device creation leaves the existing valid state useful. The supported parameter-block path and large sparse-range behavior can stay separate.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7111518267 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/968#issuecomment-7111518267). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T19:22:44Z. --- The source-built device → DIRECT queue → readback sequence is useful on its own. At this head the new export validates the input and sets a process-wide flag, but the selected configuration never reaches device creation or address binding. The shifted-window witness still exercises the fixture's own mapping, so it would also pass if the production setup ignored the configuration payload. Please keep the sequence as a focused source-built fixture, or connect the export to an observable configuration state. For the production path, hold the adapter and inputs fixed and show a device/queue operation that distinguishes a valid configuration from a missing or rejected configuration. Also verify that a failed device creation leaves the existing valid state useful. The supported parameter-block path and large sparse-range behavior can stay separate.
lukaslw-lab commented 2026-11-24 06:49:33 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-23T19:38:05Z.


AI-assisted (Claude Code).

Thanks. I connected the export to an observable state in 51e7e61. An accepted configuration now changes what the next D3D12XboxCreateDevice returns. The shim reserves (value - 2) × 16 GiB of GPU virtual address space as reserved buffers of at most 4 GiB each. It attaches them to the device as private data (IX2WGpuRange, src/d3d12_xs_range.h), so any module holding the device can read them. A missing or refused configuration leaves the device without a range.

New cases vm_translation_range_{valid,missing,rejected}_{warp,hardware} use the same adapter, device requests, first DIRECT queue and tile inputs, and change only the configuration:

Configuration GetPrivateData(IX2WGpuRange) Queue operation
4 sample, accepted S_OK, 32 GiB in 4 GiB windows (RTX) UpdateTileMappings maps three tiles (range start, first tile of window 1, last tile). A copy fills each, and a dispatch reads it back at the range's GPU address.
no call DXGI_ERROR_NOT_FOUND no range to map
refused (DWORD 5, then a non-zero byte at +8) DXGI_ERROR_NOT_FOUND no range to map

Failed creation:

  • In every case, device requests with a parameter block or another interface are refused first. The accepted configuration survives them, and the next request gets the range.
  • After the range exists, a later configuration and a later parameter-block request are refused. The device keeps the same range, GPU addresses and tile contents.
  • If a window cannot be reserved, creation returns that HRESULT and no device. The configuration stays.

Negative controls (not committed):

  • With the shim always attaching a range, the four missing and rejected cases fail.
  • With it never attaching one, both valid cases fail.

Results:

  • dev: 100% tests passed, 0 tests failed out of 21.
  • release: 100% tests passed, 0 tests failed out of 15.
  • Skips: vm_translation_range_valid_warp and the pre-existing cpu_shim_chain_warp.
  • In-box WARP 10.0.19041.7811 fails the capability check on a test-owned reserved buffer: a dispatch does not read a copied tile, so the valid case skips there. With WARP 1.0.22 loaded app-locally, all five WARP cases pass.
  • VA bits per resource: 32 on in-box WARP (nine 4095 MiB windows), 40 on the RTX 3080 Ti (eight 4 GiB windows).

Not included: the parameter-block path, any single reserved buffer above 4 GiB, and connecting the CPU range A to the windows.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7111880798 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/968#issuecomment-7111880798). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-11-23T19:38:05Z. --- _AI-assisted (Claude Code)._ Thanks. I connected the export to an observable state in `51e7e61`. An accepted configuration now changes what the next `D3D12XboxCreateDevice` returns. The shim reserves `(value - 2) × 16 GiB` of GPU virtual address space as reserved buffers of at most 4 GiB each. It attaches them to the device as private data (`IX2WGpuRange`, `src/d3d12_xs_range.h`), so any module holding the device can read them. A missing or refused configuration leaves the device without a range. New cases `vm_translation_range_{valid,missing,rejected}_{warp,hardware}` use the same adapter, device requests, first DIRECT queue and tile inputs, and change only the configuration: | Configuration | `GetPrivateData(IX2WGpuRange)` | Queue operation | |---|---|---| | 4 sample, accepted | `S_OK`, 32 GiB in 4 GiB windows (RTX) | `UpdateTileMappings` maps three tiles (range start, first tile of window 1, last tile). A copy fills each, and a dispatch reads it back at the range's GPU address. | | no call | `DXGI_ERROR_NOT_FOUND` | no range to map | | refused (DWORD 5, then a non-zero byte at `+8`) | `DXGI_ERROR_NOT_FOUND` | no range to map | Failed creation: - In every case, device requests with a parameter block or another interface are refused first. The accepted configuration survives them, and the next request gets the range. - After the range exists, a later configuration and a later parameter-block request are refused. The device keeps the same range, GPU addresses and tile contents. - If a window cannot be reserved, creation returns that HRESULT and no device. The configuration stays. Negative controls (not committed): - With the shim always attaching a range, the four missing and rejected cases fail. - With it never attaching one, both valid cases fail. Results: - `dev`: `100% tests passed, 0 tests failed out of 21`. - `release`: `100% tests passed, 0 tests failed out of 15`. - Skips: `vm_translation_range_valid_warp` and the pre-existing `cpu_shim_chain_warp`. - In-box WARP 10.0.19041.7811 fails the capability check on a test-owned reserved buffer: a dispatch does not read a copied tile, so the valid case skips there. With WARP 1.0.22 loaded app-locally, all five WARP cases pass. - VA bits per resource: 32 on in-box WARP (nine 4095 MiB windows), 40 on the RTX 3080 Ti (eight 4 GiB windows). Not included: the parameter-block path, any single reserved buffer above 4 GiB, and connecting the CPU range A to the windows.
R0Y00 commented 2026-11-24 06:49:35 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T19:51:54Z.


The new range is observable. I built 51e7e61 and tested its exported configure/create calls on in-box WARP in separate source-built processes. With the valid sample I could query nine windows, and both a span crossing the first window edge and an address at the end of the range returned 0 as documented.

There is a lifetime blocker. I registered an ID3DDestructionNotifier callback on the returned device, released my range reference, then released the last caller-owned device reference. The unconfigured control destroyed the device (Release 0, one callback). The configured branch kept the device alive (Release 9, no callback). D3D12CreateDevice then returned the same device, and the callback fired only after I cleared IX2WGpuRange private data and released it again. SetPrivateDataInterface takes a strong reference, and the range owns device-child resources, so automatic device cleanup cannot break this cycle.

Please make range ownership explicit outside device private data, or provide a teardown path exercised by the actual owner before its final device release. Include a repeatable configured create/release destruction check, plus cleanup after forced partial-window failure. Keep an out-of-window span rejected and report capability skips separately from a configured-range mismatch. This is the reserve/window slice under #874; queue capacity and cross-queue synchronization remain independent.

The original range fixture also ran here under Windows 11 build 26200.9974, Release. All eight sequence and range cases passed across in-box WARP and RTX 4060 Laptop (driver 32.0.16.1656), with no skips. WARP reported 32 per-resource VA bits and used nine windows of at most 4095 MiB. RTX reported 40 bits and used eight windows of 4096 MiB. Each adapter matched all 1,024 words at the first tile, second-window start, and last tile. The source-built destruction control above catches the lifetime issue separately from those queue/readback cases.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7112215911 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/968#issuecomment-7112215911). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T19:51:54Z. --- The new range is observable. I built 51e7e61 and tested its exported configure/create calls on in-box WARP in separate source-built processes. With the valid sample I could query nine windows, and both a span crossing the first window edge and an address at the end of the range returned 0 as documented. There is a lifetime blocker. I registered an ID3DDestructionNotifier callback on the returned device, released my range reference, then released the last caller-owned device reference. The unconfigured control destroyed the device (Release 0, one callback). The configured branch kept the device alive (Release 9, no callback). D3D12CreateDevice then returned the same device, and the callback fired only after I cleared IX2WGpuRange private data and released it again. SetPrivateDataInterface takes a strong reference, and the range owns device-child resources, so automatic device cleanup cannot break this cycle. Please make range ownership explicit outside device private data, or provide a teardown path exercised by the actual owner before its final device release. Include a repeatable configured create/release destruction check, plus cleanup after forced partial-window failure. Keep an out-of-window span rejected and report capability skips separately from a configured-range mismatch. This is the reserve/window slice under #874; queue capacity and cross-queue synchronization remain independent. The original range fixture also ran here under Windows 11 build 26200.9974, Release. All eight sequence and range cases passed across in-box WARP and RTX 4060 Laptop (driver 32.0.16.1656), with no skips. WARP reported 32 per-resource VA bits and used nine windows of at most 4095 MiB. RTX reported 40 bits and used eight windows of 4096 MiB. Each adapter matched all 1,024 words at the first tile, second-window start, and last tile. The source-built destruction control above catches the lifetime issue separately from those queue/readback cases.
lukaslw-lab commented 2026-11-24 06:49:36 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-23T20:03:10Z.


AI-assisted (Claude Code).

Thanks for the destruction check and the Windows 11 run. Fixed in 3647cce with an explicit teardown path. The cycle cannot be broken automatically: the windows are device children and hold the device wherever the range lives.

  • Teardown. IX2WGpuRange::Close() deletes the private-data entry (SetPrivateData(guid, 0, nullptr)) and releases the windows. The range is empty afterwards, and a second call does nothing. The header documents the contract: the device's owner calls Close() before its final release.
  • Partial failure. The range code moved to src/d3d12_xs_range.cpp, so tests can link it directly and inject a failing window creator. Every window created before a failure is released before the HRESULT is returned. attach attaches nothing.
  • Out-of-window spans still return 0. Capability skips stay separate from range mismatches.

New cases:

Case Checks
vm_translation_range_lifetime_{warp,hardware} ID3DDestructionNotifier on the configured device, two create/release rounds. Control: without Close(), the last caller Release leaves 8 references (RTX) or 9 (in-box WARP) and no callback, and the next request returns the same device and range. After Close(): DXGI_ERROR_NOT_FOUND on the device, Release returns 0, and one callback, in both rounds.
vm_translation_range_partial_{warp,hardware} Window creation fails at window 1 or 3, through create and through attach. The test checks that E_OUTOFMEMORY is returned after exactly that many calls, that no range is returned or attached, and that the last device release returns 0 with one callback.

Negative controls (not committed): a Close() that does nothing fails both lifetime cases; keeping the already-created windows on failure fails both partial cases.

Results at 3647cce:

  • dev: 100% tests passed, 0 tests failed out of 25
  • release: 100% tests passed, 0 tests failed out of 19
  • Skips: vm_translation_range_valid_warp on in-box WARP 10.0.19041.7811 (the capability check), and the pre-existing cpu_shim_chain_warp. The new lifetime and partial cases ran without skips on both adapters.

Your Windows 11 26200 run had no skips on in-box WARP, so the skip is specific to the Windows 10 19041 WARP.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7112483226 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/968#issuecomment-7112483226). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-11-23T20:03:10Z. --- _AI-assisted (Claude Code)._ Thanks for the destruction check and the Windows 11 run. Fixed in `3647cce` with an explicit teardown path. The cycle cannot be broken automatically: the windows are device children and hold the device wherever the range lives. - **Teardown.** `IX2WGpuRange::Close()` deletes the private-data entry (`SetPrivateData(guid, 0, nullptr)`) and releases the windows. The range is empty afterwards, and a second call does nothing. The header documents the contract: the device's owner calls `Close()` before its final release. - **Partial failure.** The range code moved to `src/d3d12_xs_range.cpp`, so tests can link it directly and inject a failing window creator. Every window created before a failure is released before the HRESULT is returned. `attach` attaches nothing. - Out-of-window spans still return 0. Capability skips stay separate from range mismatches. New cases: | Case | Checks | |---|---| | `vm_translation_range_lifetime_{warp,hardware}` | `ID3DDestructionNotifier` on the configured device, two create/release rounds. Control: without `Close()`, the last caller `Release` leaves 8 references (RTX) or 9 (in-box WARP) and no callback, and the next request returns the same device and range. After `Close()`: `DXGI_ERROR_NOT_FOUND` on the device, `Release` returns 0, and one callback, in both rounds. | | `vm_translation_range_partial_{warp,hardware}` | Window creation fails at window 1 or 3, through `create` and through `attach`. The test checks that `E_OUTOFMEMORY` is returned after exactly that many calls, that no range is returned or attached, and that the last device release returns 0 with one callback. | Negative controls (not committed): a `Close()` that does nothing fails both lifetime cases; keeping the already-created windows on failure fails both partial cases. Results at `3647cce`: - `dev`: `100% tests passed, 0 tests failed out of 25` - `release`: `100% tests passed, 0 tests failed out of 19` - Skips: `vm_translation_range_valid_warp` on in-box WARP 10.0.19041.7811 (the capability check), and the pre-existing `cpu_shim_chain_warp`. The new lifetime and partial cases ran without skips on both adapters. Your Windows 11 26200 run had no skips on in-box WARP, so the skip is specific to the Windows 10 19041 WARP.
R0Y00 commented 2026-11-24 06:49:37 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T20:07:34Z.


I reran 3647cce on in-box WARP and RTX 4060 Laptop in Release. All 12 sequence and range cases passed with zero skips, including both create/close rounds and failure at windows 1 and 3. The new negative control confirms that ordinary device Release still leaves the configured device alive unless someone calls Close.

The attach-failure branch already closes the range. After a successful attach, only the dedicated lifetime test calls Close in this candidate. The exported device path still returns an ordinary ID3D12Device, so current callers can release it without using this new protocol. Please connect Close to the actual owner before enabling the attachment on that export, including failed initialization and a fence/idle boundary for users of the window resources. Alternatively, the independent range implementation and fixture can land with an explicit owning test handle while production attachment waits for its owner. Document that Close is serialized with window access and describe what happens if private-data removal fails. #986 supplies the separate COPY-to-DIRECT ordering evidence.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7112598968 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/968#issuecomment-7112598968). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T20:07:34Z. --- I reran 3647cce on in-box WARP and RTX 4060 Laptop in Release. All 12 sequence and range cases passed with zero skips, including both create/close rounds and failure at windows 1 and 3. The new negative control confirms that ordinary device Release still leaves the configured device alive unless someone calls Close. The attach-failure branch already closes the range. After a successful attach, only the dedicated lifetime test calls Close in this candidate. The exported device path still returns an ordinary ID3D12Device, so current callers can release it without using this new protocol. Please connect Close to the actual owner before enabling the attachment on that export, including failed initialization and a fence/idle boundary for users of the window resources. Alternatively, the independent range implementation and fixture can land with an explicit owning test handle while production attachment waits for its owner. Document that Close is serialized with window access and describe what happens if private-data removal fails. #986 supplies the separate COPY-to-DIRECT ordering evidence.
lukaslw-lab commented 2026-11-24 06:49:38 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-23T20:23:19Z.


AI-assisted (Claude Code).

Thanks. I took the second option in c4a42d26. The range implementation and its fixture land with an explicit owning handle, and the export no longer attaches a range.

  • Export. D3D12XboxCreateDevice creates no range. The accepted configuration is recorded for a later owner of the title's device. A configured device from d3d12_xs.dll carries no IX2WGpuRange private data, and its last ordinary release destroys it; the lifetime test checks this with ID3DDestructionNotifier.
  • Ownership. d3d12_xs_range::create returns an owning IX2WGpuRange. There is no device private data, so there is no cycle: the windows hold the device only until Close() or the range's last release.
  • Serialization. Close() takes an SRW lock exclusively, and GetSize, GetWindowCount, GetWindow and GetGPUVirtualAddress take it shared. A query that overlaps Close() sees the open range or an empty one. Window references already returned by GetWindow stay valid until their holder releases them. The header asks the owner to wait for GPU work that uses the windows (a fence on each queue) before Close() or the final release. The private-data removal path is gone, so it has no failure case.
Case Result (RTX 3080 Ti / in-box WARP 10.0.19041)
configured device from the export, released 0 references left, one destruction callback / same
device released while the range is open 8 / 9 references left, no callback. Releasing the range then destroys the device.
Close() while a thread reads the range 167,583 / 114,147 reads, 0 inconsistent. The device's last release then returns 0 with one callback.
window creation fails at window 1 or 3 E_OUTOFMEMORY after that many calls, no range, and the device is destroyed on release
range readback (three tiles, shift, edge and end spans, Close() after idle) pass / capability skip (Windows 10 WARP only)

Negative controls (not committed):

  • With the export attaching a reserved buffer as private data, both lifetime cases fail, and the exported device keeps a reference with no callback.
  • With a Close() that does nothing, the lifetime cases fail.
  • With partial windows kept on failure, the partial cases fail.

Results at c4a42d26:

  • dev: 100% tests passed, 0 tests failed out of 21 (skips: vm_translation_range_warp on Windows 10 in-box WARP, pre-existing cpu_shim_chain_warp). With WARP 1.0.22 loaded app-locally, all five WARP cases pass.
  • release: 100% tests passed, 0 tests failed out of 15

Attaching the range at device creation stays for the follow-up that adds an owner of the title's device, covering failed initialization and a fence/idle boundary before Close().

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7112993324 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/968#issuecomment-7112993324). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-11-23T20:23:19Z. --- _AI-assisted (Claude Code)._ Thanks. I took the second option in `c4a42d26`. The range implementation and its fixture land with an explicit owning handle, and the export no longer attaches a range. - **Export.** `D3D12XboxCreateDevice` creates no range. The accepted configuration is recorded for a later owner of the title's device. A configured device from `d3d12_xs.dll` carries no `IX2WGpuRange` private data, and its last ordinary release destroys it; the lifetime test checks this with `ID3DDestructionNotifier`. - **Ownership.** `d3d12_xs_range::create` returns an owning `IX2WGpuRange`. There is no device private data, so there is no cycle: the windows hold the device only until `Close()` or the range's last release. - **Serialization.** `Close()` takes an SRW lock exclusively, and `GetSize`, `GetWindowCount`, `GetWindow` and `GetGPUVirtualAddress` take it shared. A query that overlaps `Close()` sees the open range or an empty one. Window references already returned by `GetWindow` stay valid until their holder releases them. The header asks the owner to wait for GPU work that uses the windows (a fence on each queue) before `Close()` or the final release. The private-data removal path is gone, so it has no failure case. | Case | Result (RTX 3080 Ti / in-box WARP 10.0.19041) | |---|---| | configured device from the export, released | 0 references left, one destruction callback / same | | device released while the range is open | 8 / 9 references left, no callback. Releasing the range then destroys the device. | | `Close()` while a thread reads the range | 167,583 / 114,147 reads, 0 inconsistent. The device's last release then returns 0 with one callback. | | window creation fails at window 1 or 3 | `E_OUTOFMEMORY` after that many calls, no range, and the device is destroyed on release | | range readback (three tiles, shift, edge and end spans, `Close()` after idle) | pass / capability skip (Windows 10 WARP only) | Negative controls (not committed): - With the export attaching a reserved buffer as private data, both lifetime cases fail, and the exported device keeps a reference with no callback. - With a `Close()` that does nothing, the lifetime cases fail. - With partial windows kept on failure, the partial cases fail. Results at `c4a42d26`: - `dev`: `100% tests passed, 0 tests failed out of 21` (skips: `vm_translation_range_warp` on Windows 10 in-box WARP, pre-existing `cpu_shim_chain_warp`). With WARP 1.0.22 loaded app-locally, all five WARP cases pass. - `release`: `100% tests passed, 0 tests failed out of 15` Attaching the range at device creation stays for the follow-up that adds an owner of the title's device, covering failed initialization and a fence/idle boundary before `Close()`.
R0Y00 commented 2026-11-24 06:49:38 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T20:35:26Z.


I reran the bounded implementation on Windows 11 with in-box WARP and RTX 4060 Laptop. The configured export returned an ordinary device that its final Release destroyed. The independent range lifetime, readback and partial-allocation tests passed. I pushed d9f7d29 to reject zero, unaligned and oversized ranges before reserving any window. The previous size ceiling could wrap and return an empty range as successful. The Release selection ^(vm_translation_|d3d12_xs_shim_) passed 15/15, with no skips. The configuration is recorded here. Attaching the range still needs a device owner and a fence-complete shutdown path.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7113278559 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/968#issuecomment-7113278559). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T20:35:26Z. --- I reran the bounded implementation on Windows 11 with in-box WARP and RTX 4060 Laptop. The configured export returned an ordinary device that its final Release destroyed. The independent range lifetime, readback and partial-allocation tests passed. I pushed `d9f7d29` to reject zero, unaligned and oversized ranges before reserving any window. The previous size ceiling could wrap and return an empty range as successful. The Release selection `^(vm_translation_|d3d12_xs_shim_)` passed 15/15, with no skips. The configuration is recorded here. Attaching the range still needs a device owner and a fence-complete shutdown path.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!961
No description provided.