Skip to content

Commit 5ff3a0c

Browse files
my shader code is a sahara
1 parent 50d5682 commit 5ff3a0c

File tree

3 files changed

+17
-95
lines changed

3 files changed

+17
-95
lines changed

examples_tests/49.ComputeFFT/fft_convolve_ifft.comp

Lines changed: 8 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,22 @@
11
layout(local_size_x=_NBL_GLSL_WORKGROUP_SIZE_, local_size_y=1, local_size_z=1) in;
22

3-
4-
#define _NBL_GLSL_EXT_FFT_GET_PARAMETERS_DEFINED_
5-
#define _NBL_GLSL_EXT_FFT_SET_DATA_DEFINED_
6-
#define _NBL_GLSL_EXT_FFT_GET_PADDED_DATA_DEFINED_
7-
#include "nbl/builtin/glsl/ext/FFT/fft.glsl"
8-
9-
// Input Descriptor
103

4+
#include <nbl/builtin/glsl/math/complex.glsl>
5+
// Input and Output Descriptor
116
layout(set=0, binding=0) buffer restrict InputOutputBuffer
127
{
138
nbl_glsl_complex inoutData[];
149
};
10+
#define _NBL_GLSL_EXT_FFT_INPUT_DESCRIPTOR_DEFINED_
11+
#define _NBL_GLSL_EXT_FFT_OUTPUT_DESCRIPTOR_DEFINED_
1512

1613
layout(set=0, binding=1) uniform sampler2D NormalizedKernel[3];
1714

18-
// Get/Set Data Function
19-
layout(push_constant) uniform PushConstants
20-
{
21-
nbl_glsl_ext_FFT_Parameters_t params;
22-
} pc;
23-
24-
nbl_glsl_ext_FFT_Parameters_t nbl_glsl_ext_FFT_getParameters()
25-
{
26-
nbl_glsl_ext_FFT_Parameters_t ret;
27-
ret = pc.params;
28-
return ret;
29-
}
30-
31-
32-
void nbl_glsl_ext_FFT_setData(in uvec3 coordinate, in uint channel, in nbl_glsl_complex complex_value)
33-
{
34-
uvec3 dimension = nbl_glsl_ext_FFT_Parameters_t_getPaddedDimensions();
35-
uint index = channel * (dimension.x * dimension.y * dimension.z) + coordinate.z * (dimension.x * dimension.y) + coordinate.y * (dimension.x) + coordinate.x;
36-
inoutData[index] = complex_value;
37-
}
38-
39-
nbl_glsl_complex nbl_glsl_ext_FFT_getPaddedData(in uvec3 coordinate, in uint channel) {
4015

41-
uvec3 max_coord = nbl_glsl_ext_FFT_Parameters_t_getDimensions() - uvec3(1u);
42-
uvec3 clamped_coord = min(coordinate, max_coord);
43-
44-
bool is_out_of_range = any(bvec3(coordinate!=clamped_coord));
45-
46-
uint paddingType = nbl_glsl_ext_FFT_Parameters_t_getPaddingType();
47-
48-
if (_NBL_GLSL_EXT_FFT_FILL_WITH_ZERO_ == paddingType && is_out_of_range) {
49-
return nbl_glsl_complex(0, 0);
50-
}
51-
52-
uvec3 dimension = nbl_glsl_ext_FFT_Parameters_t_getDimensions();
53-
uint index = channel * (dimension.x * dimension.y * dimension.z) + clamped_coord.z * (dimension.x * dimension.y) + clamped_coord.y * (dimension.x) + clamped_coord.x;
54-
return inoutData[index];
55-
}
16+
#define inData inoutData
17+
#define outData inoutData
18+
#define _NBL_GLSL_EXT_FFT_MAIN_DEFINED_
19+
#include "nbl/builtin/glsl/ext/FFT/default_compute_fft.comp"
5620

5721
void convolve(in uint item_per_thread_count, in uint ch)
5822
{
Lines changed: 4 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,10 @@
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-
8-
// Input Descriptor
9-
10-
layout(set=0, binding=0) readonly restrict buffer InputBuffer
11-
{
12-
nbl_glsl_complex inData[];
13-
};
14-
153
// Output Descriptor
16-
174
layout(set=0, binding=1, rgba16f) uniform image2D outImage;
5+
#define _NBL_GLSL_EXT_FFT_OUTPUT_DESCRIPTOR_DEFINED_
186

19-
// Get/Set Data Function
20-
21-
layout(push_constant) uniform PushConstants
22-
{
23-
nbl_glsl_ext_FFT_Parameters_t params;
24-
} pc;
25-
26-
nbl_glsl_ext_FFT_Parameters_t nbl_glsl_ext_FFT_getParameters() {
27-
nbl_glsl_ext_FFT_Parameters_t ret;
28-
ret = pc.params;
29-
return ret;
30-
}
31-
7+
#include <nbl/builtin/glsl/math/complex.glsl>
328
void nbl_glsl_ext_FFT_setData(in uvec3 coordinate, in uint channel, in nbl_glsl_complex complex_value)
339
{
3410
const ivec2 coords = ivec2(coordinate.xy);
@@ -37,30 +13,7 @@ void nbl_glsl_ext_FFT_setData(in uvec3 coordinate, in uint channel, in nbl_glsl_
3713
color_value[channel] = complex_value.x;
3814
imageStore(outImage, coords, color_value);
3915
}
16+
#define _NBL_GLSL_EXT_FFT_SET_DATA_DEFINED_
4017

41-
nbl_glsl_complex nbl_glsl_ext_FFT_getPaddedData(in uvec3 coordinate, in uint channel)
42-
{
43-
uvec3 max_coord = nbl_glsl_ext_FFT_Parameters_t_getDimensions() - uvec3(1u);
44-
uvec3 clamped_coord = min(coordinate, max_coord);
45-
46-
bool is_out_of_range = any(bvec3(coordinate!=clamped_coord));
47-
48-
uint paddingType = nbl_glsl_ext_FFT_Parameters_t_getPaddingType();
49-
50-
if (_NBL_GLSL_EXT_FFT_FILL_WITH_ZERO_ == paddingType && is_out_of_range) {
51-
return nbl_glsl_complex(0, 0);
52-
}
53-
54-
uvec3 dimension = nbl_glsl_ext_FFT_Parameters_t_getDimensions();
55-
uint index = channel * (dimension.x * dimension.y * dimension.z) + clamped_coord.z * (dimension.x * dimension.y) + clamped_coord.y * (dimension.x) + clamped_coord.x;
56-
return inData[index];
57-
}
5818

59-
void main()
60-
{
61-
const uint numChannels = nbl_glsl_ext_FFT_Parameters_t_getNumChannels();
62-
for(uint ch = 0u; ch < numChannels; ++ch)
63-
{
64-
nbl_glsl_ext_FFT(true, ch);
65-
}
66-
}
19+
#include "nbl/builtin/glsl/ext/FFT/default_compute_fft.comp"

examples_tests/49.ComputeFFT/main.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ R"===(#version 430 core
6868

6969
return gpuSpecializedShader;
7070
}
71+
72+
73+
7174
inline void updateDescriptorSet_Convolution (
7275
video::IVideoDriver * driver,
7376
video::IGPUDescriptorSet * set,
@@ -175,6 +178,8 @@ inline void updateDescriptorSet_LastFFT (
175178
driver->updateDescriptorSets(2u, pWrites, 0u, nullptr);
176179
}
177180

181+
182+
178183
int main()
179184
{
180185
nbl::SIrrlichtCreationParameters deviceParams;

0 commit comments

Comments
 (0)