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 HDST_EXT_COMP_GPU_COMPUTATION_H
25 #define HDST_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 <vector>
38 
39 PXR_NAMESPACE_OPEN_SCOPE
40 
41 class HdSceneDelegate;
42 class HdExtComputation;
43 typedef boost::shared_ptr<class HdStGLSLProgram> HdStGLSLProgramSharedPtr;
44 typedef std::vector<struct HdExtComputationPrimvarDescriptor>
45  HdExtComputationPrimvarDescriptorVector;
46 
47 typedef boost::shared_ptr<class HdStExtCompGpuComputation>
48  HdStExtCompGpuComputationSharedPtr;
49 
84 public:
93  SdfPath const &id,
94  HdStExtCompGpuComputationResourceSharedPtr const &resource,
95  HdExtComputationPrimvarDescriptorVector const &compPrimvars,
96  int dispatchCount,
97  int elementCount);
98 
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 
160  HDST_API
161  virtual HdStExtCompGpuComputationResourceSharedPtr const &
162  GetResource() const;
163 
164 private:
165  SdfPath _id;
166  HdStExtCompGpuComputationResourceSharedPtr _resource;
167  HdExtComputationPrimvarDescriptorVector _compPrimvars;
168  int _dispatchCount;
169  int _elementCount;
170 
171  HdStExtCompGpuComputation() = delete;
174  = delete;
175 };
176 
177 
202 HDST_API
203 void HdSt_GetExtComputationPrimvarsComputations(
204  const SdfPath &id,
205  HdSceneDelegate *sceneDelegate,
206  HdInterpolation interpolationMode,
207  HdDirtyBits dirtyBits,
208  HdBufferSourceVector *sources,
209  HdBufferSourceVector *reserveOnlySources,
210  HdBufferSourceVector *separateComputationSources,
211  HdComputationVector *computations);
212 
213 PXR_NAMESPACE_CLOSE_SCOPE
214 
215 #endif // HDST_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 of all GPU resources.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:287
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:50
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...