8#ifndef PXR_USD_SDR_REGISTRY_H
9#define PXR_USD_SDR_REGISTRY_H
15#include "pxr/usd/sdr/api.h"
20#include "pxr/usd/sdr/shaderNodeQuery.h"
26PXR_NAMESPACE_OPEN_SCOPE
53 using DiscoveryPluginRefPtrVec = SdrDiscoveryPluginRefPtrVector;
125 SdrVersionFilterDefaultOnly)
const;
160 const SdrTokenVec& typePriority = SdrTokenVec());
181 const std::string& name,
182 const SdrTokenVec& typePriority = SdrTokenVec(),
195 const std::string& name,
224 const SdrTokenMap &metadata=SdrTokenMap(),
245 const std::string &sourceCode,
247 const SdrTokenMap &metadata=SdrTokenMap());
261 const std::string& name,
330 class _DiscoveryContext;
331 friend class _DiscoveryContext;
333 using _TypeToParserPluginMap =
334 std::unordered_map<TfToken, SdrParserPlugin*, TfToken::HashFunctor>;
338 using _ShaderNodeMapKey = std::pair<SdrIdentifier, TfToken>;
339 using _ShaderNodeMap =
340 std::unordered_map<_ShaderNodeMapKey, SdrShaderNodeUniquePtr, TfHash>;
344 using _DiscoveryResultsByIdentifier = std::unordered_multimap<
346 using _DiscoveryResultsByIdentifierRange =
347 std::pair<_DiscoveryResultsByIdentifier::const_iterator,
348 _DiscoveryResultsByIdentifier::const_iterator>;
353 using _DiscoveryResultPtrsByName = std::unordered_multimap<
355 using _DiscoveryResultPtrsByNameRange =
356 std::pair<_DiscoveryResultPtrsByName::const_iterator,
357 _DiscoveryResultPtrsByName::const_iterator>;
361 mutable std::mutex _discoveryResultMutex;
366 mutable std::mutex _nodeMapMutex;
370 void _RunDiscoveryPlugins(
371 const DiscoveryPluginRefPtrVec& discoveryPlugins);
378 void _FindAndInstantiateDiscoveryPlugins();
381 void _FindAndInstantiateParserPlugins();
385 void _InstantiateParserPlugins(
const std::set<TfType>& parserPluginTypes);
392 SdrShaderNodeConstPtr _ParseNodeFromAssetOrSourceCode(
397 SdrShaderNodeConstPtr _GetNodeInIdentifierRangeWithSourceType(
398 _DiscoveryResultsByIdentifierRange range,
const TfToken& sourceType);
403 SdrShaderNodeConstPtr _GetNodeInNameRangeWithSourceType(
404 _DiscoveryResultPtrsByNameRange range,
const TfToken& sourceType,
408 SdrShaderNodeConstPtr _FindNodeInCache(
409 const _ShaderNodeMapKey &key)
const;
415 SdrShaderNodeConstPtr _InsertNodeInCache(
416 _ShaderNodeMapKey &&key, SdrShaderNodeUniquePtr &&node);
422 SdrShaderNodeConstPtr _FindOrParseNodeInCache(
428 _GetParserForDiscoveryType(
const TfToken& discoveryType)
const;
432 DiscoveryPluginRefPtrVec _discoveryPlugins;
436 _TypeToParserPluginMap _parserPluginMap;
439 std::vector<std::unique_ptr<SdrParserPlugin>> _parserPlugins;
444 _DiscoveryResultsByIdentifier _discoveryResultsByIdentifier;
445 _DiscoveryResultPtrsByName _discoveryResultPtrsByName;
454 _ShaderNodeMap _nodeMap;
457PXR_NAMESPACE_CLOSE_SCOPE
Contains an asset path and optional evaluated and resolved paths.
Interface for parser plugins.
The registry provides access to shader node information.
SDR_API SdrShaderNodeConstPtr GetShaderNodeByName(const std::string &name, const SdrTokenVec &typePriority=SdrTokenVec(), SdrVersionFilter filter=SdrVersionFilterDefaultOnly)
Get the shader node with the specified name.
SDR_API SdrShaderNodePtrVec 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 th...
SDR_API SdrShaderNodeConstPtr GetShaderNodeByIdentifierAndType(const SdrIdentifier &identifier, const TfToken &nodeType)
Get the shader node with the specified identifier and sourceType.
SDR_API SdrStringVec GetSearchURIs() const
Get the locations where the registry is searching for nodes.
SDR_API void SetExtraDiscoveryPlugins(const std::vector< TfType > &pluginTypes)
Allows the client to set any additional discovery plugins that would otherwise NOT be found through t...
SDR_API SdrShaderNodeConstPtr GetShaderNodeByIdentifier(const SdrIdentifier &identifier, const SdrTokenVec &typePriority=SdrTokenVec())
Get the shader node with the specified identifier, and an optional sourceTypePriority list specifying...
SDR_API void SetExtraParserPlugins(const std::vector< TfType > &pluginTypes)
Allows the client to set any additional parser plugins that would otherwise NOT be found through the ...
SDR_API void ParseAll()
Parses all unparsed shader nodes.
SDR_API SdrShaderNodePtrVec GetShaderNodesByIdentifier(const SdrIdentifier &identifier)
Get all shader nodes matching the given identifier (multiple nodes of the same identifier,...
SDR_API SdrShaderNodeConstPtr GetShaderNodeByNameAndType(const std::string &name, const TfToken &nodeType, SdrVersionFilter filter=SdrVersionFilterDefaultOnly)
A convenience wrapper around GetShaderNodeByName().
SDR_API SdrShaderNodePtrVec GetAllShaderNodes()
Parses all unparsed shader nodes and returns all shader nodes in the registry.
static SDR_API SdrRegistry & GetInstance()
Get the single SdrRegistry instance.
SDR_API SdrStringVec GetShaderNodeNames(const TfToken &family=TfToken()) const
Get the names of all the shader nodes that the registry is aware of.
SDR_API void AddDiscoveryResult(const SdrShaderNodeDiscoveryResult &discoveryResult)
Copy version of the method above.
SDR_API void AddDiscoveryResult(SdrShaderNodeDiscoveryResult &&discoveryResult)
Allows the client to explicitly set additional discovery results that would otherwise NOT be found th...
SDR_API void SetExtraDiscoveryPlugins(DiscoveryPluginRefPtrVec plugins)
Allows the client to set any additional discovery plugins that would otherwise NOT be found through t...
SDR_API SdrTokenVec GetAllShaderNodeSourceTypes() const
Get a sorted list of all shader node source types that may be present on the nodes in the registry.
SDR_API SdrShaderNodeQueryResult RunQuery(const SdrShaderNodeQuery &query)
Run an SdrShaderNodeQuery.
SDR_API SdrIdentifierVec GetShaderNodeIdentifiers(const TfToken &family=TfToken(), SdrVersionFilter filter=SdrVersionFilterDefaultOnly) const
Get identifiers of all the shader nodes that the registry is aware of.
SDR_API SdrShaderNodeConstPtr 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.
SDR_API SdrShaderNodeConstPtr 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.
SDR_API SdrShaderNodePtrVec GetShaderNodesByName(const std::string &name, SdrVersionFilter filter=SdrVersionFilterDefaultOnly)
Get all shader nodes matching the given name.
SdrShaderNodeQuery is a constraint-based query builder object that operates on all SdrShaderNodes con...
SdrShaderNodeQueryResult stores the results of an SdrShaderNodeQuery.
A user-extensible hashing mechanism for use with runtime hash tables.
Manage a single instance of an object (see.
Token for efficient comparison, assignment, and hashing of known strings.
std::set< TfToken, TfTokenFastArbitraryLessThan > Set
Predefined type for set of tokens, for when faster lookup is desired, without paying the memory or in...
Enable a concrete base class for use with TfWeakPtr.
Manage a single instance of an object.
Represents the raw data of a node, and some other bits of metadata, that were determined via a SdrDis...
SdrVersionFilter
Enumeration used to select nodes by version.