Skip to content

dxgi: resolve monitor ownership without creating a native factory per lookup - #8620

Closed
LukeOsland1 wants to merge 3 commits into
ProjectLeonida:mainfrom
LukeOsland1:codex/dxgi-output-owner-displayconfig
Closed

LukeOsland1 wants to merge 3 commits into
ProjectLeonida:mainfrom
LukeOsland1:codex/dxgi-output-owner-displayconfig

Conversation

@LukeOsland1

Copy link
Copy Markdown
Contributor

Depends on: #7020

Coordination claim.

The output-ownership fix in #7020 creates a system DXGI factory for each EnumOutputs lookup. The Vulkan shim can get the same adapter LUID directly from the monitor's GDI display source using D3DKMTOpenAdapterFromGdiDisplayName. The lookup closes each adapter handle immediately and retains the existing fallback if Windows cannot resolve a source.

The regression compares the full set of attached HMONITORs with system DXGI and rejects duplicates. A negative-control build that returned monitor 0 again for index 1 failed on the two-monitor RTX even though the original index-0 comparison matched.

Adapter, Windows driver Parent mean lookup Branch mean lookup Native monitor comparison
RTX 4070 Ti SUPER, 32.0.16.1088 254.1 µs 71.6 µs Both monitors matched
Integrated AMD Radeon, 32.0.21042.62 287.1 µs 84.7 µs Zero outputs, matching native DXGI

Local measurements from 64 consecutive EnumOutputs(0) calls per configuration with a temporary timer, parent a81b62b, branch implementation at da32a0b. On a clean build of the submitted sources, dxgi_device_test passed all three backends for each selection. dxgi_swapchain_test passed on each GPU with Vulkan validation enabled and zero validation errors.

AI-assisted with Codex. Synthetic tests only.

@shdann

shdann commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested da32a0b on Windows 11. Monitor lookup is faster on both adapters. The swapchain test passes on the parent and on the PR with zero Vulkan validation errors.

I timed 256 consecutive calls to EnumOutputs(0) with QueryPerformanceCounter. The loop releases each returned output. Each number is the mean time per call in a separate process, in microseconds. The run order was parent, PR, PR, parent for each adapter.

Adapter Parent a81b62b PR da32a0b Lookup result
RTX 4090 135.95, 236.72 71.45, 32.96 S_OK
AMD Radeon iGPU 219.99, 150.10 57.19, 26.27 DXGI_ERROR_NOT_FOUND

I built the same instrumented dxgi_swapchain_test in RelWithDebInfo for both revisions and ran ctest -C RelWithDebInfo -R "^dxgi_swapchain$" -V. I enabled validation and selected the Vulkan adapter with VK_LOADER_DRIVERS_DISABLE (*amd* for NVIDIA, *nv* for AMD). I checked each device line. The timings cover output lookup and release only.

AI-assisted.

@lohant27-netizen

Copy link
Copy Markdown

Tested da32a0b6c on Windows 11 (10.0.26300), NVIDIA GeForce RTX 5070 (driver 32.0.16.2101, subgroup 32), MSVC with SDK 10.0.26100, Release, merged onto main 867d922f0 together with #8599, #8589, #8591, #8620, #8569 and #8622 (no conflicts): pass.

@RAINighty

Copy link
Copy Markdown

Tested da32a0b6c merged with main 867d922f0 (clean merge) on Windows 11 (10.0.26300), Intel Core i7-14650HX, hybrid-GPU laptop (RTX 5060 + Intel UHD, no adapter forced), MSVC 19.44.35228, RelWithDebInfo (Ninja): pass.

  • dxgi_swapchain and dxgi_swapchain_count pass with this PR (2 of 2).
  • Negative control: this PR's dxgi_swapchain_test.cpp with main's runtime/shims/dxgi_com.cpp: dxgi_swapchain fails, dxgi_swapchain_count still passes, so the new test does catch the change.
  • Code not reviewed beyond running it. No game files.

AI-assisted (Claude Code).

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.

6 participants