From fa7a8df3aaa0c2a470b3a183d5e08da260657df3 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Fri, 27 Feb 2026 14:41:37 +0000 Subject: [PATCH] linux required changes --- Engine/source/math/impl/float3_impl.inl | 4 ++-- Engine/source/math/isa/sse41/float3.cpp | 10 +++++++++- Engine/source/platformPOSIX/POSIXMath.cpp | 3 +++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Engine/source/math/impl/float3_impl.inl b/Engine/source/math/impl/float3_impl.inl index ddf9886d7..668e2c5d8 100644 --- a/Engine/source/math/impl/float3_impl.inl +++ b/Engine/source/math/impl/float3_impl.inl @@ -47,7 +47,7 @@ namespace math_backend::float3 { f32x4 va = v_load3(a); f32x4 vb = v_load3(b); - f32x4 vr = v_div(va, vb); + f32x4 vr = v_div_fast(va, vb); v_store3(r, vr); } @@ -56,7 +56,7 @@ namespace math_backend::float3 { f32x4 va = v_load3(a); f32x4 vs = v_set1(s); - f32x4 vr = v_div(va, vs); + f32x4 vr = v_div_fast(va, vs); v_store3(r, vr); } diff --git a/Engine/source/math/isa/sse41/float3.cpp b/Engine/source/math/isa/sse41/float3.cpp index 52f675ab9..9a5e0be5c 100644 --- a/Engine/source/math/isa/sse41/float3.cpp +++ b/Engine/source/math/isa/sse41/float3.cpp @@ -28,8 +28,16 @@ namespace // Element-wise multiply inline f32x4 v_mul(f32x4 a, f32x4 b) { return _mm_mul_ps(a, b); } + // Element-wise divide fast (1/b) + inline f32x4 v_div_fast(f32x4 a, f32x4 b) + { + f32x4 rcp = _mm_rcp_ps(b); + // Optional refinement here + return _mm_mul_ps(a, rcp); + } + // Element-wise divide - inline f32x4 v_div(f32x4 a, f32x4 b) { return _mm_div_ps(a, b); } + inline f32x4 v_div(f32x4 a, f32x4 b) { return v_div_fast(a, b); } // Element-wise add inline f32x4 v_add(f32x4 a, f32x4 b) { return _mm_add_ps(a, b); } diff --git a/Engine/source/platformPOSIX/POSIXMath.cpp b/Engine/source/platformPOSIX/POSIXMath.cpp index 8f21329a3..751df294e 100644 --- a/Engine/source/platformPOSIX/POSIXMath.cpp +++ b/Engine/source/platformPOSIX/POSIXMath.cpp @@ -27,6 +27,7 @@ #include "math/mMath.h" #include "core/strings/stringFunctions.h" #include "console/engineAPI.h" +#include "math/public/math_backend.h" extern void mInstallLibrary_C(); extern void mInstallLibrary_ASM(); @@ -90,6 +91,8 @@ void Math::init(U32 properties) Con::printf(" Installing Standard C extensions"); mInstallLibrary_C(); + math_backend::install_from_cpu_flags(properties); + #if defined(TORQUE_CPU_X32) || defined(TORQUE_CPU_X64) Con::printf(" Installing Assembly extensions"); mInstallLibrary_ASM();