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,
310 class _DiscoveryContext;
311 friend class _DiscoveryContext;
313 using _TypeToParserPluginMap =
314 std::unordered_map<TfToken, SdrParserPlugin*, TfToken::HashFunctor>;
318 using _ShaderNodeMapKey = std::pair<SdrIdentifier, TfToken>;
319 using _ShaderNodeMap =
320 std::unordered_map<_ShaderNodeMapKey, SdrShaderNodeUniquePtr, TfHash>;
324 using _DiscoveryResultsByIdentifier = std::unordered_multimap<
326 using _DiscoveryResultsByIdentifierRange =
327 std::pair<_DiscoveryResultsByIdentifier::const_iterator,
328 _DiscoveryResultsByIdentifier::const_iterator>;
333 using _DiscoveryResultPtrsByName = std::unordered_multimap<
335 using _DiscoveryResultPtrsByNameRange =
336 std::pair<_DiscoveryResultPtrsByName::const_iterator,
337 _DiscoveryResultPtrsByName::const_iterator>;
341 mutable std::mutex _discoveryResultMutex;
346 mutable std::mutex _nodeMapMutex;
350 void _RunDiscoveryPlugins(
351 const DiscoveryPluginRefPtrVec& discoveryPlugins);
358 void _FindAndInstantiateDiscoveryPlugins();
361 void _FindAndInstantiateParserPlugins();
365 void _InstantiateParserPlugins(
const std::set<TfType>& parserPluginTypes);
372 SdrShaderNodeConstPtr _ParseNodeFromAssetOrSourceCode(
377 SdrShaderNodeConstPtr _GetNodeInIdentifierRangeWithSourceType(
378 _DiscoveryResultsByIdentifierRange range,
const TfToken& sourceType);
383 SdrShaderNodeConstPtr _GetNodeInNameRangeWithSourceType(
384 _DiscoveryResultPtrsByNameRange range,
const TfToken& sourceType,
388 SdrShaderNodeConstPtr _FindNodeInCache(
389 const _ShaderNodeMapKey &key)
const;
395 SdrShaderNodeConstPtr _InsertNodeInCache(
396 _ShaderNodeMapKey &&key, SdrShaderNodeUniquePtr &&node);
402 SdrShaderNodeConstPtr _FindOrParseNodeInCache(
408 _GetParserForDiscoveryType(
const TfToken& discoveryType)
const;
412 DiscoveryPluginRefPtrVec _discoveryPlugins;
416 _TypeToParserPluginMap _parserPluginMap;
419 std::vector<std::unique_ptr<SdrParserPlugin>> _parserPlugins;
424 _DiscoveryResultsByIdentifier _discoveryResultsByIdentifier;
425 _DiscoveryResultPtrsByName _discoveryResultPtrsByName;
434 _ShaderNodeMap _nodeMap;
437PXR_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 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().
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.