extCompGpuComputation.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_ST_EXT_COMP_GPU_COMPUTATION_H
25 #define PXR_IMAGING_HD_ST_EXT_COMP_GPU_COMPUTATION_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hdSt/api.h"
29 #include "pxr/imaging/hdSt/extCompGpuComputationResource.h"
30 #include "pxr/imaging/hdSt/resourceBinder.h"
31 #include "pxr/imaging/hd/bufferSource.h"
32 #include "pxr/imaging/hd/computation.h"
33 #include "pxr/imaging/hd/types.h"
34 #include "pxr/usd/sdf/path.h"
35 #include "pxr/base/tf/token.h"
36 #include "pxr/base/vt/value.h"
37 
38 #include <memory>
39 #include <vector>
40 
41 PXR_NAMESPACE_OPEN_SCOPE
42 
43 class HdSceneDelegate;
44 class HdExtComputation;
45 using HdStGLSLProgramSharedPtr= std::shared_ptr<class HdStGLSLProgram>;
46 using HdExtComputationPrimvarDescriptorVector =
47  std::vector<struct HdExtComputationPrimvarDescriptor>;
48 
49 using HdStExtCompGpuComputationSharedPtr =
50  std::shared_ptr<class HdStExtCompGpuComputation>;
51 
52 
85 public:
94  SdfPath const &id,
95  HdStExtCompGpuComputationResourceSharedPtr const &resource,
96  HdExtComputationPrimvarDescriptorVector const &compPrimvars,
97  int dispatchCount,
98  int elementCount);
99 
114  HDST_API
115  static HdStExtCompGpuComputationSharedPtr
117  HdSceneDelegate *sceneDelegate,
118  HdExtComputation const *sourceComp,
119  HdExtComputationPrimvarDescriptorVector const &compPrimvars);
120 
121  HDST_API
122  virtual ~HdStExtCompGpuComputation() = default;
123 
128  HDST_API
129  virtual void GetBufferSpecs(HdBufferSpecVector *specs) const override;
130 
139  HDST_API
140  virtual void Execute(HdBufferArrayRangeSharedPtr const &range,
141  HdResourceRegistry *resourceRegistry) override;
142 
147  HDST_API
148  int GetDispatchCount() const;
149 
154  HDST_API
155  virtual int GetNumOutputElements() const override;
156 
158  HDST_API
159  virtual HdStExtCompGpuComputationResourceSharedPtr const &
160  GetResource() const;
161 
162 private:
163  SdfPath _id;
164  HdStExtCompGpuComputationResourceSharedPtr _resource;
165  HdExtComputationPrimvarDescriptorVector _compPrimvars;
166  int _dispatchCount;
167  int _elementCount;
168 
169  HdStExtCompGpuComputation() = delete;
172  = delete;
173 };
174 
175 
200 HDST_API
201 void HdSt_GetExtComputationPrimvarsComputations(
202  const SdfPath &id,
203  HdSceneDelegate *sceneDelegate,
204  HdExtComputationPrimvarDescriptorVector const& allCompPrimvars,
205  HdDirtyBits dirtyBits,
206  HdBufferSourceSharedPtrVector *sources,
207  HdBufferSourceSharedPtrVector *reserveOnlySources,
208  HdBufferSourceSharedPtrVector *separateComputationSources,
209  HdStComputationSharedPtrVector *computations);
210 
211 PXR_NAMESPACE_CLOSE_SCOPE
212 
213 #endif // PXR_IMAGING_HD_ST_EXT_COMP_GPU_COMPUTATION_H
Hydra Representation of a Client defined computation.
Adapter class providing data exchange with the client scene graph.
A central registry for resources.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:290
virtual HDST_API int GetNumOutputElements() const override
Gets the number of elements in the output primvar.
An interface class for GPU computation.
Definition: computation.h:52
A Computation that represents a GPU implementation of a ExtComputation.
virtual HDST_API HdStExtCompGpuComputationResourceSharedPtr const & GetResource() const
Gets the shared GPU resource holder for the computation.
virtual HDST_API void Execute(HdBufferArrayRangeSharedPtr const &range, HdResourceRegistry *resourceRegistry) override
Executes the computation on the GPU.
static HDST_API HdStExtCompGpuComputationSharedPtr CreateGpuComputation(HdSceneDelegate *sceneDelegate, HdExtComputation const *sourceComp, HdExtComputationPrimvarDescriptorVector const &compPrimvars)
Creates a GPU computation implementing the given abstract computation.
HDST_API int GetDispatchCount() const
Gets the number of GPU kernel invocations to execute.
virtual HDST_API void GetBufferSpecs(HdBufferSpecVector *specs) const override
Adds the output buffer specs generated by this computation to the passed in vector of buffer specs.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...