Skip to content

Commit 070ac3e

Browse files
committed
Another packing util
1 parent efe14d6 commit 070ac3e

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,15 @@ uint32_t getNegativeIndex(uint32_t idx)
168168
return getOutputIndex<ElementsPerInvocation, WorkgroupSize>(mirror<ElementsPerInvocation, WorkgroupSize>(getFrequencyIndex<ElementsPerInvocation, WorkgroupSize>(idx)));
169169
}
170170

171+
// Util to unpack two values from the packed FFT X + iY - get outputs in the same input arguments, storing x to lo and y to hi
172+
template<typename Scalar>
173+
void unpack(NBL_CONST_REF_ARG(complex_t<Scalar>) lo, NBL_CONST_REF_ARG(complex_t<Scalar>) hi)
174+
{
175+
complex_t<Scalar> x = (lo + conj(hi)) * Scalar(0.5);
176+
hi = rotateRight<Scalar>(lo - conj(hi)) * 0.5;
177+
lo = x;
178+
}
179+
171180
} //namespace fft
172181

173182
// ----------------------------------- End Utils -----------------------------------------------

0 commit comments

Comments
 (0)