runtime: check the GPU range windows without a device #1507
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1514"
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 Asimmimx on 2026-11-24T13:25:00Z.
Change
Refs #874. This adds a device-free check for
src/d3d12_xs_range.{h,cpp}, the desktop stand-in for the GPU range aD3D12ConfigureVirtualMemoryXconfiguration describes.d3d12_xs_range::createreserves the range as reserved buffers ("windows") no larger than the adapter's per-resource limit.GetGPUVirtualAddress(offset, bytes)may return an address only when the whole span lies inside one window; a 0-byte span counts as 1.The module's only test user is
tests/vm_translation_check.cpp. On WARP, which reports 32 bits per resource, it builds nine windows of 4095 MiB with an 8 MiB last window. Five single-point mutants left the six WARP and device-freevm_translationtests passing:CheckFeatureSupportreturnsE_FAILinstead of its own HRESULT.The first two hand a shader an address whose span runs past the reserved buffer.
d3d12_xs_rangedrivescreatethrough the injectableCreateWindowFn, so it needs no GPU:CheckFeatureSupport. It is a vtable with that method in slot 13;tests/cpu/dstorage_provider.cppuses the same pattern. Any other call counts as unexpected and fails the test.ID3D12Resourcewindows start at(i + 1) << 44. The fake can fail on a chosen call and stops after 16 requests.0xFFFF0000,0xFFFF0000and0x30000.It checks:
GetWindow,Close()and a secondClose(), with no window released twice;UINTwindows) and a failed feature query;d3d12_xs_range_full_last_window_controlruns--mutate full_last_windowand must fail (WILL_FAIL).The change is test, CMake and
docs/experiments.md(the #874 range section) only. The CMake block follows thevm_translationregistrations.Verification
Commit
3c6273ac(main) plus this change,devpreset (Debug), Windows 11 Pro build 26300.9974, MSVC 19.51.36260, Windows SDK 10.0.26100.0, WARP 10.0.26100.9818.tests/docs_links_check.py,tests/bidi_controls_check.pyandgit diff --checkpassed.Mutation probe
I applied each mutation to
src/d3d12_xs_range.cppalone, rebuilt, ran the tests, then reverted. None of this is committed.vm_translation)d3d12_xs_range- 64 KiBCheckFeatureSupportfailure returned asE_FAILUINTnot refusedReleaseon a mid-way failureGetWindowwithoutAddRefGetWindowaccepts index == countCloseleavessize_setsize / window)if (!bytes) bytes = 1;deleted< 17→< 16>= 64→> 64Notes on the last three rows:
if (!bytes) bytes = 1;deleted. This is equivalent: onceoffset < size_and the offset lies inside a window, a 1-byte span always fits.< 17→< 16. Fewer than 17 bits per resource would mean a 0-byte window, which no real adapter reports.>= 64→> 64.1 << 64is undefined behaviour, and on x64 the mutant behaves the same as the original.Checklist
AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T14:09:22Z.
Review: COMMENTED
Technical review of commit
b86bceaa0163aa2a8760a2c6335a74c47f208ef8:Code & fixture audit
tests/d3d12_xs_range_check.cppcleanly exercisessrc/d3d12_xs_range.{h,cpp}without a GPU viaCreateWindowFnand aFakeDevicevtable (slot 13CheckFeatureSupport).GetGPUVirtualAddressspans (0-byte, window-edge, range-end, and overflow),GetWindowrefcounting +Close()idempotency, refusal paths (E_POINTER,E_INVALIDARG,DXGI_ERROR_UNSUPPORTED, mid-creationE_OUTOFMEMORYrollback), and the--mutate full_last_windownegative control (WILL_FAIL TRUE).docs/experiments.mdandCMakeLists.txtupdates are focused and match the fixture.Verification
tests/docs_links_check.py,tests/bidi_controls_check.py,git diff --check, andgit merge-tree --write-tree origin/main HEADall pass.--preset dev): builtd3d12_xs_range_check(4.10s);ctest --preset dev -R '^d3d12_xs_range' --no-tests=error: 2/2 passed (d3d12_xs_range,d3d12_xs_range_full_last_window_control)./O2(--preset release): builtd3d12_xs_range_check(1.39s);ctest --preset release -R '^d3d12_xs_range' --no-tests=error: 2/2 passed (d3d12_xs_range,d3d12_xs_range_full_last_window_control).Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T14:37:49Z.
Three of the five mutants reproduced independently, plus the in-tree control
Independent reviewer, not the author. Reviewed
b86bceaa; nothing pushed to the branch. Mutations were made locally insrc/d3d12_xs_range.cpp, rebuilt, reverted; working tree is clean.Environment: Windows 11 build 26300.9974, MSVC 14.44.35207, SDK 10.0.26100.
Unmodified branch:
The in-tree
--mutate full_last_windowcontrol does what it says: it asserts the wrong window request is what comes outand the ctest case passes only because the check reports it. Nice pattern — it keeps the negative control next to the
fixture instead of in a comment.
Independent mutations
All three are caught by the plain case, with no help from the mutation flag, so the new check does carry the three
edge conditions it claims. I did not reproduce the remaining two (the window count and the per-resource limit path)
because they need the fake device to report different
MaxGPUVirtualAddressBitsPerResourcevalues; if you want thoseconfirmed as well, say so and I will drive them through the fake device.
What this adds over the WARP tests
vm_translation_range_warpalready covers the create path, but only at WARP's 32 bits per resource and only for theshapes that fit. The device-free check runs the same logic with the limits handed in, which is why it can cover
4 GiB-sized windows and the last-window case at all — my three mutants confirm it is exercising the span arithmetic
rather than just the create call.
Verdict
Reviewed
b86bceaa. Builds clean, both cases pass, the in-tree control is genuine, and three independently injectedmutants are caught. No objection from me.