Loading...
Searching...
No Matches
pageCacheSubExecutor.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//
7#ifndef PXR_EXEC_EF_PAGE_CACHE_SUB_EXECUTOR_H
8#define PXR_EXEC_EF_PAGE_CACHE_SUB_EXECUTOR_H
9
11
12#include "pxr/pxr.h"
13
16
19
20PXR_NAMESPACE_OPEN_SCOPE
21
35template <
36 template <typename> class EngineType,
37 typename DataManagerType>
39 public EfPageCacheBasedExecutor<EngineType, DataManagerType>
40{
41 // Base type definition.
43
44 // The speculation executor engine alias declaration, to be bound as a
45 // template template parameter.
46 template <typename T>
47 using SpeculationEngineType =
48 typename EngineType<T>::SpeculationExecutorEngine;
49
50 // Executor factory.
51 typedef
52 VdfExecutorFactory<
53 EfSubExecutor<EngineType, DataManagerType>,
55 _Factory;
56
57public:
61 Base(cacheStorage)
62 {}
63
67 EfPageCacheStorage *cacheStorage,
68 const VdfExecutorInterface *parentExecutor);
69
73
76 virtual const VdfExecutorFactoryBase &GetFactory() const override final {
77 return _factory;
78 }
79
80private:
81
82 // Returns a value for the cache that flows across \p connection.
83 //
84 virtual const VdfVector *_GetInputValue(
85 const VdfConnection &connection,
86 const VdfMask &mask) const override;
87
88 // Returns an output value for reading.
89 //
90 virtual const VdfVector *_GetOutputValueForReading(
91 const VdfOutput &output,
92 const VdfMask &mask) const override;
93
94 // Get an output value from the parent executor.
95 //
96 const VdfVector *_GetParentExecutorValue(
97 const VdfOutput &output,
98 const VdfMask &mask) const;
99
100 // Clear all data in the local data manager.
101 //
102 virtual void _ClearData();
103
104 // The factory shared amongst executors of this type.
105 //
106 static const _Factory _factory;
107
108};
109
111
112template <template <typename> class EngineType, typename DataManagerType>
113const typename EfPageCacheSubExecutor<EngineType, DataManagerType>::_Factory
115
116template <template <typename> class EngineType, typename DataManagerType>
118 EfPageCacheStorage *cacheStorage,
119 const VdfExecutorInterface *parentExecutor) :
120 Base(cacheStorage)
121{
122 // Set the parent executor
123 Base::SetParentExecutor(parentExecutor);
124}
125
126/* virtual */
127template <template <typename> class EngineType, typename DataManagerType>
128const VdfVector *
130 const VdfConnection &connection,
131 const VdfMask &mask) const
132{
133 // Lookup the output value in the local data manager and page cache, first!
134 if (const VdfVector *value =
135 Base::_GetInputValue(connection, mask)) {
136 return value;
137 }
138
139 // If available, also check for the value in the parent executor.
140 return _GetParentExecutorValue(connection.GetSourceOutput(), mask);
141}
142
143/* virtual */
144template <template <typename> class EngineType, typename DataManagerType>
145const VdfVector *
147 const VdfOutput &output,
148 const VdfMask &mask) const
149{
150 // Lookup the output value in the local data manager and page cache, first!
151 if (const VdfVector *value =
152 Base::_GetOutputValueForReading(output, mask)) {
153 return value;
154 }
155
156 // If available, also check for the value in the parent executor.
157 return _GetParentExecutorValue(output, mask);
158}
159
160template <template <typename> class EngineType, typename DataManagerType>
161const VdfVector *
163 const VdfOutput &output,
164 const VdfMask &mask) const
165{
166 const VdfExecutorInterface *parentExecutor = Base::GetParentExecutor();
167 return parentExecutor
168 ? parentExecutor->GetOutputValue(output, mask)
169 : nullptr;
170}
171
172/* virtual */
173template <template <typename> class EngineType, typename DataManagerType>
174void
176{
177 // Clear all the relevant data from the parent class.
178 Base::_ClearData();
179
180 // If the data manager remains empty we can bail out.
181 if (!Base::_dataManager.IsEmpty()) {
182 Base::_dataManager.Clear();
183 }
184}
185
186PXR_NAMESPACE_CLOSE_SCOPE
187
188#endif
Executes a VdfNetwork to compute a requested set of values.
Manages a page cache and provides methods for invalidation of cached values.
Executes a VdfNetwork to compute a requested set of values.
EfPageCacheSubExecutor(EfPageCacheStorage *cacheStorage)
Constructor.
virtual ~EfPageCacheSubExecutor()
Destructor.
virtual const VdfExecutorFactoryBase & GetFactory() const override final
Factory construction.
A class that fully represents a connection between two VdfNodes.
Definition: connection.h:30
const VdfOutput & GetSourceOutput() const
Returns the output (ie. source) for this connection.
Definition: connection.h:63
Abstract base class for classes that execute a VdfNetwork to compute a requested set of values.
const VdfVector * GetOutputValue(const VdfOutput &output, const VdfMask &mask) const
Returns the cached value for a given output if it has a cache that contains all values specified by m...
VDF_API void SetParentExecutor(const VdfExecutorInterface *parentExecutor)
Sets the parent executor.
A VdfMask is placed on connections to specify the data flowing through them.
Definition: mask.h:37
A VdfOutput represents an output on a node.
Definition: output.h:32
Executor used in speculation.
This class is used to abstract away knowledge of the cache data used for each node.
Definition: vector.h:56