@@ -130,33 +130,26 @@ enable_if_t<H <= N, uint32_t> bitShiftLeftHigher(uint32_t i)
130
130
return mid | high | low;
131
131
}
132
132
133
- // For an N-bit number, mirrors it around the Nyquist frequency, which for the range [0, 2^N - 1] is precisely 2^(N - 1)
134
- template<uint32_t N>
135
- uint32_t mirror (uint32_t i)
136
- {
137
- return ((1 << N) - i) & ((1 << N) - 1 )
138
- }
139
-
140
133
// This function maps the index `idx` in the output array of a Forward FFT to the index `freqIdx` in the DFT such that `DFT[freqIdx] = output[idx]`
141
134
// This is because Cooley-Tukey + subgroup operations end up spewing out the outputs in a weird order
142
135
template<uint16_t ElementsPerInvocation, uint32_t WorkgroupSize>
143
- uint32_t getFrequencyAt (uint32_t idx )
136
+ uint32_t getFrequencyIndex (uint32_t outputIdx )
144
137
{
145
138
NBL_CONSTEXPR_STATIC_INLINE uint32_t ELEMENTS_PER_INVOCATION_LOG_2 = uint32_t (mpl::log2<ElementsPerInvocation>::value);
146
139
NBL_CONSTEXPR_STATIC_INLINE uint32_t FFT_SIZE_LOG_2 = ELEMENTS_PER_INVOCATION_LOG_2 + uint32_t (mpl::log2<WorkgroupSize>::value);
147
140
148
- return mirror <FFT_SIZE_LOG_2>( bitShiftRightHigher<FFT_SIZE_LOG_2, FFT_SIZE_LOG_2 - ELEMENTS_PER_INVOCATION_LOG_2 + 1 >(glsl::bitfieldReverse<uint32_t>(idx ) >> (32 - FFT_SIZE_LOG_2) ));
141
+ return bitShiftRightHigher<FFT_SIZE_LOG_2, FFT_SIZE_LOG_2 - ELEMENTS_PER_INVOCATION_LOG_2 + 1 >(glsl::bitfieldReverse<uint32_t>(outputIdx ) >> (32 - FFT_SIZE_LOG_2));
149
142
}
150
143
151
144
// This function maps the index `freqIdx` in the DFT to the index `idx` in the output array of a Forward FFT such that `DFT[freqIdx] = output[idx]`
152
- // It is essentially the inverse of `getFrequencyAt `
145
+ // It is essentially the inverse of `getFrequencyIndex `
153
146
template<uint16_t ElementsPerInvocation, uint32_t WorkgroupSize>
154
- uint32_t getOutputAt (uint32_t freqIdx)
147
+ uint32_t getOutputIndex (uint32_t freqIdx)
155
148
{
156
149
NBL_CONSTEXPR_STATIC_INLINE uint32_t ELEMENTS_PER_INVOCATION_LOG_2 = uint32_t (mpl::log2<ElementsPerInvocation>::value);
157
150
NBL_CONSTEXPR_STATIC_INLINE uint32_t FFT_SIZE_LOG_2 = ELEMENTS_PER_INVOCATION_LOG_2 + uint32_t (mpl::log2<WorkgroupSize>::value);
158
151
159
- return glsl::bitfieldReverse<uint32_t>(bitShiftLeftHigher<FFT_SIZE_LOG_2, FFT_SIZE_LOG_2 - ELEMENTS_PER_INVOCATION_LOG_2 + 1 >(mirror <FFT_SIZE_LOG_2>( freqIdx) )) >> (32 - FFT_SIZE_LOG_2);
152
+ return glsl::bitfieldReverse<uint32_t>(bitShiftLeftHigher<FFT_SIZE_LOG_2, FFT_SIZE_LOG_2 - ELEMENTS_PER_INVOCATION_LOG_2 + 1 >(freqIdx)) >> (32 - FFT_SIZE_LOG_2);
160
153
}
161
154
162
155
} //namespace fft
0 commit comments