Loading...
Searching...
No Matches
requestImpl.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//
7#ifndef PXR_EXEC_EXEC_REQUEST_IMPL_H
8#define PXR_EXEC_EXEC_REQUEST_IMPL_H
9
10#include "pxr/pxr.h"
11
12#include "pxr/exec/exec/api.h"
13#include "pxr/exec/exec/request.h"
15
16#include "pxr/base/tf/bits.h"
17#include "pxr/base/tf/pxrTslRobinMap/robin_map.h"
20#include "pxr/exec/vdf/types.h"
21
22#include <memory>
23#include <vector>
24
25PXR_NAMESPACE_OPEN_SCOPE
26
27class EfLeafNode;
28class EfTime;
29struct Exec_AttributeValueInvalidationResult;
30class Exec_CacheView;
31struct Exec_DisconnectedInputsInvalidationResult;
32struct Exec_MetadataInvalidationResult;
33class Exec_TimeChangeInvalidationResult;
34class Exec_ValueExtractor;
35class ExecSystem;
36class ExecValueKey;
37template <typename> class TfSpan;
38class VdfRequest;
39class VdfSchedule;
40
48{
49public:
54 const Exec_AttributeValueInvalidationResult &invalidationResult);
55
60 const Exec_MetadataInvalidationResult &invalidationResult);
61
66 const Exec_DisconnectedInputsInvalidationResult &invalidationResult);
67
72
75 const Exec_TimeChangeInvalidationResult &invalidationResult);
76
82 void Expire();
83
84protected:
85 EXEC_API
87 ExecSystem *system,
88 ExecRequestComputedValueInvalidationCallback &&valueCallback,
89 ExecRequestTimeChangeInvalidationCallback &&timeCallback);
90
91 Exec_RequestImpl(const Exec_RequestImpl&) = delete;
92 Exec_RequestImpl& operator=(const Exec_RequestImpl&) = delete;
93
94 EXEC_API
96
98 EXEC_API
100
102 EXEC_API
103 void _Schedule();
104
106 EXEC_API
108
112 EXEC_API
114 ExecValueOverrideVector &&valueOverrides);
115
121 EXEC_API
123
130 EXEC_API
132
138 EXEC_API
139 void _Discard();
140
141private:
142 // Ensures the _leafNodeToIndex map is up-to-date.
143 void _BuildLeafNodeToIndexMap(
145 const std::vector<const EfLeafNode*> &leafNodes);
146
147 // Turns invalid leaf nodes into a set of requested - and not previously
148 // invalidated - indices.
149 //
150 void _InvalidateLeafOutputs(
151 bool isNewlyInvalidInterval,
153 ExecRequestIndexSet *invalidIndices);
154
155 // Resets the schedule if any there are any topological network edits to
156 // leaf nodes that are referenced in this request.
157 //
158 void _InvalidateScheduleForLeafNodes(
159 TfSpan<const VdfNode *const> disconnectedLeafNodes);
160
161private:
162 // The system that issued this request.
163 ExecSystem *_system;
164
165 // The compiled leaf output.
166 std::vector<VdfMaskedOutput> _leafOutputs;
167
168 // Value extractors corresponding to each requested value.
169 std::vector<Exec_ValueExtractor> _extractors;
170
171 // Maps leaf nodes to their index in the array of valueKeys the request
172 // was built with.
173 pxr_tsl::robin_map<VdfId, size_t> _leafNodeToIndex;
174
175 // The compute request to cache values with.
176 std::unique_ptr<VdfRequest> _computeRequest;
177
178 // The schedule to cache values with.
179 std::unique_ptr<VdfSchedule> _schedule;
180
181 // The combined time interval for which invalidation has been sent out.
182 EfTimeInterval _lastInvalidatedInterval;
183
184 // The combined set of indices for which invalidation has been sent out.
185 TfBits _lastInvalidatedIndices;
186
187 // The invalidation callback to invoke when computed values change.
188 ExecRequestComputedValueInvalidationCallback _valueCallback;
189
190 // The invalidation callback to invoke when time changes.
191 ExecRequestTimeChangeInvalidationCallback _timeCallback;
192};
193
194PXR_NAMESPACE_CLOSE_SCOPE
195
196#endif
A terminal node, which is never executed.
Definition leafNode.h:38
A class that represents a point in time for execution.
Definition time.h:37
A class that represents an interval in EfTime.
A view into values cached by ExecSystem.
Definition cacheView.h:34
Contains data structures necessary to implement exec requests that are independent of scene descripti...
Definition requestImpl.h:48
EXEC_API void _Schedule()
Builds the schedule for the request.
void DidInvalidateComputedValues(const Exec_AttributeValueInvalidationResult &invalidationResult)
Notify the request of invalid computed values as a consequence of attribute authored value invalidati...
void Expire()
Expires all request indices and discards the request.
EXEC_API Exec_CacheView _Compute()
Computes the value keys in the request.
EXEC_API void _ExpireIndices(const ExecRequestIndexSet &expired)
Expires the indices in expired.
EXEC_API void _Discard()
Removes the request from the system.
void DidChangeTime(const Exec_TimeChangeInvalidationResult &invalidationResult)
Notify the request of time having changed.
void DidInvalidateUnknownValues()
Notify the request to invalidate value keys that don't have a compiled leaf node.
void DidInvalidateComputedValues(const Exec_DisconnectedInputsInvalidationResult &invalidationResult)
Notify the request of invalid computed values as a consequence of uncompilation.
EXEC_API Exec_CacheView _ComputeWithOverrides(ExecValueOverrideVector &&valueOverrides)
Computes the value keys in the request in the presence of the provided valueOverrides.
EXEC_API bool _RequiresCompilation() const
Returns true if the request needs to be compiled.
void DidInvalidateComputedValues(const Exec_MetadataInvalidationResult &invalidationResult)
Notify the request of invalid computed values as a consequence of metadata authored value invalidatio...
EXEC_API void _Compile(TfSpan< const ExecValueKey > valueKeys)
Compiles outputs for the value keys in the request.
Base implementation of a system to procedurally compute values based on scene description and computa...
Definition system.h:47
Specifies a computed value.
Definition valueKey.h:29
Fast bit array that keeps track of the number of bits set and can find the next set in a timely manne...
Definition bits.h:49
Represents a range of contiguous elements.
Definition span.h:71
Contains a specification of how to execute a particular VdfNetwork.
Definition schedule.h:41
Implementation of a hash map using open-addressing and the robin hood hashing algorithm with backward...
Definition robin_map.h:96
Implementation of a hash set using open-addressing and the robin hood hashing algorithm with backward...
Definition robin_set.h:95