Skip to content

Commit

Permalink
Removing BUILD_HOUDINI_TOOLS and all associated documentation from th…
Browse files Browse the repository at this point in the history
…e build and codebase (#118)

* Removing BUILD_HOUDINI_TOOLS and all associated documentation from the build and codebase.
Fixes #114

* Renaming houdini related functions, types and variables.

* Adding comments to explain the Houdini specific code in volume.cpp.
  • Loading branch information
sirpalee authored and kikou committed Jan 8, 2020
1 parent 3bec9e1 commit 5bfcc41
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 48 deletions.
2 changes: 0 additions & 2 deletions SConstruct
Expand Up @@ -95,7 +95,6 @@ vars.AddVariables(
BoolVariable('BUILD_PROCEDURAL', 'Whether or not to build the arnold procedural', True),
BoolVariable('BUILD_TESTSUITE', 'Whether or not to build the testsuite', True),
BoolVariable('BUILD_DOCS', 'Whether or not to build the documentation.', True),
BoolVariable('BUILD_HOUDINI_TOOLS', 'Whether or not to build the Houdini tools.', False),
BoolVariable('DISABLE_CXX11_ABI', 'Disable the use of the CXX11 abi for gcc/clang', False),
BoolVariable('BUILD_FOR_KATANA', 'Whether or not to build the plugins for Katana', False),
StringVariable('BOOST_LIB_NAME', 'Boost library name pattern', 'boost_%s'),
Expand All @@ -118,7 +117,6 @@ BUILD_USD_WRITER = env['BUILD_USD_WRITER']
BUILD_PROCEDURAL = env['BUILD_PROCEDURAL']
BUILD_TESTSUITE = env['BUILD_TESTSUITE']
BUILD_DOCS = env['BUILD_DOCS']
BUILD_HOUDINI_TOOLS = env['BUILD_HOUDINI_TOOLS']

USD_LIB_PREFIX = env['USD_LIB_PREFIX']

Expand Down
6 changes: 1 addition & 5 deletions docs/building.md
Expand Up @@ -43,7 +43,6 @@ For example `custom.py` files see below.
- BUILD_TESTSUITE: Whether or not to build the testsuite.
- BUILD_DOCS: Whether or not to build the documentation.
- BUILD_FOR_KATANA: Whether or not the build is using usd libs shipped in Katana.
- BUILD_HOUDINI_TOOLS: Whether or not to build the Houdini specific tools.
- DISABLE_CXX11_ABI: Disabling the new C++ ABI introduced in GCC 5.1.

## Configuring Dependencies
Expand Down Expand Up @@ -124,7 +123,7 @@ PREFIX='/opt/autodesk/arnold-usd'

# Building for Houdini 18.0+

We support building against the shipped libraries in Houdini and using the render delegate in the Solaris viewport. As of now (18.0.287) Houdini does not ship usdGenSchema, so the schemas target can't be built against Houdini. Houdini prefixes standard USD library names with `libpxr_` (i.e. `libusd.so` becomes `libpxr_usd.so`), which can be configured via the `USD_LIB_PREFIX` variable. On Linux and MacOS boost libraries are prefixed with `h`, on Windows boost libraries are prefixed with `h` and suffixed with `-mt` (i.e. `boost_python.lib` becomes `hboost_python-mt.lib`), which requires setting the `BOOST_LIB_NAME` variable. Houdini specific features in the render delegate can be enabled using `BUILD_HOUDINI_TOOLS`.
We support building against the shipped libraries in Houdini and using the render delegate in the Solaris viewport. As of now (18.0.287) Houdini does not ship usdGenSchema, so the schemas target can't be built against Houdini. Houdini prefixes standard USD library names with `libpxr_` (i.e. `libusd.so` becomes `libpxr_usd.so`), which can be configured via the `USD_LIB_PREFIX` variable. On Linux and MacOS boost libraries are prefixed with `h`, on Windows boost libraries are prefixed with `h` and suffixed with `-mt` (i.e. `boost_python.lib` becomes `hboost_python-mt.lib`), which requires setting the `BOOST_LIB_NAME` variable.

Example configuration for the standard installation of Houdini-18.0.287 on MacOS.

Expand Down Expand Up @@ -154,7 +153,6 @@ BUILD_USD_WRITER=True
BUILD_PROCEDURAL=True
BUILD_TESTSUITE=True
BUILD_DOCS=True
BUILD_HOUDINI_TOOLS=True
PREFIX='/opt/solidAngle/arnold-usd'
```
Expand Down Expand Up @@ -185,7 +183,6 @@ BUILD_RENDER_DELEGATE=True
BUILD_PROCEDURAL=True
BUILD_TESTSUITE=True
BUILD_USD_WRITER=True
BUILD_HOUDINI_TOOLS=True
BUILD_DOCS=False
PREFIX=r'C:\solidAngle\arnold-usd'
Expand Down Expand Up @@ -220,6 +217,5 @@ BUILD_RENDER_DELEGATE=True
BUILD_PROCEDURAL=True
BUILD_TESTSUITE=True
BUILD_USD_WRITER=True
BUILD_HOUDINI_TOOLS=True
BUILD_DOCS=True
```
3 changes: 0 additions & 3 deletions render_delegate/SConscript
Expand Up @@ -48,9 +48,6 @@ if not system.IS_WINDOWS:
if local_env['USD_HAS_UPDATED_COMPOSITOR']:
local_env.Append(CPPDEFINES=['USD_HAS_UPDATED_COMPOSITOR'])

if local_env['BUILD_HOUDINI_TOOLS']:
local_env.Append(CPPDEFINES=['BUILD_HOUDINI_TOOLS'])

local_env.Append(CPPDEFINES=['HDARNOLD_EXPORTS'])
local_env.Append(CPPPATH = [os.path.join(env['ROOT_DIR'], env['BUILD_BASE_DIR'], 'render_delegate')])
local_env.Append(LIBS = ['ai'])
Expand Down
75 changes: 39 additions & 36 deletions render_delegate/volume.cpp
Expand Up @@ -40,13 +40,12 @@

#include <iostream>

#ifdef BUILD_HOUDINI_TOOLS
#include <pxr/base/arch/defines.h>
#include <pxr/base/arch/env.h>
#include <pxr/base/arch/library.h>
#include <pxr/base/tf/pathUtils.h>

// These don't seem to be publicly exposed anywhere?
/// This is not publicly exposed in USD's TF module.
#if defined(ARCH_OS_WINDOWS)
#include <Windows.h>
#define GETSYM(handle, name) GetProcAddress((HMODULE)handle, name)
Expand All @@ -55,24 +54,29 @@
#define WINAPI
#define GETSYM(handle, name) dlsym(handle, name)
#endif
#endif

PXR_NAMESPACE_OPEN_SCOPE

namespace {

#ifdef BUILD_HOUDINI_TOOLS

using HouGetHoudiniVdbPrimitive = void* (*)(const char*, const char*);
using HouGetHoudiniVolumePrimitive = void* (*)(const char*, const char*, int);
struct HouFnSet {
HouGetHoudiniVdbPrimitive getVdbVolumePrimitive = nullptr;
HouGetHoudiniVolumePrimitive getHoudiniVolumePrimitive = nullptr;

HouFnSet()
/// Houdini provides two function pointers to access Volume primitives via a
/// dynamic library, removing the need for linking against Houdini libraries.
/// HoudiniGetVdbPrimitive -> Returns a Houdini primitive to work with OpenVDB
/// volumes.
/// HoudiniGetVolumePrimitives -> Returns a Houdini primitive to work with
/// native Houdini volumes.
using HoudiniGetVdbPrimitive = void* (*)(const char*, const char*);
using HoudiniGetVolumePrimitive = void* (*)(const char*, const char*, int);
struct HoudiniFnSet {
HoudiniGetVdbPrimitive getVdbPrimitive = nullptr;
HoudiniGetVolumePrimitive getVolumePrimitive = nullptr;

/// We need to load USD_SopVol.(so|dylib|dll) to access the volume function
/// pointers.
HoudiniFnSet()
{
constexpr auto getVdbName = "SOPgetVDBVolumePrimitive";
constexpr auto getHoudiniName = "SOPgetHoudiniVolumePrimitive";
constexpr auto getVolumeName = "SOPgetHoudiniVolumePrimitive";
const auto HFS = ArchGetEnv("HFS");
const auto dsoPath = HFS + ARCH_PATH_SEP + "houdini" + ARCH_PATH_SEP + "dso" + ARCH_PATH_SEP + "USD_SopVol" +
ARCH_LIBRARY_SUFFIX;
Expand All @@ -82,35 +86,39 @@ struct HouFnSet {
if (sopVol == nullptr) {
return;
}
getVdbVolumePrimitive = reinterpret_cast<HouGetHoudiniVdbPrimitive>(GETSYM(sopVol, getVdbName));
getHoudiniVolumePrimitive = reinterpret_cast<HouGetHoudiniVolumePrimitive>(GETSYM(sopVol, getHoudiniName));
getVdbPrimitive = reinterpret_cast<HoudiniGetVdbPrimitive>(GETSYM(sopVol, getVdbName));
getVolumePrimitive = reinterpret_cast<HoudiniGetVolumePrimitive>(GETSYM(sopVol, getVolumeName));
}
};

const HouFnSet& GetHouFunctionSet()
const HoudiniFnSet& GetHoudiniFunctionSet()
{
static HouFnSet ret;
static HoudiniFnSet ret;
return ret;
}

using HtoAConvertPrimVdbToArnold = void (*)(void*, int, void**);

/// HtoA provides a function to read data from a Houdini OpenVDB primitive
/// and write it to a volume node storing the VDB data in-memory.
struct HtoAFnSet {
HtoAConvertPrimVdbToArnold convertPrimVdbToArnold = nullptr;

HtoAFnSet()
{
// The symbol is stored in _htoa_pygeo.so in python2.7libs, and
// htoa is typically configured using HOUDINI_PATH. We should refine
// this method in the future.
/// The symbol is stored in _htoa_pygeo.so in python2.7libs, and
/// htoa is typically configured using HOUDINI_PATH. We should refine
/// this method in the future.
/// One of the current limitations is that we don't support HtoA
/// installed in a path containing `;` or `&`.
constexpr auto convertVdbName = "HtoAConvertPrimVdbToArnold";
const auto HOUDINI_PATH = ArchGetEnv("HOUDINI_PATH");
auto searchForPygeo = [&](const std::string& path) -> bool {
if (path == "&") {
return false;
}
const auto dsoPath = path + ARCH_PATH_SEP + "python2.7libs" + ARCH_PATH_SEP + "_htoa_pygeo" +
// HTOA sets this library's extension to .so even on linux.
//. HTOA sets this library's extension .so on MacOS.
#ifdef ARCH_OS_WINDOWS
".dll"
#else
Expand Down Expand Up @@ -143,6 +151,8 @@ struct HtoAFnSet {
}
#endif
}
/// TF warning, error and status functions don't show up in the terminal
/// when running on Linux/MacOS and Houdini 18.
std::cerr << "[HdArnold] Cannot load _htoa_pygeo library required for volume rendering in Solaris" << std::endl;
}
};
Expand All @@ -153,8 +163,6 @@ const HtoAFnSet GetHtoAFunctionSet()
return ret;
}

#endif

} // namespace

// clang-format off
Expand All @@ -174,11 +182,9 @@ HdArnoldVolume::~HdArnoldVolume()
for (auto* volume : _volumes) {
AiNodeDestroy(volume);
}
#ifdef BUILD_HOUDINI_TOOLS
for (auto* volume : _inMemoryVolumes) {
AiNodeDestroy(volume);
}
#endif
}

void HdArnoldVolume::Sync(
Expand All @@ -202,16 +208,15 @@ void HdArnoldVolume::Sync(
for (auto& volume : _volumes) {
AiNodeSetPtr(volume, str::shader, volumeShader);
}
#ifdef BUILD_HOUDINI_TOOLS
for (auto& volume : _inMemoryVolumes) {
AiNodeSetPtr(volume, str::shader, volumeShader);
}
#endif
}

if (HdChangeTracker::IsTransformDirty(*dirtyBits, id)) {
param->End();
HdArnoldSetTransform(_volumes, delegate, GetId());
HdArnoldSetTransform(_inMemoryVolumes, delegate, GetId());
}

*dirtyBits = HdChangeTracker::Clean;
Expand All @@ -220,9 +225,7 @@ void HdArnoldVolume::Sync(
void HdArnoldVolume::_CreateVolumes(const SdfPath& id, HdSceneDelegate* delegate)
{
std::unordered_map<std::string, std::vector<TfToken>> openvdbs;
#ifdef BUILD_HOUDINI_TOOLS
std::unordered_map<std::string, std::vector<TfToken>> houVdbs;
#endif
const auto fieldDescriptors = delegate->GetVolumeFieldDescriptors(id);
for (const auto& field : fieldDescriptors) {
auto* openvdbAsset = dynamic_cast<HdArnoldOpenvdbAsset*>(
Expand All @@ -238,15 +241,13 @@ void HdArnoldVolume::_CreateVolumes(const SdfPath& id, HdSceneDelegate* delegate
if (path.empty()) {
path = assetPath.GetAssetPath();
}
#ifdef BUILD_HOUDINI_TOOLS
if (TfStringStartsWith(path, "op:")) {
auto& fields = houVdbs[path];
if (std::find(fields.begin(), fields.end(), field.fieldName) == fields.end()) {
fields.push_back(field.fieldName);
}
continue;
}
#endif
auto& fields = openvdbs[path];
if (std::find(fields.begin(), fields.end(), field.fieldName) == fields.end()) {
fields.push_back(field.fieldName);
Expand Down Expand Up @@ -289,14 +290,17 @@ void HdArnoldVolume::_CreateVolumes(const SdfPath& id, HdSceneDelegate* delegate
AiNodeSetArray(volume, str::grids, fields);
}

#ifdef BUILD_HOUDINI_TOOLS
for (auto* volume : _inMemoryVolumes) {
AiNodeDestroy(volume);
}
_inMemoryVolumes.clear();

const auto& houFnSet = GetHouFunctionSet();
if (houFnSet.getVdbVolumePrimitive == nullptr || houFnSet.getHoudiniVolumePrimitive == nullptr) {
if (houVdbs.empty()) {
return;
}

const auto& houdiniFnSet = GetHoudiniFunctionSet();
if (houdiniFnSet.getVdbPrimitive == nullptr || houdiniFnSet.getVolumePrimitive == nullptr) {
return;
}

Expand All @@ -308,7 +312,7 @@ void HdArnoldVolume::_CreateVolumes(const SdfPath& id, HdSceneDelegate* delegate
for (const auto& houVdb : houVdbs) {
std::vector<void*> gridVec;
for (const auto& field : houVdb.second) {
auto* primVdb = houFnSet.getVdbVolumePrimitive(houVdb.first.c_str(), field.GetText());
auto* primVdb = houdiniFnSet.getVdbPrimitive(houVdb.first.c_str(), field.GetText());
if (primVdb == nullptr) {
continue;
}
Expand All @@ -324,7 +328,6 @@ void HdArnoldVolume::_CreateVolumes(const SdfPath& id, HdSceneDelegate* delegate
AiNodeSetUInt(volume, str::id, static_cast<unsigned int>(GetPrimId()) + 1);
_inMemoryVolumes.push_back(volume);
}
#endif
}

HdDirtyBits HdArnoldVolume::GetInitialDirtyBitsMask() const { return HdChangeTracker::AllDirty; }
Expand Down
2 changes: 0 additions & 2 deletions render_delegate/volume.h
Expand Up @@ -109,9 +109,7 @@ class HdArnoldVolume : public HdVolume {

HdArnoldRenderDelegate* _delegate; ///< Pointer to the Render Delegate.
std::vector<AtNode*> _volumes; ///< Vector storing all the Volumes created.
#ifdef BUILD_HOUDINI_TOOLS
std::vector<AtNode*> _inMemoryVolumes; ///< Vectoring storing all the Volumes for in-memory VDB storage.
#endif
};

PXR_NAMESPACE_CLOSE_SCOPE

0 comments on commit 5bfcc41

Please sign in to comment.