Mapping FVF Codes to a Direct3D 9 Declaration

This table maps FVF codes to a D3DVERTEXELEMENT9 structure.

FVF Data type Usage Usage index
D3DFVF_XYZ D3DDECLTYPE_FLOAT3 D3DDECLUSAGE_POSITION 0
D3DFVF_XYZRHW D3DDECLTYPE_FLOAT4 D3DDECLUSAGE_POSITIONT 0
D3DFVF_XYZW D3DDECLTYPE_FLOAT4 D3DDECLUSAGE_POSITION 0
D3DFVF_XYZB5 and D3DFVF_LASTBETA_UBYTE4 D3DVSDT_FLOAT3, D3DVSDT_FLOAT4, D3DVSDT_UBYTE4 D3DDECLUSAGE_POSITION, D3DDECLUSAGE_BLENDWEIGHT, D3DDECLUSAGE_BLENDINDICES 0
D3DFVF_XYZB5 and D3DFVF_LASTBETA_D3DCOLOR D3DVSDT_FLOAT3, D3DVSDT_FLOAT4, D3DVSDT_D3DCOLOR D3DDECLUSAGE_POSITION, D3DDECLUSAGE_BLENDWEIGHT, D3DDECLUSAGE_BLENDINDICES 0
D3DFVF_XYZB5 D3DDECLTYPE_FLOAT3, D3DDECLTYPE_FLOAT4, D3DDECLTYPE_FLOAT1 D3DDECLUSAGE_POSITION, D3DDECLUSAGE_BLENDWEIGHT, D3DDECLUSAGE_BLENDINDICES 0
D3DFVF_XYZBn (n=1..4) D3DDECLTYPE_FLOAT3, D3DDECLTYPE_FLOATn D3DDECLUSAGE_POSITION, D3DDECLUSAGE_BLENDWEIGHT 0
D3DFVF_XYZBn (n=1..4) and D3DFVF_LASTBETA_UBYTE4 D3DDECLTYPE_FLOAT3, D3DDECLTYPE_FLOAT(n-1), D3DDECLTYPE_UBYTE4 D3DDECLUSAGE_POSITION, D3DDECLUSAGE_BLENDWEIGHT, D3DDECLUSAGE_BLENDINDICES 0
D3DFVF_XYZBn (n=1..4) and D3DFVF_LASTBETA_D3DCOLOR D3DDECLTYPE_FLOAT3, D3DDECLTYPE_FLOAT(n-1), D3DDECLTYPE_D3DCOLOR D3DDECLUSAGE_POSITION, D3DDECLUSAGE_BLENDWEIGHT, D3DDECLUSAGE_BLENDINDICES 0
D3DFVF_NORMAL D3DDECLTYPE_FLOAT3 D3DDECLUSAGE_NORMAL 0
D3DFVF_PSIZE D3DDECLTYPE_FLOAT1 D3DDECLUSAGE_PSIZE 0
D3DFVF_DIFFUSE D3DDECLTYPE_D3DCOLOR D3DDECLUSAGE_COLOR 0
D3DFVF_SPECULAR D3DDECLTYPE_D3DCOLOR D3DDECLUSAGE_COLOR 1
D3DFVF_TEXCOORDSIZEm(n) D3DDECLTYPE_FLOATm D3DDECLUSAGE_TEXCOORD n

Vertex Declarations with D3DDECLUSAGE_POSITIONT

The presence of a vertex element with (D3DUSAGE_POSITIONT, 0) is used to indicate to the device that the vertex data coming in has already been through vertex processing (like an FVF with D3DFVF_XYZRHW bit set). At draw time, if the currently set declaration has an element with the (D3DUSAGE_POSITIONT, 0) semantic, the entire vertex processing is skipped (just as if an FVF with D3DFVF_XYZRHW bit has been set).

There are some restrictions on vertex declarations with (D3DDECLUSAGE_POSITIONT, 0):

In addition, there are some restrictions on such declaration related to the device driver version. These restrictions are in effect because Direct3D sends such declarations directly to the driver without doing any conversion.

Vertex Declarations without D3DDECLUSAGE_POSITIONT

Runtime validates the creation of declarations. Following are the general rules for what declarations are legal.

Driver Considerations

Pre-Direct3D 9 Drivers

Direct3D 9 Drivers without Pixel Shader Version 3 Support

Direct3D 9 Drivers with Pixel Shader Version 3 Support

More general declarations are allowed.

Vertex Declaration Usage with the Programmable Vertex Pipeline

There are additional restrictions when using with hardware vertex processing on a DirectX 8 driver:

The CreateVertexDeclaration might fail if the declaration provided cannot be converted to a DirectX 8-style declaration. For a mixed mode device, this failure will happen at Draw* time because that is the only time it can be known whether this shader is being used with hardware or software vertex processing.

Vertex Declaration Usage with the Fixed Function Pipeline

Only declarations that adhere to the following rules can be used:

When a declaration is used with hardware vertex processing on a DirectX 8 driver, the Direct3D runtime converts it to a DirectX 8-style declaration with the following rules:

Using Vertex Declarations with ProcessVertices

A vertex declaration could be used to describe the output of ProcessVertices. Such declaration should adhere to the following rules: