| 1 |
#pragma clang diagnostic ignored "-Wmissing-prototypes" |
| 2 |
|
| 3 |
#include <metal_stdlib> |
| 4 |
#include <simd/simd.h> |
| 5 |
|
| 6 |
using namespace metal; |
| 7 |
|
| 8 |
struct ResType |
| 9 |
{ |
| 10 |
half4 _m0; |
| 11 |
int4 _m1; |
| 12 |
}; |
| 13 |
|
| 14 |
struct main0_in |
| 15 |
{ |
| 16 |
half v1 [[user(locn0)]]; |
| 17 |
half2 v2 [[user(locn1)]]; |
| 18 |
half3 v3 [[user(locn2)]]; |
| 19 |
half4 v4 [[user(locn3)]]; |
| 20 |
}; |
| 21 |
|
| 22 |
// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() |
| 23 |
template<typename Tx, typename Ty> |
| 24 |
inline Tx mod(Tx x, Ty y) |
| 25 |
{ |
| 26 |
return x - y * floor(x / y); |
| 27 |
} |
| 28 |
|
| 29 |
// Implementation of the GLSL radians() function |
| 30 |
template<typename T> |
| 31 |
inline T radians(T d) |
| 32 |
{ |
| 33 |
return d * T(0.01745329251); |
| 34 |
} |
| 35 |
|
| 36 |
// Implementation of the GLSL degrees() function |
| 37 |
template<typename T> |
| 38 |
inline T degrees(T r) |
| 39 |
{ |
| 40 |
return r * T(57.2957795131); |
| 41 |
} |
| 42 |
|
| 43 |
static inline __attribute__((always_inline)) |
| 44 |
half2x2 test_mat2(thread const half2& a, thread const half2& b, thread const half2& c, thread const half2& d) |
| 45 |
{ |
| 46 |
return half2x2(half2(a), half2(b)) * half2x2(half2(c), half2(d)); |
| 47 |
} |
| 48 |
|
| 49 |
static inline __attribute__((always_inline)) |
| 50 |
half3x3 test_mat3(thread const half3& a, thread const half3& b, thread const half3& c, thread const half3& d, thread const half3& e, thread const half3& f) |
| 51 |
{ |
| 52 |
return half3x3(half3(a), half3(b), half3(c)) * half3x3(half3(d), half3(e), half3(f)); |
| 53 |
} |
| 54 |
|
| 55 |
static inline __attribute__((always_inline)) |
| 56 |
void test_constants() |
| 57 |
{ |
| 58 |
half a = half(1.0); |
| 59 |
half b = half(1.5); |
| 60 |
half c = half(-1.5); |
| 61 |
half d = half(0.0 / 0.0); |
| 62 |
half e = half(1.0 / 0.0); |
| 63 |
half f = half(-1.0 / 0.0); |
| 64 |
half g = half(1014.0); |
| 65 |
half h = half(9.5367431640625e-07); |
| 66 |
} |
| 67 |
|
| 68 |
static inline __attribute__((always_inline)) |
| 69 |
half test_result() |
| 70 |
{ |
| 71 |
return half(1.0); |
| 72 |
} |
| 73 |
|
| 74 |
static inline __attribute__((always_inline)) |
| 75 |
void test_conversions() |
| 76 |
{ |
| 77 |
half one = test_result(); |
| 78 |
int a = int(one); |
| 79 |
uint b = uint(one); |
| 80 |
bool c = (isunordered(one, half(0.0)) || one != half(0.0)); |
| 81 |
float d = float(one); |
| 82 |
half a2 = half(a); |
| 83 |
half b2 = half(b); |
| 84 |
half c2 = half(c); |
| 85 |
half d2 = half(d); |
| 86 |
} |
| 87 |
|
| 88 |
static inline __attribute__((always_inline)) |
| 89 |
void test_builtins(thread half4& v4, thread half3& v3, thread half& v1) |
| 90 |
{ |
| 91 |
half4 res = radians(v4); |
| 92 |
res = degrees(v4); |
| 93 |
res = sin(v4); |
| 94 |
res = cos(v4); |
| 95 |
res = tan(v4); |
| 96 |
res = asin(v4); |
| 97 |
res = atan2(v4, v3.xyzz); |
| 98 |
res = atan(v4); |
| 99 |
res = sinh(v4); |
| 100 |
res = cosh(v4); |
| 101 |
res = tanh(v4); |
| 102 |
res = asinh(v4); |
| 103 |
res = acosh(v4); |
| 104 |
res = atanh(v4); |
| 105 |
res = pow(v4, v4); |
| 106 |
res = exp(v4); |
| 107 |
res = log(v4); |
| 108 |
res = exp2(v4); |
| 109 |
res = log2(v4); |
| 110 |
res = sqrt(v4); |
| 111 |
res = rsqrt(v4); |
| 112 |
res = abs(v4); |
| 113 |
res = sign(v4); |
| 114 |
res = floor(v4); |
| 115 |
res = trunc(v4); |
| 116 |
res = round(v4); |
| 117 |
res = rint(v4); |
| 118 |
res = ceil(v4); |
| 119 |
res = fract(v4); |
| 120 |
res = mod(v4, v4); |
| 121 |
half4 tmp; |
| 122 |
half4 _223 = modf(v4, tmp); |
| 123 |
res = _223; |
| 124 |
res = min(v4, v4); |
| 125 |
res = max(v4, v4); |
| 126 |
res = clamp(v4, v4, v4); |
| 127 |
res = mix(v4, v4, v4); |
| 128 |
res = select(v4, v4, v4 < v4); |
| 129 |
res = step(v4, v4); |
| 130 |
res = smoothstep(v4, v4, v4); |
| 131 |
bool4 btmp = isnan(v4); |
| 132 |
btmp = isinf(v4); |
| 133 |
res = fma(v4, v4, v4); |
| 134 |
ResType _267; |
| 135 |
_267._m0 = frexp(v4, _267._m1); |
| 136 |
int4 itmp = _267._m1; |
| 137 |
res = _267._m0; |
| 138 |
res = ldexp(res, itmp); |
| 139 |
uint pack0 = as_type<uint>(v4.xy); |
| 140 |
uint pack1 = as_type<uint>(v4.zw); |
| 141 |
res = half4(as_type<half2>(pack0), as_type<half2>(pack1)); |
| 142 |
half t0 = length(v4); |
| 143 |
t0 = distance(v4, v4); |
| 144 |
t0 = dot(v4, v4); |
| 145 |
half3 res3 = cross(v3, v3); |
| 146 |
res = normalize(v4); |
| 147 |
res = faceforward(v4, v4, v4); |
| 148 |
res = reflect(v4, v4); |
| 149 |
res = refract(v4, v4, v1); |
| 150 |
btmp = v4 < v4; |
| 151 |
btmp = v4 <= v4; |
| 152 |
btmp = v4 > v4; |
| 153 |
btmp = v4 >= v4; |
| 154 |
btmp = v4 == v4; |
| 155 |
btmp = (isunordered(v4, v4) || v4 != v4); |
| 156 |
res = dfdx(v4); |
| 157 |
res = dfdy(v4); |
| 158 |
res = dfdx(v4); |
| 159 |
res = dfdy(v4); |
| 160 |
res = dfdx(v4); |
| 161 |
res = dfdy(v4); |
| 162 |
res = fwidth(v4); |
| 163 |
res = fwidth(v4); |
| 164 |
res = fwidth(v4); |
| 165 |
} |
| 166 |
|
| 167 |
fragment void main0(main0_in in [[stage_in]]) |
| 168 |
{ |
| 169 |
half2 param = in.v2; |
| 170 |
half2 param_1 = in.v2; |
| 171 |
half2 param_2 = in.v3.xy; |
| 172 |
half2 param_3 = in.v3.xy; |
| 173 |
half2x2 m0 = test_mat2(param, param_1, param_2, param_3); |
| 174 |
half3 param_4 = in.v3; |
| 175 |
half3 param_5 = in.v3; |
| 176 |
half3 param_6 = in.v3; |
| 177 |
half3 param_7 = in.v4.xyz; |
| 178 |
half3 param_8 = in.v4.xyz; |
| 179 |
half3 param_9 = in.v4.yzw; |
| 180 |
half3x3 m1 = test_mat3(param_4, param_5, param_6, param_7, param_8, param_9); |
| 181 |
test_constants(); |
| 182 |
test_conversions(); |
| 183 |
test_builtins(in.v4, in.v3, in.v1); |
| 184 |
} |
| 185 |
|