Torque3D/Engine/source/math/public/math_backend.h
marauder2k7 68e762130d Compilation changes
Few compile time attempts to speed things up

Swap include guards for pramga once
Change compile options in the cmakeLists for source
generate a pch

small tweaks
2026-06-04 20:42:09 +01:00

88 lines
1.9 KiB
C++

#pragma once
#pragma once
#ifndef _MATH_BACKEND_H_
#define _MATH_BACKEND_H_
#include "math/mConstants.h"
#include "platform/platformAssert.h"
#include "math/public/float4_dispatch.h"
#include "math/public/float3_dispatch.h"
#include "math/public/mat44_dispatch.h"
namespace math_backend
{
enum class backend
{
scalar,
sse2,
sse41,
avx,
avx2,
neon
};
static backend g_backend = backend::scalar;
backend choose_backend(U32 cpu_flags);
void install_from_cpu_flags(uint32_t cpu_flags);
}
#include <mutex>
namespace math_backend::float4::dispatch
{
//--------------------------------------------------
// Thread-safe getter, ensures scalar installed if empty
//--------------------------------------------------
inline Float4Funcs& GetFloat4()
{
if (gFloat4.mul == nullptr)
{
static std::once_flag once;
std::call_once(once, []{
install_scalar();
});
}
return gFloat4;
}
}
namespace math_backend::float3::dispatch
{
//--------------------------------------------------
// Thread-safe getter, ensures scalar installed if empty
//--------------------------------------------------
inline Float3Funcs& GetFloat3()
{
if (gFloat3.mul == nullptr)
{
static std::once_flag once;
std::call_once(once, []{
install_scalar();
});
}
return gFloat3;
}
}
namespace math_backend::mat44::dispatch
{
//--------------------------------------------------
// Thread-safe getter, ensures scalar installed if empty
//--------------------------------------------------
inline Mat44Funcs& GetMat44()
{
if (gMat44.mul_mat44 == nullptr)
{
static std::once_flag once;
std::call_once(once, []{
install_scalar();
});
}
return gMat44;
}
}
#endif // !_MATH_BACKEND_H_