d3d12, test: track unbound T# refusal counts by reason and verify binding rules (RT-UNBOUND-TSHARP-REASONS) #1987

Manually merged
github merged 2 commits from gh-pr/1987/head into gh-pr/1987/base 2026-11-26 10:13:58 +00:00
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-25 17:27 UTC · original
abnalstlll-byte:feat/rt-unbound-tsharp-reasons → main · +545 −21 · 4 files · 2 commits · merged 2026-11-25 21:12 UTC

Summary

Implements per-reason refusal tracking for console descriptor heap T# binding and provides synthetic unit tests verifying binding rules as requested on the maintainer roadmap.

Item claimed in #1608: RT-UNBOUND-TSHARP-REASONS.

Key Changes

  1. runtime/shims/d3d12_vulkan_device.cpp:
    • note_refused_tsharp: tracks both total distinct slots and per-reason distinct slots and total refusal counts (UnboundTsharpTracker). Logs per-reason distinct slot count when logging a refusal.
    • ConsoleHeap: tracks refused_reasons and logs periodic summary in refresh_console_heaps (console descriptor heap 0x... unbound T#s by reason: ...) mirroring title textures diagnostic reporting.
    • bind_title_image: sets refusal reason "no texture at T# address" when !owner instead of leaving why unassigned.
    • Exposes unbound_tsharp_stats(), reset_unbound_tsharp_stats(), note_refused_tsharp_for_test(), test_bind_title_image(), and resource_image_address().
  2. runtime/shims/d3d12_com.h:
    • Declares UnboundTsharpStats, UnboundTsharpReasonStats, and inspection helpers.
    • Declares enum class TitleImage.
  3. runtime/test/d3d12_unbound_tsharp_rules_test.cpp:
    • Synthetic test covering:
      • 1D rule: dimension and layer count compatibility ("T# type or samples do not fit the texture").
      • Array rule: layer bounds ("T# names layers the texture lacks").
      • Cube rule: minimum layer requirements ("cube T# on fewer than six layers").
      • MSAA rule: sample count matching ("T# type or samples do not fit the texture").
      • Per-reason tracking: distinct slot and total refusal counts by reason.
  4. runtime/CMakeLists.txt:
    • Registers d3d12_unbound_tsharp_rules_test.

Clean-Room & Verification

  • python -I scripts/check_no_game_data.py: passed (0 game data).
  • python -I tests/test_docs_links.py: passed (16/16).
  • python -I tests/test_docs_design_rows.py: passed (5/5).
  • python -I tests/test_text_write_line_endings.py: passed (3/3).
  • python -m compileall -q make_game.py tools tests: passed.

AI-assisted (Claude Code)

**@⁠abnalstlll-byte** on GitHub · 2026-11-25 17:27 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1987) `abnalstlll-byte:feat/rt-unbound-tsharp-reasons` → `main` · +545 −21 · 4 files · 2 commits · merged 2026-11-25 21:12 UTC ### Summary Implements per-reason refusal tracking for console descriptor heap T# binding and provides synthetic unit tests verifying binding rules as requested on the maintainer roadmap. Item claimed in #1608: `RT-UNBOUND-TSHARP-REASONS`. ### Key Changes 1. **`runtime/shims/d3d12_vulkan_device.cpp`**: - `note_refused_tsharp`: tracks both total distinct slots and per-reason distinct slots and total refusal counts (`UnboundTsharpTracker`). Logs per-reason distinct slot count when logging a refusal. - `ConsoleHeap`: tracks `refused_reasons` and logs periodic summary in `refresh_console_heaps` (`console descriptor heap 0x... unbound T#s by reason: ...`) mirroring title textures diagnostic reporting. - `bind_title_image`: sets refusal reason `"no texture at T# address"` when `!owner` instead of leaving `why` unassigned. - Exposes `unbound_tsharp_stats()`, `reset_unbound_tsharp_stats()`, `note_refused_tsharp_for_test()`, `test_bind_title_image()`, and `resource_image_address()`. 2. **`runtime/shims/d3d12_com.h`**: - Declares `UnboundTsharpStats`, `UnboundTsharpReasonStats`, and inspection helpers. - Declares `enum class TitleImage`. 3. **`runtime/test/d3d12_unbound_tsharp_rules_test.cpp`**: - Synthetic test covering: - 1D rule: dimension and layer count compatibility (`"T# type or samples do not fit the texture"`). - Array rule: layer bounds (`"T# names layers the texture lacks"`). - Cube rule: minimum layer requirements (`"cube T# on fewer than six layers"`). - MSAA rule: sample count matching (`"T# type or samples do not fit the texture"`). - Per-reason tracking: distinct slot and total refusal counts by reason. 4. **`runtime/CMakeLists.txt`**: - Registers `d3d12_unbound_tsharp_rules_test`. ### Clean-Room & Verification - `python -I scripts/check_no_game_data.py`: passed (0 game data). - `python -I tests/test_docs_links.py`: passed (16/16). - `python -I tests/test_docs_design_rows.py`: passed (5/5). - `python -I tests/test_text_write_line_endings.py`: passed (3/3). - `python -m compileall -q make_game.py tools tests`: passed. AI-assisted (Claude Code)
In runtime/shims/d3d12_vulkan_device.cpp, extend note_refused_tsharp to record
both overall distinct slots and per-reason distinct slots and total refusal
counts across console descriptor heaps, matching the title texture diagnostic
breakdown in refresh_console_heaps.

