Loading...
Searching...
No Matches
sceneIndexPluginRegistry.h
1//
2// Copyright 2021 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_IMAGING_HD_SCENE_INDEX_PLUGIN_REGISTRY_H
8#define PXR_IMAGING_HD_SCENE_INDEX_PLUGIN_REGISTRY_H
9
10#include "pxr/imaging/hd/api.h"
11#include "pxr/imaging/hd/sceneIndex.h"
12#include "pxr/imaging/hd/sceneIndexObserver.h"
13#include "pxr/imaging/hf/pluginRegistry.h"
14
17#include "pxr/base/tf/token.h"
18#include "pxr/base/tf/weakPtr.h"
19
20#include "pxr/pxr.h"
21
22#include <string>
23#include <memory>
24
25PXR_NAMESPACE_OPEN_SCOPE
26
27#define HDSCENEINDEXPLUGINREGISTRY_TOKENS \
28 ((rendererDisplayName, "__rendererDisplayName")) \
29 ((allRenderers, ""))
30
31TF_DECLARE_PUBLIC_TOKENS(HdSceneIndexPluginRegistryTokens, HD_API,
32 HDSCENEINDEXPLUGINREGISTRY_TOKENS);
33
35
40{
41public:
45 HD_API
47
51 template<typename T, typename... Bases>
52 static void Define();
53
59 HD_API
60 HdSceneIndexBaseRefPtr AppendSceneIndex(
61 const TfToken &sceneIndexPluginId,
62 const HdSceneIndexBaseRefPtr &inputScene,
63 const HdContainerDataSourceHandle &inputArgs,
64 const std::string &renderInstanceId=std::string());
65
89 HD_API
90 HdSceneIndexBaseRefPtr AppendSceneIndicesForRenderer(
91 const std::string &rendererDisplayName,
92 const HdSceneIndexBaseRefPtr &inputScene,
93 const std::string &renderInstanceId=std::string(),
94 const std::string &appName=std::string(),
95 const HdContainerDataSourceHandle &sceneIndexCreateArgs=nullptr);
96
97 enum InsertionOrder
98 {
99 InsertionOrderAtStart,
100 InsertionOrderAtEnd,
101 };
102
103 using InsertionPhase = int;
104
149 HD_API
151 const std::string &rendererDisplayName,
152 const TfToken &sceneIndexPluginId,
153 const HdContainerDataSourceHandle &inputArgs,
154 InsertionPhase insertionPhase,
155 InsertionOrder insertionOrder);
156
157
158 using SceneIndexAppendCallback =
159 std::function<
160 HdSceneIndexBaseRefPtr(
161 const std::string &renderInstanceId,
162 const HdSceneIndexBaseRefPtr &inputScene,
163 const HdContainerDataSourceHandle &inputArgs)>;
164
191 HD_API
193 const std::string &rendererDisplayName,
194 SceneIndexAppendCallback callback,
195 const HdContainerDataSourceHandle &inputArgs,
196 InsertionPhase insertionPhase,
197 InsertionOrder insertionOrder);
198
205 HD_API
206 std::vector<TfToken> LoadAndGetSceneIndexPluginIds(
207 const std::string& rendererDisplayName,
208 const std::string& appName);
209
210 struct PluginInsertionMetadata
211 {
212 std::string rendererDisplayName;
213 TfToken sceneIndexPluginId;
214 int insertionPhase = -1;
215 };
216
221 bool
223 const HdSceneIndexBaseRefPtr& sceneIndex,
224 PluginInsertionMetadata& metadata);
225
234 {
238
242
246 Hybrid
247 };
248
251 HD_API
252 void
254
255protected:
256
258 const PlugRegistry &plugRegistry, const TfType &pluginType) override;
259
260private:
262
263 // Singleton gets private constructed
266
267 void _LoadPluginsForRenderer(
268 const std::string &rendererDisplayName,
269 const std::string &appName);
270
271 HdSceneIndexPlugin *_GetSceneIndexPlugin(const TfToken &pluginId);
272
273 struct _Impl;
274 std::unique_ptr<_Impl> _impl;
275};
276
277template<typename T, typename... Bases>
282
283PXR_NAMESPACE_CLOSE_SCOPE
284
285#endif // PXR_IMAGING_HD_SCENE_INDEX_PLUGIN_REGISTRY_H
A scene index plugin bundles one or more (typically filtering) scene indices together and enables the...
A registry for renderer- and application-specific scene indices.
static HD_API HdSceneIndexPluginRegistry & GetInstance()
Returns the singleton registry for HdSceneIndexPlugin.
bool GetPluginInsertionMetadataForSceneIndex(const HdSceneIndexBaseRefPtr &sceneIndex, PluginInsertionMetadata &metadata)
Gets metadata about the plugin that inserted the given scene index, if available.
HD_API HdSceneIndexBaseRefPtr AppendSceneIndicesForRenderer(const std::string &rendererDisplayName, const HdSceneIndexBaseRefPtr &inputScene, const std::string &renderInstanceId=std::string(), const std::string &appName=std::string(), const HdContainerDataSourceHandle &sceneIndexCreateArgs=nullptr)
Append scene indices generated by plug-ins registered (via RegisterSceneIndexForRenderer) for this re...
HD_API void RegisterSceneIndexForRenderer(const std::string &rendererDisplayName, SceneIndexAppendCallback callback, const HdContainerDataSourceHandle &inputArgs, InsertionPhase insertionPhase, InsertionOrder insertionOrder)
Register a scene index to be instantiated via a callback for a specified renderer (or all renderers i...
static void Define()
Entry point for defining an HdSceneIndexPlugin plugin.
HD_API void RegisterSceneIndexForRenderer(const std::string &rendererDisplayName, const TfToken &sceneIndexPluginId, const HdContainerDataSourceHandle &inputArgs, InsertionPhase insertionPhase, InsertionOrder insertionOrder)
Register a scene index plugin to be instantiated for a specified renderer (or all renderers if render...
PluginOrderingPolicy
Enum to specify the policy for determining the order of scene index plugins.
@ JsonMetadataOnly
The tags and ordering specified in the JSON metadata are used to drive the ordering of scene index pl...
@ CppRegistrationOnly
The order of plugins is determined solely by the insertion phase/order arguments of the C++ registrat...
@ Hybrid
A hybrid ordering scheme where we attempt to honor both the insertion phase/order specified via the C...
void _CollectAdditionalMetadata(const PlugRegistry &plugRegistry, const TfType &pluginType) override
Gives subclasses an opportunity to inspect plugInfo-based metadata at the time of discovery.
HD_API std::vector< TfToken > LoadAndGetSceneIndexPluginIds(const std::string &rendererDisplayName, const std::string &appName)
Loads plugins for rendererDisplayName and appName.
HD_API HdSceneIndexBaseRefPtr AppendSceneIndex(const TfToken &sceneIndexPluginId, const HdSceneIndexBaseRefPtr &inputScene, const HdContainerDataSourceHandle &inputArgs, const std::string &renderInstanceId=std::string())
Given a specific scene index plug-in id, give the plug-in a chance to add scene indices to the end of...
HD_API void SetPluginOrderingPolicy(PluginOrderingPolicy policy)
Sets the policy for determining the order of scene index plugins.
Base class for registering Hydra plugins using the plug mechanism.
static void Define()
Entry point for registering a types implementation.
Defines an interface for registering plugins.
Definition registry.h:319
Manage a single instance of an object (see.
Definition singleton.h:107
Token for efficient comparison, assignment, and hashing of known strings.
Definition token.h:81
TfType represents a dynamic runtime type.
Definition type.h:48
Manage a single instance of an object.
This file defines some macros that are useful for declaring and using static TfTokens.
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
Pointer storage with deletion detection.