• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 /// @brief Allow to perform bit operations on integer values
11 ///
12 /// <glm/gtc/bitfield.hpp> need to be included to use these functionalities.
13 
14 #pragma once
15 
16 // Dependencies
17 #include "../detail/setup.hpp"
18 #include "../detail/precision.hpp"
19 #include "../detail/type_int.hpp"
20 #include "../detail/_vectorize.hpp"
21 #include <limits>
22 
23 #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED)
24 #	pragma message("GLM: GLM_GTC_bitfield extension included")
25 #endif
26 
27 namespace glm
28 {
29 	/// @addtogroup gtc_bitfield
30 	/// @{
31 
32 	/// Build a mask of 'count' bits
33 	///
34 	/// @see gtc_bitfield
35 	template <typename genIUType>
36 	GLM_FUNC_DECL genIUType mask(genIUType Bits);
37 
38 	/// Build a mask of 'count' bits
39 	///
40 	/// @see gtc_bitfield
41 	template <typename T, precision P, template <typename, precision> class vecIUType>
42 	GLM_FUNC_DECL vecIUType<T, P> mask(vecIUType<T, P> const & v);
43 
44 	/// Rotate all bits to the right. All the bits dropped in the right side are inserted back on the left side.
45 	///
46 	/// @see gtc_bitfield
47 	template <typename genIUType>
48 	GLM_FUNC_DECL genIUType bitfieldRotateRight(genIUType In, int Shift);
49 
50 	/// Rotate all bits to the right. All the bits dropped in the right side are inserted back on the left side.
51 	///
52 	/// @see gtc_bitfield
53 	template <typename T, precision P, template <typename, precision> class vecType>
54 	GLM_FUNC_DECL vecType<T, P> bitfieldRotateRight(vecType<T, P> const & In, int Shift);
55 
56 	/// Rotate all bits to the left. All the bits dropped in the left side are inserted back on the right side.
57 	///
58 	/// @see gtc_bitfield
59 	template <typename genIUType>
60 	GLM_FUNC_DECL genIUType bitfieldRotateLeft(genIUType In, int Shift);
61 
62 	/// Rotate all bits to the left. All the bits dropped in the left side are inserted back on the right side.
63 	///
64 	/// @see gtc_bitfield
65 	template <typename T, precision P, template <typename, precision> class vecType>
66 	GLM_FUNC_DECL vecType<T, P> bitfieldRotateLeft(vecType<T, P> const & In, int Shift);
67 
68 	/// Set to 1 a range of bits.
69 	///
70 	/// @see gtc_bitfield
71 	template <typename genIUType>
72 	GLM_FUNC_DECL genIUType bitfieldFillOne(genIUType Value, int FirstBit, int BitCount);
73 
74 	/// Set to 1 a range of bits.
75 	///
76 	/// @see gtc_bitfield
77 	template <typename T, precision P, template <typename, precision> class vecType>
78 	GLM_FUNC_DECL vecType<T, P> bitfieldFillOne(vecType<T, P> const & Value, int FirstBit, int BitCount);
79 
80 	/// Set to 0 a range of bits.
81 	///
82 	/// @see gtc_bitfield
83 	template <typename genIUType>
84 	GLM_FUNC_DECL genIUType bitfieldFillZero(genIUType Value, int FirstBit, int BitCount);
85 
86 	/// Set to 0 a range of bits.
87 	///
88 	/// @see gtc_bitfield
89 	template <typename T, precision P, template <typename, precision> class vecType>
90 	GLM_FUNC_DECL vecType<T, P> bitfieldFillZero(vecType<T, P> const & Value, int FirstBit, int BitCount);
91 
92 	/// Interleaves the bits of x and y.
93 	/// The first bit is the first bit of x followed by the first bit of y.
94 	/// The other bits are interleaved following the previous sequence.
95 	///
96 	/// @see gtc_bitfield
97 	GLM_FUNC_DECL int16 bitfieldInterleave(int8 x, int8 y);
98 
99 	/// Interleaves the bits of x and y.
100 	/// The first bit is the first bit of x followed by the first bit of y.
101 	/// The other bits are interleaved following the previous sequence.
102 	///
103 	/// @see gtc_bitfield
104 	GLM_FUNC_DECL uint16 bitfieldInterleave(uint8 x, uint8 y);
105 
106 	/// Interleaves the bits of x and y.
107 	/// The first bit is the first bit of x followed by the first bit of y.
108 	/// The other bits are interleaved following the previous sequence.
109 	///
110 	/// @see gtc_bitfield
111 	GLM_FUNC_DECL int32 bitfieldInterleave(int16 x, int16 y);
112 
113 	/// Interleaves the bits of x and y.
114 	/// The first bit is the first bit of x followed by the first bit of y.
115 	/// The other bits are interleaved following the previous sequence.
116 	///
117 	/// @see gtc_bitfield
118 	GLM_FUNC_DECL uint32 bitfieldInterleave(uint16 x, uint16 y);
119 
120 	/// Interleaves the bits of x and y.
121 	/// The first bit is the first bit of x followed by the first bit of y.
122 	/// The other bits are interleaved following the previous sequence.
123 	///
124 	/// @see gtc_bitfield
125 	GLM_FUNC_DECL int64 bitfieldInterleave(int32 x, int32 y);
126 
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 
134 	/// Interleaves the bits of x, y and z.
135 	/// The first bit is the first bit of x followed by the first bit of y and the first bit of z.
136 	/// The other bits are interleaved following the previous sequence.
137 	///
138 	/// @see gtc_bitfield
139 	GLM_FUNC_DECL int32 bitfieldInterleave(int8 x, int8 y, int8 z);
140 
141 	/// Interleaves the bits of x, y and z.
142 	/// The first bit is the first bit of x followed by the first bit of y and the first bit of z.
143 	/// The other bits are interleaved following the previous sequence.
144 	///
145 	/// @see gtc_bitfield
146 	GLM_FUNC_DECL uint32 bitfieldInterleave(uint8 x, uint8 y, uint8 z);
147 
148 	/// Interleaves the bits of x, y and z.
149 	/// The first bit is the first bit of x followed by the first bit of y and the first bit of z.
150 	/// The other bits are interleaved following the previous sequence.
151 	///
152 	/// @see gtc_bitfield
153 	GLM_FUNC_DECL int64 bitfieldInterleave(int16 x, int16 y, int16 z);
154 
155 	/// Interleaves the bits of x, y and z.
156 	/// The first bit is the first bit of x followed by the first bit of y and the first bit of z.
157 	/// The other bits are interleaved following the previous sequence.
158 	///
159 	/// @see gtc_bitfield
160 	GLM_FUNC_DECL uint64 bitfieldInterleave(uint16 x, uint16 y, uint16 z);
161 
162 	/// Interleaves the bits of x, y and z.
163 	/// The first bit is the first bit of x followed by the first bit of y and the first bit of z.
164 	/// The other bits are interleaved following the previous sequence.
165 	///
166 	/// @see gtc_bitfield
167 	GLM_FUNC_DECL int64 bitfieldInterleave(int32 x, int32 y, int32 z);
168 
169 	/// Interleaves the bits of x, y and z.
170 	/// The first bit is the first bit of x followed by the first bit of y and the first bit of z.
171 	/// The other bits are interleaved following the previous sequence.
172 	///
173 	/// @see gtc_bitfield
174 	GLM_FUNC_DECL uint64 bitfieldInterleave(uint32 x, uint32 y, uint32 z);
175 
176 	/// Interleaves the bits of x, y, z and w.
177 	/// 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.
178 	/// The other bits are interleaved following the previous sequence.
179 	///
180 	/// @see gtc_bitfield
181 	GLM_FUNC_DECL int32 bitfieldInterleave(int8 x, int8 y, int8 z, int8 w);
182 
183 	/// Interleaves the bits of x, y, z and w.
184 	/// 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.
185 	/// The other bits are interleaved following the previous sequence.
186 	///
187 	/// @see gtc_bitfield
188 	GLM_FUNC_DECL uint32 bitfieldInterleave(uint8 x, uint8 y, uint8 z, uint8 w);
189 
190 	/// Interleaves the bits of x, y, z and w.
191 	/// 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.
192 	/// The other bits are interleaved following the previous sequence.
193 	///
194 	/// @see gtc_bitfield
195 	GLM_FUNC_DECL int64 bitfieldInterleave(int16 x, int16 y, int16 z, int16 w);
196 
197 	/// Interleaves the bits of x, y, z and w.
198 	/// 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.
199 	/// The other bits are interleaved following the previous sequence.
200 	///
201 	/// @see gtc_bitfield
202 	GLM_FUNC_DECL uint64 bitfieldInterleave(uint16 x, uint16 y, uint16 z, uint16 w);
203 
204 	/// @}
205 } //namespace glm
206 
207 #include "bitfield.inl"
208