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
16 // Single float literals
19 const float64_t f64c = 0.000001LF;
20 const f64vec2 f64cv = f64vec2(-0.25lF, 0.03Lf);
27 // Block memory layout
35 layout(column_major, std140) uniform B1
47 // Specialization constant
48 layout(constant_id = 100) const float16_t sf16 = 0.125hf;
49 layout(constant_id = 101) const float32_t sf = 0.25;
50 layout(constant_id = 102) const float64_t sd = 0.5lf;
52 const float f16_to_f = float(sf16);
53 const double f16_to_d = float(sf16);
55 const float16_t f_to_f16 = float16_t(sf);
56 const float16_t d_to_f16 = float16_t(sd);
77 f64 = f64v.x + f64v.y;
78 f64 = f64v.x - f64v.y;
79 f64 = f64v.x * f64v.y;
80 f64 = f64v.x / f64v.y;
90 // Vector/matrix operations
113 f64v = f64vec3(bv); // bool -> float64
114 bv = bvec3(f64v); // float64 -> bool
116 f64v = f64vec3(f16v); // float16 -> float64
117 f16v = f16vec3(f64v); // float64 -> float16
119 i8v = i8vec3(f64v); // float64 -> int8
120 i16v = i16vec3(f64v); // float64 -> int16
121 i32v = i32vec3(f64v); // float64 -> int32
122 i64v = i64vec3(f64v); // float64 -> int64
124 u8v = u8vec3(f64v); // float64 -> uint8
125 u16v = u16vec3(f64v); // float64 -> uint16
126 u32v = u32vec3(f64v); // float64 -> uint32
127 u64v = u64vec3(f64v); // float64 -> uint64
130 // Trig, pow, exp and log are not supported for f64
132 void builtinTranscendentalFuncs()
134 f64vec2 f64v1, f64v2;
137 f64v2 = inversesqrt(f64v1);
140 void builtinCommonFuncs()
142 f64vec3 f64v1, f64v2, f64v3;
150 f64v2 = floor(f64v1);
151 f64v2 = trunc(f64v1);
152 f64v2 = round(f64v1);
153 f64v2 = roundEven(f64v1);
155 f64v2 = fract(f64v1);
156 f64v2 = mod(f64v1, f64v2);
157 f64v2 = mod(f64v1, f64);
158 f64v3 = modf(f64v1, f64v2);
159 f64v3 = min(f64v1, f64v2);
160 f64v3 = min(f64v1, f64);
161 f64v3 = max(f64v1, f64v2);
162 f64v3 = max(f64v1, f64);
163 f64v3 = clamp(f64v1, f64, f64v2.x);
164 f64v3 = clamp(f64v1, f64v2, f64vec3(f64));
165 f64v3 = mix(f64v1, f64v2, f64);
166 f64v3 = mix(f64v1, f64v2, f64v3);
167 f64v3 = mix(f64v1, f64v2, bv);
168 f64v3 = step(f64v1, f64v2);
169 f64v3 = step(f64, f64v3);
170 f64v3 = smoothstep(f64v1, f64v2, f64v3);
171 f64v3 = smoothstep(f64, f64v1.x, f64v2);
174 f64v3 = fma(f64v1, f64v2, f64v3);
175 f64v2 = frexp(f64v1, iv);
176 f64v2 = ldexp(f64v1, iv);
179 void builtinGeometryFuncs()
182 f64vec3 f64v1, f64v2, f64v3;
185 f64 = distance(f64v1, f64v2);
186 f64 = dot(f64v1, f64v2);
187 f64v3 = cross(f64v1, f64v2);
188 f64v2 = normalize(f64v1);
189 f64v3 = faceforward(f64v1, f64v2, f64v3);
190 f64v3 = reflect(f64v1, f64v2);
191 f64v3 = refract(f64v1, f64v2, f64);
194 void builtinMatrixFuncs()
196 f64mat2x3 f64m1, f64m2, f64m3;
199 f64mat4 f64m6, f64m7;
206 f64m3 = matrixCompMult(f64m1, f64m2);
207 f64m1 = outerProduct(f64v1, f64v2);
208 f64m4 = transpose(f64m1);
209 f64 = determinant(f64m5);
210 f64m6 = inverse(f64m7);
213 void builtinVecRelFuncs()
215 f64vec3 f64v1, f64v2;
218 bv = lessThan(f64v1, f64v2);
219 bv = lessThanEqual(f64v1, f64v2);
220 bv = greaterThan(f64v1, f64v2);
221 bv = greaterThanEqual(f64v1, f64v2);
222 bv = equal(f64v1, f64v2);
223 bv = notEqual(f64v1, f64v2);
226 in flat f64vec3 if64v;
228 void builtinFragProcFuncs()
233 f64v.x = dFdx(if64v.x);
234 f64v.y = dFdy(if64v.y);
235 f64v.xy = dFdxFine(if64v.xy);
236 f64v.xy = dFdyFine(if64v.xy);
237 f64v = dFdxCoarse(if64v);
238 f64v = dFdxCoarse(if64v);
240 f64v.x = fwidth(if64v.x);
241 f64v.xy = fwidthFine(if64v.xy);
242 f64v = fwidthCoarse(if64v);
245 f64v.x = interpolateAtCentroid(if64v.x);
246 f64v.xy = interpolateAtSample(if64v.xy, 1);
247 f64v = interpolateAtOffset(if64v, f64vec2(0.5f));