Open chrisforbes opened 11 years ago
Here's a real example, from KSP. It's a 60-tap poisson disc filter, butchered horribly.
In D3D you'd write that as a cbuffer -- which behaves more or less like our UBO. (In fact, the NV paper on this shadow technique provides a sample HLSL shader using a cbuffer for exactly this purpose.
Suggests that it's both acceptable (from a perf perspective) and possible to shunt the block of constants as a whole, into a block of uniforms.
Looks like the lowering pass can be tweaked slightly to avoid lowering references into constant arrays. Unsure what else would have to happen -- probably shipping the array out to pull constants [as we do with uniforms] needs to be handled nicely in FS too.
Things like this generate a horrendous mess currently. The nonconstant index is lowered to a massive conditional tree for all possible indexes.
If the loop were just unrolled instead, or even better, induction variables were allowed as array indexes, things would be quite a lot better.