HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
executorDataManagerInterface.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_VDF_EXECUTOR_DATA_MANAGER_INTERFACE_H
8 #define PXR_EXEC_VDF_EXECUTOR_DATA_MANAGER_INTERFACE_H
9 
10 ///\file
11 
12 #include "pxr/pxr.h"
13 
14 #include "pxr/exec/vdf/types.h"
15 
17 
20 class VdfNetwork;
21 class VdfOutput;
22 class VdfSMBLData;
23 
24 ///////////////////////////////////////////////////////////////////////////////
25 ///
26 /// \class Vdf_ExecutorDataManagerInterface
27 ///
28 /// \brief The interface contract for the static polymorphism used by executor
29 /// data manager implementations.
30 ///
31 
32 template <typename DerivedClass, typename DataHandle>
34 {
35 protected:
36 
37  /// Allow construction via derived classes, only.
38  ///
40 
41  /// Prevent destruction via base class pointers (static polymorphism only).
42  ///
44 
45  /// Resize the data manager to accommodate all the outputs in the given
46  /// network.
47  ///
48  void _Resize(const VdfNetwork &network) {
49  _Self()->Resize(network);
50  }
51 
52  /// Returns \c true if the given data \p handle is valid, i.e. it is valid
53  /// to ask for data for this given \p handle.
54  ///
55  /// Note that attempting to resolve data at an invalid handle need not be
56  /// supported.
57  ///
58  bool _IsValidDataHandle(const DataHandle handle) const {
59  return _Self()->IsValidDataHandle(handle);
60  }
61 
62  /// Returns an existing data handle, or creates a new one for the given
63  /// \p outputId.
64  ///
65  /// This method must always return a valid data handle.
66  ///
67  DataHandle _GetOrCreateDataHandle(const VdfId outputId) const {
68  return _Self()->GetOrCreateDataHandle(outputId);
69  }
70 
71  /// Returns an existing data handle for the given \p outputId. This method
72  /// must return an invalid data handle, if no handle has been created
73  /// for the given \p outputId.
74  ///
75  DataHandle _GetDataHandle(const VdfId outputId) const {
76  return _Self()->GetDataHandle(outputId);
77  }
78 
79  /// Returns the VdfExecutorBufferData associated with the given \p handle.
80  ///
81  /// Note that attempting to retrieve data at an invalid handle need not
82  /// be supported.
83  ///
84  VdfExecutorBufferData * _GetBufferData(const DataHandle handle) const {
85  return _Self()->GetBufferData(handle);
86  }
87 
88  /// Returns the VdfExecutorInvalidationData associated with the given
89  /// \p handle.
90  ///
91  /// Note that attempting to retrieve data at an invalid handle need not
92  /// be supported.
93  ///
95  const DataHandle handle) const {
96  return _Self()->GetInvalidationData(handle);
97  }
98 
99  /// Returns the VdfInvalidationTimestamp associated with the given
100  /// \p handle.
101  ///
102  /// Note that attempting to retrieve data at an invalid handle need not
103  /// be supported.
104  ///
106  const DataHandle handle) const {
107  return _Self()->GetInvalidationTimestamp(handle);
108  }
109 
110  /// Sets the invalidation \p timestamp for the give data \p handle.
111  ///
112  /// Note that attempting to retrieve data at an invalid handle need not
113  /// be supported.
114  ///
116  const DataHandle handle,
118  _Self()->SetInvalidationTimestamp(handle, ts);
119  }
120 
121  /// Returns an existing \p VdfSMBLData associated with the given \p handle.
122  /// Returns \c nullptr if there is no SMBL data associated with this
123  /// data \p handle.
124  ///
125  /// Note that attempting to retrieve data at an invalid handle need not
126  /// be supported.
127  ///
128  VdfSMBLData * _GetSMBLData(const DataHandle handle) const {
129  return _Self()->GetSMBLData(handle);
130  }
131 
132  /// Returns an existing \p VdfSMBLData associated with the given \p handle
133  /// or creates a new one of none exists.
134  ///
135  /// Note that this must always return a valid pointer to VdfSMBLData.
136  ///
137  VdfSMBLData * _GetOrCreateSMBLData(const DataHandle handle) const {
138  return _Self()->GetOrCreateSMBLData(handle);
139  }
140 
141  /// Returns \c true if the data at the given \p handle has been touched by
142  /// evaluation.
143  ///
144  /// Note that attempting to touch data at an invalid handle need not
145  /// be supported.
146  ///
147  bool _IsTouched(const DataHandle handle) const {
148  return _Self()->IsTouched(handle);
149  }
150 
151  /// Marks the data at the given \p handle as having been touched by
152  /// evaluation.
153  ///
154  /// Note that attempting to touch data at an invalid handle need not
155  /// be supported.
156  ///
157  void _Touch(const DataHandle handle) const {
158  _Self()->Touch(handle);
159  }
160 
161  /// Marks the data at the given \p handle as not having been touched by
162  /// evaluation. Returns \c true if the data has previously been touched.
163  ///
164  /// Note that attempting to un-touch data at an invalid handle need not
165  /// be supported.
166  ///
167  bool _Untouch(const DataHandle handle) {
168  return _Self()->Untouch(handle);
169  }
170 
171  /// Clears the executor data for a specific output
172  ///
173  void _ClearDataForOutput(const VdfOutput &output) {
174  return _Self()->ClearDataForOutput(output);
175  }
176 
177 private:
178 
179  // Returns the constant this pointer to the derived class.
180  const DerivedClass * _Self() const {
181  return static_cast<const DerivedClass *>(this);
182  }
183 
184 
185  // Returns the mutable this pointer to the derived class.
186  DerivedClass * _Self() {
187  return static_cast<DerivedClass *>(this);
188  }
189 
190 };
191 
193 
194 #endif
bool _IsValidDataHandle(const DataHandle handle) const
VdfExecutorBufferData * _GetBufferData(const DataHandle handle) const
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
void _ClearDataForOutput(const VdfOutput &output)
void _Touch(const DataHandle handle) const
VdfSMBLData * _GetOrCreateSMBLData(const DataHandle handle) const
VdfSMBLData holds per-output data that is meant to be consumed by the executor. This data is an optio...
Definition: smblData.h:30
void _Resize(const VdfNetwork &network)
This object is responsible for storing the executor buffer data, comprised of the executor cache vect...
DataHandle _GetDataHandle(const VdfId outputId) const
VdfInvalidationTimestamp _GetInvalidationTimestamp(const DataHandle handle) const
The interface contract for the static polymorphism used by executor data manager implementations.
unsigned int VdfInvalidationTimestamp
Type of the timestamp that identifies the most recent round of invalidation.
Definition: types.h:74
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
bool _IsTouched(const DataHandle handle) const
VdfSMBLData * _GetSMBLData(const DataHandle handle) const
void _SetInvalidationTimestamp(const DataHandle handle, VdfInvalidationTimestamp ts)
VdfExecutorInvalidationData * _GetInvalidationData(const DataHandle handle) const
DataHandle _GetOrCreateDataHandle(const VdfId outputId) const
uint64_t VdfId
The unique identifier type for Vdf objects.
Definition: types.h:107