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
34class HdSceneIndexPlugin;
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
81 HD_API
82 HdSceneIndexBaseRefPtr AppendSceneIndicesForRenderer(
83 const std::string &rendererDisplayName,
84 const HdSceneIndexBaseRefPtr &inputScene,
85 const std::string &renderInstanceId=std::string(),
86 const std::string &appName=std::string());
87
88 enum InsertionOrder
89 {
90 InsertionOrderAtStart,
91 InsertionOrderAtEnd,
92 };
93
94 using InsertionPhase = int;
95
140 HD_API
142 const std::string &rendererDisplayName,
143 const TfToken &sceneIndexPluginId,
144 const HdContainerDataSourceHandle &inputArgs,
145 InsertionPhase insertionPhase,
146 InsertionOrder insertionOrder);
147
148
149 using SceneIndexAppendCallback =
150 std::function<
151 HdSceneIndexBaseRefPtr(
152 const std::string &renderInstanceId,
153 const HdSceneIndexBaseRefPtr &inputScene,
154 const HdContainerDataSourceHandle &inputArgs)>;
155
182 HD_API
184 const std::string &rendererDisplayName,
185 SceneIndexAppendCallback callback,
186 const HdContainerDataSourceHandle &inputArgs,
187 InsertionPhase insertionPhase,
188 InsertionOrder insertionOrder);
189
196 HD_API
197 std::vector<TfToken> LoadAndGetSceneIndexPluginIds(
198 const std::string& rendererDisplayName,
199 const std::string& appName);
200
201 struct PluginInsertionMetadata
202 {
203 std::string rendererDisplayName;
204 TfToken sceneIndexPluginId;
205 int insertionPhase = -1;
206 };
207
212 bool
214 const HdSceneIndexBaseRefPtr& sceneIndex,
215 PluginInsertionMetadata& metadata);
216
225 {
229
233
237 Hybrid
238 };
239
242 HD_API
243 void
245
246protected:
247
249 const PlugRegistry &plugRegistry, const TfType &pluginType) override;
250
251private:
253
254 // Singleton gets private constructed
257
258 void _LoadPluginsForRenderer(
259 const std::string &rendererDisplayName,
260 const std::string &appName);
261
262 HdSceneIndexPlugin *_GetSceneIndexPlugin(const TfToken &pluginId);
263
264 struct _Impl;
265 std::unique_ptr<_Impl> _impl;
266};
267
268template<typename T, typename... Bases>
270{
271 HfPluginRegistry::Define<T, HdSceneIndexPlugin, Bases...>();
272}
273
274PXR_NAMESPACE_CLOSE_SCOPE
275
276#endif // PXR_IMAGING_HD_SCENE_INDEX_PLUGIN_REGISTRY_H
A registry for renderer- and application-specific scene indices.
static HD_API HdSceneIndexPluginRegistry & GetInstance()
Returns the singleton registry for HdSceneIndexPlugin.
HD_API HdSceneIndexBaseRefPtr AppendSceneIndicesForRenderer(const std::string &rendererDisplayName, const HdSceneIndexBaseRefPtr &inputScene, const std::string &renderInstanceId=std::string(), const std::string &appName=std::string())
Append scene indices generated by plug-ins registered (via RegisterSceneIndexForRenderer) for this re...
bool GetPluginInsertionMetadataForSceneIndex(const HdSceneIndexBaseRefPtr &sceneIndex, PluginInsertionMetadata &metadata)
Gets metadata about the plugin that inserted the given scene index, if available.
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:71
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.
Definition: staticTokens.h:92
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
Pointer storage with deletion detection.