Hardware Buffers In OGRE: Buffer Usage

[ < ] | [ Up ] | [ > ] |  |  |  |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 2.2 Buffer Usage

Because the memory in a hardware buffer is likely to be under significant contention during the rendering of a scene, the kind of access you need to the buffer over the time it is used is extremely important; whether you need to update the contents of the buffer regularly, whether you need to be able to read information back from it, these are all important factors to how the graphics card manages the buffer. The method and exact parameters used to create a buffer depends on whether you are creating an index or vertex buffer (See section 2.6 Hardware Vertex Buffers and See section 2.7 Hardware Index Buffers), however one creation parameter is common to them both - the 'usage'.
The most optimal type of hardware buffer is one which is not updated often, and is never read from. The usage parameter of createVertexBuffer or createIndexBuffer can be one of the following:

`HBU_STATIC`
  This means you do not need to update the buffer very often, but you might occasionally want to read from it.
`HBU_STATIC_WRITE_ONLY`
  This means you do not need to update the buffer very often, and you do not need to read from it. However, you may read from it's shadow buffer if you set one up (See section 2.3 Shadow Buffers). This is the optimal buffer usage setting.
`HBU_DYNAMIC`
  This means you expect to update the buffer often, and that you may wish to read from it. This is the least optimal buffer setting.
`HBU_DYNAMIC_WRITE_ONLY`
  This means you expect to update the buffer often, but that you never want to read from it. However, you may read from it's shadow buffer if you set one up (See section 2.3 Shadow Buffers).

Choosing the usage of your buffers carefully is important to getting optimal performance out of your geometry. If you have a situation where you need to update a vertex buffer often, consider whether you actually need to update all the parts of it, or just some. If it's the latter, consider using more than one buffer, with only the data you need to modify in the HBU_DYNAMIC buffer.
Always try to use the _WRITE_ONLY forms. This just means that you cannot read directly from the hardware buffer, which is good practice because reading from hardware buffers is very slow. If you really need to read data back, use a shadow buffer, described in the next section.

[ < ] | [ Up ] | [ > ] |  |  |  |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

This document was generated by Steve Streeting on , 21 2003 using texi2html