• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#version 450
2
3#extension GL_EXT_shader_explicit_arithmetic_types: enable
4#extension GL_EXT_shader_explicit_arithmetic_types_int8: require
5#extension GL_EXT_shader_explicit_arithmetic_types_int16: require
6#extension GL_EXT_shader_explicit_arithmetic_types_int32: require
7#extension GL_EXT_shader_explicit_arithmetic_types_int64: require
8#extension GL_EXT_shader_explicit_arithmetic_types_float16: require
9#extension GL_EXT_shader_explicit_arithmetic_types_float32: require
10#extension GL_EXT_shader_explicit_arithmetic_types_float64: require
11
12layout(binding = 0) uniform Uniforms
13{
14    uint index;
15};
16
17layout(std140, binding = 1) uniform Block
18{
19    int16_t   i16;
20    i16vec2   i16v2;
21    i16vec3   i16v3;
22    i16vec4   i16v4;
23    uint16_t  u16;
24    u16vec2   u16v2;
25    u16vec3   u16v3;
26    u16vec4   u16v4;
27
28    int32_t   i32;
29    i32vec2   i32v2;
30    i32vec3   i32v3;
31    i32vec4   i32v4;
32    uint32_t  u32;
33    u32vec2   u32v2;
34    u32vec3   u32v3;
35    u32vec4   u32v4;
36} block;
37
38void main()
39{
40}
41
42void literal()
43{
44    const int64_t i64Const[3] =
45    {
46        -0x1111111111111111l,   // Hex
47        -1l,                    // Dec
48        040000000000l,          // Oct
49    };
50
51    int64_t i64 = i64Const[index];
52
53    const uint64_t u64Const[] =
54    {
55        0xFFFFFFFFFFFFFFFFul,   // Hex
56        4294967296UL,           // Dec
57        077777777777ul,         // Oct
58    };
59
60    uint64_t u64 = u64Const[index];
61
62    const int32_t i32Const[3] =
63    {
64        -0x11111111,           // Hex
65        -1,                    // Dec
66        04000000000,           // Oct
67    };
68
69    int32_t i32 = i32Const[index];
70
71    const uint32_t u32Const[] =
72    {
73        0xFFFFFFFF,             // Hex
74        4294967295,             // Dec
75        017777777777,           // Oct
76    };
77
78    uint32_t u32 = u32Const[index];
79
80    const int16_t i16Const[3] =
81    {
82        int16_t(-0x1111),           // Hex
83        int16_t(-1),                // Dec
84        int16_t(040000),            // Oct
85    };
86
87    int16_t i16 = i16Const[index];
88
89    const uint16_t u16Const[] =
90    {
91        uint16_t(0xFFFF),             // Hex
92        uint16_t(65535),              // Dec
93        uint16_t(077777),             // Oct
94    };
95
96    uint16_t u16 = u16Const[index];
97
98    const int8_t i8Const[3] =
99    {
100        int8_t(-0x11),           // Hex
101        int8_t(-1),              // Dec
102        int8_t(0400),            // Oct
103    };
104
105    int8_t i8 = i8Const[index];
106
107    const uint8_t u8Const[] =
108    {
109        uint8_t(0xFF),             // Hex
110        uint8_t(255),              // Dec
111        uint8_t(0177),             // Oct
112    };
113
114    uint8_t u8 = u8Const[index];
115}
116
117void typeCast8()
118{
119    i8vec2 i8v;
120    u8vec2 u8v;
121    i16vec2 i16v;
122    u16vec2 u16v;
123    i32vec2 i32v;
124    u32vec2 u32v;
125    i64vec2 i64v;
126    u64vec2 u64v;
127    f16vec2 f16v;
128    f32vec2 f32v;
129    f64vec2 f64v;
130    bvec2   bv;
131
132    u8v = i8v;      // int8_t  ->  uint8_t
133    i16v = i8v;     // int8_t  ->   int16_t
134    i16v = u8v;     // uint8_t ->   int16_t
135    i32v = i8v;     // int8_t  ->   int32_t
136    i32v = u8v;     // uint8_t ->   int32_t
137    u32v = i8v;     // int8_t  ->  uint32_t
138    i64v = i8v;     // int8_t  ->   int64_t
139    u64v = i8v;     // int8_t  ->  uint64_t
140    u32v = u8v;     // uint8_t ->  uint32_t
141    i64v = u8v;     // uint8_t ->   int64_t
142    u64v = u8v;     // uint8_t ->  uint64_t
143    f16v = i8v;     // int8_t  ->  float16_t
144    f32v = i8v;     // int8_t  ->  float32_t
145    f64v = i8v;     // int8_t  ->  float64_t
146    f16v = u8v;     // uint8_t ->  float16_t
147    f32v = u8v;     // uint8_t ->  float32_t
148    f64v = u8v;     // uint8_t ->  float64_t
149
150    i8v =  i8vec2(u8v);       // uint8_t  ->   int8_t
151    i16v = i16vec2(i8v);      // int8_t   ->   int16_t
152    i16v = i16vec2(u8v);      // uint8_t  ->   int16_t
153    i32v = i32vec2(i8v);      // int8_t   ->   int32_t
154    i32v = i32vec2(u8v);      // uint8_t  ->   int32_t
155    i64v = i64vec2(i8v);      // int8_t   ->   int64_t
156    u64v = i64vec2(i8v);      // int8_t   ->  uint64_t
157    u16v = u16vec2(i8v);      // int8_t   ->  uint16_t
158    u16v = u16vec2(u8v);      // uint8_t  ->  uint16_t
159    u32v = u32vec2(u8v);      // uint8_t  ->  uint32_t
160    i64v = i64vec2(u8v);      // uint8_t  ->   int64_t
161    u64v = i64vec2(u8v);      // uint8_t  ->  uint64_t
162    f16v = f16vec2(i8v);      // int8_t   ->  float16_t
163    f32v = f32vec2(i8v);      // int8_t   ->  float32_t
164    f64v = f64vec2(i8v);      // int8_t   ->  float64_t
165    f16v = f16vec2(u8v);      // uint8_t  ->  float16_t
166    f32v = f32vec2(u8v);      // uint8_t  ->  float32_t
167    f64v = f64vec2(u8v);      // uint8_t  ->  float64_t
168
169    i8v = i8vec2(bv);       // bool     ->   int8
170    u8v = u8vec2(bv);       // bool     ->   uint8
171    bv  = bvec2(i8v);       // int8    ->   bool
172    bv  = bvec2(u8v);       // uint8   ->   bool
173}
174
175void typeCast16()
176{
177    i8vec2 i8v;
178    u8vec2 u8v;
179    i16vec2 i16v;
180    u16vec2 u16v;
181    i32vec2 i32v;
182    u32vec2 u32v;
183    i64vec2 i64v;
184    u64vec2 u64v;
185    f16vec2 f16v;
186    f32vec2 f32v;
187    f64vec2 f64v;
188    bvec2   bv;
189
190    i32v = i16v;     // int16_t  ->   int32_t
191    i32v = u16v;     // uint16_t ->   int32_t
192    u16v = i16v;     // int16_t  ->  uint16_t
193    u32v = i16v;     // int16_t  ->  uint32_t
194    i64v = i16v;     // int16_t  ->   int64_t
195    u64v = i16v;     // int16_t  ->  uint64_t
196    u32v = u16v;     // uint16_t ->  uint32_t
197    i64v = u16v;     // uint16_t ->   int64_t
198    u64v = u16v;     // uint16_t ->  uint64_t
199    f16v = i16v;     // int16_t  ->  float16_t
200    f32v = i16v;     // int16_t  ->  float32_t
201    f64v = i16v;     // int16_t  ->  float64_t
202    f16v = u16v;     // uint16_t ->  float16_t
203    f32v = u16v;     // uint16_t ->  float32_t
204    f64v = u16v;     // uint16_t ->  float64_t
205
206    i32v = i32vec2(i16v);     // int16_t  ->   int32_t
207    i32v = i32vec2(u16v);     // uint16_t ->   int32_t
208    u16v = u16vec2(i16v);     // int16_t  ->  uint16_t
209    u32v = u32vec2(i16v);     // int16_t  ->  uint32_t
210    i64v = i64vec2(i16v);     // int16_t  ->   int64_t
211    u64v = i64vec2(i16v);     // int16_t  ->  uint64_t
212    u32v = u32vec2(u16v);     // uint16_t ->  uint32_t
213    i64v = i64vec2(u16v);     // uint16_t ->   int64_t
214    u64v = i64vec2(u16v);     // uint16_t ->  uint64_t
215    f16v = f16vec2(i16v);     // int16_t  ->  float16_t
216    f32v = f32vec2(i16v);     // int16_t  ->  float32_t
217    f64v = f64vec2(i16v);     // int16_t  ->  float64_t
218    f16v = f16vec2(u16v);     // uint16_t ->  float16_t
219    f32v = f32vec2(u16v);     // uint16_t ->  float32_t
220    f64v = f64vec2(u16v);     // uint16_t ->  float64_t
221
222    i8v  = i8vec2(i16v);      // int16_t  ->   int8_t
223    i8v  = i8vec2(u16v);      // uint16_t ->   int8_t
224    u8v  = u8vec2(i16v);      // int16_t  ->  uint8_t
225    u8v  = u8vec2(u16v);      // uint16_t ->  uint8_t
226    i16v = u8vec2(u16v);      // uint16_t ->   int16_t
227    i16v = i16vec2(bv);       // bool     ->   int16
228    u16v = u16vec2(bv);       // bool     ->   uint16
229    bv   = bvec2(i16v);       // int16    ->   bool
230    bv   = bvec2(u16v);       // uint16   ->   bool
231}
232
233void typeCast32()
234{
235    i8vec2 i8v;
236    u8vec2 u8v;
237    i16vec2 i16v;
238    u16vec2 u16v;
239    i32vec2 i32v;
240    u32vec2 u32v;
241    i64vec2 i64v;
242    u64vec2 u64v;
243    f16vec2 f16v;
244    f32vec2 f32v;
245    f64vec2 f64v;
246    bvec2   bv;
247
248    u32v = i32v;     // int32_t  ->  uint32_t
249    i64v = i32v;     // int32_t  ->   int64_t
250    u64v = i32v;     // int32_t  ->  uint64_t
251    i64v = u32v;     // uint32_t ->   int64_t
252    u64v = u32v;     // uint32_t ->  uint64_t
253    f32v = i32v;     // int32_t  ->  float32_t
254    f64v = i32v;     // int32_t  ->  float64_t
255    f32v = u32v;     // uint32_t ->  float32_t
256    f64v = u32v;     // uint32_t ->  float64_t
257
258    i8v =  i8vec2(i32v);       // int32_t   ->   int8_t
259    i8v =  i8vec2(u32v);       // uint32_t  ->   int8_t
260    i16v = i16vec2(i32v);      // int32_t   ->   int16_t
261    i16v = i16vec2(u32v);      // uint32_t  ->   int16_t
262    i32v = i32vec2(i32v);      // int32_t   ->   int32_t
263    i32v = i32vec2(u32v);      // uint32_t  ->   int32_t
264    i64v = i64vec2(i32v);      // int32_t   ->   int64_t
265	i64v = i64vec2(u32v);      // uint32_t  ->   int64_t
266	u8v =  u8vec2(i32v);       // int32_t   ->   uint8_t
267    u8v =  u8vec2(u32v);       // uint32_t  ->   uint8_t
268    u16v = u16vec2(i32v);      // int32_t   ->   uint16_t
269    u16v = u16vec2(u32v);      // uint32_t  ->   uint16_t
270    u32v = u32vec2(i32v);      // int32_t   ->   uint32_t
271    u32v = u32vec2(u32v);      // uint32_t  ->   uint32_t
272    u64v = u64vec2(i32v);      // int32_t   ->   uint64_t
273    u64v = u64vec2(u32v);      // uint32_t  ->   uint64_t
274
275    f16v = f16vec2(i32v);      // int32_t   ->  float16_t
276    f32v = f32vec2(i32v);      // int32_t   ->  float32_t
277    f64v = f64vec2(i32v);      // int32_t   ->  float64_t
278    f16v = f16vec2(u32v);      // uint32_t  ->  float16_t
279    f32v = f32vec2(u32v);      // uint32_t  ->  float32_t
280    f64v = f64vec2(u32v);      // uint32_t  ->  float64_t
281
282    i32v = i32vec2(bv);       // bool     ->   int32
283    u32v = u32vec2(bv);       // bool     ->   uint32
284    bv   = bvec2(i32v);       // int32    ->   bool
285    bv   = bvec2(u32v);       // uint32   ->   bool
286}
287
288void typeCast64()
289{
290    i8vec2 i8v;
291    u8vec2 u8v;
292    i16vec2 i16v;
293    u16vec2 u16v;
294    i32vec2 i32v;
295    u32vec2 u32v;
296    i64vec2 i64v;
297    u64vec2 u64v;
298    f16vec2 f16v;
299    f32vec2 f32v;
300    f64vec2 f64v;
301    bvec2   bv;
302
303    u64v = i64v;     // int64_t  ->  uint64_t
304    f64v = i64v;     // int64_t  ->  float64_t
305    f64v = u64v;     // uint64_t ->  float64_t
306
307    i8v =  i8vec2(i64v);       // int64_t   ->   int8_t
308    i8v =  i8vec2(u64v);       // uint64_t  ->   int8_t
309    i16v = i16vec2(i64v);      // int64_t   ->   int16_t
310    i16v = i16vec2(u64v);      // uint64_t  ->   int16_t
311    i32v = i32vec2(i64v);      // int64_t   ->   int32_t
312    i32v = i32vec2(u64v);      // uint64_t  ->   int32_t
313	i64v = i64vec2(u64v);      // uint64_t  ->   int64_t
314	u8v =  u8vec2(i64v);       // int64_t   ->   uint8_t
315    u8v =  u8vec2(u64v);       // uint64_t  ->   uint8_t
316    u16v = u16vec2(i64v);      // int64_t   ->   uint16_t
317    u16v = u16vec2(u64v);      // uint64_t  ->   uint16_t
318    u32v = u32vec2(i64v);      // int64_t   ->   uint32_t
319    u32v = u32vec2(u64v);      // uint64_t  ->   uint32_t
320    u64v = u64vec2(i64v);      // int64_t   ->   uint64_t
321    u64v = u64vec2(u64v);      // uint64_t  ->   uint64_t
322
323    f16v = f16vec2(i64v);      // int64_t   ->  float16_t
324    f32v = f32vec2(i64v);      // int64_t   ->  float32_t
325    f64v = f64vec2(i64v);      // int64_t   ->  float64_t
326    f16v = f16vec2(u64v);      // uint64_t  ->  float16_t
327    f32v = f32vec2(u64v);      // uint64_t  ->  float32_t
328    f64v = f64vec2(u64v);      // uint64_t  ->  float64_t
329
330    i64v = i64vec2(bv);       // bool     ->   int64
331    u64v = u64vec2(bv);       // bool     ->   uint64
332    bv   = bvec2(i64v);       // int64    ->   bool
333    bv   = bvec2(u64v);       // uint64   ->   bool
334}
335