Previous Next

D3dDrawPrimitives2

The D3dDrawPrimitives2 function renders primitives and returns the updated render state.

DWORD
  (APIENTRY *LPD3DHAL_DRAWPRIMITIVES2CB)(
    LPD3DHAL_DRAWPRIMITIVES2DATA  pdp
    );

Parameters

pdp
Points to a D3DHAL_DRAWPRIMITIVES2DATA structure that contains the information required for the driver to render one or more primitives.

Return Value

D3dDrawPrimitives2 returns one of the following callback codes:

DDHAL_DRIVER_HANDLED

DDHAL_DRIVER_NOTHANDLED

Headers

Declared in d3dhal.h. Include d3dhal.h.

Comments

D3dDrawPrimitives2 must be implemented in Direct3D drivers.

The driver must do the following:

The driver does not need to probe for readability of the memory where the command and vertex buffers are stored. However, the driver must stay within the bounds specified by the dwCommandLength and dwVertexLength members of D3DHAL_DRAWPRIMITIVES2DATA.

If the driver must fail D3dDrawPrimitives2, it should fill in the dwErrorOffset member of D3DHAL_DRAWPRIMITIVES2DATA with the offset into the command buffer where the first unhandled D3DHAL_DP2COMMAND can be found.

If the driver is used with a DirectX 8.1 or later runtime, the driver's D3dDrawPrimitives2 function should never cause rendering from the current vertex buffer (passed in via lpDDVertex) to stall if the buffer is implicit. If the buffer is explicit and there is an outstanding lock on it, the driver should stall at the end of its D3dDrawPrimitives2 function if it does not rename the buffer (does not set D3DHALDP2_SWAPVERTEXBUFFER). If the driver renames the buffer, then the driver does not stall. DirectX 8.1 and later runtimes call the driver's D3dDrawPrimitives2 function to render from a locked explicit vertex buffer only when necessary so performance is rarely affected. An implicit vertex buffer is created by the driver's CreateD3DBuffer callback with only the DDSCAPS_EXECUTEBUFFER flag set. An explicit vertex buffer is created by the driver's CreateD3DBuffer callback with the DDSCAPS_EXECUTEBUFFER and DDSCAPS2_VERTEXBUFFER flags set. The explicit vertex buffer becomes locked by the driver's LockD3DBuffer callback.

If the driver is used with a DirectX 8.0 runtime, the driver should sometimes stall when rendering from an implicit vertex buffer to prevent synchronization issues and resulting corruption. In addition, the DirectX 8.0 runtime calls the driver's D3dDrawPrimitives2 function to render from a locked explicit vertex buffer more often then really necessary so performance is degraded. The following are stalling workarounds for a driver that is used with a DirectX 8.0 runtime:

See Also

D3DHAL_DP2INDEXEDLINELIST, D3DHAL_DP2INDEXEDLINESTRIP, D3DHAL_DP2INDEXEDTRIANGLEFAN, D3DHAL_DP2INDEXEDTRIANGLELIST, D3DHAL_DP2INDEXEDTRIANGLESTRIP, D3DHAL_DP2LINELIST, D3DHAL_DP2LINESTRIP, D3DHAL_DP2POINTS, D3DHAL_DP2TRIANGLEFAN, D3DHAL_DP2TRIANGLELIST, D3DHAL_DP2TRIANGLESTRIP, FVF