2
\$\begingroup\$

I'm adding batched rendering to my game engine and I'm wondering: Should I support non-indexed, non-instanced batches or just indexed and/or instanced?

It's my understanding that the concept of indexed rendering was invented after pure "vertex only" drawing. That said, is supporting vertex-only rendering useful anymore? Is there a modern use-case for it?

\$\endgroup\$
  • 1
    \$\begingroup\$ If the vertex is used only once, there's no value in using indexed drawing. For example, the simplest case of drawing a single triangle for a full-screen quad. \$\endgroup\$ – Chuck Walbourn Jun 8 at 22:57
  • \$\begingroup\$ Contrariwise, even in cases where vertices are only used once, indices can still be useful for concatenating primitives to get bigger batches. \$\endgroup\$ – Maximus Minimus Jun 9 at 21:50
2
\$\begingroup\$

If you're looking to simplify down, then it may be helpful to bear the following in mind:

  • 1 is a valid value for number of instances.
  • An index buffer of 0,1,2,3,4,5,6,etc can replicate non-indexed rendering.

In that sense, you can certainly have all of your draw calls be indexed instanced calls, yet still be able to deal with unforseen cases where either or both of non-instanced or non-indexed may seem to be needed.

It can also be instructive to look at how modern APIs handle this, so:

  • In Vulkan, every draw call is an instanced draw call (bearing in mind that 1 is still a valid value for number of instances), but separate draw calls still exist for indexed and non-indexed cases.
  • Direct3D 12 likewise only has DrawInstanced and DrawIndexedInstanced.

So this suggests that even for modern use, there is still benefit to be gained from supporting non-indexed cases, but not from non-instanced cases.

So what non-indexed cases still exist? Looking over some of my own code, I use non-indexed for the following:

  • Lists of points in a particle system.
  • Full-screen post-processing passes.
  • Some 2D UI elements.
| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.