Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am currently reading upon Geometry Instancing, as I want to render a lot of animatable objects on the screen.

However I have come to a more fundamental question first: Why do I even need to use it?

Consider this setup:

  • A plane as the base of the game world
  • On top of that a lot of tiles, which can be destructable with the use of a Physics Engine.
  • A camera which you can control with WASD + mouse for direction.

Now I do understand that there definately must be a performance hit at some point. I thought it would occur when sending all object data (vertices) to the GPU.

However the performance hit remains to be there, at every single frame it renders, what is actually happening in the background? Considering nothing at my scene is changing at all, it even happens when I do not move the camera at all.

I have no clue what exactly is going on and would definately want to read up more about it before starting to fix an issue that I do not understand, thus making the fix also harder to understand. I do know however that the fix (Geometry Instancing) works by sending the vertex data only once per multiple of objects based on that same vertex. So somehow it would have to do with the amount of vertices, yet I don't see what is going on?

Also: I am using the Ogre3D engine, so any specific answers/tips to that engine would also be welcome.

Regards.

share|improve this question
    
Can you show example of what kind of scene are you rendering ? are you sure your performance hit is caused by being GPU bound ? –  concept3d Oct 15 '13 at 20:45
    
@concept3d It might very well be that it is CPU limited, nowhere I say it is GPU limited. I can't show any example at the moment, but think about it as a 1500 x 1500 textured plane (as ground), with 5 x 5 concrete tiles (3D object, texture applied on it) on top of it. –  skiwi Oct 15 '13 at 20:49
    
Okay a bug issue performance-wise was that Ogre ran in debug mode, now it can run 400 batches (100 entities + Stencil Additive shadow) fine, at 1600 batches it gets a big performance hit. At least miles better. –  skiwi Oct 16 '13 at 9:53
add comment

1 Answer

up vote 3 down vote accepted

Since you talk about drawing tiles, I presume the geometry of a tile is pretty simple, e.g. just 2 triangles in a square. If that's the case, and you're drawing a large number of tiles, geometry instancing could certainly help you.

There is a certain amount of performance overhead per draw call on both the CPU and the GPU. The details depend on your hardware, drivers, etc. but in general, if you have fewer than a couple hundred vertices per draw call, you're not likely to be using the GPU efficiently; and if you have more than a few thousand draw calls per frame, you're likely using too much CPU and becoming CPU-limited. Instancing allows you to put more stuff in each draw, making each draw do more work, so the per-draw overhead doesn't hurt you so much.

The reason too-small draws hurt on the GPU is that internally, GPUs need to store a little bit of data about each draw call currently in flight, and they have a limited buffer of memory for this data, so only somewhere around 8 draw calls at most can run at the same time. If the draws are so small (have so few vertices) that 8 draw calls don't use all the GPU's capacity, then that extra capacity is being left idle, and could be put to work by using instancing to make the draws bigger.

On the CPU side, the graphics driver has to do some validation, memory management and other housekeeping tasks whenever you submit a draw call, and this can add up. The rule of thumb for D3D9 is no more than 2,000 to 3,000 draw calls per frame to avoid becoming CPU-limited. I'm not sure about OpenGL or about newer D3Ds, but the limit is going to be in the range of a few thousand. This work is not really dependent on the number of vertices drawn, just on the number of individual draw calls. So fewer, larger draw calls are more efficient here as well.

share|improve this answer
1  
Okay, I understand it somewhat more now. Still one fundamental thing remains, which I should understand: Are the draw calls being done every single frame, even though the position of the objects in 3D space does not change? –  skiwi Oct 16 '13 at 9:05
    
@skiwi draw calls should be performed every frame, that's how computer graphics work, update calls on the other hand shouldn't be . –  concept3d Oct 16 '13 at 12:25
    
@skiwi Yes, in general whenever the frame changes it needs to be redrawn from scratch. Of course, if absolutely nothing has changed you can just keep using the old image. But if, for instance, the camera moves or a few objects move, we usually must re-render everything. –  Nathan Reed Oct 16 '13 at 16:59
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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