HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sceneIndexPluginRegistry.h
Go to the documentation of this file.
1 //
2 // Copyright 2021 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXR_IMAGING_HD_SCENE_INDEX_PLUGIN_REGISTRY_H
25 #define PXR_IMAGING_HD_SCENE_INDEX_PLUGIN_REGISTRY_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/base/tf/singleton.h"
31 #include "pxr/imaging/hd/api.h"
33 
35 
36 #define HDSCENEINDEXPLUGINREGISTRY_TOKENS \
37  ((rendererDisplayName, "__rendererDisplayName")) \
38 
39 
40 TF_DECLARE_PUBLIC_TOKENS(HdSceneIndexPluginRegistryTokens, HD_API,
42 
43 
44 
45 class HdSceneIndexPlugin;
46 
48 {
49 public:
50  ///
51  /// Returns the singleton registry for \c HdSceneIndexPlugin
52  ///
53  HD_API
55 
56  ///
57  /// Entry point for defining an HdSceneIndexPlugin plugin.
58  ///
59  template<typename T, typename... Bases>
60  static void Define();
61 
62  ///
63  /// Given a specific scene index plug-in id, give the plug-in a chance
64  /// to add scene indices to the end of the chain. Return value is the
65  /// last scene index -- or inputScene if the plug-in chooses not to act.
66  /// Input arguments may be nullptr if not relevant to this plug-in.
67  HD_API
68  HdSceneIndexBaseRefPtr AppendSceneIndex(
69  const TfToken &sceneIndexPluginId,
70  const HdSceneIndexBaseRefPtr &inputScene,
71  const HdContainerDataSourceHandle &inputArgs);
72 
73  ///
74  /// Append scene indices generated by plug-ins registered (via
75  /// RegisterSceneIndexForRenderer) for this renderer. Return value is the
76  /// last scene index -- or inputScene if no plugins are registered or
77  /// taking action. This also includes plug-ins registered for all
78  /// renderers (via an empty rendererDisplayName) to be added in advance
79  /// of any registered for the specified rendeer.
80  HD_API
81  HdSceneIndexBaseRefPtr AppendSceneIndicesForRenderer(
82  const std::string &rendererDisplayName,
83  const HdSceneIndexBaseRefPtr &inputScene);
84 
86  {
89  };
90 
91  using InsertionPhase = unsigned int;
92 
93  ///
94  /// Register a scene index to be instantiated whenever a specified
95  /// renderer (or all renderers if rendererDisplayName is empty).
96  ///
97  /// Insertion phase is a broad ordering value with lower values indicating
98  /// earlier instantiation (possibly given render plugin-specific meaning
99  /// via enum values). Insertion order indicates whether this entry
100  /// should go at the start or end of the specified phase.
101  HD_API
103  const std::string &rendererDisplayName,
104  const TfToken &sceneIndexPluginId,
105  const HdContainerDataSourceHandle &inputArgs,
106  InsertionPhase insertionPhase,
107  InsertionOrder insertionOrder);
108 
109 protected:
110 
112  const PlugRegistry &plugRegistry, const TfType &pluginType) override;
113 
114 private:
116 
117  // Singleton gets private constructed
119  ~HdSceneIndexPluginRegistry() override;
120 
121  HdSceneIndexPlugin *_GetSceneIndexPlugin(const TfToken &pluginId);
122 
123  struct _Entry
124  {
125  _Entry(const TfToken &sceneIndexPluginId,
126  const HdContainerDataSourceHandle &args)
127  : sceneIndexPluginId(sceneIndexPluginId)
128  , args(args)
129  {}
130 
131  TfToken sceneIndexPluginId;
132  HdContainerDataSourceHandle args;
133  };
134 
135  using _EntryList = std::vector<_Entry>;
136  using _PhasesMap = std::map<InsertionPhase, _EntryList>;
137  using _RenderersMap = std::map<std::string, _PhasesMap>;
138 
139  HdSceneIndexBaseRefPtr _AppendForPhases(
140  const HdSceneIndexBaseRefPtr &inputScene,
141  const _PhasesMap &phasesMap,
142  const HdContainerDataSourceHandle &argsUnderlay);
143 
144  _RenderersMap _sceneIndicesForRenderers;
145 
146  // Used to track plugins whose plugInfo entries contain "loadWithRenderer"
147  // values to load when the specified renderer or renderers are used.
148  // Loading the plug-in allows for further registration code to run when
149  // a plug-in wouldn't be loaded elsewhere.
150  using _PreloadMap = std::map<std::string, TfTokenVector>;
151  _PreloadMap _preloadsForRenderer;
152 
153 };
154 
155 template<typename T, typename... Bases>
157 {
159 }
160 
162 
163 #endif // PXR_IMAGING_HD_SCENE_INDEX_PLUGIN_REGISTRY_H
void _CollectAdditionalMetadata(const PlugRegistry &plugRegistry, const TfType &pluginType) override
#define HD_API
Definition: api.h:40
static HD_API HdSceneIndexPluginRegistry & GetInstance()
Definition: token.h:87
#define HDSCENEINDEXPLUGINREGISTRY_TOKENS
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
HD_API void RegisterSceneIndexForRenderer(const std::string &rendererDisplayName, const TfToken &sceneIndexPluginId, const HdContainerDataSourceHandle &inputArgs, InsertionPhase insertionPhase, InsertionOrder insertionOrder)
HD_API HdSceneIndexBaseRefPtr AppendSceneIndex(const TfToken &sceneIndexPluginId, const HdSceneIndexBaseRefPtr &inputScene, const HdContainerDataSourceHandle &inputArgs)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1394
static void Define()
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
TF_DECLARE_PUBLIC_TOKENS(HdSceneIndexPluginRegistryTokens, HD_API, HDSCENEINDEXPLUGINREGISTRY_TOKENS)
**If you just want to fire and args
Definition: thread.h:609
Definition: type.h:64
HD_API HdSceneIndexBaseRefPtr AppendSceneIndicesForRenderer(const std::string &rendererDisplayName, const HdSceneIndexBaseRefPtr &inputScene)