[Bf-blender-cvs] [d350976ba06] master: Cycles: Add Hydra render delegate

Patrick Mours noreply at git.blender.org
Wed Mar 23 16:39:41 CET 2022


Commit: d350976ba06d4ef93aa53fc4cd9da57be46ae924
Author: Patrick Mours
Date:   Wed Mar 23 16:07:43 2022 +0100
Branches: master
https://developer.blender.org/rBd350976ba06d4ef93aa53fc4cd9da57be46ae924

Cycles: Add Hydra render delegate

This patch adds a Hydra render delegate to Cycles, allowing Cycles to be used for rendering
in applications that provide a Hydra viewport. The implementation was written from scratch
against Cycles X, for integration into the Blender repository to make it possible to continue
developing it in step with the rest of Cycles. For this purpose it follows the style of the rest of
the Cycles code and can be built with a CMake option
(`WITH_CYCLES_HYDRA_RENDER_DELEGATE=1`) similar to the existing standalone version
of Cycles.

Since Hydra render delegates need to be built against the exact USD version and other
dependencies as the target application is using, this is intended to be built separate from
Blender (`WITH_BLENDER=0` CMake option) and with support for library versions different
from what Blender is using. As such the CMake build scripts for Windows had to be modified
slightly, so that the Cycles Hydra render delegate can e.g. be built with MSVC 2017 again
even though Blender requires MSVC 2019 now, and it's possible to specify custom paths to
the USD SDK etc. The codebase supports building against the latest USD release 22.03 and all
the way back to USD 20.08 (with some limitations).

Reviewed By: brecht, LazyDodo

Differential Revision: https://developer.blender.org/D14398

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

