3 #extension GL_ARB_gpu_shader_int64: enable
\r
4 #extension GL_EXT_shader_explicit_arithmetic_types_int64: require
\r
6 layout(binding = 0) uniform Uniforms
\r
11 layout(std140, binding = 1) uniform Block
\r
23 const int64_t i64Const[3] =
\r
25 -0x1111111111111111l, // Hex
\r
27 040000000000l, // Oct
\r
30 int64_t i64 = i64Const[index];
\r
32 const uint64_t u64Const[] =
\r
34 0xFFFFFFFFFFFFFFFFul, // Hex
\r
35 4294967296UL, // Dec
\r
36 077777777777ul, // Oct
\r
39 uint64_t u64 = u64Const[index];
\r
53 i64v = i64vec2(bv); // bool -> int64
\r
54 u64v = u64vec2(bv); // bool -> uint64
\r
56 i64v = iv; // int -> int64
\r
57 iv = ivec2(i64v); // int64 -> int
\r
59 u64v = uv; // uint -> uint64
\r
60 uv = uvec2(u64v); // uint64 -> uint
\r
62 fv = vec2(i64v); // int64 -> float
\r
63 dv = i64v; // int64 -> double
\r
65 fv = vec2(u64v); // uint64 -> float
\r
66 dv = u64v; // uint64 -> double
\r
68 i64v = i64vec2(fv); // float -> int64
\r
69 i64v = i64vec2(dv); // double -> int64
\r
71 u64v = u64vec2(fv); // float -> uint64
\r
72 u64v = u64vec2(dv); // double -> uint64
\r
74 bv = bvec2(i64v); // int64 -> bool
\r
75 bv = bvec2(u64v); // uint64 -> bool
\r
77 u64v = i64v; // int64 -> uint64
\r
78 i64v = i64vec2(u64v); // uint64 -> int64
\r
80 uv = uvec2(i64v); // int64 -> uint
\r
81 i64v = i64vec2(uv); // uint -> int64
\r
82 iv = ivec2(u64v); // uint64 -> int
\r
83 u64v = iv; // int -> uint64
\r
124 i64 = i64 << u64v.z;
\r
125 u64v = u64v << i64;
\r
128 b = (u64v.x != i64);
\r
129 b = (i64 == u64v.x);
\r
130 b = (u64v.x > uv.y);
\r
132 b = (u64v.y >= uv.x);
\r
144 void builtinFuncs()
\r
161 i64v = min(i64v, i64);
\r
162 i64v = min(i64v, i64vec2(-1));
\r
163 u64v = min(u64v, u64);
\r
164 u64v = min(u64v, u64vec3(0));
\r
167 i64v = max(i64v, i64);
\r
168 i64v = max(i64v, i64vec2(-1));
\r
169 u64v = max(u64v, u64);
\r
170 u64v = max(u64v, u64vec3(0));
\r
173 i64v = clamp(i64v, -i64, i64);
\r
174 i64v = clamp(i64v, -i64v, i64v);
\r
175 u64v = clamp(u64v, -u64, u64);
\r
176 u64v = clamp(u64v, -u64v, u64v);
\r
179 i64 = mix(i64v.x, i64v.y, true);
\r
180 i64v = mix(i64vec2(i64), i64vec2(-i64), bvec2(false));
\r
181 u64 = mix(u64v.x, u64v.y, true);
\r
182 u64v = mix(u64vec3(u64), u64vec3(-u64), bvec3(false));
\r
184 // doubleBitsToInt64()
\r
185 i64v = doubleBitsToInt64(dv.xy);
\r
187 // doubleBitsToUint64()
\r
188 u64v.x = doubleBitsToUint64(dv.z);
\r
190 // int64BitsToDouble()
\r
191 dv.xy = int64BitsToDouble(i64v);
\r
193 // uint64BitsToDouble()
\r
194 dv = uint64BitsToDouble(u64v);
\r
197 i64 = packInt2x32(ivec2(1, 2));
\r
200 ivec2 iv = unpackInt2x32(i64);
\r
203 u64 = packUint2x32(uvec2(2, 3));
\r
205 // unpackUint2x32()
\r
206 uvec2 uv = unpackUint2x32(u64);
\r
209 bv = lessThan(u64v, u64vec3(u64));
\r
210 bv.xy = lessThan(i64v, i64vec2(i64));
\r
213 bv = lessThanEqual(u64v, u64vec3(u64));
\r
214 bv.xy = lessThanEqual(i64v, i64vec2(i64));
\r
217 bv = greaterThan(u64v, u64vec3(u64));
\r
218 bv.xy = greaterThan(i64v, i64vec2(i64));
\r
220 // greaterThanEqual()
\r
221 bv = greaterThanEqual(u64v, u64vec3(u64));
\r
222 bv.xy = greaterThanEqual(i64v, i64vec2(i64));
\r
225 bv = equal(u64v, u64vec3(u64));
\r
226 bv.xy = equal(i64v, i64vec2(i64));
\r
229 bv = notEqual(u64v, u64vec3(u64));
\r
230 bv.xy = notEqual(i64v, i64vec2(i64));
\r
233 i64 = findLSB(u64);
\r
234 i64v = findLSB(u64vec2(u64));
\r
237 i64 = bitCount(u64);
\r
238 i64v = bitCount(u64vec2(u64));
\r
241 // Type conversion for specialization constant
\r
242 layout(constant_id = 100) const int64_t si64 = -10L;
\r
243 layout(constant_id = 101) const uint64_t su64 = 20UL;
\r
244 layout(constant_id = 102) const int si = -5;
\r
245 layout(constant_id = 103) const uint su = 4;
\r
246 layout(constant_id = 104) const bool sb = true;
\r
247 layout(constant_id = 105) const uint64_t su64inc = su64 + 1UL;
\r
249 // bool <-> int64/uint64
\r
250 const bool i64_to_b = bool(si64);
\r
251 const bool u64_to_b = bool(su64);
\r
252 const int64_t b_to_i64 = int64_t(sb);
\r
253 const uint64_t b_to_u64 = uint64_t(sb);
\r
256 const int i64_to_i = int(si64);
\r
257 const int64_t i_to_i64 = int64_t(si);
\r
260 const uint u64_to_u = uint(su64);
\r
261 const uint64_t u_to_u64 = uint64_t(su);
\r
263 // int64 <-> uint64
\r
264 const int64_t u64_to_i64 = int64_t(su64);
\r
265 const uint64_t i64_to_u64 = uint64_t(si64);
\r
268 const int u64_to_i = int(su64);
\r
269 const uint64_t i_to_u64 = uint64_t(si);
\r
272 const uint i64_to_u = uint(si64);
\r
273 const int64_t u_to_i64 = int64_t(su);
\r
275 #define UINT64_MAX 18446744073709551615ul
\r
276 uint64_t u64Max = UINT64_MAX;
\r