The declaration portion of a vertex shader defines the static external
interface of the shader. The information in the declaration includes:
- Assignments of vertex shader input registers to data streams. These
assignments bind a specific vertex register to a single component within a
vertex stream. A vertex stream element is identified by a byte offset
within the stream and a type. The type specifies the arithmetic data type
plus the dimensionality (1, 2, 3, or 4 values). Stream data which is
less than 4 values are always expanded out to 4 values with zero or more
0.F values and one 1.F value.
- Assignment of vertex shader input registers to implicit data from the
primitive tessellator. This controls the loading of vertex data which is
not loaded from a stream, but rather is generated during primitive
tessellation prior to the vertex shader.
- Loading data into the constant memory at the time a shader is set as the
current shader. Each token specifies values for one or more contiguous 4
DWORD constant registers. This allows the shader to update an arbitrary
subset of the constant memory, overwriting the device state (which
contains the current values of the constant memory). Note that these
values can be subsequently overwritten (between DrawPrimitive calls)
during the time a shader is bound to a device via the
SetVertexShaderConstant method.
Declaration arrays are single-dimensional arrays of DWORDs composed of
multiple tokens each of which is one or more DWORDs. The single-DWORD
token value 0xFFFFFFFF is a special token used to indicate the end of the
declaration array. The single DWORD token value 0x00000000 is a NOP token
with is ignored during the declaration parsing. Note that 0x00000000 is a
valid value for DWORDs following the first DWORD for multiple word tokens.
[31:29] TokenType
0x0 - NOP (requires all DWORD bits to be zero)
0x1 - stream selector
0x2 - stream data definition (map to vertex input memory)
0x3 - vertex input memory from tessellator
0x4 - constant memory from shader
0x5 - extension
0x6 - reserved
0x7 - end-of-array (requires all DWORD bits to be 1)
NOP Token (single DWORD token)
[31:29] 0x0
[28:00] 0x0
Stream Selector (single DWORD token)
[31:29] 0x1
[28] indicates whether this is a tessellator stream
[27:04] 0x0
[03:00] stream selector (0..15)
Stream Data Definition (single DWORD token)
Vertex Input Register Load
[31:29] 0x2
[28] 0x0
[27:20] 0x0
[19:16] type (dimensionality and data type)
[15:04] 0x0
[03:00] vertex register address (0..15)
Data Skip (no register load)
[31:29] 0x2
[28] 0x1
[27:20] 0x0
[19:16] count of DWORDS to skip over (0..15)
[15:00] 0x0
Vertex Input Memory from Tessellator Data (single DWORD token)
[31:29] 0x3
[28] indicates whether data is normals or u/v
[27:24] 0x0
[23:20] vertex register address (0..15)
[19:16] type (dimensionality)
[15:04] 0x0
[03:00] vertex register address (0..15)
Constant Memory from Shader (multiple DWORD token)
[31:29] 0x4
[28:25] count of 4*DWORD constants to load (0..15)
[24:07] 0x0
[06:00] constant memory address (0..95)
Extension Token (single or multiple DWORD token)
[31:29] 0x5
[28:24] count of additional DWORDs in token (0..31)
[23:00] extension-specific information
End-of-array token (single DWORD token)
[31:29] 0x7
[28:00] 0x1fffffff
The stream selector token must be immediately followed by a contiguous set of stream data definition tokens. This token sequence fully defines that stream, including the set of elements within the stream, the order in which the elements appear, the type of each element, and the vertex register into which to load an element.
Streams are allowed to include data which is not loaded into a vertex register, thus allowing data which is not used for this shader to exist in the vertex stream. This skipped data is defined only by a count of DWORDs to skip over, since the type information is irrelevant.
The token sequence:
Stream Select: stream=0
Stream Data Definition (Load): type=FLOAT3; register=3
Stream Data Definition (Load): type=FLOAT3; register=4
Stream Data Definition (Skip): count=2
Stream Data Definition (Load): type=FLOAT2; register=7
defines stream zero to consist of 4 elements, 3 of which are loaded into registers and the fourth skipped over. Register 3 is loaded with the first three DWORDs in each vertex interpreted as FLOAT data. Register 4 is loaded with the 4th, 5th, and 6th DWORDs interpreted as FLOAT data. The next two DWORDs (7th and 8th) are skipped over and not loaded into any vertex input register. Register 7 is loaded with the 9th and 10th DWORDS interpreted as FLOAT data.
Placing of tokens other than NOPs between the Stream Selector and Stream Data Definition tokens is disallowed.
*/
typedef enum _D3DVSD_TOKENTYPE
{
D3DVSD_TOKEN_NOP = 0, // NOP or extension
D3DVSD_TOKEN_STREAM, // stream selector
D3DVSD_TOKEN_STREAMDATA, // stream data definition (map to vertex input memory)
D3DVSD_TOKEN_TESSELLATOR, // vertex input memory from tessellator
D3DVSD_TOKEN_CONSTMEM, // constant memory from shader
D3DVSD_TOKEN_EXT, // extension
D3DVSD_TOKEN_END = 7, // end-of-array (requires all DWORD bits to be 1)
D3DVSD_FORCE_DWORD = 0x7fffffff,// force 32-bit size enum