Skip to content

Commit efe14d6

Browse files
committed
Add packing/unpacking utils
1 parent b161dbb commit efe14d6

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

include/nbl/builtin/hlsl/workgroup/fft.hlsl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,14 @@ uint32_t mirror(uint32_t idx)
160160
return (FFT_SIZE - idx) & (FFT_SIZE - 1);
161161
}
162162

163+
// When packing real FFTs a common operation is to get `DFT[T]` and `DFT[-T]` to unpack the result of a packed real FFT.
164+
// Given an index `idx` into the Nabla-ordered DFT such that `output[idx] = DFT[T]`, this function is such that `output[getNegativeIndex(idx)] = DFT[-T]`
165+
template<uint16_t ElementsPerInvocation, uint32_t WorkgroupSize>
166+
uint32_t getNegativeIndex(uint32_t idx)
167+
{
168+
return getOutputIndex<ElementsPerInvocation, WorkgroupSize>(mirror<ElementsPerInvocation, WorkgroupSize>(getFrequencyIndex<ElementsPerInvocation, WorkgroupSize>(idx)));
169+
}
170+
163171
} //namespace fft
164172

165173
// ----------------------------------- End Utils -----------------------------------------------

0 commit comments

Comments
 (0)