Debian Codegraph @

third_party/spirv-cross/shaders-msl-no-opt/frag/fp16.desktop.invalid.frag

raw
1 #version 450
2 #extension GL_AMD_gpu_shader_half_float : require
3
4 layout(location = 0) in float16_t v1;
5 layout(location = 1) in f16vec2 v2;
6 layout(location = 2) in f16vec3 v3;
7 layout(location = 3) in f16vec4 v4;
8
9 layout(location = 0) out float o1;
10 layout(location = 1) out vec2 o2;
11 layout(location = 2) out vec3 o3;
12 layout(location = 3) out vec4 o4;
13
14 f16mat2 test_mat2(f16vec2 a, f16vec2 b, f16vec2 c, f16vec2 d)
15 {
16 return f16mat2(a, b) * f16mat2(c, d);
17 }
18
19 f16mat3 test_mat3(f16vec3 a, f16vec3 b, f16vec3 c, f16vec3 d, f16vec3 e, f16vec3 f)
20 {
21 return f16mat3(a, b, c) * f16mat3(d, e, f);
22 }
23
24 void test_constants()
25 {
26 float16_t a = 1.0hf;
27 float16_t b = 1.5hf;
28 float16_t c = -1.5hf; // Negatives
29 float16_t d = (0.0hf / 0.0hf); // NaN
30 float16_t e = (1.0hf / 0.0hf); // +Inf
31 float16_t f = (-1.0hf / 0.0hf); // -Inf
32 float16_t g = 1014.0hf; // Large.
33 float16_t h = 0.000001hf; // Denormal
34 }
35
36 float16_t test_result()
37 {
38 return 1.0hf;
39 }
40
41 void test_conversions()
42 {
43 float16_t one = test_result();
44 int a = int(one);
45 uint b = uint(one);
46 bool c = bool(one);
47 float d = float(one);
48 //double e = double(one);
49 float16_t a2 = float16_t(a);
50 float16_t b2 = float16_t(b);
51 float16_t c2 = float16_t(c);
52 float16_t d2 = float16_t(d);
53 //float16_t e2 = float16_t(e);
54 }
55
56 void test_builtins()
57 {
58 f16vec4 res;
59 res = radians(v4);
60 res = degrees(v4);
61 res = sin(v4);
62 res = cos(v4);
63 res = tan(v4);
64 res = asin(v4);
65 res = atan(v4, v3.xyzz);
66 res = atan(v4);
67 res = sinh(v4);
68 res = cosh(v4);
69 res = tanh(v4);
70 res = asinh(v4);
71 res = acosh(v4);
72 res = atanh(v4);
73 res = pow(v4, v4);
74 res = exp(v4);
75 res = log(v4);
76 res = exp2(v4);
77 res = log2(v4);
78 res = sqrt(v4);
79 res = inversesqrt(v4);
80 res = abs(v4);
81 res = sign(v4);
82 res = floor(v4);
83 res = trunc(v4);
84 res = round(v4);
85 res = roundEven(v4);
86 res = ceil(v4);
87 res = fract(v4);
88 res = mod(v4, v4);
89 f16vec4 tmp;
90 res = modf(v4, tmp);
91 res = min(v4, v4);
92 res = max(v4, v4);
93 res = clamp(v4, v4, v4);
94 res = mix(v4, v4, v4);
95 res = mix(v4, v4, lessThan(v4, v4));
96 res = step(v4, v4);
97 res = smoothstep(v4, v4, v4);
98
99 bvec4 btmp = isnan(v4);
100 btmp = isinf(v4);
101 res = fma(v4, v4, v4);
102
103 ivec4 itmp;
104 res = frexp(v4, itmp);
105 res = ldexp(res, itmp);
106
107 uint pack0 = packFloat2x16(v4.xy);
108 uint pack1 = packFloat2x16(v4.zw);
109 res = f16vec4(unpackFloat2x16(pack0), unpackFloat2x16(pack1));
110
111 float16_t t0 = length(v4);
112 t0 = distance(v4, v4);
113 t0 = dot(v4, v4);
114 f16vec3 res3 = cross(v3, v3);
115 res = normalize(v4);
116 res = faceforward(v4, v4, v4);
117 res = reflect(v4, v4);
118 res = refract(v4, v4, v1);
119
120 btmp = lessThan(v4, v4);
121 btmp = lessThanEqual(v4, v4);
122 btmp = greaterThan(v4, v4);
123 btmp = greaterThanEqual(v4, v4);
124 btmp = equal(v4, v4);
125 btmp = notEqual(v4, v4);
126
127 res = dFdx(v4);
128 res = dFdy(v4);
129 res = dFdxFine(v4);
130 res = dFdyFine(v4);
131 res = dFdxCoarse(v4);
132 res = dFdyCoarse(v4);
133 res = fwidth(v4);
134 res = fwidthFine(v4);
135 res = fwidthCoarse(v4);
136
137 //res = interpolateAtCentroid(v4);
138 //res = interpolateAtSample(v4, 0);
139 //res = interpolateAtOffset(v4, f16vec2(0.1hf));
140 }
141
142 void main()
143 {
144 // Basic matrix tests.
145 f16mat2 m0 = test_mat2(v2, v2, v3.xy, v3.xy);
146 f16mat3 m1 = test_mat3(v3, v3, v3, v4.xyz, v4.xyz, v4.yzw);
147
148 test_constants();
149 test_conversions();
150 test_builtins();
151 }