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 float32_t f32c = 0.000001f;
20 const f32vec2 f32cv = f32vec2(-0.25F, 0.03f);
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 f32 = f32v.x + f32v.y;
78 f32 = f32v.x - f32v.y;
79 f32 = f32v.x * f32v.y;
80 f32 = f32v.x / f32v.y;
90 // Vector/matrix operations
113 f64v = f32v; // float32_t -> float64_t
115 f32v = f32vec3(bv); // bool -> float32
116 bv = bvec3(f32v); // float32 -> bool
118 f32v = f32vec3(f64v); // double -> float32
119 f64v = f64vec3(f32v); // float32 -> double
121 f32v = f32vec3(f16v); // float16 -> float32
122 f16v = f16vec3(f32v); // float32 -> float16
124 i8v = i8vec3(f32v); // float32 -> int8
125 i16v = i16vec3(f32v); // float32 -> int16
126 i32v = i32vec3(f32v); // float32 -> int32
127 i64v = i64vec3(f32v); // float32 -> int64
129 u8v = u8vec3(f32v); // float32 -> uint8
130 u16v = u16vec3(f32v); // float32 -> uint16
131 u32v = u32vec3(f32v); // float32 -> uint32
132 u64v = u64vec3(f32v); // float32 -> uint64
135 void builtinAngleTrigFuncs()
137 f32vec4 f32v1, f32v2;
139 f32v2 = radians(f32v1);
140 f32v2 = degrees(f32v1);
146 f32v2 = atan(f32v1, f32v2);
151 f32v2 = asinh(f32v1);
152 f32v2 = acosh(f32v1);
153 f32v2 = atanh(f32v1);
156 void builtinExpFuncs()
158 f32vec2 f32v1, f32v2;
160 f32v2 = pow(f32v1, f32v2);
166 f32v2 = inversesqrt(f32v1);
169 void builtinCommonFuncs()
171 f32vec3 f32v1, f32v2, f32v3;
179 f32v2 = floor(f32v1);
180 f32v2 = trunc(f32v1);
181 f32v2 = round(f32v1);
182 f32v2 = roundEven(f32v1);
184 f32v2 = fract(f32v1);
185 f32v2 = mod(f32v1, f32v2);
186 f32v2 = mod(f32v1, f32);
187 f32v3 = modf(f32v1, f32v2);
188 f32v3 = min(f32v1, f32v2);
189 f32v3 = min(f32v1, f32);
190 f32v3 = max(f32v1, f32v2);
191 f32v3 = max(f32v1, f32);
192 f32v3 = clamp(f32v1, f32, f32v2.x);
193 f32v3 = clamp(f32v1, f32v2, f32vec3(f32));
194 f32v3 = mix(f32v1, f32v2, f32);
195 f32v3 = mix(f32v1, f32v2, f32v3);
196 f32v3 = mix(f32v1, f32v2, bv);
197 f32v3 = step(f32v1, f32v2);
198 f32v3 = step(f32, f32v3);
199 f32v3 = smoothstep(f32v1, f32v2, f32v3);
200 f32v3 = smoothstep(f32, f32v1.x, f32v2);
203 f32v3 = fma(f32v1, f32v2, f32v3);
204 f32v2 = frexp(f32v1, iv);
205 f32v2 = ldexp(f32v1, iv);
208 void builtinGeometryFuncs()
211 f32vec3 f32v1, f32v2, f32v3;
214 f32 = distance(f32v1, f32v2);
215 f32 = dot(f32v1, f32v2);
216 f32v3 = cross(f32v1, f32v2);
217 f32v2 = normalize(f32v1);
218 f32v3 = faceforward(f32v1, f32v2, f32v3);
219 f32v3 = reflect(f32v1, f32v2);
220 f32v3 = refract(f32v1, f32v2, f32);
223 void builtinMatrixFuncs()
225 f32mat2x3 f32m1, f32m2, f32m3;
228 f32mat4 f32m6, f32m7;
235 f32m3 = matrixCompMult(f32m1, f32m2);
236 f32m1 = outerProduct(f32v1, f32v2);
237 f32m4 = transpose(f32m1);
238 f32 = determinant(f32m5);
239 f32m6 = inverse(f32m7);
242 void builtinVecRelFuncs()
244 f32vec3 f32v1, f32v2;
247 bv = lessThan(f32v1, f32v2);
248 bv = lessThanEqual(f32v1, f32v2);
249 bv = greaterThan(f32v1, f32v2);
250 bv = greaterThanEqual(f32v1, f32v2);
251 bv = equal(f32v1, f32v2);
252 bv = notEqual(f32v1, f32v2);
257 void builtinFragProcFuncs()
262 f32v.x = dFdx(if32v.x);
263 f32v.y = dFdy(if32v.y);
264 f32v.xy = dFdxFine(if32v.xy);
265 f32v.xy = dFdyFine(if32v.xy);
266 f32v = dFdxCoarse(if32v);
267 f32v = dFdxCoarse(if32v);
269 f32v.x = fwidth(if32v.x);
270 f32v.xy = fwidthFine(if32v.xy);
271 f32v = fwidthCoarse(if32v);
274 f32v.x = interpolateAtCentroid(if32v.x);
275 f32v.xy = interpolateAtSample(if32v.xy, 1);
276 f32v = interpolateAtOffset(if32v, f32vec2(0.5f));