Loading...
Searching...
No Matches
primTypeNoticeBatchingSceneIndex.h
Go to the documentation of this file.
1//
2// Copyright 2023 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_HDSI_PRIMTYPE_NOTICE_BATCHING_SCENE_INDEX_H
25#define PXR_IMAGING_HDSI_PRIMTYPE_NOTICE_BATCHING_SCENE_INDEX_H
26
28
29#include "pxr/imaging/hdsi/api.h"
30
31#include "pxr/imaging/hd/filteringSceneIndex.h"
32
33#include <variant>
34
35PXR_NAMESPACE_OPEN_SCOPE
36
37#define HDSI_PRIM_TYPE_NOTICE_BATCHING_SCENE_INDEX_TOKENS \
38 (primTypePriorityFunctor)
39
40TF_DECLARE_PUBLIC_TOKENS(HdsiPrimTypeNoticeBatchingSceneIndexTokens, HDSI_API,
41 HDSI_PRIM_TYPE_NOTICE_BATCHING_SCENE_INDEX_TOKENS);
42
44
67{
68public:
74 {
75 public:
76 HDSI_API
78
83 virtual size_t GetPriorityForPrimType(
84 const TfToken &primType) const = 0;
85
92 virtual size_t GetNumPriorities() const = 0;
93 };
94 using PrimTypePriorityFunctorHandle =
95 std::shared_ptr<PrimTypePriorityFunctor>;
96
102 static HdsiPrimTypeNoticeBatchingSceneIndexRefPtr New(
103 HdSceneIndexBaseRefPtr const &inputScene,
104 HdContainerDataSourceHandle const &inputArgs) {
105 return TfCreateRefPtr(
107 inputScene,
108 inputArgs));
109 }
110
111 HDSI_API
113
116 HDSI_API
117 HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override;
118
121 HDSI_API
122 SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override;
123
129 HDSI_API
130 void Flush();
131
132protected:
133
134 HDSI_API
136 HdSceneIndexBaseRefPtr const &inputScene,
137 HdContainerDataSourceHandle const &inputArgs);
138
139 // satisfying HdSingleInputFilteringSceneIndexBase
140 void _PrimsAdded(
141 const HdSceneIndexBase &sender,
142 const HdSceneIndexObserver::AddedPrimEntries &entries) override;
143
144 void _PrimsRemoved(
145 const HdSceneIndexBase &sender,
146 const HdSceneIndexObserver::RemovedPrimEntries &entries) override;
147
148 void _PrimsDirtied(
149 const HdSceneIndexBase &sender,
150 const HdSceneIndexObserver::DirtiedPrimEntries &entries) override;
151
152 // Removes items from _addedOrDirtiedPrims prefixed by path.
153 void _RemovePathFromAddedOrDirtiedPrims(const SdfPath &path);
154 // Adds path to _removedPrims and normalizes _removedPrims if necessary.
155 void _AddPathToRemovedPrims(const SdfPath &path);
156
157 size_t _GetPriority(const TfToken &primType) const;
158
159 PrimTypePriorityFunctorHandle const _primTypePriorityFunctor;
160 const size_t _numPriorities;
161
162 struct _PrimAddedEntry
163 {
164 TfToken primType;
165 };
166
167 struct _PrimDirtiedEntry
168 {
169 HdDataSourceLocatorSet dirtyLocators;
170 };
171
172 // True after first call to flush.
173 bool _populated;
174
175 // Default constructored _PrimAddedOrDirtiedEntry contains a
176 // _PrimDirtiedEntry. This is used by _addedOrDirtiedPrims.
177 using _PrimAddedOrDirtiedEntry =
178 std::variant<_PrimDirtiedEntry, _PrimAddedEntry>;
179
180 std::map<SdfPath, _PrimAddedOrDirtiedEntry> _addedOrDirtiedPrims;
181
182 // Normalized, so a prefix of an element in _removedPrims will never be in
183 // _removedPrims.
184 std::set<SdfPath> _removedPrims;
185};
186
187
188PXR_NAMESPACE_CLOSE_SCOPE
189
190
191#endif
Represents a set of data source locators closed under descendancy.
Abstract interface to scene data.
Definition: sceneIndex.h:65
An abstract base class for a filtering scene index that observes a single input scene index.
Base class for functor mapping prim types to priorities.
virtual size_t GetNumPriorities() const =0
Number of priorities - that is 1 + the highest number ever returned by GetPriorityForPrimType().
virtual size_t GetPriorityForPrimType(const TfToken &primType) const =0
Priority for given prim type.
A filtering scene index batching prim notices by type using a given priority functor.
HDSI_API void Flush()
Sends out all notices queued and commulated since the last call to Flush.
static HdsiPrimTypeNoticeBatchingSceneIndexRefPtr New(HdSceneIndexBaseRefPtr const &inputScene, HdContainerDataSourceHandle const &inputArgs)
Creates a new notice batching scene index.
HDSI_API HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override
Forwards to input scene after first call to Flush.
HDSI_API SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override
Forwards to input scene after first call to Flush.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:290
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:88
#define TF_DECLARE_REF_PTRS(type)
Define standard ref pointer types.
Definition: declarePtrs.h:75
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
Definition: staticTokens.h:98
Small struct representing a 'prim' in the Hydra scene index.
Definition: sceneIndex.h:52