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 HD_EXT_COMP_CPU_COMPUTATION_H
25 #define 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 PXR_NAMESPACE_OPEN_SCOPE
37 
38 class HdSceneDelegate;
39 class HdExtComputation;
41 
42 typedef std::vector<VtValue> VtValueVector;
43 typedef boost::shared_ptr<HdExtCompCpuComputation>
44  HdExtCompCpuComputationSharedPtr;
45 
61 public:
62  static const size_t INVALID_OUTPUT_INDEX;
63 
74  const Hd_ExtCompInputSourceSharedPtrVector &inputs,
75  const TfTokenVector &outputs,
76  int numElements,
77  HdSceneDelegate *sceneDelegate);
78 
81  HD_API
82  static HdExtCompCpuComputationSharedPtr
83  CreateComputation(HdSceneDelegate *sceneDelegate,
84  const HdExtComputation &computation,
85  HdBufferSourceVector *computationSources);
86 
87  HD_API
88  virtual ~HdExtCompCpuComputation() = default;
89 
91  HD_API
92  virtual TfToken const &GetName() const override;
93 
96  HD_API
97  virtual bool Resolve() override;
98 
99  HD_API
100  virtual size_t GetNumElements() const override;
101 
102 
104  HD_API
105  size_t GetOutputIndex(const TfToken &outputName) const;
106 
109  HD_API
110  const VtValue &GetOutputByIndex(size_t index) const;
111 
112 protected:
114  HD_API
115  virtual bool _CheckValid() const override;
116 
117 private:
118  SdfPath _id;
119  Hd_ExtCompInputSourceSharedPtrVector _inputs;
120  TfTokenVector _outputs;
121  size_t _numElements;
122  HdSceneDelegate *_sceneDelegate;
123 
124  VtValueVector _outputValues;
125 
126  HdExtCompCpuComputation() = delete;
129  = delete;
130 };
131 
132 PXR_NAMESPACE_CLOSE_SCOPE
133 
134 #endif // 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:89
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:235
Adapter class providing data exchange with the client scene graph.
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:438
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:287
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.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:182
static HD_API HdExtCompCpuComputationSharedPtr CreateComputation(HdSceneDelegate *sceneDelegate, const HdExtComputation &computation, HdBufferSourceVector *computationSources)
Create a CPU computation implementing the given abstract computation.