Vertex Buffer Descriptions

A vertex buffer is described in terms of its capabilities: if it can only exist in system memory, if it is only to be used for write operations, the type and number of vertices it can contain, and whether or not it has been optimized since it was created. All these traits are held within a D3DVERTEXBUFFERDESC structure.

Vertex buffer descriptions tell the system how to create a vertex buffer or tell your application how an existing buffer was created (and if it has been optimized since being created). You must specify a complete description to create a new vertex buffer, and you provide an empty description structure for the system to fill with the capabilities of a previously created vertex buffer. For more information about these tasks, see Creating a Vertex Buffer and Retrieving Vertex Buffer Descriptions.

The dwSize member, common to most DirectX structures, is used for identify structure versions and must be set to the structure size before the structure can be used with any methods. The dwCaps structure member contains general capability flags. The D3DVBCAPS_SYSTEMMEMORY flag indicates that the system should create (or already has created) the vertex buffer in system memory. Create an explicit system memory vertex buffer if your application uses a software rendering device; otherwise, it is best to let the system determine the best location by omitting the flag. For more information about explicit system memory vertex buffers, see Vertex Buffers and Device Types.

The presence of the D3DVBCAPS_WRITEONLY flag in dwCaps hints to the system that the vertex buffer memory is used only for write operations. This frees the driver to place the vertex data in the best possible memory location it can to enable fast processing and rendering. Reading from a vertex buffer that uses this flag can result in very slow memory access times. If the D3DVBCAPS_WRITEONLY flag isn't used, the driver is less likely to put the data in a location inefficient for read operations, sacrificing some processing and rendering speed. If no flags are specified, it is assumed that applications will perform read and write operations on the data within the vertex buffer.

Note  The D3DVBCAPS_OPTIMIZED flag is not used during vertex buffer creation. The system sets this capability when it optimizes a vertex buffer.

The final two D3DVERTEXBUFFERDESC structure members describe other capabilities. The dwFVF member contains a combination of flexible vertex format flags that identify the type of vertices that the buffer can contain. Vertex buffer capacity is measured by the total number of vertices it can contain, given in the dwNumVertices member.