vulkan: retain a valid bindless table under pressure (RT-BINDLESS-TABLE-DEGRADE) #1092
Closed
github-bot
wants to merge 1 commit from
gh-pr/1092/head into gh-pr/1092/base
pull from: gh-pr/1092/head
merge into: github:gh-pr/1092/base
github:main
github:docs/animation-merge-remnants
github:docs/story-dedup-and-cli
github:docs/restofworld-merge-remnants
github:docs/gamedata-dedup-tables
github:docs/textures-bcpack-tables-and-cli
github:docs/exe-fail-fast-shims-sync
github:fix/address-guard-wraparound-parity
github:fix/cvt-f16-denorm-and-clamp
github:docs/pso-cache-scope-note
github:docs/viewer-readme
github:docs/textures-arrays-dds-preview
github:docs/conformance-readme-status
github:fix/docs-validators-fences-urls
github:claude/loop-total
github:claude/pops-collision-seed
github:claude/dstorage-hold-page-reads
github:claude/host-image-copy-switch
github:feat/gdk-lifecycle-window-hook
github:claude/d16s8-uav-nvidia-fallback
github:feat/mfplat-offline-shim
github:claude/gameinput-slow-reader
github:fix/rt-null-barrier-clear
github:claude/depth-resolve-sample-positions
github:integration/palmetto-parity
github:claude/valu-literal-sext
github:claude/slot74-pool-handle
github:claude/rgb9e5-uint-alias-view
github:claude/fssm-root-layout-tables
github:feat/gdk-speech-display-lifecycle
github:asset-audio-skip-current
github:qemmhd/old-9940-rectangle-quad-lists
github:feat/ws2-offline-shim
github:qemmhd/rt-d16-unorm-uav
github:feat/xs-device-stops-7-9
github:qemmhd/rt-depth-same-base-shapes
github:qemmhd/rt-lazy-attachment-variant
github:feat/acphal-xma2-decoder
github:asset-audio-skip
github:codex/coord-claim-check-20261124-7e48
github:feat/xs-frame-pacing-presentx
github:feat/xs-device-vm-options
github:old-pr/9844
github:old-pr/9978
github:old-pr/9815
github:old-pr/10057
github:old-pr/9874
github:old-pr/9965
github:old-pr/9863
github:old-pr/10068
github:old-pr/10066
github:old-pr/10067
github:old-pr/10007
github:old-pr/10061
github:old-pr/10065
github:old-pr/10059
github:old-pr/10063
github:old-pr/10055
github:old-pr/10062
github:old-pr/10042
github:old-pr/10041
github:old-pr/10049
github:old-pr/10047
github:old-pr/10046
github:old-pr/10045
github:old-pr/10056
github:old-pr/10043
github:old-pr/10036
github:old-pr/10034
github:old-pr/9984
github:old-pr/10052
github:old-pr/10038
github:old-pr/10033
github:old-pr/10028
github:old-pr/10050
github:old-pr/9891
github:old-pr/9889
github:old-pr/10051
github:old-pr/10019
github:old-pr/10027
github:old-pr/10029
github:old-pr/10031
github:old-pr/10026
github:old-pr/9941
github:old-pr/10030
github:old-pr/10040
github:old-pr/9990
github:old-pr/10021
github:old-pr/9962
github:old-pr/10022
github:old-pr/10020
github:old-pr/10015
github:old-pr/10025
github:old-pr/9886
github:old-pr/10048
github:old-pr/10014
github:old-pr/10011
github:old-pr/9861
github:old-pr/10010
github:old-pr/10008
github:old-pr/9860
github:old-pr/10006
github:old-pr/9920
github:old-pr/9995
github:old-pr/10000
github:old-pr/10016
github:old-pr/10004
github:old-pr/10023
github:old-pr/9982
github:old-pr/9981
github:old-pr/9983
github:old-pr/9970
github:old-pr/9969
github:old-pr/9968
github:old-pr/9971
github:old-pr/9972
github:old-pr/9942
github:old-pr/9963
github:old-pr/9960
github:old-pr/9964
github:old-pr/9985
github:old-pr/9973
github:old-pr/9862
github:old-pr/9953
github:old-pr/10017
github:old-pr/9952
github:old-pr/9955
github:old-pr/9946
github:old-pr/9954
github:old-pr/9938
github:old-pr/9956
github:old-pr/9856
github:old-pr/9947
github:old-pr/9924
github:old-pr/9961
github:old-pr/9927
github:old-pr/9979
github:old-pr/10032
github:old-pr/9926
github:old-pr/5237
github:old-pr/9951
github:old-pr/9931
github:old-pr/9902
github:old-pr/9921
github:old-pr/9994
github:old-pr/9775
github:old-pr/9768
github:old-pr/9905
github:old-pr/9936
github:old-pr/9901
github:old-pr/9904
github:old-pr/9906
github:old-pr/9988
github:old-pr/9908
github:old-pr/9909
github:old-pr/9911
github:old-pr/9912
github:old-pr/9913
github:old-pr/9887
github:old-pr/9916
github:old-pr/9919
github:old-pr/9925
github:old-pr/9933
github:old-pr/9935
github:old-pr/9918
github:old-pr/9879
github:old-pr/9880
github:old-pr/9881
github:old-pr/9996
github:old-pr/9876
github:old-pr/9892
github:old-pr/9899
github:old-pr/9915
github:old-pr/9914
github:old-pr/9872
github:old-pr/9869
github:old-pr/9866
github:old-pr/9819
github:old-pr/10012
github:old-pr/9857
github:old-pr/9893
github:old-pr/9897
github:old-pr/9928
github:old-pr/9868
github:old-pr/9917
github:old-pr/9940
github:old-pr/9873
github:old-pr/9816
github:old-pr/10009
github:old-pr/9900
github:old-pr/9966
github:old-pr/9859
github:old-pr/9843
github:old-pr/9991
github:old-pr/10058
github:old-pr/9883
github:old-pr/9838
github:old-pr/9835
github:old-pr/9959
github:old-pr/9895
github:old-pr/9837
github:old-pr/9858
github:old-pr/9865
github:old-pr/9864
github:old-pr/9840
github:old-pr/9820
github:old-pr/4669
github:old-pr/9848
github:old-pr/9850
github:old-pr/9810
github:old-pr/9799
github:old-pr/9853
github:old-pr/9875
github:old-pr/9831
github:old-pr/9796
github:old-pr/9801
github:old-pr/9813
github:old-pr/9794
github:old-pr/7417
github:old-pr/9781
github:old-pr/9806
github:old-pr/9958
github:old-pr/9809
github:old-pr/9791
github:old-pr/9792
github:old-pr/10053
github:old-pr/9784
github:old-pr/9789
github:old-pr/9849
github:old-pr/9846
github:old-pr/9773
github:old-pr/9785
github:old-pr/9803
github:old-pr/9826
github:old-pr/9839
github:old-pr/9922
github:old-pr/9948
github:old-pr/7189
github:old-pr/9957
github:old-pr/9823
github:old-pr/9807
github:old-pr/9851
github:old-pr/9774
github:old-pr/9830
github:old-pr/9836
github:old-pr/9822
github:old-pr/9783
github:old-pr/9833
github:old-pr/9890
github:old-pr/9770
github:old-pr/9769
github:old-pr/9772
github:old-pr/9787
github:old-pr/9852
github:old-pr/9834
github:old-pr/9845
github:old-pr/9871
github:old-pr/9771
github:old-pr/9776
github:old-pr/10005
github:old-pr/9949
github:old-pr/9923
github:old-pr/9805
github:old-pr/9829
github:old-pr/9790
github:old-pr/9827
github:old-pr/9929
github:old-pr/9855
github:old-pr/9934
github:old-pr/9907
github:old-pr/9910
github:old-pr/9779
github:old-pr/9780
github:old-pr/9885
github:old-pr/9882
github:old-pr/9877
github:old-pr/9998
github:old-pr/4251
github:old-pr/9987
github:old-pr/9989
github:old-pr/9950
github:old-pr/9777
github:old-pr/10044
github:old-pr/9884
github:old-pr/2906
github:old-pr/5076
github:old-pr/9937
github:old-pr/9986
github:old-pr/3014
github:old-pr/9943
github:old-pr/9939
github:old-pr/4682
github:old-pr/4765
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
bug
Something isn't working
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
missing claim
Needs a claim in #14
needs rebase
Conflicts with the base branch: rebase it on main
question
Further information is requested
wontfix
This will not be worked on
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
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.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!1092
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1092/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Moriz82 on GitHub · 2026-11-24 18:16 UTC · original
split/rt-bindless-table-degrade→main· +91 −6 · 2 files · 1 commits · closed without mergingClaimed in the coordination issue as: RT-BINDLESS-TABLE-DEGRADE (claim).
Part of the split of #984 into small pull requests.
Depends on: none
Overlaps: #984 contains the integration. #425 covers descriptor-set
recycling and its pool budget. This child can land independently of it.
What and why
Under device-local memory pressure, a bindless table rebuild could fail
and cause ExecuteCommandLists to refuse the whole submission. The smaller
sampled-image arrays could also fill during streaming.
A replacement table can use coherent host-visible memory. If allocation
fails, the runtime releases completed generations and retries. An idle
table can be rewritten in place if it still fits. When those paths fail,
work can use the last table submitted to the GPU. New keys resolve to the
fallback and removed indices stay reserved until the table catches up.
The first upload must reach the queue before any submission can use this
fallback. Device loss still propagates.
Device limits now permit up to 16,384 sampled 2D-array images and 4,096
each for 3D and 1D. The existing layout and per-stage limits still apply.
Tested
Release cross-build with clang-cl 23.1.5 and an xwin SDK on CachyOS,
kernel 7.3.5. Runtime tests used Proton Experimental (Wine 11), a Ryzen
5 5600X, 16 GB RAM and an RTX 4070 12 GB with NVIDIA 620.73.04. CMake
omitted the optional XMA2 decoder because the Rust Windows target was
unavailable.
The sizing test passed, with 152,929 descriptors on synthetic RTX
5070-like limits. The GPU pressure test passed 41/41 checks. It observed
one host-memory fallback, one idle rewrite and two degraded flushes, then
recovered to a 256-slot table. It also rejected a first upload under
pressure, a discarded upload and a simulated device loss.
D3D12 churn passed all four runs. Each compared 98,304 texels over 96
frames on direct and compute queues, with zero mismatches. The two
deferred-retirement runs each made three generations and recorded zero
device-idle waits. The two legacy runs each recorded three waits.
The semantic suite passed 6,168 tests across 470 files. The content and
whitespace checks passed.
Review round 1. A review proposed keeping descriptor writes pending
across a degraded flush, so that a key rebound while the old table is
kept does not find the fallback. That is not taken: the device destroys
a removed texture's views right after
remove_image, so a removedimage's descriptors must go back to the fallback at the next flush even
when that flush keeps the old table. Otherwise a key the old table still
maps to that index finds a destroyed view. The pressure test now records
what every image descriptor names and checks after each flush that the
current set names no destroyed view. It passes 50/50 checks on this head
(41 before the new checks), natively on Linux and as a Windows program
under Wine 11.22, on an RTX 4070 (NVIDIA 620.73.04). With pending writes
kept, it exits 1 at the removal between the two degraded flushes: the
current set's binding 0, element 256 names a destroyed view. The runs
described above and below were made on the head before this round; only
the test file changed since.
For the control, rebuild the GPU pressure test with only the previous
refusal restored. Change the guard in BindlessSet::flush from
!written && must_replace && !table_on_gpu_to!written && must_replace. Link with the same flags and run the sametest. The control passed 17 checks and stopped at check 18 with exit 1:
the busy flush refused the submission. The remaining 23 checks did not
run in this control.
The sizing control omits the three new calls to grow the 2D-array, 3D
and 1D bindings. It passed the first five checks, then exited 1 at the
first check for the larger sampled-image arrays.
Two integration runs on Windows 11 (i9-13900K, RTX 4070 Ti, NVIDIA
630.20) used host memory and continued without refusing a batch. Neither
run exercised a degraded flush. This standalone child was not run on
native Windows, AMD or Intel, with validation layers, or in a game boot.
GPUs tested: NVIDIA GeForce RTX 4070.
AI-assisted: yes
Checklist
🤖 Generated with Claude Code
@Plaaasma on GitHub · 2026-11-24 18:28 UTC · original
Native Windows check, AI-assisted (Claude Code). Windows 11, i9-13900K, 64 GB, RTX 4070 Ti 12 GB (NVIDIA 630.20), MSVC 2022 (VS 17 generator, Release), Vulkan.
Head
4247b2120. Builtvk_bindless_grow_test bindless_sizing_test d3d12_bindless_churn_test, thenctest -C Release -R "^(vk_bindless_grow|bindless_sizing|d3d12_bindless_churn|d3d12_bindless_churn_validated)$" --output-on-failure --timeout 300:vk_bindless_grow: passed, 0.54 s (41 checks passed: 1 host fallback, 1 in-place rewrite, 2 degraded flushes; first flush under full memory refused, then uploaded once memory was back)bindless_sizing: passed, 0.04 sd3d12_bindless_churn: passed, 2.64 s (96 frames, direct + compute queue, 0 wrong texels in all four modes; 0vkDeviceWaitIdlefor the set on the deferred path vs 3 on the old wait)d3d12_bindless_churn_validated: skipped (exit 77,VK_LAYER_KHRONOS_validationisn't installed on this machine)3 passed, 1 skipped, 0 failed.
@abnalstlll-byte on GitHub · 2026-11-24 18:41 UTC · original · approved these changes
Audited and verified. Increases bindless descriptor bounds (16384 for 2D arrays, 4096 for 3D/1D) and implements multi-tier memory pressure degradation (host-visible fallback, in-place table rewrites, and degraded table reuse retaining prior GPU generations) in
untime/src/vulkan_bindless.h. Verified in
untime/test/vk_bindless_grow_test.cpp. Approved.
@abnalstlll-byte on GitHub · 2026-11-24 18:52 UTC · original · approved these changes
Clean-Room Audit — PR #1092 (
RT-BINDLESS-TABLE-DEGRADE)Thoughtful resilience upgrade in
vulkan_bindless.handd3d12_vulkan_device.cpp: expands bindless limits (16,384 2D / 4,096 3D & 1D) and gracefully handles allocation pressure via generation flushes, host-visible fallback, and retaining a valid bindless table rather than aborting submissions. Covered byvk_bindless_grow_test.cpp; 0 game data.Verdict: APPROVED
@bobcatchris on GitHub · 2026-11-24 19:43 UTC · original
Concrete correctness follow-up: a degraded flush currently still applies and clears
pending_descriptor writes. If the failed replacement was caused by a live-key replacement/relocation, those writes include the old index’s fallback, while the GPU’s retained old hash table still maps the key to that index. Newly recorded/submitted work can therefore sample the fallback until a later successful generation.Reproduction added in
vk_bindless_grow_test: publish a victim key/index, rebind it to a new index, remove the old index, fail all table/pool allocations while a submission may still read the old set, and degrade. On this headpending_write_count()is 0 after the degraded flush; with the fix it remains nonzero and returns to 0 only after recovery.Fix branch (stacked on this PR, not opened against main to avoid duplicating its diff): https://github.com/bobcatchris/leonida-public/tree/fix/bindless-degrade-live-keys, commit
b59279da7. It keeps descriptor updates and held indices pending on degraded flushes, and updates the comments.Verified on RX 7900 XTX / 32.0.32029.2010 / Windows 11 with
LEONIDA_VK_VALIDATION=1:vk_bindless_grow52/52 checks,bindless_sizing, bothd3d12_bindless_churnmodes,vk_bindless_ps_tex, andvk_bindless_ps_imgatomicall pass. Baseline negative control fails the new pending-write assertion. No game data; security sweep clean. AI-assisted.@iFeyz on GitHub · 2026-11-24 19:51 UTC · original
AMD run (the gap the description lists): RX 9070 XT (RDNA4, GFX1201), AMD proprietary Windows driver 26.11.2 (LLPC, Vulkan 1.4.359), Windows 11, MSVC 2022 RelWithDebInfo.
Head
4247b2120:vk_bindless_growandbindless_sizingbuilt from it: 2 of 2 pass.@Moriz82 on GitHub · 2026-11-24 21:29 UTC · original
@bobcatchris thank you for the reproduction and the patch. I ran both here. I am not taking
b59279da7: it fixes the sequence in your test, but it makes the texture-destruction sequence unsafe, and that is the one the D3D12 layer produces. Lines below are for4247b2120, the head you reviewed.Reproduced. RTX 4070, NVIDIA 620.73.04, CachyOS,
vk_bindless_grow_testbuilt natively and as a Windows program (clang-cl, run under Wine 11.22). Your branch passes 52/52 in both. Your test on this head'sflush(), with onlypending_write_count()added, stops at check 17,set.pending_write_count() != 0, exit 1, in both. So what you describe happens for that sequence:insert_key(victim, victim_new),remove_image(victim_old)while a submission can still read the set, then a degraded flush writes the fallback atvictim_oldin that set.The D3D12 layer does not make that sequence. It never removes an index whose key is live:
replaced_imagesuntil the texture is destroyed (runtime/shims/d3d12_vulkan_device.cpp:1074,1260-1262). The old index keeps a view of the same texture, so the retained table finds a valid descriptor through any number of degraded flushes.remove_imagehas one caller, the deferred release (d3d12_vulkan_device.cpp:5319-5325).forget_imagequeues it after erasing every key of the texture (1272-1288,1133-1139), and it runs once the submission after that has completed (runtime/src/vulkan_backend.h:1457-1470).Keeping the writes pending is unsafe for that caller.
release()queues the index and then its views (d3d12_vulkan_device.cpp:1136-1138), anddrain()runs them in that order:remove_image, thenvkDestroyImageView(vulkan_backend.h:500-510). The set's own contract allows this: a view removed before the next flush "may be destroyed by then" (runtime/src/vulkan_bindless.h:1099-1100). So after a flush that returns true the set must no longer name a removed view, and on this head a degraded flush writes the fallback for that reason. Withb59279da7a degraded flush returns true and leaves the removed index naming the destroyed view for as long as flushes keep degrading, while the table on the GPU still maps the erased key to that index. A stale T# finds index 0 through a current table and the fallback at the old index on this head; with the patch it finds a destroyed view. On a device withoutdescriptorBindingPartiallyBoundthe set is then invalid for every draw, looked up or not.maindid keep these writes pending when the generation could not be made (vulkan_bindless.h:500-501at this PR's base3aa975421), but there the flush failed and the submission ran none of its work. This PR lets work run on the retained table, so the two do not combine.Measured, and now in this PR's test. The sequence is already in the test:
remove(gone)(erase the key, remove the index, destroy the view) between two degraded flushes.vk_bindless_grow_testnow wrapsvkUpdateDescriptorSets,vkAllocateDescriptorSets,vkCreateImageViewandvkDestroyImageViewthrough theget_procit already has, records which view each image descriptor names, and checks after every successful flush that the current set names no destroyed view. The head is updated with that (test file only, no change tovulkan_bindless.h).b59279da7with the same test: after the second degraded flush the table as last uploaded still mapsgone.keytogone.index, and binding 0, element 256 of the current set names the destroyed view; the test exits 1 there (stale == 0), natively and under Wine.A validation run cannot show this in
vk_bindless_grow_test, because the test draws nothing. Your new case does not show it either: it keeps both victim views alive until after the recovering flush (lines 206-207 of your version).Narrower variants. Delaying only the writes at indices the retained table can still name selects the removed indices, the ones whose views are gone, so it has the same problem. The writes that could wait safely are those at new indices from
add_imageandadd_sampler; no key of the retained table reaches them, so nothing is gained by holding them. Making your sequence work would need the caller to keep a removed view, and the image under it, alive until a flush that does not degrade and the work before it has finished. That holds texture memory through the condition that makes flushes degrade, and it is a change to the device's release path rather than to this PR.vulkan_bindless.hstays as it was at4247b2120; only the test changed. If you see a path in the D3D12 layer that removes an index while its key is live, or a case where the fallback is the wrong answer after a texture is destroyed, please point me at it.Not run here: the validation layer (not installed on this machine), native Windows, AMD. I did not rerun
d3d12_bindless_churnor the twovk_bindless_ps_*tests for this: they inject no allocation failure and cannot reach a degraded flush.AI-assisted (Claude Code).
🤖 Generated with Claude Code
@whoalin1 on GitHub · 2026-11-24 22:04 UTC · original
GPU verification (AI-assisted, independent worker on the shared test box) — head
4247b2120. Note: based on3aa975421, not currentorigin/main(4a50cafc7at verification time).Host/device tests (
ctest -R bindless,TEMP/TMPset to a user-writable dir):LEONIDA_VK_VALIDATION=1; NVIDIA: 1.5s.origin/main(4a50cafc7, same env): both abort atCreateComputePipelineStatewith "pipelines need 144 bytes of push constants … maxPushConstantsSize 128" — the known 128-byte push-constant cap on this iGPU, unrelated to the bindless change (fails before any table code runs).vk_bindless_testrun manually (the ctest entries need translated shaders this configure lacks; SPIR-V taken from the GPU suite's--workoutput — samevs_ids/ps_tex/ps_imgatomicfixtures),LEONIDA_VK_VALIDATION=1on AMD and plain on NVIDIA:ps_texPASS — "bindless: 24 draws read back, 0 bad pixels", table grew 64→512 slots, index 9098 of 65536 2D images / 2102 of 4096 samplers;ps_imgatomicPASS — 0 wrong texels/pixels. No VUIDs.GPU suite
py -3.14 -I scripts/run_gpu_tests.py --build runtime/build --work C:\leonida_gpu_work(261 shaders translated, all pass spirv-val; llvm-mc via WSL Ubuntu, spirv-as/spirv-val from Vulkan SDK 1.4.363):VK_LOADER_DRIVERS_SELECT=*amd-vulkan* LEONIDA_VK_DEVICE=radeon VK_LOADER_LAYERS_DISABLE=~implicit~ LEONIDA_VK_VALIDATION=1 LEONIDA_PC_TAIL_UBO=1): 230/252 passed, 20 skipped, 2 failed —ms_clip,ms_wave_info_s3, identical toorigin/mainbaseline (known LLPC issue #802/#808). No validation errors.VK_LOADER_DRIVERS_SELECT=*nv-vk* LEONIDA_VK_DEVICE=4070 VK_LOADER_LAYERS_DISABLE=~implicit~): 203/252 passed, 49 skipped, 0 failed — identical toorigin/mainbaseline.Verdict: PASS — the new degrade/hold path is exercised cleanly on both GPUs including under validation; the only failures are pre-existing on main (AMD push-constant cap for the two d3d12 churn tests, LLPC mesh-shader crashes in the suite).
@Moriz82 on GitHub · 2026-11-24 22:06 UTC · original
@whoalin1 thank you, especially for the AMD run under
LEONIDA_VK_VALIDATION=1: the validation layer is not installed here, so that is the first validated run ofvk_bindless_grow.For anyone reading the results: they are for
4247b2120. The head is now1f0e69de4, and the only change since isruntime/test/vk_bindless_grow_test.cpp(review round 1 above): the test now also records which view every image descriptor names and checks after each flush that the current set names no destroyed view. It reports 50 checks instead of 41;vulkan_bindless.h, the device and the other tests are as you ran them.AI-assisted (Claude Code).
@Moriz82 on GitHub · 2026-11-25 03:51 UTC · original
Rebased onto
5129be10at84de57c0. Main now has the table replacement and churn handling. This diff preserves the check that a degraded flush’s current set names no destroyed views and returns failure for Vulkan device loss. Fresh GPU results are pending.AI-assisted.
Pull request closed