blender/intern/cycles/hydra/CMakeLists.txt
Brecht Van Lommel 51977de03a Cycles: Hydra: Change render delegate to use Hydra 2.0 API
The 1.0 API is deprecated (though not yet removed) in OpenUSD 26.xx
releases. So it's time to migrate.

Use of the HdSceneDelegate is mostly removed, except for retrieving the
prims. Specific properties of prims are retrieved through schemas rather
than querying the scene delegate.

The full replacement of HdSceneDelegate is still ongoing in USD itself.
In the very latest 26.05 only HdPrman has an experimental option for
using the scene index directly, but for example HdStorm does not use it
yet. So removing it's use with the current 25.08 in Blender is not
expected to be stable enough.

Additionally HdRenderer is supposed to replace HdRenderDelegate and its
handling of tasks. However even in 26.05 that is only a stub
implementation so there is no actual alternative to migrate to.

Note that OpenUSD provides a compatibility layer so 1.0 and 2.0 hosts and
render delegates can work together. Which means ideally everything keeps
working the same, but there are likely some differences anyway. Support for
OpenUSD version 23.xx and older was dropped.

Pull Request: https://projects.blender.org/blender/blender/pulls/158456
2026-05-27 15:56:20 +02:00

205 lines
5 KiB
CMake

# SPDX-FileCopyrightText: 2022 Blender Foundation
#
# SPDX-License-Identifier: Apache-2.0
#####################################################################
# Cycles Hydra render delegate
#####################################################################
set(INC
..
)
set(INC_SYS
)
set(LIB
cycles_scene
cycles_session
cycles_graph
bf::dependencies::epoxy
)
cycles_external_libraries_append(LIB)
set(SRC_HD_CYCLES_HEADERS
camera.h
config.h
curves.h
field.h
file_reader.h
geometry.h
geometry.inl
instancer.h
light.h
material.h
mesh.h
node_util.h
output_driver.h
pointcloud.h
render_buffer.h
render_delegate.h
render_pass.h
session.h
util.h
volume.h
)
set(SRC_HD_CYCLES
curves.cpp
camera.cpp
field.cpp
file_reader.cpp
geometry.cpp
instancer.cpp
light.cpp
material.cpp
mesh.cpp
node_util.cpp
output_driver.cpp
pointcloud.cpp
render_buffer.cpp
render_delegate.cpp
render_pass.cpp
session.cpp
util.cpp
volume.cpp
)
# Blender libraries do not include hgiGL, so build without display driver then.
if(EXISTS ${USD_INCLUDE_DIR}/pxr/imaging/hgiGL)
add_definitions(-DWITH_HYDRA_DISPLAY_DRIVER)
list(APPEND SRC_HD_CYCLES display_driver.cpp)
list(APPEND SRC_HD_CYCLES_HEADERS display_driver.h)
endif()
# Silence warning from USD headers using deprecated TBB header.
add_definitions(
-D__TBB_show_deprecation_message_atomic_H
-D__TBB_show_deprecation_message_task_H
)
include_directories(${INC})
include_directories(SYSTEM ${INC_SYS})
add_library(cycles_hydra STATIC
${SRC_HD_CYCLES}
${SRC_HD_CYCLES_HEADERS}
)
target_compile_options(cycles_hydra
PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:/wd4003 /wd4244 /wd4506>
$<$<CXX_COMPILER_ID:GNU>:-Wno-float-conversion -Wno-double-promotion -Wno-deprecated>
)
target_compile_definitions(cycles_hydra
PRIVATE
GLOG_NO_ABBREVIATED_SEVERITIES=1
OSL_DEBUG=$<CONFIG:DEBUG>
TBB_USE_DEBUG=$<CONFIG:DEBUG>
$<$<CXX_COMPILER_ID:MSVC>:NOMINMAX=1>
)
target_link_libraries(cycles_hydra
PUBLIC
bf::dependencies::openimageio
bf::dependencies::optional::tbb
bf::dependencies::optional::usd
bf::dependencies::optional::python
PRIVATE
${LIB}
)
if(WITH_CYCLES_HYDRA_RENDER_DELEGATE)
set(SRC_HD_CYCLES_PLUGIN
plugin.h
plugin.cpp
)
set(HdCyclesPluginName hdCycles)
add_library(${HdCyclesPluginName} SHARED ${SRC_HD_CYCLES_PLUGIN})
set_target_properties(${HdCyclesPluginName}
PROPERTIES PREFIX ""
)
target_compile_definitions(${HdCyclesPluginName}
PRIVATE
MFB_PACKAGE_NAME=${HdCyclesPluginName}
MFB_ALT_PACKAGE_NAME=${HdCyclesPluginName}
GLOG_NO_ABBREVIATED_SEVERITIES=1
OSL_DEBUG=$<CONFIG:DEBUG>
TBB_USE_DEBUG=$<CONFIG:DEBUG>
$<$<CXX_COMPILER_ID:MSVC>:NOMINMAX=1>
)
target_link_libraries(${HdCyclesPluginName}
cycles_hydra
)
if(APPLE)
set_property(
TARGET
${HdCyclesPluginName}
APPEND_STRING PROPERTY LINK_FLAGS
" -Wl,-exported_symbols_list,'${CMAKE_CURRENT_SOURCE_DIR}/resources/apple_symbols.map'"
)
elseif(UNIX)
set_property(
TARGET
${HdCyclesPluginName}
APPEND_STRING PROPERTY LINK_FLAGS
" -Wl,--version-script='${CMAKE_CURRENT_SOURCE_DIR}/resources/linux_symbols.map'"
)
endif()
if(WITH_CYCLES_BLENDER)
# Install inside add-on
set(CYCLES_HYDRA_INSTALL_PATH ${CYCLES_INSTALL_PATH}/hydra)
else()
# Install next to cycles executable
set(CYCLES_HYDRA_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/hydra)
endif()
# Put the root `plugInfo.json` one level up.
delayed_install("${CMAKE_CURRENT_SOURCE_DIR}" "plugInfo.json" ${CYCLES_HYDRA_INSTALL_PATH})
delayed_install("" $<TARGET_FILE:${HdCyclesPluginName}> ${CYCLES_HYDRA_INSTALL_PATH})
set_target_properties(${HdCyclesPluginName}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set(PLUG_INFO_ROOT "..")
if(WITH_CYCLES_BLENDER)
# Full path not yet known at this point and RELATIVE_PATH requires
# absolute path as input. So just set manually.
set(PLUG_INFO_LIBRARY_PATH "../${HdCyclesPluginName}${CMAKE_SHARED_LIBRARY_SUFFIX}")
set(PLUG_INFO_RESOURCE_PATH "../..")
else()
file(RELATIVE_PATH
PLUG_INFO_LIBRARY_PATH
"${CYCLES_HYDRA_INSTALL_PATH}/${HdCyclesPluginName}"
"${CYCLES_HYDRA_INSTALL_PATH}/${HdCyclesPluginName}${CMAKE_SHARED_LIBRARY_SUFFIX}")
file(RELATIVE_PATH PLUG_INFO_RESOURCE_PATH
"${CYCLES_HYDRA_INSTALL_PATH}/${HdCyclesPluginName}"
"${CYCLES_INSTALL_PATH}")
endif()
configure_file(resources/plugInfo.json
${CMAKE_CURRENT_BINARY_DIR}/resources/plugInfo.json
@ONLY
)
delayed_install("${CMAKE_CURRENT_BINARY_DIR}/resources" "plugInfo.json" "${CYCLES_HYDRA_INSTALL_PATH}/${HdCyclesPluginName}/resources")
if(WITH_CYCLES_BLENDER)
get_filename_component(_addons_core_dir "${CYCLES_INSTALL_PATH}" DIRECTORY)
delayed_install(
"${CMAKE_CURRENT_SOURCE_DIR}/addon"
"__init__.py"
"${_addons_core_dir}/hydra_cycles"
)
unset(_addons_core_dir)
endif()
endif()