Skip to content

Commit

Permalink
Merge branch fix-7.2.5 20240125 (#1831)
Browse files Browse the repository at this point in the history
* Update tests after arnold changes on curves (#1766)

(cherry picked from commit 2fcc262)

* Fix the incorrect orientation of the PointInstancer instances in the render delegate (#1777)

* add test for #1776

* Initialize the rotation matrix with the quad directly

* update changelog for #1776

* Fix changelog for 7.2.5 release (#1788)

* More changelog fixes

* handle vertex interpolated uvs on bspline curves (#1792)

* FIx the error "Cannot load _htoa_pygeo library required for volume rendering in Solaris" (#1811)

* Improve material network creation times by caching the nodes returned by Arnold (#1813)

* Improve material network creation by caching the nodes returned by arnold

* optimize further by first checking if the shader is an arnold shader

* move shader node entry and osl code cache in the render delegate and use lock/mutex

* cache materialx nodes only

* Fix build with older versions of arnold (#1820)

* fix build with older versions of arnold

* fix compatibility with older versions of arnold

* convert AtString to string

* allow materialx for versions > 7.1.4

* fix ifdef versions for materialx

* compatibility with older arnold versions

* update changelog for fix-7.2.5.0 (#1827)

* Fix crash happening in maya aiStandin when scrolling the timeline (#1830)

* make the UsdArnoldReaderRegistry non static

* register readers before reading

---------

Co-authored-by: Sebastien Blaineau-Ortega <sebastien.blaineau.ortega@autodesk.com>
  • Loading branch information
cpichard and sebastienblor committed Jan 25, 2024
1 parent 32f86e0 commit 5454a9e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 46 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -28,6 +28,7 @@

- [usd#1808](https://github.com/Autodesk/arnold-usd/issues/1808) - Fix the error "Cannot load _htoa_pygeo library required for volume rendering in Solaris" in Houdini 19.5+.
- [usd#1812](https://github.com/Autodesk/arnold-usd/issues/1812) - Improve Material network creation by caching the node entries and the osl code.
- [usd#1781](https://github.com/Autodesk/arnold-usd/issues/1781) - Fix a crash happening in a aiStandin usd when scrolling the timeline in maya.

## [7.2.5.1] - 2024-01-18

Expand Down
47 changes: 20 additions & 27 deletions libs/translator/reader/reader.cpp
Expand Up @@ -83,22 +83,27 @@ namespace {
WorkDispatcher *dispatcher;
};
};
// global reader registry, will be used in the default case
static UsdArnoldReaderRegistry *s_readerRegistry = nullptr;
static int s_mustDeleteRegistry = 0;


static AtMutex s_globalReaderMutex;
static std::unordered_map<int, int> s_cacheRefCount;

UsdArnoldReader::UsdArnoldReader()
: _procParent(nullptr),
_universe(nullptr),
_convert(true),
_debug(false),
_threadCount(1),
_mask(AI_NODE_ALL),
_defaultShader(nullptr),
_hasRootPrim(false),
_readStep(READ_NOT_STARTED),
_purpose(UsdGeomTokens->render),
_dispatcher(nullptr),
_readerRegistry(new UsdArnoldReaderRegistry())
{}
UsdArnoldReader::~UsdArnoldReader()
{
if (s_mustDeleteRegistry && _registry) {
delete _registry;
s_mustDeleteRegistry = false;
_registry = s_readerRegistry;
}
// What do we want to do at destruction here ?
// Should we delete the created nodes in case there was no procParent ?
delete _readerRegistry;
}

void UsdArnoldReader::TraverseStage(UsdPrim *rootPrim, UsdArnoldReaderContext &context,
Expand Down Expand Up @@ -291,19 +296,7 @@ void UsdArnoldReader::ReadStage(UsdStageRefPtr stage, const std::string &path)
// and the eventual procedural mask set above
_mask = _mask & procMask;

// eventually use a dedicated registry
if (_registry == nullptr) {
// No registry was set (default), let's use the global one
{
std::lock_guard<AtMutex> guard(s_globalReaderMutex);
if (s_readerRegistry == nullptr) {
s_readerRegistry = new UsdArnoldReaderRegistry(); // initialize the global registry
s_readerRegistry->RegisterPrimitiveReaders();
}
}
_registry = s_readerRegistry;
} else
_registry->RegisterPrimitiveReaders();
_readerRegistry->RegisterPrimitiveReaders();

UsdPrim *rootPrimPtr = nullptr;

Expand Down Expand Up @@ -609,7 +602,7 @@ void UsdArnoldReader::ReadPrimitive(const UsdPrim &prim, UsdArnoldReaderContext
_renderSettings = objName;
}

UsdArnoldPrimReader *primReader = _registry->GetPrimReader(objType);
UsdArnoldPrimReader *primReader = _readerRegistry->GetPrimReader(objType);
if (primReader && (_mask & primReader->GetType())) {
if (_debug) {
std::string txt;
Expand Down Expand Up @@ -706,8 +699,8 @@ void UsdArnoldReader::SetProceduralParent(AtNode *node)
}

void UsdArnoldReader::CreateViewportRegistry(AtProcViewportMode mode, const AtParamValueMap* params) {
s_mustDeleteRegistry = true;
_registry = new UsdArnoldViewportReaderRegistry(mode, params);
delete _readerRegistry;
_readerRegistry = new UsdArnoldViewportReaderRegistry(mode, params);
}

void UsdArnoldReader::SetUniverse(AtUniverse *universe)
Expand Down
24 changes: 5 additions & 19 deletions libs/translator/reader/reader.h
Expand Up @@ -47,21 +47,7 @@ class UsdArnoldReaderRegistry;

class UsdArnoldReader : public ProceduralReader {
public:
UsdArnoldReader()
: _procParent(nullptr),
_universe(nullptr),
_registry(nullptr),
_convert(true),
_debug(false),
_threadCount(1),
_mask(AI_NODE_ALL),
_defaultShader(nullptr),
_hasRootPrim(false),
_readStep(READ_NOT_STARTED),
_purpose(UsdGeomTokens->render),
_dispatcher(nullptr)
{
}
UsdArnoldReader();
~UsdArnoldReader();

void ReadStage(UsdStageRefPtr stage,
Expand All @@ -74,7 +60,7 @@ class UsdArnoldReader : public ProceduralReader {

void SetProceduralParent(AtNode *node) override;
void SetUniverse(AtUniverse *universe) override;
// void SetRegistry(UsdArnoldReaderRegistry *registry);

void CreateViewportRegistry(AtProcViewportMode mode, const AtParamValueMap* params) override;
void SetFrame(float frame) override;
void SetMotionBlur(bool motionBlur, float motionStart = 0.f, float motionEnd = 0.f) override;
Expand All @@ -89,7 +75,7 @@ class UsdArnoldReader : public ProceduralReader {
const UsdStageRefPtr &GetStage() const { return _stage; }
const std::vector<AtNode *> &GetNodes() const override { return _nodes; }
float GetFrame() const { return _time.frame; }
UsdArnoldReaderRegistry *GetRegistry() { return _registry; }
UsdArnoldReaderRegistry *GetRegistry() { return _readerRegistry; }
AtUniverse *GetUniverse() { return _universe; }
const AtNode *GetProceduralParent() const { return _procParent; }
bool GetDebug() const { return _debug; }
Expand Down Expand Up @@ -206,8 +192,6 @@ class UsdArnoldReader : public ProceduralReader {
private:
const AtNode *_procParent; // the created nodes are children of a procedural parent
AtUniverse *_universe; // only set if a specific universe is being used
UsdArnoldReaderRegistry *_registry; // custom registry used for this reader. If null, a global
// registry will be used.
TimeSettings _time;
bool _convert; // do we want to convert the primitives attributes
bool _debug;
Expand Down Expand Up @@ -235,6 +219,8 @@ class UsdArnoldReader : public ProceduralReader {
AtString _pxrMtlxPath; // environment variable PXR_MTLX_STDLIB_SEARCH_PATHS

unsigned int _id = 0; ///< Arnold shape ID for the procedural.
// Reader registry, will be used in the default case
UsdArnoldReaderRegistry *_readerRegistry = nullptr;
};

class UsdArnoldReaderThreadContext : public ArnoldAPIAdapter {
Expand Down

0 comments on commit 5454a9e

Please sign in to comment.