mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-12-29 11:01:23 +00:00
util-math: Add 16-byte aligned version of vec2
This commit is contained in:
parent
98baa0d98b
commit
406326b378
2 changed files with 48 additions and 20 deletions
|
@ -22,6 +22,26 @@
|
|||
#include <cstdlib>
|
||||
#include "util-memory.hpp"
|
||||
|
||||
void* util::vec2a::operator new(size_t count)
|
||||
{
|
||||
return aligned_alloc(count, 16);
|
||||
}
|
||||
|
||||
void* util::vec2a::operator new[](size_t count)
|
||||
{
|
||||
return aligned_alloc(count, 16);
|
||||
}
|
||||
|
||||
void util::vec2a::operator delete(void* p)
|
||||
{
|
||||
aligned_free(p);
|
||||
}
|
||||
|
||||
void util::vec2a::operator delete[](void* p)
|
||||
{
|
||||
aligned_free(p);
|
||||
}
|
||||
|
||||
void* util::vec3a::operator new(size_t count)
|
||||
{
|
||||
return aligned_alloc(count, 16);
|
||||
|
|
|
@ -67,24 +67,37 @@ inline size_t GetNearestPowerOfTwoBelow(size_t v)
|
|||
}
|
||||
|
||||
namespace util {
|
||||
#ifdef _MSC_VER
|
||||
#ifdef _MSC_VER
|
||||
__declspec(align(16))
|
||||
#endif
|
||||
struct vec3a : public vec3 {
|
||||
#endif
|
||||
struct vec2a : public vec2 {
|
||||
// 16-byte Aligned version of vec2
|
||||
static void* operator new(size_t count);
|
||||
static void* operator new[](size_t count);
|
||||
static void operator delete(void* p);
|
||||
static void operator delete[](void* p);
|
||||
static void operator delete(void* p);
|
||||
static void operator delete[](void* p);
|
||||
};
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#ifdef _MSC_VER
|
||||
__declspec(align(16))
|
||||
#endif
|
||||
struct vec4a : public vec4 {
|
||||
#endif
|
||||
struct vec3a : public vec3 {
|
||||
// 16-byte Aligned version of vec3
|
||||
static void* operator new(size_t count);
|
||||
static void* operator new[](size_t count);
|
||||
static void operator delete(void* p);
|
||||
static void operator delete[](void* p);
|
||||
static void operator delete(void* p);
|
||||
static void operator delete[](void* p);
|
||||
};
|
||||
|
||||
#ifdef _MSC_VER
|
||||
__declspec(align(16))
|
||||
#endif
|
||||
struct vec4a : public vec4 {
|
||||
// 16-byte Aligned version of vec4
|
||||
static void* operator new(size_t count);
|
||||
static void* operator new[](size_t count);
|
||||
static void operator delete(void* p);
|
||||
static void operator delete[](void* p);
|
||||
};
|
||||
|
||||
std::pair<int64_t, int64_t> SizeFromString(std::string text, bool allowSquare = true);
|
||||
|
@ -122,19 +135,14 @@ namespace util {
|
|||
{ \
|
||||
return is_power_of_two_loop(v); \
|
||||
}
|
||||
is_power_of_two_as_loop(int8_t)
|
||||
is_power_of_two_as_loop(uint8_t)
|
||||
is_power_of_two_as_loop(int16_t)
|
||||
is_power_of_two_as_loop(uint16_t)
|
||||
is_power_of_two_as_loop(int32_t)
|
||||
is_power_of_two_as_loop(uint32_t)
|
||||
is_power_of_two_as_loop(int64_t)
|
||||
is_power_of_two_as_loop(uint64_t)
|
||||
is_power_of_two_as_loop(int8_t) is_power_of_two_as_loop(uint8_t) is_power_of_two_as_loop(int16_t)
|
||||
is_power_of_two_as_loop(uint16_t) is_power_of_two_as_loop(int32_t) is_power_of_two_as_loop(uint32_t)
|
||||
is_power_of_two_as_loop(int64_t) is_power_of_two_as_loop(uint64_t)
|
||||
#undef is_power_of_two_as_loop
|
||||
#pragma pop_macro("is_power_of_two_as_loop")
|
||||
|
||||
template<typename T>
|
||||
inline uint64_t get_power_of_two_exponent_floor(T v)
|
||||
template<typename T>
|
||||
inline uint64_t get_power_of_two_exponent_floor(T v)
|
||||
{
|
||||
return uint64_t(floor(log10(T(v)) / log10(2.0)));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue