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

Open
github-bot wants to merge 1 commit from github-bot/gh-438 into main AGit
Owner

@⁠jujumoneylol on GitHub · 2026-11-24 05:20 UTC · original
jujumoneylol:pr/d3d12-lifetime-tracker → main · +280 −4 · 3 files · 1 commits · open

Claimed in the coordination issue as: D3D-LIFETIME-TRACKER (#14)

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)
**@⁠jujumoneylol** on GitHub · 2026-11-24 05:20 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/438) `jujumoneylol:pr/d3d12-lifetime-tracker` → `main` · +280 −4 · 3 files · 1 commits · open Claimed in the coordination issue as: D3D-LIFETIME-TRACKER (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### 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)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:00:11 +00:00
Author
Owner

@⁠Sangonapou on GitHub · 2026-11-24 18:56 UTC · original

Tested 811039f9 on NVIDIA GeForce RTX 3080 Ti Laptop (Ampere), NVIDIA 621.24, Vulkan 1.4.357, Windows 11 Pro (build 26300), native Windows: pass

Built at this head with scripts\build_runtime.ps1 (MSVC 19.51, VS Build Tools 2026, Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0). No game files.

ctest -R ^d3d12_lifetime_tracker$ -V: passed, Parity against real Windows D3D12 (WARP): EXACT MATCH on CreateLifetimeTracker & refcounting, ALL CHECKS PASSED.

For whoever reviews the Destroy part, the two lines as printed here (the destroy fields differ between the layer and WARP; the parity line covers creation and refcounting):

[vulkan] null_owner=0x80070057 null_out=0x8000FFFF bad_iid=0x80004002 ok=0x00000000 owner_ref_delta=(+0 -> +0) cb_create=0 destroy_null=0x80070057 destroy_ok=0x00000000 cb_destroy=1 last_state=1 destroy_foreign=0x80070057 get_dev=1
[host-warp] null_owner=0x80070057 null_out=0x8000FFFF bad_iid=0x80004002 ok=0x00000000 owner_ref_delta=(+0 -> +0) cb_create=0 destroy_null=0x00000000 destroy_ok=0x80070057 cb_destroy=0 last_state=-1 destroy_foreign=0x00000000 get_dev=1
**@⁠Sangonapou** on GitHub · 2026-11-24 18:56 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/438#issuecomment-7141359993) Tested 811039f9 on NVIDIA GeForce RTX 3080 Ti Laptop (Ampere), NVIDIA 621.24, Vulkan 1.4.357, Windows 11 Pro (build 26300), native Windows: pass Built at this head with `scripts\build_runtime.ps1` (MSVC 19.51, VS Build Tools 2026, Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0). No game files. `ctest -R ^d3d12_lifetime_tracker$ -V`: passed, `Parity against real Windows D3D12 (WARP): EXACT MATCH on CreateLifetimeTracker & refcounting`, `ALL CHECKS PASSED`. For whoever reviews the Destroy part, the two lines as printed here (the destroy fields differ between the layer and WARP; the parity line covers creation and refcounting): ``` [vulkan] null_owner=0x80070057 null_out=0x8000FFFF bad_iid=0x80004002 ok=0x00000000 owner_ref_delta=(+0 -> +0) cb_create=0 destroy_null=0x80070057 destroy_ok=0x00000000 cb_destroy=1 last_state=1 destroy_foreign=0x80070057 get_dev=1 [host-warp] null_owner=0x80070057 null_out=0x8000FFFF bad_iid=0x80004002 ok=0x00000000 owner_ref_delta=(+0 -> +0) cb_create=0 destroy_null=0x00000000 destroy_ok=0x80070057 cb_destroy=0 last_state=-1 destroy_foreign=0x00000000 get_dev=1 ```
Author
Owner

@⁠madhyn on GitHub · 2026-11-24 22:45 UTC · original

Tested 811039f96 on Arch Linux + Wine 11.22 (clang-cl + xwin) with an NVIDIA GeForce RTX 3060 Ti:

  • d3d12_lifetime_tracker_test.exe:
    • [vulkan] (the layer): all checks passed (null_owner=0x80070057 null_out=0x8000FFFF bad_iid=0x80004002 ok=0x00000000 owner_ref_delta=(+0 -> +0) cb_create=0 destroy_null=0x80070057 destroy_ok=0x00000000 cb_destroy=1 last_state=1 destroy_foreign=0x80070057 get_dev=1).
    • [host-warp] (Wine vkd3d): failed at line 103 (FAIL [host-warp] line 103: SUCCEEDED(obs.create_ok) && tracker.p != nullptr) because Wine's vkd3d currently stubs d3d12_device_CreateLifetimeTracker.

AI-assisted: yes

**@⁠madhyn** on GitHub · 2026-11-24 22:45 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/438#issuecomment-7146602525) Tested `811039f96` on Arch Linux + Wine 11.22 (clang-cl + xwin) with an NVIDIA GeForce RTX 3060 Ti: - `d3d12_lifetime_tracker_test.exe`: - `[vulkan]` (the layer): **all checks passed** (`null_owner=0x80070057 null_out=0x8000FFFF bad_iid=0x80004002 ok=0x00000000 owner_ref_delta=(+0 -> +0) cb_create=0 destroy_null=0x80070057 destroy_ok=0x00000000 cb_destroy=1 last_state=1 destroy_foreign=0x80070057 get_dev=1`). - `[host-warp]` (Wine vkd3d): failed at line 103 (`FAIL [host-warp] line 103: SUCCEEDED(obs.create_ok) && tracker.p != nullptr`) because Wine's `vkd3d` currently stubs `d3d12_device_CreateLifetimeTracker`. AI-assisted: yes
This pull request has changes conflicting with the target branch.
  • runtime/CMakeLists.txt
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/438/head:github-bot/gh-438'
git switch 'github-bot/gh-438'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-438'
git switch 'github-bot/gh-438'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-438'
git switch 'github-bot/gh-438'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-438'
git switch 'main'
git merge --squash 'github-bot/gh-438'
git switch 'main'
git merge --ff-only 'github-bot/gh-438'
git switch 'main'
git merge 'github-bot/gh-438'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.