Dynamic Vertex and Index Buffers

A dynamic vertex or index buffer is a resource that an application frequently locks and writes to. When a dynamic buffer is locked in a call to the driver's LockD3DBuffer function, the DDLOCK_OKTOSWAP bit (also known as the D3DLOCK_DISCARD bit) of the dwFlags member of the DD_LOCKDATA structure can be set to indicate that the caller does not require the existing contents of the buffer. Therefore, the driver can discard the contents before returning the pointer to the buffer data. Because the caller does not require the existing contents, the driver can rename the buffer by setting the fpVidMem member of the DD_SURFACE_GLOBAL structure for the buffer to a new value. By renaming the buffer (that is, setting up multiple buffering), the driver avoids hardware stalling.

The DDLOCK_OKTOSWAP bit can only be set to lock dynamic buffers and never to lock static buffers.

Note that drivers should store dynamic buffers in AGP memory because if dynamic buffers are stored in local video memory and an application writes data into those buffers in a nonsequential manner, bus performance might be seriously affected.