M	CMakeLists.txt
M	build_files/cmake/Modules/FindUSD.cmake
M	build_files/cmake/macros.cmake
M	build_files/cmake/platform/platform_win32.cmake
M	intern/cycles/CMakeLists.txt
M	intern/cycles/device/CMakeLists.txt
A	intern/cycles/hydra/CMakeLists.txt
A	intern/cycles/hydra/attribute.cpp
A	intern/cycles/hydra/attribute.h
A	intern/cycles/hydra/camera.cpp
A	intern/cycles/hydra/camera.h
A	intern/cycles/hydra/config.h
A	intern/cycles/hydra/curves.cpp
A	intern/cycles/hydra/curves.h
A	intern/cycles/hydra/display_driver.cpp
A	intern/cycles/hydra/display_driver.h
A	intern/cycles/hydra/field.cpp
A	intern/cycles/hydra/field.h
A	intern/cycles/hydra/geometry.h
A	intern/cycles/hydra/geometry.inl
A	intern/cycles/hydra/instancer.cpp
A	intern/cycles/hydra/instancer.h
A	intern/cycles/hydra/light.cpp
A	intern/cycles/hydra/light.h
A	intern/cycles/hydra/material.cpp
A	intern/cycles/hydra/material.h
A	intern/cycles/hydra/mesh.cpp
A	intern/cycles/hydra/mesh.h
A	intern/cycles/hydra/node_util.cpp
A	intern/cycles/hydra/node_util.h
A	intern/cycles/hydra/output_driver.cpp
A	intern/cycles/hydra/output_driver.h
A	intern/cycles/hydra/plugInfo.json
A	intern/cycles/hydra/plugin.cpp
A	intern/cycles/hydra/plugin.h
A	intern/cycles/hydra/pointcloud.cpp
A	intern/cycles/hydra/pointcloud.h
A	intern/cycles/hydra/render_buffer.cpp
A	intern/cycles/hydra/render_buffer.h
A	intern/cycles/hydra/render_delegate.cpp
A	intern/cycles/hydra/render_delegate.h
A	intern/cycles/hydra/render_pass.cpp
A	intern/cycles/hydra/render_pass.h
A	intern/cycles/hydra/resources/plugInfo.json
A	intern/cycles/hydra/session.cpp
A	intern/cycles/hydra/session.h
A	intern/cycles/hydra/volume.cpp
A	intern/cycles/hydra/volume.h
M	intern/cycles/integrator/render_scheduler.cpp
M	intern/cycles/kernel/svm/vertex_color.h
M	intern/cycles/scene/integrator.cpp
M	intern/cycles/scene/mesh.cpp
M	intern/cycles/scene/mesh.h
M	intern/cycles/session/session.h
M	intern/cycles/util/tbb.h

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

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d31a0c4a63d..bf40347e2ef 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -408,6 +408,8 @@ option(WITH_CYCLES_DEBUG             "Build Cycles with options useful for debug
 option(WITH_CYCLES_STANDALONE        "Build Cycles standalone application" OFF)
 option(WITH_CYCLES_STANDALONE_GUI    "Build Cycles standalone with GUI" OFF)
 
+option(WITH_CYCLES_HYDRA_RENDER_DELEGATE "Build Cycles Hydra render delegate" OFF)
+
 option(WITH_CYCLES_DEBUG_NAN         "Build Cycles with additional asserts for detecting NaNs and invalid values" OFF)
 option(WITH_CYCLES_NATIVE_ONLY       "Build Cycles with native kernel only (which fits current CPU, use for development only)" OFF)
 option(WITH_CYCLES_KERNEL_ASAN       "Build Cycles kernels with address sanitizer when WITH_COMPILER_ASAN is on, even if it's very slow" OFF)
@@ -742,9 +744,10 @@ endif()
 #-----------------------------------------------------------------------------
 # Check for conflicting/unsupported configurations
 
-if(NOT WITH_BLENDER AND NOT WITH_CYCLES_STANDALONE)
+if(NOT WITH_BLENDER AND NOT WITH_CYCLES_STANDALONE AND NOT WITH_CYCLES_HYDRA_RENDER_DELEGATE)
   message(FATAL_ERROR
     "At least one of WITH_BLENDER or WITH_CYCLES_STANDALONE "
+    "or WITH_CYCLES_HYDRA_RENDER_DELEGATE "
     "must be enabled, nothing to do!"
   )
 endif()
@@ -1907,14 +1910,13 @@ if(WITH_BLENDER)
   # source after intern and extern to gather all
   # internal and external library information first, for test linking
   add_subdirectory(source)
-elseif(WITH_CYCLES_STANDALONE)
+elseif(WITH_CYCLES_STANDALONE OR WITH_CYCLES_HYDRA_RENDER_DELEGATE)
   add_subdirectory(intern/glew-mx)
   add_subdirectory(intern/guardedalloc)
   add_subdirectory(intern/libc_compat)
   add_subdirectory(intern/sky)
 
   add_subdirectory(intern/cycles)
-  add_subdirectory(extern/clew)
   if(WITH_CYCLES_LOGGING)
     if(NOT WITH_SYSTEM_GFLAGS)
       add_subdirectory(extern/gflags)
diff --git a/build_files/cmake/Modules/FindUSD.cmake b/build_files/cmake/Modules/FindUSD.cmake
index a5370fe24b3..75b5df9e196 100644
--- a/build_files/cmake/Modules/FindUSD.cmake
+++ b/build_files/cmake/Modules/FindUSD.cmake
@@ -36,7 +36,7 @@ FIND_PATH(USD_INCLUDE_DIR
 # See https://github.com/PixarAnimationStudios/USD/blob/release/CHANGELOG.md#2111---2021-11-01
 FIND_LIBRARY(USD_LIBRARY
   NAMES
-    usd_usd_m usd_usd_ms usd_m usd_ms
+    usd_usd_m usd_usd_ms usd_m usd_ms ${USD_LIBRARY_PREFIX}usd
   NAMES_PER_DIR
   HINTS
     ${_usd_SEARCH_DIRS}
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index bf3e56922c9..5508e8f2104 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -879,7 +879,7 @@ function(delayed_install
   destination)
 
   foreach(f ${files})
-    if(IS_ABSOLUTE ${f})
+    if(IS_ABSOLUTE ${f} OR "${base}" STREQUAL "")
       set_property(GLOBAL APPEND PROPERTY DELAYED_INSTALL_FILES ${f})
     else()
       set_property(GLOBAL APPEND PROPERTY DELAYED_INSTALL_FILES ${base}/${f})
diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake
index e2e49ca0bcd..ca4af2274e6 100644
--- a/build_files/cmake/platform/platform_win32.cmake
+++ b/build_files/cmake/platform/platform_win32.cmake
@@ -39,12 +39,12 @@ if(CMAKE_C_COMPILER_ID MATCHES "Clang")
     set(WITH_WINDOWS_STRIPPED_PDB OFF)
   endif()
 else()
-  if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.28.29921) # MSVC 2019 16.9.16
+  if(WITH_BLENDER AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.28.29921) # MSVC 2019 16.9.16
     message(FATAL_ERROR "Compiler is unsupported, MSVC 2019 16.9.16 or newer is required for building blender.")
   endif()
 endif()
 
-if(NOT WITH_PYTHON_MODULE)
+if(WITH_BLENDER AND NOT WITH_PYTHON_MODULE)
   set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT blender)
 endif()
 
@@ -238,7 +238,6 @@ else()
 endif()
 
 if(NOT DEFINED LIBDIR)
-
   # Setup 64bit and 64bit windows systems
   if(CMAKE_CL_64)
     message(STATUS "64 bit compiler detected.")
@@ -252,6 +251,9 @@ if(NOT DEFINED LIBDIR)
   elseif(MSVC_VERSION GREATER 1919)
     message(STATUS "Visual Studio 2019 detected.")
     set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_BASE}_vc15)
