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-31 20:27:32 +0300
committerPatrick Mours <pmours@nvidia.com>2022-04-05 18:23:52 +0300
commitf60cffad38d12bdfefe503924e93c33a7c89f671 (patch)
treee741cf808bd41be36f5e5dde6bdd2aa96fcb8eae /intern/cycles/hydra
parent190334b47df46f0e912c873077163e6129e4cbae (diff)
Cycles: Use USD dependencies when building Hydra render delegate
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). Differential Revision: https://developer.blender.org/D14523
Diffstat (limited to 'intern/cycles/hydra')
-rw-r--r--intern/cycles/hydra/CMakeLists.txt39
-rw-r--r--intern/cycles/hydra/camera.cpp15
-rw-r--r--intern/cycles/hydra/config.h1
-rw-r--r--intern/cycles/hydra/field.cpp2
-rw-r--r--intern/cycles/hydra/material.cpp9
-rw-r--r--intern/cycles/hydra/material.h7
-rw-r--r--intern/cycles/hydra/node_util.cpp2
7 files changed, 31 insertions, 44 deletions
diff --git a/intern/cycles/hydra/CMakeLists.txt b/intern/cycles/hydra/CMakeLists.txt
index 703bd955135..d632cd01a02 100644
--- a/intern/cycles/hydra/CMakeLists.txt
+++ b/intern/cycles/hydra/CMakeLists.txt
@@ -91,35 +91,15 @@ target_compile_definitions(hdCyclesStatic
)
target_link_libraries(hdCyclesStatic
+ PUBLIC
+ hd
+ hgi
PRIVATE
- ${USD_LIBRARY_DIR}/${PXR_LIB_PREFIX}hd${CMAKE_LINK_LIBRARY_SUFFIX}
- ${USD_LIBRARY_DIR}/${PXR_LIB_PREFIX}plug${CMAKE_LINK_LIBRARY_SUFFIX}
- ${USD_LIBRARY_DIR}/${PXR_LIB_PREFIX}tf${CMAKE_LINK_LIBRARY_SUFFIX}
- ${USD_LIBRARY_DIR}/${PXR_LIB_PREFIX}trace${CMAKE_LINK_LIBRARY_SUFFIX}
- ${USD_LIBRARY_DIR}/${PXR_LIB_PREFIX}vt${CMAKE_LINK_LIBRARY_SUFFIX}
- ${USD_LIBRARY_DIR}/${PXR_LIB_PREFIX}work${CMAKE_LINK_LIBRARY_SUFFIX}
- ${USD_LIBRARY_DIR}/${PXR_LIB_PREFIX}sdf${CMAKE_LINK_LIBRARY_SUFFIX}
- ${USD_LIBRARY_DIR}/${PXR_LIB_PREFIX}cameraUtil${CMAKE_LINK_LIBRARY_SUFFIX}
- ${USD_LIBRARY_DIR}/${PXR_LIB_PREFIX}hf${CMAKE_LINK_LIBRARY_SUFFIX}
- ${USD_LIBRARY_DIR}/${PXR_LIB_PREFIX}pxOsd${CMAKE_LINK_LIBRARY_SUFFIX}
- ${USD_LIBRARY_DIR}/${PXR_LIB_PREFIX}gf${CMAKE_LINK_LIBRARY_SUFFIX}
- ${USD_LIBRARY_DIR}/${PXR_LIB_PREFIX}arch${CMAKE_LINK_LIBRARY_SUFFIX}
- ${USD_LIBRARY_DIR}/${PXR_LIB_PREFIX}hgi${CMAKE_LINK_LIBRARY_SUFFIX}
- ${USD_LIBRARY_DIR}/${PXR_LIB_PREFIX}glf${CMAKE_LINK_LIBRARY_SUFFIX}
- ${USD_LIBRARY_DIR}/${PXR_LIB_PREFIX}hdx${CMAKE_LINK_LIBRARY_SUFFIX}
- ${USD_LIBRARY_DIR}/${PXR_LIB_PREFIX}usdGeom${CMAKE_LINK_LIBRARY_SUFFIX}
cycles_scene
cycles_session
cycles_graph
)
-if(USD_PYTHON_LIBRARIES)
- target_link_libraries(hdCyclesStatic
- PRIVATE
- ${USD_PYTHON_LIBRARIES}
- )
-endif()
-
set(HdCyclesPluginName hdCycles)
add_library(${HdCyclesPluginName} SHARED
plugin.h
@@ -144,12 +124,6 @@ target_link_libraries(${HdCyclesPluginName}
hdCyclesStatic
)
-target_link_directories(${HdCyclesPluginName}
- BEFORE
- PRIVATE
- ${USD_LIBRARY_DIR}
-)
-
cycles_target_link_libraries(${HdCyclesPluginName})
if(WITH_CYCLES_BLENDER)
@@ -162,9 +136,10 @@ endif()
delayed_install("" $<TARGET_FILE:${HdCyclesPluginName}> ${CYCLES_HYDRA_INSTALL_PATH})
-set(PLUG_INFO_ROOT "..")
-set(PLUG_INFO_LIBRARY_PATH "../${HdCyclesPluginName}${CMAKE_SHARED_LIBRARY_SUFFIX}")
-set(PLUG_INFO_RESOURCE_PATH "resources")
+set(PLUG_INFO_ROOT "..")
+
+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}")
configure_file(resources/plugInfo.json
${CMAKE_CURRENT_BINARY_DIR}/resources/plugInfo.json
diff --git a/intern/cycles/hydra/camera.cpp b/intern/cycles/hydra/camera.cpp
index 05f1c32d3c4..5d961a6a090 100644
--- a/intern/cycles/hydra/camera.cpp
+++ b/intern/cycles/hydra/camera.cpp
@@ -13,6 +13,15 @@ HDCYCLES_NAMESPACE_OPEN_SCOPE
extern Transform convert_transform(const GfMatrix4d &matrix);
+#if PXR_VERSION < 2102
+// clang-format off
+TF_DEFINE_PRIVATE_TOKENS(_tokens,
+ (projection)
+ (orthographic)
+);
+// clang-format on
+#endif
+
HdCyclesCamera::HdCyclesCamera(const SdfPath &sprimId) : HdCamera(sprimId)
{
#if PXR_VERSION >= 2102
@@ -73,6 +82,7 @@ void HdCyclesCamera::Sync(HdSceneDelegate *sceneDelegate,
}
#endif
+#if PXR_VERSION < 2111
if (*dirtyBits & DirtyBits::DirtyProjMatrix) {
value = sceneDelegate->GetCameraParamValue(id, HdCameraTokens->projectionMatrix);
if (!value.IsEmpty()) {
@@ -113,6 +123,7 @@ void HdCyclesCamera::Sync(HdSceneDelegate *sceneDelegate,
#endif
}
}
+#endif
if (*dirtyBits & DirtyBits::DirtyWindowPolicy) {
value = sceneDelegate->GetCameraParamValue(id, HdCameraTokens->windowPolicy);
@@ -137,9 +148,9 @@ void HdCyclesCamera::Sync(HdSceneDelegate *sceneDelegate,
GfCamera::Orthographic);
}
#else
- value = sceneDelegate->GetCameraParamValue(id, UsdGeomTokens->projection);
+ value = sceneDelegate->GetCameraParamValue(id, _tokens->projection);
if (!value.IsEmpty()) {
- _data.SetProjection(value.Get<TfToken>() != UsdGeomTokens->orthographic ?
+ _data.SetProjection(value.Get<TfToken>() != _tokens->orthographic ?
GfCamera::Perspective :
GfCamera::Orthographic);
}
diff --git a/intern/cycles/hydra/config.h b/intern/cycles/hydra/config.h
index 034be302d9f..479980e0c11 100644
--- a/intern/cycles/hydra/config.h
+++ b/intern/cycles/hydra/config.h
@@ -40,5 +40,6 @@ class Session;
class SessionParams;
class Shader;
class ShaderGraph;
+class ShaderNode;
class Volume;
} // namespace CCL_NS
diff --git a/intern/cycles/hydra/field.cpp b/intern/cycles/hydra/field.cpp
index 8b92ddb6f1f..67945be9d52 100644
--- a/intern/cycles/hydra/field.cpp
+++ b/intern/cycles/hydra/field.cpp
@@ -12,11 +12,13 @@
HDCYCLES_NAMESPACE_OPEN_SCOPE
+#if PXR_VERSION < 2108
// clang-format off
TF_DEFINE_PRIVATE_TOKENS(_tokens,
(fieldName)
);
// clang-format on
+#endif
#ifdef WITH_OPENVDB
class HdCyclesVolumeLoader : public VDBImageLoader {
diff --git a/intern/cycles/hydra/material.cpp b/intern/cycles/hydra/material.cpp
index a595102a605..b296d9f3751 100644
--- a/intern/cycles/hydra/material.cpp
+++ b/intern/cycles/hydra/material.cpp
@@ -40,8 +40,6 @@ TF_DEFINE_PRIVATE_TOKENS(CyclesMaterialTokens,
);
// clang-format on
-namespace {
-
// Simple class to handle remapping of USDPreviewSurface nodes and parameters to Cycles equivalents
class UsdToCyclesMapping {
using ParamMap = std::unordered_map<TfToken, ustring, TfToken::HashFunctor>;
@@ -130,6 +128,8 @@ class UsdToCyclesTexture : public UsdToCyclesMapping {
}
};
+namespace {
+
class UsdToCycles {
const UsdToCyclesMapping UsdPreviewSurface = {
"principled_bsdf",
@@ -183,11 +183,6 @@ TfStaticData<UsdToCycles> sUsdToCyles;
} // namespace
-struct HdCyclesMaterial::NodeDesc {
- ShaderNode *node;
- const UsdToCyclesMapping *mapping;
-};
-
HdCyclesMaterial::HdCyclesMaterial(const SdfPath &sprimId) : HdMaterial(sprimId)
{
}
diff --git a/intern/cycles/hydra/material.h b/intern/cycles/hydra/material.h
index 15925671bb8..5e08fd5c99e 100644
--- a/intern/cycles/hydra/material.h
+++ b/intern/cycles/hydra/material.h
@@ -34,9 +34,12 @@ class HdCyclesMaterial final : public PXR_NS::HdMaterial {
return _shader;
}
- struct NodeDesc;
-
private:
+ struct NodeDesc {
+ CCL_NS::ShaderNode *node;
+ const class UsdToCyclesMapping *mapping;
+ };
+
void Initialize(PXR_NS::HdRenderParam *renderParam);
void UpdateParameters(NodeDesc &nodeDesc,
diff --git a/intern/cycles/hydra/node_util.cpp b/intern/cycles/hydra/node_util.cpp
index c7e49688f5c..bdf5786ed75 100644
--- a/intern/cycles/hydra/node_util.cpp
+++ b/intern/cycles/hydra/node_util.cpp
@@ -273,7 +273,7 @@ template<typename MatrixArray> array<Transform> convertToCyclesTransformArray(co
array<Transform> cyclesArray;
cyclesArray.reserve(valueData.size());
for (const auto &element : valueData) {
- cyclesArray.push_back_reserved(convertMatrixToCycles<MatrixArray::value_type>(element));
+ cyclesArray.push_back_reserved(convertMatrixToCycles<typename MatrixArray::value_type>(element));
}
return cyclesArray;
}