All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
extCompCpuComputation.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_EXT_COMP_CPU_COMPUTATION_H
25 #define PXR_IMAGING_HD_EXT_COMP_CPU_COMPUTATION_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hd/api.h"
29 #include "pxr/imaging/hd/extCompInputSource.h"
30 
31 #include "pxr/usd/sdf/path.h"
32 
33 #include "pxr/base/tf/token.h"
34 #include "pxr/base/vt/value.h"
35 
36 #include <memory>
37 
38 PXR_NAMESPACE_OPEN_SCOPE
39 
40 class HdSceneDelegate;
41 class HdExtComputation;
43 
44 using HdExtCompCpuComputationSharedPtr =
45  std::shared_ptr<HdExtCompCpuComputation>;
46 
62 public:
63  static const size_t INVALID_OUTPUT_INDEX;
64 
75  const Hd_ExtCompInputSourceSharedPtrVector &inputs,
76  const TfTokenVector &outputs,
77  int numElements,
78  HdSceneDelegate *sceneDelegate);
79 
82  HD_API
83  static HdExtCompCpuComputationSharedPtr
84  CreateComputation(HdSceneDelegate *sceneDelegate,
85  const HdExtComputation &computation,
86  HdBufferSourceSharedPtrVector *computationSources);
87 
88  HD_API
89  virtual ~HdExtCompCpuComputation() = default;
90 
92  HD_API
93  virtual TfToken const &GetName() const override;
94 
97  HD_API
98  virtual bool Resolve() override;
99 
100  HD_API
101  virtual size_t GetNumElements() const override;
102 
103 
105  HD_API
106  size_t GetOutputIndex(const TfToken &outputName) const;
107 
110  HD_API
111  const VtValue &GetOutputByIndex(size_t index) const;
112 
113 protected:
115  HD_API
116  virtual bool _CheckValid() const override;
117 
118 private:
119  SdfPath _id;
120  Hd_ExtCompInputSourceSharedPtrVector _inputs;
121  TfTokenVector _outputs;
122  size_t _numElements;
123  HdSceneDelegate *_sceneDelegate;
124 
125  std::vector<VtValue> _outputValues;
126 
127  HdExtCompCpuComputation() = delete;
130  = delete;
131 };
132 
133 PXR_NAMESPACE_CLOSE_SCOPE
134 
135 #endif // PXR_IMAGING_HD_EXT_COMP_CPU_COMPUTATION_H
A Buffer Source that represents a CPU implementation of a ExtComputation.
Hydra Representation of a Client defined computation.
virtual HD_API TfToken const & GetName() const override
Returns the id for this computation as a token.
HD_API const VtValue & GetOutputByIndex(size_t index) const
Returns the value of the specified output (after the computations been Resolved). ...
virtual HD_API bool Resolve() override
Ask the scene delegate to run the computation and captures the output signals.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
virtual HD_API bool _CheckValid() const override
Returns if the computation is specified correctly.
A abstract base class for pure cpu computation.
Definition: bufferSource.h:238
Adapter class providing data exchange with the client scene graph.
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:288
virtual HD_API size_t GetNumElements() const override
Returns the number of elements (e.g.
HD_API size_t GetOutputIndex(const TfToken &outputName) const
Converts a output name token into an index.
static HD_API HdExtCompCpuComputationSharedPtr CreateComputation(HdSceneDelegate *sceneDelegate, const HdExtComputation &computation, HdBufferSourceSharedPtrVector *computationSources)
Create a CPU computation implementing the given abstract computation.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:168
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...