HDK
|
#include <registry.h>
Public Types | |
using | DiscoveryPluginRefPtrVec = SdrDiscoveryPluginRefPtrVector |
![]() | |
using | DiscoveryPluginRefPtrVec = NdrDiscoveryPluginRefPtrVector |
Static Public Member Functions | |
static SDR_API SdrRegistry & | GetInstance () |
Get the single SdrRegistry instance. More... | |
Protected Member Functions | |
SDR_API | SdrRegistry () |
SDR_API | ~SdrRegistry () |
![]() | |
NdrRegistry (const NdrRegistry &)=delete | |
NdrRegistry & | operator= (const NdrRegistry &)=delete |
NDR_API | NdrRegistry () |
NDR_API | ~NdrRegistry () |
![]() | |
~TfWeakBase () | |
TfRefPtr< Tf_Remnant > | _Register () const |
template<class T > | |
TfRefPtr< Tf_Remnant > | _Register (T *tempRmnt) const |
bool | _HasRemnant () const |
Friends | |
class | TfSingleton< SdrRegistry > |
The registry provides access to shader node information. "Discovery Plugins" are responsible for finding the nodes that should be included in the registry.
Discovery plugins are found through the plugin system. If additional discovery plugins need to be specified, a client can pass them to SetExtraDiscoveryPlugins()
.
When the registry is first told about the discovery plugins, the plugins will be asked to discover nodes. These plugins will generate SdrShaderNodeDiscoveryResult
instances, which only contain basic metadata. Once the client asks for information that would require the node's contents to be parsed (eg, what its inputs and outputs are), the registry will begin the parsing process on an as-needed basis. See SdrShaderNodeDiscoveryResult
for the information that can be retrieved without triggering a parse.
Some methods in this library may allow for a "family" to be provided. A family is simply a generic grouping which is optional.
Definition at line 55 of file registry.h.
using SdrRegistry::DiscoveryPluginRefPtrVec = SdrDiscoveryPluginRefPtrVector |
Definition at line 58 of file registry.h.
|
protected |
|
protected |
SDR_API void SdrRegistry::AddDiscoveryResult | ( | SdrShaderNodeDiscoveryResult && | discoveryResult | ) |
Allows the client to explicitly set additional discovery results that would otherwise NOT be found through the plugin system. For example to support lazily-loaded plugins which cannot be easily discovered in advance.
This method will not immediately spawn a parse call which will be deferred until a GetShaderNode*() method is called.
SDR_API void SdrRegistry::AddDiscoveryResult | ( | const SdrShaderNodeDiscoveryResult & | discoveryResult | ) |
Copy version of the method above. For performance reasons, one should prefer to use the rvalue reference form. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
SDR_API SdrTokenVec SdrRegistry::GetAllShaderNodeSourceTypes | ( | ) | const |
Get a sorted list of all shader node source types that may be present on the nodes in the registry.
Source types originate from the discovery process, but there is no guarantee that the discovered source types will also have a registered parser plugin. The actual supported source types here depend on the parsers that are available. Also note that some parser plugins may not advertise a source type.
See the documentation for SdrParserPlugin
and SdrShaderNode::GetSourceType()
for more information.
|
static |
Get the single SdrRegistry
instance.
SDR_API SdrShaderNodeConstPtr SdrRegistry::GetShaderNodeByIdentifier | ( | const SdrIdentifier & | identifier, |
const SdrTokenVec & | typePriority = SdrTokenVec() |
||
) |
Get the shader node with the specified identifier
, and an optional sourceTypePriority
list specifying the set of node SOURCE types (see SdrShaderNode::GetSourceType()
) that should be searched.
If no sourceTypePriority is specified, the first encountered node with the specified identifier will be returned (first is arbitrary) if found.
If a sourceTypePriority list is specified, then this will iterate through each source type and try to find a node matching by identifier. This is equivalent to calling SdrRegistry::GetShaderNodeByIdentifierAndType for each source type until a node is found.
Nodes of the same identifier but different source type can exist in the registry. If a node 'Foo' with source types 'abc' and 'xyz' exist in the registry, and you want to make sure the 'abc' version is fetched before the 'xyz' version, the priority list would be specified as ['abc', 'xyz']. If the 'abc' version did not exist in the registry, then the 'xyz' version would be returned.
Returns nullptr
if a node matching the arguments can't be found.
SDR_API SdrShaderNodeConstPtr SdrRegistry::GetShaderNodeByIdentifierAndType | ( | const SdrIdentifier & | identifier, |
const TfToken & | nodeType | ||
) |
Get the shader node with the specified identifier
and sourceType
. If there is no matching node for the sourceType, nullptr is returned.
SDR_API SdrShaderNodeConstPtr SdrRegistry::GetShaderNodeByName | ( | const std::string & | name, |
const NdrTokenVec & | typePriority, | ||
NdrVersionFilter | filter | ||
) |
Get the shader node with the specified name.
SDR_API SdrShaderNodeConstPtr SdrRegistry::GetShaderNodeByName | ( | const std::string & | name, |
const SdrTokenVec & | typePriority = SdrTokenVec() , |
||
SdrVersionFilter | filter = SdrVersionFilterDefaultOnly |
||
) |
Get the shader node with the specified name. An optional priority list specifies the set of node SOURCE types (
Optionally, a filter can be specified to consider just the default versions of nodes matching name
(the default) or all versions of the nodes.
SDR_API SdrShaderNodeConstPtr SdrRegistry::GetShaderNodeByNameAndType | ( | const std::string & | name, |
const TfToken & | nodeType, | ||
NdrVersionFilter | filter | ||
) |
A convenience wrapper around GetShaderNodeByName()
.
SDR_API SdrShaderNodeConstPtr SdrRegistry::GetShaderNodeByNameAndType | ( | const std::string & | name, |
const TfToken & | nodeType, | ||
SdrVersionFilter | filter = SdrVersionFilterDefaultOnly |
||
) |
A convenience wrapper around GetShaderNodeByName()
. Instead of providing a priority list, an exact type is specified, and nullptr
is returned if a node with the exact identifier and type does not exist.
Optionally, a filter can be specified to consider just the default versions of nodes matching name
(the default) or all versions of the nodes.
SDR_API SdrShaderNodeConstPtr SdrRegistry::GetShaderNodeFromAsset | ( | const SdfAssetPath & | shaderAsset, |
const SdrTokenMap & | metadata = SdrTokenMap() , |
||
const TfToken & | subIdentifier = TfToken() , |
||
const TfToken & | sourceType = TfToken() |
||
) |
Parses the given asset
, constructs a SdrShaderNode from it and adds it to the registry.
Nodes created from an asset using this API can be looked up by the unique identifier and sourceType of the returned node, or by URI, which will be set to the unresolved asset path value.
metadata
contains additional metadata needed for parsing and compiling the source code in the file pointed to by asset
correctly. This metadata supplements the metadata available in the asset and overrides it in cases where there are key collisions.
subidentifier
is optional, and it would be used to indicate a particular definition in the asset file if the asset contains multiple node definitions.
sourceType
is optional, and it is only needed to indicate a particular type if the asset file is capable of representing a node definition of multiple source types.
Returns a valid node if the asset is parsed successfully using one of the registered parser plugins.
SDR_API SdrShaderNodeConstPtr SdrRegistry::GetShaderNodeFromSourceCode | ( | const std::string & | sourceCode, |
const TfToken & | sourceType, | ||
const SdrTokenMap & | metadata = SdrTokenMap() |
||
) |
Parses the given sourceCode
string, constructs a SdrShaderNode from it and adds it to the registry. The parser to be used is determined by the specified sourceType
.
Nodes created from source code using this API can be looked up by the unique identifier and sourceType of the returned node.
metadata
contains additional metadata needed for parsing and compiling the source code correctly. This metadata supplements the metadata available in sourceCode
and overrides it cases where there are key collisions.
Returns a valid node if the given source code is parsed successfully using the parser plugins that is registered for the specified sourceType
.
SDR_API SdrIdentifierVec SdrRegistry::GetShaderNodeIdentifiers | ( | const TfToken & | family = TfToken() , |
SdrVersionFilter | filter = SdrVersionFilterDefaultOnly |
||
) | const |
Get identifiers of all the shader nodes that the registry is aware of.
This will not run the parsing plugins on the nodes that have been discovered, so this method is relatively quick. Optionally, a "family" name can be specified to only get the identifiers of nodes that belong to that family and a filter can be specified to get just the default version (the default) or all versions of the node.
SDR_API SdrStringVec SdrRegistry::GetShaderNodeNames | ( | const TfToken & | family = TfToken() | ) | const |
Get the names of all the shader nodes that the registry is aware of.
This will not run the parsing plugins on the nodes that have been discovered, so this method is relatively quick. Optionally, a "family" name can be specified to only get the names of nodes that belong to that family.
SDR_API SdrShaderNodePtrVec SdrRegistry::GetShaderNodesByFamily | ( | const TfToken & | family, |
NdrVersionFilter | filter | ||
) |
Get all shader nodes, optionally restricted to the nodes that fall under a specified family and/or the default version.
SDR_API SdrShaderNodePtrVec SdrRegistry::GetShaderNodesByFamily | ( | const TfToken & | family = TfToken() , |
SdrVersionFilter | filter = SdrVersionFilterDefaultOnly |
||
) |
Get all shader nodes, optionally restricted to the nodes that fall under a specified family and/or the default version.
Note that this will parse all nodes that the registry is aware of (unless a family is specified), so this may take some time to run the first time it is called.
SDR_API SdrShaderNodePtrVec SdrRegistry::GetShaderNodesByIdentifier | ( | const SdrIdentifier & | identifier | ) |
Get all shader nodes matching the given identifier (multiple nodes of the same identifier, but different source types, may exist). If no nodes match the identifier, an empty vector is returned.
SDR_API SdrShaderNodePtrVec SdrRegistry::GetShaderNodesByName | ( | const std::string & | name, |
NdrVersionFilter | filter | ||
) |
Get all shader nodes matching the given name.
SDR_API SdrShaderNodePtrVec SdrRegistry::GetShaderNodesByName | ( | const std::string & | name, |
SdrVersionFilter | filter = SdrVersionFilterDefaultOnly |
||
) |
Get all shader nodes matching the given name. Only nodes matching the specified name will be parsed. Optionally, a filter can be specified to get just the default version (the default) or all versions of the node. If no nodes match an empty vector is returned.
|
friend |
Definition at line 300 of file registry.h.