Skip to content

Commit 1663ea2

Browse files
slight API change
1 parent 5ff3a0c commit 1663ea2

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

examples_tests/49.ComputeFFT/fft_convolve_ifft.comp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void convolve(in uint item_per_thread_count, in uint ch)
2626
for(uint t=0u; t<item_per_thread_count; t++)
2727
{
2828
uint tid = gl_LocalInvocationIndex + t * _NBL_GLSL_WORKGROUP_SIZE_;
29-
// TODO: refactor
29+
// TODO: refactor for smem usage
3030
uvec3 coords = nbl_glsl_ext_FFT_getCoordinates(tid);
3131
const uvec3 log2_size = uvec3(11u, 10u, 0u);
3232
coords = bitfieldReverse(coords)>>(uvec3(32u)-log2_size);
@@ -42,8 +42,9 @@ void convolve(in uint item_per_thread_count, in uint ch)
4242

4343
void main()
4444
{
45-
const uint dataLength = nbl_glsl_ext_FFT_Parameters_t_getFFTLength();
46-
const uint item_per_thread_count = dataLength>>_NBL_GLSL_WORKGROUP_SIZE_LOG2_;
45+
const uint log2FFTSize = nbl_glsl_ext_FFT_Parameters_t_getLog2FFTSize();
46+
const uint item_per_thread_count = 0x1u<<(log2FFTSize-_NBL_GLSL_WORKGROUP_SIZE_LOG2_);
47+
4748
const uint numChannels = nbl_glsl_ext_FFT_Parameters_t_getNumChannels();
4849
for(uint ch = 0u; ch < numChannels; ++ch)
4950
{
@@ -53,13 +54,13 @@ void main()
5354
const uint tid = (t<<_NBL_GLSL_WORKGROUP_SIZE_LOG2_)|gl_LocalInvocationIndex;
5455
nbl_glsl_ext_FFT_impl_values[t] = nbl_glsl_ext_FFT_getPaddedData(nbl_glsl_ext_FFT_getCoordinates(tid),ch);
5556
}
56-
nbl_glsl_ext_FFT_preloaded(false,dataLength);
57+
nbl_glsl_ext_FFT_preloaded(false,log2FFTSize);
5758
barrier();
5859

5960
convolve(item_per_thread_count,ch);
6061

6162
barrier();
62-
nbl_glsl_ext_FFT_preloaded(true,dataLength);
63+
nbl_glsl_ext_FFT_preloaded(true,log2FFTSize);
6364
// write out to main memory
6465
for(uint t=0u; t<item_per_thread_count; t++)
6566
{

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,10 @@ void nbl_glsl_ext_FFT_loop(in bool is_inverse, in uint virtual_thread_count, in
6767
}
6868
}
6969

70-
void nbl_glsl_ext_FFT_preloaded(bool is_inverse, in uint dataLength)
70+
void nbl_glsl_ext_FFT_preloaded(bool is_inverse, in uint log2FFTSize)
7171
{
7272
// Virtual Threads Calculation
73+
const uint dataLength = 1u<<log2FFTSize;
7374
const uint halfDataLength = dataLength>>1u;
7475
const uint virtual_thread_count = halfDataLength>>_NBL_GLSL_WORKGROUP_SIZE_LOG2_;
7576

@@ -98,8 +99,8 @@ void nbl_glsl_ext_FFT_preloaded(bool is_inverse, in uint dataLength)
9899
void nbl_glsl_ext_FFT(bool is_inverse, uint channel)
99100
{
100101
// Virtual Threads Calculation
101-
const uint dataLength = nbl_glsl_ext_FFT_Parameters_t_getFFTLength();
102-
const uint item_per_thread_count = dataLength>>_NBL_GLSL_WORKGROUP_SIZE_LOG2_;
102+
const uint log2FFTSize = nbl_glsl_ext_FFT_Parameters_t_getLog2FFTSize();
103+
const uint item_per_thread_count = 0x1u<<(log2FFTSize-_NBL_GLSL_WORKGROUP_SIZE_LOG2_);
103104

104105
// Load Values into local memory
105106
for(uint t=0u; t<item_per_thread_count; t++)
@@ -108,7 +109,7 @@ void nbl_glsl_ext_FFT(bool is_inverse, uint channel)
108109
nbl_glsl_ext_FFT_impl_values[t] = nbl_glsl_ext_FFT_getPaddedData(nbl_glsl_ext_FFT_getCoordinates(tid),channel);
109110
}
110111
// do FFT
111-
nbl_glsl_ext_FFT_preloaded(is_inverse,dataLength);
112+
nbl_glsl_ext_FFT_preloaded(is_inverse,log2FFTSize);
112113
// write out to main memory
113114
for(uint t=0u; t<item_per_thread_count; t++)
114115
{

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ uint nbl_glsl_ext_FFT_Parameters_t_getFFTLength() {
3838
const uint direction = nbl_glsl_ext_FFT_Parameters_t_getDirection();
3939
return nbl_glsl_ext_FFT_Parameters_t_getPaddedDimensions()[direction];
4040
}
41+
uint nbl_glsl_ext_FFT_Parameters_t_getLog2FFTSize()
42+
{
43+
return findMSB(nbl_glsl_ext_FFT_Parameters_t_getFFTLength());
44+
}
4145

4246
bool nbl_glsl_ext_FFT_Parameters_t_getIsInverse() {
4347
nbl_glsl_ext_FFT_Parameters_t params = nbl_glsl_ext_FFT_getParameters();

0 commit comments

Comments
 (0)