Skip to content

dxgi: MakeWindowAssociation refuses unknown flag bits (host-measured) - #2822

Merged
ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
bobcatchris:fix/dxgi-make-window-association
Nov 22, 2026
Merged

ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
bobcatchris:fix/dxgi-make-window-association

Conversation

@bobcatchris

Copy link
Copy Markdown
Contributor

IDXGIFactory::MakeWindowAssociation answered S_OK for every Flags value, while the host rejects anything outside the three documented bits.

Host measurements

Probe against the system dxgi on Windows 11, RX 7900 XTX:

flags host result
0x0, 0x1 (NO_WINDOW_CHANGES), 0x2 (NO_ALT_ENTER), 0x4 (NO_PRINT_SCREEN), 0x3, 0x5, 0x6, 0x7 S_OK
0x8 DXGI_ERROR_INVALID_CALL
0x40 DXGI_ERROR_INVALID_CALL

Fix

MakeWindowAssociation returns DXGI_ERROR_INVALID_CALL for any bit outside DXGI_MWA_NO_WINDOW_CHANGES | DXGI_MWA_NO_ALT_ENTER | DXGI_MWA_NO_PRINT_SCREEN and records the window only for an accepted call.

Test

dxgi_swapchain_test.exe now checks all three known bits together (S_OK) and rejects 0x8, 0x40 and 0x7 | 0x8.

dxgi_swapchain_test: PASS (CreateSwapChainForHwnd, CreateSwapChainForCoreWindow, occlusion status,
                      GetBuffer+GetDesc, clear+readback, Present, ResizeBuffers; 0 validation errors)

RX 7900 XTX (RDNA3), Windows 11, MSVC 19.39, RelWithDebInfo. No game files.

AI-assisted.

@tupacfan04

Copy link
Copy Markdown
Contributor

Code read of 56c0e6ca (I didn't build it). Looks right. Masking with the three documented DXGI_MWA_* bits and returning DXGI_ERROR_INVALID_CALL before storing the window matches the measured host behaviour, so a refused call also leaves GetWindowAssociation unchanged.

AI-assisted review (Claude Code).

@Yourrespawn

Copy link
Copy Markdown
Contributor

Independently reproduced the host measurement on a different GPU vendor (standalone probe against the system dxgi, Windows 11 Pro 10.0.26200, NVIDIA GeForce RTX 4080, driver 617.14): the table matches exactly.

  • 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 → S_OK (0x00000000)
  • 0x8 and 0x40 → DXGI_ERROR_INVALID_CALL (0x887A0001)
  • Probe also tried 0x10 and 0x20 (not in the PR's table): both DXGI_ERROR_INVALID_CALL, consistent with the fix's rule — any bit outside the three documented MWA bits is refused.

So the flag validation is host-dxgi behavior, GPU-vendor-independent as expected, and the one-line fix (flags & ~known → DXGI_ERROR_INVALID_CALL, record the window only on success) reproduces it precisely. The test additions cover all three known bits together plus three rejected values.

This is the host-side behavior check; I have not built the shim itself, so the dxgi_swapchain_test run quoted in the PR is the author's.

AI-assisted (ZCode agent): the probe was written and run by a coding agent on this machine.

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified against current main (16282101) with a host DXGI probe: mask 0x7 equals SDK DXGI_MWA_VALID; flags 0-7 return S_OK, 0x8/0x40/0xF return DXGI_ERROR_INVALID_CALL. The code rejects before storing. Synthetic swapchain only; no game data or absolute paths. Approve.

Nit: use DXGI_MWA_VALID in the test and assert GetWindowAssociation is unchanged after a rejected call.

@JRamos1993

Copy link
Copy Markdown
Contributor

Tested 56c0e6c merged onto main 77444fa on an RTX 5090 (driver 616.92), Windows 11, MSVC 19.44, Vulkan SDK 1.4.363, RelWithDebInfo:

  • Full ctest: 130/130.
  • dxgi_swapchain: passes 20 of 20 runs, and passes under LEONIDA_VK_VALIDATION=1 with 0 validation messages.
  • Warnings: none new in the files this PR changes.

AI-assisted (Claude Code).

@zzEmmazz

Copy link
Copy Markdown
Contributor

Tested 56c0e6ca, applied alone on main 77444fa0: pass. Windows 11 (26200), MSVC 14.50 (VS 2026), Ninja RelWithDebInfo. Two GPUs: Ryzen 7 9700X iGPU (RDNA2, AMD 32.0.21042.62) and RTX 3070 (NVIDIA 610.74), picked with LEONIDA_VK_DEVICE.

  • Only the test change: dxgi_swapchain_test fails on both GPUs with "MakeWindowAssociation accepted an unknown flag bit", so the new check catches the old behaviour.
  • The whole PR: exit 0 on both GPUs.

The host side, measured here on Windows 11's DXGI with a small program: flags 0, 1, 2, 4 and 7 give S_OK; 0x8, 0x10, 0x40, 0xf, 0x80000000 and 0xffffffff give DXGI_ERROR_INVALID_CALL (0x887a0001). That matches the PR.

@FaKL-Code

Copy link
Copy Markdown
Contributor

Tested 56c0e6c (merged onto main 77444fa) on NVIDIA GeForce RTX 4060 Ti, driver 610.88 (32.0.16.1088), Windows 11 26200, MSVC 14.51.36231 (VS 2026), Vulkan SDK 1.4.363.0: pass

  • Clean merge; RelWithDebInfo build with no warnings that main doesn't have.
  • ctest -j 4 (all but loader): 120/120 pass, including dxgi_swapchain, with the same 8 skips as main.
  • loader run on its own: pass.
  • With LEONIDA_VK_VALIDATION=1, every d3d12_* and dxgi_* test plus command_list and xbox_present (48 tests): no validation errors, the same as main.
  • I also checked the host rule on this PC. A local probe (not committed) called the real IDXGIFactory4::MakeWindowAssociation on Windows 11 26200:
    • 0x0, 0x1, 0x2, 0x4 and 0x7 are S_OK.
    • 0x8, 0x10, 0x40, 0xF and 0x80000000 are DXGI_ERROR_INVALID_CALL.
    • A null HWND with 0x8 is also DXGI_ERROR_INVALID_CALL, which matches the layer checking the flags before the window.
  • This PR merges cleanly with DXGI: return INVALID_CALL for an out-of-range GetBuffer index #2876, which edits the same two files.

AI-assisted (Claude).

The factory answered S_OK for every flags value, while the host rejects anything
outside DXGI_MWA_NO_WINDOW_CHANGES, DXGI_MWA_NO_ALT_ENTER and
DXGI_MWA_NO_PRINT_SCREEN with DXGI_ERROR_INVALID_CALL (measured on Windows 11
with the system DXGI), so an invalid call looked accepted. Reject unknown bits
before recording the window, and cover the accepted combinations and two unknown
bits in the swapchain test.
@bobcatchris
bobcatchris force-pushed the fix/dxgi-make-window-association branch from 56c0e6c to 32fc04a Compare November 22, 2026 19:42
@ItsNotRexed
ItsNotRexed merged commit 9a507b0 into ItsNotRexed:main Nov 22, 2026
2 of 4 checks passed
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.

8 participants