d3d12: never defer buffer V#s past console-fix budget (RT-CONSOLE-FIX-NEVER-DEFER-BUFFER-VSHARP) #2162

Merged
abnalstlll-byte merged 1 commit from upstream-pr/2162 into main 2026-11-26 14:41:03 +00:00
abnalstlll-byte commented 2026-11-26 00:39:34 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-26T00:39:34Z.


Claimed in Issue #1608: RT-CONSOLE-FIX-NEVER-DEFER-BUFFER-VSHARP.

What and why

In fix_console_slots() (runtime/shims/d3d12_vulkan_device.cpp), when the LEONIDA_CONSOLE_FIX_US submission budget expires (heap.fix_over == true), the code currently zeroes every remaining descriptor slot and defers them to retry_console_slots.

Nulling buffer descriptor slots (V#s) causes compute shaders during the world transition (e.g. lib_cs_01144) to divide by 0 or read zero loop bounds from buffer descriptors, causing an infinite loop and GPU device loss.

Buffer V# descriptors (!(w3 >> 30)) only rebase virtual addresses and are fast to process without causing submission stalls (the 28s freeze is driven by thousands of image T# descriptors performing image binding and view lookups).

This change ensures that buffer V# descriptors are never nulled or deferred when the fix budget expires: they are always resolved in-place with fix_console_slot, while image T# descriptors continue to be safely deferred to retry_console_slots.

Testing

  • console_heap_vsharp_slots_test: added test_console_fix_budget_buffer_vsharp_non_deferral() verifying that under fix_over == true, buffer V# descriptors are preserved live while image T#s are deferred and nulled. Passed (100%).
  • vk_console_heap_gpu_test: passed on NVIDIA GeForce RTX 5060 Ti.
  • scripts/check_no_game_data.py: passed (0 violations).
  • tests/test_text_write_line_endings.py: passed.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5501755434 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2162). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-26T00:39:34Z. --- Claimed in Issue #1608: [RT-CONSOLE-FIX-NEVER-DEFER-BUFFER-VSHARP](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7178867037). ### What and why In `fix_console_slots()` (`runtime/shims/d3d12_vulkan_device.cpp`), when the `LEONIDA_CONSOLE_FIX_US` submission budget expires (`heap.fix_over == true`), the code currently zeroes every remaining descriptor slot and defers them to `retry_console_slots`. Nulling buffer descriptor slots (V#s) causes compute shaders during the world transition (e.g. `lib_cs_01144`) to divide by 0 or read zero loop bounds from buffer descriptors, causing an infinite loop and GPU device loss. Buffer V# descriptors (`!(w3 >> 30)`) only rebase virtual addresses and are fast to process without causing submission stalls (the 28s freeze is driven by thousands of image T# descriptors performing image binding and view lookups). This change ensures that buffer V# descriptors are never nulled or deferred when the fix budget expires: they are always resolved in-place with `fix_console_slot`, while image T# descriptors continue to be safely deferred to `retry_console_slots`. ### Testing - `console_heap_vsharp_slots_test`: added `test_console_fix_budget_buffer_vsharp_non_deferral()` verifying that under `fix_over == true`, buffer V# descriptors are preserved live while image T#s are deferred and nulled. Passed (100%). - `vk_console_heap_gpu_test`: passed on NVIDIA GeForce RTX 5060 Ti. - `scripts/check_no_game_data.py`: passed (0 violations). - `tests/test_text_write_line_endings.py`: passed. AI-assisted (Claude Code).
moffington commented 2026-11-26 00:51:43 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by moffington on 2026-11-26T00:51:43Z.


