runtime: report process GPU memory from XMemGetWorkingSetStatistics #516

Merged
lukaslw-lab merged 4 commits from upstream-pr/522 into main 2026-11-23 12:47:16 +00:00
lukaslw-lab commented 2026-11-22 08:56:14 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-22T08:56:14Z.


Change

The desktop xmem.dll now answers XMemGetWorkingSetStatistics(0x20000001, …) instead of reporting it as unsupported. It returns TRUE and writes this process's GPU memory in bytes (DXGI QueryVideoMemoryInfo CurrentUsage, local + non-local, summed over adapters) to the qword at +8. No other byte is written. Windows can list one device under several LUIDs, so each LUID is identified by the PnP hardware keys of its physical adapters (D3DKMT), not by vendor/device ID. The value is published only when the total is complete and non-duplicated; otherwise, as for other selectors, the call returns FALSE / ERROR_NOT_SUPPORTED and leaves the output untouched. A null output returns ERROR_INVALID_PARAMETER. dxgi.dll and gdi32.dll are delay-loaded, so xmem.dll still maps neither DXGI nor D3D12 at load.

This resolves the "units, scope and selector meaning remain open" entry for this import in docs/experiments.md as far as the callers need it. There is no issue for it.

Why bytes of GPU memory — call-site evidence from the upscaler DLL (RVAs) and the public SDK:

Evidence Finding
All 7 call sites Pass 0x20000001 and a 128-byte stack buffer; read only +8 (0 on failure); use only after - before
What they bracket Resource create 0x2ea1/0x39a9, resource release (getter 0x26b3 twice from 0x3b40), heap create 0x7452/0x74d2 (ID3D12Device::CreateHeap), heap release 0x7568/0x75b1
Where the delta goes Two qwords at +0x40/+0x48 of 96-byte per-effect records; the second only for aliasable resources/heaps
Public FidelityFX SDK v2.3.0 EffectContext in Kits/FidelityFX/backend/dx12/ffx_dx12.cpp is 96 bytes with vramUsage { totalUsageInBytes, aliasableUsageInBytes } at offset 64, updated at the same four points with the same callback shapes, adding known sizes. v2.3.0 ships FSR upscaling 4.1.1, the version string in the inspected DLL. The cited files are on the MIT list in the SDK's docs/license.md.

The console value's scope and the selector's meaning stay unconfirmed; the callers depend only on its differences. docs/experiments.md records this as a desktop policy.

#511's cpu_native_shim_startup checked the unsupported reply with 0x20000001. It now uses 0x20000002, which stays unsupported, so the fixture's "xmem working set unsupported" step keeps its meaning (one line in tests/cpu/shim_startup.cpp, plus the matching sentence in its docs section).

