[Bf-blender-cvs] [fc25a2d4487] pygpu_extensions: OpenColorIO: upgrade to version 2.0.0

Brecht Van Lommel noreply at git.blender.org
Fri Feb 12 22:56:29 CET 2021


Commit: fc25a2d4487214b56ea675d8b9e7b929625cda3e
Author: Brecht Van Lommel
Date:   Sun Jan 31 19:35:00 2021 +0100
Branches: pygpu_extensions
https://developer.blender.org/rBfc25a2d4487214b56ea675d8b9e7b929625cda3e

OpenColorIO: upgrade to version 2.0.0

Ref T84819

Build System
============

This is an API breaking new version, and the updated code only builds with
OpenColorIO 2.0 and later. Adding backwards compatibility was too complicated.

* Tinyxml was replaced with Expat, adding a new dependency.
* Yaml-cpp is now built as a dependency on Unix, as was already done on Windows.
* Removed currently unused LCMS code.
* Pystring remains built as part of OCIO itself, since it has no good build system.
* Linux and macOS check for the OpenColorIO verison, and disable it if too old.

Ref D10270

Processors and Transforms
=========================

CPU processors now need to be created to do CPU processing. These are cached
internally, but the cache lookup is not fast enough to execute per pixel or
texture sample, so for performance these are now also exposed in the C API.

The C API for transforms will no longer be needed afer all changes, so remove
it to simplify the API and fallback implementation.

Ref D10271

Display Transforms
==================

Needs a bit more manual work constructing the transform. LegacyViewingPipeline
could also have been used, but isn't really any simpler and since it's legacy
we better not rely on it.

We moved more logic into the opencolorio module, to simplify the API. There is
no need to wrap a dozen functions just to be able to do this in C rather than C++.
It's also tightly coupled to the GPU shader logic, and so should be in the same
module.

Ref D10271

GPU Display Shader
==================

To avoid baking exposure and gamma into the GLSL shader and requiring slow
recompiles when tweaking, we manually apply them in the shader. This leads
to some logic duplicaton between the CPU and GPU display processor, but it
seems unavoidable.

Caching was also changed. Previously this was done both on the imbuf and
opencolorio module levels. Now it's all done in the opencolorio module by
simply matching color space names. We no longer use cacheIDs from OpenColorIO
since computing them is expensive, and they are unlikely to match now that
more is baked into the shader code.

Shaders can now use multiple 2D textures, 3D textures and uniforms, rather
than a single 3D texture. So allocating and binding those adds some code.

Color space conversions for blending with overlays is now hardcoded in the
shader. This was using harcoded numbers anyway, if this every becomes a
general OpenColorIO transform it can be changed, but for now there is no
point to add code complexity.

Ref D10273

CIE XYZ
=======

We need standard CIE XYZ values for rendering effects like blackbody emission.
The relation to the scene linear role is based on OpenColorIO configuration.

In OpenColorIO 2.0 configs roles can no longer have the same name as color
spaces, which means our XYZ role and colorspace in the configuration give an
error.

Instead use the new standard aces_interchange role, which relates scene linear
to a known scene referred color space. Compatibility with the old XYZ role is
preserved, if the configuration file has no conflicting names.

Also includes a non-functional change to the configuraton file to use an
XYZ-to-ACES matrix instead of REC709-to-ACES, makes debugging a little easier
since the matrix is the same one we have in the code now and that is also
found easily in the ACES specs.

Ref D10274

===================================================================

M	CMakeLists.txt
M	build_files/build_environment/CMakeLists.txt
R066	build_files/build_environment/cmake/lcms.cmake	build_files/build_environment/cmake/expat.cmake
M	build_files/build_environment/cmake/nasm.cmake
M	build_files/build_environment/cmake/opencolorio.cmake
D	build_files/build_environment/cmake/tinyxml.cmake
M	build_files/build_environment/cmake/versions.cmake
M	build_files/build_environment/cmake/yamlcpp.cmake
M	build_files/build_environment/install_deps.sh
M	build_files/cmake/Modules/FindOpenColorIO.cmake
M	build_files/cmake/platform/platform_apple.cmake
M	build_files/cmake/platform/platform_unix.cmake
M	build_files/cmake/platform/platform_win32.cmake
M	intern/cycles/render/CMakeLists.txt
M	intern/cycles/render/colorspace.cpp
M	intern/cycles/render/shader.cpp
M	intern/cycles/render/shader.h
M	intern/opencolorio/fallback_impl.cc
M	intern/opencolorio/gpu_shader_display_transform.glsl
M	intern/opencolorio/ocio_capi.cc
M	intern/opencolorio/ocio_capi.h
M	intern/opencolorio/ocio_impl.cc
M	intern/opencolorio/ocio_impl.h
M	intern/opencolorio/ocio_impl_glsl.cc
M	release/datafiles/colormanagement/config.ocio
D	release/datafiles/colormanagement/luts/aces_to_xyz.spimtx
D	release/datafiles/colormanagement/luts/rec709_to_aces.spimtx
A	release/datafiles/colormanagement/luts/xyz_to_aces.spimtx
M	source/blender/imbuf/intern/IMB_colormanagement_intern.h
M	source/blender/imbuf/intern/colormanagement.c

===================================================================

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 51308850d3a..b6fb6dbd9dc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -728,8 +728,9 @@ set_and_warn_dependency(WITH_TBB WITH_MOD_FLUID         OFF)
 # NanoVDB requires OpenVDB to convert the data structure
 set_and_warn_dependency(WITH_OPENVDB WITH_NANOVDB       OFF)
 
-# OpenVDB uses 'half' type from OpenEXR & fails to link without OpenEXR enabled.
+# OpenVDB and OpenColorIO uses 'half' type from OpenEXR
 set_and_warn_dependency(WITH_IMAGE_OPENEXR WITH_OPENVDB OFF)
+set_and_warn_dependency(WITH_IMAGE_OPENEXR WITH_OPENCOLORIO  OFF)
 
 # Haru needs `TIFFFaxBlackCodes` & `TIFFFaxWhiteCodes` symbols from TIFF.
 set_and_warn_dependency(WITH_IMAGE_TIFF WITH_HARU       OFF)
diff --git a/build_files/build_environment/CMakeLists.txt b/build_files/build_environment/CMakeLists.txt
index 672f5820a16..8d6fd3ab4c3 100644
--- a/build_files/build_environment/CMakeLists.txt
+++ b/build_files/build_environment/CMakeLists.txt
@@ -70,7 +70,6 @@ include(cmake/cuew.cmake)
 include(cmake/opensubdiv.cmake)
 include(cmake/sdl.cmake)
 include(cmake/opencollada.cmake)
-include(cmake/opencolorio.cmake)
 include(cmake/llvm.cmake)
 include(cmake/clang.cmake)
 if(APPLE)
@@ -105,18 +104,15 @@ if(NOT APPLE)
   include(cmake/xr_openxr.cmake)
 endif()
 
+# OpenColorIO and dependencies.
+include(cmake/expat.cmake)
+include(cmake/yamlcpp.cmake)
+include(cmake/opencolorio.cmake)
+
 if(WITH_WEBP)
   include(cmake/webp.cmake)
 endif()
 
-if(WIN32)
-  # OCIO deps
-  include(cmake/tinyxml.cmake)
-  include(cmake/yamlcpp.cmake)
-  # LCMS is an OCIO dep, but only if you build the apps, leaving it here for convenience
-  # include(cmake/lcms.cmake)
-endif()
-
 if(NOT WIN32 OR ENABLE_MINGW64)
   include(cmake/gmp.cmake)
   include(cmake/openjpeg.cmake)
diff --git a/build_files/build_environment/cmake/tinyxml.cmake b/build_files/build_environment/cmake/expat.cmake
similarity index 66%
rename from build_files/build_environment/cmake/tinyxml.cmake
rename to build_files/build_environment/cmake/expat.cmake
index 763fd959d24..001f3941de1 100644
--- a/build_files/build_environment/cmake/tinyxml.cmake
+++ b/build_files/build_environment/cmake/expat.cmake
@@ -16,16 +16,20 @@
 #
 # ***** END GPL LICENSE BLOCK *****
 
