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/extCompGpuComputationResource.h"
30 #include "pxr/imaging/hdSt/resourceBinder.h"
31 #include "pxr/imaging/hd/binding.h"
32 #include "pxr/imaging/hd/bufferSource.h"
33 #include "pxr/imaging/hd/computation.h"
34 #include "pxr/imaging/hd/types.h"
35 #include "pxr/usd/sdf/path.h"
36 #include "pxr/base/tf/token.h"
37 #include "pxr/base/vt/value.h"
38 
39 #include <memory>
40 #include <vector>
41 
42 PXR_NAMESPACE_OPEN_SCOPE
43 
44 class HdSceneDelegate;
45 class HdExtComputation;
46 using HdStGLSLProgramSharedPtr= std::shared_ptr<class HdStGLSLProgram>;
47 using HdExtComputationPrimvarDescriptorVector =
48  std::vector<struct HdExtComputationPrimvarDescriptor>;
49 
50 using HdStExtCompGpuComputationSharedPtr =
51  std::shared_ptr<class HdStExtCompGpuComputation>;
52 
53 
86 public:
95  SdfPath const &id,
96  HdStExtCompGpuComputationResourceSharedPtr const &resource,
97  HdExtComputationPrimvarDescriptorVector const &compPrimvars,
98  int dispatchCount,
99  int elementCount);
100 
115  HDST_API
116  static HdStExtCompGpuComputationSharedPtr
118  HdSceneDelegate *sceneDelegate,
119  HdExtComputation const *sourceComp,
120  HdExtComputationPrimvarDescriptorVector const &compPrimvars);
121 
122  HDST_API
123  virtual ~HdStExtCompGpuComputation() = default;
124 
129  HDST_API
130  virtual void GetBufferSpecs(HdBufferSpecVector *specs) const override;
131 
140  HDST_API
141  virtual void Execute(HdBufferArrayRangeSharedPtr const &range,
142  HdResourceRegistry *resourceRegistry) override;
143 
148  HDST_API
149  int GetDispatchCount() const;
150 
155  HDST_API
156  virtual int GetNumOutputElements() const override;
157 
159  HDST_API
160  virtual HdStExtCompGpuComputationResourceSharedPtr const &
161  GetResource() const;
162 
163 private:
164  SdfPath _id;
165  HdStExtCompGpuComputationResourceSharedPtr _resource;
166  HdExtComputationPrimvarDescriptorVector _compPrimvars;
167  int _dispatchCount;
168  int _elementCount;
169 
170  HdStExtCompGpuComputation() = delete;
173  = delete;
174 };
175 
176 
201 HDST_API
202 void HdSt_GetExtComputationPrimvarsComputations(
203  const SdfPath &id,
204  HdSceneDelegate *sceneDelegate,
205  HdExtComputationPrimvarDescriptorVector const& allCompPrimvars,
206  HdDirtyBits dirtyBits,
207  HdBufferSourceSharedPtrVector *sources,
208  HdBufferSourceSharedPtrVector *reserveOnlySources,
209  HdBufferSourceSharedPtrVector *separateComputationSources,
210  HdStComputationSharedPtrVector *computations);
211 
212 PXR_NAMESPACE_CLOSE_SCOPE
213 
214 #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...
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...