d3d12_xs tests: enable experimental shader models before the first real device is created #171
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
library
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/omonkeyz--xbox-emulator!171
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/171/head"
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?
@MeNoSkills on GitHub · 2026-11-22 17:41 UTC · original
MeNoSkills:fix/create-device-test-isolation→main· +5 −0 · 1 files · 1 commits · closed without mergingIn a single
cargo test -p d3d12_xs --libprocess, 22 tests fail (23 on current main), all withD3D12CreateDevicereturning DXGI_ERROR_DEVICE_RESET (0x887a0007), although each module passes when run on its own. Refs #157.Cause
D3D12XboxCreateDevicecallsD3D12EnableExperimentalFeatures(ShaderModels)before it creates the device, and that call has to happen before any device exists in the process. Four tests create a real device straight through the host'sD3D12CreateDevicewithout it:alias::tests::title_heap_does_not_block_unmap_or_free,alias::tests::two_placements_at_one_va_share_title_memory,alias::tests::two_textures_at_one_va_share_gpu_local_heapandcl2_state::tests::real_device_query_spanning_a_split_resolves_the_whole_total. Whencreate_device_tests::create_device_returns_wrapped_devicelater goes through the emulator's export, the late enable call makes every creation after it in that process fail with DEVICE_RESET. With parallel threads the same race fails 5 more tests (the four above andalias::tests::msaa_depth_with_a_larger_pc_layout_never_overlaps_the_next_title_placement).How I found it: I paired each of the 128 tests that run before
create_device_returns_wrapped_devicewith it in one process (--exact, one thread). The four tests above are the only ones that make it print "no D3D12 device on this machine (hr=0x887a0007)". Releasing the queue and device at the end of thecl2_statetest did not help, ruling out a leak. A probe that creates 400 devices without releasing them worked, ruling out a device count limit.Change
In
host_proc(lib.rs), under#[cfg(test)], the first time a test resolvesD3D12CreateDeviceit runsenable_experimental_shader_models()once (std::sync::Once). Production code is unchanged.Results
Windows 10 build 19045, NVIDIA GeForce RTX 4070 Ti, MSVC, on upstream main
9cd1305:cargo test --locked -p d3d12_xs --lib -- --test-threads=1cargo test --locked -p d3d12_xs --libThe remaining failure is
xs_exports::console_fixed_tests::fixed_result_dxgix_exports_match_every_console_d3d12_xs, which needs a console d3d12_xs.dll inD:\xbox-pc-port\games.cargo test --locked -p d3d12_xs --lib hw_ -- --ignored --test-threads=1is still 38 passed.python .github/scripts/pr_gate.py --base upstream/main --head HEAD: 0 problems.Environment dependence
I reproduce the failures on Windows 10 build 19045 (D3D12 runtime 10.0.19041) with an NVIDIA RTX 4070 Ti. In #157 another contributor reports 512 passed, 1 failed on current main in both modes on an RTX 5070 with Windows 11 26H2, so on that runtime the late enable call does not poison later device creation. This change therefore mainly helps developers on Windows 10; on Windows 11 it should be a no-op (the enable call is made once, before the first device, which is what the D3D12 documentation requires). I have not run it on Windows 11 myself.
@omonkeyz on GitHub · 2026-11-22 17:59 UTC · original
Applied in
fa28145(merged in202c763) with your authorship kept, thanks. Nice find. The merge note records your 512/1 result in both test modes and the matching RTX 5070 confirmation from #157.Pull request closed