Expose inspection helpers in runtime/shims/d3d12_com.h and add synthetic tests
in runtime/test/d3d12_unbound_tsharp_rules_test.cpp covering:
- 1D rule: dimension and layer count compatibility ("T# type or samples do not fit the texture")
- Array rule: layer bounds ("T# names layers the texture lacks")
- Cube rule: minimum layer requirements ("cube T# on fewer than six layers")
- MSAA rule: sample count matching ("T# type or samples do not fit the texture")
- Tracking: distinct slot and total refusal counts by reason

AI-assisted (Claude Code)
- Move UnboundTsharpTracker and unbound_tsharp_tracker() to namespace scope
  so the free functions in rt::d3d12 that call it compile correctly.
- Add non-const Device::state() overload for test_bind_title_image().
- Remove nonexistent rt::d3d12_xs::resource_proxy_real_resource() call;
  resource_image_address() now casts the ID3D12Resource pointer directly.
- Fix cube layer check in bind_title_image to verify texture layer count.
- Add D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET to test MSAA texture desc.
- All 35 checks in d3d12_unbound_tsharp_rules_test pass cleanly.

AI-assisted (Claude Code)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:13:57 +00:00
github manually merged commit a05c178708 into gh-pr/1987/base 2026-11-26 10:13:58 +00:00
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-25 19:22 UTC · original

Thanks. At 2c77fe878 the runtime doesn't build (clang-cl):

  • unbound_tsharp_tracker() is a static member of DeviceState, but the new test helpers call it at namespace scope.
  • The bind_title_image call there matches no declaration.
  • rt::d3d12_xs::resource_proxy_real_resource doesn't exist.

Please build gta6rt_d3d12_com before pushing.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠aslan2142** on GitHub · 2026-11-25 19:22 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1987#issuecomment-7172198319) Thanks. At `2c77fe878` the runtime doesn't build (clang-cl): - `unbound_tsharp_tracker()` is a static member of `DeviceState`, but the new test helpers call it at namespace scope. - The `bind_title_image` call there matches no declaration. - `rt::d3d12_xs::resource_proxy_real_resource` doesn't exist. Please build `gta6rt_d3d12_com` before pushing. AI-assisted (Claude Code, Claude Opus 5.5).
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-25 20:58 UTC · original

Fixed the reported build issues and verified with a clean local build of gta6rt_d3d12_com and the test suite:

  • Moved UnboundTsharpTracker and unbound_tsharp_tracker() to namespace scope so the test helper functions can access the tracker directly.
  • Added non-const Device::state() overload so test_bind_title_image can pass a mutable DeviceState& to bind_title_image.
  • Removed nonexistent resource_proxy_real_resource() call; resource_image_address() now casts ID3D12Resource* directly via Resource::from<Resource>.
  • Updated cube map check in bind_title_image to check texture layers (layers >= 6) before the layer overflow check, and updated test Case 3b to request 6 faces on a 4-layer texture.
  • Added D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET to the test's MSAA texture descriptor.

Built gta6rt_d3d12_com.lib and d3d12_unbound_tsharp_rules_test.exe with MSVC 19.51 / Windows SDK 10.0.26100.
All 35 checks in d3d12_unbound_tsharp_rules_test pass cleanly (0 failures).

AI-assisted (Claude Code)

**@⁠abnalstlll-byte** on GitHub · 2026-11-25 20:58 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1987#issuecomment-7174443872) Fixed the reported build issues and verified with a clean local build of `gta6rt_d3d12_com` and the test suite: - Moved `UnboundTsharpTracker` and `unbound_tsharp_tracker()` to namespace scope so the test helper functions can access the tracker directly. - Added non-const `Device::state()` overload so `test_bind_title_image` can pass a mutable `DeviceState&` to `bind_title_image`. - Removed nonexistent `resource_proxy_real_resource()` call; `resource_image_address()` now casts `ID3D12Resource*` directly via `Resource::from<Resource>`. - Updated cube map check in `bind_title_image` to check texture layers (`layers >= 6`) before the layer overflow check, and updated test Case 3b to request 6 faces on a 4-layer texture. - Added `D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET` to the test's MSAA texture descriptor. Built `gta6rt_d3d12_com.lib` and `d3d12_unbound_tsharp_rules_test.exe` with MSVC 19.51 / Windows SDK 10.0.26100. All 35 checks in `d3d12_unbound_tsharp_rules_test` pass cleanly (0 failures). AI-assisted (Claude Code)
This discussion has been locked. Commenting is limited to contributors.
No description provided.