Debian Codegraph @

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