HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
renderIndex.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 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_RENDER_INDEX_H
8 #define PXR_IMAGING_HD_RENDER_INDEX_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hd/api.h"
12 #include "pxr/imaging/hd/version.h"
15 #include "pxr/imaging/hd/perfLog.h"
19 #include "pxr/imaging/hd/tokens.h"
20 
26 
27 #include "pxr/imaging/hf/perfLog.h"
28 
29 #include "pxr/usd/sdf/path.h"
30 
31 #include "pxr/base/gf/vec4i.h"
32 #include "pxr/base/tf/hashmap.h"
33 
34 #include <tbb/enumerable_thread_specific.h>
35 
36 #include <vector>
37 #include <unordered_map>
38 #include <memory>
39 
41 
42 class HdRprim;
43 class HdSprim;
44 class HdBprim;
45 class HdDrawItem;
46 class HdRprimCollection;
47 class HdSceneDelegate;
48 class HdRenderDelegate;
49 class HdExtComputation;
50 class VtValue;
51 class HdInstancer;
52 class HdDriver;
53 
54 using HdDriverVector = std::vector<HdDriver*>;
55 using HdRprimCollectionVector = std::vector<HdRprimCollection>;
56 using HdTaskSharedPtr = std::shared_ptr<class HdTask>;
57 using HdResourceRegistrySharedPtr = std::shared_ptr<class HdResourceRegistry>;
58 using HdTaskSharedPtrVector = std::vector<HdTaskSharedPtr>;
59 using HdTaskContext = std::unordered_map<TfToken,
60  VtValue,
62 
63 /// \class HdRenderIndex
64 ///
65 /// The Hydra render index is a flattened representation of the client scene
66 /// graph, which may be composed of several self-contained scene graphs, each of
67 /// which provides a HdSceneDelegate adapter for data access.
68 ///
69 /// Thus, multiple HdSceneDelegate's may be tied to the same HdRenderIndex.
70 ///
71 /// The render index, however, is tied to a single HdRenderDelegate, which
72 /// handles the actual creation and deletion of Hydra scene primitives. These
73 /// include geometry and non-drawable objects (such as the camera and texture
74 /// buffers). The render index simply holds a handle to these primitives, and
75 /// tracks any changes to them via the HdChangeTracker.
76 /// It also tracks computations and tasks that may update resources and render a
77 /// subset of the renderable primitives.
78 ///
79 /// The render index orchestrates the "syncing" of scene primitives, by
80 /// providing the relevant scene delegate for data access, and leaves resource
81 /// management to the rendering backend (via HdResourceRegistry).
82 ///
83 /// It also provides "execution" functionality for application facing Hydra
84 /// concepts (such as HdTask/HdRenderPass) in computing the set of HdDrawItems
85 /// for a given HdRprimCollection, for rendering.
86 ///
87 /// \sa
88 /// HdChangeTracker
89 /// HdDrawItem
90 /// HdRenderDelegate
91 /// HdRprimCollection
92 /// HdSceneDelegate
93 ///
94 /// \note
95 /// The current design ties a HdRenderIndex to a HdRenderDelegate.
96 /// However, the HdRenderIndex isn't tied to a viewer (viewport).
97 /// It is common to have multiple viewers image the composed scene (for example,
98 /// with different cameras), in which case the HdRenderIndex and
99 /// HdRenderDelegate are shared by the viewers.
100 ///
101 /// If two viewers use different HdRenderDelegate's, then it may unfortunately
102 /// require populating two HdRenderIndex's.
103 ///
104 class HdRenderIndex final
105 {
106 public:
107  typedef std::vector<HdDrawItem const*> HdDrawItemPtrVector;
108 
109  /// Create a render index with the given render delegate.
110  /// Returns null if renderDelegate is null.
111  /// The render delegate and render tasks may require access to a renderer's
112  /// device provided by the application. The objects can be
113  /// passed in as 'drivers'. Hgi is an example of a HdDriver.
114  // hgi = Hgi::CreatePlatformDefaultHgi()
115  // hgiDriver = new HdDriver<Hgi*>(HgiTokens→renderDriver, hgi)
116  // HdRenderIndex::New(_renderDelegate, {_hgiDriver})
117  //
118  /// "instanceName" is an optional identifier useful for applications to
119  /// associate this render index with related resources (such as the scene
120  /// index instances).
121  ///
122  /// "appName" is an application name that is used to load scene index
123  /// plugins that are enabled on a per-app basis, when scene index emulation
124  /// is enabled. See HdSceneIndexPluginRegistry for more information.
125  ///
126  HD_API
127  static HdRenderIndex* New(
128  HdRenderDelegate *renderDelegate,
129  HdDriverVector const& drivers,
130  const std::string &instanceName=std::string(),
131  const std::string &appName=std::string());
132 
133  /// Create a render index with the given render delegate that populates
134  /// itself by observing the given scene index.
135  /// Returns null if renderDelegate is null.
136  /// The render delegate and render tasks may require access to a renderer's
137  /// device provided by the application. The objects can be
138  /// passed in as 'drivers'. Hgi is an example of a HdDriver.
139  /// hgi = Hgi::CreatePlatformDefaultHgi()
140  /// hgiDriver = new HdDriver<Hgi*>(HgiTokens→renderDriver, hgi)
141  /// HdRenderIndex::New(_renderDelegate, {_hgiDriver})
142  ///
143  static HdRenderIndex *New(
144  HdRenderDelegate *renderDelegate,
145  HdDriverVector const& drivers,
146  HdSceneIndexBaseRefPtr const &terminalSceneIndex);
147 
148  /// Create a render index for "front-end" emulation. That is,
149  /// the render index can be populated from an HdSceneDelegate and
150  /// populates the returned emulation scene index.
151  ///
152  /// The HdRenderDelegate is not populated. It is just used by the
153  /// HdSceneDelegate for queries such as
154  /// HdRenderDelegate::GetMaterialBindingPurpose().
155  ///
156  static HdRenderIndex *
157  New(HdRenderDelegate *renderDelegate);
158 
159  HD_API
160  ~HdRenderIndex();
161 
162  /// Clear all r (render), s (state) and b (buffer) prims.
163  HD_API
164  void Clear();
165 
166  /// Clear all entries in the render index under
167  /// the given root and belong to a specified delegate.
168  ///
169  /// Used for example to unload a delegate.
170  HD_API
171  void RemoveSubtree(const SdfPath &root, HdSceneDelegate* sceneDelegate);
172 
173  // ---------------------------------------------------------------------- //
174  /// Given a prim id, returns the path of the corresponding rprim
175  /// or an empty path if none is found.
176  HD_API
177  SdfPath GetRprimPathFromPrimId(int primId) const;
178 
179  // ---------------------------------------------------------------------- //
180  /// \name Synchronization
181  // ---------------------------------------------------------------------- //
182 
183  /// Hydra's core currently needs to know the collections used by tasks
184  /// to aggregate the reprs that need to be synced for the dirty Rprims.
185  ///
186  HD_API
187  void EnqueueCollectionToSync(HdRprimCollection const &collection);
188 
189  /// Syncs input tasks, B & S prims, (external) computations and updates the
190  /// Rprim dirty list to then sync the Rprims.
191  /// At the end of this step, all the resources that need to be updated have
192  /// handles to their data sources.
193  /// This is the first phase in Hydra's execution. See HdEngine::Execute
194  HD_API
195  void SyncAll(HdTaskSharedPtrVector *tasks, HdTaskContext *taskContext);
196 
197  /// Returns true while a thread is invoking SyncAll().
198  HD_API bool IsSyncAllInProgress() const;
199 
200  // ---------------------------------------------------------------------- //
201  /// \name Execution
202  // ---------------------------------------------------------------------- //
203 
204  /// Returns a list of relevant draw items that match the criteria specified
205  // by renderTags and collection.
206  /// The is typically called during render pass execution, which is the
207  /// final phase in the Hydra's execution. See HdRenderPass::Execute
208  HD_API
210  TfTokenVector const& renderTags);
211 
212  // ---------------------------------------------------------------------- //
213  /// \name Change Tracker
214  // ---------------------------------------------------------------------- //
215 
216  HdChangeTracker& GetChangeTracker() { return _tracker; }
217  HdChangeTracker const& GetChangeTracker() const { return _tracker; }
218 
219  // ---------------------------------------------------------------------- //
220  /// \name Renderable prims (e.g. meshes, basis curves)
221  // ---------------------------------------------------------------------- //
222 
223  /// Returns whether the rprim type is supported by this render index.
224  HD_API
225  bool IsRprimTypeSupported(TfToken const& typeId) const;
226 
227  /// Insert a rprim into index
228  HD_API
229  void InsertRprim(TfToken const& typeId,
230  HdSceneDelegate* sceneDelegate,
231  SdfPath const& rprimId);
232 
233  /// Remove a rprim from index
234  HD_API
235  void RemoveRprim(SdfPath const& id);
236 
237  /// Returns true if rprim \p id exists in index.
238  bool HasRprim(SdfPath const& id) {
239  return _rprimMap.find(id) != _rprimMap.end();
240  }
241 
242  /// Returns the rprim of id
243  HD_API
244  HdRprim const *GetRprim(SdfPath const &id) const;
245 
246  /// Returns the scene delegate for the given rprim
247  HD_API
249 
250  /// Query function to return the id's of the scene delegate and instancer
251  /// associated with the Rprim at the given path.
252  ///
253  /// \deprecated. Query terminal scene index for prim and extract instancer
254  /// from HdInstancedBySchema instead.
255  ///
256  HD_API
258  SdfPath* sceneDelegateId,
259  SdfPath* instancerId) const;
260 
261  /// Returns the render tag for the given rprim
262  HD_API
263  TfToken GetRenderTag(SdfPath const& id) const;
264 
265  /// Like GetRenderTag, but updates the render tag if dirty.
266  TfToken UpdateRenderTag(SdfPath const& id,
267  HdDirtyBits bits);
268 
269  /// Returns a sorted list of all Rprims in the render index.
270  /// The list is sorted by std::less<SdfPath>
271  HD_API
272  const SdfPathVector &GetRprimIds() { return _rprimIds.GetIds(); }
273 
274 
275  /// Returns the subtree rooted under the given path.
276  HD_API
278 
279 
280  // ---------------------------------------------------------------------- //
281  /// \name Instancer Support
282  // ---------------------------------------------------------------------- //
283 
284  /// Insert an instancer into index
285  HD_API
286  void InsertInstancer(HdSceneDelegate* delegate,
287  SdfPath const &id);
288 
289  /// Remove an instancer from index
290  HD_API
291  void RemoveInstancer(SdfPath const& id);
292 
293  /// Returns true if instancer \p id exists in index.
294  bool HasInstancer(SdfPath const& id) {
295  return _instancerMap.find(id) != _instancerMap.end();
296  }
297 
298  /// Returns the instancer of id
299  HD_API
300  HdInstancer *GetInstancer(SdfPath const &id) const;
301 
302  // ---------------------------------------------------------------------- //
303  /// \name Task Support
304  // ---------------------------------------------------------------------- //
305 
306  /// \deprecated
307  ///
308  /// In Hydra 2.0, tasks are managed by a scene index such as the
309  /// HdxTaskControllerSceneIndex (reimplementing HdxTaskController).
310  ///
311  /// Inserts a new task into the render index with an identifier of \p id.
312  template <typename T>
313  void InsertTask(HdSceneDelegate* delegate, SdfPath const& id);
314 
315  /// \deprecated
316  ///
317  /// In Hydra 2.0, tasks are managed by a scene index such as the
318  /// HdxTaskControllerSceneIndex (reimplementing HdxTaskController).
319  ///
320  /// Removes the given task from the RenderIndex.
321  HD_API
322  void RemoveTask(SdfPath const& id);
323 
324  /// \deprecated
325  ///
326  /// In Hydra 2.0, tasks are managed by a scene index such as the
327  /// HdxTaskControllerSceneIndex (reimplementing HdxTaskController).
328  ///
329  /// Returns true if a task exists in the index with the given \p id.
330  bool HasTask(SdfPath const& id) {
331  return _taskMap.find(id) != _taskMap.end();
332  }
333 
334  /// Returns the task for the given \p id.
335  HD_API
336  HdTaskSharedPtr const& GetTask(SdfPath const& id) const;
337 
338  // ---------------------------------------------------------------------- //
339  /// \name Scene state prims (e.g. camera, light)
340  // ---------------------------------------------------------------------- //
341 
342  /// Returns whether the sprim type is supported by this render index.
343  HD_API
344  bool IsSprimTypeSupported(TfToken const& typeId) const;
345 
346  /// Insert a sprim into index
347  HD_API
348  void InsertSprim(TfToken const& typeId,
349  HdSceneDelegate* delegate,
350  SdfPath const& sprimId);
351 
352  HD_API
353  void RemoveSprim(TfToken const& typeId, SdfPath const &id);
354 
355  HD_API
356  HdSprim *GetSprim(TfToken const& typeId, SdfPath const &id) const;
357 
358  /// Returns the subtree rooted under the given path for the given sprim
359  /// type.
360  HD_API
361  SdfPathVector GetSprimSubtree(TfToken const& typeId,
362  SdfPath const& root);
363 
364  /// Returns the fullback prim for the Sprim of the given type.
365  HD_API
366  HdSprim *GetFallbackSprim(TfToken const& typeId) const;
367 
368 
369  // ---------------------------------------------------------------------- //
370  /// \name Buffer prims (e.g. textures, buffers)
371  // ---------------------------------------------------------------------- //
372 
373  /// Returns whether the bprim type is supported by this render index.
374  HD_API
375  bool IsBprimTypeSupported(TfToken const& typeId) const;
376 
377  /// Insert a bprim into index
378  HD_API
379  void InsertBprim(TfToken const& typeId,
380  HdSceneDelegate* delegate,
381  SdfPath const& bprimId);
382 
383  HD_API
384  void RemoveBprim(TfToken const& typeId, SdfPath const &id);
385 
386  HD_API
387  HdBprim *GetBprim(TfToken const& typeId, SdfPath const &id) const;
388 
389  /// Returns the subtree rooted under the given path for the given bprim
390  /// type.
391  HD_API
392  SdfPathVector GetBprimSubtree(TfToken const& typeId,
393  SdfPath const& root);
394 
395  /// Returns the fallback prim for the Bprim of the given type.
396  HD_API
397  HdBprim *GetFallbackBprim(TfToken const& typeId) const;
398 
399  // ---------------------------------------------------------------------- //
400  /// \name Scene indices
401  // ---------------------------------------------------------------------- //
402  HD_API
403  void InsertSceneIndex(
404  const HdSceneIndexBaseRefPtr &inputScene,
405  SdfPath const& scenePathPrefix,
406  bool needsPrefixing = true);
407 
408  HD_API
409  void RemoveSceneIndex(
410  const HdSceneIndexBaseRefPtr &inputScene);
411 
412  /// The terminal scene index that is driving what is in the render index
413  /// through emulation.
414  HD_API
415  HdSceneIndexBaseRefPtr GetTerminalSceneIndex() const;
416 
417  HD_API
418  HdSceneIndexBaseRefPtr GetEmulationSceneIndex() const;
419 
420  // ---------------------------------------------------------------------- //
421  /// \name Render Delegate
422  // ---------------------------------------------------------------------- //
423  /// Currently, a render index only supports connection to one type of
424  /// render delegate, due to the inserted information and change tracking
425  /// being specific to that delegate type.
426  HD_API
428 
429  // The render delegate may require access to a render context / device
430  // that is provided by the application.
431  HD_API
432  HdDriverVector const& GetDrivers() const;
433 
434  /// Returns a shared ptr to the resource registry of the current render
435  /// delegate.
436  HD_API
438 
439  /// Returns true if scene index features are available
440  /// This is true by default but can be controlled via an
441  /// HD_ENABLE_SCENE_INDEX_EMULATION environment variable.
442  HD_API
443  static bool IsSceneIndexEmulationEnabled();
444 
445  /// An application or legacy scene delegate may prefer for the scene
446  /// index observer notices generated from its prim insertions, removals, or
447  /// invalidations to be consolidated into vectorized batches. Calling this
448  /// will cause subsequent notices to be queued.
449  ///
450  /// NOTE: This tracks depth internally and is safe to call in nested
451  /// contexts. It is not safe to call from multiple threads, though.
452  HD_API
454 
455  /// Flushes any queued scene index observer notices and disables further
456  /// queueing.
457  ///
458  /// NOTE: This tracks depth internally and is safe to call in nested
459  /// contexts. It is not safe to call from multiple threads, though.
460  HD_API
462 
463  /// Consolidate notices generated by the merging scene index to vectorized
464  /// batches. Calling this will cause subsequent notices to be queued.
465  ///
466  /// NOTE: This tracks depth internally and is safe to call in nested
467  /// contexts. It is not safe to call from multiple threads, though.
468  HD_API
470 
471  /// Flushes any queued scene index observer notices from the merging scene
472  /// index and disables further queueing.
473  ///
474  /// NOTE: This tracks depth internally and is safe to call in nested
475  /// contexts. It is not safe to call from multiple threads, though.
476  HD_API
478 
479  HD_API
480  std::string GetInstanceName() const;
481 
482 private:
483  // The render index constructor is private so we can check
484  // renderDelegate before construction: see HdRenderIndex::New(...).
486  HdRenderDelegate *renderDelegate,
487  HdDriverVector const& drivers,
488  const std::string &instanceName,
489  const std::string &appName,
490  HdSceneIndexBaseRefPtr const &terminalSceneIndex = nullptr,
491  bool createFrontEndEmulationOnly = false);
492 
493  // ---------------------------------------------------------------------- //
494  // Private Helper methods
495  // ---------------------------------------------------------------------- //
496 
497  // Go through all RPrims and reallocate their instance ids
498  // This is called once we have exhausted all 24bit instance ids.
499  void _CompactPrimIds();
500 
501  // Allocate the next available instance id to the prim
502  void _AllocatePrimId(HdRprim* prim);
503 
504  using HdTaskCreateFnc =
505  std::function<HdTaskSharedPtr(HdSceneDelegate*, SdfPath const&)>;
506 
507  // Implements InsertTask<T>.
508  // Inserts task going through emulation if enabled.
509  HD_API
510  void _InsertSceneDelegateTask(
511  HdSceneDelegate* delegate,
512  SdfPath const& taskId,
514 
515  template <typename T>
516  static inline const TfToken & _GetTypeId();
517 
518 
519  // Private versions of equivalent public methods which insert and remove
520  // from this render index.
521  //
522  // The public versions check to see if scene delegate emulation is active.
523  // If not, they call through to these. Otherwise, they forward to the
524  // the HdLegacyPrimSceneIndex member. If a legacy render delegate is also
525  // in use, the scene index chain will terminate with a
526  // HdSceneIndexAdapterSceneDelegate. That will call the private versions
527  // directly so that the internal render index tables are updated.
528  //
529  // This prevents cyclic insertion/removals while allowing a single
530  // HdRenderIndex to be used for both front and back-end emulation.
531  //
532  // Note: all render index users should call the public APIs; only
533  // sceneIndexAdapterSceneDelegate.cpp should call these versions, to keep
534  // state synchronized. Note, for example, that _RemoveSubtree and _Clear
535  // don't affect the task map, since tasks aren't part of emulation, whereas
536  // RemoveSubtree and Clear do affect the task map...
538  void _InsertRprim(TfToken const& typeId,
539  HdSceneDelegate* sceneDelegate,
540  SdfPath const& rprimId);
541  void _InsertSprim(TfToken const& typeId,
542  HdSceneDelegate* delegate,
543  SdfPath const& sprimId);
544  void _InsertBprim(TfToken const& typeId,
545  HdSceneDelegate* delegate,
546  SdfPath const& bprimId);
547  void _InsertInstancer(HdSceneDelegate* delegate,
548  SdfPath const &id);
549  void _InsertTask(HdSceneDelegate* delegate,
550  SdfPath const &id,
551  HdTaskSharedPtr const &task);
552 
553  void _RemoveRprim(SdfPath const& id);
554  void _RemoveSprim(TfToken const& typeId, SdfPath const& id);
555  void _RemoveBprim(TfToken const& typeId, SdfPath const& id);
556  void _RemoveInstancer(SdfPath const& id);
557  void _RemoveSubtree(SdfPath const& id, HdSceneDelegate* sceneDelegate);
558  void _RemoveRprimSubtree(const SdfPath &root,
559  HdSceneDelegate* sceneDelegate);
560  void _RemoveInstancerSubtree(const SdfPath &root,
561  HdSceneDelegate* sceneDelegate);
562  void _RemoveExtComputationSubtree(const SdfPath &root,
563  HdSceneDelegate* sceneDelegate);
564  void _RemoveTaskSubtree(const SdfPath &root,
565  HdSceneDelegate* sceneDelegate);
566  void _RemoveTask(SdfPath const &id);
567  void _Clear();
568 
569  // ---------------------------------------------------------------------- //
570  // Index State
571  // ---------------------------------------------------------------------- //
572  struct _RprimInfo {
573  HdSceneDelegate *sceneDelegate;
574  HdRprim *rprim;
575  };
576 
577  class _NoticeBatchingContext;
578 
579  HdLegacyPrimSceneIndexRefPtr _emulationSceneIndex;
580  std::unique_ptr<_NoticeBatchingContext> _emulationBatchingCtx;
581 
582  std::unique_ptr<class HdSceneIndexAdapterSceneDelegate> _siSd;
583 
584  HdMergingSceneIndexRefPtr _mergingSceneIndex;
585  std::unique_ptr<_NoticeBatchingContext> _mergingBatchingCtx;
586 
587  HdSceneIndexBaseRefPtr _terminalSceneIndex;
588 
589  struct _TaskInfo {
590  HdSceneDelegate *sceneDelegate;
591  HdTaskSharedPtr task;
592  };
593 
594  typedef std::unordered_map<SdfPath, _TaskInfo, SdfPath::Hash> _TaskMap;
596  typedef std::vector<SdfPath> _RprimPrimIDVector;
597 
598  typedef Hd_PrimTypeIndex<HdSprim> _SprimIndex;
599  typedef Hd_PrimTypeIndex<HdBprim> _BprimIndex;
600 
601  _RprimMap _rprimMap;
602  Hd_SortedIds _rprimIds;
603 
604  _RprimPrimIDVector _rprimPrimIdMap;
605 
606  _TaskMap _taskMap;
607 
608  _SprimIndex _sprimIndex;
609  _BprimIndex _bprimIndex;
610 
611  HdChangeTracker _tracker;
612 
614  _InstancerMap _instancerMap;
615 
616  HdRenderDelegate *_renderDelegate;
617  HdDriverVector _drivers;
618 
619  HdSceneIndexBaseRefPtr _finalEmulationSceneIndex;
620 
621  std::string _instanceName;
622 
623  // ---------------------------------------------------------------------- //
624  // Sync State
625  // ---------------------------------------------------------------------- //
626  HdRprimCollectionVector _collectionsToSync;
627  HdDirtyList _rprimDirtyList;
628 
629  // Call depth to SyncAll(). Should only ever be 0 or 1.
630  std::atomic<int> _syncAllDepth;
631 
632  // ---------------------------------------------------------------------- //
633 
634  /// Register the render delegate's list of supported prim types.
635  void _InitPrimTypes();
636 
637  /// Creates fallback prims for each supported prim type.
638  bool _CreateFallbackPrims();
639 
640  /// Release the fallback prims.
641  void _DestroyFallbackPrims();
642 
643  typedef tbb::enumerable_thread_specific<HdDrawItemPtrVector>
644  _ConcurrentDrawItems;
645 
646  void _AppendDrawItems(const SdfPathVector &rprimIds,
647  size_t begin,
648  size_t end,
649  HdRprimCollection const& collection,
650  _ConcurrentDrawItems* result);
651 
652  /// Register core hydra reprs. Only ever called once, the first time
653  /// a render index is created.
654  /// XXX: This code should move to the application layer.
655  static void _ConfigureReprs();
656 
657  // Remove default constructor
658  HdRenderIndex() = delete;
659 
660  // Don't allow copies
661  HdRenderIndex(const HdRenderIndex &) = delete;
662  HdRenderIndex &operator=(const HdRenderIndex &) = delete;
663 
664 };
665 
666 template <typename T>
667 void
669 {
670  _InsertSceneDelegateTask(
671  delegate, id, HdMakeLegacyTaskFactory<T>());
672 }
673 
675 
676 #endif //PXR_IMAGING_HD_RENDER_INDEX_H
HD_API void InsertBprim(TfToken const &typeId, HdSceneDelegate *delegate, SdfPath const &bprimId)
Insert a bprim into index.
HD_API ~HdRenderIndex()
void InsertTask(HdSceneDelegate *delegate, SdfPath const &id)
Definition: renderIndex.h:668
TfToken UpdateRenderTag(SdfPath const &id, HdDirtyBits bits)
Like GetRenderTag, but updates the render tag if dirty.
HD_API bool IsSyncAllInProgress() const
Returns true while a thread is invoking SyncAll().
HD_API void RemoveInstancer(SdfPath const &id)
Remove an instancer from index.
std::shared_ptr< class HdResourceRegistry > HdResourceRegistrySharedPtr
HD_API void InsertSprim(TfToken const &typeId, HdSceneDelegate *delegate, SdfPath const &sprimId)
Insert a sprim into index.
iterator end()
Definition: hashmap.h:301
std::vector< HdDrawItem const * > HdDrawItemPtrVector
Definition: renderIndex.h:107
uint32_t HdDirtyBits
Definition: types.h:143
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
HD_API void Clear()
Clear all r (render), s (state) and b (buffer) prims.
HD_API HdSprim * GetSprim(TfToken const &typeId, SdfPath const &id) const
Returns whether the sprim type is supported by this render index.
HD_API HdRenderDelegate * GetRenderDelegate() const
HD_API void RemoveSubtree(const SdfPath &root, HdSceneDelegate *sceneDelegate)
HD_API void InsertSceneIndex(const HdSceneIndexBaseRefPtr &inputScene, SdfPath const &scenePathPrefix, bool needsPrefixing=true)
HD_API SdfPathVector GetRprimSubtree(SdfPath const &root)
Returns the subtree rooted under the given path.
#define HD_API
Definition: api.h:23
bool HasTask(SdfPath const &id)
Definition: renderIndex.h:330
HD_API HdDrawItemPtrVector GetDrawItems(HdRprimCollection const &collection, TfTokenVector const &renderTags)
Returns a list of relevant draw items that match the criteria specified.
HD_API HdSceneIndexBaseRefPtr GetEmulationSceneIndex() const
Functor to use for hash maps from tokens to other things.
Definition: token.h:149
HD_API SdfPathVector GetBprimSubtree(TfToken const &typeId, SdfPath const &root)
HD_API bool IsSprimTypeSupported(TfToken const &typeId) const
Returns whether the sprim type is supported by this render index.
**But if you need a result
Definition: thread.h:622
std::vector< HdTaskSharedPtr > HdTaskSharedPtrVector
Definition: renderIndex.h:58
HD_API HdRprim const * GetRprim(SdfPath const &id) const
Returns the rprim of id.
HdChangeTracker const & GetChangeTracker() const
Definition: renderIndex.h:217
HD_API TfToken GetRenderTag(SdfPath const &id) const
Returns the render tag for the given rprim.
bool HasRprim(SdfPath const &id)
Returns true if rprim id exists in index.
Definition: renderIndex.h:238
std::shared_ptr< class HdTask > HdTaskSharedPtr
static HD_API bool IsSceneIndexEmulationEnabled()
static HD_API HdRenderIndex * New(HdRenderDelegate *renderDelegate, HdDriverVector const &drivers, const std::string &instanceName=std::string(), const std::string &appName=std::string())
HD_API SdfPathVector GetSprimSubtree(TfToken const &typeId, SdfPath const &root)
HD_API HdSceneIndexBaseRefPtr GetTerminalSceneIndex() const
Definition: token.h:70
std::vector< HdDriver * > HdDriverVector
HD_API HdResourceRegistrySharedPtr GetResourceRegistry() const
HD_API void SyncAll(HdTaskSharedPtrVector *tasks, HdTaskContext *taskContext)
HD_API void RemoveSceneIndex(const HdSceneIndexBaseRefPtr &inputScene)
Definition: rprim.h:37
std::vector< class SdfPath > SdfPathVector
GLuint GLuint end
Definition: glcorearb.h:475
HD_API void RemoveBprim(TfToken const &typeId, SdfPath const &id)
Returns whether the bprim type is supported by this render index.
HD_API void InsertInstancer(HdSceneDelegate *delegate, SdfPath const &id)
Insert an instancer into index.
HD_API void SceneIndexEmulationNoticeBatchBegin()
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
HD_API void EnqueueCollectionToSync(HdRprimCollection const &collection)
Definition: path.h:280
HD_API HdSprim * GetFallbackSprim(TfToken const &typeId) const
Returns the fullback prim for the Sprim of the given type.
HD_API HdBprim * GetBprim(TfToken const &typeId, SdfPath const &id) const
Returns whether the bprim type is supported by this render index.
std::unordered_map< TfToken, VtValue, TfToken::HashFunctor > HdTaskContext
Definition: renderIndex.h:61
Definition: sprim.h:34
std::vector< HdRprimCollection > HdRprimCollectionVector
Definition: renderIndex.h:55
HD_API std::string GetInstanceName() const
HD_API bool GetSceneDelegateAndInstancerIds(SdfPath const &id, SdfPath *sceneDelegateId, SdfPath *instancerId) const
HdChangeTracker & GetChangeTracker()
Definition: renderIndex.h:216
PcpNodeRef_ChildrenIterator begin(const PcpNodeRef::child_const_range &r)
Support for range-based for loops for PcpNodeRef children ranges.
Definition: node.h:587
HD_API const SdfPathVector & GetRprimIds()
Definition: renderIndex.h:272
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
HD_API SdfPath GetRprimPathFromPrimId(int primId) const
Definition: bprim.h:39
HD_API bool IsRprimTypeSupported(TfToken const &typeId) const
Returns whether the rprim type is supported by this render index.
HD_API void RemoveSprim(TfToken const &typeId, SdfPath const &id)
Returns whether the sprim type is supported by this render index.
HD_API HdDriverVector const & GetDrivers() const
HD_API void MergingSceneIndexNoticeBatchEnd()
HD_API HdInstancer * GetInstancer(SdfPath const &id) const
Returns the instancer of id.
HD_API bool IsBprimTypeSupported(TfToken const &typeId) const
Returns whether the bprim type is supported by this render index.
HD_API const SdfPathVector & GetIds()
Sorts the ids if needed and returns the sorted list of ids.
HD_API void RemoveTask(SdfPath const &id)
HD_API void RemoveRprim(SdfPath const &id)
Remove a rprim from index.
HD_API void MergingSceneIndexNoticeBatchBegin()
std::shared_ptr< class HdLegacyTaskFactory > HdLegacyTaskFactorySharedPtr
HD_API void SceneIndexEmulationNoticeBatchEnd()
Definition: value.h:89
HD_API void InsertRprim(TfToken const &typeId, HdSceneDelegate *sceneDelegate, SdfPath const &rprimId)
Insert a rprim into index.
HD_API HdBprim * GetFallbackBprim(TfToken const &typeId) const
Returns the fallback prim for the Bprim of the given type.
HD_API HdSceneDelegate * GetSceneDelegateForRprim(SdfPath const &id) const
Returns the scene delegate for the given rprim.
HD_API HdTaskSharedPtr const & GetTask(SdfPath const &id) const
Returns the task for the given id.
bool HasInstancer(SdfPath const &id)
Returns true if instancer id exists in index.
Definition: renderIndex.h:294