Skip to content

Commit

Permalink
Merge pull request #38 from andrewkaufman/cachePolicy
Browse files Browse the repository at this point in the history
Protect engine plugs with the Gaffer 0.54 computeCachePolicy
  • Loading branch information
andrewkaufman authored Aug 23, 2019
2 parents 3bdfada + fd5b651 commit 15fc54a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/AtomsGaffer/AtomsCrowdReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ class AtomsCrowdReader : public GafferScene::ObjectSource

protected:

Gaffer::ValuePlug::CachePolicy computeCachePolicy( const Gaffer::ValuePlug *output ) const override;

void hashSource( const Gaffer::Context *context, IECore::MurmurHash &h ) const override;
IECore::ConstObjectPtr computeSource( const Gaffer::Context *context ) const override;

Expand Down
2 changes: 2 additions & 0 deletions include/AtomsGaffer/AtomsVariationReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ class AtomsVariationReader : public GafferScene::SceneNode

protected:

Gaffer::ValuePlug::CachePolicy computeCachePolicy( const Gaffer::ValuePlug *output ) const override;

void hashBound( const ScenePath &path, const Gaffer::Context *context, const GafferScene::ScenePlug *parent, IECore::MurmurHash &h ) const override;
void hashTransform( const ScenePath &path, const Gaffer::Context *context, const GafferScene::ScenePlug *parent, IECore::MurmurHash &h ) const override;
void hashAttributes( const ScenePath &path, const Gaffer::Context *context, const GafferScene::ScenePlug *parent, IECore::MurmurHash &h ) const override;
Expand Down
12 changes: 12 additions & 0 deletions src/AtomsGaffer/AtomsCrowdReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,18 @@ void AtomsCrowdReader::affects( const Plug *input, AffectedPlugsContainer &outpu
}
}

Gaffer::ValuePlug::CachePolicy AtomsCrowdReader::computeCachePolicy( const Gaffer::ValuePlug *output ) const
{
if( output == enginePlug() )
{
// Request blocking compute for the engine, to avoid concurrent threads
// loading the same engine redundantly.
return ValuePlug::CachePolicy::Standard;
}

return ObjectSource::computeCachePolicy( output );
}

void AtomsCrowdReader::hashSource( const Gaffer::Context *context, MurmurHash &h ) const
{
atomsSimFilePlug()->hash( h );
Expand Down
12 changes: 12 additions & 0 deletions src/AtomsGaffer/AtomsVariationReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,18 @@ void AtomsVariationReader::affects( const Plug *input, AffectedPlugsContainer &o
SceneNode::affects( input, outputs );
}

Gaffer::ValuePlug::CachePolicy AtomsVariationReader::computeCachePolicy( const Gaffer::ValuePlug *output ) const
{
if( output == enginePlug() )
{
// Request blocking compute for the engine, to avoid concurrent threads
// loading the same engine redundantly.
return ValuePlug::CachePolicy::Standard;
}

return SceneNode::computeCachePolicy( output );
}

void AtomsVariationReader::hashBound( const ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent, IECore::MurmurHash &h ) const
{
SceneNode::hashBound( path, context, parent, h );
Expand Down

0 comments on commit 15fc54a

Please sign in to comment.