Skip to content

HLE: implement mfplat.dll!MFResetDXGIDeviceManagerX with system fallback - #22

Merged
ivall merged 1 commit into
xcl-dev:mainfrom
raylitebull:mfplat-reset-dxgi
Nov 21, 2026
Merged

ivall merged 1 commit into
xcl-dev:mainfrom
raylitebull:mfplat-reset-dxgi

Conversation

@raylitebull

@raylitebull raylitebull commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Summary

Implements the Xbox GDK Media Foundation helper mfplat.dll!MFResetDXGIDeviceManagerX with transparent system fallback for all standard Media Foundation exports.

Changes

  • crates/xcl/src/hle/mfplat.rs:
    • Implements MFResetDXGIDeviceManagerX(pDeviceManager, pDevice, resetToken) -> HRESULT using the typed windows::Win32::Media::MediaFoundation::IMFDXGIDeviceManager COM interface (borrowing caller-owned pointers with ManuallyDrop).
    • Validates null pointers (E_POINTER) and attempts IMFDXGIDeviceManager::ResetDevice directly first (which succeeds natively for ID3D12Device on Windows 11 and preserves E_INVALIDARG for invalid reset tokens).
    • When direct ResetDevice fails for an ID3D12Device, creates a companion D3D11 device (dynamically loaded from d3d11.dll) on the matching adapter LUID with VIDEO_SUPPORT | BGRA_SUPPORT and ID3D10Multithread::SetMultithreadProtected(TRUE), then passes it to ResetDevice with the caller's resetToken.
    • Adds unit tests covering import routing/fallback, LoadLibrary + GetProcAddress, null pointer handling, invalid token rejection, real ID3D12Device reset + OpenDeviceHandle/TestDevice/CloseDeviceHandle, and the companion D3D11 bridge path.
  • crates/xcl/src/hle/mod.rs:
    • Registers MFPLAT (mfplat.dll) with system fallback &[mfplat.dll] (aliases_are_system() == false), so standard exports (MFStartup, MFCreateDXGIDeviceManager, MFCreateMediaType, etc.) resolve to Windows' mfplat.dll while MFResetDXGIDeviceManagerX resolves to XCL's HLE export and hle::opus dynamic loading remains unchanged.
  • tests/testtitle/src/gpu.rs & tests/testtitle/src/main.rs:
    • Adds an end-to-end check importing MFStartup, MFCreateDXGIDeviceManager, MFShutdown, and MFResetDXGIDeviceManagerX from mfplat.dll against the console d3d12_xs device.

Verification

  • cargo build --workspace: 0 new warnings
  • cargo test --workspace -- --test-threads=4: all tests passed (243 lib unit tests, 12 console_dlls_e2e, 1 console_shaders, 1 e2e including the new testtitle check, 6 gpu_pso_e2e, 3 xg_oracle).

@ivall

ivall commented Nov 21, 2026

Copy link
Copy Markdown
Collaborator

Reviewed and merged, thanks. It conflicted with #20 in tests/testtitle/src/main.rs (both added a check line); I merged it on main keeping both lines (your MFPlat check and the XMA2 + Opus XAudio2 line). Checked together with #21, #22 and #25 on top of current main: full workspace tests pass (277 lib tests, e2e, console_dlls_e2e, gpu_pso_e2e, rpf_e2e), no new build warnings.

@raylitebull
raylitebull deleted the mfplat-reset-dxgi branch November 22, 2026 00:37
rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 27, 2026
…wports/scissors/topo) into ListDrawRecord

List slots xcl-dev#34 (SetGraphicsRootSignature), xcl-dev#50 (OMSetRenderTargets),
xcl-dev#47 (IASetIndexBuffer), plus PC-side xcl-dev#20/xcl-dev#21/xcl-dev#22 (topology, viewports,
scissors) store into ListDrawRecord. SetPipelineState (xcl-dev#25) now merges
instead of overwriting so PSO-first or state-first order both keep the
full record. Store-only: no draw, no validation, no execute; triangle/
bias FAILs stay failing.

Evidence: new draw_s2_list_state_recorded_pre_draw fails pre-change
(S2 symbols absent at HEAD: grep count 0) and passes post; full lib
806 passed, 0 failed, 1 ignored; both cargo checks clean; title null
4 FAILs identical to HEAD-baseline worktree run (triangle, present,
bias-xcl-dev#94, all D3D12.X GPU-only, + pre-existing files:delete also on
HEAD), delta 0; Vulkan 3 (triangle, bias-xcl-dev#94 + same files:delete);
retail HOLDS (exit 139 @ exe+0x2237320, SIGSEGV fault 0, 20 stubs,
xgr XAsync/XNetworking/XUser, 0 d3d12).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants