Loading...
Searching...
No Matches
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/computation.h"
30#include "pxr/imaging/hdSt/extCompGpuComputationResource.h"
31
32#include "pxr/imaging/hd/bufferSource.h"
33
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
41PXR_NAMESPACE_OPEN_SCOPE
42
43
44class HdSceneDelegate;
46using HdStGLSLProgramSharedPtr= std::shared_ptr<class HdStGLSLProgram>;
47using HdExtComputationPrimvarDescriptorVector =
48 std::vector<struct HdExtComputationPrimvarDescriptor>;
49
50using HdStExtCompGpuComputationSharedPtr =
51 std::shared_ptr<class HdStExtCompGpuComputation>;
52
53
86{
87public:
96 SdfPath const &id,
97 HdStExtCompGpuComputationResourceSharedPtr const &resource,
98 HdExtComputationPrimvarDescriptorVector const &compPrimvars,
99 int dispatchCount,
100 int elementCount);
101
116 HDST_API
117 static HdStExtCompGpuComputationSharedPtr
119 HdSceneDelegate *sceneDelegate,
120 HdExtComputation const *sourceComp,
121 HdExtComputationPrimvarDescriptorVector const &compPrimvars);
122
123 HDST_API
125
130 HDST_API
131 void GetBufferSpecs(HdBufferSpecVector *specs) const override;
132
141 HDST_API
142 void Execute(HdBufferArrayRangeSharedPtr const &range,
143 HdResourceRegistry *resourceRegistry) override;
144
149 HDST_API
150 int GetDispatchCount() const;
151
156 HDST_API
157 int GetNumOutputElements() const override;
158
160 HDST_API
161 HdStExtCompGpuComputationResourceSharedPtr const &GetResource() const;
162
163private:
164 SdfPath _id;
165 HdStExtCompGpuComputationResourceSharedPtr _resource;
166 HdExtComputationPrimvarDescriptorVector _compPrimvars;
167 int _dispatchCount;
168 int _elementCount;
169
170 HdStExtCompGpuComputation() = delete;
172 const HdStExtCompGpuComputation &) = delete;
173 HdStExtCompGpuComputation &operator = (
174 const HdStExtCompGpuComputation &) = delete;
175};
176
177
202HDST_API
203void HdSt_GetExtComputationPrimvarsComputations(
204 const SdfPath &id,
205 HdSceneDelegate *sceneDelegate,
206 HdExtComputationPrimvarDescriptorVector const& allCompPrimvars,
207 HdDirtyBits dirtyBits,
208 HdBufferSourceSharedPtrVector *sources,
209 HdBufferSourceSharedPtrVector *reserveOnlySources,
210 HdBufferSourceSharedPtrVector *separateComputationSources,
211 HdStComputationComputeQueuePairVector *computations);
212
213
214PXR_NAMESPACE_CLOSE_SCOPE
215
216#endif // PXR_IMAGING_HD_ST_EXT_COMP_GPU_COMPUTATION_H
Hydra Representation of a Client defined computation.
A central registry for resources.
Adapter class providing data exchange with the client scene graph.
An interface class for GPU computation.
Definition: computation.h:53
A Computation that represents a GPU implementation of a ExtComputation.
HDST_API void Execute(HdBufferArrayRangeSharedPtr const &range, HdResourceRegistry *resourceRegistry) override
Executes the computation on the GPU.
HDST_API HdStExtCompGpuComputationResourceSharedPtr const & GetResource() const
Gets the shared GPU resource holder for the computation.
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.
HDST_API int GetNumOutputElements() const override
Gets the number of elements in the output primvar.
HDST_API int GetDispatchCount() const
Gets the number of GPU kernel invocations to execute.
static HDST_API HdStExtCompGpuComputationSharedPtr CreateGpuComputation(HdSceneDelegate *sceneDelegate, HdExtComputation const *sourceComp, HdExtComputationPrimvarDescriptorVector const &compPrimvars)
Creates a GPU computation implementing the given abstract computation.
HdStExtCompGpuComputation(SdfPath const &id, HdStExtCompGpuComputationResourceSharedPtr const &resource, HdExtComputationPrimvarDescriptorVector const &compPrimvars, int dispatchCount, int elementCount)
Constructs a new GPU ExtComputation computation.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:290
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...