3 #extension GL_ARB_gpu_shader_int64: enable
4 #extension GL_AMD_gpu_shader_half_float: enable
5 #extension GL_AMD_gpu_shader_int16: enable
7 layout(binding = 0) uniform Uniforms
12 // int16/uint16 in block
13 layout(std140, binding = 1) uniform Block
19 // int16/uint16 for input
20 layout(location = 0) in flat u16vec3 iu16v;
21 layout(location = 1) in flat int16_t ii16;
25 const int16_t i16c[3] =
32 const uint16_t u16c[] =
39 uint16_t u16 = i16c[i] + u16c[i];
85 b = (u16v.x > u16v.y);
87 b = (u16v.y >= u16v.x);
113 i16v = i16vec2(bv); // bool -> int16
114 u16v = u16vec2(bv); // bool -> uint16
115 bv = bvec2(i16v); // int16 -> bool
116 bv = bvec2(u16v); // uint16 -> bool
118 i16v = i16vec2(iv); // int -> int16
119 u16v = u16vec2(iv); // int -> uint16
120 iv = i16v; // int16 -> int
121 iv = ivec2(u16v); // uint16 -> int
123 i16v = i16vec2(uv); // uint -> int16
124 u16v = u16vec2(uv); // uint -> uint16
125 uv = i16v; // int16 -> uint
126 uv = u16v; // uint16 -> uint
128 i16v = i16vec2(fv); // float -> int16
129 u16v = u16vec2(fv); // float -> uint16
130 fv = i16v; // int16 -> float
131 fv = u16v; // uint16 -> float
133 i16v = i16vec2(dv); // double -> int16
134 u16v = u16vec2(dv); // double -> uint16
135 dv = i16v; // int16 -> double
136 dv = u16v; // uint16 -> double
138 i16v = i16vec2(f16v); // float16 -> int16
139 u16v = u16vec2(f16v); // float16 -> uint16
140 f16v = i16v; // int16 -> float16
141 f16v = u16v; // uint16 -> float16
143 i16v = i16vec2(i64v); // int64 -> int16
144 u16v = u16vec2(i64v); // int64 -> uint16
145 i64v = i16v; // int16 -> int64
146 i64v = i64vec2(u16v); // uint16 -> int64
148 i16v = i16vec2(u64v); // uint64 -> int16
149 u16v = u16vec2(u64v); // uint64 -> uint16
150 u64v = i16v; // int16 -> uint64
151 u64v = u16v; // uint16 -> uint64
153 i16v = i16vec2(u16v); // uint16 -> int16
154 u16v = i16v; // int16 -> uint16
174 i16v = min(i16v, i16);
175 i16v = min(i16v, i16vec2(-1s));
176 u16v = min(u16v, u16);
177 u16v = min(u16v, u16vec3(0us));
180 i16v = max(i16v, i16);
181 i16v = max(i16v, i16vec2(-1s));
182 u16v = max(u16v, u16);
183 u16v = max(u16v, u16vec3(0us));
186 i16v = clamp(i16v, -i16, i16);
187 i16v = clamp(i16v, -i16v, i16v);
188 u16v = clamp(u16v, -u16, u16);
189 u16v = clamp(u16v, -u16v, u16v);
192 i16 = mix(i16v.x, i16v.y, true);
193 i16v = mix(i16vec2(i16), i16vec2(-i16), bvec2(false));
194 u16 = mix(u16v.x, u16v.y, true);
195 u16v = mix(u16vec3(u16), u16vec3(-u16), bvec3(false));
199 f16v = frexp(f16v, exp);
202 f16v = ldexp(f16v, exp);
204 // float16BitsToInt16()
205 i16v = float16BitsToInt16(f16v.xy);
207 // float16BitsToUint16()
208 u16v.x = float16BitsToUint16(f16v.z);
210 // int16BitsToFloat16()
211 f16v.xy = int16BitsToFloat16(i16v);
213 // uint16BitsToFloat16()
214 f16v = uint16BitsToFloat16(u16v);
217 int packi = packInt2x16(i16v);
220 i16v = unpackInt2x16(packi);
223 uint packu = packUint2x16(u16v.xy);
226 u16v.xy = unpackUint2x16(packu);
229 int64_t packi64 = packInt4x16(i16vec4(i16));
232 i16v = unpackInt4x16(packi64).xy;
235 uint64_t packu64 = packUint4x16(u16vec4(u16));
238 u16v = unpackUint4x16(packu64).xyz;
241 bv = lessThan(u16v, u16vec3(u16));
242 bv.xy = lessThan(i16v, i16vec2(i16));
245 bv = lessThanEqual(u16v, u16vec3(u16));
246 bv.xy = lessThanEqual(i16v, i16vec2(i16));
249 bv = greaterThan(u16v, u16vec3(u16));
250 bv.xy = greaterThan(i16v, i16vec2(i16));
252 // greaterThanEqual()
253 bv = greaterThanEqual(u16v, u16vec3(u16));
254 bv.xy = greaterThanEqual(i16v, i16vec2(i16));
257 bv = equal(u16v, u16vec3(u16));
258 bv.xy = equal(i16v, i16vec2(i16));
261 bv = notEqual(u16v, u16vec3(u16));
262 bv.xy = notEqual(i16v, i16vec2(i16));
265 // Type conversion for specialization constant
266 layout(constant_id = 100) const int64_t si64 = -10L;
267 layout(constant_id = 101) const uint64_t su64 = 20UL;
268 layout(constant_id = 102) const int si = -5;
269 layout(constant_id = 103) const uint su = 4;
270 layout(constant_id = 104) const bool sb = true;
271 layout(constant_id = 105) const int16_t si16 = -5S;
272 layout(constant_id = 106) const uint16_t su16 = 4US;
274 // bool <-> int16/uint16
275 const bool i16_to_b = bool(si16);
276 const bool u16_to_b = bool(su16);
277 const int16_t b_to_i16 = int16_t(sb);
278 const uint16_t b_to_u16 = uint16_t(sb);
280 // int <-> int16/uint16
281 const int i16_to_i = int(si16);
282 const int u16_to_i = int(su16);
283 const int16_t i_to_i16 = int16_t(si);
284 const uint16_t i_to_u16 = uint16_t(si);
286 // uint <-> int16/uint16
287 const uint i16_to_u = uint(si16);
288 const uint u16_to_u = uint(su16);
289 const int16_t u_to_i16 = int16_t(su);
290 const uint16_t u_to_u16 = uint16_t(su);
292 // int64 <-> int16/uint16
293 const int64_t i16_to_i64 = int64_t(si16);
294 const int64_t u16_to_i64 = int64_t(su16);
295 const int16_t i64_to_i16 = int16_t(si64);
296 const uint16_t i64_to_u16 = uint16_t(si64);
298 // uint64 <-> int16/uint16
299 const uint64_t i16_to_u64 = uint64_t(si16);
300 const uint64_t u16_to_u64 = uint64_t(su16);
301 const int16_t u64_to_i16 = int16_t(su64);
302 const uint16_t u64_to_u16 = uint16_t(su64);
305 const uint16_t i16_to_u16 = uint16_t(si16);
306 const int16_t u16_to_i16 = int16_t(su16);