extComputation.h
1 //
2 // Copyright 2017 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_IMAGING_HD_EXT_COMPUTATION_H
8 #define PXR_IMAGING_HD_EXT_COMPUTATION_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hd/api.h"
12 #include "pxr/imaging/hd/sceneDelegate.h"
13 #include "pxr/imaging/hd/sprim.h"
14 
15 PXR_NAMESPACE_OPEN_SCOPE
16 
39 class HdExtComputation : public HdSprim
40 {
41 public:
43  HD_API
44  HdExtComputation(SdfPath const &id);
45 
46  HD_API
47  ~HdExtComputation() override;
48 
52  enum DirtyBits : HdDirtyBits {
53  Clean = 0,
54  DirtyInputDesc = 1 << 0,
55  DirtyOutputDesc = 1 << 1,
57  DirtyElementCount = 1 << 2,
58  DirtySceneInput = 1 << 3,
60  DirtyCompInput = 1 << 4,
61  DirtyKernel = 1 << 5,
62 
63  DirtyDispatchCount = 1 << 6,
64 
66  AllDirty = (DirtyInputDesc
73  };
74 
75  HD_API
76  void Sync(HdSceneDelegate *sceneDelegate,
77  HdRenderParam *renderParam,
78  HdDirtyBits *dirtyBits) override;
79 
80  HD_API
81  HdDirtyBits GetInitialDirtyBitsMask() const override;
82 
83  HD_API
84  size_t GetDispatchCount() const;
85 
86  HD_API
87  size_t GetElementCount() const { return _elementCount; }
88 
89  HD_API
90  TfTokenVector const & GetSceneInputNames() const {
91  return _sceneInputNames;
92  }
93 
94  HD_API
95  TfTokenVector GetOutputNames() const;
96 
97  HD_API
98  HdExtComputationInputDescriptorVector const &
99  GetComputationInputs() const {
100  return _computationInputs;
101  }
102 
103  HD_API
104  HdExtComputationOutputDescriptorVector const &
105  GetComputationOutputs() const {
106  return _computationOutputs;
107  }
108 
109  HD_API
110  const std::string& GetGpuKernelSource() const {
111  return _gpuKernelSource.GetString();
112  }
113 
114  HD_API
115  bool IsInputAggregation() const;
116 
117 protected:
118  HD_API
119  void
120  _Sync(HdSceneDelegate *sceneDelegate,
121  HdRenderParam *renderParam,
122  HdDirtyBits *dirtyBits);
123 
124  HD_API
125  static bool _IsEnabledSharedExtComputationData();
126 
127 private:
128  size_t _dispatchCount;
129  size_t _elementCount;
130  TfTokenVector _sceneInputNames;
131  HdExtComputationInputDescriptorVector _computationInputs;
132  HdExtComputationOutputDescriptorVector _computationOutputs;
133  TfToken _gpuKernelSource;
134 
135  // No default construction or copying
136  HdExtComputation() = delete;
137  HdExtComputation(const HdExtComputation &) = delete;
138  HdExtComputation &operator =(const HdExtComputation &) = delete;
139 
140 };
141 
142 PXR_NAMESPACE_CLOSE_SCOPE
143 
144 #endif // PXR_IMAGING_HD_EXT_COMPUTATION_H
Hydra Representation of a Client defined computation.
The HdRenderParam is an opaque (to core Hydra) handle, to an object that is obtained from the render ...
HD_API void Sync(HdSceneDelegate *sceneDelegate, HdRenderParam *renderParam, HdDirtyBits *dirtyBits) override
Synchronizes state from the delegate to this object.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:80
std::string const & GetString() const
Return the string that this token represents.
Definition: token.h:232
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...
Adapter class providing data exchange with the client scene graph.
The list of outputs changed.
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:489
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:280
DirtyBits
Change tracking.
Sprim (state prim) is a base class of managing state for non-drawable scene entity (e....
Definition: sprim.h:34
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.
A scene input changed value.
The list of inputs or input bindings changed.