Cycles:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 16 Aug 2011 16:15:34 +0000 (16:15 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 16 Aug 2011 16:15:34 +0000 (16:15 +0000)
* add some (disabled) test code for using OpenImageIO in imbuf
* link cycles, openimageio and boost into blender instead of a shared library
* some cmakefile changes to simplify the code and follow conventions better
* this may solve running cycles problems on windows XP, or give a different
  and hopefully more useful error message

31 files changed:
CMakeLists.txt
build_files/cmake/macros.cmake
intern/cycles/CMakeLists.txt
intern/cycles/app/CMakeLists.txt
intern/cycles/blender/CMakeLists.txt
intern/cycles/blender/addon/engine.py
intern/cycles/blender/blender_python.cpp
intern/cycles/bvh/CMakeLists.txt
intern/cycles/cmake/external_libs.cmake
intern/cycles/cmake/platforms.cmake [deleted file]
intern/cycles/device/CMakeLists.txt
intern/cycles/doc/CMakeLists.txt
intern/cycles/doc/license/CMakeLists.txt [new file with mode: 0644]
intern/cycles/kernel/CMakeLists.txt
intern/cycles/kernel/osl/CMakeLists.txt
intern/cycles/kernel/osl/nodes/CMakeLists.txt
intern/cycles/render/CMakeLists.txt
intern/cycles/subd/CMakeLists.txt
intern/cycles/util/CMakeLists.txt
source/blender/editors/screen/area.c
source/blender/imbuf/CMakeLists.txt
source/blender/imbuf/IMB_imbuf_types.h
source/blender/imbuf/intern/IMB_filetype.h
source/blender/imbuf/intern/filetype.c
source/blender/imbuf/intern/openimageio.cpp [new file with mode: 0644]
source/blender/imbuf/intern/readimage.c
source/blender/imbuf/intern/util.c
source/blender/imbuf/intern/writeimage.c
source/blender/python/intern/CMakeLists.txt
source/blender/python/intern/bpy_interface.c
source/creator/CMakeLists.txt

index 7b36b3b9fd7f4631add264c82203c9dbfe4c3e0b..bbd9598780d1b366b78b77a38c6662d76ecfb07a 100644 (file)
@@ -190,6 +190,14 @@ option(WITH_API_INSTALL     "Copy API header files into the blender install fold
 
 # Cycles
 option(WITH_CYCLES                     "Enable Cycles Render Engine" ON)
+OPTION(WITH_CYCLES_OSL         "Build with Open Shading Language support" OFF)
+OPTION(WITH_CYCLES_CUDA                "Build with CUDA support" OFF)
+OPTION(WITH_CYCLES_OPENCL      "Build with OpenCL support (not working)" OFF)
+OPTION(WITH_CYCLES_BLENDER     "Build Blender Python extension" ON)
+OPTION(WITH_CYCLES_PARTIO      "Build with Partio point cloud support (unfinished)" OFF)
+OPTION(WITH_CYCLES_NETWORK     "Build with network rendering support (unfinished)" OFF)
+OPTION(WITH_CYCLES_MULTI       "Build with network rendering support (unfinished)" OFF)
+OPTION(WITH_CYCLES_TEST                "Build cycles test application" OFF)
 
 # disable for now, but plan to support on all platforms eventually
 option(WITH_MEM_JEMALLOC   "Enable malloc replacement (http://www.canonware.com/jemalloc)" OFF)
@@ -263,6 +271,16 @@ endif()
 
 TEST_SSE_SUPPORT()
 
+# XXX hack
+if(WITH_CYCLES)
+       set(WITH_OPENIMAGEIO ON)
+       set(WITH_BOOST ON)
+endif()
+
+if(WITH_OPENIMAGEIO)
+       set(WITH_BOOST ON)
+endif()
+
 #-----------------------------------------------------------------------------
 # Initialize un-cached vars, avoid unused warning
 
@@ -471,6 +489,44 @@ if(UNIX AND NOT APPLE)
                endif()
        endif()
 
+       if(WITH_BOOST)
+               if(CYCLES_BOOST)
+                       set(BOOST ${CYCLES_BOOST} CACHE PATH "Boost Directory")
+                       unset(CYCLES_BOOST CACHE)
+               else()
+                       set(BOOST "/usr" CACHE PATH "Boost Directory")
+               endif()
+
+           #set(Boost_ADDITIONAL_VERSIONS "1.46" "1.45" "1.44" 
+               #       "1.43" "1.43.0" "1.42" "1.42.0" 
+               #       "1.41" "1.41.0" "1.40" "1.40.0"
+               #       "1.39" "1.39.0" "1.38" "1.38.0"
+               #       "1.37" "1.37.0" "1.34.1" "1_34_1")
+
+               set(BOOST_ROOT ${BOOST})
+               set(Boost_USE_MULTITHREADED ON)
+               find_package(Boost 1.34 REQUIRED COMPONENTS filesystem regex system thread)
+
+               set(BOOST_INCLUDE_DIR ${Boost_INCLUDE_DIRS})
+               set(BOOST_LIBRARIES ${Boost_LIBRARIES})
+               set(BOOST_LIBPATH ${Boost_LIBRARY_DIRS})
+               set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB")
+       endif()
+
+       if(WITH_OPENIMAGEIO)
+               if(CYCLES_OIIO)
+                       set(OPENIMAGEIO ${CYCLES_OIIO} CACHE PATH "OpenImageIO Directory")
+                       unset(CYCLES_OIIO CACHE)
+               else()
+                       set(OPENIMAGEIO "/usr" CACHE PATH "OpenImageIO Directory")
+               endif()
+
+               set(OPENIMAGEIO_INCLUDE_DIR ${OPENIMAGEIO}/include)
+               set(OPENIMAGEIO_LIBRARY OpenImageIO)
+               set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib)
+               set(OPENIMAGEIO_DEFINITIONS)
+       endif()
+
        # OpenSuse needs lutil, ArchLinux not, for now keep, can avoid by using --as-needed
        set(PLATFORM_LINKLIBS "-lutil -lc -lm -lpthread -lstdc++")
 
@@ -759,6 +815,24 @@ elseif(WIN32)
                        set(PYTHON_LIBRARIES  "${PYTHON_LIBRARY}")
                endif()
 
+               if(WITH_BOOST)
+                       set(BOOST ${LIBDIR}/boost)
+                       set(BOOST_INCLUDE_DIR ${BOOST}/include)
+                       set(BOOST_POSTFIX "vc90-mt-s-1_46_1.lib")
+                       set(BOOST_LIBRARIES libboost_date_time-${BOOST_POSTFIX} libboost_filesystem-${BOOST_POSTFIX}
+                       libboost_regex-${BOOST_POSTFIX} libboost_system-${BOOST_POSTFIX} libboost_thread-${BOOST_POSTFIX})
+                       set(BOOST_LIBPATH ${BOOST}/lib)
+                       set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB")
+               endif()
+                       
+               if(WITH_OPENIMAGEIO)
+                       set(OPENIMAGEIO ${LIBDIR}/openimageio)
+                       set(OPENIMAGEIO_INCLUDE_DIR ${OPENIMAGEIO}/include)
+                       set(OPENIMAGEIO_LIBRARY OpenImageIO)
+                       set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib)
+                       set(OPENIMAGEIO_DEFINITIONS)
+               endif()
+
                set(PLATFORM_LINKFLAGS "/SUBSYSTEM:CONSOLE /STACK:2097152 /INCREMENTAL:NO /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcmrt.lib /NODEFAULTLIB:msvcurt.lib /NODEFAULTLIB:msvcrtd.lib")
 
                # MSVC only, Mingw doesnt need
@@ -1064,6 +1138,22 @@ elseif(APPLE)
                # linker needs "-weak_framework 3DconnexionClient"
        endif()
 
+       if(WITH_BOOST)
+               set(BOOST ${LIBDIR}/boost)
+               set(BOOST_INCLUDE_DIR ${BOOST}/include)
+               set(BOOST_LIBRARIES boost_date_time-mt boost_filesystem-mt boost_regex-mt boost_system-mt boost_thread-mt)
+               set(BOOST_LIBPATH ${BOOST}/lib)
+               set(BOOST_DEFINITIONS)
+       endif()
+
+       if(WITH_OPENIMAGEIO)
+               set(OPENIMAGEIO ${LIBDIR}/openimageio)
+               set(OPENIMAGEIO_INCLUDE_DIR ${OPENIMAGEIO}/include)
+               set(OPENIMAGEIO_LIBRARY OpenImageIO ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${TIFF_LIBRARY} ${OPENEXR_LIBRARIES} ${ZLIB_LIBRARIES})
+               set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib ${JPEG_LIBPATH} ${PNG_LIBPATH} ${TIFF_LIBPATH} ${OPENEXR_LIBPATH} ${ZLIB_LIBPATH})
+               set(OPENIMAGEIO_DEFINITIONS "-DOIIO_STATIC_BUILD")
+       endif()
+
        set(EXETYPE MACOSX_BUNDLE)
 
        set(CMAKE_C_FLAGS_DEBUG "-fno-strict-aliasing -g")
@@ -1304,6 +1394,12 @@ add_subdirectory(source)
 add_subdirectory(intern)
 add_subdirectory(extern)
 
+#-----------------------------------------------------------------------------
+# Cycles
+
+if(WITH_CYCLES)
+       add_subdirectory(intern/cycles)
+endif()
 
 #-----------------------------------------------------------------------------
 # Blender Application
@@ -1317,13 +1413,6 @@ if(WITH_PLAYER)
        add_subdirectory(source/blenderplayer)
 endif()
 
-#-----------------------------------------------------------------------------
-# Cycles
-
-if(WITH_CYCLES)
-       add_subdirectory(intern/cycles)
-endif()
-
 #-----------------------------------------------------------------------------
 # CPack for generating packages
 include(build_files/cmake/packaging.cmake)
index ed200abd4195a016212dfaadbc8b915fff448276..b991edcd5d48d5c8e65af6de101140c9b47873b0 100644 (file)
@@ -164,6 +164,12 @@ macro(SETUP_LIBDIRS)
        if(WITH_IMAGE_TIFF)
                link_directories(${TIFF_LIBPATH})
        endif()
+       if(WITH_BOOST)
+               link_directories(${BOOST_LIBPATH})
+       endif()
+       if(WITH_OPENIMAGEIO)
+               link_directories(${OPENIMAGEIO_LIBPATH})
+       endif()
        if(WITH_IMAGE_OPENJPEG AND UNIX AND NOT APPLE)
                link_directories(${OPENJPEG_LIBPATH})
        endif()