+  elseif(MSVC_VERSION GREATER 1909)
+    message(STATUS "Visual Studio 2017 detected.")
+    set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_BASE}_vc15)
   endif()
 else()
   message(STATUS "Using pre-compiled LIBDIR: ${LIBDIR}")
@@ -300,9 +302,8 @@ set(ZLIB_INCLUDE_DIR ${LIBDIR}/zlib/include)
 set(ZLIB_LIBRARY ${LIBDIR}/zlib/lib/libz_st.lib)
 set(ZLIB_DIR ${LIBDIR}/zlib)
 
-windows_find_package(zlib) # we want to find before finding things that depend on it like png
-windows_find_package(png)
-
+windows_find_package(ZLIB) # we want to find before finding things that depend on it like png
+windows_find_package(PNG)
 if(NOT PNG_FOUND)
   warn_hardcoded_paths(libpng)
   set(PNG_PNG_INCLUDE_DIR ${LIBDIR}/png/include)
@@ -313,9 +314,9 @@ if(NOT PNG_FOUND)
 endif()
 
 set(JPEG_NAMES ${JPEG_NAMES} libjpeg)
-windows_find_package(jpeg REQUIRED)
+windows_find_package(JPEG REQUIRED)
 if(NOT JPEG_FOUND)
-  warn_hardcoded_paths(jpeg)
+  warn_hardcoded_paths(libjpeg)
   set(JPEG_INCLUDE_DIR ${LIBDIR}/jpeg/include)
   set(JPEG_LIBRARIES ${LIBDIR}/jpeg/lib/libjpeg.lib)
 endif()
@@ -333,7 +334,7 @@ set(FREETYPE_LIBRARIES
   ${LIBDIR}/brotli/lib/brotlidec-static.lib
   ${LIBDIR}/brotli/lib/brotlicommon-static.lib
 )
-windows_find_package(freetype REQUIRED)
+windows_find_package(Freetype REQUIRED)
 
 if(WITH_FFTW3)
   set(FFTW3 ${LIBDIR}/fftw3)
