Update SIMD and Platform Linux.

This commit is contained in:
Thorben Höhne 2025-01-21 23:57:42 +01:00
parent bb759b1a9a
commit c65b1c8139
7 changed files with 47 additions and 28 deletions

22
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,22 @@
{
"C_Cpp.formatting": "clangFormat",
"C_Cpp.loggingLevel": "Error",
"C_Cpp.default.cppStandard": "c++20",
"C_Cpp.default.includePath": [
"${workspaceFolder}/Engine/Source/Runtime",
"${workspaceFolder}/Engine/Source/ThirdParty"
],
"C_Cpp.default.browse.path": [
"${workspaceFolder}/Engine/Source/Runtime",
"${workspaceFolder}/Engine/Source/ThirdParty"
],
"C_Cpp.default.browse.databaseFilename": "${workspaceFolder}/.vscode/browse.vc.db",
"files.associations": {
"cstdint": "cpp"
},
"C_Cpp.default.defines": [
"P_LINUX_BUILD",
"__SSE__",
],
}

View File

@ -14,9 +14,9 @@
// User defines build platform // User defines build platform
#ifdef P_WIN_BUILD #ifdef P_WIN_BUILD
# define P_PLATFORM P_PLATFORM_WIN # define P_PLATFORM P_PLATFORM_WIN
# error Windows system is not yet supported.
#elif P_LINUX_BUILD #elif P_LINUX_BUILD
# define P_PLATFORM P_PLATFORM_LIN # define P_PLATFORM P_PLATFORM_LIN
# error Linux / Unix system is not yet supported.
#elif P_MAC_BUILD #elif P_MAC_BUILD
# define P_PLATFORM P_PLATFORM_MAC # define P_PLATFORM P_PLATFORM_MAC
# error Mac target system is not yet supported. # error Mac target system is not yet supported.
@ -133,7 +133,6 @@
// Clang // Clang
#elif (defined(__clang__)) #elif (defined(__clang__))
# error PhanesEngine only supports MSVC -> Visual Studio
# if defined(__apple_build_version__) # if defined(__apple_build_version__)
# #
# if (__clang_major__ < 6) # if (__clang_major__ < 6)

View File

