[PR #2046] runtime: guard null out pointers, add inspection helpers and unit tests for PlacedDepthTextures (RT-XS-PLACED-DEPTH-GUARDS-AND-TESTS) #2052

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2046
Author: @abnalstlll-byte
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: feat/rt-xs-placed-depth-guards-and-tests


📝 Commits (1)

  • 0233a9e runtime: guard null out pointers, add inspection helpers and unit tests for PlacedDepthTextures (RT-XS-PLACED-DEPTH-GUARDS-AND-TESTS)

📊 Changes

3 files changed (+335 additions, -1 deletions)

View changed files

📝 runtime/CMakeLists.txt (+8 -0)
📝 runtime/shims/d3d12_xs_placed_depth.h (+23 -1)
➕ runtime/test/d3d12_xs_placed_depth_test.cpp (+304 -0)

📄 Description

Claimed in the coordination issue as: RT-XS-PLACED-DEPTH-GUARDS-AND-TESTS (claim)

What and why

runtime/shims/d3d12_xs_placed_depth.h manages GPU backing for slot-133 depth/UAV textures keyed by Xbox placement ranges.

  1. Null out pointer guards:

    • PlacedDepthTextures::create: If out is null, returns E_POINTER immediately before attempting any allocations or lookups.
    • If out is non-null, sets *out = nullptr at entry so failures (E_INVALIDARG, E_NOTIMPL, or backing creation failures) guarantee callers receive null.
  2. Inspection and cleanup helpers:

    • Added clear(), size(), and empty() to PlacedDepthTextures (marking mutex_ mutable for const query methods).
  3. Portability:

    • Supports MinGW and MSVC COM virtual dispatch signatures for ID3D12Resource::GetDesc in PlacedDepthTexture.
  4. Unit test suite (runtime/test/d3d12_xs_placed_depth_test.cpp):

    • 46 assertions covering:
      • Null out pointer returning E_POINTER.
      • Invalid arguments (address == 0, Alignment == 0, unaligned address, SizeInBytes == 0, address+size overflow) setting *out = nullptr and returning E_INVALIDARG.
      • create_backing failure propagation and clearing *out.
      • Valid creation, GPU VA verification, and texture_backing resolution.
      • QueryInterface forwarding (kVulkanResourceTag delegating to backing, ID3D12Resource returning wrapper).
      • Identical placement aliasing (sharing backing, distinct COM identities).
      • Refusal of incompatible shapes with non-opaque layouts (E_NOTIMPL).
      • Refusal of overlapping non-opaque layouts (E_NOTIMPL).
      • Separate backings for alternating shapes under opaque layouts.
      • Weak reference expiration (std::erase_if) when all aliases are released.
      • clear() and empty().
      • OptimizedClear mismatch refusal.

Registers d3d12_xs_placed_depth_test and CTest in runtime/CMakeLists.txt.

Tested

  • Unit test execution: 46/46 checks passed (0 failures).
  • python -I tests/test_ci_registration.py: 16/16 pass.
  • python -I tests/test_text_write_line_endings.py: 3/3 pass.
  • python -I scripts/check_no_game_data.py: clean (0 violations, no game data).

AI-assisted (Claude Code)


🔄 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/2046 **Author:** [@abnalstlll-byte](https://github.com/abnalstlll-byte) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/rt-xs-placed-depth-guards-and-tests` --- ### 📝 Commits (1) - [`0233a9e`](https://github.com/ubiquitarianism/leonida/commit/0233a9ec735c670242d8039341f406d1d4ff97d5) runtime: guard null out pointers, add inspection helpers and unit tests for PlacedDepthTextures (RT-XS-PLACED-DEPTH-GUARDS-AND-TESTS) ### 📊 Changes **3 files changed** (+335 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `runtime/CMakeLists.txt` (+8 -0) 📝 `runtime/shims/d3d12_xs_placed_depth.h` (+23 -1) ➕ `runtime/test/d3d12_xs_placed_depth_test.cpp` (+304 -0) </details> ### 📄 Description Claimed in the coordination issue as: RT-XS-PLACED-DEPTH-GUARDS-AND-TESTS ([claim](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7171516197)) ### What and why `runtime/shims/d3d12_xs_placed_depth.h` manages GPU backing for slot-133 depth/UAV textures keyed by Xbox placement ranges. 1. **Null out pointer guards**: - `PlacedDepthTextures::create`: If `out` is null, returns `E_POINTER` immediately before attempting any allocations or lookups. - If `out` is non-null, sets `*out = nullptr` at entry so failures (`E_INVALIDARG`, `E_NOTIMPL`, or backing creation failures) guarantee callers receive null. 2. **Inspection and cleanup helpers**: - Added `clear()`, `size()`, and `empty()` to `PlacedDepthTextures` (marking `mutex_` mutable for const query methods). 3. **Portability**: - Supports MinGW and MSVC COM virtual dispatch signatures for `ID3D12Resource::GetDesc` in `PlacedDepthTexture`. 4. **Unit test suite (`runtime/test/d3d12_xs_placed_depth_test.cpp`)**: - 46 assertions covering: - Null `out` pointer returning `E_POINTER`. - Invalid arguments (`address == 0`, `Alignment == 0`, unaligned address, `SizeInBytes == 0`, address+size overflow) setting `*out = nullptr` and returning `E_INVALIDARG`. - `create_backing` failure propagation and clearing `*out`. - Valid creation, GPU VA verification, and `texture_backing` resolution. - `QueryInterface` forwarding (`kVulkanResourceTag` delegating to backing, `ID3D12Resource` returning wrapper). - Identical placement aliasing (sharing backing, distinct COM identities). - Refusal of incompatible shapes with non-opaque layouts (`E_NOTIMPL`). - Refusal of overlapping non-opaque layouts (`E_NOTIMPL`). - Separate backings for alternating shapes under opaque layouts. - Weak reference expiration (`std::erase_if`) when all aliases are released. - `clear()` and `empty()`. - `OptimizedClear` mismatch refusal. Registers `d3d12_xs_placed_depth_test` and CTest in `runtime/CMakeLists.txt`. ### Tested - Unit test execution: `46/46 checks passed` (0 failures). - `python -I tests/test_ci_registration.py`: 16/16 pass. - `python -I tests/test_text_write_line_endings.py`: 3/3 pass. - `python -I scripts/check_no_game_data.py`: clean (0 violations, no game data). AI-assisted (Claude Code) --- <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#2052
No description provided.