@@ -389,9 +390,9 @@ if(WITH_CODEC_FFMPEG)
     ${LIBDIR}/ffmpeg/include
     ${LIBDIR}/ffmpeg/include/msvc
   )
-  windows_find_package(FFMPEG)
+  windows_find_package(FFmpeg)
   if(NOT FFMPEG_FOUND)
-    warn_hardcoded_paths(ffmpeg)
+    warn_hardcoded_paths(FFmpeg)
     set(FFMPEG_LIBRARIES
       ${LIBDIR}/ffmpeg/lib/avcodec.lib
       ${LIBDIR}/ffmpeg/lib/avformat.lib
@@ -403,10 +404,10 @@ if(WITH_CODEC_FFMPEG)
 endif()
 
 if(WITH_IMAGE_OPENEXR)
-  set(OPENEXR_ROOT_DIR ${LIBDIR}/openexr)
-  set(OPENEXR_VERSION "2.1")
-  windows_find_package(OPENEXR REQUIRED)
+  windows_find_package(OpenEXR REQUIRED)
   if(NOT OPENEXR_FOUND)
+    set(OPENEXR_ROOT_DIR ${LIBDIR}/openexr)
+    set(OPENEXR_VERSION "2.1")
     warn_hardcoded_paths(OpenEXR)
     set(OPENEXR ${LIBDIR}/openexr)
     set(OPENEXR_INCLUDE_DIR ${OPENEXR}/include)
@@ -624,21 +625,23 @@ if(WITH_IMAGE_OPENJPEG)
 endif()
 
 if(WITH_OPENSUBDIV)
-  set(OPENSUBDIV_INCLUDE_DIRS ${LIBDIR}/opensubdiv/include)
-  set(OPENSUBDIV_LIBPATH ${LIBDIR}/opensubdiv/lib)
-  set(OPENSUBDIV_LIBRARIES
-    optimized ${OPENSUBDIV_LIBPATH}/osdCPU.lib
-    optimized ${OPENSUBDIV_LIBPATH}/osdGPU.lib
-    debug ${OPENSUBDIV_LIBPATH}/osdCPU_d.lib
-    debug ${OPENSUBDIV_LIBPATH}/osdGPU_d.lib
-  )
-  set(OPENSUBDIV_HAS_OPENMP TRUE)
-  set(OPENSUBDIV_HAS_TBB FALSE)
-  set(OPENSUBDIV_HAS_OPENCL TRUE)
-  set(OPENSUBDIV_HAS_CUDA FALSE)
-  set(OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK TRUE)
-  set(OPENSUBDIV_HAS_GLSL_COMPUTE TRUE)
   windows_find_package(OpenSubdiv)
+  if (NOT OpenSubdiv_FOUND)
+    set(OPENSUBDIV_INCLUDE_DIRS ${LIBDIR}/opensubdiv/include)
+    set(OPENSUBDIV_LIBPATH ${LIBDIR}/opensubdiv/lib)
+    set(OPENSUBDIV_LIBRARIES
+      optimized ${OPENSUBDIV_LIBPATH}/osdCPU.lib
+      optimized ${OPENSUBDIV_LIBPATH}/osdGPU.lib
+      debug ${OPENSUBDIV_LIBPATH}/osdCPU_d.lib
+      debug ${OPENSUBDIV_LIBPATH}/osdGPU_d.lib
+    )
+    set(OPENSUBDIV_HAS_OPENMP TRUE)
+    set(OPENSUBDIV_HAS_TBB FALSE)
+    set(OPENSUBDIV_HAS_OPENCL TRUE)
+    set(OPENSUBDIV_HAS_CUDA FALSE)
+    set(OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK TRUE)
+    set(OPENSUBDIV_HAS_GLSL_COMPUTE TRUE)
+  endif()
 endif()
 
 if(WITH_SDL)
@@ -659,12 +662,15 @@ if(WITH_SYSTEM_AUDASPACE)
 endif()
 
 if(WITH_TBB)
-  set(TBB_LIBRARIES optimized ${LIBDIR}/tbb/lib/tbb.lib debug ${LIBDIR}/tbb/lib/tbb_debug.lib)
-  set(TBB_INCLUDE_DIR ${LIBDIR}/tbb/include)
-  set(TBB_INCLUDE_DIRS ${TBB_INCLUDE_DIR})
-  if(WITH_TBB_MALLOC_PROXY)
-    set(TBB_MALLOC_LIBRARIES optimized ${LIBDIR}/tbb/lib/tbbmalloc.lib debug ${LIBDIR}/tbb/lib/tbbmalloc_debug.lib)
-    add_definitions(-DWITH_TBB_MALLOC)
+  windows_find_package(TBB)
+  if (NOT TBB_FOUND)
+    set(TBB_LIBRARIES optimized ${LIBDIR}/tbb/lib/tbb.lib debug ${LIBDIR}/tbb/lib/tbb_debug.lib)
+    set(TBB_INCLUDE_DIR ${LIBDIR}/tbb/include)
+    set(TBB_INCLUDE_DIRS ${TBB_INCLUDE_DIR})
+    if(WITH_TBB_MALLOC_PROXY)
+      set(TBB_MALLOC_LIBRARIES optimized ${LIBDIR}/tbb/lib/tbbmalloc.lib debug ${LIBDIR}/tbb/lib/tbbmalloc_debug.lib)
+      add_definitions(-DWITH_TBB_MALLOC)
+    endif()
   endif()
 endif()
 
diff --git a/intern/cycles/CMakeLists.txt b/intern/cycles/CMakeLists.txt
index ad2b5ab4d7b..1cc3dccf426 100644
--- a/intern/cycles/CMakeLists.txt
+++ b/intern/cycles/CMakeLists.txt
@@ -2,8 +2,12 @@
 # Copyright 2011-2022 Blender Foundation
 
 # Standalone or with Blender
-if(NOT WITH_BLENDER AND WITH_CYCLES_STANDALONE)
-  set(CYCLES_INSTALL_PATH ${CMAKE_INSTALL_PREFIX})
+if(NOT WITH_BLENDER)
+  if(WITH_CYCLES_STANDALONE OR NOT WITH_CYCLES_HYDRA_RENDER_DELEGATE)
+    set(CYCLES_INSTALL_PATH ${CMAKE_INSTALL_PREFIX})
+  else()
+    set(CYCLES_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/hdCycles/resources)
+  endif()
 else()
   set(WITH_CYCLES_BLENDER ON)
   # WINDOWS_PYTHON_DEBUG needs to write into the user addons folder since it will
@@ -335,6 +339,11 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_C_COMPILER_ID MATCHES "Clang")
   unset(_has_no_error_unused_macros)
 endif()
 
+if(WITH_CYCLES_HYDRA_RENDER_DELEGATE AND NOT WITH_USD)
+  message(STATUS "USD not found, disabling WITH_CYCLES_HYDRA_RENDER_DELEGATE")
+  set(WITH_CYCLES_HYDRA_RENDER_DELEGATE OFF)
+endif()
+
 if(WITH_CYCLES_CUDA_BINARIES AND (NOT WITH_CYCLES_CUBIN_COMPILER))
   if(MSVC)
     set(MAX_MSVC 1800)
@@ -395,6 +404,10 @@ if(WITH_GTESTS)
   add_subdirectory(test)
 endif()
 
-if(NOT WITH_BLENDER AND WITH_CYCLES_STANDALONE)
+if(WITH_CYCLES_HYDRA_RENDER_DELEGATE)
+  add_subdirectory(hydra)
+endif()
+
+if(NOT WITH_BLENDER)
   delayed_do_install(${CMAKE_BINARY_DIR}/bin)
 endif()
diff --git a/intern/cycles/device/CMakeLists.txt b/intern/cycles/device/CMakeLists.txt
index 670285fb310..d4e12809

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list