Debian Codegraph @

thirdparty/amd-fsr2/shaders/ffx_common_types.h

raw symbols SCIP
1 // This file is part of the FidelityFX SDK.
2 //
3 // Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved.
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
13 //
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 // THE SOFTWARE.
21 #ifndef FFX_COMMON_TYPES_H
22 #define FFX_COMMON_TYPES_H
23
24 #if defined(FFX_CPU)
25 #define FFX_PARAMETER_IN
26 #define FFX_PARAMETER_OUT
27 #define FFX_PARAMETER_INOUT
28 #elif defined(FFX_HLSL)
29 #define FFX_PARAMETER_IN in
30 #define FFX_PARAMETER_OUT out
31 #define FFX_PARAMETER_INOUT inout
32 #elif defined(FFX_GLSL)
33 #define FFX_PARAMETER_IN in
34 #define FFX_PARAMETER_OUT out
35 #define FFX_PARAMETER_INOUT inout
36 #endif // #if defined(FFX_CPU)
37
38 #if defined(FFX_CPU)
39 /// A typedef for a boolean value.
40 ///
41 /// @ingroup CPU
42 typedef bool FfxBoolean;
43
44 /// A typedef for a unsigned 8bit integer.
45 ///
46 /// @ingroup CPU
47 typedef uint8_t FfxUInt8;
48
49 /// A typedef for a unsigned 16bit integer.
50 ///
51 /// @ingroup CPU
52 typedef uint16_t FfxUInt16;
53
54 /// A typedef for a unsigned 32bit integer.
55 ///
56 /// @ingroup CPU
57 typedef uint32_t FfxUInt32;
58
59 /// A typedef for a unsigned 64bit integer.
60 ///
61 /// @ingroup CPU
62 typedef uint64_t FfxUInt64;
63
64 /// A typedef for a signed 8bit integer.
65 ///
66 /// @ingroup CPU
67 typedef int8_t FfxInt8;
68
69 /// A typedef for a signed 16bit integer.
70 ///
71 /// @ingroup CPU
72 typedef int16_t FfxInt16;
73
74 /// A typedef for a signed 32bit integer.
75 ///
76 /// @ingroup CPU
77 typedef int32_t FfxInt32;
78
79 /// A typedef for a signed 64bit integer.
80 ///
81 /// @ingroup CPU
82 typedef int64_t FfxInt64;
83
84 /// A typedef for a floating point value.
85 ///
86 /// @ingroup CPU
87 typedef float FfxFloat32;
88
89 /// A typedef for a 2-dimensional floating point value.
90 ///
91 /// @ingroup CPU
92 typedef float FfxFloat32x2[2];
93
94 /// A typedef for a 3-dimensional floating point value.
95 ///
96 /// @ingroup CPU
97 typedef float FfxFloat32x3[3];
98
99 /// A typedef for a 4-dimensional floating point value.
100 ///
101 /// @ingroup CPU
102 typedef float FfxFloat32x4[4];
103
104 /// A typedef for a 2-dimensional 32bit unsigned integer.
105 ///
106 /// @ingroup CPU
107 typedef uint32_t FfxUInt32x2[2];
108
109 /// A typedef for a 3-dimensional 32bit unsigned integer.
110 ///
111 /// @ingroup CPU
112 typedef uint32_t FfxUInt32x3[3];
113
114 /// A typedef for a 4-dimensional 32bit unsigned integer.
115 ///
116 /// @ingroup CPU
117 typedef uint32_t FfxUInt32x4[4];
118 #endif // #if defined(FFX_CPU)
119
120 #if defined(FFX_HLSL)
121 /// A typedef for a boolean value.
122 ///
123 /// @ingroup GPU
124 typedef bool FfxBoolean;
125
126 #if FFX_HLSL_6_2
127 typedef float32_t FfxFloat32;
128 typedef float32_t2 FfxFloat32x2;
129 typedef float32_t3 FfxFloat32x3;
130 typedef float32_t4 FfxFloat32x4;
131
132 /// A typedef for a unsigned 32bit integer.
133 ///
134 /// @ingroup GPU
135 typedef uint32_t FfxUInt32;
136 typedef uint32_t2 FfxUInt32x2;
137 typedef uint32_t3 FfxUInt32x3;
138 typedef uint32_t4 FfxUInt32x4;
139 typedef int32_t FfxInt32;
140 typedef int32_t2 FfxInt32x2;
141 typedef int32_t3 FfxInt32x3;
142 typedef int32_t4 FfxInt32x4;
143 #else
144 #define FfxFloat32 float
145 #define FfxFloat32x2 float2
146 #define FfxFloat32x3 float3
147 #define FfxFloat32x4 float4
148
149 /// A typedef for a unsigned 32bit integer.
150 ///
151 /// @ingroup GPU
152 typedef uint FfxUInt32;
153 typedef uint2 FfxUInt32x2;
154 typedef uint3 FfxUInt32x3;
155 typedef uint4 FfxUInt32x4;
156 typedef int FfxInt32;
157 typedef int2 FfxInt32x2;
158 typedef int3 FfxInt32x3;
159 typedef int4 FfxInt32x4;
160 #endif // #if defined(FFX_HLSL_6_2)
161
162 #if FFX_HALF
163 #if FFX_HLSL_6_2
164 typedef float16_t FfxFloat16;
165 typedef float16_t2 FfxFloat16x2;
166 typedef float16_t3 FfxFloat16x3;
167 typedef float16_t4 FfxFloat16x4;
168
169 /// A typedef for an unsigned 16bit integer.
170 ///
171 /// @ingroup GPU
172 typedef uint16_t FfxUInt16;
173 typedef uint16_t2 FfxUInt16x2;
174 typedef uint16_t3 FfxUInt16x3;
175 typedef uint16_t4 FfxUInt16x4;
176
177 /// A typedef for a signed 16bit integer.
178 ///
179 /// @ingroup GPU
180 typedef int16_t FfxInt16;
181 typedef int16_t2 FfxInt16x2;
182 typedef int16_t3 FfxInt16x3;
183 typedef int16_t4 FfxInt16x4;
184 #else
185 typedef min16float FfxFloat16;
186 typedef min16float2 FfxFloat16x2;
187 typedef min16float3 FfxFloat16x3;
188 typedef min16float4 FfxFloat16x4;
189
190 /// A typedef for an unsigned 16bit integer.
191 ///
192 /// @ingroup GPU
193 typedef min16uint FfxUInt16;
194 typedef min16uint2 FfxUInt16x2;
195 typedef min16uint3 FfxUInt16x3;
196 typedef min16uint4 FfxUInt16x4;
197
198 /// A typedef for a signed 16bit integer.
199 ///
200 /// @ingroup GPU
201 typedef min16int FfxInt16;
202 typedef min16int2 FfxInt16x2;
203 typedef min16int3 FfxInt16x3;
204 typedef min16int4 FfxInt16x4;
205 #endif // FFX_HLSL_6_2
206 #endif // FFX_HALF
207 #endif // #if defined(FFX_HLSL)
208
209 #if defined(FFX_GLSL)
210 /// A typedef for a boolean value.
211 ///
212 /// @ingroup GPU
213 #define FfxBoolean bool
214 #define FfxFloat32 float
215 #define FfxFloat32x2 vec2
216 #define FfxFloat32x3 vec3
217 #define FfxFloat32x4 vec4
218 #define FfxUInt32 uint
219 #define FfxUInt32x2 uvec2
220 #define FfxUInt32x3 uvec3
221 #define FfxUInt32x4 uvec4
222 #define FfxInt32 int
223 #define FfxInt32x2 ivec2
224 #define FfxInt32x3 ivec3
225 #define FfxInt32x4 ivec4
226 #if FFX_HALF
227 #define FfxFloat16 float16_t
228 #define FfxFloat16x2 f16vec2
229 #define FfxFloat16x3 f16vec3
230 #define FfxFloat16x4 f16vec4
231 #define FfxUInt16 uint16_t
232 #define FfxUInt16x2 u16vec2
233 #define FfxUInt16x3 u16vec3
234 #define FfxUInt16x4 u16vec4
235 #define FfxInt16 int16_t
236 #define FfxInt16x2 i16vec2
237 #define FfxInt16x3 i16vec3
238 #define FfxInt16x4 i16vec4
239 #endif // FFX_HALF
240 #endif // #if defined(FFX_GLSL)
241
242 // Global toggles:
243 // #define FFX_HALF (1)
244 // #define FFX_HLSL_6_2 (1)
245
246 #if FFX_HALF
247
248 #if FFX_HLSL_6_2
249
250 #define FFX_MIN16_SCALAR( TypeName, BaseComponentType ) typedef BaseComponentType##16_t TypeName;
251 #define FFX_MIN16_VECTOR( TypeName, BaseComponentType, COL ) typedef vector<BaseComponentType##16_t, COL> TypeName;
252 #define FFX_MIN16_MATRIX( TypeName, BaseComponentType, ROW, COL ) typedef matrix<BaseComponentType##16_t, ROW, COL> TypeName;
253
254 #define FFX_16BIT_SCALAR( TypeName, BaseComponentType ) typedef BaseComponentType##16_t TypeName;
255 #define FFX_16BIT_VECTOR( TypeName, BaseComponentType, COL ) typedef vector<BaseComponentType##16_t, COL> TypeName;
256 #define FFX_16BIT_MATRIX( TypeName, BaseComponentType, ROW, COL ) typedef matrix<BaseComponentType##16_t, ROW, COL> TypeName;
257
258 #else //FFX_HLSL_6_2
259
260 #define FFX_MIN16_SCALAR( TypeName, BaseComponentType ) typedef min16##BaseComponentType TypeName;
261 #define FFX_MIN16_VECTOR( TypeName, BaseComponentType, COL ) typedef vector<min16##BaseComponentType, COL> TypeName;
262 #define FFX_MIN16_MATRIX( TypeName, BaseComponentType, ROW, COL ) typedef matrix<min16##BaseComponentType, ROW, COL> TypeName;
263
264 #define FFX_16BIT_SCALAR( TypeName, BaseComponentType ) FFX_MIN16_SCALAR( TypeName, BaseComponentType );
265 #define FFX_16BIT_VECTOR( TypeName, BaseComponentType, COL ) FFX_MIN16_VECTOR( TypeName, BaseComponentType, COL );
266 #define FFX_16BIT_MATRIX( TypeName, BaseComponentType, ROW, COL ) FFX_MIN16_MATRIX( TypeName, BaseComponentType, ROW, COL );
267
268 #endif //FFX_HLSL_6_2
269
270 #else //FFX_HALF
271
272 #define FFX_MIN16_SCALAR( TypeName, BaseComponentType ) typedef BaseComponentType TypeName;
273 #define FFX_MIN16_VECTOR( TypeName, BaseComponentType, COL ) typedef vector<BaseComponentType, COL> TypeName;
274 #define FFX_MIN16_MATRIX( TypeName, BaseComponentType, ROW, COL ) typedef matrix<BaseComponentType, ROW, COL> TypeName;
275
276 #define FFX_16BIT_SCALAR( TypeName, BaseComponentType ) typedef BaseComponentType TypeName;
277 #define FFX_16BIT_VECTOR( TypeName, BaseComponentType, COL ) typedef vector<BaseComponentType, COL> TypeName;
278 #define FFX_16BIT_MATRIX( TypeName, BaseComponentType, ROW, COL ) typedef matrix<BaseComponentType, ROW, COL> TypeName;
279
280 #endif //FFX_HALF
281
282 #if defined(FFX_GPU)
283 // Common typedefs:
284 #if defined(FFX_HLSL)
285 FFX_MIN16_SCALAR( FFX_MIN16_F , float );
286 FFX_MIN16_VECTOR( FFX_MIN16_F2, float, 2 );
287 FFX_MIN16_VECTOR( FFX_MIN16_F3, float, 3 );
288 FFX_MIN16_VECTOR( FFX_MIN16_F4, float, 4 );
289
290 FFX_MIN16_SCALAR( FFX_MIN16_I, int );
291 FFX_MIN16_VECTOR( FFX_MIN16_I2, int, 2 );
292 FFX_MIN16_VECTOR( FFX_MIN16_I3, int, 3 );
293 FFX_MIN16_VECTOR( FFX_MIN16_I4, int, 4 );
294
295 FFX_MIN16_SCALAR( FFX_MIN16_U, uint );
296 FFX_MIN16_VECTOR( FFX_MIN16_U2, uint, 2 );
297 FFX_MIN16_VECTOR( FFX_MIN16_U3, uint, 3 );
298 FFX_MIN16_VECTOR( FFX_MIN16_U4, uint, 4 );
299
300 FFX_16BIT_SCALAR( FFX_F16_t , float );
301 FFX_16BIT_VECTOR( FFX_F16_t2, float, 2 );
302 FFX_16BIT_VECTOR( FFX_F16_t3, float, 3 );
303 FFX_16BIT_VECTOR( FFX_F16_t4, float, 4 );
304
305 FFX_16BIT_SCALAR( FFX_I16_t, int );
306 FFX_16BIT_VECTOR( FFX_I16_t2, int, 2 );
307 FFX_16BIT_VECTOR( FFX_I16_t3, int, 3 );
308 FFX_16BIT_VECTOR( FFX_I16_t4, int, 4 );
309
310 FFX_16BIT_SCALAR( FFX_U16_t, uint );
311 FFX_16BIT_VECTOR( FFX_U16_t2, uint, 2 );
312 FFX_16BIT_VECTOR( FFX_U16_t3, uint, 3 );
313 FFX_16BIT_VECTOR( FFX_U16_t4, uint, 4 );
314
315 #define TYPEDEF_MIN16_TYPES(Prefix) \
316 typedef FFX_MIN16_F Prefix##_F; \
317 typedef FFX_MIN16_F2 Prefix##_F2; \
318 typedef FFX_MIN16_F3 Prefix##_F3; \
319 typedef FFX_MIN16_F4 Prefix##_F4; \
320 typedef FFX_MIN16_I Prefix##_I; \
321 typedef FFX_MIN16_I2 Prefix##_I2; \
322 typedef FFX_MIN16_I3 Prefix##_I3; \
323 typedef FFX_MIN16_I4 Prefix##_I4; \
324 typedef FFX_MIN16_U Prefix##_U; \
325 typedef FFX_MIN16_U2 Prefix##_U2; \
326 typedef FFX_MIN16_U3 Prefix##_U3; \
327 typedef FFX_MIN16_U4 Prefix##_U4;
328
329 #define TYPEDEF_16BIT_TYPES(Prefix) \
330 typedef FFX_16BIT_F Prefix##_F; \
331 typedef FFX_16BIT_F2 Prefix##_F2; \
332 typedef FFX_16BIT_F3 Prefix##_F3; \
333 typedef FFX_16BIT_F4 Prefix##_F4; \
334 typedef FFX_16BIT_I Prefix##_I; \
335 typedef FFX_16BIT_I2 Prefix##_I2; \
336 typedef FFX_16BIT_I3 Prefix##_I3; \
337 typedef FFX_16BIT_I4 Prefix##_I4; \
338 typedef FFX_16BIT_U Prefix##_U; \
339 typedef FFX_16BIT_U2 Prefix##_U2; \
340 typedef FFX_16BIT_U3 Prefix##_U3; \
341 typedef FFX_16BIT_U4 Prefix##_U4;
342
343 #define TYPEDEF_FULL_PRECISION_TYPES(Prefix) \
344 typedef FfxFloat32 Prefix##_F; \
345 typedef FfxFloat32x2 Prefix##_F2; \
346 typedef FfxFloat32x3 Prefix##_F3; \
347 typedef FfxFloat32x4 Prefix##_F4; \
348 typedef FfxInt32 Prefix##_I; \
349 typedef FfxInt32x2 Prefix##_I2; \
350 typedef FfxInt32x3 Prefix##_I3; \
351 typedef FfxInt32x4 Prefix##_I4; \
352 typedef FfxUInt32 Prefix##_U; \
353 typedef FfxUInt32x2 Prefix##_U2; \
354 typedef FfxUInt32x3 Prefix##_U3; \
355 typedef FfxUInt32x4 Prefix##_U4;
356 #endif // #if defined(FFX_HLSL)
357
358 #if defined(FFX_GLSL)
359
360 #if FFX_HALF
361
362 #define FFX_MIN16_F float16_t
363 #define FFX_MIN16_F2 f16vec2
364 #define FFX_MIN16_F3 f16vec3
365 #define FFX_MIN16_F4 f16vec4
366
367 #define FFX_MIN16_I int16_t
368 #define FFX_MIN16_I2 i16vec2
369 #define FFX_MIN16_I3 i16vec3
370 #define FFX_MIN16_I4 i16vec4
371
372 #define FFX_MIN16_U uint16_t
373 #define FFX_MIN16_U2 u16vec2
374 #define FFX_MIN16_U3 u16vec3
375 #define FFX_MIN16_U4 u16vec4
376
377 #define FFX_16BIT_F float16_t
378 #define FFX_16BIT_F2 f16vec2
379 #define FFX_16BIT_F3 f16vec3
380 #define FFX_16BIT_F4 f16vec4
381
382 #define FFX_16BIT_I int16_t
383 #define FFX_16BIT_I2 i16vec2
384 #define FFX_16BIT_I3 i16vec3
385 #define FFX_16BIT_I4 i16vec4
386
387 #define FFX_16BIT_U uint16_t
388 #define FFX_16BIT_U2 u16vec2
389 #define FFX_16BIT_U3 u16vec3
390 #define FFX_16BIT_U4 u16vec4
391
392 #else // FFX_HALF
393
394 #define FFX_MIN16_F float
395 #define FFX_MIN16_F2 vec2
396 #define FFX_MIN16_F3 vec3
397 #define FFX_MIN16_F4 vec4
398
399 #define FFX_MIN16_I int
400 #define FFX_MIN16_I2 ivec2
401 #define FFX_MIN16_I3 ivec3
402 #define FFX_MIN16_I4 ivec4
403
404 #define FFX_MIN16_U uint
405 #define FFX_MIN16_U2 uvec2
406 #define FFX_MIN16_U3 uvec3
407 #define FFX_MIN16_U4 uvec4
408
409 #define FFX_16BIT_F float
410 #define FFX_16BIT_F2 vec2
411 #define FFX_16BIT_F3 vec3
412 #define FFX_16BIT_F4 vec4
413
414 #define FFX_16BIT_I int
415 #define FFX_16BIT_I2 ivec2
416 #define FFX_16BIT_I3 ivec3
417 #define FFX_16BIT_I4 ivec4
418
419 #define FFX_16BIT_U uint
420 #define FFX_16BIT_U2 uvec2
421 #define FFX_16BIT_U3 uvec3
422 #define FFX_16BIT_U4 uvec4
423
424 #endif // FFX_HALF
425
426 #endif // #if defined(FFX_GLSL)
427
428 #endif // #if defined(FFX_GPU)
429 #endif // #ifndef FFX_COMMON_TYPES_H