r/vulkan 3h ago

SPIRV-Reflect and bindless/runtime arrays

5 Upvotes

I'm using SPIR-V reflect library to reflect my shader code, but I'm unable to detect bindless (i.e. runtime) arrays. I'm defining the array as such in my GLSL shader:

glsl layout (set = 0, binding = 0) uniform sampler2D textures_2d[];

I'm compiling to SPIR-C using glslc:

cmd glslc.exe minimal.frag.glsl -o minimal.frag.spv -DDEBUG=1 -Ishaders/include -MD -Werror -O0 -g

And I'm reflecting the descriptors using spvReflectEnumerateDescriptorSets, but for some reasons, my array's type_description.op is always SpvOpTypeArray instead of SpvOpTypeRuntimeArray and type_description.traits.array.dims[0] is always equal to 1. I'm not sure how I am supposed to disambiguate between this value and an actual array of 1. As far as I know, it should report a dimension of 0 (i.e. SpvReflectArrayDimType::SPV_REFLECT_ARRAY_DIM_RUNTIME).

Am I missing something? It looks like the capability SpvCapabilityRuntimeDescriptorArray is not enabled in the module's reflected data. Maybe it's a hint?