Skip to content

Commit 89e64af

Browse files
rework for more dryness
1 parent 238074c commit 89e64af

File tree

3 files changed

+37
-22
lines changed

3 files changed

+37
-22
lines changed

include/nbl/builtin/glsl/ext/FFT/default_compute_fft.comp

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22
#define _NBL_GLSL_WORKGROUP_SIZE_ 256
33
#endif
44
layout(local_size_x=_NBL_GLSL_WORKGROUP_SIZE_, local_size_y=1, local_size_z=1) in;
5-
6-
#define _NBL_GLSL_EXT_FFT_GET_PARAMETERS_DEFINED_
7-
#define _NBL_GLSL_EXT_FFT_SET_DATA_DEFINED_
8-
#define _NBL_GLSL_EXT_FFT_GET_PADDED_DATA_DEFINED_
9-
#include "nbl/builtin/glsl/ext/FFT/fft.glsl"
105

11-
// Input Descriptor
126

7+
#include <nbl/builtin/glsl/math/complex.glsl>
8+
9+
10+
// Input Descriptor
1311
#ifndef _NBL_GLSL_EXT_FFT_INPUT_SET_DEFINED_
1412
#define _NBL_GLSL_EXT_FFT_INPUT_SET_DEFINED_ 0
1513
#endif
@@ -26,11 +24,9 @@ layout(set=_NBL_GLSL_EXT_FFT_INPUT_SET_DEFINED_, binding=_NBL_GLSL_EXT_FFT_INPUT
2624
{
2725
nbl_glsl_complex inData[];
2826
};
29-
3027
#endif
3128

3229
// Output Descriptor
33-
3430
#ifndef _NBL_GLSL_EXT_FFT_OUTPUT_SET_DEFINED_
3531
#define _NBL_GLSL_EXT_FFT_OUTPUT_SET_DEFINED_ 0
3632
#endif
@@ -47,27 +43,37 @@ layout(set=_NBL_GLSL_EXT_FFT_OUTPUT_SET_DEFINED_, binding=_NBL_GLSL_EXT_FFT_OUTP
4743
};
4844
#endif
4945

50-
// Get/Set Data Function
5146

47+
#include <nbl/builtin/glsl/ext/FFT/parameters.glsl>
48+
49+
50+
#ifndef _NBL_GLSL_EXT_FFT_PUSH_CONSTANTS_DEFINED_
5251
layout(push_constant) uniform PushConstants
5352
{
5453
layout (offset = 0) nbl_glsl_ext_FFT_Parameters_t params;
5554
} pc;
55+
#define _NBL_GLSL_EXT_FFT_PUSH_CONSTANTS_DEFINED_
56+
#endif
5657

58+
#ifndef _NBL_GLSL_EXT_FFT_GET_PARAMETERS_DEFINED_
5759
nbl_glsl_ext_FFT_Parameters_t nbl_glsl_ext_FFT_getParameters()
5860
{
59-
nbl_glsl_ext_FFT_Parameters_t ret;
60-
ret = pc.params;
61-
return ret;
61+
return pc.params;
6262
}
63+
#define _NBL_GLSL_EXT_FFT_GET_PARAMETERS_DEFINED_
64+
#endif
6365

66+
#ifndef _NBL_GLSL_EXT_FFT_SET_DATA_DEFINED_
6467
void nbl_glsl_ext_FFT_setData(in uvec3 coordinate, in uint channel, in nbl_glsl_complex complex_value)
6568
{
6669
uvec3 dimension = nbl_glsl_ext_FFT_Parameters_t_getPaddedDimensions();
6770
uint index = channel * (dimension.x * dimension.y * dimension.z) + coordinate.z * (dimension.x * dimension.y) + coordinate.y * (dimension.x) + coordinate.x;
6871
outData[index] = complex_value;
6972
}
73+
#define _NBL_GLSL_EXT_FFT_SET_DATA_DEFINED_
74+
#endif
7075

76+
#ifndef _NBL_GLSL_EXT_FFT_GET_PADDED_DATA_DEFINED_
7177
nbl_glsl_complex nbl_glsl_ext_FFT_getPaddedData(in uvec3 coordinate, in uint channel)
7278
{
7379
uvec3 max_coord = nbl_glsl_ext_FFT_Parameters_t_getDimensions() - uvec3(1u);
@@ -85,10 +91,19 @@ nbl_glsl_complex nbl_glsl_ext_FFT_getPaddedData(in uvec3 coordinate, in uint cha
8591
uint index = channel * (dimension.x * dimension.y * dimension.z) + clamped_coord.z * (dimension.x * dimension.y) + clamped_coord.y * (dimension.x) + clamped_coord.x;
8692
return inData[index];
8793
}
94+
#define _NBL_GLSL_EXT_FFT_GET_PADDED_DATA_DEFINED_
95+
#endif
96+
97+
98+
#include "nbl/builtin/glsl/ext/FFT/fft.glsl"
99+
88100

101+
#ifndef _NBL_GLSL_EXT_FFT_MAIN_DEFINED_
102+
#define _NBL_GLSL_EXT_FFT_MAIN_DEFINED_
89103
void main()
90104
{
91105
const uint numChannels = nbl_glsl_ext_FFT_Parameters_t_getNumChannels();
92106
for(uint ch = 0u; ch < numChannels; ++ch)
93107
nbl_glsl_ext_FFT(nbl_glsl_ext_FFT_Parameters_t_getIsInverse(), ch);
94-
}
108+
}
109+
#endif

include/nbl/builtin/glsl/ext/FFT/fft.glsl

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,6 @@
1414

1515
#include "nbl/builtin/glsl/workgroup/shared_fft.glsl"
1616

17-
// Push Constants
18-
19-
#define _NBL_GLSL_EXT_FFT_DIRECTION_X_ 0
20-
#define _NBL_GLSL_EXT_FFT_DIRECTION_Y_ 1
21-
#define _NBL_GLSL_EXT_FFT_DIRECTION_Z_ 2
22-
23-
#define _NBL_GLSL_EXT_FFT_CLAMP_TO_EDGE_ 0
24-
#define _NBL_GLSL_EXT_FFT_FILL_WITH_ZERO_ 1
25-
2617

2718
#ifndef _NBL_GLSL_EXT_FFT_SET_DATA_DECLARED_
2819
#define _NBL_GLSL_EXT_FFT_SET_DATA_DECLARED_

include/nbl/builtin/glsl/ext/FFT/parameters.glsl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@
77

88
#include "nbl/builtin/glsl/ext/FFT/parameters_struct.glsl"
99

10+
11+
#define _NBL_GLSL_EXT_FFT_DIRECTION_X_ 0
12+
#define _NBL_GLSL_EXT_FFT_DIRECTION_Y_ 1
13+
#define _NBL_GLSL_EXT_FFT_DIRECTION_Z_ 2
14+
15+
#define _NBL_GLSL_EXT_FFT_CLAMP_TO_EDGE_ 0
16+
#define _NBL_GLSL_EXT_FFT_FILL_WITH_ZERO_ 1
17+
18+
1019
#ifndef _NBL_GLSL_EXT_FFT_GET_PARAMETERS_DECLARED_
1120
#define _NBL_GLSL_EXT_FFT_GET_PARAMETERS_DECLARED_
1221
nbl_glsl_ext_FFT_Parameters_t nbl_glsl_ext_FFT_getParameters();

0 commit comments

Comments
 (0)