Example #1
0
		void hashParameter( const Gaffer::Plug *parameter, IECore::MurmurHash &h )
		{
			const Gaffer::Plug *effectiveParameter = this->effectiveParameter( parameter );
			if( !effectiveParameter )
			{
				return;
			}

			const Shader *effectiveShader = static_cast<const Shader *>( effectiveParameter->node() );
			if( isInputParameter( effectiveParameter ) )
			{
				effectiveShader->parameterHash( effectiveParameter, h );
				hashParameterComponentConnections( parameter, h );
			}
			else
			{
				assert( isOutputParameter( effectiveParameter ) );
				h.append( shaderHash( effectiveShader ) );
				if( effectiveShader->outPlug()->isAncestorOf( effectiveParameter ) )
				{
					h.append( effectiveParameter->relativeName( effectiveShader->outPlug() ) );
				}
				return;
			}
		}
Example #2
0
unsigned long int Random::computeSeed( const Context *context ) const
{
	unsigned long int seed = seedPlug()->getValue();
	std::string contextEntry = contextEntryPlug()->getValue();
	if( contextEntry.size() )
	{
		const IECore::Data *contextData = 0;
		try
		{	
			contextData = context->get<IECore::Data>( contextEntry );
		}
		catch( ... )
		{
		}
		if( contextData )
		{
			IECore::MurmurHash hash = contextData->Object::hash();
			/// \todo It'd be nice if there was a way of getting the hash folded into an
			/// int so we could avoid this jiggery pokery.
			std::string s = hash.toString();
			seed += boost::hash<std::string>()( s );
		}
	}
	return seed;
}
Example #3
0
IECore::MurmurHash Shader::NetworkBuilder::shaderHash( const Shader *shaderNode )
{
	shaderNode = effectiveNode( shaderNode );
	if( !shaderNode )
	{
		IECore::MurmurHash h;
		h.append( Shader::staticTypeId() );
		return h;
	}

	ShaderAndHash &shaderAndHash = m_shaders[shaderNode];
	if( shaderAndHash.hash != IECore::MurmurHash() )
	{
		return shaderAndHash.hash;
	}

	shaderAndHash.hash.append( shaderNode->typeId() );
	shaderNode->namePlug()->hash( shaderAndHash.hash );
	shaderNode->typePlug()->hash( shaderAndHash.hash );

	parameterHashWalk( shaderNode, shaderNode->parametersPlug(), shaderAndHash.hash );

	shaderNode->nodeNamePlug()->hash( shaderAndHash.hash );
	shaderNode->nodeColorPlug()->hash( shaderAndHash.hash );

	return shaderAndHash.hash;
}
Example #4
0
void Shader::parameterHash( const Gaffer::Plug *parameterPlug, NetworkBuilder &network, IECore::MurmurHash &h ) const
{
	const Plug *inputPlug = parameterPlug->source<Plug>();
	if( inputPlug != parameterPlug )
	{
		const Shader *n = IECore::runTimeCast<const Shader>( inputPlug->node() );
		if( n && ( inputPlug == n->outPlug() || n->outPlug()->isAncestorOf( inputPlug ) ) )
		{
			h.append( network.shaderHash( n ) );
			if( inputPlug != n->outPlug() )
			{
				// shader has multiple outputs - we need to make sure the particular
				// output in question is taken into account by the hash.
				h.append( inputPlug->relativeName( n->outPlug() ) );
			}
			return;
		}
		// fall through to hash plug value
	}

	const ValuePlug *vplug = IECore::runTimeCast<const ValuePlug>( parameterPlug );
	if( vplug )
	{
		vplug->hash( h );
	}
	else
	{
		h.append( parameterPlug->typeId() );
	}
}
Example #5
0
void Shape::hashChannelData( const GafferImage::ImagePlug *parent, const Gaffer::Context *context, IECore::MurmurHash &h ) const
{
	assert( parent == shapePlug() );
	const std::string &channelName = context->get<std::string>( ImagePlug::channelNameContextName );
	if( channelName == g_shapeChannelName )
	{
		// Private channel we use for caching the shape but don't advertise via channelNames.
		hashShapeChannelData( context->get<V2i>( ImagePlug::tileOriginContextName ), context, h );
	}
	else
	{
		const MurmurHash shapeHash = parent->channelDataHash( g_shapeChannelName, context->get<V2i>( ImagePlug::tileOriginContextName ) );
		const float c = channelValue( parent, channelName );
		if( c == 1 )
		{
			h = shapeHash;
		}
		else
		{
			ImageProcessor::hashChannelData( parent, context, h );
			h.append( shapeHash );
			h.append( c );
		}
	}
}
AtNode *InstancingConverter::convert( const std::vector<const IECore::Primitive *> &samples, const std::vector<float> &sampleTimes, const IECore::MurmurHash &additionalHash )
{
	IECore::MurmurHash h;
	for( std::vector<const IECore::Primitive *>::const_iterator it = samples.begin(), eIt = samples.end(); it != eIt; ++it )
	{
		(*it)->hash( h );
	}
	h.append( additionalHash );

	MemberData::Cache::accessor a;
	if( m_data->cache.insert( a, h ) )
	{
		std::vector<const IECore::Object *> objectSamples( samples.begin(), samples.end() );
		a->second = NodeAlgo::convert( objectSamples, sampleTimes );
		return a->second;
	}
	else
	{
		if( a->second )
		{
			AtNode *instance = AiNode( "ginstance" );
			AiNodeSetPtr( instance, "node", a->second );
			return instance;
		}
	}

	return NULL;
}
Example #7
0
void AlembicSource::hashObject( const ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent, IECore::MurmurHash &h ) const
{
	SceneNode::hashObject( path, context, parent, h );

	fileNamePlug()->hash( h );
	refreshCountPlug()->hash( h );

	h.append( &(path[0]), path.size() );
	h.append( context->getTime() );
}
Example #8
0
IECore::MurmurHash Context::hash() const
{
	IECore::MurmurHash result;
	for( Map::const_iterator it = m_map.begin(), eIt = m_map.end(); it != eIt; it++ )
	{
		result.append( it->first );
		it->second.data->hash( result );
	}
	return result;
}
Example #9
0
void MapProjection::hashProcessedObject( const ScenePath &path, const Gaffer::Context *context, IECore::MurmurHash &h ) const
{
	ScenePath cameraPath;
	ScenePlug::stringToPath( cameraPlug()->getValue(), cameraPath );

	h.append( inPlug()->objectHash( cameraPath ) );
	h.append( inPlug()->transformHash( cameraPath ) );

	inPlug()->transformPlug()->hash( h );
	uvSetPlug()->hash( h );
}
Example #10
0
void Sampler::hash( IECore::MurmurHash &h ) const
{
	for ( int x = m_cacheWindow.min.x; x < m_cacheWindow.max.x; x += GafferImage::ImagePlug::tileSize() )
	{
		for ( int y = m_cacheWindow.min.y; y < m_cacheWindow.max.y; y += GafferImage::ImagePlug::tileSize() )
		{
			h.append( m_plug->channelDataHash( m_channelName, Imath::V2i( x, y ) ) );
		}
	}
	h.append( m_boundingMode );
	h.append( m_dataWindow );
	h.append( m_sampleWindow );
}
Example #11
0
void ArnoldDisplacement::attributesHash( IECore::MurmurHash &h ) const
{
	h.append( typeId() );
	if( !enabledPlug()->getValue() )
	{
		return;
	}

	h.append( mapPlug()->attributesHash() );
	heightPlug()->hash( h );
	paddingPlug()->hash( h );
	zeroValuePlug()->hash( h );
	autoBumpPlug()->hash( h );
}
Example #12
0
void BranchCreator::hashMapping( const Gaffer::Context *context, IECore::MurmurHash &h ) const
{
	string parentAsString = parentPlug()->getValue();
	h.append( parentAsString );
	
	ScenePlug::ScenePath parent;
	ScenePlug::stringToPath( parentAsString, parent );
	
	h.append( inPlug()->childNamesHash( parent ) );
	
	MurmurHash branchChildNamesHash;
	hashBranchChildNames( parent, ScenePath(), context, branchChildNamesHash );
	h.append( branchChildNamesHash );
}
Example #13
0
void Reformat::hashDataWindow( const GafferImage::ImagePlug *output, const Gaffer::Context *context, IECore::MurmurHash &h ) const
{
	ImageProcessor::hashDataWindow( output, context, h );

	Format format = formatPlug()->getValue();
	h.append( format.getDisplayWindow() );
	h.append( format.getPixelAspect() );

	Format inFormat = inPlug()->formatPlug()->getValue();
	h.append( inFormat.getDisplayWindow() );
	h.append( inFormat.getPixelAspect() );

	inPlug()->dataWindowPlug()->hash( h );
}
Example #14
0
void Instancer::hashBranchTransform( const ScenePath &parentPath, const ScenePath &branchPath, const Gaffer::Context *context, IECore::MurmurHash &h ) const
{
	ContextPtr ic = instanceContext( context, branchPath );
	if( ic )
	{
		Context::Scope scopedContext( ic );
		h = instancePlug()->transformPlug()->hash();
	}
	
	if( branchPath.size() == 1 )
	{
		h.append( inPlug()->objectHash( parentPath ) );
		h.append( instanceIndex( branchPath ) );
	}
}
IECore::MurmurHash AtomicFormatPlug::hash() const
{
	Format v = getValue();
	if( v.getDisplayWindow().isEmpty() )
	{
		v = FormatPlug::getDefaultFormat( Context::current() );
	}

	IECore::MurmurHash result;
	result.append( v.getDisplayWindow() );
	result.append( v.getPixelAspect() );
	return result;

	return ValuePlug::hash();
}
Example #16
0
void OSLObject::hashProcessedObject( const ScenePath &path, const Gaffer::Context *context, IECore::MurmurHash &h ) const
{
	const OSLShader *shader = runTimeCast<const OSLShader>( shaderPlug()->source()->node() );
	ConstShadingEnginePtr shadingEngine = shader ? shader->shadingEngine() : nullptr;

	if( !shadingEngine )
	{
		return;
	}

	shadingEngine->hash( h );
	interpolationPlug()->hash( h );
	h.append( inPlug()->fullTransformHash( path ) );
	h.append( resampledInPlug()->objectPlug()->hash() );
}
Example #17
0
		void hash( IECore::MurmurHash &h ) const
		{
			std::unique_lock<std::mutex> lock( m_hashMutex );
			if( m_hashDirty )
			{
				m_hash = MurmurHash();
				for( const auto &node : m_nodes )
				{
					m_hash.append( node.handle );
					node.shader->hash( m_hash );

					for( const auto &connection : node.inputConnections )
					{
						m_hash.append( connection.source.shader );
						m_hash.append( connection.source.name );
						m_hash.append( connection.destination.name );
					}
				}

				m_hash.append( m_output.shader );
				m_hash.append( m_output.name );

				m_hashDirty = false;
			}
			lock.unlock();

			h.append( m_hash );
		}
