[PR #1521] d3d12: break title buffer device reference cycle (RT-TITLE-WINDOW-CLEANUP) #1550

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1521
Author: @exoticLgk
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: fix-title-window-cleanup


📝 Commits (1)

  • d314442 d3d12: break title buffer device reference cycle

📊 Changes

2 files changed (+28 additions, -7 deletions)

View changed files

📝 runtime/shims/d3d12_vulkan_device.cpp (+9 -0)
📝 runtime/test/d3d12_draw_test.cpp (+19 -7)

📄 Description

Claimed in the coordination issue as: RT-TITLE-WINDOW-CLEANUP (#14).

What and why

Fix a COM reference cycle between the D3D12 device and its internally owned title-memory buffers.

The device retains buffers created by make_title_buffer() in title_buffers_, while each buffer retains a reference to the device. This prevents normal device destruction and resource cleanup.

With Vulkan validation enabled, both d3d12_title_index_window and d3d12_title_vertex_window previously passed despite reporting 11 leaked Vulkan objects each (VUID-vkDestroyDevice-device-05137).

This PR:

  • Removes the device back-reference from internally owned title buffers.
  • Releases retained title buffers after waiting for device idle and before draining deferred resource destruction.
  • Adds explicit resource cleanup and strict device reference-count assertions to the title-window tests.
  • Restores the strict reference-count assertion for xbox_geometry_upload_batch, previously relaxed in commit 7be70a9f5.
  • Checks Vulkan validation errors after test teardown, so destruction-time errors can no longer silently pass these tests.

Tested

Built successfully using scripts/build_runtime.ps1 on Windows.

With LEONIDA_VK_VALIDATION=1:

  • d3d12_draw: PASS
  • d3d12_title_index_window: PASS
  • d3d12_title_vertex_window: PASS
  • xbox_geometry_upload_batch: PASS

The previously observed Vulkan object leaks were no longer reported after the runtime fix. All four tests also pass with strict device reference-count assertions enabled.

Additional targeted regression tests: 10/10 passed.

Full runtime CTest suite:

  • 402 configured tests
  • 390 passed
  • 10 skipped
  • 2 disabled
  • 0 failed
  • Total runtime: 389.92 seconds

Tested against main f78385646, with a successful conflict-free merge simulation against 1cfc29af7. The newer merged tree has not been independently tested.

GPUs tested

NVIDIA GeForce RTX 4070 SUPER (12 GB)

  • Driver: 591.86
  • OS: Windows 11 Pro, build 26200
  • Vulkan SDK: 1.4.363.0

AMD, Linux and actual game execution have not been tested. XMA and SDL3-dependent GameInput coverage was unavailable in the local build.

AI-assisted

ChatGPT assisted with diagnosis, patch design, implementation, test selection and preparation of this PR. Compilation and tests were executed locally, and their actual outputs were reviewed.

Checklist

  • Claimed in the coordination issue before implementing the fix.
  • One focused topic.
  • Tested locally with Vulkan validation enabled.
  • Checked for merge conflicts against current main.
  • No game files, copyrighted game assets or generated game data included.
  • AI assistance disclosed.

No shader translator changes.


🔄 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/1521 **Author:** [@exoticLgk](https://github.com/exoticLgk) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix-title-window-cleanup` --- ### 📝 Commits (1) - [`d314442`](https://github.com/ubiquitarianism/leonida/commit/d31444234e91a2feb38aa0b7e4625a0a6f0b6b68) d3d12: break title buffer device reference cycle ### 📊 Changes **2 files changed** (+28 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+9 -0) 📝 `runtime/test/d3d12_draw_test.cpp` (+19 -7) </details> ### 📄 Description Claimed in the coordination issue as: RT-TITLE-WINDOW-CLEANUP (#14). ## What and why Fix a COM reference cycle between the D3D12 device and its internally owned title-memory buffers. The device retains buffers created by `make_title_buffer()` in `title_buffers_`, while each buffer retains a reference to the device. This prevents normal device destruction and resource cleanup. With Vulkan validation enabled, both `d3d12_title_index_window` and `d3d12_title_vertex_window` previously passed despite reporting 11 leaked Vulkan objects each (`VUID-vkDestroyDevice-device-05137`). This PR: - Removes the device back-reference from internally owned title buffers. - Releases retained title buffers after waiting for device idle and before draining deferred resource destruction. - Adds explicit resource cleanup and strict device reference-count assertions to the title-window tests. - Restores the strict reference-count assertion for `xbox_geometry_upload_batch`, previously relaxed in commit `7be70a9f5`. - Checks Vulkan validation errors after test teardown, so destruction-time errors can no longer silently pass these tests. ## Tested Built successfully using `scripts/build_runtime.ps1` on Windows. With `LEONIDA_VK_VALIDATION=1`: - `d3d12_draw`: PASS - `d3d12_title_index_window`: PASS - `d3d12_title_vertex_window`: PASS - `xbox_geometry_upload_batch`: PASS The previously observed Vulkan object leaks were no longer reported after the runtime fix. All four tests also pass with strict device reference-count assertions enabled. Additional targeted regression tests: 10/10 passed. Full runtime CTest suite: - 402 configured tests - 390 passed - 10 skipped - 2 disabled - 0 failed - Total runtime: 389.92 seconds Tested against main `f78385646`, with a successful conflict-free merge simulation against `1cfc29af7`. The newer merged tree has not been independently tested. ## GPUs tested NVIDIA GeForce RTX 4070 SUPER (12 GB) - Driver: 591.86 - OS: Windows 11 Pro, build 26200 - Vulkan SDK: 1.4.363.0 AMD, Linux and actual game execution have not been tested. XMA and SDL3-dependent GameInput coverage was unavailable in the local build. ## AI-assisted ChatGPT assisted with diagnosis, patch design, implementation, test selection and preparation of this PR. Compilation and tests were executed locally, and their actual outputs were reviewed. ## Checklist - [x] Claimed in the coordination issue before implementing the fix. - [x] One focused topic. - [x] Tested locally with Vulkan validation enabled. - [x] Checked for merge conflicts against current main. - [x] No game files, copyrighted game assets or generated game data included. - [x] AI assistance disclosed. No shader translator changes. --- <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#1550
No description provided.