gpu: check the CPU/GPU range translation against a desktop D3D12 heap #905
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/912"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-23T16:55:39Z.
Change
Adds the translation test requested on #874 after #891. A source-built consumer mirrors the main executable's CPU/GPU range helpers against desktop D3D12. On the CPU→GPU path,
gpu = cpu - A + B. On the GPU→CPU path, an address in[B, B + size)maps togpu - B + Aand anything else passes through. Refs #874, #870.vm_translation_shared_range: the no-device case, kept separate. A and B are one range, so both directions are the identity, and addresses just outside pass through.vm_translation_device_warp/_hardware: a committed 64 MiB range is opened once withID3D12Device3::OpenExistingHeapFromAddress, with one cross-adapter buffer placed over all of it. That buffer's GPU address is B. The compute shader receives only root UAV addresses computed from CPU pointers or taken from a live resource.No shim export is added; the production
D3D12ConfigureVirtualMemoryXbehavior stays open. The device helpertests/xmem_test_device.his reused unchanged apart from its comment.Verification
Commit
b68ef35on Windows 10 22H2 (build 19045), Visual Studio 2026 18.12 (MSVC 19.52), Windows SDK 10.0.26100, CMake 4.3.1, Python 3.13.7. D3D12 10.0.19041.7291. GPUs: NVIDIA GeForce RTX 3080 Ti (driver 32.0.16.1047) and in-box WARP 10.0.19041.7811.The same with
--preset release: 12 passed, 0 skipped, 0 failed.tests/bidi_controls_check.pyandtests/docs_links_check.pypassed.vm_translation_check device_hardware(Release), abridged:WARP gives the same lines.
Evidence and follow-up
E_INVALIDARG.B + offsetis observed on both adapters; D3D12 does not document it.Checklist
AI-assisted: prepared with Claude Code; the commands and results above were run on the author's PC.
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T17:02:30Z.
The range and shifted-window control look useful. One lifetime issue needs fixing on this candidate: device_checks releases A while whole and heap are still alive, including the branch where CreatePlacedResource fails after the heap opens. Wait for any submitted work, then release the resource and heap before freeing the backing allocation on every path. Also make a failed reserve-only VirtualAlloc a setup error so the negative cannot pass by testing nullptr. Please rerun shared range and WARP/hardware after this change and report any capability skip separately.
Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-23T17:07:28Z.
Fixed in
af0590a.VirtualAllocrange is owned by a holder declared before the heap and the resources that use it, so they are destroyed first. A guard declared after them waits for all submitted work. On every return, including a failed placement after the heap opened and the 77 skip, the order is: wait for idle, release the resources and heap, free the range.VirtualAllocnow returns 1 withsetup error: reserve-only VirtualAlloc failed, before any heap call. The committed range gets the same treatment.Checks at
af0590aon the same machine (Windows 10 19045, RTX 3080 Ti driver 32.0.16.1047, in-box WARP 10.0.19041.7811):--preset releasegave 3 passed, 0 skipped, 0 failed.vm_translation_shared_range,vm_translation_device_warpandvm_translation_device_hardwareeach passed, with no capability skips.Failure path: a local build that places the buffer at an invalid offset, after the heap has opened, exits with 1 on both adapters (
FAIL wrap the committed range and place one buffer over it). It doesn't crash, and it releases everything in order. The unchanged source passes again.AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T17:12:55Z.
Independent check of
af0590a: Windows 11 26200.9974, RTX 4060 Laptop (616.56), and in-box WARP. The fixture does not enable the debug layer. The shared-range, WARP and hardware cases passed 3/3 in both Debug and Release. The hardware run observed distinct CPU/GPU bases, preserved the +0x200000 placement offset, and the +64 KiB mutation missed all 1,024 intended words. The new lifetime order addresses my review finding.