Supporting Vertex Elements Sharing Offset in a Stream

A DirectX 9.0 version driver indicates that its device lets multiple vertex elements share the same offset in a stream by setting the D3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET capability bit in the DevCaps2 member of the D3DCAPS9 structure. A vertex shader declaration consists of an array of vertex elements. For more information, see Separating Declarations and Code for Vertex Shaders.

If a DirectX 9.0 driver for a device that supports pixel shader (PS) versions earlier than 3.0 sets D3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET, the driver can handle most vertex declarations with elements that specify the D3DDECLUSAGE_POSITIONT (0) usage type. This pre PS 3.0-driver converts vertex declarations with D3DDECLUSAGE_POSITIONT (0) to valid flexible vertex format (FVF). However, this pre PS 3.0-driver cannot handle vertex declarations with elements that specify the D3DDECLUSAGE_POSITIONT (0) usage type if the declarations have gaps in texture coordinates. For example, this pre PS 3.0-driver cannot handle the following vertex declaration:

{0,0,D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITIONT, 0}
{0,16,D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0}
{0,24,D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 5}

Because there is a gap in the texture coordinates, this pre PS 3.0-driver cannot express the D3DDECLUSAGE_TEXCOORD elements using FVF.

If a DirectX 9.0 driver for a device that supports pixel shader 3.0 and later sets D3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET, the driver must handle all vertex declarations with elements that specify the D3DDECLUSAGE_POSITIONT (0) usage type. This driver must let multiple vertex elements:

  • Share the same offset in a stream.

  • Be different types. Therefore, they can have different sizes.

  • Overlap arbitrarily. For example, one element can start at a location of a stream that is currently in the middle of another element.