Checked 2769c5a7 on Linux (AMD Ryzen 5 5600X3D, NVIDIA GeForce RTX 3060, driver 615.78.08) and Windows/Wine (clang-cl 23.1.3 + xwin SDK 10.0.26100).

  • console_heap_vsharp_slots_test: passed at both merge-base (61732aca) and head (2769c5a7) on Linux (g++ 16.2.1, RelWithDebInfo and ASan+UBSan -Wall -Wextra -Werror) and under Wine.
  • d3d12_vulkan_device_test and d3d12_console_descriptor_heap_test (with LEONIDA_CONSOLE_FIX_US=1): built cleanly with clang-cl and passed under Wine on RTX 3060.
  • Code check: in DeviceState::fix_console_slots() (runtime/shims/d3d12_vulkan_device.cpp), !(w3 >> 30) at heap.previous + at + 12 matches fix_console_slot()'s buffer V# classification.
  • Coverage limitation: test_console_fix_budget_buffer_vsharp_non_deferral() in console_heap_vsharp_slots_test.cpp simulates the !(w3 >> 30) deferral branch inline on a local array rather than calling DeviceState::fix_console_slots(), and no existing runtime/test/ target exercises LEONIDA_CONSOLE_FIX_US budget expiry through fix_console_slots().

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7179187366 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2162#issuecomment-7179187366). Originally posted by [moffington](https://github.com/moffington) on 2026-11-26T00:51:43Z. --- Checked `2769c5a7` on Linux (AMD Ryzen 5 5600X3D, NVIDIA GeForce RTX 3060, driver 615.78.08) and Windows/Wine (`clang-cl 23.1.3` + `xwin` SDK 10.0.26100). - `console_heap_vsharp_slots_test`: passed at both merge-base (`61732aca`) and head (`2769c5a7`) on Linux (`g++ 16.2.1`, RelWithDebInfo and ASan+UBSan `-Wall -Wextra -Werror`) and under Wine. - `d3d12_vulkan_device_test` and `d3d12_console_descriptor_heap_test` (with `LEONIDA_CONSOLE_FIX_US=1`): built cleanly with `clang-cl` and passed under Wine on RTX 3060. - Code check: in `DeviceState::fix_console_slots()` (`runtime/shims/d3d12_vulkan_device.cpp`), `!(w3 >> 30)` at `heap.previous + at + 12` matches `fix_console_slot()`'s buffer V# classification. - Coverage limitation: `test_console_fix_budget_buffer_vsharp_non_deferral()` in `console_heap_vsharp_slots_test.cpp` simulates the `!(w3 >> 30)` deferral branch inline on a local array rather than calling `DeviceState::fix_console_slots()`, and no existing `runtime/test/` target exercises `LEONIDA_CONSOLE_FIX_US` budget expiry through `fix_console_slots()`. AI-assisted.
moffington commented 2026-11-26 01:31:04 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by moffington on 2026-11-26T01:31:04Z.


Follow-up negative control on 2769c5a7 (coverage gap, not a defect in the d3d12_vulkan_device.cpp fix itself):

  • Compiling #2162 HEAD's runtime/test/console_heap_vsharp_slots_test.cpp against merge-base (61732aca) runtime/src — i.e., with the DeviceState::fix_console_slots() change reverted — still builds and passes (console_heap_vsharp_slots_test: ok).
  • This confirms test_console_fix_budget_buffer_vsharp_non_deferral() would not catch a regression in fix_console_slots(), since it only exercises an inline local array rather than the production DeviceState::fix_console_slots() path.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7179849859 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2162#issuecomment-7179849859). Originally posted by [moffington](https://github.com/moffington) on 2026-11-26T01:31:04Z. --- Follow-up negative control on `2769c5a7` (coverage gap, not a defect in the `d3d12_vulkan_device.cpp` fix itself): - Compiling `#2162` HEAD's `runtime/test/console_heap_vsharp_slots_test.cpp` against merge-base (`61732aca`) `runtime/src` — i.e., with the `DeviceState::fix_console_slots()` change reverted — still builds and passes (`console_heap_vsharp_slots_test: ok`). - This confirms `test_console_fix_budget_buffer_vsharp_non_deferral()` would not catch a regression in `fix_console_slots()`, since it only exercises an inline local array rather than the production `DeviceState::fix_console_slots()` path. AI-assisted.
aslan2142 commented 2026-11-26 14:42:07 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-26T14:42:07Z.


Thank you, @abnalstlll-byte. This went into main through #2350 (RT-LINUX-AMD-WORLD), merged at your head 2769c5a73 with your commits and authorship kept. The one conflict, in fix_console_slots, came from a host-RAM mirror of the heap copy in the same PR. Your buffer-V# exception was kept, and the zeroing now goes through heap.copy.zero(). GitHub shows this PR as merged for that reason, so nothing needs closing.

AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7195197054 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2162#issuecomment-7195197054). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-11-26T14:42:07Z. --- Thank you, @abnalstlll-byte. This went into `main` through #2350 (RT-LINUX-AMD-WORLD), merged at your head `2769c5a73` with your commits and authorship kept. The one conflict, in `fix_console_slots`, came from a host-RAM mirror of the heap copy in the same PR. Your buffer-V# exception was kept, and the zeroing now goes through `heap.copy.zero()`. GitHub shows this PR as merged for that reason, so nothing needs closing. AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2)
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!2162
No description provided.