@ -1,30 +1,15 @@
#pragma once #pragma once
#include "PhanesEnginePCH.h"
// ============================================= // // ============================================= //
// Turn os specific types into global types. // // Turn os specific types into global types. //
// ============================================= // // ============================================= //
// TODO: include int128
namespace Phanes::Core::Types namespace Phanes::Core::Types
{ {
#ifdef P_WIN_BUILD
// MSCV++ specific types
typedef FLOAT128 float128;
//#elif P_UNIX_BUILD
//
// // GCC specific types
//
// typedef __float128 float128;
#endif
// Specific types size // Specific types size
// //
// 8-Bit integer // 8-Bit integer

View File

@ -28,9 +28,19 @@
#define FORCEINLINE __forceinline #define FORCEINLINE __forceinline
#elif defined(P_UNIX_BUILD) #elif defined(P_LINUX_BUILD)
#ifdef P_DEBUG
#error Only Windows is supported at the moment. #define P_DEBUGBREAK __builtin_trap();
#else
#define P_DEBUGBREAK
#endif // P_DEBUG
#define FORCEINLINE inline __attribute__((always_inline))
#elif defined(P_ARM_BUILD) #elif defined(P_ARM_BUILD)

View File

@ -4,7 +4,6 @@
# include "PhanesEnginePCH.h" # include "PhanesEnginePCH.h"
#else #else
# define NOMINMAX # define NOMINMAX
# include <Windows.h>
# include <stdint.h> # include <stdint.h>
#endif #endif

View File

@ -113,7 +113,7 @@ namespace Phanes::Core::Math::SIMD
/// <param name="v1"></param> /// <param name="v1"></param>
void vec3_fix(Phanes::Core::Types::Vec4f32Reg v1) void vec3_fix(Phanes::Core::Types::Vec4f32Reg v1)
{ {
v1.m128_f32[3] = 0.0f; v1 = _mm_and_ps(v1, _mm_castsi128_ps(_mm_set_epi32(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000)));
} }
} }
@ -265,7 +265,7 @@ namespace Phanes::Core::Math::Detail
static FORCEINLINE float map(const Phanes::Core::Math::TVector4<float, true>& v1) static FORCEINLINE float map(const Phanes::Core::Math::TVector4<float, true>& v1)
{ {
__m128 tmp = _mm_mul_ps(v1.data, v1.data); __m128 tmp = _mm_mul_ps(v1.data, v1.data);
return sqrt(tmp.m128_f32[0] + tmp.m128_f32[1] + tmp.m128_f32[2] + tmp.m128_f32[3]); return _mm_cvtss_f32(_mm_sqrt_ps(SIMD::vec4_hadd(tmp)));
} }
}; };
@ -515,7 +515,7 @@ namespace Phanes::Core::Math::Detail
static FORCEINLINE double map(const Phanes::Core::Math::TVector2<double, true>& v1) static FORCEINLINE double map(const Phanes::Core::Math::TVector2<double, true>& v1)
{ {
__m128d tmp = _mm_mul_pd(v1.data, v1.data); __m128d tmp = _mm_mul_pd(v1.data, v1.data);
return sqrt(tmp.m128d_f64[0] + tmp.m128d_f64[1]); return _mm_cvtsd_f64(_mm_sqrt_pd(_mm_hadd_pd(tmp, tmp)));
} }
}; };
@ -526,7 +526,7 @@ namespace Phanes::Core::Math::Detail
static FORCEINLINE double map(const Phanes::Core::Math::TVector2<double, true>& v1) static FORCEINLINE double map(const Phanes::Core::Math::TVector2<double, true>& v1)
{ {
__m128d tmp = _mm_mul_pd(v1.data, v1.data); __m128d tmp = _mm_mul_pd(v1.data, v1.data);
return tmp.m128d_f64[0] + tmp.m128d_f64[1]; return _mm_cvtsd_f64(_mm_hadd_pd(tmp, tmp));
} }
}; };
@ -657,7 +657,7 @@ namespace Phanes::Core::Math::Detail
static FORCEINLINE void map(Phanes::Core::Math::TIntVector4<int, true>& v1, const int* comp) static FORCEINLINE void map(Phanes::Core::Math::TIntVector4<int, true>& v1, const int* comp)
{ {
v1.comp = _mm_loadu_epi32(comp); v1.comp = _mm_set_epi32(comp[3], comp[2], comp[1], comp[0]);
} }
static FORCEINLINE void map(Phanes::Core::Math::TIntVector4<int, true>& r, const Phanes::Core::Math::TIntVector2<int, true>& v1, const Phanes::Core::Math::TIntVector2<int, true>& v2) static FORCEINLINE void map(Phanes::Core::Math::TIntVector4<int, true>& r, const Phanes::Core::Math::TIntVector2<int, true>& v1, const Phanes::Core::Math::TIntVector2<int, true>& v2)
@ -875,7 +875,7 @@ namespace Phanes::Core::Math::Detail
static FORCEINLINE void map(Phanes::Core::Math::TIntVector2<Phanes::Core::Types::int64, true>& v1, const Phanes::Core::Types::int64* comp) static FORCEINLINE void map(Phanes::Core::Math::TIntVector2<Phanes::Core::Types::int64, true>& v1, const Phanes::Core::Types::int64* comp)
{ {
v1.comp = _mm_loadu_epi64(comp); v1.comp = _mm_set_epi64x(comp[1], comp[0]);
} }
}; };

View File

@ -0,0 +1,4 @@
cmake_minimum_required(2.8)
project(MathTestFPU)