[PR #438] d3d12: implement ID3D12Device5::CreateLifetimeTracker and ID3D12LifetimeTracker::DestroyOwnedObject (D3D-LIFETIME-TRACKER) #489

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

📋 Pull Request Information

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

Base: main ← Head: pr/d3d12-lifetime-tracker


📝 Commits (1)

  • 811039f d3d12: implement ID3D12Device5::CreateLifetimeTracker and ID3D12LifetimeTracker::DestroyOwnedObject

📊 Changes

3 files changed (+280 additions, -4 deletions)

View changed files

📝 runtime/CMakeLists.txt (+9 -0)
📝 runtime/shims/d3d12_vulkan_device.cpp (+48 -4)
➕ runtime/test/d3d12_lifetime_tracker_test.cpp (+223 -0)

📄 Description

Claimed in the coordination issue as: D3D-LIFETIME-TRACKER (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7122816234)

What and why

Implements PC ID3D12Device5::CreateLifetimeTracker and ID3D12LifetimeTracker::DestroyOwnedObject in the Vulkan D3D12 shim (runtime/shims/d3d12_vulkan_device.cpp), replacing the E_NOTIMPL stub.

  • Adds LifetimeTracker (ID3D12LifetimeTracker / ID3D12DeviceChild / ID3D12Object) holding a non-owning ID3D12LifetimeOwner* pointer (matching Windows D3D12, which does not AddRef the owner at creation).
  • Matches Windows 11 D3D12 (d3d12.dll) parameter validation on CreateLifetimeTracker:
    • owner == nullptr → E_INVALIDARG (0x80070057)
    • out == nullptr → E_UNEXPECTED (0x8000FFFF)
    • unknown riid → E_NOINTERFACE (0x80004002)
    • valid create → S_OK, owner refcount delta (+0 -> +0), 0 callbacks at creation, GetDevice returns the owning device.
  • Implements DestroyOwnedObject(ID3D12DeviceChild*): rejects nullptr and foreign-device objects with E_INVALIDARG, drains submitted Vulkan work (vkDeviceWaitIdle under submit_mutex()), and invokes owner->LifetimeStateUpdated(D3D12_LIFETIME_STATE_NOT_IN_USE).
  • Adds d3d12_lifetime_tracker_test comparing our Vulkan device side-by-side against host Windows D3D12 (WARP).
  • Note: this implements the PC ID3D12Device5 / ID3D12LifetimeTracker contract; it does not make any assumptions about Xbox Series device slot 57 semantics beyond PC fallback.

Tested

  • Built d3d12_lifetime_tracker_test and d3d12_existing_heap_test with MSVC 19.44 (vcvars64) + Ninja on top of main 8f481cf16.
  • d3d12_lifetime_tracker_test: ALL CHECKS PASSED — EXACT MATCH against host Windows D3D12 (WARP) on CreateLifetimeTracker error codes, refcounting, and GetDevice, plus DestroyOwnedObject valid/null/foreign-device checks on Vulkan.
  • d3d12_existing_heap_test: PASSED — existing-heap and lifetime-tracker refusal checks match both host GTX 1650 D3D12 and WARP (8/8 OpenExistingHeapFromAddress cases match).
  • py -3.13 -I scripts/check_no_game_data.py runtime/shims/d3d12_vulkan_device.cpp runtime/test/d3d12_lifetime_tracker_test.cpp runtime/CMakeLists.txt: clean.

GPUs tested: NVIDIA GeForce GTX 1650 (driver 592.00, Windows 11 26200) and Microsoft WARP (d3d12.dll, Windows 11 26200)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • 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 — runtime D3D12 shim only)

🔄 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/438 **Author:** [@jujumoneylol](https://github.com/jujumoneylol) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `pr/d3d12-lifetime-tracker` --- ### 📝 Commits (1) - [`811039f`](https://github.com/ubiquitarianism/leonida/commit/811039f96f2c6e43867cd559bae1437c14f0100c) d3d12: implement ID3D12Device5::CreateLifetimeTracker and ID3D12LifetimeTracker::DestroyOwnedObject ### 📊 Changes **3 files changed** (+280 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `runtime/CMakeLists.txt` (+9 -0) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+48 -4) ➕ `runtime/test/d3d12_lifetime_tracker_test.cpp` (+223 -0) </details> ### 📄 Description Claimed in the coordination issue as: D3D-LIFETIME-TRACKER (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7122816234) ### What and why Implements PC `ID3D12Device5::CreateLifetimeTracker` and `ID3D12LifetimeTracker::DestroyOwnedObject` in the Vulkan D3D12 shim (`runtime/shims/d3d12_vulkan_device.cpp`), replacing the `E_NOTIMPL` stub. - Adds `LifetimeTracker` (`ID3D12LifetimeTracker` / `ID3D12DeviceChild` / `ID3D12Object`) holding a non-owning `ID3D12LifetimeOwner*` pointer (matching Windows D3D12, which does not `AddRef` the owner at creation). - Matches Windows 11 D3D12 (`d3d12.dll`) parameter validation on `CreateLifetimeTracker`: - `owner == nullptr` → `E_INVALIDARG` (`0x80070057`) - `out == nullptr` → `E_UNEXPECTED` (`0x8000FFFF`) - unknown `riid` → `E_NOINTERFACE` (`0x80004002`) - valid create → `S_OK`, owner refcount delta `(+0 -> +0)`, 0 callbacks at creation, `GetDevice` returns the owning device. - Implements `DestroyOwnedObject(ID3D12DeviceChild*)`: rejects `nullptr` and foreign-device objects with `E_INVALIDARG`, drains submitted Vulkan work (`vkDeviceWaitIdle` under `submit_mutex()`), and invokes `owner->LifetimeStateUpdated(D3D12_LIFETIME_STATE_NOT_IN_USE)`. - Adds `d3d12_lifetime_tracker_test` comparing our Vulkan device side-by-side against host Windows D3D12 (WARP). - Note: this implements the PC `ID3D12Device5` / `ID3D12LifetimeTracker` contract; it does not make any assumptions about Xbox Series device slot 57 semantics beyond PC fallback. ### Tested - Built `d3d12_lifetime_tracker_test` and `d3d12_existing_heap_test` with MSVC 19.44 (`vcvars64`) + Ninja on top of `main` `8f481cf16`. - `d3d12_lifetime_tracker_test`: ALL CHECKS PASSED — `EXACT MATCH` against host Windows D3D12 (WARP) on `CreateLifetimeTracker` error codes, refcounting, and `GetDevice`, plus `DestroyOwnedObject` valid/null/foreign-device checks on Vulkan. - `d3d12_existing_heap_test`: PASSED — existing-heap and lifetime-tracker refusal checks match both host GTX 1650 D3D12 and WARP (8/8 `OpenExistingHeapFromAddress` cases match). - `py -3.13 -I scripts/check_no_game_data.py runtime/shims/d3d12_vulkan_device.cpp runtime/test/d3d12_lifetime_tracker_test.cpp runtime/CMakeLists.txt`: clean. GPUs tested: NVIDIA GeForce GTX 1650 (driver 592.00, Windows 11 26200) and Microsoft WARP (`d3d12.dll`, Windows 11 26200) AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a — runtime D3D12 shim only) --- <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#489
No description provided.