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
49 using DiscoveryPluginRefPtrVec = SdrDiscoveryPluginRefPtrVector;
121 SdrVersionFilterDefaultOnly)
const;
158 const SdrTokenVec& shadingSystemPriority = SdrTokenVec());
192 const std::string& name,
193 const SdrTokenVec& shadingSystemPriority = SdrTokenVec(),
207 const std::string& name,
224 const std::string& name,
253 const SdrTokenMap &metadata=SdrTokenMap(),
274 const std::string &sourceCode,
276 const SdrTokenMap &metadata=SdrTokenMap());
290 const std::string& name,
377 class _DiscoveryContext;
378 friend class _DiscoveryContext;
380 using _TypeToParserPluginMap =
381 std::unordered_map<TfToken, SdrParserPlugin*, TfToken::HashFunctor>;
385 using _ShaderNodeMapKey = std::pair<SdrIdentifier, TfToken>;
386 using _ShaderNodeMap =
387 std::unordered_map<_ShaderNodeMapKey, SdrShaderNodeUniquePtr, TfHash>;
391 using _DiscoveryResultsByIdentifier = std::unordered_multimap<
393 using _DiscoveryResultsByIdentifierRange =
394 std::pair<_DiscoveryResultsByIdentifier::const_iterator,
395 _DiscoveryResultsByIdentifier::const_iterator>;
400 using _DiscoveryResultPtrsByName = std::unordered_multimap<
402 using _DiscoveryResultPtrsByNameRange =
403 std::pair<_DiscoveryResultPtrsByName::const_iterator,
404 _DiscoveryResultPtrsByName::const_iterator>;
408 mutable std::mutex _discoveryResultMutex;
413 mutable std::mutex _nodeMapMutex;
417 void _RunDiscoveryPlugins(
418 const DiscoveryPluginRefPtrVec& discoveryPlugins);
425 void _FindAndInstantiateDiscoveryPlugins();
428 void _FindAndInstantiateParserPlugins();
432 void _InstantiateParserPlugins(
const std::set<TfType>& parserPluginTypes);
439 SdrShaderNodeConstPtr _ParseNodeFromAssetOrSourceCode(
445 SdrShaderNodeConstPtr _GetNodeInIdentifierRangeWithShadingSystem(
446 _DiscoveryResultsByIdentifierRange range,
452 SdrShaderNodeConstPtr _GetNodeInNameRangeWithShadingSystem(
453 _DiscoveryResultPtrsByNameRange range,
const TfToken& shadingSystem,
457 SdrShaderNodeConstPtr _FindNodeInCache(
458 const _ShaderNodeMapKey &key)
const;
464 SdrShaderNodeConstPtr _InsertNodeInCache(
465 _ShaderNodeMapKey &&key, SdrShaderNodeUniquePtr &&node);
471 SdrShaderNodeConstPtr _FindOrParseNodeInCache(
477 _GetParserForDiscoveryType(
const TfToken& discoveryType)
const;
481 DiscoveryPluginRefPtrVec _discoveryPlugins;
485 _TypeToParserPluginMap _parserPluginMap;
488 std::vector<std::unique_ptr<SdrParserPlugin>> _parserPlugins;
493 _DiscoveryResultsByIdentifier _discoveryResultsByIdentifier;
494 _DiscoveryResultPtrsByName _discoveryResultPtrsByName;
503 _ShaderNodeMap _nodeMap;
506PXR_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 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 GetShaderNodeByName(const std::string &name, const SdrTokenVec &shadingSystemPriority=SdrTokenVec(), SdrVersionFilter filter=SdrVersionFilterDefaultOnly)
Get the shader node with the specified name.
SDR_API SdrShaderNodeConstPtr GetShaderNodeFromSourceCode(const std::string &sourceCode, const TfToken &shadingSystem, const SdrTokenMap &metadata=SdrTokenMap())
Parses the given sourceCode string, constructs a SdrShaderNode from it and adds it to the registry.
SDR_API SdrShaderNodeConstPtr GetShaderNodeByNameAndSystem(const std::string &name, const TfToken &shadingSystem, SdrVersionFilter filter=SdrVersionFilterDefaultOnly)
A convenience wrapper around GetShaderNodeByName().
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 GetShaderNodesByFunction(const TfToken &function=TfToken(), SdrVersionFilter filter=SdrVersionFilterDefaultOnly)
Get all shader nodes, optionally restricted to the nodes that fall under a specified family and/or th...
SDR_API SdrTokenVec GetAllShaderNodeShadingSystems() const
Get a sorted list of all shader node shading systems that may be present on the nodes in the registry...
SDR_API void ParseAll()
Parses all unparsed shader nodes.
SDR_API SdrShaderNodeConstPtr GetShaderNodeByIdentifierAndSystem(const SdrIdentifier &identifier, const TfToken &shadingSystem)
Get the shader node with the specified identifier and shadingSystem.
SDR_API SdrShaderNodeConstPtr GetShaderNodeFromAsset(const SdfAssetPath &shaderAsset, const SdrTokenMap &metadata=SdrTokenMap(), const TfToken &subIdentifier=TfToken(), const TfToken &shadingSystem=TfToken())
Parses the given asset, constructs a SdrShaderNode from it and adds it to the registry.
SDR_API SdrIdentifierVec GetShaderNodeIdentifiers(const TfToken &function=TfToken(), SdrVersionFilter filter=SdrVersionFilterDefaultOnly) const
Get identifiers of all the shader nodes that the registry is aware of.
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 SdrStringVec GetShaderNodeNames(const TfToken &function=TfToken()) const
Get the names of all the shader nodes that the registry is aware of.
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 void AddDiscoveryResult(const SdrShaderNodeDiscoveryResult &discoveryResult)
Copy version of the method above.
SDR_API SdrShaderNodeConstPtr GetShaderNodeByIdentifier(const SdrIdentifier &identifier, const SdrTokenVec &shadingSystemPriority=SdrTokenVec())
Get the shader node with the specified identifier, and an optional shadingSystemPriority list specify...
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 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.