microsoft/compiler: Support unlimited resource arrays and dynamic indexing
The current compiler backend assumes D3D11-sized resource limits: 128 SRVs, 64 UAVs, 32 samplers, 16 CBs. These limits are more-than-sufficient for GL3.3, and are also sufficient for OpenCL 1.2. However, WebGPU and Vulkan in general don't need to follow these limits, so let's relax them.
There's 2 concepts here:
- The number of resource arrays that have been declared (e.g.
RWByteAddressBuffer foo;is one array with 100 resources). There should be no limit here.
- The number of pre-created handles to resources. For GL we can pre-create all handles to all resources, since there's no dynamic indexing support (currently). At worst, we'd end up with if/else or bcsel chains to select a resource. For CL we already dynamically create handles to global/constant memory resources.
When compiling Vulkan shaders, we stop pre-creating resource handles. Instead, we rely on the compiler deduping derefs or
load_vulkan_descriptor operations to create the minimal number of handles at the right point in the shader. That means the limits on the number of pre-created handles can stay at D3D11-level.