@@ -98,9 +98,9 @@ core::SRange<const video::IGPUDescriptorSetLayout::SBinding> FFT::getDefaultBind
98
98
return {bnd, bnd+sizeof (bnd)/sizeof (IGPUDescriptorSetLayout::SBinding)};
99
99
}
100
100
101
- core::smart_refctd_ptr<video::IGPUSpecializedShader> FFT::createShader (video::IVideoDriver* driver, DataType inputType, uint32_t maxPaddedDimensionSize )
101
+ core::smart_refctd_ptr<video::IGPUSpecializedShader> FFT::createShader (video::IVideoDriver* driver, DataType inputType, uint32_t maxDimensionSize )
102
102
{
103
- assert ( core::isPoT (maxPaddedDimensionSize) );
103
+ uint32_t const maxPaddedDimensionSize = core::roundUpToPoT (maxDimensionSize );
104
104
105
105
const char * sourceFmt =
106
106
R"===( #version 430 core
@@ -130,6 +130,7 @@ layout(local_size_x=_NBL_GLSL_EXT_FFT_BLOCK_SIZE_X_DEFINED_, local_size_y=_NBL_G
130
130
131
131
#define _NBL_GLSL_EXT_FFT_GET_DATA_DEFINED_
132
132
#define _NBL_GLSL_EXT_FFT_SET_DATA_DEFINED_
133
+ #define _NBL_GLSL_EXT_FFT_GET_PADDED_DATA_DEFINED_
133
134
#include "nbl/builtin/glsl/ext/FFT/fft.glsl"
134
135
135
136
// Input Descriptor
@@ -187,7 +188,7 @@ layout(set=_NBL_GLSL_EXT_FFT_OUTPUT_SET_DEFINED_, binding=_NBL_GLSL_EXT_FFT_OUTP
187
188
188
189
// Get/Set Data Function
189
190
190
- vec2 nbl_glsl_ext_FFT_getData(in uvec3 coordinate, in uint channel)
191
+ nbl_glsl_complex nbl_glsl_ext_FFT_getData(in uvec3 coordinate, in uint channel)
191
192
{
192
193
vec2 retValue = vec2(0, 0);
193
194
#if USE_SSBO_FOR_INPUT > 0
@@ -201,13 +202,27 @@ vec2 nbl_glsl_ext_FFT_getData(in uvec3 coordinate, in uint channel)
201
202
return retValue;
202
203
}
203
204
204
- void nbl_glsl_ext_FFT_setData(in uvec3 coordinate, in uint channel, in vec2 complex_value)
205
+ void nbl_glsl_ext_FFT_setData(in uvec3 coordinate, in uint channel, in nbl_glsl_complex complex_value)
205
206
{
206
207
uvec3 dimension = pc.padded_dimension;
207
208
uint index = channel * (dimension.x * dimension.y * dimension.z) + coordinate.z * (dimension.x * dimension.y) + coordinate.y * (dimension.x) + coordinate.x;
208
209
outData[index].complex_value = complex_value;
209
210
}
210
211
212
+ nbl_glsl_complex nbl_glsl_ext_FFT_getPaddedData(in uvec3 coordinate, in uint channel) {
213
+
214
+ uvec3 max_coord = pc.dimension - uvec3(1u);
215
+ uvec3 clamped_coord = min(coordinate, max_coord);
216
+
217
+ bool is_out_of_range = any(bvec3(coordinate!=clamped_coord));
218
+
219
+ if (_NBL_GLSL_EXT_FFT_FILL_WITH_ZERO_ == pc.padding_type && is_out_of_range) {
220
+ return nbl_glsl_complex(0, 0);
221
+ }
222
+
223
+ return nbl_glsl_ext_FFT_getData(clamped_coord, channel);
224
+ }
225
+
211
226
void main()
212
227
{
213
228
nbl_glsl_ext_FFT();
@@ -271,9 +286,9 @@ layout(set=0, binding=1) restrict buffer OutBuffer
271
286
272
287
void main()
273
288
{
274
- float power = length(in_data[0].complex_value);
275
- vec2 normalized_data = in_data[gl_GlobalInvocationID.x].complex_value / power;
276
- out_data[gl_GlobalInvocationID.x].complex_value = normalized_data;
289
+ float power = length(in_data[0].complex_value);
290
+ vec2 normalized_data = in_data[gl_GlobalInvocationID.x].complex_value / power;
291
+ out_data[gl_GlobalInvocationID.x].complex_value = normalized_data;
277
292
}
278
293
)===" ;
279
294
0 commit comments