HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
renderPassPruneSceneIndex.h
Go to the documentation of this file.
1 //
2 // Copyright 2025 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 #ifndef PXR_IMAGING_HDSI_RENDER_PASS_PRUNE_SCENE_INDEX_H
7 #define PXR_IMAGING_HDSI_RENDER_PASS_PRUNE_SCENE_INDEX_H
8 
9 #include "pxr/pxr.h"
10 #if PXR_VERSION >= 2408
13 #include "pxr/imaging/hdsi/api.h"
14 #include <optional>
15 
17 
18 TF_DECLARE_WEAK_AND_REF_PTRS(HdsiRenderPassPruneSceneIndex);
19 
20 /// Applies prune rules of the active render pass specified in the
21 /// HdSceneGlobalsSchema.
22 ///
23 /// \note This scene index assumes that the active render pass is a
24 /// UsdRenderPass for the purposes of collection naming conventions.
25 ///
26 class HdsiRenderPassPruneSceneIndex :
28 {
29 public:
30  HDSI_API
31  static HdsiRenderPassPruneSceneIndexRefPtr
32  New(const HdSceneIndexBaseRefPtr& inputSceneIndex);
33 
34  HDSI_API
35  HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override;
36  HDSI_API
37  SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override;
38 
39 protected:
40  HDSI_API
41  HdsiRenderPassPruneSceneIndex(
42  const HdSceneIndexBaseRefPtr& inputSceneIndex);
43  HDSI_API
44  ~HdsiRenderPassPruneSceneIndex() override;
45 
46  HDSI_API
47  void _PrimsAdded(
48  const HdSceneIndexBase &sender,
49  const HdSceneIndexObserver::AddedPrimEntries &entries) override;
50  HDSI_API
51  void _PrimsRemoved(
52  const HdSceneIndexBase &sender,
53  const HdSceneIndexObserver::RemovedPrimEntries &entries) override;
54  HDSI_API
55  void _PrimsDirtied(
56  const HdSceneIndexBase &sender,
57  const HdSceneIndexObserver::DirtiedPrimEntries &entries) override;
58 
59 private:
60  // Prune state specified by a render pass.
61  struct _RenderPassPruneState {
62  SdfPath renderPassPath;
63 
64  // Retain the expression so we can compare old vs. new state.
65  SdfPathExpression pruneExpr;
66 
67  // Evalulator for the pattern expression.
68  std::optional<HdCollectionExpressionEvaluator> pruneEval;
69 
70  bool DoesPrune(const SdfPath &primPath) const;
71  };
72 
73  // Pull on the scene globals schema for the active render pass,
74  // computing and caching its prune state in _activeRenderPass.
75  void _UpdateActiveRenderPassState(
78 
79  // Prune state for the active render pass.
80  _RenderPassPruneState _activeRenderPass;
81 
82  // Flag used to track the first time prims have been added.
83  bool _hasPopulated = false;
84 };
85 
87 
88 #endif
89 #endif // PXR_VERSION >= 2408
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
virtual void _PrimsRemoved(const HdSceneIndexBase &sender, const HdSceneIndexObserver::RemovedPrimEntries &entries)=0
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Definition: declarePtrs.h:72
virtual SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const =0
std::vector< class SdfPath > SdfPathVector
virtual void _PrimsDirtied(const HdSceneIndexBase &sender, const HdSceneIndexObserver::DirtiedPrimEntries &entries)=0
Definition: path.h:280
#define HDSI_API
Definition: api.h:23
virtual HdSceneIndexPrim GetPrim(const SdfPath &primPath) const =0
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
virtual void _PrimsAdded(const HdSceneIndexBase &sender, const HdSceneIndexObserver::AddedPrimEntries &entries)=0