Platform SDK: DirectX

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.

[C++]

Performance of both hardware and software devices can benefit from using optimized vertex buffers. The optimization of vertex buffers differs depending on whether the vertex buffer is to be used for hardware or software vertex processing. Vertex buffers created with the D3DVBCAPS_SYSTEMMEMORY flag will, when optimized, be optimized for use with software vertex processing only, and can only be used with the IDirect3DVertexBuffer7::ProcessVertices method or the vertex-buffer rendering methods on a HAL Device (as opposed to a TnLHAL Device). Vertex buffers created without the D3DVBCAPS_SYSTEMMEMORY flag (for driver-optimal memory) will be optimized for hardware vertex processing, and thus can only be used for rendering methods on a TnLHAL Device. Optimized vertex buffers cannot be used as the destination buffer for the IDirect3DVertexBuffer7::ProcessVertices or IDirect3DVertexBuffer7::ProcessVerticesStrided methods.

Call the IDirect3DVertexBuffer7::Optimize method to optimize a vertex buffer. Optimizing a vertex buffer improves performance of vertex operations and rendering. The IDirect3DVertexBuffer7::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 IDirect3DVertexBuffer7::ProcessVertices method and the vertex buffer rendering methods.

[Visual Basic]

Performance of both hardware and software devices can benefit from using optimized vertex buffers. The optimization of vertex buffers differs depending on whether the vertex buffer is to be used for hardware or software vertex processing. Vertex buffers created with the D3DVBCAPS_SYSTEMMEMORY flag will, when optimized, be optimized for use with software vertex processing only, and can only be used with the Direct3DVertexBuffer7.ProcessVertices method or the vertex-buffer rendering methods on a HAL Device (as opposed to a TnLHAL Device). Vertex buffers created without the D3DVBCAPS_SYSTEMMEMORY flag (for driver-optimal memory) will be optimized for hardware vertex processing, and thus can only be used for rendering methods on a TnLHAL Device. Optimized vertex buffers cannot be used as the destination buffer for the Direct3DVertexBuffer7.ProcessVertices method.

Call the Direct3DVertexBuffer7.Optimize method to optimize a vertex buffer. Optimizing a vertex buffer improves performance of vertex operations and rendering. The Direct3DVertexBuffer7.Optimize method accepts one parameter. Set it to the Direct3DDevice7 object for which the vertices will be optimized. 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 Direct3DVertexBuffer7.ProcessVertices method and the vertex buffer rendering methods.