Question about instanced rendering performance

Started by
3 comments, last by _the_phantom_ 11 years, 5 months ago
Can you use instancing for everything?I mean obviously if something is rendered 1000 times,you should instance it,but what about if it's only rendered 1-5 times,does the instancing cycle(or whatever it is in the GPU) cause a large overhead?
Advertisement
Well, that's something to test. Instancing is a good way to reduce draw calls which helps to reduce the CPU load.

I use instancing in my projects for every drawn mesh and I don't make difference if there is just 1 instance or 100. This way I have only one shader for each case instead of 2 (because typically instancing shader and single object rendering shader are slightly different).

Cheers!
I believe that there is a cutoff point beyond which the performance of instancing is always better (and below which it's quite likely going to be slightly slower), but that this point will depend on hardware, drivers, API usage, API version, vertex formats, per-vertex data size, per-instance data size, etc, so it's impossible to give a definitive answer.

Personally I do the same as kauna here: if a model type is a candidate for instancing then I always draw it using an instanced path. The reasoning is also the same: being able to just have a single shader, and also a single code-path in my C++. If there is a performance hit then I accept that (a) it's going to be small, and (b) it's a fair tradeoff for the increased code simplicity.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

There is almost no difference between an instanced draw and a non-instanced draw on a modern GPU, since vertex fetch is performed by the shader cores.
There used to be a "use wisely, instancing has a non-neglegible fixed overhead" once upon a time, but that was 3 generations of hardware ago.

Meanwhile, people have abused instancing for implementing tesselation on NV40 hardware (which means using instancing on a per-triangle scale!). The performance is in my opinion entirely acceptable [Tatarinov08].
I'm pretty sure that engines such as the Frostbyte engine (BF3) treat all drawn objects as instanced draw calls (with maybe some case by case exceptions) based on the principle; if you have one then you'll likely have many.

This topic is closed to new replies.

Advertisement