[PR #869] runtime: D3D12.X command submission, multi-segment sync points, and Vulkan presentation swapchain #907

Open
opened 2026-11-26 20:19:27 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/869
Author: @Tortoche
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: feat/d3d12x-execute-command-lists


📝 Commits (2)

  • 4ff2c49 runtime: D3D12.X command submission, multi-segment sync points, and Vulkan presentation swapchain (Phase 1 / Axe 1)
  • e6a069a runtime/presenter: unlock mutex before frame callback and validate reset_cmd_buf dispatch

📊 Changes

9 files changed (+5065 additions, -2 deletions)

View changed files

📝 runtime/CMakeLists.txt (+13 -0)
➕ runtime/shims/d3d12_x.cpp (+1140 -0)
➕ runtime/shims/d3d12_x.h (+472 -0)
📝 runtime/src/command_list.h (+1 -2)
➕ runtime/src/vulkan_device.cpp (+867 -0)
➕ runtime/src/vulkan_device.h (+348 -0)
➕ runtime/src/vulkan_presenter.cpp (+975 -0)
➕ runtime/src/vulkan_presenter.h (+292 -0)
➕ runtime/test/d3d12_x_stress_test.cpp (+957 -0)

📄 Description

Claimed in the coordination issue as: RUNTIME-D3D12X-EXECUTE (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135050832)

What and why

  1. D3D12.X Command Submission (CommandQueueX):

    • Implements ExecuteCommandListsX, wrapping ID3D12CommandQueue with extended metadata parsing and command list unwrapping.
    • Decouples CPU command dispatch from GPU completion by deferring D3D12 fence signaling until the Vulkan queue/fence actually retires, eliminating race conditions and premature CPU completion bugs.
  2. Multi-Segment Sync Point Splitting:

    • Vulkan queue submissions require splitting batches into multiple segments whenever intermediate synchronization points occur.
    • Implements automatic segment grouping, preserving wait/signal dependency ordering across command lists.
  3. Vulkan Presentation Swapchain:

    • Provides VulkanPresentationSwapchain with robust surface creation, format negotiation, and clean resource deallocation on window resize (preventing fence/semaphore leaks).
    • Includes automatic headless fallback when running in displayless or virtualized environments.
    • Releases presenter lock prior to invoking frame callbacks to eliminate lock reentrancy hazards.
  4. Empirical Regression & Stress Tests:

    • Implements runtime/test/d3d12_x_stress_test.cpp covering 9 comprehensive test cases: multi-threaded command recording, 64-list batch submissions, queue flushes, headless swapchain lifecycle, sync point placement, and resource leak regression checks.

Tested

  • Linux / GCC: CTest / CMake build target d3d12_x_stress_test passes 9/9 tests with 0 failures:
    • test_command_list_recording_stress: PASSED
    • test_command_list_concurrent_recording: PASSED
    • test_execute_command_lists_x_multiple_lists: PASSED
    • test_queue_flushes_and_frame_boundaries: PASSED
    • test_headless_presentation_swapchain: PASSED
    • test_headless_detection_environment: PASSED
    • test_bug_sync_point_wait_placement: PASSED
    • test_bug_premature_cpu_fence_signal: PASSED
    • test_bug_swapchain_resize_resource_leak: PASSED
  • Line endings compliant (newline="\n").
  • scripts/check_no_game_data.py: 0 violations.

AI-assisted: yes.

Checklist

  • Based on current main and merges cleanly.
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md).
  • Portable subset builds cleanly under Linux.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/869 **Author:** [@Tortoche](https://github.com/Tortoche) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/d3d12x-execute-command-lists` --- ### 📝 Commits (2) - [`4ff2c49`](https://github.com/ubiquitarianism/leonida/commit/4ff2c49b14af6f02f040a3e06753aeeb34c1dc33) runtime: D3D12.X command submission, multi-segment sync points, and Vulkan presentation swapchain (Phase 1 / Axe 1) - [`e6a069a`](https://github.com/ubiquitarianism/leonida/commit/e6a069a620fe4338930f2662d852cfa17233a352) runtime/presenter: unlock mutex before frame callback and validate reset_cmd_buf dispatch ### 📊 Changes **9 files changed** (+5065 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `runtime/CMakeLists.txt` (+13 -0) ➕ `runtime/shims/d3d12_x.cpp` (+1140 -0) ➕ `runtime/shims/d3d12_x.h` (+472 -0) 📝 `runtime/src/command_list.h` (+1 -2) ➕ `runtime/src/vulkan_device.cpp` (+867 -0) ➕ `runtime/src/vulkan_device.h` (+348 -0) ➕ `runtime/src/vulkan_presenter.cpp` (+975 -0) ➕ `runtime/src/vulkan_presenter.h` (+292 -0) ➕ `runtime/test/d3d12_x_stress_test.cpp` (+957 -0) </details> ### 📄 Description Claimed in the coordination issue as: RUNTIME-D3D12X-EXECUTE (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135050832) ### What and why 1. **D3D12.X Command Submission (`CommandQueueX`)**: - Implements `ExecuteCommandListsX`, wrapping `ID3D12CommandQueue` with extended metadata parsing and command list unwrapping. - Decouples CPU command dispatch from GPU completion by deferring D3D12 fence signaling until the Vulkan queue/fence actually retires, eliminating race conditions and premature CPU completion bugs. 2. **Multi-Segment Sync Point Splitting**: - Vulkan queue submissions require splitting batches into multiple segments whenever intermediate synchronization points occur. - Implements automatic segment grouping, preserving wait/signal dependency ordering across command lists. 3. **Vulkan Presentation Swapchain**: - Provides `VulkanPresentationSwapchain` with robust surface creation, format negotiation, and clean resource deallocation on window resize (preventing fence/semaphore leaks). - Includes automatic headless fallback when running in displayless or virtualized environments. - Releases presenter lock prior to invoking frame callbacks to eliminate lock reentrancy hazards. 4. **Empirical Regression & Stress Tests**: - Implements `runtime/test/d3d12_x_stress_test.cpp` covering 9 comprehensive test cases: multi-threaded command recording, 64-list batch submissions, queue flushes, headless swapchain lifecycle, sync point placement, and resource leak regression checks. ### Tested - Linux / GCC: CTest / CMake build target `d3d12_x_stress_test` passes 9/9 tests with 0 failures: - `test_command_list_recording_stress`: PASSED - `test_command_list_concurrent_recording`: PASSED - `test_execute_command_lists_x_multiple_lists`: PASSED - `test_queue_flushes_and_frame_boundaries`: PASSED - `test_headless_presentation_swapchain`: PASSED - `test_headless_detection_environment`: PASSED - `test_bug_sync_point_wait_placement`: PASSED - `test_bug_premature_cpu_fence_signal`: PASSED - `test_bug_swapchain_resize_resource_leak`: PASSED - Line endings compliant (`newline="\n"`). - `scripts/check_no_game_data.py`: 0 violations. AI-assisted: yes. ### Checklist - [x] Based on current main and merges cleanly. - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md). - [x] Portable subset builds cleanly under Linux. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#907
No description provided.