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

Merged
abnalstlll-byte merged 2 commits from upstream-pr/1987 into main 2026-11-25 21:12:59 +00:00
abnalstlll-byte commented 2026-11-25 17:27:51 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-25T17:27:51Z.


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)

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5496019887 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1987). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-25T17:27:51Z. --- ### 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)
aslan2142 commented 2026-11-25 19:22:09 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-25T19:22:09Z.


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).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7172198319 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1987#issuecomment-7172198319). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-11-25T19:22:09Z. --- 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).
abnalstlll-byte commented 2026-11-25 20:58:40 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-25T20:58:40Z.


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)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7174443872 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1987#issuecomment-7174443872). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-25T20:58:40Z. --- 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)
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!1987
No description provided.