HLE: bridge ID3D12Device before direct ResetDevice and cache D3D11 companion #1677

Open
github-bot wants to merge 1 commit from github-bot/gh-1677 into main AGit
Owner

@⁠eizispark on GitHub · 2026-11-24 19:12 UTC · original
eizispark:fix/mfplat-d3d12-bridge → main · +169 −43 · 1 files · 1 commits · open

MFResetDXGIDeviceManagerX previously tried calling IMFDXGIDeviceManager::ResetDevice directly with pDevice before checking whether pDevice implements ID3D12Device. Under XCL's null D3D12 backend (NullObj::QueryInterface answers S_OK to every IID, including IID_ID3D11Device and IID_ID3D10Multithread), system mfplat.dll accepted NullObj directly and stored it inside IMFDXGIDeviceManager, causing subsequent LockDevice(IID_ID3D11Device) calls to fail with MF_E_UNEXPECTED (0xC00D36BB).

In addition, MFResetDXGIDeviceManagerX created a new companion ID3D11Device (D3D11CreateDevice + VIDEO_SUPPORT) on every call rather than reusing the companion D3D11 device for the adapter LUID.

What is in it

  • crates/xcl/src/hle/mfplat.rs: check device_unk.cast::<ID3D12Device>() before falling back to direct IMFDXGIDeviceManager::ResetDevice, cache multithread-protected companion ID3D11Device instances per adapter LUID (recreating only if ID3D11Device::GetDeviceRemovedReason at vtable slot 39 reports removal), and add null_d3d12_device_bridges_to_real_d3d11_and_reuses_companion_per_luid covering both the null D3D12 backend and hardware ID3D12Device LUID caching.

Tested

  • Hardware / toolchain: AMD Radeon RX 9070 XT (driver 32.0.32015.16001), AMD Ryzen 7 9800X3D, Windows 11 x64, rustc 1.100.0 (0ef1bc386 2026-11-09) (stable-x86_64-pc-windows-msvc), debug (unit + workspace tests) and release (60 s title smoke).
  • cargo test -p xcl --lib mfplat: 4 passed, 0 failed, 0 ignored (null_d3d12_device_bridges_to_real_d3d11_and_reuses_companion_per_luid verified failing with 0xC00D36BB (MF_E_UNEXPECTED) before the fix).
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 777 passed, 0 failed, 41 ignored (SKIPPED GPU/SDK tests: 3 — test_title_draws_with_a_root_signature_under_the_debug_layer: no d3d12SDKLayers.dll; heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows; uploads_start_from_each_subresources_state: no D3D12 debug layer).

Regression run

main (9e3831e1f570d3646e53ab753b19ec07eb8f1485):

xcl-smoke v1
commit: 9e3831e1f570d3646e53ab753b19ec07eb8f1485
gpu: AMD Radeon RX 9070 XT
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1677 (PresentX 1677)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14728 MB

PR (8c441777a6c06197b00baca498790ae02f4154f5):

xcl-smoke v1
commit: 8c441777a6c06197b00baca498790ae02f4154f5
gpu: AMD Radeon RX 9070 XT
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1673 (PresentX 1673)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14730 MB

Not tested

  • Retail titles exercising hardware Media Foundation video playback (MFResetDXGIDeviceManagerX + MFSourceReader / hardware MFTs) under graphics = "null" or Linux / Wine.
  • D3D12 SDK debug-layer tests (d3d12SDKLayers.dll not installed on this machine).

AI use

  • Antigravity (Google DeepMind, Gemini 4 Carbon): audited mfplat.rs and d3d11.h (ID3D11DeviceVtbl), wrote the regression test and fix, ran the workspace test suite and scripts/smoke.ps1 runs, and drafted this PR description.