@@ -270,6 +276,12 @@ macro(setup_liblinks
        if(WITH_IMAGE_TIFF)
                target_link_libraries(${target} ${TIFF_LIBRARY})
        endif()
+       if(WITH_BOOST)
+               target_link_libraries(${target} ${BOOST_LIBRARIES})
+       endif()
+       if(WITH_OPENIMAGEIO)
+               target_link_libraries(${target} ${OPENIMAGEIO_LIBRARY})
+       endif()
        if(WITH_IMAGE_OPENEXR)
                if(WIN32 AND NOT UNIX)
                        file_list_suffix(OPENEXR_LIBRARIES_DEBUG "${OPENEXR_LIBRARIES}" "_d")
@@ -569,3 +581,38 @@ macro(blender_project_hack_post)
        endif()
 
 endmacro()
+
+# pair of macros to allow libraries to be specify files to install, but to
+# only install them at the end so the directories don't get cleared with
+# the files in them. used by cycles to install addon.
+macro(delayed_install
+       base
+       files
+       destination)
+
+       foreach(f ${files})
+               set_property(GLOBAL APPEND PROPERTY DELAYED_INSTALL_FILES ${base}/${f})
+               set_property(GLOBAL APPEND PROPERTY DELAYED_INSTALL_DESTINATIONS ${destination})
+       endforeach()
+endmacro()
+
+# note this is a function instead of a macro so that ${BUILD_TYPE} in targetdir
+# does not get expanded in calling but is preserved
+function(delayed_do_install
+       targetdir)
+
+       get_property(files GLOBAL PROPERTY DELAYED_INSTALL_FILES)
+       get_property(destinations GLOBAL PROPERTY DELAYED_INSTALL_DESTINATIONS)
+
+       if(files)
+               list(LENGTH files n)
+               math(EXPR n "${n}-1")
+
+               foreach(i RANGE ${n})
+                       list(GET files ${i} f)
+                       list(GET destinations ${i} d)
+                       install(FILES ${f} DESTINATION ${targetdir}/${d})
+               endforeach()
+       endif()
+endfunction()
+
index 413952e8791c8e1d19912c5df5ff9db1e6d7a589..77ae0486d163925fde01e2786597eda934b91e59 100644 (file)
@@ -1,81 +1,80 @@
 
-SET(CYCLES_VERSION_MAJOR 0)
-SET(CYCLES_VERSION_MINOR 0)
-SET(CYCLES_VERSION ${CYCLES_VERSION_MAJOR}.${CYCLES_VERSION_MINOR})
-
-# Options
-
-OPTION(WITH_CYCLES_OSL "Build with Open Shading Language support" OFF)
-OPTION(WITH_CYCLES_CUDA "Build with CUDA support" OFF)
-OPTION(WITH_CYCLES_OPENCL "Build with OpenCL support (not working)" OFF)
-OPTION(WITH_CYCLES_BLENDER "Build Blender Python extension" ON)
-OPTION(WITH_CYCLES_PARTIO "Build with Partio point cloud support (unfinished)" OFF)
-OPTION(WITH_CYCLES_NETWORK "Build with network rendering support (unfinished)" OFF)
-OPTION(WITH_CYCLES_MULTI "Build with network rendering support (unfinished)" OFF)
-OPTION(WITH_CYCLES_TEST "Build cycles test application" OFF)
-
-# Flags
-
-SET(CYCLES_CUDA_ARCH sm_10 sm_11 sm_12 sm_13 sm_20 sm_21 CACHE STRING "CUDA architectures to build for")
-SET(CYCLES_CUDA_MAXREG 24 CACHE STRING "CUDA maximum number of register to use")
-
-# Paths
-
-IF(UNIX AND NOT APPLE)
-       SET(CYCLES_OIIO "" CACHE PATH "Path to OpenImageIO installation")
-       SET(CYCLES_BOOST "/usr" CACHE PATH "Path to Boost installation")
-ENDIF()
-
-SET(CYCLES_OSL "" CACHE PATH "Path to OpenShadingLanguage installation")
-SET(CYCLES_CUDA "/usr/local/cuda" CACHE PATH "Path to CUDA installation")
-SET(CYCLES_OPENCL "" CACHE PATH "Path to OpenCL installation")
-SET(CYCLES_PARTIO "" CACHE PATH "Path to Partio installation")
-SET(CYCLES_GLEW "" CACHE PATH "Path to GLEW installation")
-
-# Install, todo: deduplicate install path code
-
-if(MSVC_IDE)
-       set(TARGETDIR ${EXECUTABLE_OUTPUT_PATH}/\${BUILD_TYPE})
-elseif(APPLE)
-       set(TARGETDIR ${EXECUTABLE_OUTPUT_PATH}/\${BUILD_TYPE})
-else()
-       set(TARGETDIR ${EXECUTABLE_OUTPUT_PATH})
-endif()
+set(CYCLES_INSTALL_PATH "scripts/addons/cycles")
+
+# External Libraries
+
+include(cmake/external_libs.cmake)
+
+# Build Flags
+
+set(GCC_WARNING_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-long-long")
+set(GCC_OPTIM_FLAGS "-ffast-math -fPIC -msse -msse2 -msse3 -mtune=native")
+
+if(APPLE)
+       set(CMAKE_CXX_FLAGS "${GCC_WARNING_FLAGS} ${GCC_OPTIM_FLAGS}")
+       set(RTTI_DISABLE_FLAGS "-fno-rtti -DBOOST_NO_RTTI -DBOOST_NO_TYPEID")
+endif(APPLE)
+
+if(WIN32)
+       set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Ox /Ot /arch:SSE2 -D_CRT_SECURE_NO_WARNINGS /EHsc /fp:fast")
+       set(RTTI_DISABLE_FLAGS "/GR- -DBOOST_NO_RTTI -DBOOST_NO_TYPEID")
+endif(WIN32)
 
 if(UNIX AND NOT APPLE)
-       if(WITH_INSTALL_PORTABLE)
-               set(TARGETDIR_VER ${TARGETDIR}/${BLENDER_VERSION})
-       else()
-               set(TARGETDIR_VER ${CMAKE_INSTALL_PREFIX}/share/blender/${BLENDER_VERSION})
-       endif()
-elseif(WIN32)
-       set(TARGETDIR_VER ${TARGETDIR}/${BLENDER_VERSION})
-elseif(APPLE)
-       set(TARGETDIR_VER ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION})
+       set(CMAKE_CXX_FLAGS "${GCC_WARNING_FLAGS} ${GCC_OPTIM_FLAGS}")
+       set(RTTI_DISABLE_FLAGS "-fno-rtti -DBOOST_NO_RTTI -DBOOST_NO_TYPEID")
+endif(UNIX AND NOT APPLE)
+
+# Definitions and Includes
+
+add_definitions(${BOOST_DEFINITIONS} ${OPENIMAGEIO_DEFINITIONS})
+
+add_definitions(-DCCL_NAMESPACE_BEGIN=namespace\ ccl\ {)
+add_definitions(-DCCL_NAMESPACE_END=})
+
+if(WITH_CYCLES_NETWORK)
+  add_definitions(-DWITH_NETWORK)
 endif()
 
-SET(CYCLES_INSTALL_PATH "${TARGETDIR_VER}/scripts/addons")
+if(WITH_CYCLES_MULTI)
+  add_definitions(-DWITH_MULTI)
+endif()
 
-# External Libraries
+if(WITH_CYCLES_CUDA)
+  add_definitions(-DWITH_CUDA)
+endif()
 
-INCLUDE(cmake/external_libs.cmake)
+if(WITH_CYCLES_OSL)
+  add_definitions(-DWITH_OSL)
+endif()
+
+if(WITH_CYCLES_PARTIO)
+  add_definitions(-DWITH_PARTIO)
+endif()
 
-# Platforms
+if(WITH_CYCLES_OPENCL)
+  add_definitions(-DWITH_OPENCL)
+  include_directories(${OPENCL_INCLUDE_DIR})
+
+endif()
 
-INCLUDE(cmake/platforms.cmake)
+include_directories(
+       ${BOOST_INCLUDE_DIR}
+       ${OPENIMAGEIO_INCLUDE_DIR}
+       ${OPENIMAGEIO_INCLUDE_DIR}/OpenImageIO)
 
 # Subdirectories
 
-IF(WITH_CYCLES_BLENDER)
-       ADD_SUBDIRECTORY(blender)
-ENDIF(WITH_CYCLES_BLENDER)
-
-ADD_SUBDIRECTORY(app)
-ADD_SUBDIRECTORY(bvh)
-ADD_SUBDIRECTORY(device)
-ADD_SUBDIRECTORY(doc)
-ADD_SUBDIRECTORY(kernel)
-ADD_SUBDIRECTORY(render)
-ADD_SUBDIRECTORY(subd)
-ADD_SUBDIRECTORY(util)
+if(WITH_CYCLES_BLENDER)
+       add_subdirectory(blender)
+endif(WITH_CYCLES_BLENDER)
+
+add_subdirectory(app)
+add_subdirectory(bvh)
+add_subdirectory(device)
+add_subdirectory(doc)
+add_subdirectory(kernel)
+add_subdirectory(render)
+add_subdirectory(subd)
+add_subdirectory(util)
 
index c250662aecf399bbd976b8a15001ba10fb6ae2f6..1d74c32ca289774efc1c28a2c886a57d9249f751 100644 (file)
@@ -1,5 +1,5 @@
 
-INCLUDE_DIRECTORIES(
+include_directories(
        .
        ../device
        ../kernel
@@ -9,51 +9,51 @@ INCLUDE_DIRECTORIES(
        ../render
        ../subd)
 
-SET(LIBRARIES
+set(LIBRARIES
        cycles_device
        cycles_kernel
        cycles_render
        cycles_bvh
        cycles_subd
        cycles_util
-       ${Boost_LIBRARIES}
+       ${BOOST_LIBRARIES}
        ${OPENGL_LIBRARIES}
        ${CYCLES_GLEW_LIBRARY}
        ${OPENIMAGEIO_LIBRARY})
 
-IF(WITH_CYCLES_TEST)
-       LIST(APPEND LIBRARIES ${GLUT_LIBRARIES})
-ENDIF()
-
-IF(WITH_CYCLES_OSL)
-       LIST(APPEND LIBRARIES cycles_kernel_osl ${OSL_LIBRARIES})
-ENDIF()
-
-IF(WITH_CYCLES_PARTIO)
-       LIST(APPEND LIBRARIES ${PARTIO_LIBRARIES})
-ENDIF()
-
-IF(WITH_CYCLES_OPENCL)
-       LIST(APPEND LIBRARIES ${OPENCL_LIBRARIES})
-ENDIF()
-
-IF(WITH_CYCLES_TEST)
-       ADD_EXECUTABLE(cycles_test cycles_test.cpp cycles_xml.cpp cycles_xml.h)
-       TARGET_LINK_LIBRARIES(cycles_test ${LIBRARIES})
-       INSTALL(TARGETS cycles_test DESTINATION ${CYCLES_INSTALL_PATH}/cycles)
-
-       IF(UNIX AND NOT APPLE)
-               SET_TARGET_PROPERTIES(cycles_test PROPERTIES INSTALL_RPATH $ORIGIN/lib)
-       ENDIF()
-ENDIF()
-
-IF(WITH_CYCLES_NETWORK)
-       ADD_EXECUTABLE(cycles_server cycles_server.cpp)
-       TARGET_LINK_LIBRARIES(cycles_server ${LIBRARIES})
-       INSTALL(TARGETS cycles_server DESTINATION ${CYCLES_INSTALL_PATH}/cycles)
-
-       IF(UNIX AND NOT APPLE)
-               SET_TARGET_PROPERTIES(cycles_server PROPERTIES INSTALL_RPATH $ORIGIN/lib)
-       ENDIF()
-ENDIF()
+link_directories(${OPENIMAGEIO_LIBPATH} ${BOOST_LIBPATH})
+
+if(WITH_CYCLES_TEST)
+       list(APPEND LIBRARIES ${GLUT_LIBRARIES})
+endif()
+
+if(WITH_CYCLES_OSL)
+       list(APPEND LIBRARIES cycles_kernel_osl ${OSL_LIBRARIES})
+endif()
+
+if(WITH_CYCLES_PARTIO)
+       list(APPEND LIBRARIES ${PARTIO_LIBRARIES})
+endif()
+
+if(WITH_CYCLES_OPENCL)
+       list(APPEND LIBRARIES ${OPENCL_LIBRARIES})
+endif()
+
+if(WITH_CYCLES_TEST)
+       add_executable(cycles_test cycles_test.cpp cycles_xml.cpp cycles_xml.h)
+       target_link_libraries(cycles_test ${LIBRARIES})
+
+       if(UNIX AND NOT APPLE)
+               set_target_properties(cycles_test PROPERTIES INSTALL_RPATH $ORIGIN/lib)
+       endif()
+endif()
+
+if(WITH_CYCLES_NETWORK)
+       add_executable(cycles_server cycles_server.cpp)
+       target_link_libraries(cycles_server ${LIBRARIES})
+
+       if(UNIX AND NOT APPLE)
+               set_target_properties(cycles_server PROPERTIES INSTALL_RPATH $ORIGIN/lib)
+       endif()
+endif()
 
index 8d7f2b1504b8ea58f287b4d8dac7305d3db3bc90..324d35d53600e617bbc27593dab92db94ddeb8ee 100644 (file)
@@ -1,19 +1,18 @@
 
-SET(sources
+set(sources
        blender_camera.cpp
        blender_mesh.cpp
        blender_object.cpp
        blender_python.cpp
        blender_session.cpp
        blender_shader.cpp
-       blender_sync.cpp)
+       blender_sync.cpp
 
-SET(headers
        blender_sync.h
        blender_session.h
        blender_util.h)
 
-SET(addonfiles
+set(addonfiles
        addon/__init__.py
        addon/engine.py 
        addon/enums.py
@@ -21,7 +20,7 @@ SET(addonfiles
        addon/ui.py
        addon/xml.py)
 
-INCLUDE_DIRECTORIES(
+include_directories(
        ../render
        ../device
        ../kernel
@@ -32,78 +31,30 @@ INCLUDE_DIRECTORIES(
        ${PYTHON_INCLUDE_DIRS}
        ${GLEW_INCLUDE_PATH})
 
-SET(LIBRARIES
+set(LIBRARIES
        cycles_render
        cycles_bvh
        cycles_device
        cycles_kernel
        cycles_util
-       cycles_subd
-       ${Boost_LIBRARIES}
-       ${OPENGL_LIBRARIES}
-       ${OPENIMAGEIO_LIBRARY}
-       ${GLUT_LIBRARIES}
-       ${CYCLES_GLEW_LIBRARY}
-       ${BLENDER_LIBRARIES})
+       cycles_subd)
 
-IF(WITH_CYCLES_OSL)
-       LIST(APPEND LIBRARIES cycles_kernel_osl ${OSL_LIBRARIES})
-ENDIF()
+if(WITH_CYCLES_OSL)
+       list(APPEND LIBRARIES cycles_kernel_osl ${OSL_LIBRARIES})
+endif()
 
-IF(WITH_CYCLES_PARTIO)
-       LIST(APPEND LIBRARIES ${PARTIO_LIBRARIES})
-ENDIF()
+if(WITH_CYCLES_PARTIO)
+       list(APPEND LIBRARIES ${PARTIO_LIBRARIES})
+endif()
 
-IF(WITH_CYCLES_OPENCL)
-       LIST(APPEND LIBRARIES ${OPENCL_LIBRARIES})
-ENDIF()
+if(WITH_CYCLES_OPENCL)
+       list(APPEND LIBRARIES ${OPENCL_LIBRARIES})
+endif()
 
-LINK_DIRECTORIES(${PYTHON_LIBPATH})
-SET(CMAKE_MODULE_LINKER_FLAGS ${PYTHON_MODULE_FLAGS})
+blender_add_lib(bf_intern_cycles "${sources}" "" "")
 
-ADD_LIBRARY(cycles_blender MODULE ${sources} ${headers})
-ADD_DEPENDENCIES(cycles_blender bf_rna)
+add_dependencies(bf_intern_cycles bf_rna)
+target_link_libraries(bf_intern_cycles ${LIBRARIES})
 
-IF(WIN32)
-       TARGET_LINK_LIBRARIES(cycles_blender ${PYTHON_LINKFLAGS})
-
-       FILE_LIST_SUFFIX(PYTHON_LIBRARIES_DEBUG "${PYTHON_LIBRARIES}" "_d")
-       TARGET_LINK_LIBRARIES_DEBUG(cycles_blender "${PYTHON_LIBRARIES_DEBUG}")
-       TARGET_LINK_LIBRARIES_OPTIMIZED(cycles_blender "${PYTHON_LIBRARIES}")
-       UNSET(PYTHON_LIBRARIES_DEBUG)
-
-       SET_TARGET_PROPERTIES(cycles_blender PROPERTIES PREFIX "lib")
-       SET_TARGET_PROPERTIES(cycles_blender PROPERTIES SUFFIX ".pyd")
-ENDIF()
-
-TARGET_LINK_LIBRARIES(cycles_blender ${LIBRARIES})
-
-INSTALL(FILES ${addonfiles} DESTINATION ${CYCLES_INSTALL_PATH}/cycles)
-INSTALL(TARGETS cycles_blender LIBRARY DESTINATION ${CYCLES_INSTALL_PATH}/cycles)
-
-# Install Dynamic Libraries
-
-IF(WIN32)
-       FILE(GLOB OIIO_DLLS "${CYCLES_OIIO}/bin/*.dll")
-       INSTALL(FILES ${OIIO_DLLS}
-               DESTINATION ${CYCLES_INSTALL_PATH}/cycles)
-ENDIF()
-
-IF(UNIX AND NOT APPLE)
-       # copy libraries to cycles lib directory
-       SET(install_libs
-               ${OPENIMAGEIO_LIBRARY}
-               ${Boost_LIBRARIES}
-               ${OSL_LIBRARIES}
-               ${PARTIO_LIBRARIES})
-       
-       LIST(REMOVE_ITEM install_libs optimized)
-       LIST(REMOVE_ITEM install_libs debug)
-
-       INSTALL(FILES ${install_libs}
-               DESTINATION ${CYCLES_INSTALL_PATH}/cycles/lib)
-       
-       # set path to look for dynamic libs
-       SET_TARGET_PROPERTIES(cycles_blender PROPERTIES INSTALL_RPATH $ORIGIN/lib)
-ENDIF()
+delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${addonfiles}" ${CYCLES_INSTALL_PATH})
 
index a78107735ebcf58af165703f0e625c228b72c766..6879efcb24eb2016137454128f24bcdc0e6a8c06 100644 (file)
 import bpy
 
 def init():
-       from cycles import libcycles_blender as lib
+       import libcycles_blender as lib
        import os.path
        lib.init(os.path.dirname(__file__))
 
 def create(engine, data, scene, region = 0, v3d = 0, rv3d = 0):
-       from cycles import libcycles_blender as lib
+       import libcycles_blender as lib
 
        data = data.as_pointer()
        scene = scene.as_pointer()
@@ -40,20 +40,20 @@ def create(engine, data, scene, region = 0, v3d = 0, rv3d = 0):
 def free(engine):
        if "session" in dir(engine):
                if engine.session:
-                       from cycles import libcycles_blender as lib
+                       import libcycles_blender as lib
                        lib.free(engine.session)
                del engine.session
 
 def render(engine):
-       from cycles import libcycles_blender as lib
+       import libcycles_blender as lib
        lib.render(engine.session)
 
 def update(engine, data, scene):
-       from cycles import libcycles_blender as lib
+       import libcycles_blender as lib
        lib.sync(engine.session)
 
 def draw(engine, region, v3d, rv3d):
-       from cycles import libcycles_blender as lib
+       import libcycles_blender as lib
        v3d = v3d.as_pointer()
        rv3d = rv3d.as_pointer()
 
@@ -95,10 +95,10 @@ def draw(engine, region, v3d, rv3d):
                blf.draw(fontid, substatus)
 
 def available_devices():
-       from cycles import libcycles_blender as lib
+       import libcycles_blender as lib
        return lib.available_devices()
 
 def with_osl():
-       from cycles import libcycles_blender as lib
+       import libcycles_blender as lib
        return lib.with_osl()
 
index 00d16edbf741f149da95a3658cf49680d504abdf..1e72e5f15f1dd106dddfe09499d103484b30fcc5 100644 (file)
@@ -224,7 +224,9 @@ static struct PyModuleDef module = {
 
 CCL_NAMESPACE_END
 
-PyMODINIT_FUNC PyInit_libcycles_blender() 
+extern "C" PyObject *CYCLES_initPython();
+
+PyObject *CYCLES_initPython()
 {
        return PyModule_Create(&ccl::module);
 }
index 9ea3bc77461d13ab4eb6c593149e0430348acdcd..b35c20b7a3840f22faca5b9fa77afc2650b48818 100644 (file)
@@ -1,18 +1,18 @@
 
-INCLUDE_DIRECTORIES(. ../kernel ../kernel/svm ../render ../util ../device)
+include_directories(. ../kernel ../kernel/svm ../render ../util ../device)
 
-SET(sources
+set(sources
        bvh.cpp
        bvh_build.cpp
        bvh_node.cpp
        bvh_sort.cpp)
 
-SET(headers
+set(headers
        bvh.h
        bvh_build.h
        bvh_node.h
        bvh_params.h
        bvh_sort.h)
 
-ADD_LIBRARY(cycles_bvh ${sources} ${headers})
+add_library(cycles_bvh ${sources} ${headers})
 
index 6da71c8235fb4eb29cbfd4b7851a3a6f642d2dc0..01f3cc1af0df39100e07462bc6c8b824132b69f8 100644 (file)
-###########################################################################
-# Windows and Darwin lib directory libraries
-
-IF(WIN32)
-       IF(CMAKE_CL_64)
-               SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/win64)
-       ELSE()
-               SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/windows)
-       ENDIF()
-ENDIF()
-
-IF(APPLE)
-       SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-9.x.universal)
-       SET(OIIO_STATIC ON)
-ENDIF()
-
-IF(LIBDIR)
-       SET(CYCLES_OIIO ${LIBDIR}/openimageio)
-       SET(CYCLES_BOOST ${LIBDIR}/boost)
-       SET(Boost_USE_STATIC_LIBS ON)
-ENDIF()
-
-###########################################################################
-# Boost setup
-
-SET(BOOST_ROOT ${CYCLES_BOOST})
-
-SET(Boost_ADDITIONAL_VERSIONS "1.45" "1.44" 
-                               "1.43" "1.43.0" "1.42" "1.42.0" 
-                               "1.41" "1.41.0" "1.40" "1.40.0"
-                               "1.39" "1.39.0" "1.38" "1.38.0"
-                               "1.37" "1.37.0" "1.34.1" "1_34_1")
-
-SET(Boost_USE_MULTITHREADED ON)
-
-FIND_PACKAGE(Boost 1.34 REQUIRED COMPONENTS filesystem regex system thread)
-
-MESSAGE(STATUS "Boost found ${Boost_FOUND}")
-MESSAGE(STATUS "Boost version ${Boost_VERSION}")
-MESSAGE(STATUS "Boost include dirs ${Boost_INCLUDE_DIRS}")
-MESSAGE(STATUS "Boost library dirs ${Boost_LIBRARY_DIRS}")
-MESSAGE(STATUS "Boost libraries ${Boost_LIBRARIES}")
-
-INCLUDE_DIRECTORIES("${Boost_INCLUDE_DIRS}")
-LINK_DIRECTORIES("${Boost_LIBRARY_DIRS}")
-
-ADD_DEFINITIONS(-DBOOST_ALL_NO_LIB)
-
-IF(WITH_CYCLES_NETWORK)
-       ADD_DEFINITIONS(-DWITH_NETWORK)
-ENDIF()
-
-IF(WITH_CYCLES_MULTI)
-       ADD_DEFINITIONS(-DWITH_MULTI)
-ENDIF()
-
-###########################################################################
-# OpenImageIO
-
-FIND_LIBRARY(OPENIMAGEIO_LIBRARY NAMES OpenImageIO PATHS ${CYCLES_OIIO}/lib ${CYCLES_OIIO}/dist)
-FIND_PATH(OPENIMAGEIO_INCLUDES OpenImageIO/imageio.h PATHS ${CYCLES_OIIO}/include ${CYCLES_OIIO}/dist)
-FIND_PROGRAM(OPENIMAGEIO_IDIFF NAMES idiff PATHS ${CYCLES_OIIO}/bin ${CYCLES_OIIO}/dist)
-
-IF(OPENIMAGEIO_INCLUDES AND OPENIMAGEIO_LIBRARY)
-       SET(OPENIMAGEIO_FOUND TRUE)
-       MESSAGE(STATUS "OpenImageIO includes = ${OPENIMAGEIO_INCLUDES}")
-       MESSAGE(STATUS "OpenImageIO library = ${OPENIMAGEIO_LIBRARY}")
-ELSE()
-       MESSAGE(STATUS "OpenImageIO not found")
-ENDIF()
-
-ADD_DEFINITIONS(-DWITH_OIIO)
-INCLUDE_DIRECTORIES(${OPENIMAGEIO_INCLUDES} ${OPENIMAGEIO_INCLUDES}/OpenImageIO)
-
-IF(OIIO_STATIC)
-       ADD_DEFINITIONS(-DOIIO_STATIC_BUILD)
-
-       SET(OPENIMAGEIO_LIBRARY
-               ${OPENIMAGEIO_LIBRARY}
-               ${PNG_LIBRARIES}
-               ${JPEG_LIBRARIES}
-               ${TIFF_LIBRARY}
-               ${OPENEXR_LIBRARIES}
-               ${ZLIB_LIBRARIES})
-
-       LINK_DIRECTORIES(
-               ${JPEG_LIBPATH}
-               ${PNG_LIBPATH}
-               ${TIFF_LIBPATH}
-               ${OPENEXR_LIBPATH}
-               ${ZLIB_LIBPATH})
-ENDIF()
 
 ###########################################################################
 # GLUT
 
-IF(WITH_CYCLES_TEST)
-       SET(GLUT_ROOT_PATH ${CYCLES_GLUT})
+if(WITH_CYCLES_TEST)
+       set(GLUT_ROOT_PATH ${CYCLES_GLUT})
 
-       FIND_PACKAGE(GLUT)
-       MESSAGE(STATUS "GLUT_FOUND=${GLUT_FOUND}")
+       find_package(GLUT)
+       message(STATUS "GLUT_FOUND=${GLUT_FOUND}")
 
-       INCLUDE_DIRECTORIES(${GLUT_INCLUDE_DIR})
-ENDIF()
+       include_directories(${GLUT_INCLUDE_DIR})
+endif()
 
-IF(WITH_BUILTIN_GLEW)
-       SET(CYCLES_GLEW_LIBRARY extern_glew)
-ELSE()
-       SET(CYCLES_GLEW_LIBRARY ${GLEW_LIBRARY})
-ENDIF()
+if(WITH_BUILTIN_GLEW)
+       set(CYCLES_GLEW_LIBRARY extern_glew)
+else()
+       set(CYCLES_GLEW_LIBRARY ${GLEW_LIBRARY})
+endif()
 
 ###########################################################################
 # OpenShadingLanguage
 
-IF(WITH_CYCLES_OSL)
+if(WITH_CYCLES_OSL)
+
+       set(CYCLES_OSL "" CACHE PATH "Path to OpenShadingLanguage installation")
 
-       MESSAGE(STATUS "CYCLES_OSL = ${CYCLES_OSL}")
+       message(STATUS "CYCLES_OSL = ${CYCLES_OSL}")
 
-       FIND_LIBRARY(OSL_LIBRARIES NAMES oslexec oslcomp oslquery PATHS ${CYCLES_OSL}/lib ${CYCLES_OSL}/dist)
-       FIND_PATH(OSL_INCLUDES OSL/oslclosure.h PATHS ${CYCLES_OSL}/include ${CYCLES_OSL}/dist)
-       FIND_PROGRAM(OSL_COMPILER NAMES oslc PATHS ${CYCLES_OSL}/bin ${CYCLES_OSL}/dist)
+       find_library(OSL_LIBRARIES NAMES oslexec oslcomp oslquery PATHS ${CYCLES_OSL}/lib ${CYCLES_OSL}/dist)
+       find_path(OSL_INCLUDES OSL/oslclosure.h PATHS ${CYCLES_OSL}/include ${CYCLES_OSL}/dist)
+       find_program(OSL_COMPILER NAMES oslc PATHS ${CYCLES_OSL}/bin ${CYCLES_OSL}/dist)
 
-       IF(OSL_INCLUDES AND OSL_LIBRARIES AND OSL_COMPILER)
-               SET(OSL_FOUND TRUE)
-               MESSAGE(STATUS "OSL includes = ${OSL_INCLUDES}")
-               MESSAGE(STATUS "OSL library = ${OSL_LIBRARIES}")
-               MESSAGE(STATUS "OSL compiler = ${OSL_COMPILER}")
-       ELSE()
-               MESSAGE(STATUS "OSL not found")
-       ENDIF()
+       if(OSL_INCLUDES AND OSL_LIBRARIES AND OSL_COMPILER)
+               set(OSL_FOUND TRUE)
+               message(STATUS "OSL includes = ${OSL_INCLUDES}")
+               message(STATUS "OSL library = ${OSL_LIBRARIES}")
+               message(STATUS "OSL compiler = ${OSL_COMPILER}")
+       else()
+               message(STATUS "OSL not found")
+       endif()
 
-       ADD_DEFINITIONS(-DWITH_OSL)
-       INCLUDE_DIRECTORIES(${OSL_INCLUDES} ${OSL_INCLUDES}/OSL ${OSL_INCLUDES}/../../../src/liboslexec)
+       include_directories(${OSL_INCLUDES} ${OSL_INCLUDES}/OSL ${OSL_INCLUDES}/../../../src/liboslexec)
 
-ENDIF()
+endif()
 
 ###########################################################################
 # Partio
 
-IF(WITH_CYCLES_PARTIO)
+if(WITH_CYCLES_PARTIO)
 
-       MESSAGE(STATUS "CYCLES_PARTIO = ${CYCLES_PARTIO}")
+       set(CYCLES_PARTIO "" CACHE PATH "Path to Partio installation")
 
-       FIND_LIBRARY(PARTIO_LIBRARIES NAMES partio PATHS ${CYCLES_PARTIO}/lib)
-       FIND_PATH(PARTIO_INCLUDES Partio.h ${CYCLES_PARTIO}/include)
+       message(STATUS "CYCLES_PARTIO = ${CYCLES_PARTIO}")
 
-       FIND_PACKAGE(ZLIB)
+       find_library(PARTIO_LIBRARIES NAMES partio PATHS ${CYCLES_PARTIO}/lib)
+       find_path(PARTIO_INCLUDES Partio.h ${CYCLES_PARTIO}/include)
 
-       IF(PARTIO_INCLUDES AND PARTIO_LIBRARIES AND ZLIB_LIBRARIES)
-               LIST(APPEND PARTIO_LIBRARIES ${ZLIB_LIBRARIES})
-               SET(PARTIO_FOUND TRUE)
-               MESSAGE(STATUS "PARTIO includes = ${PARTIO_INCLUDES}")
-               MESSAGE(STATUS "PARTIO library = ${PARTIO_LIBRARIES}")
-       ELSE()
-               MESSAGE(STATUS "PARTIO not found")
-       ENDIF()
+       find_package(ZLIB)
 
-       ADD_DEFINITIONS(-DWITH_PARTIO)
-       INCLUDE_DIRECTORIES(${PARTIO_INCLUDES})
+       if(PARTIO_INCLUDES AND PARTIO_LIBRARIES AND ZLIB_LIBRARIES)
+               list(APPEND PARTIO_LIBRARIES ${ZLIB_LIBRARIES})
+               set(PARTIO_FOUND TRUE)
+               message(STATUS "PARTIO includes = ${PARTIO_INCLUDES}")
+               message(STATUS "PARTIO library = ${PARTIO_LIBRARIES}")
+       else()
+               message(STATUS "PARTIO not found")
+       endif()
 
-ENDIF()
+       include_directories(${PARTIO_INCLUDES})
+
+endif()
 
 ###########################################################################
 # Blender
 
-IF(WITH_CYCLES_BLENDER)
-       # FIND_PATH(BLENDER_INCLUDE_DIRS RNA_blender.h PATHS ${CMAKE_BINARY_DIR}/include)
-       SET(BLENDER_INCLUDE_DIRS
+if(WITH_CYCLES_BLENDER)
+
+       set(BLENDER_INCLUDE_DIRS
                ${CMAKE_SOURCE_DIR}/intern/guardedalloc
                ${CMAKE_SOURCE_DIR}/source/blender/makesdna
                ${CMAKE_SOURCE_DIR}/source/blender/makesrna
                ${CMAKE_SOURCE_DIR}/source/blender/blenloader
                ${CMAKE_BINARY_DIR}/source/blender/makesrna/intern)
-       IF(WIN32)
-               SET(BLENDER_LIBRARIES ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/blender.lib)
-       ENDIF()
 
        ADD_DEFINITIONS(-DBLENDER_PLUGIN)
-ENDIF()
+endif()
 
 ###########################################################################
 # CUDA
 
-IF(WITH_CYCLES_CUDA)
+if(WITH_CYCLES_CUDA)
+
+       set(CYCLES_CUDA "/usr/local/cuda" CACHE PATH "Path to CUDA installation")
+       set(CYCLES_CUDA_ARCH sm_10 sm_11 sm_12 sm_13 sm_20 sm_21 CACHE STRING "CUDA architectures to build for")
+       set(CYCLES_CUDA_MAXREG 24 CACHE STRING "CUDA maximum number of register to use")
 
-       FIND_LIBRARY(CUDA_LIBRARIES NAMES cuda PATHS ${CYCLES_CUDA}/lib ${CYCLES_CUDA}/lib/Win32 NO_DEFAULT_PATH)
-       FIND_PATH(CUDA_INCLUDES cuda.h ${CYCLES_CUDA}/include NO_DEFAULT_PATH)
-       FIND_PROGRAM(CUDA_NVCC NAMES nvcc PATHS ${CYCLES_CUDA}/bin NO_DEFAULT_PATH)
+       find_library(CUDA_LIBRARIES NAMES cuda PATHS ${CYCLES_CUDA}/lib ${CYCLES_CUDA}/lib/Win32 NO_DEFAULT_PATH)
+       find_path(CUDA_INCLUDES cuda.h ${CYCLES_CUDA}/include NO_DEFAULT_PATH)
+       find_program(CUDA_NVCC NAMES nvcc PATHS ${CYCLES_CUDA}/bin NO_DEFAULT_PATH)
 
-       IF(CUDA_INCLUDES AND CUDA_LIBRARIES AND CUDA_NVCC)
-               MESSAGE(STATUS "CUDA includes = ${CUDA_INCLUDES}")
-               MESSAGE(STATUS "CUDA library = ${CUDA_LIBRARIES}")
-               MESSAGE(STATUS "CUDA nvcc = ${CUDA_NVCC}")
-       ELSE()
-               MESSAGE(STATUS "CUDA not found")
-       ENDIF()
+       if(CUDA_INCLUDES AND CUDA_LIBRARIES AND CUDA_NVCC)
+               message(STATUS "CUDA includes = ${CUDA_INCLUDES}")
+               message(STATUS "CUDA library = ${CUDA_LIBRARIES}")
+               message(STATUS "CUDA nvcc = ${CUDA_NVCC}")
+       else()
+               message(STATUS "CUDA not found")
+       endif()
 
-       ADD_DEFINITIONS(-DWITH_CUDA)
-       INCLUDE_DIRECTORIES(${CUDA_INCLUDES})
+       include_directories(${CUDA_INCLUDES})
 
-ENDIF()
+endif()
 
 ###########################################################################
 # OpenCL
 
-IF(WITH_CYCLES_OPENCL)
-
-       IF(APPLE)
-               SET(OPENCL_INCLUDES "/System/Library/Frameworks/OpenCL.framework/Headers")
-               SET(OPENCL_LIBRARIES "-framework OpenCL")
-       ENDIF()
-
-       IF(WIN32)
-               SET(OPENCL_INCLUDES "")
-               SET(OPENCL_LIBRARIES "OpenCL")
-       ENDIF()
+if(WITH_CYCLES_OPENCL)
 
-       IF(UNIX AND NOT APPLE)
-               SET(OPENCL_INCLUDES ${CYCLES_OPENCL})
-               SET(OPENCL_LIBRARIES "OpenCL")
-       ENDIF()
+       if(APPLE)
+               set(OPENCL_INCLUDE_DIR "/System/Library/Frameworks/OpenCL.framework/Headers")
+               set(OPENCL_LIBRARIES "-framework OpenCL")
+       endif()
 
-       ADD_DEFINITIONS(-DWITH_OPENCL)
-       INCLUDE_DIRECTORIES(${OPENCL_INCLUDES})
+       if(WIN32)
+               set(OPENCL_INCLUDE_DIR "")
+               set(OPENCL_LIBRARIES "OpenCL")
+       endif()
 
-ENDIF()
+       if(UNIX AND NOT APPLE)
+               set(OPENCL_INCLUDE_DIR ${CYCLES_OPENCL})
+               set(OPENCL_LIBRARIES "OpenCL")
+       endif()
+endif()
 
diff --git a/intern/cycles/cmake/platforms.cmake b/intern/cycles/cmake/platforms.cmake
deleted file mode 100644 (file)
index e4364d8..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-
-# Platform specific build flags
-
-SET(GCC_WARNING_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-long-long")
-SET(GCC_OPTIM_FLAGS "-ffast-math -fPIC -msse -msse2 -msse3 -mtune=native")
-
-IF(APPLE)
-       SET(CMAKE_CXX_FLAGS "${GCC_WARNING_FLAGS} ${GCC_OPTIM_FLAGS}")
-       SET(RTTI_DISABLE_FLAGS "-fno-rtti -DBOOST_NO_RTTI -DBOOST_NO_TYPEID")
-       SET(PYTHON_MODULE_FLAGS "-undefined dynamic_lookup")
-ENDIF(APPLE)
-
-IF(WIN32)
-       SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Ox /Ot /arch:SSE2 -D_CRT_SECURE_NO_WARNINGS /EHsc /fp:fast")
-       SET(RTTI_DISABLE_FLAGS "/GR- -DBOOST_NO_RTTI -DBOOST_NO_TYPEID")
-       SET(PYTHON_MODULE_FLAGS "-DLL")
-ENDIF(WIN32)
-
-IF(UNIX AND NOT APPLE)
-       SET(CMAKE_CXX_FLAGS "${GCC_WARNING_FLAGS} ${GCC_OPTIM_FLAGS}")
-       SET(RTTI_DISABLE_FLAGS "-fno-rtti -DBOOST_NO_RTTI -DBOOST_NO_TYPEID")
-       SET(PYTHON_MODULE_FLAGS "-fPIC")
-ENDIF(UNIX AND NOT APPLE)
-
-ADD_DEFINITIONS(-DCCL_NAMESPACE_BEGIN=namespace\ ccl\ {)
-ADD_DEFINITIONS(-DCCL_NAMESPACE_END=})
-
index 712351b9558d7f123e7e9d082f6926e2eea7767e..559414387201475e4caef1cdb4301c29033d2186 100644 (file)
@@ -1,5 +1,5 @@
 
-INCLUDE_DIRECTORIES(
+include_directories(
        .
        ../kernel
        ../kernel/svm
@@ -9,7 +9,7 @@ INCLUDE_DIRECTORIES(
        ${OPENGL_INCLUDE_DIR}
        ${GLEW_INCLUDE_PATH})
 
-SET(sources
+set(sources
        device.cpp
        device_cpu.cpp
        device_cuda.cpp
@@ -17,10 +17,10 @@ SET(sources
        device_network.cpp
        device_opencl.cpp)
 
-SET(headers
+set(headers
        device.h
        device_intern.h
        device_network.h)
 
-ADD_LIBRARY(cycles_device ${sources} ${headers})
+add_library(cycles_device ${sources} ${headers})
 
index 584bcc8079c5a92a9141a2c0bca6408c2f573bb2..4ae0d12a06045813d8f145d08b21f6dc0fb935c4 100644 (file)
@@ -1,3 +1,3 @@
 
-INSTALL(DIRECTORY license DESTINATION ${CYCLES_INSTALL_PATH}/cycles PATTERN ".svn" EXCLUDE)
+add_subdirectory(license)
 
diff --git a/intern/cycles/doc/license/CMakeLists.txt b/intern/cycles/doc/license/CMakeLists.txt
new file mode 100644 (file)
index 0000000..14049d4
--- /dev/null
@@ -0,0 +1,13 @@
+
+set(licenses
+       Apache_2.0.txt
+       Blender.txt
+       GPL.txt
+       ILM.txt
+       NVidia.txt
+       OSL.txt
+       Sobol.txt
+       readme.txt)
+
+delayed_install(${CMAKE_CURRENT_SOURCE_DIR}  "${licenses}" ${CYCLES_INSTALL_PATH}/license)
+
index b6d758369cced78f64e2ec838f0fd9b553386810..7c77bf7ff82c31074d89bf2b0c0313f46e3764b2 100644 (file)
@@ -1,10 +1,10 @@
 
-SET(sources
+set(sources
        kernel.cpp
        kernel.cl
        kernel.cu)
 
-SET(headers
+set(headers
        kernel.h
        kernel_bvh.h
        kernel_camera.h
@@ -29,7 +29,7 @@ SET(headers
        kernel_triangle.h
        kernel_types.h)
 
-SET(svm_headers
+set(svm_headers
        svm/bsdf.h
        svm/bsdf_ashikhmin_velvet.h
        svm/bsdf_diffuse.h
@@ -72,7 +72,7 @@ SET(svm_headers
        svm/volume.h
        )
 
-SET(util_headers
+set(util_headers
        ../util/util_color.h
        ../util/util_math.h
        ../util/util_transform.h
@@ -80,60 +80,61 @@ SET(util_headers
 
 # CUDA module
 
-IF("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
-       SET(CUDA_BITS 64)
-ELSE()
-       SET(CUDA_BITS 32)
-ENDIF()
+if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
+       set(CUDA_BITS 64)
+else()
+       set(CUDA_BITS 32)
+endif()
 
-IF(WITH_CYCLES_CUDA)
-       SET(cuda_sources kernel.cu ${headers} ${svm_headers})
-       SET(cuda_cubins)
+if(WITH_CYCLES_CUDA)
+       set(cuda_sources kernel.cu ${headers} ${svm_headers})
+       set(cuda_cubins)
 
-       FOREACH(arch ${CYCLES_CUDA_ARCH})
-               SET(cuda_cubin kernel_${arch}.cubin)
+       foreach(arch ${CYCLES_CUDA_ARCH})
+               set(cuda_cubin kernel_${arch}.cubin)
 
-               ADD_CUSTOM_COMMAND(
+               add_custom_command(
                        OUTPUT ${cuda_cubin}
                        COMMAND ${CUDA_NVCC} -arch=${arch} -m${CUDA_BITS} --cubin ${CMAKE_CURRENT_SOURCE_DIR}/kernel.cu --use_fast_math -o ${CMAKE_CURRENT_BINARY_DIR}/${cuda_cubin} --ptxas-options="-v" --maxrregcount=${CYCLES_CUDA_MAXREG} --opencc-options -OPT:Olimit=0 -I${CMAKE_CURRENT_SOURCE_DIR}/../util -I${CMAKE_CURRENT_SOURCE_DIR}/svm -DCCL_NAMESPACE_BEGIN= -DCCL_NAMESPACE_END= -DNVCC
                        DEPENDS ${cuda_sources})
 
-               INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${cuda_cubin} DESTINATION ${CYCLES_INSTALL_PATH}/cycles/lib)
-               LIST(APPEND cuda_cubins ${cuda_cubin})
-       ENDFOREACH()
+               delayed_install("${CMAKE_CURRENT_BINARY_DIR}" "${cuda_cubin}" ${CYCLES_INSTALL_PATH}/lib)
+               list(APPEND cuda_cubins ${cuda_cubin})
+       endforeach()
 
-       ADD_CUSTOM_TARGET(cycles_kernel_cuda ALL DEPENDS ${cuda_cubins})
-ENDIF()
+       add_custom_target(cycles_kernel_cuda ALL DEPENDS ${cuda_cubins})
+endif()
 
 # OSL module
 
-IF(WITH_CYCLES_OSL)
-       ADD_SUBDIRECTORY(osl)
-ENDIF()
+if(WITH_CYCLES_OSL)
+       add_subdirectory(osl)
+endif()
 
 # CPU module
 
-INCLUDE_DIRECTORIES(. ../util osl svm)
+include_directories(. ../util osl svm)
 
-ADD_LIBRARY(cycles_kernel ${sources} ${headers} ${svm_headers})
+add_library(cycles_kernel ${sources} ${headers} ${svm_headers})
 
-IF(WITH_CYCLES_CUDA)
-       ADD_DEPENDENCIES(cycles_kernel cycles_kernel_cuda)
-ENDIF()
+if(WITH_CYCLES_CUDA)
+       add_dependencies(cycles_kernel cycles_kernel_cuda)
+endif()
 
 # OPENCL kernel
 
-IF(WITH_CYCLES_OPENCL)
-       #SET(kernel_preprocessed ${CMAKE_CURRENT_BINARY_DIR}/kernel_preprocessed.cl)
-       #ADD_CUSTOM_COMMAND(
+if(WITH_CYCLES_OPENCL)
+       #set(kernel_preprocessed ${CMAKE_CURRENT_BINARY_DIR}/kernel_preprocessed.cl)
+       #add_custom_command(
        #       OUTPUT ${kernel_preprocessed}
        #       COMMAND gcc -x c++ -E ${CMAKE_CURRENT_SOURCE_DIR}/kernel.cl -I ${CMAKE_CURRENT_SOURCE_DIR}/../util/ -DCCL_NAMESPACE_BEGIN= -DCCL_NAMESPACE_END= -DWITH_OPENCL -o ${kernel_preprocessed}
        #       DEPENDS ${kernel_sources} ${util_headers})
-       #ADD_CUSTOM_TARGET(cycles_kernel_preprocess ALL DEPENDS ${kernel_preprocessed})
-       #INSTALL(FILES ${kernel_preprocessed} DESTINATION ${CYCLES_INSTALL_PATH}/cycles/kernel)
-
-       INSTALL(FILES kernel.cl ${headers} DESTINATION ${CYCLES_INSTALL_PATH}/cycles/kernel)
-       INSTALL(FILES ${svm_headers} DESTINATION ${CYCLES_INSTALL_PATH}/cycles/kernel/svm)
-       INSTALL(FILES ${util_headers} DESTINATION ${CYCLES_INSTALL_PATH}/cycles/kernel)
-ENDIF()
+       #add_custom_target(cycles_kernel_preprocess ALL DEPENDS ${kernel_preprocessed})
+       #delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${kernel_preprocessed}" ${CYCLES_INSTALL_PATH}/kernel)
+
+       delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel.cl" ${CYCLES_INSTALL_PATH}/kernel)
+       delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${headers}" ${CYCLES_INSTALL_PATH}/kernel)
+       delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${svm_headers}" ${CYCLES_INSTALL_PATH}/kernel/svm)
+       delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${util_headers}" ${CYCLES_INSTALL_PATH}/kernel)
+endif()
 
index 31a162bdd0ef52956aca230de9b53e2212af4a72..4a3a6f6798aa524078694cff460713e97979bd5c 100644 (file)
@@ -1,7 +1,7 @@
 
-INCLUDE_DIRECTORIES(. ../ ../svm ../../render ../../util ../../device)
+include_directories(. ../ ../svm ../../render ../../util ../../device)
 
-SET(sources
+set(sources
        background.cpp
        bsdf_ashikhmin_velvet.cpp
        bsdf_diffuse.cpp
@@ -19,15 +19,15 @@ SET(sources
        osl_shader.cpp
        vol_subsurface.cpp)
 
-SET(headers
+set(headers
        osl_closures.h
        osl_globals.h
        osl_services.h
        osl_shader.h)
 
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${RTTI_DISABLE_FLAGS}")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${RTTI_DISABLE_FLAGS}")
 
-ADD_LIBRARY(cycles_kernel_osl ${sources} ${headers})
+add_library(cycles_kernel_osl ${sources} ${headers})
 
-ADD_SUBDIRECTORY(nodes)
+add_subdirectory(nodes)
 
index 56e8ba0b5b688dcce30d597be1075b964d2e0670..365cc42ad6be931f2683e869cb388911d472f6f2 100644 (file)
@@ -1,7 +1,7 @@
 
 # OSL node shaders
 
-SET(osl_sources
+set(osl_sources
        node_add_closure.osl
        node_attribute.osl
        node_background.osl
@@ -46,24 +46,24 @@ SET(osl_sources
        node_ward_bsdf.osl
        node_wood_texture.osl)
 
-SET(osl_headers
+set(osl_headers
        node_texture.h
        stdosl.h)
 
-SET(oso_sources)
+set(oso_sources)
 
-FOREACH(_file ${osl_sources})
-       SET(osl_file ${CMAKE_CURRENT_SOURCE_DIR}/${_file})
-       STRING(REPLACE ".osl" ".oso" oso_file ${osl_file})
-       STRING(REPLACE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} oso_file ${oso_file})
-       ADD_CUSTOM_COMMAND(
+foreach(_file ${osl_sources})
+       set(osl_file ${CMAKE_CURRENT_SOURCE_DIR}/${_file})
+       string(REPLACE ".osl" ".oso" oso_file ${osl_file})
+       string(REPLACE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} oso_file ${oso_file})
+       add_custom_command(
                OUTPUT ${oso_file} 
                COMMAND ${OSL_COMPILER} -O2 ${osl_file}
                DEPENDS ${osl_file} ${osl_headers})
-       LIST(APPEND oso_sources ${oso_file})
-ENDFOREACH()
+       list(APPEND oso_sources ${oso_file})
+endforeach()
 
-ADD_CUSTOM_TARGET(shader ALL DEPENDS ${oso_sources} ${osl_headers})
+add_custom_target(shader ALL DEPENDS ${oso_sources} ${osl_headers})
 
-INSTALL(FILES ${oso_sources} DESTINATION ${CYCLES_INSTALL_PATH}/cycles/shader)
+delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${oso_sources}" ${CYCLES_INSTALL_PATH}/shader)
 
index 9a0583c48aa7fc7e69dd15498cf2ec2cb8b4da36..c3d5ae1ea05d6e11d620f9efc32899e076943dd1 100644 (file)
@@ -1,5 +1,5 @@
 
-INCLUDE_DIRECTORIES(
+include_directories(
        .
        ../device
        ../kernel
@@ -9,7 +9,7 @@ INCLUDE_DIRECTORIES(
        ../util
        ${GLEW_INCLUDE_PATH})
 
-SET(sources
+set(sources
        attribute.cpp
        background.cpp
        buffers.cpp
@@ -33,7 +33,7 @@ SET(sources
        svm.cpp
        tile.cpp)
 
-SET(headers
+set(headers
        attribute.h
        background.h
        buffers.h
@@ -56,7 +56,7 @@ SET(headers
        svm.h
        tile.h)
 
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${RTTI_DISABLE_FLAGS}")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${RTTI_DISABLE_FLAGS}")
 
-ADD_LIBRARY(cycles_render ${sources} ${headers})
+add_library(cycles_render ${sources} ${headers})
 
index 5357df4fab7234414b51551e0838bc3d9ac4306c..79ed73134f245b912cf23bbbbf8f2384d8bd18c3 100644 (file)
@@ -1,7 +1,7 @@
 
-INCLUDE_DIRECTORIES(. ../util ../kernel ../kernel/svm ../render)
+include_directories(. ../util ../kernel ../kernel/svm ../render)
 
-SET(sources
+set(sources
        subd_build.cpp
        subd_dice.cpp
        subd_mesh.cpp
@@ -10,7 +10,7 @@ SET(sources
        subd_split.cpp
        subd_stencil.cpp)
 
-SET(headers
+set(headers
        subd_build.h
        subd_dice.h
        subd_edge.h
@@ -22,5 +22,5 @@ SET(headers
        subd_stencil.h
        subd_vert.h)
 
-ADD_LIBRARY(cycles_subd ${sources} ${headers})
+add_library(cycles_subd ${sources} ${headers})
 
index 380383e3146183444c0e312b04effc2a57ab0296..4db90adc9e6ab9c066e165e9485f9d958aa82a39 100644 (file)
@@ -1,10 +1,10 @@
 
-INCLUDE_DIRECTORIES(
+include_directories(
        .
        ${GLEW_INCLUDE_PATH}
        ${OPENGL_INCLUDE_DIR})
 
-SET(sources
+set(sources
        util_cache.cpp
        util_cuda.cpp
        util_dynlib.cpp
@@ -15,11 +15,11 @@ SET(sources
        util_time.cpp
        util_transform.cpp)
 
-IF(WITH_CYCLES_TEST)
-       LIST(APPEND sources util_view.cpp)
-ENDIF()
+if(WITH_CYCLES_TEST)
+       list(APPEND sources util_view.cpp)
+endif()
 
-SET(headers
+set(headers
        util_algorithm.h
        util_args.h
        util_boundbox.h
@@ -49,5 +49,5 @@ SET(headers
        util_vector.h
        util_xml.h)
 
-ADD_LIBRARY(cycles_util ${sources} ${headers})
+add_library(cycles_util ${sources} ${headers})
 
index 1bbf6e3b0dc43d402b1f9dde05fd9279c8760e1b..577fdce0ff36600005711d6a01a1b4cb2b94ca8f 100644 (file)
@@ -275,6 +275,7 @@ void ED_area_overdraw(bContext *C)
                                if(az->type==AZONE_AREA) {
                                        area_draw_azone(az->x1, az->y1, az->x2, az->y2);
                                } else if(az->type==AZONE_REGION) {
+                                       if(0) {
                                        
                                        if(az->ar) {
                                                /* only display tab or icons when the region is hidden */
@@ -288,6 +289,8 @@ void ED_area_overdraw(bContext *C)
                                                                region_draw_azone_icon(az);
                                                }
                                        }
+
+                                       }
                                }
                                
                                az->do_draw= 0;
index 18b5eff5c7358e47fcdbe74db49e2dda00a165ce..de9fb323451cbc700d29eeec237ecbac3a78972b 100644 (file)
@@ -61,6 +61,7 @@ set(SRC
        intern/md5.c
        intern/metadata.c
        intern/module.c
+       intern/openimageio.cpp
        intern/png.c
        intern/radiance_hdr.c
        intern/readimage.c
@@ -165,4 +166,11 @@ if(WITH_IMAGE_HDR)
        add_definitions(-DWITH_HDR)
 endif()
 
+if(WITH_OPENIMAGEIO)
+       list(APPEND INC_SYS
+               ${OPENIMAGEIO_INCLUDES}
+       )
+       # disabled for now add_definitions(-DWITH_OPENIMAGEIO ${OPENIMAGEIO_DEFINITIONS})
+endif()
+
 blender_add_lib(bf_imbuf "${SRC}" "${INC}" "${INC_SYS}")
index f5e2bf71468bea483da52192366048bdcfa9802b..c4872f370e539af3a58c42b8538f1c2d7199cb64 100644 (file)
@@ -169,39 +169,27 @@ typedef struct ImBuf {
 #define JPG                            (1 << 27)
 #define BMP                            (1 << 26)
 
-#ifdef WITH_QUICKTIME
 #define QUICKTIME              (1 << 25)
-#endif
 
-#ifdef WITH_HDR
 #define RADHDR                 (1 << 24)
-#endif
-#ifdef WITH_TIFF
 #define TIF                            (1 << 23)
 #define TIF_16BIT              (1 << 8 )
-#endif
 
 #define OPENEXR                        (1 << 22)
 #define OPENEXR_HALF   (1 << 8 )
 #define OPENEXR_COMPRESS (7)   
 
-#ifdef WITH_CINEON
 #define CINEON                 (1 << 21)
 #define DPX                            (1 << 20)
-#endif
 
-#ifdef WITH_DDS
 #define DDS                            (1 << 19)
-#endif
 
-#ifdef WITH_OPENJPEG
 #define JP2                            (1 << 18)
 #define JP2_12BIT              (1 << 17)
 #define JP2_16BIT              (1 << 16)
 #define JP2_YCC                        (1 << 15)
 #define JP2_CINE               (1 << 14)
 #define JP2_CINE_48FPS (1 << 13) 
-#endif
 
 #define RAWTGA         (TGA | 1)
 
index cf0d0990d33c50fb18e4b140e19983ffbf22390e..3a7725ae706d6452744b91bac4c02cfc8f4400ed 100644 (file)
@@ -46,6 +46,9 @@ typedef struct ImFileType {
        int (*save)(struct ImBuf *ibuf, const char *name, int flags);
        void (*load_tile)(struct ImBuf *ibuf, unsigned char *mem, size_t size, int tx, int ty, unsigned int *rect);
 
+       int (*is_a_filepath)(const char *filepath);
+       struct ImBuf *(*load_filepath)(const char *filepath, int flags);
+
        int flag;
        int filetype;
 } ImFileType;
@@ -121,5 +124,20 @@ void imb_loadtiletiff(struct ImBuf *ibuf, unsigned char *mem, size_t size,
 int imb_savetiff(struct ImBuf *ibuf, const char *name, int flags);
 void *libtiff_findsymbol(char *name);
 
+/* openimageio */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int imb_is_a_openimageio(unsigned char *buf);
+int imb_is_a_filepath_openimageio(const char *filepath);
+int imb_ftype_openimageio(struct ImFileType *type, struct ImBuf *ibuf);
+struct ImBuf *imb_load_openimageio(const char *filepath, int flags);
+int imb_save_openimageio(struct ImBuf *ibuf, const char *filepath, int flags);
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* IMB_FILETYPE_H */
 
index c51211899528c08ec2924d45b2405d99e0db0549..47be6f609c84fc8e13465ac01b7315fee3334647 100644 (file)
@@ -51,9 +51,6 @@ static int imb_ftype_default(ImFileType *type, ImBuf *ibuf) { return (ibuf->ftyp
 static int imb_ftype_cocoa(ImFileType *type, ImBuf *ibuf) { return (ibuf->ftype & TIF); }
 #endif
 static int imb_ftype_iris(ImFileType *type, ImBuf *ibuf) { (void)type; return (ibuf->ftype == IMAGIC); }
-#ifdef WITH_QUICKTIME
-static int imb_ftype_quicktime(ImFileType *type, ImBuf *ibuf) { return 0; } // XXX
-#endif
 
 #ifdef WITH_QUICKTIME
 void quicktime_init(void);
@@ -61,36 +58,39 @@ void quicktime_exit(void);
 #endif
 
 ImFileType IMB_FILE_TYPES[]= {
-       {NULL, NULL, imb_is_a_jpeg, imb_ftype_default, imb_load_jpeg, imb_savejpeg, NULL, 0, JPG},
-       {NULL, NULL, imb_is_a_png, imb_ftype_default, imb_loadpng, imb_savepng, NULL, 0, PNG},
-       {NULL, NULL, imb_is_a_bmp, imb_ftype_default, imb_bmp_decode, imb_savebmp, NULL, 0, BMP},
-       {NULL, NULL, imb_is_a_targa, imb_ftype_default, imb_loadtarga, imb_savetarga, NULL, 0, TGA},
-       {NULL, NULL, imb_is_a_iris, imb_ftype_iris, imb_loadiris, imb_saveiris, NULL, 0, IMAGIC},
+#ifdef WITH_OPENIMAGEIO
+       {NULL, NULL, imb_is_a_openimageio, imb_ftype_openimageio, NULL, imb_save_openimageio, NULL, imb_is_a_filepath_openimageio, imb_load_openimageio, 0, 0},
+#endif
+       {NULL, NULL, imb_is_a_jpeg, imb_ftype_default, imb_load_jpeg, imb_savejpeg, NULL, NULL, NULL, 0, JPG},
+       {NULL, NULL, imb_is_a_png, imb_ftype_default, imb_loadpng, imb_savepng, NULL, NULL, NULL, 0, PNG},
+       {NULL, NULL, imb_is_a_bmp, imb_ftype_default, imb_bmp_decode, imb_savebmp, NULL, NULL, NULL, 0, BMP},
+       {NULL, NULL, imb_is_a_targa, imb_ftype_default, imb_loadtarga, imb_savetarga, NULL, NULL, NULL, 0, TGA},
+       {NULL, NULL, imb_is_a_iris, imb_ftype_iris, imb_loadiris, imb_saveiris, NULL, NULL, NULL, 0, IMAGIC},
 #ifdef WITH_CINEON
-       {NULL, NULL, imb_is_dpx, imb_ftype_default, imb_loaddpx, imb_save_dpx, NULL, IM_FTYPE_FLOAT, DPX},
-       {NULL, NULL, imb_is_cineon, imb_ftype_default, imb_loadcineon, imb_savecineon, NULL, IM_FTYPE_FLOAT, CINEON},
+       {NULL, NULL, imb_is_dpx, imb_ftype_default, imb_loaddpx, imb_save_dpx, NULL, NULL, NULL, IM_FTYPE_FLOAT, DPX},
+       {NULL, NULL, imb_is_cineon, imb_ftype_default, imb_loadcineon, imb_savecineon, NULL, NULL, NULL, IM_FTYPE_FLOAT, CINEON},
 #endif
 #ifdef WITH_TIFF
-       {imb_inittiff, NULL, imb_is_a_tiff, imb_ftype_default, imb_loadtiff, imb_savetiff, imb_loadtiletiff, 0, TIF},
+       {imb_inittiff, NULL, imb_is_a_tiff, imb_ftype_default, imb_loadtiff, imb_savetiff, imb_loadtiletiff, NULL, NULL, 0, TIF},
 #elif defined(__APPLE__) && defined(IMBUF_COCOA)
-       {NULL, NULL, imb_is_a_cocoa, imb_ftype_cocoa, imb_imb_cocoaLoadImage, imb_savecocoa, NULL, 0, TIF},
+       {NULL, NULL, imb_is_a_cocoa, imb_ftype_cocoa, imb_imb_cocoaLoadImage, imb_savecocoa, NULL, NULL, NULL, 0, TIF},
 #endif
 #ifdef WITH_HDR
-       {NULL, NULL, imb_is_a_hdr, imb_ftype_default, imb_loadhdr, imb_savehdr, NULL, IM_FTYPE_FLOAT, RADHDR},
+       {NULL, NULL, imb_is_a_hdr, imb_ftype_default, imb_loadhdr, imb_savehdr, NULL, NULL, NULL, IM_FTYPE_FLOAT, RADHDR},
 #endif
 #ifdef WITH_OPENEXR
-       {NULL, NULL, imb_is_a_openexr, imb_ftype_default, imb_load_openexr, imb_save_openexr, NULL, IM_FTYPE_FLOAT, OPENEXR},
+       {NULL, NULL, imb_is_a_openexr, imb_ftype_default, imb_load_openexr, imb_save_openexr, NULL, NULL, NULL, IM_FTYPE_FLOAT, OPENEXR},
 #endif
 #ifdef WITH_OPENJPEG
-       {NULL, NULL, imb_is_a_jp2, imb_ftype_default, imb_jp2_decode, imb_savejp2, NULL, IM_FTYPE_FLOAT, JP2},
+       {NULL, NULL, imb_is_a_jp2, imb_ftype_default, imb_jp2_decode, imb_savejp2, NULL, NULL, NULL, IM_FTYPE_FLOAT, JP2},
 #endif
 #ifdef WITH_DDS
-       {NULL, NULL, imb_is_a_dds, imb_ftype_default, imb_load_dds, NULL, NULL, 0, DDS},
+       {NULL, NULL, imb_is_a_dds, imb_ftype_default, imb_load_dds, NULL, NULL, NULL, NULL, 0, DDS},
 #endif
 #ifdef WITH_QUICKTIME
-       {quicktime_init, quicktime_exit, imb_is_a_quicktime, imb_ftype_quicktime, imb_quicktime_decode, NULL, NULL, 0, QUICKTIME},
+       {quicktime_init, quicktime_exit, imb_is_a_quicktime, NULL, imb_quicktime_decode, NULL, NULL, NULL, 0, QUICKTIME},
 #endif 
-       {NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0}};
+       {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0}};
        
 void imb_filetypes_init(void)
 {
diff --git a/source/blender/imbuf/intern/openimageio.cpp b/source/blender/imbuf/intern/openimageio.cpp
new file mode 100644 (file)
index 0000000..2e5dd5b
--- /dev/null
@@ -0,0 +1,237 @@
+/*
+ *
+ * ***** 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) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ * $Id: png.c 36777 2011-05-19 11:54:03Z blendix $
+ */
+
+/** \file blender/imbuf/intern/png.c
+ *  \ingroup imbuf
+ */
+
+#ifdef WITH_OPENIMAGEIO
+
+#include "MEM_sys_types.h"
+
+#include "imbuf.h"
+
+extern "C" {
+
+#include "IMB_imbuf_types.h"
+#include "IMB_imbuf.h"
+
+#include "IMB_allocimbuf.h"
+#include "IMB_metadata.h"
+#include "IMB_filetype.h"
+
+}
+
+#include <OpenImageIO/imageio.h>
+
+OIIO_NAMESPACE_USING
+
+int imb_is_a_openimageio(unsigned char *buf)
+{
+       return 0;
+}
+
+int imb_is_a_filepath_openimageio(const char *filepath)
+{
+       ImageInput *in = ImageInput::create(filepath);
+       ImageSpec spec;
+       int recognized = in->open(filepath, spec);
+       in->close();
+
+       return recognized;
+}
+
+template<typename T> static void pack_pixels(T *pixels, int width, int height, int components, T alpha)
+{
+       if(components == 3) {
+               for(int i = width*height-1; i >= 0; i--) {
+                       pixels[i*4+3] = alpha;
+                       pixels[i*4+2] = pixels[i*3+2];
+                       pixels[i*4+1] = pixels[i*3+1];
+                       pixels[i*4+0] = pixels[i*3+0];
+               }
+       }
+       else if(components == 1) {
+               for(int i = width*height-1; i >= 0; i--) {
+                       pixels[i*4+3] = alpha;
+                       pixels[i*4+2] = pixels[i];
+                       pixels[i*4+1] = pixels[i];
+                       pixels[i*4+0] = pixels[i];
+               }
+       }
+}
+
+int imb_ftype_openimageio(ImFileType *type, ImBuf *ibuf)
+{
+       return ibuf->ftype & (PNG|TGA|JPG|BMP|RADHDR|TIF|OPENEXR|CINEON|DPX|DDS|JP2);
+}
+
+static int format_name_to_ftype(const char *format_name)
+{
+       if(strcmp(format_name, "png") == 0)
+               return PNG;
+       else if(strcmp(format_name, "targa") == 0)
+               return TGA; /* RAWTGA */
+       else if(strcmp(format_name, "jpeg") == 0)
+               return JPG;
+       else if(strcmp(format_name, "bmp") == 0)
+               return BMP;
+       else if(strcmp(format_name, "hdr") == 0)
+               return RADHDR;
+       else if(strcmp(format_name, "tiff") == 0)
+               return TIF; /* TIF_16BIT */
+       else if(strcmp(format_name, "openexr") == 0)
+               return OPENEXR; /* OPENEXR_HALF, OPENEXR_COMPRESS */
+       else if(strcmp(format_name, "cineon") == 0)
+               return CINEON;
+       else if(strcmp(format_name, "dpx") == 0)
+               return DPX;
+       else if(strcmp(format_name, "dds") == 0)
+               return DDS;
+       else if(strcmp(format_name, "jpeg2000") == 0)
+               return JP2; /* JP2_12BIT, JP2_16BIT, JP2_YCC , JP2_CINE , JP2_CINE_48FPS */
+
+       /* not handled: "field3d", "fits", "ico", "iff", "pnm", "ptex", "sgi", "zfile" */
+
+       return 0;
+}
+
+ImBuf *imb_load_openimageio(const char *filepath, int flags)
+{
+       ImageInput *in = ImageInput::create(filepath);
+       ImageSpec spec;
+       bool success;
+
+       if(!in->open(filepath, spec)) {
+               delete in;
+               return NULL;
+       }
+       
+       /* we only handle certain number of components */
+       int width = spec.width;
+       int height = spec.height;
+       int components = spec.nchannels;
+
+       if(!(components == 1 || components == 3 || components == 4)) {
+               delete in;
+               return NULL;
+       }
+
+       ImBuf *ibuf = IMB_allocImBuf(width, height, 32, 0);
+       ibuf->ftype = format_name_to_ftype(in->format_name());
+
+       /* TODO: handle oiio:ColorSpace, oiio:Gamma, metadata, multilayer, size_t_safe */
+
+       /* read RGBA pixels */
+       if(spec.format == TypeDesc::UINT8 || spec.format == TypeDesc::INT8) {
+               //if(in->get_string_attribute("oiio:ColorSpace") == "sRGB")
+               ibuf->profile = IB_PROFILE_SRGB;
+
+               imb_addrectImBuf(ibuf);
+
+               uint8_t *pixels = (uint8_t*)ibuf->rect;
+               int scanlinesize = width*components;
+
+               success = in->read_image(TypeDesc::UINT8,
+                       pixels + (height-1)*scanlinesize,
+                       AutoStride,
+                       -scanlinesize*sizeof(uint8_t),
+                       AutoStride);
+
+               pack_pixels<uint8_t>(pixels, width, height, components, 255);
+       }
+       else {
+               ibuf->profile = IB_PROFILE_LINEAR_RGB; /* XXX assumption */
+
+               imb_addrectfloatImBuf(ibuf);
+
+               float *pixels = ibuf->rect_float;
+               int scanlinesize = width*components;
+
+               success = in->read_image(TypeDesc::FLOAT,
+                       pixels + (height-1)*scanlinesize,
+                       AutoStride,
+                       -scanlinesize*sizeof(float),
+                       AutoStride);
+
+               pack_pixels<float>(pixels, width, height, components, 1.0f);
+       }
+
+       if(!success)
+               fprintf(stderr, "OpenImageIO: error loading image: %s\n", in->geterror().c_str());
+
+       in->close();
+       delete in;
+
+       return ibuf;
+}
+
+int imb_save_openimageio(struct ImBuf *ibuf, const char *filepath, int flags)
+{
+       ImageOutput *out = ImageOutput::create(filepath);
+
+       if(ibuf->rect_float) {
+               /* XXX profile */
+
+               /* save as float image XXX works? */
+               ImageSpec spec(ibuf->x, ibuf->y, 4, TypeDesc::FLOAT);
+               int scanlinesize = ibuf->x*4;
+
+               out->open(filepath, spec);
+
+               /* conversion for different top/bottom convention */
+               out->write_image(TypeDesc::FLOAT,
+                       ibuf->rect_float + (ibuf->y-1)*scanlinesize,
+                       AutoStride,
+                       -scanlinesize*sizeof(float),
+                       AutoStride);
+       }
+       else {
+               /* save as 8bit image */
+               ImageSpec spec(ibuf->x, ibuf->y, 4, TypeDesc::UINT8);
+               int scanlinesize = ibuf->x*4;
+
+               out->open(filepath, spec);
+
+               /* conversion for different top/bottom convention */
+               out->write_image(TypeDesc::UINT8,
+                       (uint8_t*)ibuf->rect + (ibuf->y-1)*scanlinesize,
+                       AutoStride,
+                       -scanlinesize*sizeof(uint8_t),
+                       AutoStride);
+       }
+
+       out->close();
+       delete out;
+
+       return 1;
+}
+
+#endif /* WITH_OPENIMAGEIO */
+
index 849b3ff0ce288a09ce71259cf5cd62acc9b47563..dac7e91fec60ec99ac64d671e6ceee7c3d5ad739 100644 (file)
 #include "IMB_imbuf.h"
 #include "IMB_filetype.h"
 
+static ImBuf *imb_ibImageFromFile(const char *filepath, int flags)
+{
+       ImBuf *ibuf;
+       ImFileType *type;
+
+       for(type=IMB_FILE_TYPES; type->is_a; type++) {
+               if(type->load_filepath) {
+                       ibuf= type->load_filepath(filepath, flags);
+                       if(ibuf) {
+                               if(flags & IB_premul) {
+                                       IMB_premultiply_alpha(ibuf);
+                                       ibuf->flags |= IB_premul;
+                               }
+
+                               return ibuf;
+                       }
+               }
+       }
+       
+       return NULL;
+}
+
 ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags)
 {
        ImBuf *ibuf;
@@ -127,10 +149,15 @@ ImBuf *IMB_loadiffname(const char *name, int flags)
 
        imb_cache_filename(filename, name, flags);
 
-       file = open(filename, O_BINARY|O_RDONLY);
-       if(file < 0) return NULL;
+       ibuf= imb_ibImageFromFile(name, flags);
+
+       if(!ibuf) {
+               file = open(filename, O_BINARY|O_RDONLY);
+               if(file < 0) return NULL;
 
-       ibuf= IMB_loadifffile(file, flags);
+               ibuf= IMB_loadifffile(file, flags);
+               close(file);
+       }
 
        if(ibuf) {
                BLI_strncpy(ibuf->name, name, sizeof(ibuf->name));
@@ -140,8 +167,6 @@ ImBuf *IMB_loadiffname(const char *name, int flags)
                if(flags & IB_fields) IMB_de_interlace(ibuf);
        }
 
-       close(file);
-
        return ibuf;
 }
 
@@ -184,7 +209,7 @@ static void imb_loadtilefile(ImBuf *ibuf, int file, int tx, int ty, unsigned int
        }
 
        for(type=IMB_FILE_TYPES; type->is_a; type++)
-               if(type->load_tile && type->ftype(type, ibuf))
+               if(type->load_tile && type->ftype && type->ftype(type, ibuf))
                        type->load_tile(ibuf, mem, size, tx, ty, rect);
 
        if(munmap(mem, size))
index 6db8dcc06cf1a88f75c75b872b4895db553d0852..f548d8eda923d6167968cd368daf243ec8d1ce9b 100644 (file)
@@ -155,6 +155,10 @@ static int IMB_ispic_name(const char *name)
        int fp, buf[10];
 
        if(UTIL_DEBUG) printf("IMB_ispic_name: loading %s\n", name);
+
+       /*for(type=IMB_FILE_TYPES; type->is_a; type++)
+               if(type->is_a_filepath && type->is_a_filepath(name))
+                       return type->filetype;*/
        
        if(stat(name,&st) == -1)
                return FALSE;
@@ -176,7 +180,7 @@ static int IMB_ispic_name(const char *name)
                return JPG;
 
        for(type=IMB_FILE_TYPES; type->is_a; type++)
-               if(type->is_a((uchar*)buf))
+               if(type->is_a && type->is_a((uchar*)buf))
                        return type->filetype;
 
        return FALSE;
index cd660e11f26329dbb1d013c5ce7db9a130aa6268..96e6df6d758df19a9a9f3901604cc21ec478638c 100644 (file)
@@ -50,7 +50,7 @@ short IMB_saveiff(struct ImBuf *ibuf, const char *name, int flags)
        ibuf->flags = flags;
 
        for(type=IMB_FILE_TYPES; type->is_a; type++) {
-               if(type->save && type->ftype(type, ibuf)) {
+               if(type->save && type->ftype && type->ftype(type, ibuf)) {
                        if(!(type->flag & IM_FTYPE_FLOAT)) {
                                if(ibuf->rect==NULL && ibuf->rect_float)
                                        IMB_rect_from_float(ibuf);
index 93a4b3ec2693395ac0bfd442a91f318505e374c9..3d509fa28274714ab26dab21db9e4a23d11544c3 100644 (file)
@@ -91,4 +91,8 @@ if(WITH_AUDASPACE)
        add_definitions(-DWITH_AUDASPACE)
 endif()
 
+if(WITH_CYCLES)
+       add_definitions(-DWITH_CYCLES)
+endif()
+
 blender_add_lib(bf_python "${SRC}" "${INC}" "${INC_SYS}")
index 8bd6e6c611c14dd2821204838d43ba56e2f36b1e..ea76c4bb377f91a4bb2f8cf7406a2450b9959da3 100644 (file)
@@ -172,6 +172,8 @@ void BPY_context_set(bContext *C)
 
 /* defined in AUD_C-API.cpp */
 extern PyObject *AUD_initPython(void);
+/* defined in cycles/blender */
+extern PyObject *CYCLES_initPython(void);
 
 static struct _inittab bpy_internal_modules[]= {
        {(char *)"noise", BPyInit_noise},
@@ -181,6 +183,9 @@ static struct _inittab bpy_internal_modules[]= {
        {(char *)"blf", BPyInit_blf},
 #ifdef WITH_AUDASPACE
        {(char *)"aud", AUD_initPython},
+#endif
+#ifdef WITH_CYCLES
+       {(char *)"libcycles_blender", CYCLES_initPython},
 #endif
        {NULL, NULL}
 };
index 43fec85b5bf6f28e64a15f7dc353e5465a43d640..850be368d4aa658239920bb8e445b8f76a7b65b0 100644 (file)
@@ -407,6 +407,22 @@ if(UNIX AND NOT APPLE)
                        # install(CODE "execute_process(COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/ -name '*.so' -exec strip -s {} '\;')")
                endif()
        endif()
+
+       # XXX this is non standard
+       if(WITH_OPENIMAGEIO)
+               set(oiio_install_libs
+                       ${OPENIMAGEIO_LIBPATH}/lib${OPENIMAGEIO_LIBRARY}.so
+                       ${BOOST_LIBRARIES})
+
+               list(REMOVE_ITEM oiio_install_libs optimized)
+               list(REMOVE_ITEM oiio_install_libs debug)
+
+               install(
+                       FILES ${oiio_install_libs}
+                       DESTINATION ${TARGETDIR}
+               )
+       endif()
+
 elseif(WIN32)
 
        set(TARGETDIR_VER ${TARGETDIR}/${BLENDER_VERSION})
@@ -594,6 +610,14 @@ elseif(WIN32)
                )
        endif()
 
+       if(WITH_OPENIMAGEIO)
+               install(
+                       FILES
+                               ${LIBDIR}/openimageio/bin/OpenImageIO.dll
+                       DESTINATION ${TARGETDIR}
+               )
+       endif()
+
 elseif(APPLE)
        set(SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app)
        set(SOURCEINFO ${SOURCEDIR}/Contents/Info.plist)
@@ -704,6 +728,9 @@ elseif(APPLE)
        endif()
 endif()
 
+# install more files XXX pass target dir
+delayed_do_install(${TARGETDIR_VER})
+
 unset(BLENDER_TEXT_FILES)
 
 
@@ -847,6 +874,10 @@ endif()
                list(APPEND BLENDER_SORTED_LIBS bf_quicktime)
        endif()
 
+       if(WITH_CYCLES)
+               list(APPEND BLENDER_SORTED_LIBS bf_intern_cycles)
+       endif()
+
        foreach(SORTLIB ${BLENDER_SORTED_LIBS})
                set(REMLIB ${SORTLIB})
                foreach(SEARCHLIB ${BLENDER_LINK_LIBS})