master
ブランチ master
VulkanExample / dep / include / glm / gtc / bitfield.hpp
9.9 KB、266行 生 Blame 履歴
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
14#include "../detail/setup.hpp"
15
16#pragma once
17
18// Dependencies
19#include "../ext/scalar_int_sized.hpp"
20#include "../ext/scalar_uint_sized.hpp"
21#include "../detail/qualifier.hpp"
22#include "../detail/_vectorize.hpp"
23#include "type_precision.hpp"
24#include <limits>
25
26#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
27# pragma message("GLM: GLM_GTC_bitfield extension included")
28#endif
29
30namespace glm
31{
32 /// @addtogroup gtc_bitfield
33 /// @{
34
35 /// Build a mask of 'count' bits
36 ///
37 /// @see gtc_bitfield
38 template<typename genIUType>
39 GLM_FUNC_DECL genIUType mask(genIUType Bits);
40
41 /// Build a mask of 'count' bits
42 ///
43 /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
44 /// @tparam T Signed and unsigned integer scalar types
45 /// @tparam Q Value from qualifier enum
46 ///
47 /// @see gtc_bitfield
48 template<length_t L, typename T, qualifier Q>
49 GLM_FUNC_DECL vec<L, T, Q> mask(vec<L, T, Q> const& v);
50
51 /// Rotate all bits to the right. All the bits dropped in the right side are inserted back on the left side.
52 ///
53 /// @see gtc_bitfield
54 template<typename genIUType>
55 GLM_FUNC_DECL genIUType bitfieldRotateRight(genIUType In, int Shift);
56
57 /// Rotate all bits to the right. All the bits dropped in the right side are inserted back on the left side.
58 ///
59 /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
60 /// @tparam T Signed and unsigned integer scalar types
61 /// @tparam Q Value from qualifier enum
62 ///
63 /// @see gtc_bitfield
64 template<length_t L, typename T, qualifier Q>
65 GLM_FUNC_DECL vec<L, T, Q> bitfieldRotateRight(vec<L, T, Q> const& In, int Shift);
66
67 /// Rotate all bits to the left. All the bits dropped in the left side are inserted back on the right side.
68 ///
69 /// @see gtc_bitfield
70 template<typename genIUType>
71 GLM_FUNC_DECL genIUType bitfieldRotateLeft(genIUType In, int Shift);
72
73 /// Rotate all bits to the left. All the bits dropped in the left side are inserted back on the right side.
74 ///
75 /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
76 /// @tparam T Signed and unsigned integer scalar types
77 /// @tparam Q Value from qualifier enum
78 ///
79 /// @see gtc_bitfield
80 template<length_t L, typename T, qualifier Q>
81 GLM_FUNC_DECL vec<L, T, Q> bitfieldRotateLeft(vec<L, T, Q> const& In, int Shift);
82
83 /// Set to 1 a range of bits.
84 ///
85 /// @see gtc_bitfield
86 template<typename genIUType>
87 GLM_FUNC_DECL genIUType bitfieldFillOne(genIUType Value, int FirstBit, int BitCount);
88
89 /// Set to 1 a range of bits.
90 ///
91 /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
92 /// @tparam T Signed and unsigned integer scalar types
93 /// @tparam Q Value from qualifier enum
94 ///
95 /// @see gtc_bitfield
96 template<length_t L, typename T, qualifier Q>
97 GLM_FUNC_DECL vec<L, T, Q> bitfieldFillOne(vec<L, T, Q> const& Value, int FirstBit, int BitCount);
98
99 /// Set to 0 a range of bits.
100 ///
101 /// @see gtc_bitfield
102 template<typename genIUType>
103 GLM_FUNC_DECL genIUType bitfieldFillZero(genIUType Value, int FirstBit, int BitCount);
104
105 /// Set to 0 a range of bits.
106 ///
107 /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
108 /// @tparam T Signed and unsigned integer scalar types
109 /// @tparam Q Value from qualifier enum
110 ///
111 /// @see gtc_bitfield
112 template<length_t L, typename T, qualifier Q>
113 GLM_FUNC_DECL vec<L, T, Q> bitfieldFillZero(vec<L, T, Q> const& Value, int FirstBit, int BitCount);
114
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 int16 bitfieldInterleave(int8 x, int8 y);
121
122 /// Interleaves the bits of x and y.
123 /// The first bit is the first bit of x followed by the first bit of y.
124 /// The other bits are interleaved following the previous sequence.
125 ///
126 /// @see gtc_bitfield
127 GLM_FUNC_DECL uint16 bitfieldInterleave(uint8 x, uint8 y);
128
129 /// Interleaves the bits of x and y.
130 /// The first bit is the first bit of v.x followed by the first bit of v.y.
131 /// The other bits are interleaved following the previous sequence.
132 ///
133 /// @see gtc_bitfield
134 GLM_FUNC_DECL uint16 bitfieldInterleave(u8vec2 const& v);
135
136 /// Deinterleaves the bits of x.
137 ///
138 /// @see gtc_bitfield
139 GLM_FUNC_DECL glm::u8vec2 bitfieldDeinterleave(glm::uint16 x);
140
141 /// Interleaves the bits of x and y.
142 /// The first bit is the first bit of x followed by the first bit of y.
143 /// The other bits are interleaved following the previous sequence.
144 ///
145 /// @see gtc_bitfield
146 GLM_FUNC_DECL int32 bitfieldInterleave(int16 x, int16 y);
147
148 /// Interleaves the bits of x and y.
149 /// The first bit is the first bit of x followed by the first bit of y.
150 /// The other bits are interleaved following the previous sequence.
151 ///
152 /// @see gtc_bitfield
153 GLM_FUNC_DECL uint32 bitfieldInterleave(uint16 x, uint16 y);
154
155 /// Interleaves the bits of x and y.
156 /// The first bit is the first bit of v.x followed by the first bit of v.y.
157 /// The other bits are interleaved following the previous sequence.
158 ///
159 /// @see gtc_bitfield
160 GLM_FUNC_DECL uint32 bitfieldInterleave(u16vec2 const& v);
161
162 /// Deinterleaves the bits of x.
163 ///
164 /// @see gtc_bitfield
165 GLM_FUNC_DECL glm::u16vec2 bitfieldDeinterleave(glm::uint32 x);
166
167 /// Interleaves the bits of x and y.
168 /// The first bit is the first bit of x followed by the first bit of y.
169 /// The other bits are interleaved following the previous sequence.
170 ///
171 /// @see gtc_bitfield
172 GLM_FUNC_DECL int64 bitfieldInterleave(int32 x, int32 y);
173
174 /// Interleaves the bits of x and y.
175 /// The first bit is the first bit of x followed by the first bit of y.
176 /// The other bits are interleaved following the previous sequence.
177 ///
178 /// @see gtc_bitfield
179 GLM_FUNC_DECL uint64 bitfieldInterleave(uint32 x, uint32 y);
180
181 /// Interleaves the bits of x and y.
182 /// The first bit is the first bit of v.x followed by the first bit of v.y.
183 /// The other bits are interleaved following the previous sequence.
184 ///
185 /// @see gtc_bitfield
186 GLM_FUNC_DECL uint64 bitfieldInterleave(u32vec2 const& v);
187
188 /// Deinterleaves the bits of x.
189 ///
190 /// @see gtc_bitfield
191 GLM_FUNC_DECL glm::u32vec2 bitfieldDeinterleave(glm::uint64 x);
192
193 /// Interleaves the bits of x, y and z.
194 /// The first bit is the first bit of x followed by the first bit of y and the first bit of z.
195 /// The other bits are interleaved following the previous sequence.
196 ///
197 /// @see gtc_bitfield
198 GLM_FUNC_DECL int32 bitfieldInterleave(int8 x, int8 y, int8 z);
199
200 /// Interleaves the bits of x, y and z.
201 /// The first bit is the first bit of x followed by the first bit of y and the first bit of z.
202 /// The other bits are interleaved following the previous sequence.
203 ///
204 /// @see gtc_bitfield
205 GLM_FUNC_DECL uint32 bitfieldInterleave(uint8 x, uint8 y, uint8 z);
206
207 /// Interleaves the bits of x, y and z.
208 /// The first bit is the first bit of x followed by the first bit of y and the first bit of z.
209 /// The other bits are interleaved following the previous sequence.
210 ///
211 /// @see gtc_bitfield
212 GLM_FUNC_DECL int64 bitfieldInterleave(int16 x, int16 y, int16 z);
213
214 /// Interleaves the bits of x, y and z.
215 /// The first bit is the first bit of x followed by the first bit of y and the first bit of z.
216 /// The other bits are interleaved following the previous sequence.
217 ///
218 /// @see gtc_bitfield
219 GLM_FUNC_DECL uint64 bitfieldInterleave(uint16 x, uint16 y, uint16 z);
220
221 /// Interleaves the bits of x, y and z.
222 /// The first bit is the first bit of x followed by the first bit of y and the first bit of z.
223 /// The other bits are interleaved following the previous sequence.
224 ///
225 /// @see gtc_bitfield
226 GLM_FUNC_DECL int64 bitfieldInterleave(int32 x, int32 y, int32 z);
227
228 /// Interleaves the bits of x, y and z.
229 /// The first bit is the first bit of x followed by the first bit of y and the first bit of z.
230 /// The other bits are interleaved following the previous sequence.
231 ///
232 /// @see gtc_bitfield
233 GLM_FUNC_DECL uint64 bitfieldInterleave(uint32 x, uint32 y, uint32 z);
234
235 /// Interleaves the bits of x, y, z and w.
236 /// 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.
237 /// The other bits are interleaved following the previous sequence.
238 ///
239 /// @see gtc_bitfield
240 GLM_FUNC_DECL int32 bitfieldInterleave(int8 x, int8 y, int8 z, int8 w);
241
242 /// Interleaves the bits of x, y, z and w.
243 /// 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.
244 /// The other bits are interleaved following the previous sequence.
245 ///
246 /// @see gtc_bitfield
247 GLM_FUNC_DECL uint32 bitfieldInterleave(uint8 x, uint8 y, uint8 z, uint8 w);
248
249 /// Interleaves the bits of x, y, z and w.
250 /// 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.
251 /// The other bits are interleaved following the previous sequence.
252 ///
253 /// @see gtc_bitfield
254 GLM_FUNC_DECL int64 bitfieldInterleave(int16 x, int16 y, int16 z, int16 w);
255
256 /// Interleaves the bits of x, y, z and w.
257 /// 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.
258 /// The other bits are interleaved following the previous sequence.
259 ///
260 /// @see gtc_bitfield
261 GLM_FUNC_DECL uint64 bitfieldInterleave(uint16 x, uint16 y, uint16 z, uint16 w);
262
263 /// @}
264} //namespace glm
265
266#include "bitfield.inl"