Collection of DPF-based plugins for packaging
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

229 lines
8.4KB

  1. /// @ref gtc_bitfield
  2. /// @file glm/gtc/bitfield.hpp
  3. ///
  4. /// @see core (dependence)
  5. /// @see gtc_bitfield (dependence)
  6. ///
  7. /// @defgroup gtc_bitfield GLM_GTC_bitfield
  8. /// @ingroup gtc
  9. ///
  10. /// Include <glm/gtc/bitfield.hpp> to use the features of this extension.
  11. ///
  12. /// Allow to perform bit operations on integer values
  13. #include "../detail/setup.hpp"
  14. #pragma once
  15. // Dependencies
  16. #include "../detail/qualifier.hpp"
  17. #include "../detail/type_int.hpp"
  18. #include "../detail/_vectorize.hpp"
  19. #include <limits>
  20. #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED)
  21. # pragma message("GLM: GLM_GTC_bitfield extension included")
  22. #endif
  23. namespace glm
  24. {
  25. /// @addtogroup gtc_bitfield
  26. /// @{
  27. /// Build a mask of 'count' bits
  28. ///
  29. /// @see gtc_bitfield
  30. template<typename genIUType>
  31. GLM_FUNC_DECL genIUType mask(genIUType Bits);
  32. /// Build a mask of 'count' bits
  33. ///
  34. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  35. /// @tparam T Signed and unsigned integer scalar types
  36. /// @tparam Q Value from qualifier enum
  37. ///
  38. /// @see gtc_bitfield
  39. template<length_t L, typename T, qualifier Q>
  40. GLM_FUNC_DECL vec<L, T, Q> mask(vec<L, T, Q> const& v);
  41. /// Rotate all bits to the right. All the bits dropped in the right side are inserted back on the left side.
  42. ///
  43. /// @see gtc_bitfield
  44. template<typename genIUType>
  45. GLM_FUNC_DECL genIUType bitfieldRotateRight(genIUType In, int Shift);
  46. /// Rotate all bits to the right. All the bits dropped in the right side are inserted back on the left side.
  47. ///
  48. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  49. /// @tparam T Signed and unsigned integer scalar types
  50. /// @tparam Q Value from qualifier enum
  51. ///
  52. /// @see gtc_bitfield
  53. template<length_t L, typename T, qualifier Q>
  54. GLM_FUNC_DECL vec<L, T, Q> bitfieldRotateRight(vec<L, T, Q> const& In, int Shift);
  55. /// Rotate all bits to the left. All the bits dropped in the left side are inserted back on the right side.
  56. ///
  57. /// @see gtc_bitfield
  58. template<typename genIUType>
  59. GLM_FUNC_DECL genIUType bitfieldRotateLeft(genIUType In, int Shift);
  60. /// Rotate all bits to the left. All the bits dropped in the left side are inserted back on the right side.
  61. ///
  62. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  63. /// @tparam T Signed and unsigned integer scalar types
  64. /// @tparam Q Value from qualifier enum
  65. ///
  66. /// @see gtc_bitfield
  67. template<length_t L, typename T, qualifier Q>
  68. GLM_FUNC_DECL vec<L, T, Q> bitfieldRotateLeft(vec<L, T, Q> const& In, int Shift);
  69. /// Set to 1 a range of bits.
  70. ///
  71. /// @see gtc_bitfield
  72. template<typename genIUType>
  73. GLM_FUNC_DECL genIUType bitfieldFillOne(genIUType Value, int FirstBit, int BitCount);
  74. /// Set to 1 a range of bits.
  75. ///
  76. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  77. /// @tparam T Signed and unsigned integer scalar types
  78. /// @tparam Q Value from qualifier enum
  79. ///
  80. /// @see gtc_bitfield
  81. template<length_t L, typename T, qualifier Q>
  82. GLM_FUNC_DECL vec<L, T, Q> bitfieldFillOne(vec<L, T, Q> const& Value, int FirstBit, int BitCount);
  83. /// Set to 0 a range of bits.
  84. ///
  85. /// @see gtc_bitfield
  86. template<typename genIUType>
  87. GLM_FUNC_DECL genIUType bitfieldFillZero(genIUType Value, int FirstBit, int BitCount);
  88. /// Set to 0 a range of bits.
  89. ///
  90. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  91. /// @tparam T Signed and unsigned integer scalar types
  92. /// @tparam Q Value from qualifier enum
  93. ///
  94. /// @see gtc_bitfield
  95. template<length_t L, typename T, qualifier Q>
  96. GLM_FUNC_DECL vec<L, T, Q> bitfieldFillZero(vec<L, T, Q> const& Value, int FirstBit, int BitCount);
  97. /// Interleaves the bits of x and y.
  98. /// The first bit is the first bit of x followed by the first bit of y.
  99. /// The other bits are interleaved following the previous sequence.
  100. ///
  101. /// @see gtc_bitfield
  102. GLM_FUNC_DECL int16 bitfieldInterleave(int8 x, int8 y);
  103. /// Interleaves the bits of x and y.
  104. /// The first bit is the first bit of x followed by the first bit of y.
  105. /// The other bits are interleaved following the previous sequence.
  106. ///
  107. /// @see gtc_bitfield
  108. GLM_FUNC_DECL uint16 bitfieldInterleave(uint8 x, uint8 y);
  109. /// Interleaves the bits of x and y.
  110. /// The first bit is the first bit of x followed by the first bit of y.
  111. /// The other bits are interleaved following the previous sequence.
  112. ///
  113. /// @see gtc_bitfield
  114. GLM_FUNC_DECL int32 bitfieldInterleave(int16 x, int16 y);
  115. /// Interleaves the bits of x and y.
  116. /// The first bit is the first bit of x followed by the first bit of y.
  117. /// The other bits are interleaved following the previous sequence.
  118. ///
  119. /// @see gtc_bitfield
  120. GLM_FUNC_DECL uint32 bitfieldInterleave(uint16 x, uint16 y);
  121. /// Interleaves the bits of x and y.
  122. /// The first bit is the first bit of x followed by the first bit of y.
  123. /// The other bits are interleaved following the previous sequence.
  124. ///
  125. /// @see gtc_bitfield
  126. GLM_FUNC_DECL int64 bitfieldInterleave(int32 x, int32 y);
  127. /// Interleaves the bits of x and y.
  128. /// The first bit is the first bit of x followed by the first bit of y.
  129. /// The other bits are interleaved following the previous sequence.
  130. ///
  131. /// @see gtc_bitfield
  132. GLM_FUNC_DECL uint64 bitfieldInterleave(uint32 x, uint32 y);
  133. /// Interleaves the bits of x, y and z.
  134. /// The first bit is the first bit of x followed by the first bit of y and the first bit of z.
  135. /// The other bits are interleaved following the previous sequence.
  136. ///
  137. /// @see gtc_bitfield
  138. GLM_FUNC_DECL int32 bitfieldInterleave(int8 x, int8 y, int8 z);
  139. /// Interleaves the bits of x, y and z.
  140. /// The first bit is the first bit of x followed by the first bit of y and the first bit of z.
  141. /// The other bits are interleaved following the previous sequence.
  142. ///
  143. /// @see gtc_bitfield
  144. GLM_FUNC_DECL uint32 bitfieldInterleave(uint8 x, uint8 y, uint8 z);
  145. /// Interleaves the bits of x, y and z.
  146. /// The first bit is the first bit of x followed by the first bit of y and the first bit of z.
  147. /// The other bits are interleaved following the previous sequence.
  148. ///
  149. /// @see gtc_bitfield
  150. GLM_FUNC_DECL int64 bitfieldInterleave(int16 x, int16 y, int16 z);
  151. /// Interleaves the bits of x, y and z.
  152. /// The first bit is the first bit of x followed by the first bit of y and the first bit of z.
  153. /// The other bits are interleaved following the previous sequence.
  154. ///
  155. /// @see gtc_bitfield
  156. GLM_FUNC_DECL uint64 bitfieldInterleave(uint16 x, uint16 y, uint16 z);
  157. /// Interleaves the bits of x, y and z.
  158. /// The first bit is the first bit of x followed by the first bit of y and the first bit of z.
  159. /// The other bits are interleaved following the previous sequence.
  160. ///
  161. /// @see gtc_bitfield
  162. GLM_FUNC_DECL int64 bitfieldInterleave(int32 x, int32 y, int32 z);
  163. /// Interleaves the bits of x, y and z.
  164. /// The first bit is the first bit of x followed by the first bit of y and the first bit of z.
  165. /// The other bits are interleaved following the previous sequence.
  166. ///
  167. /// @see gtc_bitfield
  168. GLM_FUNC_DECL uint64 bitfieldInterleave(uint32 x, uint32 y, uint32 z);
  169. /// Interleaves the bits of x, y, z and w.
  170. /// The first bit is the first bit of x followed by the first bit of y, the first bit of z and finally the first bit of w.
  171. /// The other bits are interleaved following the previous sequence.
  172. ///
  173. /// @see gtc_bitfield
  174. GLM_FUNC_DECL int32 bitfieldInterleave(int8 x, int8 y, int8 z, int8 w);
  175. /// Interleaves the bits of x, y, z and w.
  176. /// The first bit is the first bit of x followed by the first bit of y, the first bit of z and finally the first bit of w.
  177. /// The other bits are interleaved following the previous sequence.
  178. ///
  179. /// @see gtc_bitfield
  180. GLM_FUNC_DECL uint32 bitfieldInterleave(uint8 x, uint8 y, uint8 z, uint8 w);
  181. /// Interleaves the bits of x, y, z and w.
  182. /// The first bit is the first bit of x followed by the first bit of y, the first bit of z and finally the first bit of w.
  183. /// The other bits are interleaved following the previous sequence.
  184. ///
  185. /// @see gtc_bitfield
  186. GLM_FUNC_DECL int64 bitfieldInterleave(int16 x, int16 y, int16 z, int16 w);
  187. /// Interleaves the bits of x, y, z and w.
  188. /// The first bit is the first bit of x followed by the first bit of y, the first bit of z and finally the first bit of w.
  189. /// The other bits are interleaved following the previous sequence.
  190. ///
  191. /// @see gtc_bitfield
  192. GLM_FUNC_DECL uint64 bitfieldInterleave(uint16 x, uint16 y, uint16 z, uint16 w);
  193. /// @}
  194. } //namespace glm
  195. #include "bitfield.inl"