Skip to content

Commit

Permalink
Merge pull request #282 from eagleivg/xd_dev
Browse files Browse the repository at this point in the history
Alpha version of Linux
  • Loading branch information
eagleivg authored Dec 12, 2018
2 parents bf82cde + 3f84af5 commit 676cf70
Show file tree
Hide file tree
Showing 55 changed files with 384 additions and 690 deletions.
20 changes: 19 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ if(NOT WIN32)
set(CMAKE_INSTALL_PREFIX "") # Skip all *nix-style installing for a while. Use DESTDIR
endif()

option ( TBB_PARALLEL "Use tbb::parallel for prarticle and skinning acceleration on SMP." ON )

include(cotire)

function(xr_install tgt)
Expand Down Expand Up @@ -67,12 +69,22 @@ endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive --std=c++17 -Wno-attributes -pipe -Wl,--no-undefined -fvisibility=hidden")

#set (SANITIZE_FLAGS "-fsanitize=address -fsanitize=leak -fno-omit-frame-pointer -g -fsanitize=shift -fsanitize=integer-divide-by-zero -fsanitize=unreachable -fsanitize=vla-bound -fsanitize=return -fsanitize=null -fsanitize=signed-integer-overflow -fsanitize=bounds -fsanitize=bounds-strict -fsanitize=object-size -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fsanitize=nonnull-attribute -fsanitize=returns-nonnull-attribute -fsanitize=bool")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SANITIZE_FLAGS}")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SANITIZE_FLAGS}")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${SANITIZE_FLAGS}")
set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${SANITIZE_FLAGS}")

set(LUA_LIBRARIES luajit)

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
endif()

if( TBB_PARALLEL )
add_definitions ( -DUSE_TBB_PARALLEL )
endif()

if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
add_definitions(-DDEBUG -DMIXED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Og")
Expand All @@ -83,7 +95,9 @@ set(LUA_FOUND true)

message("CMake build ${CMAKE_BUILD_TYPE}, CFLAGS=${CMAKE_C_FLAGS}, CXXFLAGS=${CMAKE_CXX_FLAGS}")

add_definitions(-D_MT -D_CPPUNWIND -DPURE_DYNAMIC_CAST -DDECLARE_SPECIALIZATION -DM_NOSTDCONTAINERS_EXT -DUSE_OGL)
add_definitions(-D_MT -D_CPPUNWIND -DPURE_DYNAMIC_CAST -DDECLARE_SPECIALIZATION -DM_NOSTDCONTAINERS_EXT)
add_definitions(-DLUABIND_DYNAMIC_LINK) #self-explanatory
add_definitions(-DdSINGLE) # for ODE

set(LUA_INCLUDE_DIR Externals/LuaJIT/src)

Expand All @@ -92,6 +106,10 @@ if(EXISTS ${CMAKE_SOURCE_DIR}/Externals/cryptopp/dsa.h)
file(REMOVE_RECURSE ${CMAKE_SOURCE_DIR}/Externals/cryptopp)
file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/Externals/cryptopp)
endif()
if(EXISTS ${CMAKE_SOURCE_DIR}/sdk/include/tbb/tbb.h)
file(REMOVE_RECURSE ${CMAKE_SOURCE_DIR}/sdk/include/tbb)
file(REMOVE_RECURSE ${CMAKE_SOURCE_DIR}/sdk/include/serial/tbb)
endif()
find_package(GLEW REQUIRED)
find_package(FreeImage REQUIRED)
find_package(LockFile REQUIRED)
Expand Down
2 changes: 2 additions & 0 deletions Externals/OPCODE/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ include_directories(
${SDL_INCLUDE_DIRS}
)

add_definitions(-DOPCODE_EXPORTS)

add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}__SOURCES} ${${PROJECT_NAME}__INCLUDES})

set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")
Expand Down
2 changes: 1 addition & 1 deletion Externals/luajit.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ set ( LUA_MAXINPUT 512 CACHE NUMBER "Is the maximum length for an input line in
# Version
set ( MAJVER 2 )
set ( MINVER 0 )
set ( RELVER 4 )
set ( RELVER 5 )
set ( ABIVER 5.1 )
set ( NODOTABIVER 51 )

Expand Down
2 changes: 1 addition & 1 deletion Externals/ode/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ add_dir("${DIRS}")

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/../../sdk/include )

add_definitions(-DdSINGLE -D_SECURE_SCL=0 -DLINUX -D_cdecl= -D__forceinline=inline)
add_definitions(-DdSINGLE -DdNODEBUG -D_SECURE_SCL=0 -DLINUX -D_cdecl= -D__forceinline=inline)

