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

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

@⁠abnalstlll-byte on GitHub · 2026-11-25 18:56 UTC · original
abnalstlll-byte:feat/rt-xs-placed-depth-guards-and-tests → main · +335 −1 · 3 files · 1 commits · open

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)

**@⁠abnalstlll-byte** on GitHub · 2026-11-25 18:56 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2046) `abnalstlll-byte:feat/rt-xs-placed-depth-guards-and-tests` → `main` · +335 −1 · 3 files · 1 commits · open Claimed in the coordination issue as: RT-XS-PLACED-DEPTH-GUARDS-AND-TESTS ([claim](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608)) ### 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)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:15:58 +00:00
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/2046/head:github-bot/gh-2046'
git switch 'github-bot/gh-2046'

Merge

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