HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
extCompPrimvarBufferSource.h
Go to the documentation of this file.
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"
30 #include "pxr/imaging/hd/types.h"
31 #include "pxr/base/tf/token.h"
32 
33 #include <memory>
34 
36 
38 
40  std::shared_ptr<HdExtCompCpuComputation>;
41 
42 /// Hd Buffer Source that binds a primvar to a Ext Computation output.
43 /// This buffer source is compatible with being bound to a Bar.
45 public:
46 
47  /// Constructs a new primvar buffer source called primvarName and
48  /// binds it to the output called sourceOutputName from the
49  /// computation identified by source.
50  ///
51  /// Default value provides type information for the primvar and may
52  /// be used in the event of an error.
53  HD_API
54  HdExtCompPrimvarBufferSource(const TfToken &primvarName,
56  const TfToken &sourceOutputName,
57  const HdTupleType &valueType);
58 
59  HD_API
60  virtual ~HdExtCompPrimvarBufferSource() = default;
61 
62  /// Returns the name of the primvar.
63  HD_API
64  virtual TfToken const &GetName() const override;
65 
66  /// Adds this Primvar's buffer description to the buffer spec vector.
67  HD_API
68  virtual void GetBufferSpecs(HdBufferSpecVector *specs) const override;
69 
70  /// Computes and returns a hash value for the underlying data.
71  HD_API
72  virtual size_t ComputeHash() const override;
73 
74  /// Extracts the primvar from the source computation.
75  HD_API
76  virtual bool Resolve() override;
77 
78  /// Returns a raw pointer to the primvar data.
79  HD_API
80  virtual void const *GetData() const override;
81 
82  /// Returns the tuple data format of the primvar data.
83  HD_API
84  virtual HdTupleType GetTupleType() const override;
85 
86  /// Returns a count of the number of elements.
87  HD_API
88  virtual size_t GetNumElements() const override;
89 
90 protected:
91  /// Returns true if the binding to the source computation was successful.
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;
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 
116 
117 #endif // PXR_IMAGING_HD_EXT_COMP_PRIMVAR_BUFFER_SOURCE_H
virtual HD_API bool _CheckValid() const override
Returns true if the binding to the source computation was successful.
#define HD_API
Definition: api.h:40
virtual HD_API size_t GetNumElements() const override
Returns a count of the number of elements.
virtual HD_API void GetBufferSpecs(HdBufferSpecVector *specs) const override
Adds this Primvar's buffer description to the buffer spec vector.
virtual HD_API ~HdExtCompPrimvarBufferSource()=default
Definition: token.h:87
virtual HD_API TfToken const & GetName() const override
Returns the name of the primvar.
virtual HD_API void const * GetData() const override
Returns a raw pointer to the primvar data.
friend void TfHashAppend(HashState &h, HdExtCompPrimvarBufferSource const &)
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:802
std::vector< struct HdBufferSpec > HdBufferSpecVector
virtual HD_API HdTupleType GetTupleType() const override
Returns the tuple data format of the primvar data.
std::shared_ptr< HdExtCompCpuComputation > HdExtCompCpuComputationSharedPtr
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2001
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1375
virtual HD_API bool Resolve() override
Extracts the primvar from the source computation.
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
virtual HD_API size_t ComputeHash() const override
Computes and returns a hash value for the underlying data.