Skip to content

dxgi: implement CreateSwapChainForCoreWindow and occlusion status registration - #1761

Merged
ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
SHAURYASANYAL3:feat/dxgi-corewindow-swapchain
Nov 22, 2026
Merged

ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
SHAURYASANYAL3:feat/dxgi-corewindow-swapchain

Conversation

@SHAURYASANYAL3

Copy link
Copy Markdown
Contributor

Summary

Xbox Series X|S (Scarlett) titles run within the Game Core / UWP container model, where games initialize graphics through \IDXGIFactory2::CreateSwapChainForCoreWindow(pDevice, pCoreWindow, ...)\ rather than raw Win32 HWNDs (\CreateSwapChainForHwnd). Additionally, engines check window minimization and occlusion through \RegisterOcclusionStatusWindow\ / \RegisterOcclusionStatusEvent.

Previously, both calls returned \E_NOTIMPL\ in
untime/shims/dxgi_com.cpp.

Changes

  1. \CreateSwapChainForCoreWindow\ (
    untime/shims/dxgi_com.cpp)
    :
    • Validates parameters (\out, \device, \window, \desc).
    • Queries \ICoreWindowInterop\ ({45D64A29-A63E-4CB6-B498-5781D298CB4F}) from the passed \IUnknown*\ window to retrieve the underlying Win32 \HWND\ via \get_WindowHandle.
    • Returns \DXGI_ERROR_INVALID_CALL\ if \ICoreWindowInterop\ is missing or produces a null \HWND.
    • Delegates directly to \CreateSwapChainForHwnd\ once the \HWND\ is obtained.
  2. Occlusion status registration (
    untime/shims/dxgi_com.cpp)
    :
    • Implements \RegisterOcclusionStatusWindow\ and \RegisterOcclusionStatusEvent, validating inputs and returning \S_OK\ with sequential cookies via
      ext_occlusion_cookie_.
    • \UnregisterOcclusionStatus\ completes cleanly as a no-op.
  3. Tests (
    untime/test/dxgi_swapchain_test.cpp)
    :
    • Added synthetic \MockCoreWindow\ implementing \IUnknown\ and \ICoreWindowInterop.
    • Covers parameter validation: !out\ (\E_POINTER), null device/window/desc (\E_INVALIDARG), non-interop window (\DXGI_ERROR_INVALID_CALL), and null HWND (\DXGI_ERROR_INVALID_CALL).
    • Validates successful CoreWindow swapchain creation and \Present(0, 0)\ through the mock.
    • Tests \RegisterOcclusionStatusWindow\ and \RegisterOcclusionStatusEvent\ invalid/valid parameter handling and unique cookie assignment.

No game files. Synthetic tests only.

…istration

Implements CreateSwapChainForCoreWindow on Factory for UWP / Game Core Scarlett titles by querying ICoreWindowInterop for the underlying Win32 HWND, and implements RegisterOcclusionStatusWindow / RegisterOcclusionStatusEvent returning sequential cookies.

Adds mock ICoreWindow unit tests in dxgi_swapchain_test covering argument validation, null HWND failure, functional swapchain presentation, and occlusion status registration.
@dcastell1

Copy link
Copy Markdown
Contributor

Tested 0904055 on RTX 5090, NVIDIA 621.24, Windows 11: pass. Built the runtime from this tree (Ninja, RelWithDebInfo) and ran ctest -R dxgi_swapchain → 1/1 passed.

@Thatters

Copy link
Copy Markdown
Contributor

Adding validation and a negative control to @dcastell1's run: 0904055f on an RTX 5070 Ti (621.24), Windows 11 Pro 25H2, MSVC 14.51 + Ninja.

  • dxgi_swapchain_test.exe with LEONIDA_D3D12=vulkan LEONIDA_VK_VALIDATION=1: PASS (CreateSwapChainForHwnd, CreateSwapChainForCoreWindow, occlusion status, GetBuffer+GetDesc, clear+readback, Present, ResizeBuffers), 0 validation errors.
  • Negative control: with runtime/shims/dxgi_com.cpp put back to the merge-base and rebuilt, the new test fails (exit 1) at CreateSwapChainForCoreWindow(null window) should return E_INVALIDARG. So it does exercise the new path.
  • Full ctest -j 4 with validation: 101/102. The one failure is d3d12_draw's bundle-blend check, which also fails on main 89b047c and is fixed by Tests: wait for the bundle blend draws in d3d12_draw (fence 21, not 4) #1793.

AI-assisted.

@kapitche

Copy link
Copy Markdown
Contributor

Tested on Windows 11 with two GPUs on one machine (runtime built from this PR's head, MSVC 14.51): no regression from this PR. RTX 4080 SUPER: 100/101 pass. d3d12_draw fails on both GPUs, but it fails the same way on every PR built on current main (bundle blend pixel (0, 0): got 255,0,0,255, expected red 64), so it's a main regression, not from this PR. I'm bisecting it now and will report in the coordination issue. Other Intel UHD 770 failures are the known ones in #1548.

@ItsNotRexed
ItsNotRexed merged commit 4d6febb into ItsNotRexed:main Nov 22, 2026
6 of 9 checks passed
@liamarguedas

Copy link
Copy Markdown

Tested 0904055 on RTX 4070 SUPER, driver 610.47, Windows 11 (MSVC 17.14, Vulkan SDK 1.4.363): full ctest 97/98, dxgi_swapchain passes including the CoreWindow and occlusion cases. The one failure is d3d12_draw (bundle blend fence), the same on main 003e781, fixed by #1807.

Two questions on the code:

  • Does the title reach CreateSwapChainForCoreWindow at all? My understanding is that Xbox Series titles present through the console D3D12 path rather than a DXGI swap chain, so it would help to know which import or trace points here.
  • RegisterOcclusionStatusWindow/Event return a cookie but never post the message or signal the event. That is fine while the window is never occluded, but a one-time [rt] log line would make it visible as a stub instead of silent success.

@mesterember104-cpu

mesterember104-cpu commented Nov 22, 2026 •

Copy link
Copy Markdown

Tested 0904055 on Intel(R) UHD Graphics (Tiger Lake (Xe-LP) iGPU 0x9a78, subgroup 8..32, no mesh), driver 32.0.101.7088, Windows 11, MSVC 14.44: pass

Full ctest (RelWithDebInfo): 85/89 passed (4 failed: d3d12_vulkan_device, d3d12_descriptor, d3d12_copy_xfmt, d3d12_draw — same environmental D3D12/WARP failures as on other PR heads on this machine, unrelated to this dxgi diff). The PR's affected test ran separately: dxgi_swapchain passes with the new paths exercised on Intel UHD — "PASS (CreateSwapChainForHwnd, CreateSwapChainForCoreWindow, occlusion status, GetBuffer+GetDesc, clear+readback, Present, ResizeBuffers; 0 validation errors)", including the MockCoreWindow validation cases.

AI-assisted (GLM, operated by the account owner).

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.

7 participants