Skip to content

Commit 7fd1e25

Browse files
make sure blur spectrum is not bitreversed
1 parent 902b15f commit 7fd1e25

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

examples_tests/49.ComputeFFT/fft_convolve_ifft.comp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ void convolve(in uint item_per_thread_count, in uint ch)
7575
uint tid = gl_LocalInvocationIndex + t * _NBL_GLSL_WORKGROUP_SIZE_;
7676
uvec3 coords = nbl_glsl_ext_FFT_getCoordinates(tid);
7777
//coords &= uvec3(0xffeu);
78+
coords = bitfieldReverse(coords)>>uvec3(21u,22u,0u);
79+
//nbl_glsl_complex shift = nbl_glsl_expImaginary(-nbl_glsl_PI*float(k+l));
80+
//
7881
nbl_glsl_ext_FFT_impl_values[t] = nbl_glsl_complex_mul(nbl_glsl_ext_FFT_impl_values[t],texelFetch(NormalizedKernel[ch],ivec2(coords.xy),0).xy);
7982
}
8083
}

examples_tests/49.ComputeFFT/normalization.comp

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,13 @@ layout(set=0, binding=1, rg16f) uniform image2D NormalizedKernel[3];
1212

1313
void main()
1414
{
15-
const uvec3 sizes = gl_WorkGroupSize*gl_NumWorkGroups;
16-
const uvec3 strides = uvec3(1u,sizes.x,sizes.y*sizes.x);
15+
// TODO: push constants
16+
const uvec2 log2_sizes = findMSB(gl_WorkGroupSize*gl_NumWorkGroups).xy;
17+
const uvec2 strides = uvec2(1u,0x1u<<log2_sizes.x);
1718

1819
const float power = length(in_data[0]);
20+
nbl_glsl_complex value = in_data[gl_GlobalInvocationID.x*strides.x+gl_GlobalInvocationID.y*strides.y]/power;
1921

20-
nbl_glsl_complex value = in_data[gl_GlobalInvocationID.x*strides.x+gl_GlobalInvocationID.y*strides.y];
21-
value /= power;
22-
imageStore(NormalizedKernel[gl_WorkGroupID.z],ivec2(gl_GlobalInvocationID),vec4(value,0.0,0.0));
23-
24-
#if 0
25-
const uint k = bitfieldReverse(gl_GlobalInvocationID.x%2048u)>>21u;
26-
const uint l = bitfieldReverse(gl_GlobalInvocationID.x/2048u)>>21u;
27-
nbl_glsl_complex shift = nbl_glsl_expImaginary(-nbl_glsl_PI*float(k+l));
28-
//shift.x = 1.f;
29-
//shift.y = 0.f;
30-
out_data[gl_GlobalInvocationID.x] = nbl_glsl_complex_mul(in_data[gl_GlobalInvocationID.x],shift)/power;
31-
#endif
22+
uvec2 coord = bitfieldReverse(gl_GlobalInvocationID.xy)>>(uvec2(32u)-log2_sizes);
23+
imageStore(NormalizedKernel[gl_WorkGroupID.z],ivec2(coord),vec4(value,0.0,0.0));
3224
}

0 commit comments

Comments
 (0)