To simplify:
- For small constant arrays (for example: array of four quad corners in particle renderer), the waterfalling is not an issue.
- For larger constant arrays (for example: 64 bone matrix array on a single mesh), the waterfalling cost is very much noticeable.
- If you are using a large constant array, but using the same indices a lot in a thread friendly manner (for example: a 256 material ID array in deferred rendering), the constant waterfalling is not usually an issue (depends on your access pattern really).
Solutions to prevent constant waterfalling in vertex shader:
- Use multiple vertex streams. This is most benefical if the hardware / API supports vfetch with user generated vertex index.
- Point sample textures. Useful for hardware that supports texture sampling in vertex shader (usually a bit slower than using vertex stream index read).
- Use render to vertex buffer (R2VB) to render your constants to a second render stream. Most useful if you have massive amount of dynamic constants.
Solutions to prevent constant waterfalling in pixel shader:
- Store your constants to a lookup texture and sample it with point sampling.