Skip to content

Commit 50d5682

Browse files
dry code is beautiful
1 parent 89e64af commit 50d5682

File tree

3 files changed

+7
-40
lines changed

3 files changed

+7
-40
lines changed
Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,18 @@
11
layout(local_size_x=_NBL_GLSL_WORKGROUP_SIZE_, local_size_y=1, local_size_z=1) in;
22

3-
#define _NBL_GLSL_EXT_FFT_GET_PARAMETERS_DEFINED_
4-
#define _NBL_GLSL_EXT_FFT_SET_DATA_DEFINED_
5-
#define _NBL_GLSL_EXT_FFT_GET_PADDED_DATA_DEFINED_
6-
#include "nbl/builtin/glsl/ext/FFT/fft.glsl"
7-
83
// Input Descriptor
94
layout(set=0, binding=0) uniform sampler2D inputImage;
5+
#define _NBL_GLSL_EXT_FFT_INPUT_DESCRIPTOR_DEFINED_
106

11-
// output
12-
layout(set=0, binding=1) restrict buffer OutputBuffer
13-
{
14-
nbl_glsl_complex outData[];
15-
};
16-
17-
// Get/Set Data Function
18-
layout(push_constant) uniform PushConstants
19-
{
20-
nbl_glsl_ext_FFT_Parameters_t params;
21-
} pc;
22-
23-
nbl_glsl_ext_FFT_Parameters_t nbl_glsl_ext_FFT_getParameters()
24-
{
25-
nbl_glsl_ext_FFT_Parameters_t ret;
26-
ret = pc.params;
27-
return ret;
28-
}
29-
30-
void nbl_glsl_ext_FFT_setData(in uvec3 coordinate, in uint channel, in nbl_glsl_complex complex_value)
31-
{
32-
uvec3 dimension = nbl_glsl_ext_FFT_Parameters_t_getPaddedDimensions();
33-
uint index = channel * (dimension.x * dimension.y * dimension.z) + coordinate.z * (dimension.x * dimension.y) + coordinate.y * (dimension.x) + coordinate.x;
34-
outData[index] = complex_value;
35-
}
36-
7+
#include <nbl/builtin/glsl/math/complex.glsl>
378
nbl_glsl_complex nbl_glsl_ext_FFT_getPaddedData(in uvec3 coordinate, in uint channel)
389
{
3910
ivec2 inputImageSize = textureSize(inputImage, 0);
4011
vec2 normalizedCoords = (vec2(coordinate.xy) + vec2(0.5f)) / vec2(inputImageSize);
4112
vec4 texelValue= textureLod(inputImage, normalizedCoords, 0);
4213
return nbl_glsl_complex(texelValue[channel], 0.0f);
4314
}
15+
#define _NBL_GLSL_EXT_FFT_GET_PADDED_DATA_DEFINED_
4416

45-
void main()
46-
{
47-
const uint numChannels = nbl_glsl_ext_FFT_Parameters_t_getNumChannels();
48-
for(uint ch = 0u; ch < numChannels; ++ch)
49-
{
50-
nbl_glsl_ext_FFT(nbl_glsl_ext_FFT_Parameters_t_getIsInverse(), ch);
51-
}
52-
}
17+
18+
#include "nbl/builtin/glsl/ext/FFT/default_compute_fft.comp"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef _NBL_GLSL_WORKGROUP_SIZE_
22
#define _NBL_GLSL_WORKGROUP_SIZE_ 256
3-
#endif
43
layout(local_size_x=_NBL_GLSL_WORKGROUP_SIZE_, local_size_y=1, local_size_z=1) in;
4+
#endif
55

66

77
#include <nbl/builtin/glsl/math/complex.glsl>

src/nbl/ext/FFT/FFT.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ R"===(#version 430 core
7171
#define _NBL_GLSL_WORKGROUP_SIZE_ %u
7272
#define _NBL_GLSL_EXT_FFT_MAX_DIM_SIZE_ %u
7373
74+
layout(local_size_x=_NBL_GLSL_WORKGROUP_SIZE_, local_size_y=1, local_size_z=1) in;
7475
#include "nbl/builtin/glsl/ext/FFT/default_compute_fft.comp"
7576
7677
)===";

0 commit comments

Comments
 (0)