8#ifndef PXR_USD_SDR_REGISTRY_H
9#define PXR_USD_SDR_REGISTRY_H
15#include "pxr/usd/sdr/api.h"
25PXR_NAMESPACE_OPEN_SCOPE
52 using DiscoveryPluginRefPtrVec = SdrDiscoveryPluginRefPtrVector;
124 SdrVersionFilterDefaultOnly)
const;
159 const SdrTokenVec& typePriority = SdrTokenVec());
180 const std::string& name,
181 const SdrTokenVec& typePriority = SdrTokenVec(),
194 const std::string& name,
223 const SdrTokenMap &metadata=SdrTokenMap(),
244 const std::string &sourceCode,
246 const SdrTokenMap &metadata=SdrTokenMap());
260 const std::string& name,
301 class _DiscoveryContext;
302 friend class _DiscoveryContext;
304 using _TypeToParserPluginMap =
305 std::unordered_map<TfToken, SdrParserPlugin*, TfToken::HashFunctor>;
309 using _ShaderNodeMapKey = std::pair<SdrIdentifier, TfToken>;
310 using _ShaderNodeMap =
311 std::unordered_map<_ShaderNodeMapKey, SdrShaderNodeUniquePtr, TfHash>;
315 using _DiscoveryResultsByIdentifier = std::unordered_multimap<
317 using _DiscoveryResultsByIdentifierRange =
318 std::pair<_DiscoveryResultsByIdentifier::const_iterator,
319 _DiscoveryResultsByIdentifier::const_iterator>;
324 using _DiscoveryResultPtrsByName = std::unordered_multimap<
326 using _DiscoveryResultPtrsByNameRange =
327 std::pair<_DiscoveryResultPtrsByName::const_iterator,
328 _DiscoveryResultPtrsByName::const_iterator>;
332 mutable std::mutex _discoveryResultMutex;
336 mutable std::mutex _nodeMapMutex;
340 void _RunDiscoveryPlugins(
341 const DiscoveryPluginRefPtrVec& discoveryPlugins);
348 void _FindAndInstantiateDiscoveryPlugins();
351 void _FindAndInstantiateParserPlugins();
355 void _InstantiateParserPlugins(
const std::set<TfType>& parserPluginTypes);
362 SdrShaderNodeConstPtr _ParseNodeFromAssetOrSourceCode(
367 SdrShaderNodeConstPtr _GetNodeInIdentifierRangeWithSourceType(
368 _DiscoveryResultsByIdentifierRange range,
const TfToken& sourceType);
373 SdrShaderNodeConstPtr _GetNodeInNameRangeWithSourceType(
374 _DiscoveryResultPtrsByNameRange range,
const TfToken& sourceType,
378 SdrShaderNodeConstPtr _FindNodeInCache(
379 const _ShaderNodeMapKey &key)
const;
385 SdrShaderNodeConstPtr _InsertNodeInCache(
386 _ShaderNodeMapKey &&key, SdrShaderNodeUniquePtr &&node);
392 SdrShaderNodeConstPtr _FindOrParseNodeInCache(
398 _GetParserForDiscoveryType(
const TfToken& discoveryType)
const;
402 DiscoveryPluginRefPtrVec _discoveryPlugins;
406 _TypeToParserPluginMap _parserPluginMap;
409 std::vector<std::unique_ptr<SdrParserPlugin>> _parserPlugins;
414 _DiscoveryResultsByIdentifier _discoveryResultsByIdentifier;
415 _DiscoveryResultPtrsByName _discoveryResultPtrsByName;
424 _ShaderNodeMap _nodeMap;
427PXR_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 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.
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.