All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
extComputation.h
1 //
2 // Copyright 2017 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_HD_EXT_COMPUTATION_H
25 #define PXR_IMAGING_HD_EXT_COMPUTATION_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hd/api.h"
29 #include "pxr/imaging/hd/sceneDelegate.h"
30 #include "pxr/imaging/hd/sprim.h"
31 #include "pxr/imaging/hd/types.h"
32 #include "pxr/usd/sdf/path.h"
33 #include "pxr/base/vt/value.h"
34 #include <vector>
35 
36 PXR_NAMESPACE_OPEN_SCOPE
37 
60 class HdExtComputation : public HdSprim {
61 public:
63  HD_API
64  HdExtComputation(SdfPath const &id);
65 
66  HD_API
67  virtual ~HdExtComputation() = default;
68 
72  enum DirtyBits : HdDirtyBits {
73  Clean = 0,
74  DirtyInputDesc = 1 << 0,
75  DirtyOutputDesc = 1 << 1,
77  DirtyElementCount = 1 << 2,
78  DirtySceneInput = 1 << 3,
80  DirtyCompInput = 1 << 4,
81  DirtyKernel = 1 << 5,
82 
83  DirtyDispatchCount = 1 << 6,
84 
86  AllDirty = (DirtyInputDesc
93  };
94 
95  HD_API
96  virtual void Sync(HdSceneDelegate *sceneDelegate,
97  HdRenderParam *renderParam,
98  HdDirtyBits *dirtyBits) override;
99 
100  HD_API
101  virtual HdDirtyBits GetInitialDirtyBitsMask() const override;
102 
103  HD_API
104  size_t GetDispatchCount() const;
105 
106  HD_API
107  size_t GetElementCount() const { return _elementCount; }
108 
109  HD_API
110  TfTokenVector const & GetSceneInputNames() const {
111  return _sceneInputNames;
112  }
113 
114  HD_API
115  TfTokenVector GetOutputNames() const;
116 
117  HD_API
118  HdExtComputationInputDescriptorVector const &
119  GetComputationInputs() const {
120  return _computationInputs;
121  }
122 
123  HD_API
124  HdExtComputationOutputDescriptorVector const &
125  GetComputationOutputs() const {
126  return _computationOutputs;
127  }
128 
129  HD_API
130  const std::string& GetGpuKernelSource() const { return _gpuKernelSource; }
131 
132  HD_API
133  bool IsInputAggregation() const;
134 
135 protected:
136  HD_API
137  void
138  _Sync(HdSceneDelegate *sceneDelegate,
139  HdRenderParam *renderParam,
140  HdDirtyBits *dirtyBits);
141 
142  HD_API
143  static bool _IsEnabledSharedExtComputationData();
144 
145 private:
146  size_t _dispatchCount;
147  size_t _elementCount;
148  TfTokenVector _sceneInputNames;
149  HdExtComputationInputDescriptorVector _computationInputs;
150  HdExtComputationOutputDescriptorVector _computationOutputs;
151  std::string _gpuKernelSource;
152 
153  // No default construction or copying
154  HdExtComputation() = delete;
155  HdExtComputation(const HdExtComputation &) = delete;
156  HdExtComputation &operator =(const HdExtComputation &) = delete;
157 
158 };
159 
160 PXR_NAMESPACE_CLOSE_SCOPE
161 
162 #endif // PXR_IMAGING_HD_EXT_COMPUTATION_H
Hydra Representation of a Client defined computation.
virtual HD_API HdDirtyBits GetInitialDirtyBitsMask() const override
Returns the minimal set of dirty bits to place in the change tracker for use in the first sync of thi...
The HdRenderParam is an opaque (to core Hydra) handle, to an object that is obtained from the render ...
Adapter class providing data exchange with the client scene graph.
The list of outputs changed.
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:288
DirtyBits
Change tracking.
Sprim (state prim) is a base class of managing state for non-drawable scene entity (e...
Definition: sprim.h:52
The number of kernel invocations to execute changed.
A computation input changed value.
The compute kernel binding changed.
The number of elements in the output arrays changed.
virtual HD_API void Sync(HdSceneDelegate *sceneDelegate, HdRenderParam *renderParam, HdDirtyBits *dirtyBits) override
Synchronizes state from the delegate to this object.
A scene input changed value.
The list of inputs or input bindings changed.