Bindless: kind bits name only arrays that hold the image's descriptors (RT-BINDLESS-KIND-BITS) #2496

Closed
Tyrannys wants to merge 1 commit from upstream-pr/2496 into main
Tyrannys commented 2026-11-27 19:25:08 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Tyrannys on 2026-11-27T19:25:08Z.


Claimed in the coordination issue as: RT-BINDLESS-KIND-BITS (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7226161355), item 1 of @kevincommits' finding (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7225958148). Thanks to kevincommits for finding it and for the repro values.

What and why

The kind word that BindlessSet gives an image index tells a tagged module (descriptor_table: tagged) which arrays to index (descriptor_table.h's kind bits). In two cases, runtime/src/vulkan_bindless.h set a bit for an array that holds no descriptor for the image.

Storage bit past the storage arrays. The storage arrays are shorter than the sampled ones (storage_capacity < image_capacity, for example 256 and 4096 for 2D). add_image gives an image without storage views an index from the upper, sampled-only range. If update_image later gives that index storage views, write_image writes no storage descriptor there. But update_image still marked the slot's storage used, both for the image and for its 2D mirror. So image_kind_at (and kind_out) reported a storage bit for an index past the storage arrays. A module trusting it would read the storage array out of bounds.

Now:

  • update_image marks storage only below the dimension's storage capacity, and a mirror's only below the 2D one.
  • image_kind_at checks the same bound when it reads the marks.
  • Inside the storage arrays, nothing changes: an update still adds or drops the storage bit.

Sampled bit for a 1D array. ImageDimension::dim_1d_array has no sampled binding; its images are storage only. Yet add_image and image_kind_at set its sampled bit anyway. Both now set the sampled bit only for a dimension that has a sampled array, through sampled_kind.

The descriptors written are unchanged. Only the kind words change, in these two cases.

Tested

  • New bindless_kind_bits (runtime/test/bindless_kind_bits_test.cpp). It runs BindlessSet on a fake Vulkan device, so no GPU is needed, with the default capacities and kevincommits' repro:
    • A 2D sampled-only image gets index 256, the first past the storage arrays. After update_image with as_float, its kind is the sampled bit only (main: 0x101).
    • A mirrored 2D-array sampled-only image gets index 257. After an update with storage views for it and its mirror, its kind is both sampled bits only (main: 0x303).
    • A storage-only 1D-array image at index 1 has the storage bit only, from add_image, image_kind_at and update_image (main: 0x1010).
    • Inside the storage arrays, an update still drops the storage bit and then adds it back.
  • On main's header the test fails with 5 failures. With the fix it passes.
  • bindless_sizing, descriptor_table, d3d12_com and tests/test_ci_registration.py pass.
  • Short GPU tests pass: vk_bindless_dimensions, vk_bindless_grow and vk_null_descriptor.
  • Full runtime build (MSVC, Ninja): clean.

GPUs tested: NVIDIA GeForce RTX 4070 SUPER, driver 621.01, Windows 11 (profile M), for the three short GPU tests. The new test needs no GPU.

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (No translator change.)

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5532009434 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2496). Originally posted by [Tyrannys](https://github.com/Tyrannys) on 2026-11-27T19:25:08Z. --- Claimed in the coordination issue as: RT-BINDLESS-KIND-BITS (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7226161355), item 1 of @kevincommits' finding (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7225958148). Thanks to kevincommits for finding it and for the repro values. ### What and why The kind word that `BindlessSet` gives an image index tells a tagged module (`descriptor_table: tagged`) which arrays to index (`descriptor_table.h`'s kind bits). In two cases, `runtime/src/vulkan_bindless.h` set a bit for an array that holds no descriptor for the image. **Storage bit past the storage arrays.** The storage arrays are shorter than the sampled ones (`storage_capacity` < `image_capacity`, for example 256 and 4096 for 2D). `add_image` gives an image without storage views an index from the upper, sampled-only range. If `update_image` later gives that index storage views, `write_image` writes no storage descriptor there. But `update_image` still marked the slot's storage used, both for the image and for its 2D mirror. So `image_kind_at` (and `kind_out`) reported a storage bit for an index past the storage arrays. A module trusting it would read the storage array out of bounds. Now: - `update_image` marks storage only below the dimension's storage capacity, and a mirror's only below the 2D one. - `image_kind_at` checks the same bound when it reads the marks. - Inside the storage arrays, nothing changes: an update still adds or drops the storage bit. **Sampled bit for a 1D array.** `ImageDimension::dim_1d_array` has no sampled binding; its images are storage only. Yet `add_image` and `image_kind_at` set its sampled bit anyway. Both now set the sampled bit only for a dimension that has a sampled array, through `sampled_kind`. The descriptors written are unchanged. Only the kind words change, in these two cases. ### Tested - New `bindless_kind_bits` (`runtime/test/bindless_kind_bits_test.cpp`). It runs `BindlessSet` on a fake Vulkan device, so no GPU is needed, with the default capacities and kevincommits' repro: - A 2D sampled-only image gets index 256, the first past the storage arrays. After `update_image` with `as_float`, its kind is the sampled bit only (main: `0x101`). - A mirrored 2D-array sampled-only image gets index 257. After an update with storage views for it and its mirror, its kind is both sampled bits only (main: `0x303`). - A storage-only 1D-array image at index 1 has the storage bit only, from `add_image`, `image_kind_at` and `update_image` (main: `0x1010`). - Inside the storage arrays, an update still drops the storage bit and then adds it back. - On `main`'s header the test fails with 5 failures. With the fix it passes. - `bindless_sizing`, `descriptor_table`, `d3d12_com` and `tests/test_ci_registration.py` pass. - Short GPU tests pass: `vk_bindless_dimensions`, `vk_bindless_grow` and `vk_null_descriptor`. - Full runtime build (MSVC, Ninja): clean. GPUs tested: NVIDIA GeForce RTX 4070 SUPER, driver 621.01, Windows 11 (profile M), for the three short GPU tests. The new test needs no GPU. AI-assisted: yes (Claude Code) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (No translator change.) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
lixonik commented 2026-11-27 21:10:07 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-27T21:10:07Z.

Review: APPROVED


Reviewed 17ef2fe36 (runtime/src/vulkan_bindless.h, runtime/test/bindless_kind_bits_test.cpp) and tested:

  • sampled_kind(dimension) cleanly drops the sampled bit for ImageDimension::dim_1d_array (no_binding) in both add_image and image_kind_at.
  • update_image and image_kind_at bound-check storage marks against storage_capacity(dimension) and storage_capacity(dim_2d) so an index allocated in the upper sampled-only range never advertises an out-of-bounds storage bit (and add_image already asserts < storage_capacity when allocating storage-capable slots).
  • Tested on Windows 11 (MSVC 19.44): bindless_kind_bits passed (0.03 s).

Looks good to merge.

AI-assisted (Antigravity, Gemini).

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6093378989 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2496#pullrequestreview-6093378989). Originally posted by [lixonik](https://github.com/lixonik) on 2026-11-27T21:10:07Z. **Review:** APPROVED --- Reviewed `17ef2fe36` (`runtime/src/vulkan_bindless.h`, `runtime/test/bindless_kind_bits_test.cpp`) and tested: - `sampled_kind(dimension)` cleanly drops the sampled bit for `ImageDimension::dim_1d_array` (`no_binding`) in both `add_image` and `image_kind_at`. - `update_image` and `image_kind_at` bound-check storage marks against `storage_capacity(dimension)` and `storage_capacity(dim_2d)` so an index allocated in the upper sampled-only range never advertises an out-of-bounds storage bit (and `add_image` already asserts `< storage_capacity` when allocating storage-capable slots). - Tested on Windows 11 (MSVC 19.44): `bindless_kind_bits` passed (0.03 s). Looks good to merge. AI-assisted (Antigravity, Gemini).
timbot103 commented 2026-11-28 02:01:48 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-28T02:01:48Z.


Reviewed at head 17ef2fe36 on Windows 11 (MSVC 2022 19.44).

Verification

  • Built bindless_kind_bits_test.
  • bindless_kind_bits_test: passed.

Notes

  • sampled_kind() honors no_binding for storage-only 1D arrays, and the add/update/lookup paths apply write-side storage bounds to both the native dimension and 2D mirror (vulkan_bindless.h:198-210, 508-670, 1443-1468; d3d12_vulkan_device.cpp:7708-7711), preventing tagged shaders from selecting an absent binding or indexing a shorter storage array past its limit.

Approve.

AI-assisted review + local MSVC verification.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7232079873 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2496#issuecomment-7232079873). Originally posted by [timbot103](https://github.com/timbot103) on 2026-11-28T02:01:48Z. --- Reviewed at head `17ef2fe36` on Windows 11 (MSVC 2022 `19.44`). ### Verification - Built `bindless_kind_bits_test`. - `bindless_kind_bits_test`: **passed**. ### Notes - `sampled_kind()` honors `no_binding` for storage-only 1D arrays, and the add/update/lookup paths apply write-side storage bounds to both the native dimension and 2D mirror (`vulkan_bindless.h:198-210`, `508-670`, `1443-1468`; `d3d12_vulkan_device.cpp:7708-7711`), preventing tagged shaders from selecting an absent binding or indexing a shorter storage array past its limit. Approve. AI-assisted review + local MSVC verification.
zmasi commented 2026-11-28 10:22:46 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T10:22:46Z.


#2496 | head 17ef2fe36a (merged cleanly with main 33db04a701) | ctest --test-dir runtime/build -C RelWithDebInfo -R "^(bindless_kind_bits|vk_bindless_grow|vk_bindless_dimensions)$" --output-on-failure (LEONIDA_VK_VALIDATION=1) | red on main: bindless_kind_bits_test fails (5 failure(s): update_image past storage_capacity set storage kind bits on 2D and mirrored 2D-array slots, and storage-only 1D-array slots carried a sampled kind bit despite no_binding) | green on PR+main: 3/3 CTests pass (bindless_kind_bits in 0.09s, vk_bindless_grow in 0.69s, and vk_bindless_dimensions in 2.49s on RTX 3090 with LEONIDA_VK_VALIDATION=1 and 0 Khronos validation errors); check_no_game_data.py 0 violations | Windows 11, RTX 3090 (610.88), Vulkan SDK 1.4.363.1 | AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7237857710 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2496#issuecomment-7237857710). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T10:22:46Z. --- #2496 | head 17ef2fe36a561a41aa1662f821ed057ee70b5328 (merged cleanly with main 33db04a7010e81c40a7a6a15624525aa0c4a3a58) | `ctest --test-dir runtime/build -C RelWithDebInfo -R "^(bindless_kind_bits|vk_bindless_grow|vk_bindless_dimensions)$" --output-on-failure` (`LEONIDA_VK_VALIDATION=1`) | red on main: `bindless_kind_bits_test` fails (`5 failure(s)`: `update_image` past `storage_capacity` set storage kind bits on 2D and mirrored 2D-array slots, and storage-only 1D-array slots carried a sampled kind bit despite `no_binding`) | green on PR+main: `3/3` CTests pass (`bindless_kind_bits` in `0.09s`, `vk_bindless_grow` in `0.69s`, and `vk_bindless_dimensions` in `2.49s` on RTX 3090 with `LEONIDA_VK_VALIDATION=1` and `0` Khronos validation errors); `check_no_game_data.py` `0` violations | Windows 11, RTX 3090 (610.88), Vulkan SDK 1.4.363.1 | AI-assisted: yes
timbot103 commented 2026-11-29 01:07:37 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-29T01:07:37Z.

Review: COMMENTED


I reviewed head 17ef2fe36 by static inspection only, with no builds or GPU runs. The sampled-kind change matches the storage-only 1D-array layout, and the new bounds prevent tagged lookups from indexing beyond the typed storage arrays. I also traced mirror ownership, multisample and depth/stencil views, key retirement, and table synchronization.

  • runtime/src/vulkan_bindless.h:599 — With default counts, an R32_UINT storage upgrade at 2D slot 256 still writes the atomic descriptor to binding 4. The cleared storage bit sends the tagged atomic to slot 0. The 2D mirror has the same mismatch. Could update_image signal that this upgrade needs a new slot within the shared storage range, and could the regression test cover the r32ui write as well as the returned kind?
  • runtime/test/bindless_kind_bits_test.cpp:71 — The fake create callbacks are invoked through incompatible function pointer types. Please give each stub its Vulkan create-info parameter type so the constructor exercises the test without undefined behavior.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6100844106 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2496#pullrequestreview-6100844106). Originally posted by [timbot103](https://github.com/timbot103) on 2026-11-29T01:07:37Z. **Review:** COMMENTED --- I reviewed head `17ef2fe36` by static inspection only, with no builds or GPU runs. The sampled-kind change matches the storage-only 1D-array layout, and the new bounds prevent tagged lookups from indexing beyond the typed storage arrays. I also traced mirror ownership, multisample and depth/stencil views, key retirement, and table synchronization. - `runtime/src/vulkan_bindless.h:599` — With default counts, an `R32_UINT` storage upgrade at 2D slot 256 still writes the atomic descriptor to binding 4. The cleared storage bit sends the tagged atomic to slot 0. The 2D mirror has the same mismatch. Could `update_image` signal that this upgrade needs a new slot within the shared storage range, and could the regression test cover the `r32ui` write as well as the returned kind? - `runtime/test/bindless_kind_bits_test.cpp:71` — The fake create callbacks are invoked through incompatible function pointer types. Please give each stub its Vulkan create-info parameter type so the constructor exercises the test without undefined behavior. AI-assisted.
TheGeogeo commented 2026-11-29 13:11:55 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T13:11:55Z.


Tested 17ef2fe36 merged (no commit) with main 8fb974878: MSVC 19.52, Windows 11 10.0.26300.
GPUs tested: NVIDIA GeForce RTX 3080, driver 621.40.

  • Green: bindless_kind_bits passes. The 252 relinked CTests pass, except xbox_present, which fails on main too (its resize case).
  • Red: with runtime/src/vulkan_bindless.h back to main, bindless_kind_bits fails with 5 failures ("2D past the storage arrays, updated with a storage view: no storage bit", the mirrored case, and three "1D array storage-only: storage bit only" cases).
  • gta6rt links with nothing new over main: no new unresolved symbol, same imports.
  • Merge order: conflicts with #2486 in runtime/CMakeLists.txt (both add a test at the same place). Whichever lands second needs a rebase.
  • The review point posted after the last commit (give each stub its Vulkan create-info parameter type) has no reply or commit yet.
  • No game data check passes.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7256360121 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2496#issuecomment-7256360121). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-29T13:11:55Z. --- Tested 17ef2fe36 merged (no commit) with main 8fb974878: MSVC 19.52, Windows 11 10.0.26300. GPUs tested: NVIDIA GeForce RTX 3080, driver 621.40. - Green: `bindless_kind_bits` passes. The 252 relinked CTests pass, except `xbox_present`, which fails on main too (its resize case). - Red: with `runtime/src/vulkan_bindless.h` back to main, `bindless_kind_bits` fails with 5 failures ("2D past the storage arrays, updated with a storage view: no storage bit", the mirrored case, and three "1D array storage-only: storage bit only" cases). - `gta6rt` links with nothing new over main: no new unresolved symbol, same imports. - Merge order: conflicts with #2486 in `runtime/CMakeLists.txt` (both add a test at the same place). Whichever lands second needs a rebase. - The review point posted after the last commit (give each stub its Vulkan create-info parameter type) has no reply or commit yet. - No game data check passes. AI-assisted (Claude Code).
aslan2142 commented 2026-12-01 16:45:31 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T16:45:31Z.


Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7318170941 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2496#issuecomment-7318170941). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T16:45:31Z. --- Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.

Pull request closed

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!2496
No description provided.