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

Manually merged
github merged 1 commit from github-bot/gh-2162 into main 2026-11-26 14:53:20 +00:00 AGit
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-26 00:39 UTC · original
abnalstlll-byte:feat/rt-console-fix-never-defer-buffer-vsharp → main · +82 −1 · 2 files · 1 commits · merged 2026-11-26 14:41 UTC

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

**@⁠abnalstlll-byte** on GitHub · 2026-11-26 00:39 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2162) `abnalstlll-byte:feat/rt-console-fix-never-defer-buffer-vsharp` → `main` · +82 −1 · 2 files · 1 commits · merged 2026-11-26 14:41 UTC Claimed in Issue #1608: [RT-CONSOLE-FIX-NEVER-DEFER-BUFFER-VSHARP](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608). ### 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).
In fix_console_slots, when the LEONIDA_CONSOLE_FIX_US budget expires, do not null or defer buffer descriptors (!(w3 >> 30)). Only defer image T# descriptors to retry_console_slots.

Buffer V# descriptors only rebase address offsets and are fast to fix, whereas image T#s perform costly texture lookups and view creation. Compute shaders during world transition (e.g. lib_cs_01144) read loop bounds and record counts from buffer descriptors; nulling them causes infinite loops and device loss.

Tested with console_heap_vsharp_slots_test and vk_console_heap_gpu_test.

AI-assisted (Claude Code).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:20:48 +00:00
Author
Owner

@⁠moffington on GitHub · 2026-11-26 00:51 UTC · original

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** on GitHub · 2026-11-26 00:51 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2162#issuecomment-7179187366) 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.
Author
Owner

@⁠moffington on GitHub · 2026-11-26 01:31 UTC · original

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.

**@⁠moffington** on GitHub · 2026-11-26 01:31 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2162#issuecomment-7179849859) 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.
github manually merged commit 6a405cdd48 into main 2026-11-26 14:53:20 +00:00
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-26 14:42 UTC · original

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)

**@⁠aslan2142** on GitHub · 2026-11-26 14:42 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2162#issuecomment-7195197054) 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)
This discussion has been locked. Commenting is limited to contributors.
No description provided.