Skip to content

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

Open
Tyrannys wants to merge 1 commit into
ProjectLeonida:mainfrom
Tyrannys:claude/bindless-kind-bits
Open

Tyrannys wants to merge 1 commit into
ProjectLeonida:mainfrom
Tyrannys:claude/bindless-kind-bits

Conversation

@Tyrannys

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: RT-BINDLESS-KIND-BITS (#1608 (comment)), item 1 of @kevincommits' finding (#1608 (comment)). 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

BindlessSet::update_image marked an index's storage views used even when the
index was past the storage arrays (an image added without storage views gets
one from the upper, sampled-only range), where write_image writes no storage
descriptor. image_kind_at then gave the index a storage bit, and a tagged
module would index the shorter storage array out of bounds. The same held for
a 2D mirror's storage views. update_image now marks storage only below the
storage capacity, and image_kind_at checks the same bound.

add_image and image_kind_at also set the sampled bit for a 1D-array image,
whose dimension has no sampled array; they no longer do.

Test: bindless_kind_bits (a fake Vulkan device, no GPU) with the repro from
kevincommits's finding in ProjectLeonida#1608.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
clquwu added a commit to clquwu/leonida-ultimate that referenced this pull request Nov 27, 2026
…imits permit

- Add bindless::max_images_2d = 131072 in runtime/src/vulkan_bindless.h while
  keeping max_images = 65536 for 2D-array, 3D, and 1D so high-limit GPUs
  (RTX 3080/5070, RADV, llvmpipe, Intel Xe-LP) prevent live 2D T# overflow
  (64,221 live 2D T#s of 56,006 textures observed at 65,536 on RTX 3080)
  without bloating the other dimensions.
- In bindless::size_bindings(), grow all four single-sample dimensions to
  max_images (65,536) first, then grow dim_2d up to max_images_2d (131,072)
  only after 2D-array/3D/1D have reached max_images, preserving fair sizing
  on mid-limit and pool-limited GPUs (and scaling 2D storage when
  match_storage_to_sampled is enabled).
- Verified full 32-bit bindless slot indices end-to-end across
  descriptor_table.h, vulkan_bindless.h, d3d12_vulkan_device.cpp, and
  tools/rdna2spirv.py (no 16-bit packing or truncation).
- Audited ProjectLeonida/mandy#2496 (RT-BINDLESS-KIND-BITS) against
  ultimate HEAD: skipped as N/A because its prerequisite tagged descriptor
  table (kind_sampled_bit / kind_storage_bit / MirrorViews / image_kind_at
  from upstream #2098) is not present in ultimate, and BindlessSet already
  bounds-checks storage writes and skips sampled writes for dim_1d_array.
- Expand bindless_sizing_test with 131,072 2D sizing/cap tests and a CPU-only
  131,071-slot BindlessSet 32-bit lookup + OOB-storage + 1D-array safety test;
  fix bindless_queue_test's stale 6-dimension/no-dim_1d_array/held-slot model;
  update docs/d3d12_vulkan.md.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant