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 PXR_IMAGING_HD_EXT_COMP_PRIMVAR_BUFFER_SOURCE_H
25 #define PXR_IMAGING_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 #include <memory>
34 
35 PXR_NAMESPACE_OPEN_SCOPE
36 
38 
39 using HdExtCompCpuComputationSharedPtr =
40  std::shared_ptr<HdExtCompCpuComputation>;
41 
45 public:
46 
53  HD_API
54  HdExtCompPrimvarBufferSource(const TfToken &primvarName,
55  const HdExtCompCpuComputationSharedPtr &source,
56  const TfToken &sourceOutputName,
57  const HdTupleType &valueType);
58 
59  HD_API
60  virtual ~HdExtCompPrimvarBufferSource() = default;
61 
63  HD_API
64  virtual TfToken const &GetName() const override;
65 
67  HD_API
68  virtual void GetBufferSpecs(HdBufferSpecVector *specs) const override;
69 
71  HD_API
72  virtual size_t ComputeHash() const override;
73 
75  HD_API
76  virtual bool Resolve() override;
77 
79  HD_API
80  virtual void const *GetData() const override;
81 
83  HD_API
84  virtual HdTupleType GetTupleType() const override;
85 
87  HD_API
88  virtual size_t GetNumElements() const override;
89 
90 protected:
92  HD_API
93  virtual bool _CheckValid() const override;
94 
95 private:
96  // TfHash support.
97  template <class HashState>
98  friend void TfHashAppend(HashState &h,
99  HdExtCompPrimvarBufferSource const &);
100 
101  TfToken _primvarName;
102  HdExtCompCpuComputationSharedPtr _source;
103  size_t _sourceOutputIdx;
104  HdTupleType _tupleType;
105  void const *_rawDataPtr;
106 
107  HdExtCompPrimvarBufferSource() = delete;
108  HdExtCompPrimvarBufferSource(const HdExtCompPrimvarBufferSource &)
109  = delete;
110  HdExtCompPrimvarBufferSource &operator = (
111  const HdExtCompPrimvarBufferSource &)
112  = delete;
113 };
114 
115 PXR_NAMESPACE_CLOSE_SCOPE
116 
117 #endif // PXR_IMAGING_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:325
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:87
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:55
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.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...