Commit: d2c3bc58a1cf5a4800bd2fcfe75263b4b5fb90e9 Author: Sergey Sharybin Date: Sun Jul 28 12:12:47 2013 -0700 https://developer.blender.org/rBd2c3bc58a1cf5a4800bd2fcfe75263b4b5fb90e9
Initial integration of OpenSubdiv into Subsurf modifier Summary: This commit is an initial implementation of subsurf modifier using OpenSubdiv instead of our older CC. This doesn't change data layout and only uses OpsnSubdiv evaluation API to get coordinates and values for grid elements. Main changes: - Tweaked build systems to add flag to build with OSD. - Added C-API for opensubdiv, so it might be used from blender kernel. - Subsurf evaluation is hacked in into CCGSubSurf. TODO: - Clean up all the WIP code, make it more clear separation between legacy CCGSubSurf code and new one based on OSD evaluation. - Edges are not evaluating currently at all. - UVs subdivision currently would lead to incorrect memory usage. - Subdivision happens in a single thread. - Loose edges are not supported. - Only quads does work now, need to support triangles and N-gons. Only committing this to share via developer.b.o with other developers who are interested. Reviewers: brecht Differential Revision: http://developer.blender.org/D56 =================================================================== M CMakeLists.txt A build_files/cmake/Modules/FindOpenSubdiv.cmake M build_files/cmake/macros.cmake M build_files/scons/config/darwin-config.py M build_files/scons/config/linux-config.py M build_files/scons/config/win32-mingw-config.py M build_files/scons/config/win32-vc-config.py M build_files/scons/config/win64-mingw-config.py M build_files/scons/config/win64-vc-config.py M build_files/scons/tools/Blender.py M build_files/scons/tools/btools.py M intern/CMakeLists.txt M intern/SConscript A intern/opensubdiv/CMakeLists.txt A intern/opensubdiv/SConscript A intern/opensubdiv/opensubdiv_capi.cc A intern/opensubdiv/opensubdiv_capi.h M source/blender/blenkernel/CMakeLists.txt M source/blender/blenkernel/SConscript M source/blender/blenkernel/intern/CCGSubSurf.c M source/blender/modifiers/intern/MOD_subsurf.c M source/blenderplayer/CMakeLists.txt M source/creator/CMakeLists.txt =================================================================== diff --git a/CMakeLists.txt b/CMakeLists.txt index 74a662a..537bbb9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -140,6 +140,7 @@ option(WITH_GAMEENGINE "Enable Game Engine" ON) option(WITH_PLAYER "Build Player" OFF) option(WITH_OPENCOLORIO "Enable OpenColorIO color management" ON) option(WITH_COMPOSITOR "Enable the tile based nodal compositor" ON) +option(WITH_OPENSUBDIV "Enable OpenSubdiv for surface subdivision" ON) # GHOST Windowing Library Options option(WITH_GHOST_DEBUG "Enable debugging output for the GHOST library" OFF) @@ -875,6 +876,19 @@ if(UNIX AND NOT APPLE) endif() endif() + if(WITH_OPENSUBDIV) + find_package_wrapper(OpenSubdiv) + + set(OPENSUBDIV_LIBRARIES ${OPENSUBDIV_LIBRARIES}) + set(OPENSUBDIV_LIBPATH) # TODO, remove and reference the absolute path everywhere + set(OPENSUBDIV_DEFINITIONS) + + if(NOT OPENSUBDIV_FOUND) + set(WITH_OPENSUBDIV OFF) + message(STATUS "OpenSundiv not found") + endif() + endif() + # OpenSuse needs lutil, ArchLinux not, for now keep, can avoid by using --as-needed set(PLATFORM_LINKLIBS "-lutil -lc -lm -lpthread") diff --git a/build_files/cmake/Modules/FindOpenSubdiv.cmake b/build_files/cmake/Modules/FindOpenSubdiv.cmake new file mode 100644 index 0000000..f6159e5 --- /dev/null +++ b/build_files/cmake/Modules/FindOpenSubdiv.cmake @@ -0,0 +1,71 @@ +# - Find OpenSubdiv library +# Find the native OpenSubdiv includes and library +# This module defines +# OPENSUBDIV_INCLUDE_DIRS, where to find OpenSubdiv headers, Set when +# OPENSUBDIV_INCLUDE_DIR is found. +# OPENSUBDIV_LIBRARIES, libraries to link against to use OpenSubdiv. +# OPENSUBDIV_ROOT_DIR, the base directory to search for OpenSubdiv. +# This can also be an environment variable. +# OPENSUBDIV_FOUND, if false, do not try to use OpenSubdiv. +# +# also defined, but not for general use are +# OPENSUBDIV_LIBRARY, where to find the OpenSubdiv library. + +#============================================================================= +# Copyright 2013 Blender Foundation. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= + +# If OPENSUBDIV_ROOT_DIR was defined in the environment, use it. +IF(NOT OPENSUBDIV_ROOT_DIR AND NOT $ENV{OPENSUBDIV_ROOT_DIR} STREQUAL "") + SET(OPENSUBDIV_ROOT_DIR $ENV{OPENSUBDIV_ROOT_DIR}) +ENDIF() + +SET(_opensubdiv_SEARCH_DIRS + ${OPENSUBDIV_ROOT_DIR} + /usr/local + /sw # Fink + /opt/local # DarwinPorts + /opt/csw # Blastwave + /opt/lib/opensubdiv +) + +FIND_PATH(OPENSUBDIV_INCLUDE_DIR + NAMES + osd/mesh.h + HINTS + ${_opensubdiv_SEARCH_DIRS} + PATH_SUFFIXES + include +) + +FIND_LIBRARY(OPENSUBDIV_LIBRARY + NAMES + osdCPU + HINTS + ${_opensubdiv_SEARCH_DIRS} + PATH_SUFFIXES + lib64 lib + ) + +# handle the QUIETLY and REQUIRED arguments and set OPENSUBDIV_FOUND to TRUE if +# all listed variables are TRUE +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenSubdiv DEFAULT_MSG + OPENSUBDIV_LIBRARY OPENSUBDIV_INCLUDE_DIR) + +IF(OPENSUBDIV_FOUND) + SET(OPENSUBDIV_LIBRARIES ${OPENSUBDIV_LIBRARY}) + SET(OPENSUBDIV_INCLUDE_DIRS ${OPENSUBDIV_INCLUDE_DIR}) +ENDIF(OPENSUBDIV_FOUND) + +MARK_AS_ADVANCED( + OPENSUBDIV_INCLUDE_DIR + OPENSUBDIV_LIBRARY +) diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index 772ff6d..598fbd9 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -337,6 +337,9 @@ macro(setup_liblinks if(WITH_OPENCOLORIO) target_link_libraries(${target} ${OPENCOLORIO_LIBRARIES}) endif() + if(WITH_OPENSUBDIV) + target_link_libraries(${target} ${OPENSUBDIV_LIBRARIES}) + endif() if(WITH_BOOST) target_link_libraries(${target} ${BOOST_LIBRARIES}) if(Boost_USE_STATIC_LIBS AND Boost_USE_ICU) diff --git a/build_files/scons/config/darwin-config.py b/build_files/scons/config/darwin-config.py index 2f77c6b..d7c66c8 100644 --- a/build_files/scons/config/darwin-config.py +++ b/build_files/scons/config/darwin-config.py @@ -207,6 +207,12 @@ WITH_BF_FREESTYLE = True #OpenMP ( will be checked for compiler support and turned off eventually ) WITH_BF_OPENMP = True +WITH_BF_OPENSUBDIV = False +BF_OPENSUBDIV = LIBDIR + '/opensubdiv' +BF_OPENSUBDIV_INC = '${BF_OPENSUBDIV}/include' +BF_OPENSUBDIV_LIB = 'osdCPU' +BF_OPENSUBDIV_LIBPATH = '${BF_OPENSUBDIV}/lib' + #Ray trace optimization WITH_BF_RAYOPTIMIZATION = True BF_RAYOPTIMIZATION_SSE_FLAGS = [] diff --git a/build_files/scons/config/linux-config.py b/build_files/scons/config/linux-config.py index ce2d07f..bd11e85 100644 --- a/build_files/scons/config/linux-config.py +++ b/build_files/scons/config/linux-config.py @@ -226,6 +226,14 @@ BF_3DMOUSE_LIB_STATIC = '${BF_3DMOUSE_LIBPATH}/libspnav.a' #Freestyle WITH_BF_FREESTYLE = True +WITH_BF_OPENSUBDIV = False +WITH_BF_STATICOPENSUBDIV = False +BF_OPENSUBDIV = '/usr' +BF_OPENSUBDIV_INC = '${BF_OPENSUBDIV}/include' +BF_OPENSUBDIV_LIB = 'osdCPU' +BF_OPENSUBDIV_LIB_STATIC = '${BF_OPENSUBDIV_LIBPATH}/libosdCPU.a' +BF_OPENSUBDIV_LIBPATH = '${BF_OPENSUBDIV}/lib' + ## CC = 'gcc' CXX = 'g++' diff --git a/build_files/scons/config/win32-mingw-config.py b/build_files/scons/config/win32-mingw-config.py index 470987b..ce7cf9a 100644 --- a/build_files/scons/config/win32-mingw-config.py +++ b/build_files/scons/config/win32-mingw-config.py @@ -166,6 +166,12 @@ BF_BOOST_LIB = 'boost_date_time-mgw46-mt-s-1_49 boost_filesystem-mgw46-mt-s-1_49 BF_BOOST_LIB_INTERNATIONAL = 'boost_locale-mgw46-mt-s-1_49' BF_BOOST_LIBPATH = '${BF_BOOST}/lib' +WITH_BF_OPENSUBDIV = False +BF_OPENSUBDIV = LIBDIR + '/opensubdiv' +BF_OPENSUBDIV_INC = '${BF_OPENSUBDIV}/include' +BF_OPENSUBDIV_LIB = 'osdCPU' +BF_OPENSUBDIV_LIBPATH = '${BF_OPENSUBDIV}/lib' + #Ray trace optimization WITH_BF_RAYOPTIMIZATION = True BF_RAYOPTIMIZATION_SSE_FLAGS = ['-msse'] diff --git a/build_files/scons/config/win32-vc-config.py b/build_files/scons/config/win32-vc-config.py index b01d5aa..2419ac8 100644 --- a/build_files/scons/config/win32-vc-config.py +++ b/build_files/scons/config/win32-vc-config.py @@ -235,6 +235,12 @@ BF_RAYOPTIMIZATION_SSE_FLAGS = ['/arch:SSE'] #Freestyle WITH_BF_FREESTYLE = True +WITH_BF_OPENSUBDIV = False +BF_OPENSUBDIV = LIBDIR + '/opensubdiv' +BF_OPENSUBDIV_INC = '${BF_OPENSUBDIV}/include' +BF_OPENSUBDIV_LIB = 'osdCPU' +BF_OPENSUBDIV_LIBPATH = '${BF_OPENSUBDIV}/lib' + WITH_BF_STATICOPENGL = False BF_OPENGL_INC = '${BF_OPENGL}/include' BF_OPENGL_LIBINC = '${BF_OPENGL}/lib' diff --git a/build_files/scons/config/win64-mingw-config.py b/build_files/scons/config/win64-mingw-config.py index 1380a47..4d88322 100644 --- a/build_files/scons/config/win64-mingw-config.py +++ b/build_files/scons/config/win64-mingw-config.py @@ -165,6 +165,12 @@ BF_BOOST_LIB = 'boost_date_time-mgw47-mt-s-1_49 boost_date_time-mgw47-mt-sd-1_49 BF_BOOST_LIB_INTERNATIONAL = ' boost_locale-mgw47-mt-s-1_49 boost_locale-mgw47-mt-sd-1_49' BF_BOOST_LIBPATH = '${BF_BOOST}/lib' +WITH_BF_OPENSUBDIV = False +BF_OPENSUBDIV = LIBDIR + '/opensubdiv' +BF_OPENSUBDIV_INC = '${BF_OPENSUBDIV}/include' +BF_OPENSUBDIV_LIB = 'osdCPU' +BF_OPENSUBDIV_LIBPATH = '${BF_OPENSUBDIV}/lib' + #Ray trace optimization WITH_BF_RAYOPTIMIZATION = True BF_RAYOPTIMIZATION_SSE_FLAGS = ['-mmmx', '-msse', '-msse2'] diff --git a/build_files/scons/config/win64-vc-config.py b/build_files/scons/config/win64-vc-config.py index 5922c77..6942196 100644 --- a/build_files/scons/config/win64-vc-config.py +++ b/build_files/scons/config/win64-vc-config.py @@ -234,6 +234,12 @@ BF_RAYOPTIMIZATION_SSE_FLAGS = [''] #Freestyle WITH_BF_FREESTYLE = True +WITH_BF_OPENSUBDIV = False +BF_OPENSUBDIV = LIBDIR + '/opensubdiv' +BF_OPENSUBDIV_INC = '${BF_OPENSUBDIV}/include' +BF_OPENSUBDIV_LIB = 'osdCPU' +BF_OPENSUBDIV_LIBPATH = '${BF_OPENSUBDIV}/lib' + WITH_BF_STATICOPENGL = False BF_OPENGL_INC = '${BF_OPENGL}/include' BF_OPENGL_LIBINC = '${BF_OPENGL}/lib' diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py index 29e04ba..3935f12 100644 --- a/build_files/scons/tools/Blender.py +++ b/build_files/scons/tools/Blender.py @@ -211,6 +211,13 @@ def setup_staticlibs(lenv): if lenv['WITH_BF_ZLIB'] and lenv['WITH_BF_STATICZLIB']: statlibs += Split(lenv['BF_ZLIB_LIB_STATIC']) + if lenv['WITH_BF_OPENEXR']: + libincs += Split(lenv['BF_OPENEXR_LIBPATH']) + if lenv['WITH_BF_STATICOPENEXR']: + statlibs += Split(lenv['BF_OPENEXR_LIB_STATIC']) + if lenv['WITH_BF_ZLIB'] and lenv['WITH_BF_STATICZLIB']: + statlibs += Split(lenv['BF_ZLIB_LIB_STATIC']) + if lenv['WITH_BF_OCIO']: libincs += Split(lenv['BF_OCIO_LIBPATH']) if lenv['WITH_BF_STATICOCIO']: @@ -242,6 +249,11 @@ def setup_staticlibs(lenv): if lenv['WITH_BF_STATIC3DMOUSE']: statlibs += Split(lenv['BF_3DMOUSE_LIB_STATIC']) + if lenv['WITH_BF_OPENSUBDIV']: + libincs += Split(lenv['BF_OPENSUBDIV_LIBPATH']) + if lenv['WITH_BF_STATICOPENSUBDIV']: + statlibs += Split(lenv['BF_OPENSUBDIV_LIB_STATIC']) + # setting this last so any overriding of manually libs could be handled if lenv['OURPLATFORM'] not in ('win32-vc', 'win32-mingw', 'win64-vc', 'linuxcross', 'win64-mingw'): # We must remove any previous items defining this path, for same reason stated above! @@ -339,6 +351,10 @@ def setup_syslibs(lenv): if not lenv['WITH_BF_STATICPNG']: syslibs += Split(lenv['BF_PNG_LIB']) + if lenv['WITH_BF_OPENSUBDIV']: + if not lenv['WITH_BF_STATICOPENSUBDIV']: + syslibs += Split(lenv['BF_OPENSUBDIV_LIB']) + syslibs += lenv['LLIBS'] return syslibs diff --git a/build_files/scons/tools/btools.py b/build_files/scons/tools/btools.py index 3450f29..7da17dc 100644 --- a/build_files/scons/tools/btools.py +++ b/build_files/scons/tools/btoo @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list [email protected] http://lists.blender.org/mailman/listinfo/bf-blender-cvs
