All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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/extCompGpuComputationBufferSource.h"
30 #include "pxr/imaging/hd/bufferSource.h"
31 #include "pxr/imaging/hd/computation.h"
32 #include "pxr/imaging/hd/types.h"
33 #include "pxr/usd/sdf/path.h"
34 #include "pxr/base/tf/token.h"
35 #include "pxr/base/vt/value.h"
36 
37 #include <memory>
38 #include <vector>
39 
40 PXR_NAMESPACE_OPEN_SCOPE
41 
42 class HdSceneDelegate;
43 class HdExtComputation;
44 using HdStGLSLProgramSharedPtr= std::shared_ptr<class HdStGLSLProgram>;
45 using HdExtComputationPrimvarDescriptorVector =
46  std::vector<struct HdExtComputationPrimvarDescriptor>;
47 
48 using HdStExtCompGpuComputationSharedPtr =
49  std::shared_ptr<class HdStExtCompGpuComputation>;
50 
51 
86 public:
95  SdfPath const &id,
96  HdStExtCompGpuComputationResourceSharedPtr const &resource,
97  HdExtComputationPrimvarDescriptorVector const &compPrimvars,
98  int dispatchCount,
99  int elementCount);
100 
116  HDST_API
117  static HdStExtCompGpuComputationSharedPtr
119  HdSceneDelegate *sceneDelegate,
120  HdExtComputation const *sourceComp,
121  HdExtComputationPrimvarDescriptorVector const &compPrimvars);
122 
123  HDST_API
124  virtual ~HdStExtCompGpuComputation() = default;
125 
130  HDST_API
131  virtual void GetBufferSpecs(HdBufferSpecVector *specs) const override;
132 
141  HDST_API
142  virtual void Execute(HdBufferArrayRangeSharedPtr const &range,
143  HdResourceRegistry *resourceRegistry) override;
144 
149  HDST_API
150  int GetDispatchCount() const;
151 
156  HDST_API
157  virtual int GetNumOutputElements() const override;
158 
162  HDST_API
163  virtual HdStExtCompGpuComputationResourceSharedPtr const &
164  GetResource() const;
165 
166 private:
167  SdfPath _id;
168  HdStExtCompGpuComputationResourceSharedPtr _resource;
169  HdExtComputationPrimvarDescriptorVector _compPrimvars;
170  int _dispatchCount;
171  int _elementCount;
172 
173  HdStExtCompGpuComputation() = delete;
176  = delete;
177 };
178 
179 
204 HDST_API
205 void HdSt_GetExtComputationPrimvarsComputations(
206  const SdfPath &id,
207  HdSceneDelegate *sceneDelegate,
208  HdExtComputationPrimvarDescriptorVector const& allCompPrimvars,
209  HdDirtyBits dirtyBits,
210  HdBufferSourceSharedPtrVector *sources,
211  HdBufferSourceSharedPtrVector *reserveOnlySources,
212  HdBufferSourceSharedPtrVector *separateComputationSources,
213  HdComputationSharedPtrVector *computations);
214 
215 PXR_NAMESPACE_CLOSE_SCOPE
216 
217 #endif // PXR_IMAGING_HD_ST_EXT_COMP_GPU_COMPUTATION_H
Hydra Representation of a Client defined computation.
HDST_API int GetDispatchCount() const
Gets the number of GPU kernel invocations to execute.
virtual HDST_API HdStExtCompGpuComputationResourceSharedPtr const & GetResource() const
Gets the shared GPU resource holder for the 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:288
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 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.
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...