Sunday, July 15, 2007

Why Objects Kill [Framerate]

Austin and I were running some numbers on the KSBD demo area DSF as part of a discussion of how instancing will someday allow X-Plane to render more objects. (Instancing is the ability to render multiple simple objects with a single instruction to the GPU...the requirement of one command to the GPU per object means that total object count is bottlenecked by the CPU->GPU connection.)

Here's some numbers:

KSBD contains 868,220 mesh vertices - at 32 bytes per vertex, we have about 27 MB of geometry per DSF. In one view we picked, about 20% of those vertices were on screen. (But since there are six DSFs loaded, really only about 3% of a DSF mesh is seen at one time at lower altitudes.)

KSBD contains 153,816 objects. Near the airport, we average about 238 vertices per object. (This is a GOOD number - less than 100 vertices would imply that we aren't sending out enough vertices for each command to draw.) But this means that if we were to simply store all of the objects as one huge object, we would have 1.1 GB of object memory! This is why you can't just make a single huge object for the world. :-)

(X-Plane of course stores each OBJ file once, saving a lot of memory. But then we burn CPU power telling each OBJ to be drawn over and over in many places.)

It also explains why forests keep causing people to run out of memory. Consider that only about 3% of the mesh may be visible (when we're at lower altitudes, where you can see the trees). This means that we need about 30x as much memory to storage geometry as the card can draw. With cards so fast, we easily run out of memory before we max the card out.

6 comments:

Anonymous said...

So, why don't you then program a usable system? Other sims can also draw a lot of scenery and don't run out of memory (eg MSFS).

Benjamin Supnik said...

The system is already usable. All systems have trade-offs between memory and performance. We chose one particular trade-off...the only way that we can have our cake and eat it is with newer, more sophisticated hardware, like the 8800, which is where we will eventually end up.

Easyglider said...

Thanks for these nice hints. Should I use triangles instead of rectacles when constructing objects with AC3D or better should i triangulate the rectacles to get better power. I will try to build groups with the same attributes.

Benjamin Supnik said...

Hi Holger,

It doesn't matter - if you make a quad and save as an OBJ8, ac3d triangulates it. If you save a quad in OBJ7, x-plane triangulates it. So the end result is the same whether you triangulate or not.

Easyglider said...

Thanks for your answer! Where can I find a tool to see the attributes of my with AC3D designed objects? I have the problem that I made a surface transparent (which is not showed in AC3D but in xplane). I'm trying to find a way to repeat now what I've done by luck.

Benjamin Supnik said...

I don't know of a tool that will do that, but just open the OBJ file in a text editor to see all attributes - the "end" of the OBJ with the attributes and TRIs command is relatively easy to read.