-set(TINYXML_EXTRA_ARGS
+set(EXPAT_EXTRA_ARGS
+  -DEXPAT_BUILD_DOCS=OFF
+  -DEXPAT_BUILD_EXAMPLES=OFF
+  -DEXPAT_BUILD_TESTS=OFF
+  -DEXPAT_BUILD_TOOLS=OFF
+  -DEXPAT_SHARED_LIBS=OFF
 )
 
-ExternalProject_Add(external_tinyxml
-  URL ${TINYXML_URI}
+ExternalProject_Add(external_expat
+  URL ${EXPAT_URI}
   DOWNLOAD_DIR ${DOWNLOAD_DIR}
-  URL_HASH MD5=${TINYXML_HASH}
-  PREFIX ${BUILD_DIR}/tinyxml
-  # patch taken from ocio
-  PATCH_COMMAND ${PATCH_CMD} -p 1 -N -d ${BUILD_DIR}/tinyxml/src/external_tinyxml < ${PATCH_DIR}/tinyxml.diff
-  CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/tinyxml ${DEFAULT_CMAKE_FLAGS} ${TINYXML_EXTRA_ARGS}
-  INSTALL_DIR ${LIBDIR}/tinyxml
+  URL_HASH MD5=${EXPAT_HASH}
+  PREFIX ${BUILD_DIR}/expat
+  CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/expat ${DEFAULT_CMAKE_FLAGS} ${EXPAT_EXTRA_ARGS}
+  INSTALL_DIR ${LIBDIR}/expat
+  SOURCE_SUBDIR expat
 )
diff --git a/build_files/build_environment/cmake/lcms.cmake b/build_files/build_environment/cmake/lcms.cmake
deleted file mode 100644
index c7019bc645e..00000000000
--- a/build_files/build_environment/cmake/lcms.cmake
+++ /dev/null
@@ -1,31 +0,0 @@
-# ***** 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.
-#
-# ***** END GPL LICENSE BLOCK *****
-
-set(LCMS_EXTRA_ARGS
-)
-
-ExternalProject_Add(external_lcms
-  URL ${LCMS_URI}
-  DOWNLOAD_DIR ${DOWNLOAD_DIR}
-  URL_HASH MD5=${LCMS_HASH}
-  PREFIX ${BUILD_DIR}/lcms
-  # Patch taken from ocio.
-  PATCH_COMMAND ${CMAKE_COMMAND} -E copy ${PATCH_DIR}/cmakelists_lcms.txt ${BUILD_DIR}/lcms/src/external_lcms/CMakeLists.txt
-  CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/lcms ${DEFAULT_CMAKE_FLAGS} ${LCMS_EXTRA_ARGS}
-  INSTALL_DIR ${LIBDIR}/lcms
-)
diff --git a/build_files/build_environment/cmake/nasm.cmake b/build_files/build_environment/cmake/nasm.cmake
index 6eadfc5e4f0..37a57273bfe 100644
--- a/build_files/build_environment/cmake/nasm.cmake
+++ b/build_files/build_environment/cmake/nasm.cmake
@@ -22,8 +22,8 @@ ExternalProject_Add(external_nasm
   URL_HASH SHA256=${NASM_HASH}
   PREFIX ${BUILD_DIR}/nasm
   PATCH_COMMAND ${PATCH_CMD} --verbose -p 1 -N -d ${BUILD_DIR}/nasm/src/external_nasm < ${PATCH_DIR}/nasm.diff
-  CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/nasm/src/external_nasm/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/nasm
-  BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/nasm/src/external_nasm/ && make -j${MAKE_THREADS}
+  CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/nasm/src/external_nasm/ && ./autogen.sh && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/nasm
+  BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/nasm/src/external_nasm/ && make -j${MAKE_THREADS} && make manpages
   INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/nasm/src/external_nasm/ && make install
   INSTALL_DIR ${LIBDIR}/nasm
 )
diff --git a/build_files/build_environment/cmake/opencolorio.cmake b/build_files/build_environment/cmake/opencolorio.cmake
index 4ad401800d0..7622a2afdaa 100644
--- a/build_files/build_environment/cmake/opencolorio.cmake
+++ b/build_files/build_environment/cmake/opencolorio.cmake
@@ -18,16 +18,22 @@
 
 set(OPENCOLORIO_EXTRA_ARGS
   -DOCIO_BUILD_APPS=OFF
-  -DOCIO_BUILD_PYGLUE=OFF
+  -DOCIO_BUILD_PYTHON=OFF
   -DOCIO_BUILD_NUKE=OFF
-  -DOCIO_USE_BOOST_PTR=OFF
-  -DOCIO_BUILD_STATIC=ON
-  -DOCIO_BUILD_SHARED=OFF
-  -DOCIO_BUILD_TRUELIGHT=OFF
+  -DOCIO_BUILD_JAVA=OFF
+  -DBUILD_SHARED_LIBS=OFF
   -DOCIO_BUILD_DOCS=OFF
-  -DOCIO_BUILD_PYGLUE=OFF
-  -DOCIO_BUILD_JNIGLUE=OFF
-  -DOCIO_STATIC_JNIGLUE=OFF
+  -DOCIO_BUILD_TESTS=OFF
+  -DOCIO_BUILD_GPU_TESTS=OFF
+  -DOCIO_USE_SSE=ON
+
+  # Manually build ext packages except for pystring, which does not have
+  # a CMake or autotools build system that we can easily use.
+  -DOCIO_INSTALL_EXT_PACKAGES=MISSING
+  -DHalf_ROOT=${LIBDIR}/openexr
+  -DHalf_STATIC_LIBRARY=ON
+  -Dexpat_ROOT=${LIBDIR}/expat
+  -Dyaml-cpp_ROOT=${LIBDIR}/yamlcpp
 )
 
 if(APPLE AND NOT("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "x86_64"))
@@ -41,24 +47,7 @@ if(WIN32)
   set(OCIO_PATCH opencolorio_win.diff)
   set(OPENCOLORIO_EXTRA_ARGS
     ${OPENCOLORIO_EXTRA_ARGS}
-    -DOCIO_BUILD_TESTS=OFF
-    -DOCIO_USE_SSE=ON
     -DOCIO_INLINES_HIDDEN=OFF
-    -DOCIO_PYGLUE_LINK=OFF
-    -DOCIO_PYGLUE_RESPECT_ABI=OFF
-    -DOCIO_PYGLUE_SONAME=OFF
-    -DOCIO_PYGLUE_LIB_PREFIX=OFF
-    -DUSE_EXTERNAL_TINYXML=ON
-    -DTINYXML_INCLUDE_DIR=${LIBDIR}/tinyxml/include
-    -DTINYXML_LIBRARY=${LIBDIR}/tinyxml/lib/tinyxml${libext}
-    -DUSE_EXTERNAL_YAML=ON
-    -DYAML_CPP_FOUND=ON
-    -DYAML_CPP_VERSION=${YAMLCPP_VERSION}
-    -DUSE_EXTERNAL_LCMS=ON
-    -DINC_1=${LIBDIR}/tinyxml/include
-    -DINC_2=${LIBDIR}/yamlcpp/include
-    # Lie because ocio cmake is demanding boost even though it is not needed.
-    -DYAML_CPP_VERSION=0.5.0
   )
 else()
   set(OCIO_PATCH opencolorio.diff)
@@ -72,48 +61,42 @@ ExternalProject_Add(external_opencolorio
   DOWNLOAD_DIR ${DOWNLOAD_DIR}
   URL_HASH MD5=${OPENCOLORIO_HASH}
   PREFIX ${BUILD_DIR}/opencolorio
-  PATCH_COMMAND ${PATCH_CMD} -p 1 -N -d ${BUILD_DIR}/opencolorio/src/external_opencolorio < ${PATCH_DIR}/${OCIO_PATCH}
   CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/opencolorio ${DEFAULT_CMAKE_FLAGS} ${OPENCOLORIO_EXTRA_ARGS}
   INSTALL_DIR ${LIBDIR}/opencolorio
 )
 
-if(NOT WIN32)
-  add_custom_command(
-    OUTPUT ${LIBDIR}/opencolorio/lib/libtinyxml.a
-    COMMAND cp ${BUILD_DIR}/opencolorio/src/external_opencolorio-build/ext/dist/lib/libtinyxml.a ${LIBDIR}/opencolorio/lib/libtinyxml.a
-    COMMAND cp ${BUILD_DIR}/opencolorio/src/external_opencolorio-build/ext/dist/lib/libyaml-cpp.a ${LIBDIR}/opencolorio/lib/libyaml-cpp.a
-  )
-  add_custom_target(external_opencolorio_extra ALL DEPENDS external_opencolorio ${LIBDIR}/opencolorio/lib/libtinyxml.a)
-endif()
-
 add_dependencies(
   external_opencolorio
-  external_boost
+  external_yamlcpp
+  external_expat
+  external_openexr
 )
 
 if(WIN32)
-  add_dependencies(
-    external_opencolorio
-    external_tinyxml
-    external_yamlcpp
-
-  )
   if(BUILD_MODE STREQUAL Release)
     ExternalProject_Add_Step(external_opencolorio after_install
       COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/opencolorio/include ${HARVEST_TARGET}/opencolorio/include
-      COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/opencolorio/lib/static ${HARVEST_TARGET}/opencolorio/lib
+      COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/opencolorio/lib ${HARVEST_TARGET}/opencolorio/lib
       COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/yamlcpp/lib/libyaml-cppmd.lib ${HARVEST_TARGET}/opencolorio/lib/libyaml-cpp.lib
-      COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tinyxml/lib/tinyxml.lib ${HARVEST_TARGET}/opencolorio/lib/tinyxml.lib
+      COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/expat/lib/libexpatMD.lib ${HARVEST_TARGET}/opencolorio/lib/libexpatMD.lib
+      COMMAND ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/opencolorio/src/external_opencolorio-build/ext/dist/lib/pystring.lib ${HARVEST_TARGET}/opencolorio/lib/pystring.lib
       DEPENDEES install
     )
   endif()
   if(BUILD_MODE STREQUAL Debug)
     ExternalProject_Add_Step(external_opencolorio after_install
-      COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/opencolorio/lib/static/Opencolorio.lib ${HARVEST_TARGET}/opencolorio/lib/OpencolorIO_d.lib
+      COMMAND ${CMAKE_COMMAND} -E copy ${LIBDI

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list