Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Mours <pmours@nvidia.com>2022-03-21 12:58:51 +0300
committerPatrick Mours <pmours@nvidia.com>2022-03-21 15:23:25 +0300
commit08e719910bf2065ef0603cba8cc43ea236b2d090 (patch)
tree59894e7421aaec73691e653d5cc173ce12effbb3 /build_files/cmake
parent9ed63ebb458141661bcbfe81c187f843e9dcbacf (diff)
Cycles: Add Hydra render delegate
This patch adds a [Hydra](https://graphics.pixar.com/usd/release/glossary.html#usdglossary-hydra) render delegate to Cycles, allowing Cycles to be used for rendering in applications that provide a Hydra viewport (e.g. USDView or NVIDIA Omniverse Kit). 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. Supported features: - CPU/CUDA/OptiX/HIP/Metal support - Camera Settings - Render Settings (automatically queried from Cycles via node type system) - Basic AOVs (color, depth, normal, primId, instanceId) - Lights (Disk, Distant, Dome, Rect, Sphere) - Meshes - Geom Subsets - Subdivision Surfaces (using native Cycles support) - Custom Primvars (converted to Cycles attributes) - Cycles Materials (can be exported to USD using the [universal-scene-description branch of Blender](https://developer.blender.org/diffusion/B/history/universal-scene-description/)) - USD Preview Surface Materials - Curves - Point Clouds - OpenVDB Volumes Still missing features: - Motion Blur - Custom AOVs - ... 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). This also includes an optimization for Hydra viewports that display the result using OpenGL, in which case the texture can be kept entirely on the GPU (see display_driver.cpp). Unfortunately this is a bit difficult since Hydra doesn't give any control over the OpenGL context created by an application, so the only way to make it available to Cycles (which is rendering on a separate thread) without disturbing the target application is to create a second OpenGL context that is sharing resources with the primary one. The USD SDK doesn't provide an API to do so, and can't use Blenders Ghost since the render delegate is built without Blender, so have to create it manualy. That is only implemented for Windows right now, so on Linux the optimization is disabled (see `HdCyclesDelegate::IsDisplaySupported()`). --- **To build:** 1. [Set up a Blender build environment](https://wiki.blender.org/wiki/Building_Blender) as usual but download and apply this patch to the Git repository (Download Raw Diff on the right via `Save Link As` and then run `git apply patch.diff` with the downloaded file in your local repository after syncing to latest master branch). 2. Set these CMake variables: ``` WITH_BLENDER=0 WITH_CYCLES_HYDRA_RENDER_DELEGATE=1 USD_INCLUDE_DIRS=<path to your USD build>/include USD_LIBRARY_DIR=<path to your USD build>/lib USD_LIBRARY_PREFIX=<optional, if e.g. USD libs are called "usd_hd.lib", set to "usd_"> ``` 3. Continue following the usual Blender build instructions. After building the INSTALL target, the output directory contains the `hdCycles` shared library and associated resource files which can be loaded as a USD plugin. **To execute:** 4. Copy `hdCycles.dll`/`hdCycles.a` and the `hdCycles` directory from the output directory to the USD plugin directory of the target application, or point a `PXR_PLUGINPATH_NAME` environment variable to the output directory. 5. Launch the target application, it should now automatically detect the Cycles Hydra render delegate. Differential Revision: https://developer.blender.org/D14398
Diffstat (limited to 'build_files/cmake')
-rw-r--r--build_files/cmake/Modules/FindUSD.cmake82
-rw-r--r--build_files/cmake/macros.cmake2
-rw-r--r--build_files/cmake/platform/platform_win32.cmake101
3 files changed, 106 insertions, 79 deletions
diff --git a/build_files/cmake/Modules/FindUSD.cmake b/build_files/cmake/Modules/FindUSD.cmake
index 840fa2d538f..c8c1f043b63 100644
--- a/build_files/cmake/Modules/FindUSD.cmake
+++ b/build_files/cmake/Modules/FindUSD.cmake
@@ -17,50 +17,60 @@ IF(NOT USD_ROOT_DIR AND NOT $ENV{USD_ROOT_DIR} STREQUAL "")
SET(USD_ROOT_DIR $ENV{USD_ROOT_DIR})
ENDIF()
-SET(_usd_SEARCH_DIRS
- ${USD_ROOT_DIR}
- /opt/lib/usd
-)
+find_package(pxr REQUIRED OFF)
-FIND_PATH(USD_INCLUDE_DIR
- NAMES
- pxr/usd/usd/api.h
- HINTS
- ${_usd_SEARCH_DIRS}
- PATH_SUFFIXES
- include
- DOC "Universal Scene Description (USD) header files"
-)
+if (NOT pxr_FOUND)
-FIND_LIBRARY(USD_LIBRARY
- NAMES
- usd_m usd_ms
- NAMES_PER_DIR
- HINTS
- ${_usd_SEARCH_DIRS}
- PATH_SUFFIXES
- lib64 lib lib/static
- DOC "Universal Scene Description (USD) monolithic library"
-)
+ SET(_usd_SEARCH_DIRS
+ ${USD_ROOT_DIR}
+ /opt/lib/usd
+ )
-IF(${USD_LIBRARY_NOTFOUND})
- set(USD_FOUND FALSE)
-ELSE()
- # handle the QUIETLY and REQUIRED arguments and set USD_FOUND to TRUE if
- # all listed variables are TRUE
- INCLUDE(FindPackageHandleStandardArgs)
- FIND_PACKAGE_HANDLE_STANDARD_ARGS(USD DEFAULT_MSG USD_LIBRARY USD_INCLUDE_DIR)
+ FIND_PATH(USD_INCLUDE_DIR
+ NAMES
+ pxr/usd/usd/api.h
+ HINTS
+ ${_usd_SEARCH_DIRS}
+ PATH_SUFFIXES
+ include
+ DOC "Universal Scene Description (USD) header files"
+ )
+
+ FIND_LIBRARY(USD_LIBRARY
+ NAMES
+ usd_m usd_ms
+ NAMES_PER_DIR
+ HINTS
+ ${_usd_SEARCH_DIRS}
+ PATH_SUFFIXES
+ lib64 lib lib/static
+ DOC "Universal Scene Description (USD) monolithic library"
+ )
- IF(USD_FOUND)
- get_filename_component(USD_LIBRARY_DIR ${USD_LIBRARY} DIRECTORY)
- SET(USD_INCLUDE_DIRS ${USD_INCLUDE_DIR})
- set(USD_LIBRARIES ${USD_LIBRARY})
+ IF(${USD_LIBRARY_NOTFOUND})
+ set(USD_FOUND FALSE)
+ ELSE()
+ # handle the QUIETLY and REQUIRED arguments and set USD_FOUND to TRUE if
+ # all listed variables are TRUE
+ INCLUDE(FindPackageHandleStandardArgs)
+ FIND_PACKAGE_HANDLE_STANDARD_ARGS(USD DEFAULT_MSG USD_LIBRARY USD_INCLUDE_DIR)
+
+ IF(USD_FOUND)
+ get_filename_component(USD_LIBRARY_DIR ${USD_LIBRARY} DIRECTORY)
+ SET(USD_INCLUDE_DIRS ${USD_INCLUDE_DIR})
+ set(USD_LIBRARIES ${USD_LIBRARY})
+ ENDIF()
ENDIF()
+
+ UNSET(_usd_SEARCH_DIRS)
+
+ELSE()
+ SET(USD_FOUND ON)
+ SET(USD_INCLUDE_DIR ${PXR_INCLUDE_DIRS})
+ SET(USD_LIBRARIES ${PXR_LIBRARIES})
ENDIF()
MARK_AS_ADVANCED(
USD_INCLUDE_DIR
USD_LIBRARY_DIR
)
-
-UNSET(_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..ec0c83195e9 100644
--- a/build_files/cmake/platform/platform_win32.cmake
+++ b/build_files/cmake/platform/platform_win32.cmake
@@ -39,7 +39,7 @@ 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()
@@ -252,6 +252,12 @@ 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)
+ elseif(MSVC_VERSION EQUAL 1900)
+ message(STATUS "Visual Studio 2015 detected.")
+ set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_BASE}_vc15)
endif()
else()
message(STATUS "Using pre-compiled LIBDIR: ${LIBDIR}")
@@ -403,10 +409,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)
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)
@@ -462,15 +468,17 @@ if(WITH_PYTHON)
endif()
if(WITH_BOOST)
- if(WITH_CYCLES AND WITH_CYCLES_OSL)
+ if(WITH_CYCLES_OSL)
set(boost_extra_libs wave)
endif()
- if(WITH_INTERNATIONAL)
- list(APPEND boost_extra_libs locale)
+ if(WITH_BLENDER)
+ if(WITH_INTERNATIONAL)
+ list(APPEND boost_extra_libs locale)
+ endif()
+ set(Boost_USE_STATIC_RUNTIME ON) # prefix lib
+ set(Boost_USE_MULTITHREADED ON) # suffix -mt
+ set(Boost_USE_STATIC_LIBS ON) # suffix -s
endif()
- set(Boost_USE_STATIC_RUNTIME ON) # prefix lib
- set(Boost_USE_MULTITHREADED ON) # suffix -mt
- set(Boost_USE_STATIC_LIBS ON) # suffix -s
if(WITH_WINDOWS_FIND_MODULES)
find_package(Boost COMPONENTS date_time filesystem thread regex system ${boost_extra_libs})
endif()
@@ -505,7 +513,7 @@ if(WITH_BOOST)
debug ${BOOST_LIBPATH}/libboost_thread-${BOOST_DEBUG_POSTFIX}
debug ${BOOST_LIBPATH}/libboost_chrono-${BOOST_DEBUG_POSTFIX}
)
- if(WITH_CYCLES AND WITH_CYCLES_OSL)
+ if(WITH_CYCLES_OSL)
set(BOOST_LIBRARIES ${BOOST_LIBRARIES}
optimized ${BOOST_LIBPATH}/libboost_wave-${BOOST_POSTFIX}
debug ${BOOST_LIBPATH}/libboost_wave-${BOOST_DEBUG_POSTFIX})
@@ -624,21 +632,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 +669,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()
@@ -693,7 +706,7 @@ if(WITH_CODEC_SNDFILE)
set(LIBSNDFILE_LIBRARIES ${LIBSNDFILE_LIBPATH}/libsndfile-1.lib)
endif()
-if(WITH_CYCLES AND WITH_CYCLES_OSL)
+if(WITH_CYCLES_OSL)
set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation")
set(OSL_SHADER_DIR ${CYCLES_OSL}/shaders)
# Shaders have moved around a bit between OSL versions, check multiple locations
@@ -726,7 +739,7 @@ if(WITH_CYCLES AND WITH_CYCLES_OSL)
endif()
endif()
-if(WITH_CYCLES AND WITH_CYCLES_EMBREE)
+if(WITH_CYCLES_EMBREE)
windows_find_package(Embree)
if(NOT EMBREE_FOUND)
set(EMBREE_INCLUDE_DIRS ${LIBDIR}/embree/include)
@@ -754,17 +767,21 @@ if(WITH_CYCLES AND WITH_CYCLES_EMBREE)
endif()
if(WITH_USD)
- windows_find_package(USD)
- if(NOT USD_FOUND)
+ if(USD_INCLUDE_DIRS AND USD_LIBRARY_DIR)
set(USD_FOUND ON)
- set(USD_INCLUDE_DIRS ${LIBDIR}/usd/include)
- set(USD_RELEASE_LIB ${LIBDIR}/usd/lib/libusd_m.lib)
- set(USD_DEBUG_LIB ${LIBDIR}/usd/lib/libusd_m_d.lib)
- set(USD_LIBRARY_DIR ${LIBDIR}/usd/lib)
- set(USD_LIBRARIES
- debug ${USD_DEBUG_LIB}
- optimized ${USD_RELEASE_LIB}
- )
+ else()
+ windows_find_package(USD)
+ if(NOT USD_FOUND)
+ set(USD_FOUND ON)
+ set(USD_INCLUDE_DIRS ${LIBDIR}/usd/include)
+ set(USD_RELEASE_LIB ${LIBDIR}/usd/lib/libusd_m.lib)
+ set(USD_DEBUG_LIB ${LIBDIR}/usd/lib/libusd_m_d.lib)
+ set(USD_LIBRARY_DIR ${LIBDIR}/usd/lib)
+ set(USD_LIBRARIES
+ debug ${USD_DEBUG_LIB}
+ optimized ${USD_RELEASE_LIB}
+ )
+ endif()
endif()
endif()