Autogen trees and Vertex Buffers

In order to display a frame FSX needs to assemble together three things

  • Textures
  • Vertex and Index Buffers
  • Draw Instructions

The drawcalls we were looking at were only showing us the final third of this.

So how does FSX work as you fly?

My understanding of the precise terminology is a bit ropey here but essentially one would imagines that as a “cell” in the grid comes into view this comes with

terrain which maps to a texture,

heights which determine the vertices with which the ground is painted

instructions which determine the autogen to be created, exclusions which exclude autogen and objects such as non autogen buildings – the scenery.

All of these come with their own geometry and textures.

Now there are strong suggestions on the web that the terrain loading is handled in separate threads from the main rendering thread. These threads can be caught in terrain.dll by the debugger which backs this theory up somewhat.

DX9 only really allows a single thread to issues instructions to the GPU so although these threads may read the disk and determine what autogen needs to be drawn the creation of Texture Buffers and Vertex Buffers must surely occur back in the main rendering thread.

So the rendering thread must loop

Creating new textures

Creating/Updating Vertex Buffers

Issuing drawcalls

+ other stuff ATC etc

What is interesting to consider is the trees.

Does the autogen quantity increase as you fly towards a cell? Is the vertex buffer created with several thousand trees at 5 miles – or are more added as you approach. What happens as a cell passes out of view – are entries removed one by one?

Here is a test flying towards an island

At this distance we see 4 trees being drawn

There are now 8 trees in this write

Still 8

Now up to 28

Now 66

And 136 trees

So yes it seems that the tree count is increased as a cell gets closer. I think that the buffer numbers used by the Intel tool in the SetStream calls indicate that a new vertex buffer is created for this – I am surprised that it doesn’t create the full vertex buffer at the beginning and us ethe index buffer to control which get displayed.

Comparing the first and last frames – look at the light blue line above the image for this – the time to display increased from 24µs to 34.5 µs

So going from 4-136 trees increased the time by 50%.

About stevefsx

I don't use FSX that much. But I am very annoyed when it doesn't work properly!
This entry was posted in Autogen, Drawcalls. Bookmark the permalink.