Loading...
Searching...
No Matches
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_ST_EXT_COMP_CPU_COMPUTATION_H
25#define PXR_IMAGING_HD_ST_EXT_COMP_CPU_COMPUTATION_H
26
27#include "pxr/pxr.h"
28#include "pxr/imaging/hdSt/api.h"
29
30#include "pxr/imaging/hd/bufferSource.h"
31
32#include "pxr/usd/sdf/path.h"
33
34#include "pxr/base/tf/token.h"
35#include "pxr/base/vt/value.h"
36
37#include <memory>
38#include <vector>
39
40PXR_NAMESPACE_OPEN_SCOPE
41
42
43class HdSceneDelegate;
45
46using HdStExtCompCpuComputationSharedPtr =
47 std::shared_ptr<class HdStExtCompCpuComputation>;
48using HdSt_ExtCompInputSourceSharedPtr =
49 std::shared_ptr<class HdSt_ExtCompInputSource>;
50using HdSt_ExtCompInputSourceSharedPtrVector =
51 std::vector<HdSt_ExtCompInputSourceSharedPtr>;
52
68{
69public:
70 HDST_API
71 static const size_t INVALID_OUTPUT_INDEX;
72
83 const SdfPath &id,
84 const HdSt_ExtCompInputSourceSharedPtrVector &inputs,
85 const TfTokenVector &outputs,
86 int numElements,
87 HdSceneDelegate *sceneDelegate);
88
89 HDST_API
91
94 HDST_API
95 static HdStExtCompCpuComputationSharedPtr
97 const HdExtComputation &computation,
98 HdBufferSourceSharedPtrVector *computationSources);
99
101 HDST_API
102 TfToken const &GetName() const override;
103
106 HDST_API
107 bool Resolve() override;
108
109 HDST_API
110 size_t GetNumElements() const override;
111
112
114 HDST_API
115 size_t GetOutputIndex(const TfToken &outputName) const;
116
119 HDST_API
120 const VtValue &GetOutputByIndex(size_t index) const;
121
122protected:
124 HDST_API
125 bool _CheckValid() const override;
126
127private:
128 SdfPath _id;
129 HdSt_ExtCompInputSourceSharedPtrVector _inputs;
130 TfTokenVector _outputs;
131 size_t _numElements;
132 HdSceneDelegate *_sceneDelegate;
133
134 std::vector<VtValue> _outputValues;
135
136 HdStExtCompCpuComputation() = delete;
138 const HdStExtCompCpuComputation &) = delete;
139 HdStExtCompCpuComputation &operator = (
140 const HdStExtCompCpuComputation &) = delete;
141};
142
143
144PXR_NAMESPACE_CLOSE_SCOPE
145
146#endif // PXR_IMAGING_HD_ST_EXT_COMP_CPU_COMPUTATION_H
Hydra Representation of a Client defined computation.
A abstract base class for pure cpu computation.
Definition: bufferSource.h:238
Adapter class providing data exchange with the client scene graph.
A Buffer Source that represents a CPU implementation of a ExtComputation.
HDST_API bool Resolve() override
Ask the scene delegate to run the computation and captures the output signals.
HdStExtCompCpuComputation(const SdfPath &id, const HdSt_ExtCompInputSourceSharedPtrVector &inputs, const TfTokenVector &outputs, int numElements, HdSceneDelegate *sceneDelegate)
Constructs a new Cpu ExtComputation source.
static HDST_API HdStExtCompCpuComputationSharedPtr CreateComputation(HdSceneDelegate *sceneDelegate, const HdExtComputation &computation, HdBufferSourceSharedPtrVector *computationSources)
Create a CPU computation implementing the given abstract computation.
HDST_API size_t GetNumElements() const override
Returns the number of elements (e.g.
HDST_API TfToken const & GetName() const override
Returns the id for this computation as a token.
HDST_API size_t GetOutputIndex(const TfToken &outputName) const
Converts a output name token into an index.
HDST_API bool _CheckValid() const override
Returns if the computation is specified correctly.
HDST_API const VtValue & GetOutputByIndex(size_t index) const
Returns the value of the specified output (after the computations been Resolved).
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:291
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:88
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:165
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:457