mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-18 20:00:56 +00:00
working for both neon32 and neon64 Update math_backend.cpp further sse simd additions avx2 float3 added added normalize_magnitude added divide fast to float3 may copy to float4 move static spheremesh to drawSphere (initialize on first use) so platform has a chance to load the math backend all float3 and float4 functions and isas completed all options of float3 and float4 functions in isas and math_c neon still to be done but that will be on mac. Update math_backend.cpp mac isa neon update added float3 restructured the classes to look more like the final version of the x86 classes linux required changes Update build-macos-clang.yml Update build-macos-clang.yml Revert "Update build-macos-clang.yml" This reverts commit29dfc567f4. Revert "Update build-macos-clang.yml" This reverts commit2abad2b4ca. Update CMakeLists.txt fix macs stupid build remove god awful rolling average from frame time tracker.... use intrinsic headers instead each isa implementation now uses a header for that isa's intrinsic functions these are then used in the impl files. This will make it easier for matrix functions when those are implemented. fixed comment saying 256 when it should be 512 for avx512 consolidated initializers for function tables Update neon_intrinsics.h fixes for some neon intrinsics no idea if this is the best way to do these but they work at least v_cross is especially messy at the moment we basically just do it as a c math function need to look into getting this done correctly
184 lines
No EOL
7.6 KiB
CMake
184 lines
No EOL
7.6 KiB
CMake
# -----------------------------------------------------------------------------
|
|
# Copyright (c) 2014 GarageGames, LLC
|
|
#
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
# of this software and associated documentation files (the "Software"), to
|
|
# deal in the Software without restriction, including without limitation the
|
|
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
# sell copies of the Software, and to permit persons to whom the Software is
|
|
# furnished to do so, subject to the following conditions:
|
|
#
|
|
# The above copyright notice and this permission notice shall be included in
|
|
# all copies or substantial portions of the Software.
|
|
#
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
# IN THE SOFTWARE.
|
|
# -----------------------------------------------------------------------------
|
|
################# Helper Functions ###################
|
|
macro(setupVersionNumbers)
|
|
set(TORQUE_APP_VERSION_MAJOR 1 CACHE STRING "")
|
|
set(TORQUE_APP_VERSION_MINOR 0 CACHE STRING "")
|
|
set(TORQUE_APP_VERSION_PATCH 0 CACHE STRING "")
|
|
set(TORQUE_APP_VERSION_TWEAK 0 CACHE STRING "")
|
|
|
|
mark_as_advanced(TORQUE_APP_VERSION_TWEAK)
|
|
MATH(EXPR TORQUE_APP_VERSION "${TORQUE_APP_VERSION_MAJOR} * 1000 + ${TORQUE_APP_VERSION_MINOR} * 100 + ${TORQUE_APP_VERSION_PATCH} * 10 + ${TORQUE_APP_VERSION_TWEAK}")
|
|
set(TORQUE_APP_VERSION_STRING "${TORQUE_APP_VERSION_MAJOR}.${TORQUE_APP_VERSION_MINOR}.${TORQUE_APP_VERSION_PATCH}.${TORQUE_APP_VERSION_TWEAK}")
|
|
endmacro()
|
|
|
|
function(installTemplate templateName)
|
|
message("Prepare Template(${templateName}) install...")
|
|
|
|
file(COPY "${CMAKE_SOURCE_DIR}/Templates/${templateName}/" DESTINATION "${TORQUE_APP_ROOT_DIRECTORY}" FILES_MATCHING PATTERN "*.in")
|
|
file(COPY "${CMAKE_SOURCE_DIR}/Templates/${templateName}/" DESTINATION "${TORQUE_APP_ROOT_DIRECTORY}" FILES_MATCHING PATTERN "*.cmake")
|
|
add_subdirectory("${CMAKE_SOURCE_DIR}/Templates/${templateName}")
|
|
endfunction()
|
|
|
|
MACRO(SUBDIRLIST result curdir)
|
|
FILE(GLOB children RELATIVE ${curdir} ${curdir}/*)
|
|
SET(dirlist "")
|
|
FOREACH(child ${children})
|
|
IF(IS_DIRECTORY ${curdir}/${child})
|
|
LIST(APPEND dirlist ${child})
|
|
ENDIF()
|
|
ENDFOREACH()
|
|
SET(${result} ${dirlist})
|
|
ENDMACRO()
|
|
|
|
# Helper function to add a directory to the TORQUE_SOURCE_FILES variable. It automatically searches for .cpp and .h files in the
|
|
# specified directory then adds them to the TORQUE_SOURCE_FILES variable.
|
|
macro (torqueAddSourceDirectories)
|
|
foreach(ARGUMENT ${ARGV})
|
|
file(GLOB SCANNED_SOURCE_FILES "${ARGUMENT}/*.cpp")
|
|
file(GLOB SCANNED_INCLUDE_FILES "${ARGUMENT}/*.h")
|
|
|
|
if (APPLE)
|
|
file(GLOB SCANNED_MAC_FILES "${ARGUMENT}/*.mm")
|
|
endif (APPLE)
|
|
|
|
# Set in both current and parent scope so this macro can be used from loaded modules
|
|
set(TORQUE_SOURCE_FILES ${TORQUE_SOURCE_FILES} ${SCANNED_SOURCE_FILES} ${SCANNED_INCLUDE_FILES} ${SCANNED_MAC_FILES})
|
|
set(TORQUE_SOURCE_FILES ${TORQUE_SOURCE_FILES} PARENT_SCOPE)
|
|
endforeach()
|
|
endmacro (torqueAddSourceDirectories)
|
|
|
|
################# Set Conditional Engine Defines ###################
|
|
macro (forwardDef flag)
|
|
if (${flag})
|
|
set(TORQUE_COMPILE_DEFINITIONS ${TORQUE_COMPILE_DEFINITIONS} ${flag})
|
|
endif()
|
|
endmacro(forwardDef)
|
|
|
|
macro (advanced_option flag description state)
|
|
option(${flag} ${description} ${state})
|
|
mark_as_advanced(${flag})
|
|
endmacro(advanced_option)
|
|
################# additional preprocessor defines ###################
|
|
macro(__addDef def config)
|
|
# two possibilities: a) target already known, so add it directly, or b) target not yet known, so add it to its cache
|
|
if(TARGET ${PROJECT_NAME})
|
|
#message(STATUS "directly applying defs: ${PROJECT_NAME} with config ${config}: ${def}")
|
|
if("${config}" STREQUAL "")
|
|
set_property(TARGET ${PROJECT_NAME} APPEND PROPERTY COMPILE_DEFINITIONS ${def})
|
|
else()
|
|
set_property(TARGET ${PROJECT_NAME} APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:${config}>:${def}>)
|
|
endif()
|
|
else()
|
|
if("${config}" STREQUAL "")
|
|
list(APPEND ${PROJECT_NAME}_defs_ ${def})
|
|
else()
|
|
list(APPEND ${PROJECT_NAME}_defs_ $<$<CONFIG:${config}>:${def}>)
|
|
endif()
|
|
#message(STATUS "added definition to cache: ${PROJECT_NAME}_defs_: ${${PROJECT_NAME}_defs_}")
|
|
endif()
|
|
endmacro()
|
|
|
|
# adds a definition: argument 1: Nothing(for all), _DEBUG, _RELEASE, <more build configurations>
|
|
macro(addDef def)
|
|
set(def_configs "")
|
|
if(${ARGC} GREATER 1)
|
|
foreach(config ${ARGN})
|
|
__addDef(${def} ${config})
|
|
endforeach()
|
|
else()
|
|
__addDef(${def} "")
|
|
endif()
|
|
endmacro()
|
|
|
|
# this applies cached definitions onto the target must come *after* target_compile_definitions
|
|
macro(append_defs)
|
|
if(DEFINED ${PROJECT_NAME}_defs_)
|
|
set_property(TARGET ${PROJECT_NAME} APPEND PROPERTY COMPILE_DEFINITIONS ${${PROJECT_NAME}_defs_})
|
|
#message(STATUS "applying defs to project ${PROJECT_NAME}: ${${PROJECT_NAME}_defs_}")
|
|
else()
|
|
#message(STATUS "NO ${PROJECT_NAME}_defs_ defined!")
|
|
endif()
|
|
endmacro()
|
|
|
|
################# file filtering ###################
|
|
macro (filterOut)
|
|
foreach(ARGUMENT ${ARGV})
|
|
list(REMOVE_ITEM TORQUE_SOURCE_FILES "${CMAKE_SOURCE_DIR}/Engine/source/${ARGUMENT}")
|
|
endforeach()
|
|
endmacro (filterOut)
|
|
|
|
################# apple frameworks ###################
|
|
macro(addFramework framework)
|
|
if (APPLE)
|
|
find_library(_${framework}_FRAMEWORK_PATH ${framework} PATHS /System/Library/Frameworks /Library/Frameworks)
|
|
set(TORQUE_LINK_FRAMEWORKS ${TORQUE_LINK_FRAMEWORKS} "${_${framework}_FRAMEWORK_PATH}")
|
|
endif()
|
|
endmacro()
|
|
|
|
function(add_math_backend name compile_defs)
|
|
file(GLOB_RECURSE SRC CONFIGURE_DEPENDS "math/isa/${name}/*.cpp" "math/isa/${name}/*.h")
|
|
|
|
if(NOT SRC)
|
|
return()
|
|
endif()
|
|
|
|
add_library(math_${name} OBJECT ${SRC})
|
|
|
|
message(STATUS "adding math library for isa ${name}")
|
|
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")
|
|
target_compile_options(math_${name} PRIVATE /arch:SSE2)
|
|
elseif(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() |