Optimizing a Vertex Buffer

Optimizing a vertex buffer causes the system to modify the contents of the buffer for better performance when processing or rendering vertices. Exactly how vertices are optimized is platform-specific and subject to change. Consequently, you cannot lock or otherwise access the contents of an optimized vertex buffer.

Call the IDirect3DVertexBuffer::Optimize method to optimize a vertex buffer. Optimizing a vertex buffer improves performance of vertex operations and rendering. The IDirect3DVertexBuffer::Optimize method accepts two parameters, only one of which is used. Set the lpD3DDevice parameter to the address of the device for which the vertices will be optimized, and set the last parameter to 0. Locked vertex buffers cannot be optimized until they are unlocked.

You can improve performance by keeping vertices in optimized format. However, optimized vertex buffers should be used only for static geometry, because once a vertex buffer is optimized, you can't lock it to change the optimized contents. After you optimize a vertex buffer, it can only be used with the IDirect3DVertexBuffer::ProcessVertices method and the vertex buffer rendering methods.