5.0 Mask operations
With width four SIMD at least four bits are needed to represent a mask:
SSE uses the same 128-bit type for representing masks returned by floating point comparisons. Single float's byte sequence 0x00000000 in hexadecimals represents false and 0xFFFFFFFF represents true. SSE has comparison instructions for all the basic arithmetic comparisons like greater or equal than.
Mask are then produced by using standard C++ comparison operators between two vec4 types:
or listing all the elements:
The resulting mask can then be used to conditionally only write to parts of vec4 or deciding a path based on whether all the bits are set, none of them are set, or some of them are set.
Examples of different kinds of control logic turned into mask operations can be found in the algorithm examples.