In addition to the built-in intrinsic data types, HLSL supports user-defined or custom types which follow this syntax:
typedef [const] type id [array_suffix];
where:
typedef | Declares a name for a type. |
const | This keyword explicitly marks the type as a constant. |
type | Identifies the data type, it must be one of the HLSL intrinsic data types. |
id | Identifies the variable name. |
array_suffix | Optional array brackets identify whether the variable contains a single value, or contains an array of values. |
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;
These types are not case-insensitive.
For convenience, the following types are automatically defined at super-global scope. Note that the pound sign (#) represents an integer digit between 1 and 4.
typedef vector <bool, #> bool#; typedef vector <int, #> int#; typedef vector <half, #> half#; typedef vector <float, #> float#; typedef vector <double, #> double#; typedef matrix <bool, #, #> bool#x#; typedef matrix <int, #, #> int#x#; typedef matrix <half, #, #> half#x#; typedef matrix <float, #, #> float#x#; typedef matrix <double, #, #> double#x#;