Overlap: none open (#514 is closed). A trial merge onto current upstream/main is clean.

Verification

Updated at 714d2f2 (adapter identity and aggregation rules, after review): current results in this comment. The results below are from the earlier revision.

Current commit a4036da on upstream/main 26544c6 (includes #511 and #525): the 34 xmem/working_set/shim_startup/shim_compute/era_/docs/delay-load/import/inventory tests pass locally. The same change at 14da57d passed all four workflow jobs on the windows-2025 runner in my fork, with 199/199 in the Debug job. The first CI run of this PR (25007ec) failed xmem_shim_working_set_warp there with exactly double differences; that is the duplicate Basic Render Driver described above. The full local suite and the negative control below ran on ef21b4b (on 5889876). Windows 10 22H2 (build 19045), Visual Studio 18.12.1 (MSVC 19.52.37029), Windows SDK 10.0.26100, CMake 4.3.1, Python 3.13.7. GPU: NVIDIA GeForce RTX 3080 Ti, driver 32.0.16.1047, debug layer on; WARP: in-box.

cmake --build --preset dev
ctest --preset dev --no-tests=error -R '^xmem_shim_' -V
Test Result
xmem_shim_exports Pass. Also checks that dxgi.dll and d3d12.dll are not loaded.
xmem_shim_working_set Pass: amd_selector=1 rest_untouched=1 other_selector=0 error=50 null_output=0 error=87
xmem_shim_working_set_warp, _hardware Pass. 64 MiB DEFAULT/UPLOAD/READBACK heaps: added=67108864 removed=67108864; 32 MiB committed buffer: added=33554432 removed=33554432 (both adapters)

Local-only, with FFX_UPSCALER_IMAGE set to the fingerprinted upscaler DLL (reuses the existing ffx_package_working_set_delta translation):

cmake --preset dev -B out/build/pkg "-DFFX_UPSCALER_IMAGE=<upscaler DLL>"
cmake --build out/build/pkg --target ffx_package_working_set_xmem
ctest --test-dir out/build/pkg --no-tests=error -R '^ffx_package_working_set_'
aliasable=0 heap=67108864 created total=+67108864 aliasable=+0 released total=+0 aliasable=+0 ok
aliasable=1 heap=67108864 created total=+67108864 aliasable=+67108864 released total=+0 aliasable=+0 ok
3/3 passed (ffx_package_working_set_delta, ffx_package_working_set_xmem_warp, _hardware)

Full suite:

ctest --preset dev --no-tests=error -E '^pixel_aot_.*hardware$'

229 tests: 209 passed, 19 skipped (capability, exit 77), 1 failed: gpu_alias_lookup_writes_warp, the known Windows 10 in-box WARP failure (#332, #369). I excluded the pixel_aot_*_hardware tests because they hit their timeouts on this PC under load. They don't load xmem.dll, and all 14 pixel_aot_* tests passed on this branch at the previous base, 3f59c6a.

Negative control (on ef21b4b, with src/xmem_shim.cpp replaced by upstream's): xmem_shim_working_set, _warp, _hardware and both ffx_package_working_set_xmem_* cases fail. Every heap and buffer reports added=0 removed=0, and the package counters stay created total=+0 aliasable=+0. The unchanged tests (xmem_shim_exports, _allocation, _query, ffx_package_working_set_delta) still pass. With the change restored, 6/6 and 3/3 pass.

Evidence and follow-up

  • The fixtures are source-built (heaps and a buffer created on a fresh D3D12 device). The package test reuses the existing translation of the local upscaler DLL; no game bytes are added.
  • The tests measure the same before/after pattern the callers use. Assumption: the console's selector 0x20000001 value moves by the allocation size, as the SDK's known-size accounting implies.
  • Not verified: the full upscaler DLL running against this shim. Context creation needs console D3D12 methods and ACCC pipelines, an open README item. Only NVIDIA and WARP were tested; CurrentUsage comes from the Windows video memory manager, so other vendors are expected to behave the same.
  • Possible follow-up: translate the whole heap-create function (0x7390), with its two queries bound to this xmem.dll, or the resource pair at 0x2e30/0x3b40. That needs import-call and vtable-call support in the translation.

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:6540518803 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/522). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-11-22T08:56:14Z. --- ## Change The desktop `xmem.dll` now answers `XMemGetWorkingSetStatistics(0x20000001, …)` instead of reporting it as unsupported. It returns `TRUE` and writes this process's GPU memory in bytes (DXGI `QueryVideoMemoryInfo` `CurrentUsage`, local + non-local, summed over adapters) to the qword at `+8`. No other byte is written. Windows can list one device under several LUIDs, so each LUID is identified by the PnP hardware keys of its physical adapters (D3DKMT), not by vendor/device ID. The value is published only when the total is complete and non-duplicated; otherwise, as for other selectors, the call returns `FALSE` / `ERROR_NOT_SUPPORTED` and leaves the output untouched. A null output returns `ERROR_INVALID_PARAMETER`. `dxgi.dll` and `gdi32.dll` are delay-loaded, so `xmem.dll` still maps neither DXGI nor D3D12 at load. This resolves the "units, scope and selector meaning remain open" entry for this import in `docs/experiments.md` as far as the callers need it. There is no issue for it. Why bytes of GPU memory — call-site evidence from the upscaler DLL (RVAs) and the public SDK: | Evidence | Finding | |---|---| | All 7 call sites | Pass `0x20000001` and a 128-byte stack buffer; read only `+8` (0 on failure); use only `after - before` | | What they bracket | Resource create `0x2ea1`/`0x39a9`, resource release (getter `0x26b3` twice from `0x3b40`), heap create `0x7452`/`0x74d2` (`ID3D12Device::CreateHeap`), heap release `0x7568`/`0x75b1` | | Where the delta goes | Two qwords at `+0x40`/`+0x48` of 96-byte per-effect records; the second only for aliasable resources/heaps | | Public FidelityFX SDK v2.3.0 | `EffectContext` in `Kits/FidelityFX/backend/dx12/ffx_dx12.cpp` is 96 bytes with `vramUsage { totalUsageInBytes, aliasableUsageInBytes }` at offset 64, updated at the same four points with the same callback shapes, adding known sizes. v2.3.0 ships FSR upscaling 4.1.1, the version string in the inspected DLL. The cited files are on the MIT list in the SDK's `docs/license.md`. | The console value's scope and the selector's meaning stay unconfirmed; the callers depend only on its differences. `docs/experiments.md` records this as a desktop policy. #511's `cpu_native_shim_startup` checked the unsupported reply with `0x20000001`. It now uses `0x20000002`, which stays unsupported, so the fixture's "xmem working set unsupported" step keeps its meaning (one line in `tests/cpu/shim_startup.cpp`, plus the matching sentence in its docs section). Overlap: none open (#514 is closed). A trial merge onto current `upstream/main` is clean. ## Verification **Updated at `714d2f2`** (adapter identity and aggregation rules, after review): current results in [this comment](https://github.com/R0Y00/Xbox2Windows/pull/522#issuecomment-7078953280). The results below are from the earlier revision. Current commit `a4036da` on `upstream/main` `26544c6` (includes #511 and #525): the 34 `xmem`/`working_set`/`shim_startup`/`shim_compute`/`era_`/docs/delay-load/import/inventory tests pass locally. The same change at `14da57d` passed all four workflow jobs on the `windows-2025` runner in my fork, with 199/199 in the Debug job. The first CI run of this PR (`25007ec`) failed `xmem_shim_working_set_warp` there with exactly double differences; that is the duplicate Basic Render Driver described above. The full local suite and the negative control below ran on `ef21b4b` (on `5889876`). Windows 10 22H2 (build 19045), Visual Studio 18.12.1 (MSVC 19.52.37029), Windows SDK 10.0.26100, CMake 4.3.1, Python 3.13.7. GPU: NVIDIA GeForce RTX 3080 Ti, driver 32.0.16.1047, debug layer on; WARP: in-box. ```powershell cmake --build --preset dev ctest --preset dev --no-tests=error -R '^xmem_shim_' -V ``` | Test | Result | |---|---| | `xmem_shim_exports` | Pass. Also checks that `dxgi.dll` and `d3d12.dll` are not loaded. | | `xmem_shim_working_set` | Pass: `amd_selector=1 rest_untouched=1 other_selector=0 error=50 null_output=0 error=87` | | `xmem_shim_working_set_warp`, `_hardware` | Pass. 64 MiB DEFAULT/UPLOAD/READBACK heaps: `added=67108864 removed=67108864`; 32 MiB committed buffer: `added=33554432 removed=33554432` (both adapters) | Local-only, with `FFX_UPSCALER_IMAGE` set to the fingerprinted upscaler DLL (reuses the existing `ffx_package_working_set_delta` translation): ```powershell cmake --preset dev -B out/build/pkg "-DFFX_UPSCALER_IMAGE=<upscaler DLL>" cmake --build out/build/pkg --target ffx_package_working_set_xmem ctest --test-dir out/build/pkg --no-tests=error -R '^ffx_package_working_set_' ``` ```text aliasable=0 heap=67108864 created total=+67108864 aliasable=+0 released total=+0 aliasable=+0 ok aliasable=1 heap=67108864 created total=+67108864 aliasable=+67108864 released total=+0 aliasable=+0 ok 3/3 passed (ffx_package_working_set_delta, ffx_package_working_set_xmem_warp, _hardware) ``` Full suite: ```powershell ctest --preset dev --no-tests=error -E '^pixel_aot_.*hardware$' ``` 229 tests: 209 passed, 19 skipped (capability, exit 77), 1 failed: `gpu_alias_lookup_writes_warp`, the known Windows 10 in-box WARP failure (#332, #369). I excluded the `pixel_aot_*_hardware` tests because they hit their timeouts on this PC under load. They don't load `xmem.dll`, and all 14 `pixel_aot_*` tests passed on this branch at the previous base, `3f59c6a`. **Negative control** (on `ef21b4b`, with `src/xmem_shim.cpp` replaced by upstream's): `xmem_shim_working_set`, `_warp`, `_hardware` and both `ffx_package_working_set_xmem_*` cases fail. Every heap and buffer reports `added=0 removed=0`, and the package counters stay `created total=+0 aliasable=+0`. The unchanged tests (`xmem_shim_exports`, `_allocation`, `_query`, `ffx_package_working_set_delta`) still pass. With the change restored, 6/6 and 3/3 pass. ## Evidence and follow-up - The fixtures are source-built (heaps and a buffer created on a fresh D3D12 device). The package test reuses the existing translation of the local upscaler DLL; no game bytes are added. - The tests measure the same before/after pattern the callers use. Assumption: the console's selector `0x20000001` value moves by the allocation size, as the SDK's known-size accounting implies. - Not verified: the full upscaler DLL running against this shim. Context creation needs console D3D12 methods and `ACCC` pipelines, an open README item. Only NVIDIA and WARP were tested; `CurrentUsage` comes from the Windows video memory manager, so other vendors are expected to behave the same. - Possible follow-up: translate the whole heap-create function (`0x7390`), with its two queries bound to this `xmem.dll`, or the resource pair at `0x2e30`/`0x3b40`. That needs import-call and vtable-call support in the translation. ## 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:43:29 +00:00
R0Y00 commented 2026-11-24 06:43:29 +00:00 (Migrated from github.com)

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

Review: DISMISSED


The per-node reads and the positive/negative aggregation cases address the earlier review. I found one remaining deduplication case on 42154de. The current sorted vectors use case-sensitive string equality. Feeding two 64 MiB LUID views whose hardware registry key differs only by letter case returns 128 MiB in a synthetic run of the actual total() helper. Registry key names identify the same object across case variants, and the PnP query does not document that every returned path is canonicalized. Use ordinal case-insensitive key identity consistently for equality and partial overlap. Add a mixed-case alias that counts once and a mixed-case partial overlap that still fails. https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regopenkeyexw

The PnP query also returns the number of characters written including the terminator. Please use that length, check it stays inside the buffer and describes a nonempty terminated key, and treat malformed output as unknown identity. Keep the existing rejection behavior for incomplete, conflicting and failed samples. https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/d3dkmthk/ns-d3dkmthk-_d3dkmt_query_physical_adapter_pnp_key

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6021404978 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/522#pullrequestreview-6021404978). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T12:07:06Z. **Review:** DISMISSED --- The per-node reads and the positive/negative aggregation cases address the earlier review. I found one remaining deduplication case on 42154de. The current sorted vectors use case-sensitive string equality. Feeding two 64 MiB LUID views whose hardware registry key differs only by letter case returns 128 MiB in a synthetic run of the actual total() helper. Registry key names identify the same object across case variants, and the PnP query does not document that every returned path is canonicalized. Use ordinal case-insensitive key identity consistently for equality and partial overlap. Add a mixed-case alias that counts once and a mixed-case partial overlap that still fails. https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regopenkeyexw The PnP query also returns the number of characters written including the terminator. Please use that length, check it stays inside the buffer and describes a nonempty terminated key, and treat malformed output as unknown identity. Keep the existing rejection behavior for incomplete, conflicting and failed samples. https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/d3dkmthk/ns-d3dkmthk-_d3dkmt_query_physical_adapter_pnp_key
lukaslw-lab commented 2026-11-24 06:48:29 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-22T09:30:43Z.


The CI failure on 25007ec is fixed in a4036da. On the GPU-less windows-2025 runner, DXGI lists the Microsoft Basic Render Driver twice (flags 0 and SOFTWARE, different LUIDs), and both report the same allocations. As a result xmem_shim_working_set_warp measured exactly 2× (added=134217728 for a 64 MiB heap). The shim now skips a software adapter when a non-software adapter with the same vendor and device ID is listed.

I also rebased onto #511 and #525. check_working_set() from #511 now uses selector 0x20000002, which stays unsupported, so the fixture's "unsupported" step keeps its meaning. The same change passed all four workflow jobs on the windows-2025 runner in my fork (199/199 in the Debug job). Locally at a4036da, the 34 affected tests pass, including cpu_native_shim_startup and cpu_shim_compute_*.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7077194814 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/522#issuecomment-7077194814). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-11-22T09:30:43Z. --- The CI failure on `25007ec` is fixed in `a4036da`. On the GPU-less `windows-2025` runner, DXGI lists the Microsoft Basic Render Driver twice (flags 0 and `SOFTWARE`, different LUIDs), and both report the same allocations. As a result `xmem_shim_working_set_warp` measured exactly 2× (`added=134217728` for a 64 MiB heap). The shim now skips a software adapter when a non-software adapter with the same vendor and device ID is listed. I also rebased onto #511 and #525. `check_working_set()` from #511 now uses selector `0x20000002`, which stays unsupported, so the fixture's "unsupported" step keeps its meaning. The same change passed all four workflow jobs on the `windows-2025` runner in my fork (199/199 in the Debug job). Locally at `a4036da`, the 34 affected tests pass, including `cpu_native_shim_startup` and `cpu_shim_compute_*`.
R0Y00 commented 2026-11-24 06:48:29 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T09:56:47Z.


The hardware comparison also reproduces the 2× delta at a4036da on Windows build 26200 with the RTX 4060 Laptop driver 32.0.16.1656. A 64 MiB heap changes the reported usage by 128 MiB, and a 32 MiB buffer changes it by 64 MiB. WARP passes. Two DXGI entries for 10de:28e0 have different LUIDs and both have flags 0. Their local counters both move from 7,294,976 to 74,403,840 on the same 64 MiB allocation. The Intel and Basic Render Driver counters stay at zero.

For the process-wide Windows approximation, publish the qword at +8 only when the observed domains yield a complete, non-duplicated total. A genuine successful zero is valid. An incomplete enumeration, all queries failing, or overlapping active domains without reliable identity should return FALSE / ERROR_NOT_SUPPORTED and preserve the entire output. Matching PCI IDs or equal readings alone cannot establish identity because separate same-model adapters must each be counted.

Please retain this hardware mismatch as a regression reference and exercise the aggregation with synthetic results for aliases, distinct same-model adapters, genuine zero, and total query failure. A design limited to an explicitly bound device would need its narrower scope called out separately.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7077471535 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/522#issuecomment-7077471535). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-22T09:56:47Z. --- The hardware comparison also reproduces the 2× delta at `a4036da` on Windows build 26200 with the RTX 4060 Laptop driver 32.0.16.1656. A 64 MiB heap changes the reported usage by 128 MiB, and a 32 MiB buffer changes it by 64 MiB. WARP passes. Two DXGI entries for 10de:28e0 have different LUIDs and both have flags 0. Their local counters both move from 7,294,976 to 74,403,840 on the same 64 MiB allocation. The Intel and Basic Render Driver counters stay at zero. For the process-wide Windows approximation, publish the qword at +8 only when the observed domains yield a complete, non-duplicated total. A genuine successful zero is valid. An incomplete enumeration, all queries failing, or overlapping active domains without reliable identity should return FALSE / ERROR_NOT_SUPPORTED and preserve the entire output. Matching PCI IDs or equal readings alone cannot establish identity because separate same-model adapters must each be counted. Please retain this hardware mismatch as a regression reference and exercise the aggregation with synthetic results for aliases, distinct same-model adapters, genuine zero, and total query failure. A design limited to an explicitly bound device would need its narrower scope called out separately.
lukaslw-lab commented 2026-11-24 06:48:31 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-22T12:12:52Z.


AI-assisted (Claude Code).

Reworked at 714d2f2 (rebased on aefed61). The value at +8 is published only when the total is complete and non-duplicated; otherwise the call returns FALSE / ERROR_NOT_SUPPORTED and leaves the output untouched.

  • Identity: each LUID is keyed by the PnP hardware keys of its physical adapters (D3DKMT, src/adapter_identity.cpp), not by vendor/device ID.
  • Rules (src/xmem_gpu_usage.h): same keys count once and must agree; different keys are summed; an active adapter of unknown identity is accepted only when no other adapter is active; any failed reading or incomplete enumeration → no total. Zero is published.
  • Regression reference: your 10de:28e0 readings are a case in the new xmem_shim_working_set_aggregation.
Synthetic case Result
your laptop readings: no identity / one shared key declined / +64 MiB
same model, different keys, equal readings summed
genuine zero 0
all or one query failed, incomplete enumeration declined

Negative control: with a plain sum, 9 of 13 cases fail.

Fork CI (GPU-less windows-2025): 215/215, including xmem_shim_working_set_warp. Local (RTX 3080 Ti, Windows 10 19045): all xmem/working-set tests pass; the two failures are unrelated (#332, and an x87 fixture that passes on the runner).

Whether your two NVIDIA LUIDs share a PnP key I can't check here. If not, the hardware case still fails at 2×, and the adapter lines it now prints will show it. Could you rerun?

ctest --preset dev --no-tests=error -R '^xmem_shim_working_set' -V
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7078953280 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/522#issuecomment-7078953280). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-11-22T12:12:52Z. --- _AI-assisted (Claude Code)._ Reworked at `714d2f2` (rebased on `aefed61`). The value at `+8` is published only when the total is complete and non-duplicated; otherwise the call returns `FALSE` / `ERROR_NOT_SUPPORTED` and leaves the output untouched. - **Identity:** each LUID is keyed by the PnP hardware keys of its physical adapters (D3DKMT, `src/adapter_identity.cpp`), not by vendor/device ID. - **Rules** (`src/xmem_gpu_usage.h`): same keys count once and must agree; different keys are summed; an active adapter of unknown identity is accepted only when no other adapter is active; any failed reading or incomplete enumeration → no total. Zero is published. - **Regression reference:** your 10de:28e0 readings are a case in the new `xmem_shim_working_set_aggregation`. | Synthetic case | Result | |---|---| | your laptop readings: no identity / one shared key | declined / +64 MiB | | same model, different keys, equal readings | summed | | genuine zero | 0 | | all or one query failed, incomplete enumeration | declined | Negative control: with a plain sum, 9 of 13 cases fail. Fork CI (GPU-less `windows-2025`): 215/215, including `xmem_shim_working_set_warp`. Local (RTX 3080 Ti, Windows 10 19045): all `xmem`/working-set tests pass; the two failures are unrelated (#332, and an x87 fixture that passes on the runner). Whether your two NVIDIA LUIDs share a PnP key I can't check here. If not, the hardware case still fails at 2×, and the adapter lines it now prints will show it. Could you rerun? ```powershell ctest --preset dev --no-tests=error -R '^xmem_shim_working_set' -V ```
legacy-code-archaeologist commented 2026-11-24 06:48:33 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-22T14:41:00Z.


Verification of 714d2f2 on a hybrid laptop with two hardware adapters. Built from source with the dev preset: Windows 11 26100.9168, MSVC 19.52.37029, SDK 10.0.26100. I ran:

ctest --preset dev --no-tests=error -R "era_heap|desktop_memory_query|xmem_|cpu_working_set_delta" --output-on-failure

Result: 18/18 passed, with no skips. This includes xmem_shim_working_set, _aggregation, _warp and _hardware, and cpu_working_set_delta.

xmem_shim_working_set_hardware lists three DXGI adapters. Each has its own LUID and its own PnP device key, so none is counted twice:

# Adapter Flags Driver
0 Intel HD Graphics 530 (8086:191b) 0 31.0.101.2111
1 NVIDIA Quadro M1000M (10de:13b1) 0 32.0.15.7371
2 Microsoft Basic Render Driver (1414:008c) 2 (software) 10.0.26100.8972

Every bracket reports exactly 1× the allocation, which is the 2× case from a4036da now fixed:

heap_default size=67108864 added=67108864 removed=67108864 ok
heap_upload size=67108864 added=67108864 removed=67108864 ok
heap_readback size=67108864 added=67108864 removed=67108864 ok
committed_buffer size=33554432 added=33554432 removed=33554432 ok

One observation, not a failure. create_device(false) in tests/xmem_shim_check.cpp takes the first non-software adapter. On this laptop that is the integrated Intel GPU, because DXGI lists it before the NVIDIA GPU. The measurement above was therefore made on adapter 0. XBOX2WINDOWS_ADAPTER does not affect this test: runs with Quadro and Intel printed identical output. If a result on the discrete GPU of hybrid systems is wanted, the test could honor that variable like the offscreen checks do. The summed total over all three LUIDs still came out as 1× here.

AI-assisted: run and summarized with Claude Code; outputs copied from the test log.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7080725933 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/522#issuecomment-7080725933). Originally posted by [legacy-code-archaeologist](https://github.com/legacy-code-archaeologist) on 2026-11-22T14:41:00Z. --- Verification of `714d2f2` on a hybrid laptop with two hardware adapters. Built from source with the `dev` preset: Windows 11 26100.9168, MSVC 19.52.37029, SDK 10.0.26100. I ran: ```powershell ctest --preset dev --no-tests=error -R "era_heap|desktop_memory_query|xmem_|cpu_working_set_delta" --output-on-failure ``` Result: 18/18 passed, with no skips. This includes `xmem_shim_working_set`, `_aggregation`, `_warp` and `_hardware`, and `cpu_working_set_delta`. `xmem_shim_working_set_hardware` lists three DXGI adapters. Each has its own LUID and its own PnP device key, so none is counted twice: | # | Adapter | Flags | Driver | |---|---|---|---| | 0 | Intel HD Graphics 530 (`8086:191b`) | 0 | 31.0.101.2111 | | 1 | NVIDIA Quadro M1000M (`10de:13b1`) | 0 | 32.0.15.7371 | | 2 | Microsoft Basic Render Driver (`1414:008c`) | 2 (software) | 10.0.26100.8972 | Every bracket reports exactly 1× the allocation, which is the 2× case from `a4036da` now fixed: ```text heap_default size=67108864 added=67108864 removed=67108864 ok heap_upload size=67108864 added=67108864 removed=67108864 ok heap_readback size=67108864 added=67108864 removed=67108864 ok committed_buffer size=33554432 added=33554432 removed=33554432 ok ``` One observation, not a failure. `create_device(false)` in `tests/xmem_shim_check.cpp` takes the first non-software adapter. On this laptop that is the integrated Intel GPU, because DXGI lists it before the NVIDIA GPU. The measurement above was therefore made on adapter 0. `XBOX2WINDOWS_ADAPTER` does not affect this test: runs with `Quadro` and `Intel` printed identical output. If a result on the discrete GPU of hybrid systems is wanted, the test could honor that variable like the offscreen checks do. The summed total over all three LUIDs still came out as 1× here. AI-assisted: run and summarized with Claude Code; outputs copied from the test log.
lukaslw-lab commented 2026-11-24 06:48:55 +00:00 (Migrated from github.com)

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


AI-assisted (Claude Code).

Thanks @legacy-code-archaeologist for the hybrid-laptop run. Updated at 784104e, rebased on 356a7be:

  • 7cf1112: the working-set change, unchanged apart from the rebase (no conflicts).
  • 784104e: xmem_shim_working_set_hardware now selects its adapter as offscreen_check does: high-performance order, then the first whose description contains XBOX2WINDOWS_ADAPTER, ignoring case. A filter that matches no adapter fails rather than skips. The test prints the adapter it measures (device adapter 10de:2208 NVIDIA GeForce RTX 3080 Ti). The shim is unchanged.

On a hybrid laptop the allocations now land on the discrete GPU by default, which is where the duplicate-LUID 2× case was seen. Your 1× result was measured on the Intel adapter, so it didn't exercise that path.

Local, RTX 3080 Ti, Windows 10 19045:

XBOX2WINDOWS_ADAPTER Adapter measured Result
unset RTX 3080 Ti pass, 1×
rtx 3080, NVIDIA RTX 3080 Ti pass, 1×
Quadro none fail: No D3D12 hardware adapter matches XBOX2WINDOWS_ADAPTER=Quadro

All seven xmem_shim_* scenarios pass. A rerun on the Quadro would be welcome:

$env:XBOX2WINDOWS_ADAPTER = 'Quadro'
ctest --preset dev --no-tests=error -R '^xmem_shim_working_set_hardware$' -V
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7088930299 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/522#issuecomment-7088930299). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-11-23T01:10:15Z. --- _AI-assisted (Claude Code)._ Thanks @legacy-code-archaeologist for the hybrid-laptop run. Updated at `784104e`, rebased on `356a7be`: - `7cf1112`: the working-set change, unchanged apart from the rebase (no conflicts). - `784104e`: `xmem_shim_working_set_hardware` now selects its adapter as `offscreen_check` does: high-performance order, then the first whose description contains `XBOX2WINDOWS_ADAPTER`, ignoring case. A filter that matches no adapter fails rather than skips. The test prints the adapter it measures (`device adapter 10de:2208 NVIDIA GeForce RTX 3080 Ti`). The shim is unchanged. On a hybrid laptop the allocations now land on the discrete GPU by default, which is where the duplicate-LUID 2× case was seen. Your 1× result was measured on the Intel adapter, so it didn't exercise that path. Local, RTX 3080 Ti, Windows 10 19045: | `XBOX2WINDOWS_ADAPTER` | Adapter measured | Result | |---|---|---| | unset | RTX 3080 Ti | pass, 1× | | `rtx 3080`, `NVIDIA` | RTX 3080 Ti | pass, 1× | | `Quadro` | none | fail: `No D3D12 hardware adapter matches XBOX2WINDOWS_ADAPTER=Quadro` | All seven `xmem_shim_*` scenarios pass. A rerun on the Quadro would be welcome: ```powershell $env:XBOX2WINDOWS_ADAPTER = 'Quadro' ctest --preset dev --no-tests=error -R '^xmem_shim_working_set_hardware$' -V ```
R0Y00 commented 2026-11-24 06:49:05 +00:00 (Migrated from github.com)

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


The PnP identity and hybrid-laptop 1× result address the duplicate-LUID case. One completeness gap remains at 784104e: process_bytes() calls QueryVideoMemoryInfo(0, ...) for both segment groups, even when a LUID has several physical nodes. The DXGI API reports usage for the requested node. A nonzero allocation on node 1 would be absent from a successful process total. Please prove the full node set and read both segments for every node, or explicitly reject domains where the single-node precondition cannot be established. Add an injected case with zero on node 0 and nonzero on node 1, and one with a failed segment lookup after a successful read. Use checked addition at the segment boundary as well, before passing the domain total to the existing checked aggregation. Keep the current duplicate-LUID and same-device-model controls.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7095352636 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/522#issuecomment-7095352636). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T08:21:26Z. --- The PnP identity and hybrid-laptop 1× result address the duplicate-LUID case. One completeness gap remains at `784104e`: `process_bytes()` calls `QueryVideoMemoryInfo(0, ...)` for both segment groups, even when a LUID has several physical nodes. The [DXGI API](https://learn.microsoft.com/en-us/windows/win32/api/dxgi1_4/nf-dxgi1_4-idxgiadapter3-queryvideomemoryinfo) reports usage for the requested node. A nonzero allocation on node 1 would be absent from a successful process total. Please prove the full node set and read both segments for every node, or explicitly reject domains where the single-node precondition cannot be established. Add an injected case with zero on node 0 and nonzero on node 1, and one with a failed segment lookup after a successful read. Use checked addition at the segment boundary as well, before passing the domain total to the existing checked aggregation. Keep the current duplicate-LUID and same-device-model controls.
legacy-code-archaeologist commented 2026-11-24 06:49:08 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-23T11:52:57Z.


Verification of 42154de on the same hybrid laptop with two hardware adapters: Windows 11 26100, MSVC 19.52, dev preset. The head merges cleanly with main at 523d9ac (git merge-tree).

ctest --preset dev --no-tests=error -R "era_heap|desktop_memory_query|xmem_|cpu_working_set_delta"

Result: 18/18 passed, with no skips.

xmem_shim_working_set_hardware now reports the node count of each adapter (device paths omitted here):

adapter 0 8086:191b flags=0 luid=00000000:0000a792 nodes=1
adapter 1 10de:13b1 flags=0 luid=00000000:0000bdb4 nodes=1
adapter 2 1414:008c flags=2 luid=00000000:0000bd81 nodes=1
device adapter 10de:13b1 NVIDIA Quadro M1000M

All four heap and committed-buffer cases report added == removed == size.

xmem_shim_working_set_aggregation includes the new per-node cases, each reported ok:

  • single_node_segments total=69206016
  • node1_only total=67108864
  • declined: node_count_unknown, segment_failed_after_read, node1_failed_after_node0, segment_overflow, node_overflow

The earlier duplicate-LUID and same-model controls (basic_render_alias, same_model_distinct, alias_disagrees) still pass.

Every adapter on this host has one node, so this run exercises the multi-node path only through the injected cases, not on hardware.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7100208009 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/522#issuecomment-7100208009). Originally posted by [legacy-code-archaeologist](https://github.com/legacy-code-archaeologist) on 2026-11-23T11:52:57Z. --- Verification of `42154de` on the same hybrid laptop with two hardware adapters: Windows 11 26100, MSVC 19.52, `dev` preset. The head merges cleanly with `main` at `523d9ac` (`git merge-tree`). ```powershell ctest --preset dev --no-tests=error -R "era_heap|desktop_memory_query|xmem_|cpu_working_set_delta" ``` Result: 18/18 passed, with no skips. **`xmem_shim_working_set_hardware`** now reports the node count of each adapter (device paths omitted here): ```text adapter 0 8086:191b flags=0 luid=00000000:0000a792 nodes=1 adapter 1 10de:13b1 flags=0 luid=00000000:0000bdb4 nodes=1 adapter 2 1414:008c flags=2 luid=00000000:0000bd81 nodes=1 device adapter 10de:13b1 NVIDIA Quadro M1000M ``` All four heap and committed-buffer cases report `added == removed == size`. **`xmem_shim_working_set_aggregation`** includes the new per-node cases, each reported `ok`: - `single_node_segments total=69206016` - `node1_only total=67108864` - declined: `node_count_unknown`, `segment_failed_after_read`, `node1_failed_after_node0`, `segment_overflow`, `node_overflow` The earlier duplicate-LUID and same-model controls (`basic_render_alias`, `same_model_distinct`, `alias_disagrees`) still pass. Every adapter on this host has one node, so this run exercises the multi-node path only through the injected cases, not on hardware. AI-assisted (Claude Code).
lukaslw-lab commented 2026-11-24 06:49:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-23T11:56:44Z.


AI-assisted (Claude Code).

Updated at 42154de (rebased on c3db335). Each LUID's value now covers every node:

  • Node set: the count comes from D3DKMT KMTQAITYPE_PHYSICALADAPTERCOUNT, which counts the physical adapters in the LUID's link; these are the DXGI nodes. If the count can't be read, the call returns FALSE / ERROR_NOT_SUPPORTED.
  • Reading: domain_bytes() reads local and non-local usage on every node. Segment, node and cross-adapter sums all go through one checked detail::add().
Injected case Result
0 on node 0, 64 MiB on node 1 64 MiB
failed segment after a successful read (same node / node 1) declined
unknown node count declined
overflow between segments / between nodes declined

Negative control: reading node 0 only fails 3 of the 7. The duplicate-LUID and same-model controls are unchanged. The package test ffx_package_working_set_xmem_hardware now picks its adapter the same way as xmem_shim_working_set_hardware (shared tests/xmem_test_device.h).

Local (RTX 3080 Ti, Windows 10 19045) at 42154de: 31/31 area tests (2 mesh-shader skips on in-box WARP), 3/3 ffx_package_working_set_*. The hardware test prints nodes= for each adapter (both 1 here). Thanks @legacy-code-archaeologist for the hybrid run: by default it now measures the Quadro. The full-suite result follows in a separate comment.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7100290789 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/522#issuecomment-7100290789). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-11-23T11:56:44Z. --- _AI-assisted (Claude Code)._ Updated at `42154de` (rebased on `c3db335`). Each LUID's value now covers every node: - **Node set:** the count comes from D3DKMT `KMTQAITYPE_PHYSICALADAPTERCOUNT`, which counts the physical adapters in the LUID's link; these are the DXGI nodes. If the count can't be read, the call returns `FALSE` / `ERROR_NOT_SUPPORTED`. - **Reading:** `domain_bytes()` reads local and non-local usage on every node. Segment, node and cross-adapter sums all go through one checked `detail::add()`. | Injected case | Result | |---|---| | 0 on node 0, 64 MiB on node 1 | 64 MiB | | failed segment after a successful read (same node / node 1) | declined | | unknown node count | declined | | overflow between segments / between nodes | declined | Negative control: reading node 0 only fails 3 of the 7. The duplicate-LUID and same-model controls are unchanged. The package test `ffx_package_working_set_xmem_hardware` now picks its adapter the same way as `xmem_shim_working_set_hardware` (shared `tests/xmem_test_device.h`). Local (RTX 3080 Ti, Windows 10 19045) at `42154de`: 31/31 area tests (2 mesh-shader skips on in-box WARP), 3/3 `ffx_package_working_set_*`. The hardware test prints `nodes=` for each adapter (both 1 here). Thanks @legacy-code-archaeologist for the hybrid run: by default it now measures the Quadro. The full-suite result follows in a separate comment.
lukaslw-lab commented 2026-11-24 06:49:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-23T11:56:45Z.


Full local dev suite (RTX 3080 Ti, Windows 10 19045, in-box WARP): 422/425 passed, 43 capability skips. It ran before the rebase onto c3db335 and before the test-only move into tests/xmem_test_device.h; both are covered by the targeted reruns at 42154de above. The three failures are outside this change:

  • gpu_alias_lookup_writes_warp: in-box WARP (#332)
  • pixel_aot_title_loads_warp: in-box WARP, passes on WARP 1.0.22 (reported on #816)
  • rdna2_tools_check: caused by PYTHONIOENCODING=utf-8 in my shell; passes with it unset. Tracked in #844.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7100291262 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/522#issuecomment-7100291262). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-11-23T11:56:45Z. --- Full local `dev` suite (RTX 3080 Ti, Windows 10 19045, in-box WARP): 422/425 passed, 43 capability skips. It ran before the rebase onto `c3db335` and before the test-only move into `tests/xmem_test_device.h`; both are covered by the targeted reruns at `42154de` above. The three failures are outside this change: - `gpu_alias_lookup_writes_warp`: in-box WARP (#332) - `pixel_aot_title_loads_warp`: in-box WARP, passes on WARP 1.0.22 (reported on #816) - `rdna2_tools_check`: caused by `PYTHONIOENCODING=utf-8` in my shell; passes with it unset. Tracked in #844.
lukaslw-lab commented 2026-11-24 06:49:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-23T12:22:30Z.


AI-assisted (Claude Code).

Updated at 629eb61 (rebased on e97090a).

  • Key identity: adapter_identity::same_device() compares keys with CompareStringOrdinal(..., TRUE) (ordinal, OS uppercase table). total() uses it for both alias equality and partial overlap, compared as sets, so key order and case no longer matter.
  • Key length: adapter_identity::key_length() takes the pCchDest count (including the terminator) and accepts it only when it fits the buffer and forms one nonempty, terminated key with no embedded NUL. Anything else leaves the identity unknown. Rejection of incomplete, conflicting and failed samples is unchanged.
Synthetic case Result
mixed-case alias, both 64 MiB 64 MiB
mixed-case alias, 64 vs 32 MiB declined
mixed-case partial overlap declined
key: nothing written / empty / past buffer / unterminated / embedded NUL no key (identity unknown)

Negative controls: with a case-sensitive comparison the three mixed-case cases fail (the alias gives 128 MiB, as in your run). With the previous length handling, 4 of the 7 key cases are accepted.

Local (RTX 3080 Ti, Windows 10 19045) at 629eb61: 32/32 area tests (2 mesh-shader skips on in-box WARP), 3/3 ffx_package_working_set_*.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7100962054 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/522#issuecomment-7100962054). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-11-23T12:22:30Z. --- _AI-assisted (Claude Code)._ Updated at `629eb61` (rebased on `e97090a`). - **Key identity:** `adapter_identity::same_device()` compares keys with `CompareStringOrdinal(..., TRUE)` (ordinal, OS uppercase table). `total()` uses it for both alias equality and partial overlap, compared as sets, so key order and case no longer matter. - **Key length:** `adapter_identity::key_length()` takes the `pCchDest` count (including the terminator) and accepts it only when it fits the buffer and forms one nonempty, terminated key with no embedded NUL. Anything else leaves the identity unknown. Rejection of incomplete, conflicting and failed samples is unchanged. | Synthetic case | Result | |---|---| | mixed-case alias, both 64 MiB | 64 MiB | | mixed-case alias, 64 vs 32 MiB | declined | | mixed-case partial overlap | declined | | key: nothing written / empty / past buffer / unterminated / embedded NUL | no key (identity unknown) | Negative controls: with a case-sensitive comparison the three mixed-case cases fail (the alias gives 128 MiB, as in your run). With the previous length handling, 4 of the 7 key cases are accepted. Local (RTX 3080 Ti, Windows 10 19045) at `629eb61`: 32/32 area tests (2 mesh-shader skips on in-box WARP), 3/3 `ffx_package_working_set_*`.
lukaslw-lab commented 2026-11-24 06:49:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-23T12:47:01Z.


Full local dev suite at 629eb61 (RTX 3080 Ti, Windows 10 19045): 425/427 passed, 44 capability skips. Both failures are known in-box WARP issues unrelated to this change (#332, #816).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7101617875 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/522#issuecomment-7101617875). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-11-23T12:47:01Z. --- Full local `dev` suite at `629eb61` (RTX 3080 Ti, Windows 10 19045): 425/427 passed, 44 capability skips. Both failures are known in-box WARP issues unrelated to this change (#332, #816).
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!516
No description provided.