**@⁠eizispark** on GitHub · 2026-11-24 19:12 UTC · [original](https://github.com/xcl-dev/xcl/pull/1677) `eizispark:fix/mfplat-d3d12-bridge` → `main` · +169 −43 · 1 files · 1 commits · open `MFResetDXGIDeviceManagerX` previously tried calling `IMFDXGIDeviceManager::ResetDevice` directly with `pDevice` before checking whether `pDevice` implements `ID3D12Device`. Under XCL's `null` D3D12 backend (`NullObj::QueryInterface` answers `S_OK` to every IID, including `IID_ID3D11Device` and `IID_ID3D10Multithread`), system `mfplat.dll` accepted `NullObj` directly and stored it inside `IMFDXGIDeviceManager`, causing subsequent `LockDevice(IID_ID3D11Device)` calls to fail with `MF_E_UNEXPECTED` (`0xC00D36BB`). In addition, `MFResetDXGIDeviceManagerX` created a new companion `ID3D11Device` (`D3D11CreateDevice` + `VIDEO_SUPPORT`) on every call rather than reusing the companion D3D11 device for the adapter LUID. **What is in it** - `crates/xcl/src/hle/mfplat.rs`: check `device_unk.cast::<ID3D12Device>()` before falling back to direct `IMFDXGIDeviceManager::ResetDevice`, cache multithread-protected companion `ID3D11Device` instances per adapter LUID (recreating only if `ID3D11Device::GetDeviceRemovedReason` at vtable slot 39 reports removal), and add `null_d3d12_device_bridges_to_real_d3d11_and_reuses_companion_per_luid` covering both the `null` D3D12 backend and hardware `ID3D12Device` LUID caching. **Tested** - Hardware / toolchain: AMD Radeon RX 9070 XT (driver `32.0.32015.16001`), AMD Ryzen 7 9800X3D, Windows 11 x64, `rustc 1.100.0 (0ef1bc386 2026-11-09)` (`stable-x86_64-pc-windows-msvc`), debug (unit + workspace tests) and release (60 s title smoke). - `cargo test -p xcl --lib mfplat`: 4 passed, 0 failed, 0 ignored (`null_d3d12_device_bridges_to_real_d3d11_and_reuses_companion_per_luid` verified failing with `0xC00D36BB` (`MF_E_UNEXPECTED`) before the fix). - `cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4`: 777 passed, 0 failed, 41 ignored (SKIPPED GPU/SDK tests: 3 — `test_title_draws_with_a_root_signature_under_the_debug_layer`: no `d3d12SDKLayers.dll`; `heap_window_out_of_memory_falls_back_to_the_switch_form`: no heap windows; `uploads_start_from_each_subresources_state`: no D3D12 debug layer). **Regression run** `main` (`9e3831e1f570d3646e53ab753b19ec07eb8f1485`): ``` xcl-smoke v1 commit: 9e3831e1f570d3646e53ab753b19ec07eb8f1485 gpu: AMD Radeon RX 9070 XT title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1677 (PresentX 1677) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14728 MB ``` PR (`8c441777a6c06197b00baca498790ae02f4154f5`): ``` xcl-smoke v1 commit: 8c441777a6c06197b00baca498790ae02f4154f5 gpu: AMD Radeon RX 9070 XT title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1673 (PresentX 1673) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14730 MB ``` **Not tested** - Retail titles exercising hardware Media Foundation video playback (`MFResetDXGIDeviceManagerX` + `MFSourceReader` / hardware MFTs) under `graphics = "null"` or Linux / Wine. - D3D12 SDK debug-layer tests (`d3d12SDKLayers.dll` not installed on this machine). **AI use** - Antigravity (Google DeepMind, Gemini 4 Carbon): audited `mfplat.rs` and `d3d11.h` (`ID3D11DeviceVtbl`), wrote the regression test and fix, ran the workspace test suite and `scripts/smoke.ps1` runs, and drafted this PR description.
`MFResetDXGIDeviceManagerX` previously tried `IMFDXGIDeviceManager::ResetDevice`
with `pDevice` directly before checking `ID3D12Device`. Under XCL's `null`
D3D12 backend (`NullObj::QueryInterface` answers `S_OK` to every IID,
including `IID_ID3D11Device` and `IID_ID3D10Multithread`), system `mfplat.dll`
accepted `NullObj` directly and stored it inside `IMFDXGIDeviceManager`,
causing subsequent `LockDevice(IID_ID3D11Device)` calls to fail with
`MF_E_UNEXPECTED` (`0xC00D36BB`).

In addition, `MFResetDXGIDeviceManagerX` created a brand-new `ID3D11Device`
(`D3D11CreateDevice` + `VIDEO_SUPPORT`) on every call instead of reusing the
companion D3D11 device for the adapter LUID.

Check `ID3D12Device` first (falling through to direct `ResetDevice` only for
non-D3D12 devices or if bridge creation fails) and cache the multithread-
protected companion `ID3D11Device` per adapter LUID, recreating it only if
`ID3D11Device::GetDeviceRemovedReason` (vtable slot 39) reports removal.

Assisted-by: Antigravity (Google DeepMind, Gemini 4 Carbon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:01:17 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 21:37 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 21:37 UTC · [original](https://github.com/xcl-dev/xcl/pull/1677#issuecomment-7145180770) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~22 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified `main`.) Thanks!
Author
Owner

@⁠frenziedcoder on GitHub · 2026-11-24 21:54 UTC · original

NVIDIA test report for 8c44177: the full workspace and a smoke pair on the retail title, next to @⁠DavidM1911's RTX 3060 Ti library run above. Full suite green, the PR's own test passes, and a clean smoke pair (1654 vs 1655 frames).

Tested

  • NVIDIA GeForce RTX 5080 16 GB (driver 617.14, 32-lane waves), AMD Ryzen 7 9800X3D, 64 GB, Windows 11 Pro 25H2 (26200.9974), rustc 1.100.0 stable-x86_64-pc-windows-msvc, DXC 1.8.2502.11 (SDK 10.0.26100.0). Exact head 8c441777a6c06197b00baca498790ae02f4154f5, no local changes.
  • cargo build --workspace && cargo test --workspace -- --test-threads=4 (debug): 777 passed, 0 failed, 41 ignored; the PR's own test passes. SKIPPED: gpu_geometry_wave32_prefix_count_over_a_mask (no wave64), gpu_wave32_program_in_wave64_hardware (no wave64), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • test_title_draws_with_a_root_signature_under_the_debug_layer reports ok, but this machine has no D3D12 debug layer (debug layer requested but unavailable … (0x887A002D)), so it ran without the layer and is no evidence either way.

Regression run (scripts/smoke.ps1 -Seconds 60, release, the retail title of #505 at its start screen; XCL_PSO_PRELOAD=0 for both builds, because this machine's preload list holds the program of #1307)

base (9e3831e, this PR's merge base with main):

xcl-smoke v1
commit: 9e3831e1f570d3646e53ab753b19ec07eb8f1485
gpu: NVIDIA GeForce RTX 5080
title: RetailTitle
seconds: 60
exit: 0x0
frames shown: 1655 (PresentX 1655)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14601 MB

this PR:

xcl-smoke v1
commit: 8c441777a6c06197b00baca498790ae02f4154f5
gpu: NVIDIA GeForce RTX 5080
title: RetailTitle
seconds: 60
exit: 0x0
frames shown: 1654 (PresentX 1654)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14604 MB

Not tested: hardware Media Foundation video playback; graphics = "null"; the debug-layer test (see above); Linux / Wine; AMD.

AI use: Claude Code (Claude Opus 5.5) built and ran the tests and smoke runs on my machine and wrote this report; I checked it.

**@⁠frenziedcoder** on GitHub · 2026-11-24 21:54 UTC · [original](https://github.com/xcl-dev/xcl/pull/1677#issuecomment-7145551170) **NVIDIA test report for `8c44177`: the full workspace and a smoke pair on the retail title, next to @⁠DavidM1911's RTX 3060 Ti library run above. Full suite green, the PR's own test passes, and a clean smoke pair (1654 vs 1655 frames).** **Tested** - NVIDIA GeForce RTX 5080 16 GB (driver 617.14, 32-lane waves), AMD Ryzen 7 9800X3D, 64 GB, Windows 11 Pro 25H2 (26200.9974), rustc 1.100.0 `stable-x86_64-pc-windows-msvc`, DXC 1.8.2502.11 (SDK 10.0.26100.0). Exact head `8c441777a6c06197b00baca498790ae02f4154f5`, no local changes. - `cargo build --workspace && cargo test --workspace -- --test-threads=4` (debug): **777 passed, 0 failed, 41 ignored**; the PR's own test passes. SKIPPED: `gpu_geometry_wave32_prefix_count_over_a_mask` (no wave64), `gpu_wave32_program_in_wave64_hardware` (no wave64), `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows). - `test_title_draws_with_a_root_signature_under_the_debug_layer` reports ok, but this machine has no D3D12 debug layer (`debug layer requested but unavailable … (0x887A002D)`), so it ran without the layer and is no evidence either way. **Regression run** (`scripts/smoke.ps1 -Seconds 60`, release, the retail title of #505 at its start screen; `XCL_PSO_PRELOAD=0` for both builds, because this machine's preload list holds the program of #1307) base (`9e3831e`, this PR's merge base with `main`): ``` xcl-smoke v1 commit: 9e3831e1f570d3646e53ab753b19ec07eb8f1485 gpu: NVIDIA GeForce RTX 5080 title: RetailTitle seconds: 60 exit: 0x0 frames shown: 1655 (PresentX 1655) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14601 MB ``` this PR: ``` xcl-smoke v1 commit: 8c441777a6c06197b00baca498790ae02f4154f5 gpu: NVIDIA GeForce RTX 5080 title: RetailTitle seconds: 60 exit: 0x0 frames shown: 1654 (PresentX 1654) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14604 MB ``` **Not tested:** hardware Media Foundation video playback; `graphics = "null"`; the debug-layer test (see above); Linux / Wine; AMD. *AI use: Claude Code (Claude Opus 5.5) built and ran the tests and smoke runs on my machine and wrote this report; I checked it.*
Author
Owner

@⁠JJAutoCompare on GitHub · 2026-11-25 04:38 UTC · original

XCL PR #1677 verification

Head 8c441777a6c06197b00baca498790ae02f4154f5, clean detached checkout. The PR changes crates/xcl/src/hle/mfplat.rs only.

STOR-WINLAB ran Windows 11 Enterprise Evaluation x64, build 26200, on an AMD Family 23 Model 113 CPU with Intel Arc A770 Graphics and driver 32.0.101.9175. DXC was 1.9.2609.5. Rust was 1.100.0 (0ef1bc386, x86_64-pc-windows-msvc).

Tested

  • cargo build --workspace and cargo test --workspace --no-run both exited 0 outside the Arc mutex. The latter built 19 test executables.
  • cargo test -p xcl --lib hle::mfplat::tests -- --test-threads=1 ran under Invoke-ArcTest.ps1 with XCL_ADAPTER=A770. All 4 passed, with 0 failed, 0 ignored and no skip markers. For both null and hardware D3D12 inputs, the new test locked a genuine D3D11 device and confirmed the same COM identity across two Media Foundation managers for each LUID. The token test rejected an invalid token and checked device-handle usability after a valid reset. The other tests checked null arguments and export routing.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 ran once under the same mutex and adapter setting with RUST_TEST_NOCAPTURE=1. Cargo exited 101. The 20 summaries in pr1677-suite.log cover 19 test binaries and 1 doctest target and total 761 passed, 16 failed and 41 ignored. The bundled title logged a passing MFPlat reset check.

Workspace failures and skips

The library had 15 shader-recompiler failures. Eleven reported CreateComputePipelineState returning 0x80070057, and four reported output mismatches. The end-to-end title test failed its dynamic depth-bias check. The log contains 6 lines beginning with SKIPPED . Two cited wave64, two cited the D3D12 debug layer, one cited tiled resource tier and one cited heap windows. Those skips provide no coverage.

Not tested

A matched main run, retail-title smoke or playback, other GPU vendors, and forced device removal during a companion reset.

AI use

T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr1677-suite.log and published.

**@⁠JJAutoCompare** on GitHub · 2026-11-25 04:38 UTC · [original](https://github.com/xcl-dev/xcl/pull/1677#issuecomment-7153023092) # XCL PR #1677 verification Head `8c441777a6c06197b00baca498790ae02f4154f5`, clean detached checkout. The PR changes `crates/xcl/src/hle/mfplat.rs` only. STOR-WINLAB ran Windows 11 Enterprise Evaluation x64, build 26200, on an AMD Family 23 Model 113 CPU with Intel Arc A770 Graphics and driver 32.0.101.9175. DXC was 1.9.2609.5. Rust was 1.100.0 (0ef1bc386, x86_64-pc-windows-msvc). **Tested** - `cargo build --workspace` and `cargo test --workspace --no-run` both exited 0 outside the Arc mutex. The latter built 19 test executables. - `cargo test -p xcl --lib hle::mfplat::tests -- --test-threads=1` ran under `Invoke-ArcTest.ps1` with `XCL_ADAPTER=A770`. All 4 passed, with 0 failed, 0 ignored and no skip markers. For both null and hardware D3D12 inputs, the new test locked a genuine D3D11 device and confirmed the same COM identity across two Media Foundation managers for each LUID. The token test rejected an invalid token and checked device-handle usability after a valid reset. The other tests checked null arguments and export routing. - `cargo test --workspace --no-fail-fast -- --test-threads=4` ran once under the same mutex and adapter setting with `RUST_TEST_NOCAPTURE=1`. Cargo exited 101. The 20 summaries in `pr1677-suite.log` cover 19 test binaries and 1 doctest target and total 761 passed, 16 failed and 41 ignored. The bundled title logged a passing MFPlat reset check. **Workspace failures and skips** The library had 15 shader-recompiler failures. Eleven reported `CreateComputePipelineState` returning `0x80070057`, and four reported output mismatches. The end-to-end title test failed its dynamic depth-bias check. The log contains 6 lines beginning with `SKIPPED `. Two cited wave64, two cited the D3D12 debug layer, one cited tiled resource tier and one cited heap windows. Those skips provide no coverage. **Not tested** A matched main run, retail-title smoke or playback, other GPU vendors, and forced device removal during a companion reset. **AI use** T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against `pr1677-suite.log` and published.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1677/head:github-bot/gh-1677'
git switch 'github-bot/gh-1677'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1677'
git switch 'github-bot/gh-1677'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1677'
git switch 'github-bot/gh-1677'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1677'
git switch 'main'
git merge --squash 'github-bot/gh-1677'
git switch 'main'
git merge --ff-only 'github-bot/gh-1677'
git switch 'main'
git merge 'github-bot/gh-1677'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.