-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More fft utils #795
More fft utils #795
Conversation
static inline uint32_t3 padDimensions(uint32_t3 dimensions, std::span<uint16_t> axes, bool realFFT = false) | ||
{ | ||
uint16_t axisCount = 0; | ||
for (auto i : axes) | ||
{ | ||
dimensions[i] = core::roundUpToPoT(dimensions[i]); | ||
if (realFFT && !axisCount++) | ||
dimensions[i] /= 2; | ||
} | ||
return dimensions; | ||
} | ||
|
||
static inline uint64_t getOutputBufferSize(const uint32_t3& inputDimensions, uint32_t numChannels, std::span<uint16_t> axes, bool realFFT = false, bool halfFloats = false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could have just replaced uint32_t3
with vector<uint32_t,M>
and made it available both for C++ and HLSL
also why is span<uint16_t>
used, you could just deduce the axis count from N
?
roundUpToPoT
could move to hlsl namespace actually
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
roundUpToPoT
is in core/math/intutil.h
. I can create a builtin/math/intutil.hlsl
, copy most functions over and refactor every usage of the functions in that file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
roundUpToPoT
is incore/math/intutil.h
. I can create abuiltin/math/intutil.hlsl
, copy most functions over and refactor every usage of the functions in that file
ask @Przemog1 about the preferred location so it fits in with the spirit of #801
You don't actually need to do big refactor if you provide a "legacy" alias (make the old nbl::core::roundUpToPoT
call nbl::hlsl::roundUpToPoT
) and add the [[deprecated]]
attribute
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm creating builtin/hlsl/math/intutil.hlsl
, @Przemog1 lmk if you'd rather have it be named different or placed somewhere else
…ity for realt FFTs
…in functional.hlsl . Small change to FFT Indexing utils
… between cpp and hlsl. Only thing missing is to move intutils.h to a common header as well
this allows the offset accessor passed in the bigger FFTs to pass the concept requirements - Minor change to the offset accessor, I think it follows the original intent
that moved to .hlsl - Update the GLSL bitreverse to be in-line with the GLSL spec
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hate GH reviews
template<typename Integer NBL_FUNC_REQUIRES(is_integral_v<Integer>) | ||
NBL_CONSTEXPR_FORCED_INLINE_FUNC bool isNPoT(Integer value) | ||
{ | ||
return value & (value - Integer(1)); | ||
} | ||
|
||
template<typename Integer NBL_FUNC_REQUIRES(is_integral_v<Integer>) | ||
NBL_CONSTEXPR_FORCED_INLINE_FUNC bool isPoT(Integer value) | ||
{ | ||
return !isNPoT<Integer>(value); | ||
} | ||
|
||
|
||
template<typename Integer NBL_FUNC_REQUIRES(is_integral_v<Integer>) | ||
NBL_CONSTEXPR_FORCED_INLINE_FUNC Integer roundUpToPoT(Integer value) | ||
{ | ||
return Integer(0x1u) << Integer(1 + hlsl::findMSB<Integer>(value - Integer(1))); // this wont result in constexpr because findMSB is not one | ||
} | ||
|
||
template<typename Integer NBL_FUNC_REQUIRES(is_integral_v<Integer>) | ||
NBL_CONSTEXPR_FORCED_INLINE_FUNC Integer roundDownToPoT(Integer value) | ||
{ | ||
return Integer(0x1u) << hlsl::findMSB<Integer>(value); | ||
} | ||
|
||
template<typename Integer NBL_FUNC_REQUIRES(is_integral_v<Integer>) | ||
NBL_CONSTEXPR_FORCED_INLINE_FUNC Integer roundUp(Integer value, Integer multiple) | ||
{ | ||
Integer tmp = (value + multiple - 1u) / multiple; | ||
return tmp * multiple; | ||
} | ||
|
||
template<typename Integer NBL_FUNC_REQUIRES(is_integral_v<Integer>) | ||
NBL_CONSTEXPR_FORCED_INLINE_FUNC Integer align(Integer alignment, Integer size, NBL_REF_ARG(Integer) address, NBL_REF_ARG(Integer) space) | ||
{ | ||
Integer nextAlignedAddr = roundUp<Integer>(address, alignment); | ||
|
||
Integer spaceDecrement = nextAlignedAddr - address; | ||
if (spaceDecrement > space) | ||
return 0u; | ||
|
||
Integer newSpace = space - spaceDecrement; | ||
if (size > newSpace) | ||
return 0u; | ||
|
||
space = newSpace; | ||
return address = nextAlignedAddr; | ||
} | ||
|
||
#ifndef __HLSL_VERSION | ||
|
||
// Have to wait for the HLSL patch for `is_enum`. Would also have to figure out how to do it without initializer lists for HLSL use. | ||
|
||
//! Get bitmask from variadic arguments passed. | ||
/* | ||
For example if you were to create bitmask for vertex attributes | ||
having positions inteeger set as 0, colors as 1 and normals | ||
as 3, just pass them to it and use the value returned. | ||
*/ | ||
|
||
template<typename BitmaskType NBL_FUNC_REQUIRES(is_integral_v<BitmaskType> || std::is_enum_v<BitmaskType>) | ||
NBL_CONSTEXPR_FORCED_INLINE_FUNC uint64_t createBitmask(std::initializer_list<BitmaskType> initializer) | ||
{ | ||
uint64_t retval{}; | ||
for (const auto& it : initializer) | ||
retval |= (1ull << it); | ||
return retval; | ||
} | ||
|
||
#endif | ||
|
||
} // end namespace hlsl | ||
} // end namespace nbl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description
Still adding more changes on this side
Testing
All thesting done on the FFT_Bloom example on its respective branch