User-Defined Type

Use the following syntax to declare a user-defined type.

typedef [const] Type Name[Index];

Parameters

Item Description
[const]
Optional. This keyword explicitly marks the type as a constant.
Type
Identifies the data type; must be one of the HLSL intrinsic data types.
Name
An ASCII string that uniquely identifies the variable name.
Index
Optional array size. Must be an unsigned integer between 1 and 4 inclusive.

In addition to the built-in intrinsic data types, HLSL supports user-defined or custom types which follow this syntax:

Remarks

User-defined types are not case-sensitive. For convenience, the following types are automatically defined at super-global scope.

typedef vector <bool, #> bool#;
typedef vector <int, #> int#;
typedef vector <uint, #> uint#;
typedef vector <half, #> half#;
typedef vector <float, #> float#;
typedef vector <double, #> double#;

typedef matrix <bool, #, #> bool#x#;
typedef matrix <int, #, #> int#x#;
typedef matrix <uint, #, #> uint#x#;
typedef matrix <half, #, #> half#x#;
typedef matrix <float, #, #> float#x#;
typedef matrix <double, #, #> double#x#;

The pound sign (#) represents an integer digit between 1 and 4.

For compatibility with DirectX 8 effects, the following types are automatically defined at super-global scope:

typedef int DWORD;
typedef float FLOAT; 
typedef vector <float, 4> VECTOR;
typedef matrix <float, 4, 4> MATRIX;
typedef string STRING;
typedef texture TEXTURE;
typedef pixelshader PIXELSHADER;
typedef vertexshader VERTEXSHADER;

Data Types (DirectX HLSL)