math backend setup

setup libraries for different simd isa's
add float4 functions for c sse2 and avx2 (placeholder file for neon to be implemented on mac)
This commit is contained in:
marauder2k7 2026-02-26 14:57:16 +00:00
parent b6ea96f367
commit e9fdffc2dd
9 changed files with 386 additions and 2 deletions

View file

@ -133,4 +133,49 @@ macro(addFramework framework)
find_library(_${framework}_FRAMEWORK_PATH ${framework} PATHS /System/Library/Frameworks /Library/Frameworks)
set(TORQUE_LINK_FRAMEWORKS ${TORQUE_LINK_FRAMEWORKS} "${_${framework}_FRAMEWORK_PATH}")
endif()
endmacro()
endmacro()
function(add_math_backend name compile_defs)
file(GLOB_RECURSE SRC CONFIGURE_DEPENDS "math/isa/${name}/*.cpp")
if(NOT SRC)
return()
endif()
add_library(math_${name} OBJECT ${SRC})
target_include_directories(math_${name} PUBLIC
"math/public"
"math/impl"
"math/isa/${name}"
)
target_compile_definitions(math_${name} PRIVATE ${compile_defs})
# ISA flags
if(MSVC)
if(name STREQUAL "sse2" OR name STREQUAL "sse41")
target_compile_options(math_${name} PRIVATE /arch:SSE2)
elseif(name STREQUAL "avx")
target_compile_options(math_${name} PRIVATE /arch:AVX)
elseif(name STREQUAL "avx2")
target_compile_options(math_${name} PRIVATE /arch:AVX2)
endif()
else()
if(name STREQUAL "sse2")
target_compile_options(math_${name} PRIVATE -msse2)
elseif(name STREQUAL "sse41")
target_compile_options(math_${name} PRIVATE -msse4.1)
elseif(name STREQUAL "avx")
target_compile_options(math_${name} PRIVATE -mavx)
elseif(name STREQUAL "avx2")
target_compile_options(math_${name} PRIVATE -mavx2 -mfma)
elseif(name STREQUAL "neon")
target_compile_options(math_${name} PRIVATE -march=armv8-a+simd)
endif()
endif()
# Inject objects into engine
target_sources(${TORQUE_APP_NAME} PRIVATE $<TARGET_OBJECTS:math_${name}>)
set_target_properties(math_${name} PROPERTIES FOLDER "Libraries/Math")
endfunction()