This document is for a version of USD that is under development. See this page for the current release.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
extCompCpuComputation.h
1//
2// Copyright 2017 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_IMAGING_HD_ST_EXT_COMP_CPU_COMPUTATION_H
8#define PXR_IMAGING_HD_ST_EXT_COMP_CPU_COMPUTATION_H
9
10#include "pxr/pxr.h"
11#include "pxr/imaging/hdSt/api.h"
12
13#include "pxr/imaging/hd/bufferSource.h"
14
15#include "pxr/usd/sdf/path.h"
16
17#include "pxr/base/tf/token.h"
18#include "pxr/base/vt/value.h"
19
20#include <memory>
21#include <vector>
22
23PXR_NAMESPACE_OPEN_SCOPE
24
25
26class HdSceneDelegate;
28
29using HdStExtCompCpuComputationSharedPtr =
30 std::shared_ptr<class HdStExtCompCpuComputation>;
31using HdSt_ExtCompInputSourceSharedPtr =
32 std::shared_ptr<class HdSt_ExtCompInputSource>;
33using HdSt_ExtCompInputSourceSharedPtrVector =
34 std::vector<HdSt_ExtCompInputSourceSharedPtr>;
35
51{
52public:
53 HDST_API
54 static const size_t INVALID_OUTPUT_INDEX;
55
66 const SdfPath &id,
67 const HdSt_ExtCompInputSourceSharedPtrVector &inputs,
68 const TfTokenVector &outputs,
69 int numElements,
70 HdSceneDelegate *sceneDelegate);
71
72 HDST_API
74
77 HDST_API
78 static HdStExtCompCpuComputationSharedPtr
80 const HdExtComputation &computation,
81 HdBufferSourceSharedPtrVector *computationSources);
82
84 HDST_API
85 TfToken const &GetName() const override;
86
89 HDST_API
90 bool Resolve() override;
91
92 HDST_API
93 size_t GetNumElements() const override;
94
95
97 HDST_API
98 size_t GetOutputIndex(const TfToken &outputName) const;
99
102 HDST_API
103 const VtValue &GetOutputByIndex(size_t index) const;
104
105protected:
107 HDST_API
108 bool _CheckValid() const override;
109
110private:
111 SdfPath _id;
112 HdSt_ExtCompInputSourceSharedPtrVector _inputs;
113 TfTokenVector _outputs;
114 size_t _numElements;
115 HdSceneDelegate *_sceneDelegate;
116
117 std::vector<VtValue> _outputValues;
118
119 HdStExtCompCpuComputation() = delete;
121 const HdStExtCompCpuComputation &) = delete;
122 HdStExtCompCpuComputation &operator = (
123 const HdStExtCompCpuComputation &) = delete;
124};
125
126
127PXR_NAMESPACE_CLOSE_SCOPE
128
129#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:221
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:274
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:147
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:440