Move align helpers to util/asm.hpp

Also add some files:
GLTextureCache.cpp
VKTextureCache.cpp
This commit is contained in:
Nekotekina 2020-12-18 17:43:34 +03:00
parent d254a5736b
commit eec11bfba9
52 changed files with 794 additions and 713 deletions

View file

@ -595,31 +595,6 @@ struct f16
}
};
template <typename T, typename = std::enable_if_t<std::is_integral<T>::value && std::is_unsigned<T>::value>>
constexpr T align(T value, ullong align)
{
return static_cast<T>((value + (align - 1)) & (0 - align));
}
// General purpose aligned division, the result is rounded up not truncated
template <typename T, typename = std::enable_if_t<std::is_integral<T>::value && std::is_unsigned<T>::value>>
constexpr T aligned_div(T value, ullong align)
{
return static_cast<T>((value + align - 1) / align);
}
// General purpose aligned division, the result is rounded to nearest
template <typename T, typename = std::enable_if_t<std::is_integral<T>::value>>
constexpr T rounded_div(T value, std::conditional_t<std::is_signed<T>::value, llong, ullong> align)
{
if constexpr (std::is_unsigned<T>::value)
{
return static_cast<T>((value + (align / 2)) / align);
}
return static_cast<T>((value + (value < 0 ? 0 - align : align) / 2) / align);
}
template <typename T, typename T2>
inline u32 offset32(T T2::*const mptr)
{