Direct3DDevice.ProcessVertices

Started by
2 comments, last by bahos 22 years, 4 months ago
Has anyone used this method and/or could point me to an example which uses this method? I''ve been hunting around for info on ProcessVertices but haven''t found anything useful yet. I''ve tried using it in my code but keep getting an error. I need to use ProcessVertices to get transformed vertices for collision detection.
Advertisement
explain errors.
Cut and paste from the DirectX 8 (C++) documentation:
quote:

Device Types and Vertex Processing Requirements



The performance of vertex processing operations, including transformation and lighting, depends heavily on where the vertex buffer exists in memory and what type of rendering device is being used. Applications control the memory allocation for vertex buffers when they are created. When the D3DPOOL_SYSTEMMEM memory flag is set, the vertex buffer is created in system memory. When the D3DPOOL_DEFAULT memory flag is used, the device driver determines where the memory for the vertex buffer is best allocated, often referred to as driver-optimal memory. Driver-optimal memory can be local video memory, nonlocal video memory, or system memory.

Setting the D3DUSAGE_SOFTWAREPROCESSING behavior flag when calling the IDirect3DDevice8::CreateVertexBuffer method specifies that the vertex buffer is to be used with software vertex processing. This flag is required for software vertex processing in mixed vertex processing mode. This flag is allowed in software vertex processing mode and disallowed in hardware vertex processing mode. Vertex buffers used with software vertex processing include the following:
  • All input streams for IDirect3DDevice8:rocessVertices.

  • All input streams for IDirect3DDevice8::DrawPrimitive and IDirect3DDevice8::DrawIndexedPrimitive when software vertex processing. For more information, see D3DRS_SOFTWAREVERTEXPROCESSING.

The reasoning you use to determine the memory location—system or driver optimal—for vertex buffers is the same as that for textures. Vertex processing, including transformation and lighting, in hardware works best when the vertex buffers are allocated in driver-optimal memory, while software vertex processing works best with vertex buffers allocated in system memory. For textures, hardware rasterization works best when textures are allocated in driver-optimal memory, while software rasterization works best with system-memory textures.

Note Microsoft® Direct3D® supports standalone processing of vertices, without rendering any primitive with the ProcessVertices method. This standalone vertex processing is always performed in software on the host processor. Because of this, vertex buffers used as sources set with IDirect3DDevice8::SetStreamSource must be created with the D3DUSAGE_SOFTWAREPROCESSING flag. The functionality provided by ProcessVertices is identical to that of the IDirect3DDevice8::DrawPrimitive and IDirect3DDevice8::DrawIndexedPrimitive methods while using software vertex processing.

If your application performs its own vertex processing and passes transformed, lit, and clipped vertices to rendering methods, then the application can directly write vertices to a vertex buffer allocated in driver-optimal memory. This technique prevents a redundant copy operation later. Note that this technique will not work well if your application reads data back from a vertex buffer, because read operations done by the host from driver-optimal memory can be very slow. Therefore, if your application needs to read during processing or writes data to the buffer erratically, a system-memory vertex buffer is a better choice.

When using the Direct3D vertex processing features (by passing untransformed vertices to vertex-buffer rendering methods), processing can occur in either hardware or software depending on the device type and device creation flags. It is recommended that vertex buffers be allocated in pool D3DPOOL_DEFAULT for best performance in virtually all cases. When a device is using hardware vertex processing, there is a number of additional optimizations that may be done based on the flags D3DUSAGE_DYNAMIC and D3DUSAGE_WRITEONLY. See IDirect3DDevice8::CreateVertexBuffer for more information on using these flags.

As always, rtfm.

[ GDNet Start Here | GDNet FAQ | MS RTFM | STL | Google ]
Thanks to Kylotan for the idea!
Thanks for the replies. I''ll have a close read of the quote tomorrow and hopefully get it going (I''ve been using the vb sdk which didn''t seem to have quite as much detail as that). I originally transformed my vertices with vb code (using matices), which worked perfectly, but slowly. Today I began coding it as a small c++ dll instead, but if I can get process vertices to work instead, I''m sure it would be a lot better.

This topic is closed to new replies.

Advertisement