Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alpha version of Linux #282

Merged
merged 32 commits into from
Dec 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e81b8eb
xrPhysics: add init at DLL loading for Linux
eagleivg Nov 14, 2018
e89814e
ODE: add forgoten define in CMake
eagleivg Nov 15, 2018
d1744ab
Valgrind: fix some uninitialize allocations warnings
eagleivg Nov 20, 2018
298826c
xrCore, Linux: remove vsnprintf_s to common inline file
eagleivg Nov 21, 2018
6877b51
xrCore: remove vcalgrind warning about unitialized value in conditions
eagleivg Nov 21, 2018
98fecf6
xrCore: fix memory leak
eagleivg Nov 21, 2018
4bc9e7c
xrCore: remove compiler warning in xrMemory
eagleivg Nov 21, 2018
cb3bf78
xr_3da: fix wrong free, fix buffer overflow on linux
eagleivg Nov 21, 2018
ede7eec
CMake: refactor defines according MSVS solution, remove windows-specific
eagleivg Nov 21, 2018
e85b6fa
CMake: update LuaJIT release version
eagleivg Nov 23, 2018
2801582
CMake: disable TBB malloc_proxy at linux (fix many crashes)
eagleivg Nov 23, 2018
289be4f
ODE: fix bufer overflow at read from Fvector
eagleivg Nov 27, 2018
1d5549e
xrGame: fix bufer overflow at read pointer to local variable
eagleivg Nov 28, 2018
992d806
xrParticles: saved particle_effect.cpp in UTF-8
eagleivg Nov 28, 2018
19d13e4
xrRender: fix bufer overflow on Linux (type size missmatch)
eagleivg Nov 28, 2018
b1df2ce
xrParticles: refactor of size type
eagleivg Nov 28, 2018
be4272d
xrCore: replace ttapi to tbb:parallel for calculate Skin4W
eagleivg Nov 29, 2018
e3d5edd
replace ttapi by tbb finally
eagleivg Nov 29, 2018
44584f8
xrRender: fix particles glitches at tbb usage
eagleivg Nov 29, 2018
24bdb79
Fix Windows x86 build
q4a Dec 2, 2018
a3d0d9c
Fix: shapedata.h->ShapeData.h
q4a Dec 3, 2018
1c7dea1
xrCore: refactor LoadArchive in LoactorAPI
eagleivg Dec 4, 2018
d090b44
xrCore: refactor _bitwise.h - replace iCeil and iFloor on std, replace
eagleivg Dec 4, 2018
22f5942
xrCore: translate some comments
eagleivg Dec 4, 2018
56ef5d9
xrCore: fix undefined behavior (method return stack-allocated object)
eagleivg Dec 4, 2018
204029a
xr_3da: replace memory allocator on xrCore version
eagleivg Dec 6, 2018
1b791e3
Common: TBB now use for parallel processing if defined USE_TBB_PARALLEL
eagleivg Dec 10, 2018
82e947e
Common: fix redefine of SORT for tbb
eagleivg Dec 10, 2018
e1d67d0
xrGame: fix compiler symbol interference
eagleivg Dec 11, 2018
ecca848
xrGame: fix double-free error on Linux (many-many of random craches)
eagleivg Dec 11, 2018
9e0db4b
CMake: add option for use parallel acceleration via TBB (default enable)
eagleivg Dec 11, 2018
3f84af5
Common: enable build VS2017 with tbb_parallel
eagleivg Dec 11, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the magic number "3"? Can we use the expression like sizeof(array)/sizeof(array[0]) here? Or maybe define some constant?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not array, type of pos is a pointer to dReal, but it a pointer to the first component of the vector is passed to the function. Even if we pass the link to the Fvector itself there, we cannot calculate the size of the components, we need to know in advance how much to read.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It sucks :( This 'style' should lead to a lot of typos. I believe we find a LOT of such bugs later.

}
}
}
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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe remove this garbage instead of commenting it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure that I will not be required to return it.

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the NULL in path is expected behaviour? Seems like not - we don't report the error to the caller. So... Let's insert some type of assertion here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This case is defined in MSDN in the following way:

If path is NULL, the invalid parameter handler is invoked, as described in Parameter Validation. If execution is allowed to continue, errno is set to EINVAL and the function returns EINVAL.

We're trying to reproduce that second case. Notice that it doesn't make sense, because _splitpath is supposed to return void. Maybe it should insert errno = EINVAL.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, reporting an error is an alternative solution. If this function tries to mimic the Windows implementation - I agree that it's the preferrable way.


const char *p, *end;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's init the variables directly in this line


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