Loading...
Searching...
No Matches
renderPassPruneSceneIndex.h
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
11#include "pxr/imaging/hd/collectionExpressionEvaluator.h"
12#include "pxr/imaging/hd/filteringSceneIndex.h"
13#include "pxr/imaging/hdsi/api.h"
14#include "pxr/usd/sdf/pathTable.h"
15#include <mutex>
16#include <optional>
17
18PXR_NAMESPACE_OPEN_SCOPE
19
20TF_DECLARE_WEAK_AND_REF_PTRS(HdsiRenderPassPruneSceneIndex);
21
28class HdsiRenderPassPruneSceneIndex :
30{
31public:
32 HDSI_API
33 static HdsiRenderPassPruneSceneIndexRefPtr
34 New(const HdSceneIndexBaseRefPtr& inputSceneIndex);
35
36 HDSI_API
37 HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override;
38 HDSI_API
39 SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override;
40
41protected:
42 HDSI_API
43 HdsiRenderPassPruneSceneIndex(
44 const HdSceneIndexBaseRefPtr& inputSceneIndex);
45 HDSI_API
46 ~HdsiRenderPassPruneSceneIndex() override;
47
48 HDSI_API
49 void _PrimsAdded(
50 const HdSceneIndexBase &sender,
51 const HdSceneIndexObserver::AddedPrimEntries &entries) override;
52 HDSI_API
53 void _PrimsRemoved(
54 const HdSceneIndexBase &sender,
55 const HdSceneIndexObserver::RemovedPrimEntries &entries) override;
56 HDSI_API
57 void _PrimsDirtied(
58 const HdSceneIndexBase &sender,
59 const HdSceneIndexObserver::DirtiedPrimEntries &entries) override;
60
61private:
62 // Prune state specified by a render pass.
63 struct _RenderPassPruneState {
64 SdfPath renderPassPath;
65
66 // Retain the expression so we can compare old vs. new state.
67 SdfPathExpression pruneExpr;
68
69 // Evalulator for the pattern expression.
70 std::optional<HdCollectionExpressionEvaluator> pruneEval;
71
72 bool DoesPrune(const SdfPath &primPath) const;
73 };
74
75 // Pull on the scene globals schema for the active render pass,
76 // computing and caching its prune state in _activeRenderPass.
77 void _UpdateActiveRenderPassState(
80
81 // Prune state for the active render pass.
82 _RenderPassPruneState _activeRenderPass;
83
84 // Flag used to track the first time prims have been added.
85 bool _hasPopulated = false;
86
87 // Maps each instance location path to the set of instancer paths that
88 // reference it. Populated lazily in GetPrim() and used to find only the
89 // instancers affected by a prune change (via FindSubtreeRange), rather
90 // than dirtying all known instancers.
91 using InstanceToInstancerMap = SdfPathTable<SdfPathSet>;
92 mutable InstanceToInstancerMap _instanceToInstancerMap;
93 mutable std::mutex _instancerMutex;
94};
95
96PXR_NAMESPACE_CLOSE_SCOPE
97
98#endif
99#endif // PXR_VERSION >= 2408
Abstract interface to scene data.
Definition sceneIndex.h:55
virtual SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const =0
Returns the paths of all scene index prims located immediately below primPath.
virtual HdSceneIndexPrim GetPrim(const SdfPath &primPath) const =0
Returns a pair of (prim type, datasource).
An abstract base class for a filtering scene index that observes a single input scene index.
Objects of this class represent a logical expression syntax tree consisting of SdfPathPattern s,...
A path value used to locate objects in layers or scenegraphs.
Definition path.h:281
A mapping from SdfPath to MappedType, somewhat similar to map<SdfPath, MappedType> and TfHashMap<SdfP...
Definition pathTable.h:66
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
Definition declarePtrs.h:72
Small struct representing a 'prim' in the Hydra scene index.
Definition sceneIndex.h:36