add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}__SOURCES} ${${PROJECT_NAME}__INCLUDES})
xr_install(${PROJECT_NAME})
2 changes: 1 addition & 1 deletion Externals/ode/ode/src/joint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2799,7 +2799,7 @@ extern "C" ODE_API void dJointSetFixedQuaternionPos (dxJointFixed *joint,dQuater
// set joint->qrel to the transpose of the first body's q
joint->qrel[0] = quaternion[0];//joint->node[0].body->q[0];
for (i=1; i<4; i++) joint->qrel[i] = -quaternion[i];//-joint->node[0].body->q[i];
for (i=0; i<4; i++) joint->offset[i] = pos[i];//joint->node[0].body->posr.pos[i];
for (i=0; i<3; i++) joint->offset[i] = pos[i];//joint->node[0].body->posr.pos[i];
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions cmake/FindTBB.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ if (WIN32)
set(_TBB_DEFAULT_INSTALL_DIR "C:/Program Files/Intel/TBB" "C:/Program Files (x86)/Intel/TBB")
set(_TBB_LIB_NAME "tbb")
set(_TBB_LIB_MALLOC_NAME "${_TBB_LIB_NAME}malloc")
set(_TBB_LIB_MALLOC_PROXY_NAME "${_TBB_LIB_NAME}malloc_proxy")
# set(_TBB_LIB_MALLOC_PROXY_NAME "${_TBB_LIB_NAME}malloc_proxy")
set(_TBB_LIB_DEBUG_NAME "${_TBB_LIB_NAME}_debug")
set(_TBB_LIB_MALLOC_DEBUG_NAME "${_TBB_LIB_MALLOC_NAME}_debug")
if (MSVC71)
Expand Down Expand Up @@ -79,7 +79,7 @@ if (UNIX)
# libs: libtbb.dylib, libtbbmalloc.dylib, *_debug
set(_TBB_LIB_NAME "tbb")
set(_TBB_LIB_MALLOC_NAME "${_TBB_LIB_NAME}malloc")
set(_TBB_LIB_MALLOC_PROXY_NAME "${_TBB_LIB_NAME}malloc_proxy")
# set(_TBB_LIB_MALLOC_PROXY_NAME "${_TBB_LIB_NAME}malloc_proxy")
set(_TBB_LIB_DEBUG_NAME "${_TBB_LIB_NAME}_debug")
set(_TBB_LIB_MALLOC_DEBUG_NAME "${_TBB_LIB_MALLOC_NAME}_debug")
# has only one flavor: ia32/cc4.0.1_os10.4.9
Expand All @@ -90,7 +90,7 @@ if (UNIX)
set(_TBB_DEFAULT_INSTALL_DIR "/opt/intel/tbb" "/usr/local/include" "/usr/include")
set(_TBB_LIB_NAME "tbb")
set(_TBB_LIB_MALLOC_NAME "${_TBB_LIB_NAME}malloc")
set(_TBB_LIB_MALLOC_PROXY_NAME "${_TBB_LIB_NAME}malloc_proxy")
# set(_TBB_LIB_MALLOC_PROXY_NAME "${_TBB_LIB_NAME}malloc_proxy")
set(_TBB_LIB_DEBUG_NAME "${_TBB_LIB_NAME}_debug")
set(_TBB_LIB_MALLOC_DEBUG_NAME "${_TBB_LIB_MALLOC_NAME}_debug")
# has em64t/cc3.2.3_libc2.3.2_kernel2.4.21 em64t/cc3.3.3_libc2.3.3_kernel2.6.5 em64t/cc3.4.3_libc2.3.4_kernel2.6.9 em64t/cc4.1.0_libc2.4_kernel2.6.16.21
Expand Down Expand Up @@ -146,7 +146,7 @@ endif (NOT _TBB_INSTALL_DIR)
if (TBB_OBVIOUS_PLACE)
set (TBB_FOUND "YES")
find_library(TBB_MALLOC_LIBRARY ${_TBB_LIB_MALLOC_NAME})
find_library(TBB_MALLOC_PROXY_LIBRARY ${_TBB_LIB_MALLOC_PROXY_NAME} ${TBB_LIBRARY_DIR})
# find_library(TBB_MALLOC_PROXY_LIBRARY ${_TBB_LIB_MALLOC_PROXY_NAME} ${TBB_LIBRARY_DIR})
set (TBB_LIBRARIES ${TEST_TBB_LIBRARY} ${TBB_MALLOC_LIBRARY} ${TBB_MALLOC_PROXY_LIBRARY} ${TBB_LIBRARIES})
set (TBB_INCLUDE_DIRS ${TEST_TBB_INCLUDE_DIR} CACHE PATH "TBB include directory" FORCE)
mark_as_advanced(TBB_INCLUDE_DIRS TBB_LIBRARIES)
Expand Down Expand Up @@ -181,7 +181,7 @@ else (TBB_OBVIOUS_PLACE)

find_library(TBB_LIBRARY ${_TBB_LIB_NAME} ${TBB_LIBRARY_DIR} NO_DEFAULT_PATH)
find_library(TBB_MALLOC_LIBRARY ${_TBB_LIB_MALLOC_NAME} ${TBB_LIBRARY_DIR} NO_DEFAULT_PATH)
find_library(TBB_MALLOC_PROXY_LIBRARY ${_TBB_LIB_MALLOC_PROXY_NAME} ${TBB_LIBRARY_DIR} NO_DEFAULT_PATH)
# find_library(TBB_MALLOC_PROXY_LIBRARY ${_TBB_LIB_MALLOC_PROXY_NAME} ${TBB_LIBRARY_DIR} NO_DEFAULT_PATH)

mark_as_advanced(TBB_LIBRARY TBB_MALLOC_LIBRARY TBB_MALLOC_PROXY_LIBRARY)

Expand Down
5 changes: 3 additions & 2 deletions src/Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@
WIN32;
_SECURE_SCL=0;
_CRT_SECURE_NO_WARNINGS;
_CRT_SECURE_NO_DEPRECATE;
_CRT_SECURE_NO_DEPRECATE;
USE_TBB_PARALLEL;
%(PreprocessorDefinitions)
</PreprocessorDefinitions>
<FloatingPointModel>Fast</FloatingPointModel>
Expand Down Expand Up @@ -140,4 +141,4 @@
<OutputFile>$(xrLibDir)$(TargetName).lib</OutputFile>
</Lib>
</ItemDefinitionGroup>
</Project>
</Project>
7 changes: 6 additions & 1 deletion src/Common/PlatformLinux.inl
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ inline void _splitpath(const char* path, // Path Input
)
{
if(!path)
return EINVAL;
return;

const char *p, *end;

Expand Down Expand Up @@ -403,6 +403,11 @@ inline int strncat_s(char * dest, size_t num, const char * source, size_t count)
}

#define _vsnprintf vsnprintf
inline int vsnprintf_s(char* buffer, size_t size, size_t, const char* format, va_list list)
{
//TODO add bound check
return vsnprintf(buffer, size, format, list);
}
#define vsprintf_s(dest, size, format, args) vsprintf(dest, format, args)
#define _alloca alloca
#define _snprintf snprintf
Expand Down
15 changes: 15 additions & 0 deletions src/Common/Util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,18 @@
Log(msg, u32((x)->Release()));\
}\
}
#ifdef USE_TBB_PARALLEL
#define FOR_START(type, start, finish, counter)\
tbb::parallel_for(tbb::blocked_range<type>(start, finish), [&](const tbb::blocked_range<type>& range) {\
for (type counter = range.begin(); counter != range.end(); ++counter)

#define FOR_END });
#define ACCELERATED_SORT tbb::parallel_sort
#else
#define FOR_START(type, start, finish, counter)\
for (type counter = start; counter < finish; counter++)
#define FOR_END
#define ACCELERATED_SORT std::sort
#endif


6 changes: 2 additions & 4 deletions src/Layers/xrRender/HOM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@ void CHOM::Load()
// Create RASTER-triangles
m_pTris = xr_alloc<occTri>(u32(CL.getTS()));

tbb::parallel_for(tbb::blocked_range<u32>(0, CL.getTS()), [&](const auto& range)
{
for (u32 it = range.begin(); it != range.end(); ++it)
FOR_START(u32, 0, CL.getTS(), it)
{
CDB::TRI& clT = CL.getT()[it];
occTri& rT = m_pTris[it];
Expand All @@ -123,7 +121,7 @@ void CHOM::Load()
rT.skip = 0;
rT.center.add(v0, v1).add(v2).div(3.f);
}
});
FOR_END

// Create AABB-tree
m_pModel = new CDB::MODEL();
Expand Down
Loading

0 comments on commit 676cf70

Please sign in to comment.