HLSL supports several scalar data types:
- bool - true or false.
- int - 32-bit signed integer.
- uint - 32-bit unsigned integer.
- dword - 32-bit unsigned integer.
- half - 16-bit floating point value. This data type is provided only for language compatibility. Direct3D 10 shader targets map all half data types to float data types. A half data type cannot be used on a uniform global variable (use the /Gec flag if this functionality is desired).
- float - 32-bit floating point value.
- double - 64-bit floating point value. You cannot use double precision values as inputs and outputs for a stream. To pass double precision values between shaders, declare each double as a pair of uint data types. Then, use the asdouble function to pack each double into the pair of uints and the asuint function to unpack the pair of uints back into the double.
Starting with Windows 8 HLSL also supports minimum precision scalar data types. Graphics drivers can implement minimum precision scalar data types by using any precision greater than or equal to their specified bit precision. We recommend not to rely on clamping or wrapping behavior that depends on specific underlying precision. For example, the graphics driver might execute arithmetic on a min16float value at full 32-bit precision.
- min16float - minimum 16-bit floating point value.
- min10float - minimum 10-bit floating point value.
- min16int - minimum 16-bit signed integer.
- min12int - minimum 12-bit signed integer.
- min16uint - minimum 16-bit unsigned integer.
For more information about scalar literals, see Grammar.
Differences between Direct3D 9 and Direct3D 10:
In Direct3D 10, the following types are modifiers to the float type.
For example, here is a 4-component signed-normalized float-variable declaration.
snorm float4 fourComponentIEEEFloat;
HLSL also supports a string type, which is an ASCII string. There are no operations or states that accept strings, but effects can query string parameters and annotations.