HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
10 ///\file
11 
12 #include "pxr/pxr.h"
13 
15 
19 
21 
22 ///////////////////////////////////////////////////////////////////////////////
23 ///
24 /// \class EfPageCacheSubExecutor
25 ///
26 /// \brief Executes a VdfNetwork to compute a requested set of values. Caches
27 /// the computed data in an EfPageCacheStorage container and recalls
28 /// existing data using a page specified via the currently set value
29 /// on the key output.
30 ///
31 /// Contrary to the EfPageCacheExecutor, this executor stores its data
32 /// in the hash-table data manager and supports looking up output values
33 /// on a parent executor.
34 ///
35 template <
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
55  _Factory;
56 
57 public:
58  /// Constructor.
59  ///
60  explicit EfPageCacheSubExecutor(EfPageCacheStorage *cacheStorage) :
61  Base(cacheStorage)
62  {}
63 
64  /// Construct with parent executor.
65  ///
67  EfPageCacheStorage *cacheStorage,
68  const VdfExecutorInterface *parentExecutor);
69 
70  /// Destructor.
71  ///
73 
74  /// Factory construction.
75  ///
76  virtual const VdfExecutorFactoryBase &GetFactory() const override final {
77  return _factory;
78  }
79 
80 private:
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 
110 ///////////////////////////////////////////////////////////////////////////////
111 
112 template <template <typename> class EngineType, typename DataManagerType>
115 
116 template <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 */
127 template <template <typename> class EngineType, typename DataManagerType>
128 const 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 */
144 template <template <typename> class EngineType, typename DataManagerType>
145 const 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 
160 template <template <typename> class EngineType, typename DataManagerType>
161 const 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 */
173 template <template <typename> class EngineType, typename DataManagerType>
174 void
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 
187 
188 #endif
Manages a page cache and provides methods for invalidation of cached values.
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
GLsizei const GLfloat * value
Definition: glcorearb.h:824
virtual const VdfExecutorFactoryBase & GetFactory() const overridefinal
VDF_API void SetParentExecutor(const VdfExecutorInterface *parentExecutor)
A VdfMask is placed on connections to specify the data flowing through them.
Definition: mask.h:36
Executor used in speculation.
Executes a VdfNetwork to compute a requested set of values. Caches the computed data in a EfPageCache...
EfPageCacheSubExecutor(EfPageCacheStorage *cacheStorage)
GLint GLuint mask
Definition: glcorearb.h:124
const VdfOutput & GetSourceOutput() const
Returns the output (ie. source) for this connection.
Definition: connection.h:63
Executes a VdfNetwork to compute a requested set of values. Caches the computed data in an EfPageCach...
const VdfVector * GetOutputValue(const VdfOutput &output, const VdfMask &mask) const
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
Abstract base class for classes that execute a VdfNetwork to compute a requested set of values...