Example #18
0
void Shader::attributesHash( const Gaffer::Plug *output, IECore::MurmurHash &h ) const
{
	attributeSuffixPlug()->hash( h );

	NetworkBuilder networkBuilder( output );
	h.append( networkBuilder.networkHash() );
}
Example #19
0
void SceneReader::hashSet( const IECore::InternedString &setName, const Gaffer::Context *context, const ScenePlug *parent, IECore::MurmurHash &h ) const
{
	SceneNode::hashSet( setName, context, parent, h );
	fileNamePlug()->hash( h );
	refreshCountPlug()->hash( h );
	h.append( setName );
}
Example #20
0
void Expression::hash( const ValuePlug *output, const Context *context, IECore::MurmurHash &h ) const
{
	ComputeNode::hash( output, context, h );
	if( output == getChild<ValuePlug>( "out" ) )
	{
		enginePlug()->hash( h );
		expressionPlug()->hash( h );
		const CompoundPlug *in = getChild<CompoundPlug>( "in" );
		if( in )
		{
			in->hash( h );
		}
		if( m_engine )
		{
			std::vector<std::string> contextNames;
			m_engine->contextNames( contextNames );
			for( std::vector<std::string>::const_iterator it = contextNames.begin(); it != contextNames.end(); it++ )
			{
				const IECore::Data *d = context->get<IECore::Data>( *it, 0 );
				if( d )
				{
					d->hash( h );
				}
				else
				{
					h.append( 0 );
				}
			}
		}
	}
}
Example #21
0
void Expression::hash( const ValuePlug *output, const Context *context, IECore::MurmurHash &h ) const
{
	ComputeNode::hash( output, context, h );

	if( output == executePlug() )
	{
		enginePlug()->hash( h );
		expressionPlug()->hash( h );
		inPlug()->hash( h );

		if( m_engine )
		{
			for( std::vector<IECore::InternedString>::const_iterator it = m_contextNames.begin(); it != m_contextNames.end(); it++ )
			{
				const IECore::Data *d = context->get<IECore::Data>( *it, 0 );
				if( d )
				{
					d->hash( h );
				}
				else
				{
					h.append( 0 );
				}
			}
		}
	}
	else if( outPlug()->isAncestorOf( output ) )
	{
		executePlug()->hash( h );
	}
}
Example #22
0
void Instancer::hashBranchBound( const ScenePath &parentPath, const ScenePath &branchPath, const Gaffer::Context *context, IECore::MurmurHash &h ) const
{
	if( branchPath.size() <= 1 )
	{
		// "/" or "/name"

		BranchCreator::hashBranchBound( parentPath, branchPath, context, h );

		ConstV3fVectorDataPtr p = sourcePoints( parentPath );
		if( p )
		{
			p->hash( h );

			ScenePath branchChildPath( branchPath );
			if( branchChildPath.size() == 0 )
			{
				branchChildPath.push_back( namePlug()->getValue() );
			}

			BoundHash hasher( this, branchChildPath, context );
			parallel_deterministic_reduce(
				blocked_range<size_t>( 0, p->readable().size(), 100 ),
				hasher
			);

			h.append( hasher.result() );
		}
	}
	else
	{
		InstanceScope instanceScope( context, branchPath );
		h = instancePlug()->boundPlug()->hash();
	}
}
Example #23
0
void Grid::hashObject( const SceneNode::ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent, IECore::MurmurHash &h ) const
{
	if( path.size() == 2 )
	{
		SceneNode::hashObject( path, context, parent, h );
		h.append( path.back() );
		dimensionsPlug()->hash( h );
		if( path.back() == g_gridLinesName )
		{
			spacingPlug()->hash( h );
			gridColorPlug()->hash( h );
		}
		else if( path.back() == g_centerLinesName )
		{
			centerColorPlug()->hash( h );
		}
		else if( path.back() == g_borderLinesName )
		{
			borderColorPlug()->hash( h );
		}
	}
	else
	{
		h = outPlug()->objectPlug()->defaultValue()->hash();
	}
}
Example #24
0
IECore::MurmurHash ExecutableRender::hash( const Gaffer::Context *context ) const
{
	const ScenePlug *scenePlug = inPlug()->source<ScenePlug>();
	if ( scenePlug == inPlug() )
	{
		return IECore::MurmurHash();
	}

	Context::Scope scope( context );
	IECore::MurmurHash h = TaskNode::hash( context );
	/// \todo hash the actual scene when we have a hierarchyHash
	h.append( (uint64_t)scenePlug );
	h.append( context->hash() );

	return h;
}
Example #25
0
void DisplayTransform::hashTransform( const Gaffer::Context *context, IECore::MurmurHash &h ) const
{
	std::string colorSpace = inputColorSpacePlug()->getValue();
	std::string display = displayPlug()->getValue();
	std::string view = viewPlug()->getValue();

	if( colorSpace.empty() || display.empty() || view.empty() )
	{
		h = MurmurHash();
		return;
	}

	h.append( colorSpace );
	h.append( display );
	h.append( view );
}
Example #26
0
void UVWarp::hashEngine( const std::string &channelName, const Imath::V2i &tileOrigin, const Gaffer::Context *context, IECore::MurmurHash &h ) const
{
	Warp::hashEngine( channelName, tileOrigin, context, h );

	h.append( tileOrigin );
	uvPlug()->dataWindowPlug()->hash( h );

	ConstStringVectorDataPtr channelNames = uvPlug()->channelNamesPlug()->getValue();

	ContextPtr tmpContext = new Context( *context, Context::Borrowed );
	Context::Scope scopedContext( tmpContext.get() );

	if( channelExists( channelNames->readable(), "R" ) )
	{
		tmpContext->set<std::string>( ImagePlug::channelNameContextName, "R" );
		uvPlug()->channelDataPlug()->hash( h );
	}

	if( channelExists( channelNames->readable(), "G" ) )
	{
		tmpContext->set<std::string>( ImagePlug::channelNameContextName, "G" );
		uvPlug()->channelDataPlug()->hash( h );
	}

	if( channelExists( channelNames->readable(), "A" ) )
	{
		tmpContext->set<std::string>( ImagePlug::channelNameContextName, "A" );
		uvPlug()->channelDataPlug()->hash( h );
	}

	inPlug()->formatPlug()->hash( h );
}
Example #27
0
IECore::MurmurHash ExecutableOpHolder::executionHash( const Context *context ) const
{
	IECore::MurmurHash h;
	std::string className;
	int classVersion;
	getParameterised( &className, &classVersion );
	h.append( className );
	h.append( classVersion );
	Context::Scope scope( context );
	const ValuePlug *parametersPlug = getChild<ValuePlug>( "parameters" );
	if( parametersPlug )
	{
		parametersPlug->hash( h );
	}
	return h;
}
Example #28
0
void Duplicate::hashBranchTransform( const ScenePath &parentPath, const ScenePath &branchPath, const Gaffer::Context *context, IECore::MurmurHash &h ) const
{
	ScenePath source;
	sourcePath( branchPath, source );
	if( branchPath.size() == 1 )
	{
		BranchCreator::hashBranchTransform( parentPath, branchPath, context, h );
		h.append( inPlug()->transformHash( source ) );
		transformPlug()->hash( h );
		childNamesPlug()->hash( h );
		h.append( branchPath[0] );
	}
	else
	{
		h = inPlug()->transformHash( source );
	}
}
Example #29
0
IECore::MurmurHash SceneWriter::hash( const Gaffer::Context *context ) const
{
	Context::Scope scope( context );
	const ScenePlug *scenePlug = inPlug()->source<ScenePlug>();
	if ( ( fileNamePlug()->getValue() == "" ) || ( scenePlug == inPlug() ) )
	{
		return IECore::MurmurHash();
	}

	IECore::MurmurHash h = ExecutableNode::hash( context );
	h.append( fileNamePlug()->hash() );
	/// \todo hash the actual scene when we have a hierarchyHash
	h.append( (uint64_t)scenePlug );
	h.append( context->hash() );

	return h;
}
Example #30
0
void Mirror::hashDataWindow( const GafferImage::ImagePlug *parent, const Gaffer::Context *context, IECore::MurmurHash &h ) const
{
	const bool horizontal = horizontalPlug()->getValue();
	const bool vertical = verticalPlug()->getValue();

	if( !horizontal && !vertical )
	{
		h = inPlug()->dataWindowPlug()->hash();
		return;
	}

	ImageProcessor::hashDataWindow( parent, context, h );
	inPlug()->dataWindowPlug()->hash( h );
	inPlug()->formatPlug()->hash( h );
	h.append( horizontal );
	h.append( vertical );
}