Using all 31 Buffers

Hi all -

Wondering if anyone could shed light on what is probably a silly question. I’ve been looking at a lot of sample shaders lately, and none come close to 31 buffers + extra for textures and samplers. At the same time, I’ve also heard remarks about how models might need to be packed in a single buffer due to this limit on mobile devices.

In practical terms, when would you start to see a shader pushing against the max limit? I can see 7 or 8, but I can’t imagine a situation where I’d need 23 more.

Thanks!

I haven’t come across hitting the limit on buffers. I can see that you might want a ton of texture buffers, as you can use textures for look-up tables as well as textures, and in the early days you had 31 of those - you now have 128 texture slots on the latest GPUs.
I haven’t tested speed on packing data into a single buffer rather than spreading them out into separate buffers.

Marius says that the speed depends on how you read your data. Should you format your buffers to have an array of structs or a struct of arrays?

If you just process positions in this step, then struct of arrays/buffers. if you process a vertex entirely and then move on to the next vertex, then one array/buffer of structs is faster.