3 layout(constant_id = 200) const float sp_float = 3.1415926;
4 layout(constant_id = 201) const int sp_int = 10;
5 layout(constant_id = 202) const uint sp_uint = 100;
6 layout(constant_id = 203) const int sp_sint = -10;
7 layout(constant_id = 204) const double sp_double = 2.718281828459;
13 // float <-> double conversion
14 const float float_from_double = float(sp_double);
15 const double double_from_float = double(sp_float);
17 // uint/int <-> bool conversion
18 const bool bool_from_int = bool(sp_int);
19 const bool bool_from_uint = bool(sp_uint);
20 const int int_from_bool = int(bool_from_int);
21 const uint uint_from_bool = uint(bool_from_int);
24 const uint sp_uint_from_sint = uint(sp_sint);
25 const int sp_sint_from_uint = int(sp_uint);
28 const int negate_int = -sp_int;
29 const int not_int = ~sp_int;
32 const int sp_int_add_two = sp_int + 2;
33 const int sp_int_add_two_sub_three = sp_int + 2 - 3;
34 const int sp_int_add_two_sub_four = sp_int_add_two - 4;
37 const int sp_sint_mul_two = sp_sint * 2;
38 const uint sp_uint_mul_two = sp_uint * 2;
39 const int sp_sint_mul_two_div_five = sp_sint_mul_two / 5;
40 const uint sp_uint_mul_two_div_five = sp_uint_mul_two / 5;
41 const int sp_sint_rem_four = sp_sint % 4;
42 const uint sp_uint_rem_four = sp_uint % 4;
43 const int sp_sint_mul_three_div_five = sp_sint * 3 / 5;
46 const int sp_sint_shift_right_arithmetic = sp_sint >> 10;
47 const uint sp_uint_shift_right_arithmetic = sp_uint >> 20;
48 const int sp_sint_shift_left = sp_sint << 1;
49 const uint sp_uint_shift_left = sp_uint << 2;
51 // Bitwise And, Or, Xor
52 const int sp_sint_or_256 = sp_sint | 0x100;
53 const uint sp_uint_xor_512 = sp_uint ^ 0x200;
55 /* // Scalar comparison */
56 const bool sp_int_lt_sp_sint = sp_int < sp_sint;
57 const bool sp_uint_equal_sp_uint = sp_uint == sp_uint;
58 const bool sp_int_gt_sp_sint = sp_int > sp_sint;
63 const ivec4 iv = ivec4(20, 30, sp_int, sp_int);
64 const uvec4 uv = uvec4(sp_uint, sp_uint, -1, -2);
65 //const vec4 fv = vec4(sp_float, 1.25, sp_float, 1.25);
67 // uint/int <-> bool conversion
68 const bvec4 bv_from_iv = bvec4(iv);
69 const bvec4 bv_from_uv = bvec4(uv);
70 const ivec4 iv_from_bv = ivec4(bv_from_iv);
71 const uvec4 uv_from_bv = uvec4(bv_from_iv);
74 const uvec4 uv_from_iv = uvec4(iv);
75 const ivec4 iv_from_uv = ivec4(uv);
78 const ivec4 not_iv = ~iv;
79 const ivec4 negate_iv = -iv;
82 const ivec4 iv_add_two = iv + 2;
83 const ivec4 iv_add_two_sub_three = iv + 2 - 3;
84 const ivec4 iv_add_two_sub_four = iv_add_two_sub_three - 4;
87 const ivec4 iv_mul_two = iv * 2;
88 const ivec4 iv_mul_two_div_five = iv_mul_two / 5;
89 const ivec4 iv_rem_four = iv % 4;
92 const ivec4 iv_shift_right_arithmetic = iv >> 10;
93 const ivec4 iv_shift_left = iv << 2;
95 // Bitwise And, Or, Xor
96 const ivec4 iv_or_1024 = iv | 0x400;
97 const uvec4 uv_xor_2048 = uv ^ 0x800;
100 const int iv_x = iv.x;
101 const ivec2 iv_yx = iv.yx;
102 const ivec3 iv_zyx = iv.zyx;
103 const ivec4 iv_yzxw = iv.yzxw;
105 int non_const_array_size_from_spec_const() {
106 int array[sp_int + 2];
107 for (int i = 0; i < sp_int + 2; i++) {
110 return array[sp_int + 1];
114 layout(constant_id = 210) const int a = 4;
\r
115 layout(constant_id = 211) const int b = 6;
\r
116 layout(constant_id = 212) const bool c = true;
\r
117 int ternayArray1[a > b ? a : b];
\r
118 const int t1 = c ? 13 : 17;
\r
119 const int t2 = c ? a : 17;
\r
120 const int t3 = true ? a : 17;
\r
121 const int t4 = a > b ? 13 + a : 17 * b;
122 const vec2 v2 = !c ? vec2(1.0) : vec2(2.0);