From 1f88ee6213ed5e8b60597034d52188256448b104 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 20 Feb 2013 11:29:43 +0000 Subject: Fix #34299: Motion Tracking 20x slower under Windows Root of the issue goes to SSBA library which didn't work properly when using optimization in MSVC. It was worked around by disabling optimization for libmv, which is in fact shame and shouldn't have been done. It seems after some changes optimization does not affect on SSBA code, but enabling optimization could be risky so close to release. For now solved by splitting SSBA to separate CMake/SCons library, disabling optimization only for this particular library and enabling optimization for rest of libmv. Tested on all files which used to fail with optimization enabled in SSBA and all of them works the same as before. Tracking speed is significantly higher now. After release we'll enable optimization for SSBA as well, so there'll be no crappy build setup. Later we'll replace old SSBA library with new BA code based on Ceres. Bundle script would be broken for until then, so better not to use it. --- extern/libmv/CMakeLists.txt | 21 +--------- extern/libmv/SConscript | 21 +--------- extern/libmv/third_party/CMakeLists.txt | 1 + extern/libmv/third_party/SConscript | 1 + extern/libmv/third_party/ssba/CMakeLists.txt | 61 ++++++++++++++++++++++++++++ extern/libmv/third_party/ssba/SConscript | 35 ++++++++++++++++ 6 files changed, 101 insertions(+), 39 deletions(-) create mode 100644 extern/libmv/third_party/ssba/CMakeLists.txt create mode 100644 extern/libmv/third_party/ssba/SConscript (limited to 'extern/libmv') diff --git a/extern/libmv/CMakeLists.txt b/extern/libmv/CMakeLists.txt index 6b5a9a3b67a..aabf2324372 100644 --- a/extern/libmv/CMakeLists.txt +++ b/extern/libmv/CMakeLists.txt @@ -26,8 +26,6 @@ # If you're doing changes in this file, please update template # in that script too -add_subdirectory(third_party) - set(INC . ../colamd/Include @@ -86,8 +84,6 @@ set(SRC third_party/gflags/gflags_completions.cc third_party/gflags/gflags_reporting.cc third_party/ldl/Source/ldl.c - third_party/ssba/Geometry/v3d_metricbundle.cpp - third_party/ssba/Math/v3d_optimization.cpp libmv-capi.h libmv/base/id_generator.h @@ -148,13 +144,6 @@ set(SRC third_party/ldl/Include/ldl.h third_party/msinttypes/inttypes.h third_party/msinttypes/stdint.h - third_party/ssba/Geometry/v3d_cameramatrix.h - third_party/ssba/Geometry/v3d_distortion.h - third_party/ssba/Geometry/v3d_metricbundle.h - third_party/ssba/Math/v3d_linear.h - third_party/ssba/Math/v3d_linear_utils.h - third_party/ssba/Math/v3d_mathutilities.h - third_party/ssba/Math/v3d_optimization.h ) if(WIN32) @@ -193,14 +182,6 @@ if(WIN32) third_party/msinttypes ) endif() - - if(MSVC) - set(MSVC_OFLAGS O1 O2 Ox) - foreach(FLAG ${MSVC_OFLAGS}) - string(REPLACE "${FLAG}" "Od" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") - string(REPLACE "${FLAG}" "Od" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}") - endforeach() - endif() else() list(APPEND SRC third_party/glog/src/demangle.cc @@ -245,3 +226,5 @@ add_definitions( ) blender_add_lib(extern_libmv "${SRC}" "${INC}" "${INC_SYS}") + +add_subdirectory(third_party) diff --git a/extern/libmv/SConscript b/extern/libmv/SConscript index b47086f3e91..5f790ab3ae6 100644 --- a/extern/libmv/SConscript +++ b/extern/libmv/SConscript @@ -11,10 +11,6 @@ Import('env') defs = [] -cflags_libmv = Split(env['CFLAGS']) -ccflags_libmv = Split(env['CCFLAGS']) -cxxflags_libmv = Split(env['CXXFLAGS']) - defs.append('V3DLIB_ENABLE_SUITESPARSE') defs.append('GOOGLE_GLOG_DLL_DECL=') @@ -27,8 +23,6 @@ src += env.Glob('libmv/tracking/*.cc') src += env.Glob('third_party/fast/*.c') src += env.Glob('third_party/gflags/*.cc') src += env.Glob('third_party/ldl/Source/*.c') -src += env.Glob('third_party/ssba/Geometry/*.cpp') -src += env.Glob('third_party/ssba/Math/*.cpp') incs = '. ../Eigen3 third_party/ceres/include' incs += ' ' + env['BF_PNG_INC'] @@ -41,19 +35,6 @@ if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', ' src += ['./third_party/glog/src/logging.cc', './third_party/glog/src/raw_logging.cc', './third_party/glog/src/utilities.cc', './third_party/glog/src/vlog_is_on.cc'] src += ['./third_party/glog/src/windows/port.cc'] - - if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'): - cflags_libmv.append('/Od') - ccflags_libmv.append('/Od') - cxxflags_libmv.append('/Od') - - if not env['BF_DEBUG']: - defs.append('NDEBUG') - else: - if not env['BF_DEBUG']: - cflags_libmv += Split(env['REL_CFLAGS']) - ccflags_libmv += Split(env['REL_CCFLAGS']) - cxxflags_libmv += Split(env['REL_CXXFLAGS']) else: src += env.Glob("third_party/glog/src/*.cc") incs += ' ./third_party/glog/src' @@ -64,6 +45,6 @@ else: incs += ' ./third_party/ssba ./third_party/ldl/Include ../colamd/Include' -env.BlenderLib ( libname = 'extern_libmv', sources=src, includes=Split(incs), defines=defs, libtype=['extern', 'player'], priority=[20,137], compileflags=cflags_libmv, cc_compileflags=ccflags_libmv, cxx_compileflags=cxxflags_libmv ) +env.BlenderLib ( libname = 'extern_libmv', sources=src, includes=Split(incs), defines=defs, libtype=['extern', 'player'], priority=[20,137] ) SConscript(['third_party/SConscript']) diff --git a/extern/libmv/third_party/CMakeLists.txt b/extern/libmv/third_party/CMakeLists.txt index 6212fe480b1..7989d97345c 100644 --- a/extern/libmv/third_party/CMakeLists.txt +++ b/extern/libmv/third_party/CMakeLists.txt @@ -1,2 +1,3 @@ +add_subdirectory(ssba) add_subdirectory(ceres) diff --git a/extern/libmv/third_party/SConscript b/extern/libmv/third_party/SConscript index b05692e385f..2e30650f656 100644 --- a/extern/libmv/third_party/SConscript +++ b/extern/libmv/third_party/SConscript @@ -1,3 +1,4 @@ #!/usr/bin/python +SConscript(['ssba/SConscript']) SConscript(['ceres/SConscript']) diff --git a/extern/libmv/third_party/ssba/CMakeLists.txt b/extern/libmv/third_party/ssba/CMakeLists.txt new file mode 100644 index 00000000000..f73a6137d6f --- /dev/null +++ b/extern/libmv/third_party/ssba/CMakeLists.txt @@ -0,0 +1,61 @@ +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# The Original Code is Copyright (C) 2013, Blender Foundation +# All rights reserved. +# +# Contributor(s): Blender Foundation, +# Sergey Sharybin +# +# ***** END GPL LICENSE BLOCK ***** + +set(INC + . + ../ldl/Include + ../../../colamd/Include +) + +set(INC_SYS +) + +set(SRC + Geometry/v3d_metricbundle.cpp + Math/v3d_optimization.cpp + + Geometry/v3d_cameramatrix.h + Geometry/v3d_distortion.h + Geometry/v3d_metricbundle.h + Math/v3d_linear.h + Math/v3d_linear_utils.h + Math/v3d_mathutilities.h + Math/v3d_optimization.h +) + +if(WIN32) + if(MSVC) + set(MSVC_OFLAGS O1 O2 Ox) + foreach(FLAG ${MSVC_OFLAGS}) + string(REPLACE "${FLAG}" "Od" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") + string(REPLACE "${FLAG}" "Od" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}") + endforeach() + endif() +endif() + +add_definitions( + -DV3DLIB_ENABLE_SUITESPARSE +) + +blender_add_lib(extern_ssba "${SRC}" "${INC}" "${INC_SYS}") diff --git a/extern/libmv/third_party/ssba/SConscript b/extern/libmv/third_party/ssba/SConscript new file mode 100644 index 00000000000..598415d0039 --- /dev/null +++ b/extern/libmv/third_party/ssba/SConscript @@ -0,0 +1,35 @@ +#!/usr/bin/python + +import sys +import os + +Import('env') + +defs = [] + +cflags_ssba = Split(env['CFLAGS']) +ccflags_ssba = Split(env['CCFLAGS']) +cxxflags_ssba = Split(env['CXXFLAGS']) + +defs.append('V3DLIB_ENABLE_SUITESPARSE') + +src = env.Glob('Geometry/*.cpp') +src += env.Glob('Math/*.cpp') + +incs = '. ../ldl/Include ../../../colamd/Include' + +if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'): + if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'): + cflags_ssba.append('/Od') + ccflags_ssba.append('/Od') + cxxflags_ssba.append('/Od') + + if not env['BF_DEBUG']: + defs.append('NDEBUG') + else: + if not env['BF_DEBUG']: + cflags_ssba += Split(env['REL_CFLAGS']) + ccflags_ssba += Split(env['REL_CCFLAGS']) + cxxflags_ssba += Split(env['REL_CXXFLAGS']) + +env.BlenderLib ( libname = 'extern_ssba', sources=src, includes=Split(incs), defines=defs, libtype=['extern', 'player'], priority=[20,137], compileflags=cflags_ssba, cc_compileflags=ccflags_ssba, cxx_compileflags=cxxflags_ssba ) -- cgit v1.2.3