All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
extCompPrimvarBufferSource.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_PRIMVAR_BUFFER_SOURCE_H
25 #define HD_EXT_COMP_PRIMVAR_BUFFER_SOURCE_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hd/api.h"
29 #include "pxr/imaging/hd/bufferSource.h"
30 #include "pxr/imaging/hd/types.h"
31 #include "pxr/base/tf/token.h"
32 
33 PXR_NAMESPACE_OPEN_SCOPE
34 
36 
37 typedef boost::shared_ptr<HdExtCompCpuComputation>
38  HdExtCompCpuComputationSharedPtr;
39 
43 public:
44 
51  HD_API
52  HdExtCompPrimvarBufferSource(const TfToken &primvarName,
53  const HdExtCompCpuComputationSharedPtr &source,
54  const TfToken &sourceOutputName,
55  const HdTupleType &valueType);
56 
57  HD_API
58  virtual ~HdExtCompPrimvarBufferSource() = default;
59 
61  HD_API
62  virtual TfToken const &GetName() const override;
63 
65  HD_API
66  virtual void GetBufferSpecs(HdBufferSpecVector *specs) const override;
67 
69  HD_API
70  virtual size_t ComputeHash() const override;
71 
73  HD_API
74  virtual bool Resolve() override;
75 
77  HD_API
78  virtual void const *GetData() const override;
79 
81  HD_API
82  virtual HdTupleType GetTupleType() const override;
83 
85  HD_API
86  virtual size_t GetNumElements() const override;
87 
88 protected:
90  HD_API
91  virtual bool _CheckValid() const override;
92 
93 private:
94  TfToken _primvarName;
95  HdExtCompCpuComputationSharedPtr _source;
96  size_t _sourceOutputIdx;
97  HdTupleType _tupleType;
98  void const *_rawDataPtr;
99 
100  HdExtCompPrimvarBufferSource() = delete;
101  HdExtCompPrimvarBufferSource(const HdExtCompPrimvarBufferSource &)
102  = delete;
103  HdExtCompPrimvarBufferSource &operator = (
104  const HdExtCompPrimvarBufferSource &)
105  = delete;
106 };
107 
108 PXR_NAMESPACE_CLOSE_SCOPE
109 
110 #endif // HD_EXT_COMP_PRIMVAR_BUFFER_SOURCE_H
A Buffer Source that represents a CPU implementation of a ExtComputation.
virtual HD_API void const * GetData() const override
Returns a raw pointer to the primvar data.
HdTupleType represents zero, one, or more values of the same HdType.
Definition: types.h:239
Hd Buffer Source that binds a primvar to a Ext Computation output.
virtual HD_API HdTupleType GetTupleType() const override
Returns the tuple data format of the primvar data.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
virtual HD_API size_t ComputeHash() const override
Computes and returns a hash value for the underlying data.
A transient buffer of data that has not yet been committed.
Definition: bufferSource.h:57
virtual HD_API TfToken const & GetName() const override
Returns the name of the primvar.
virtual HD_API bool _CheckValid() const override
Returns true if the binding to the source computation was successful.
virtual HD_API void GetBufferSpecs(HdBufferSpecVector *specs) const override
Adds this Primvar&#39;s buffer description to the buffer spec vector.
virtual HD_API size_t GetNumElements() const override
Returns a count of the number of elements.
virtual HD_API bool Resolve() override
Extracts the primvar from the source computation.