# Bindless Resources in wgpu ---- Bindless resources should really be called bind-less. You bind all your resources at once, so shader can decide what to read. `var blah: binding_array<texture_2d<f32>>;` Bind group layout entry has a `count` parameter, bind groups can bind arrays of texture views/buffers. ---- Bindless allows tons of optimizations as it means you no longer have to do cpu side work to change bindings. ---- As far as usage scopes, behaves identically to N different bindings. wgpu highly optimized our state trackers to deal with binding hundreds of thousands of resources quickly. ---- Uniformity of index matters a lot. Few vendors (only NV and QCOMM?) natively support non-uniform indexing. All other vendors emit scalarization loop. In GLSL/HLSL/MSL _must_ annotate non-uniform indexes with something `array[nonuniformEXT(index)]` ---- Our WGSL extension does not require explicit annotation. If we did, we would need to validate its correctness anyway - we have uniformity information. WGSL `array[index]` -> GLSL `array[nonuniformEXT(index)]` ---- Shaders do not need to know length of array. Array length is part of the bind group layout. Resulting SL will have the length of the array attached. ---- There's the concept of partial binding where BG provides less than the full array. Very useful as you no longer need to re-compile shaders to resize array. As far as I can tell, vk (via `VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT`), dx12 resource tier 3, and all metal support partial binding. (intel/windows/vk hangs...) ---- Bounds checking is currently unimplemented in `wgpu`/`naga`. Without partial binding, trivially check with hardcoded array length. With partial binding, ship buffer with one occupancy bit per resource. wgpu will likely do the latter in all cases. ---- ## Limits Generally, devices with bindless support ~500k bindings. intel/windows/vk supports 1800. Metal supports 80 without argument buffers. ---- `wgpu` doesn't use argument buffers currently. Current plan is to use one argument buffer per binding array. Will bring us to 500k. ---- intel/windows/vk will be stuck with 1800. intel/vulkan/vk supports 65k. intel/dx12 is tier 3, and supports 1 million+
{"metaMigratedAt":"2023-06-17T21:02:31.683Z","metaMigratedFrom":"YAML","title":"WebGPU F2F Bindless","breaks":true,"description":"Feburary 2023","contributors":"[{\"id\":\"581f0281-0b61-4be7-9ecd-44e9171f031e\",\"add\":2396,\"del\":22}]"}
    335 views