Skip to content

Runtime: DXGI factory, adapter and swapchain over Vulkan (M0) - #194

Closed
mushymeow wants to merge 1 commit into
ItsNotRexed:mainfrom
mushymeow:m0-dxgi
Closed

mushymeow wants to merge 1 commit into
ItsNotRexed:mainfrom
mushymeow:m0-dxgi

Conversation

@mushymeow

@mushymeow mushymeow commented Nov 21, 2026 •

Copy link
Copy Markdown

What and why

Adds the presentation side of the D3D12 layer and a test for milestone M0 (docs/d3d12_vulkan.md §4.5, §6).
Before this, the layer could record commands but couldn't show a frame.

  • Vulkan swapchain for a window (src/vulkan_swapchain.h) and VulkanQueue::present
  • DXGI factory (IDXGIFactory5) and one adapter (IDXGIAdapter1) describing the Vulkan device
  • DXGI swapchain (IDXGISwapChain3) on the layer's command queues; back buffers as ID3D12Resource
  • gen_d3d12_stubs.py can read several headers (for the DXGI chains), with a new unit test
  • vk_present_test: factory → adapter → swapchain → 60 frames of clear + present, last frame read back and checked

Known gaps (logged when hit): vsync only, no ResizeBuffers yet, windowed only, not yet wired into the loader.

AI-assisted (Claude); I built and ran all the tests below myself.

Tested

RTX 4090, NVIDIA 610.88, Vulkan SDK 1.4.341.1, MSVC 19.44, with LEONIDA_VK_VALIDATION=1:
vk_present_test, d3d12_com_test, d3d12_vulkan_device_test pass; ctest 8/8; test_gen_d3d12_stubs.py 7/7.

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (N/A: no translator changes)

@ItsNotRexed

Copy link
Copy Markdown
Owner

Thanks! This conflicts with what landed on main today (runtime/shims/d3d12_com.* from #164/#159/#167, and pe_loader.cpp from #122/#140), and it's core runtime code, so I'd rather not resolve it by hand. Could you rebase onto main? Please check #156 for overlapping claims first.

@mushymeow

Copy link
Copy Markdown
Author

oh sorry yea ofc!

@mushymeow

Copy link
Copy Markdown
Author

Rebased onto main, no conflicts now! The only clash was the stub generator test file someone added today,
so I merged both and kept all their tests (26/26 pass). This PR never touched pe_loader.cpp btw.

Rebuilt and retested on my 4090: vk_present_test, d3d12_com_test, d3d12_vulkan_device_test and
ctest (12/12) all pass.

Also checked #156, and it looks like Vyral1978's D3D-2 covers the same DXGI stuff and was claimed first.
Totally fine with whatever you prefer, happy to close this or move the extra bits (factory/adapter, the
test) over to theirs.

@0xTehuti 0xTehuti 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.

Independent Review & Hardware Verification (M0 Presentation Milestone)

LGTM! Verified clean build and full test execution on target hardware in an isolated worktree (D:\Workspaces\Leonida-pr194).


Hardware & Environment

  • OS: Windows 11 x64
  • GPU: NVIDIA GeForce RTX 2070 SUPER (8203 MB dedicated VRAM)
  • Driver: NVIDIA 595.79 (Vulkan 1.4.321, WDDM 3.2)
  • Toolchain:
    • MSVC 2022 (v14.44.35207 / cl.exe 19.44.35225.0)
    • CMake 4.4.0 (Ninja generator), Ninja 1.13.0
    • C++20 (/std:c++20 /W4 /permissive- /utf-8 /O2 /Zi)
    • Vulkan Headers (1.4.321)

Compiler Diagnostic Results

  • MSVC Flags: /W4 /permissive- /utf-8
  • Result: 0 errors, 0 warnings across all 88 build targets.
  • Clean code generation for D3D12/DXGI stubs (d3d12_stubs.h, dxgi_stubs.h), COM layers, shims, and test harnesses.

Test Execution Summary

Test Suite / Target Result Details
vk_present_test.exe PASSED DXGI factory -> adapter enumeration -> swapchain creation -> 60 frames cleared & presented. Frame 59 readback of 230,400 pixels exactly matched {0.2f, 0.6f, 1.0f, 1.0f} (BGRA [255, 153, 51, 255]) with 0 mismatches and 0 validation errors.
d3d12_com_test.exe PASSED 16 colour, depth and stencil texels matched; queue wait held the GPU.
d3d12_vulkan_device_test.exe PASSED Clears, zero-filled first use, uploads, texture, buffer and BC copies, and GetCopyableFootprints all matched behind the Xbox-ABI proxy.
CTest (12 / 12) PASSED 100% pass rate (loader, pe_loader, device_proxy, command_list, descriptor_table, bink_decode, bink_audio, xmem, root_signature, root_signature_oracle, d3d12_gcl8, d3d12_state_map).
test_gen_d3d12_stubs.py PASSED 26 / 26 unit tests passed in 0.063s.
python -m compileall PASSED Clean bytecode compilation for make_game.py and tools/.

Verification Details (vk_present_test)

device: NVIDIA GeForce RTX 2070 SUPER
adapter: NVIDIA GeForce RTX 2070 SUPER, 8203 MB dedicated
M0: factory, adapter and swapchain made; 60 frames cleared and presented; the last back buffer (230400 pixels) held the clear colour

AI-assisted review and verification conducted following repository guidelines (AGENTS.md).

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.

3 participants