Page MenuHome

Cycles: Use USD dependencies when building Hydra render delegate
ClosedPublic

Authored by Patrick Mours (pmoursnv) on Apr 1 2022, 11:01 PM.

Details

Summary

Adds support for linking with some of the dependencies of a USD
build instead of the precompiled libraries from Blender, specifically
OpenSubdiv, OpenVDB and TBB. Other dependencies keep using the
precompiled libraries from Blender, since they are linked statically
anyway so it does't matter as much. Plus they have interdependencies
that are difficult to resolve when only using selected libraries from
the USD build and can't simply assume that USD was built with all
of them.

This patch also makes building the Hydra render delegate via the
standalone repository work and fixes various small issues I ran into
in general on Windows (e.g. the use of both fixed paths and
find_package did not seem to work correctly). Building both the
standalone Cycles application and the Hydra render delegate at the
same time is supported now as well (the paths in the USD plugin JSON
file are updated accordingly).

All that needs to be done now to build is to specify a PXR_ROOT
or USD_ROOT CMake variable pointing to the USD installation,
everything else is taken care of automatically (CMake targets are
loaded from the pxrTargets.cmake of USD and linked into the
render delegate and OpenSubdiv, OpenVDB and TBB are replaced
with those from USD when they exist).
I have tested building this way with various USD builds (both with
and without Python) on Windows and Linux and via both the Blender
repository and the standalone Cycles repository.

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./bin -DWITH_BLENDER=OFF -DWITH_CYCLES_HYDRA_RENDER_DELEGATE=ON -DPXR_ROOT=/usr/local/USD -DCMAKE_POSITION_INDEPENDENT_CODE=ON ..

Diff Detail

Repository
rB Blender
Branch
cycles_hydra_build (branched from master)
Build Status
Buildable 21415
Build 21415: arc lint + arc unit

Event Timeline

Patrick Mours (pmoursnv) requested review of this revision.Apr 1 2022, 11:01 PM
Patrick Mours (pmoursnv) created this revision.
intern/cycles/CMakeLists.txt
225

Moving this up here is not the cleanest solution but ensures that the OpenEXR include directory from the precompiled libraries comes before the USD include directory, so that the OpenEXR headers from the former are picked rather those from the latter (if the latter contains any).

262

Not strictly needed for this patch, just a warning fix (and could also be interesting if somebody wants to build with a shared library Embree). This is already defined by rtcore_config.h, so defining it here again causes a warning due to redefinition. Same with OIDN_STATIC_LIB below (in OpenImageDenoise/config.h).

intern/cycles/cmake/external_libs.cmake
332

Note, these changes to external_libs.cmake (apart from the pxr stuff) are mostly just copied from Blenders platform_win32.cmake.

557

(This wasn't intentional, just was hiding whitespace changes when viewing the diff so missed this.)

Brecht Van Lommel (brecht) requested changes to this revision.Apr 4 2022, 4:46 PM

Great work, thanks.

intern/cycles/cmake/external_libs.cmake
97

Should this be set(WITH_CYCLES_HYDRA_RENDER_DELEGATE OFF)?

And it would then be good to also add:

message(WARNING "USD not found, disabling WITH_CYCLES_HYDRA_RENDER_DELEGATE")
This revision now requires changes to proceed.Apr 4 2022, 4:46 PM
intern/cycles/cmake/external_libs.cmake
97

This is already done by intern/cycles/CMakeLists.txt line 335 which is why this disables WITH_USD ;)

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()

(intern/cycles/cmake/external_libs.cmake is included before this bit)

Ah indeed.

I ran this patch on the buildbot to check if it breaks a regular Blender build on any platform, it was fine.

This revision is now accepted and ready to land.Apr 4 2022, 8:23 PM

Just judging the build system changes, i see nothing concerning, i had also verified this does not break the bots, so I'll accept with a warning: with the changes coming in 3.2 for the libs, some of what this diff does may need a touch-up when those land.