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_ST_EXT_COMP_PRIMVAR_BUFFER_SOURCE_H
25 #define PXR_IMAGING_HD_ST_EXT_COMP_PRIMVAR_BUFFER_SOURCE_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hdSt/api.h"
29 
31 #include "pxr/imaging/hd/types.h"
32 
33 #include "pxr/base/tf/token.h"
34 
35 #include <memory>
36 
38 
39 
41  std::shared_ptr<class HdStExtCompCpuComputation>;
42 
43 /// Hd Buffer Source that binds a primvar to a Ext Computation output.
44 /// This buffer source is compatible with being bound to a Bar.
46 {
47 public:
48 
49  /// Constructs a new primvar buffer source called primvarName and
50  /// binds it to the output called sourceOutputName from the
51  /// computation identified by source.
52  ///
53  /// Default value provides type information for the primvar and may
54  /// be used in the event of an error.
55  HDST_API
57  const TfToken &primvarName,
59  const TfToken &sourceOutputName,
60  const HdTupleType &valueType);
61 
62  HDST_API
64 
65  /// Returns the name of the primvar.
66  HDST_API
67  TfToken const &GetName() const override;
68 
69  /// Adds this Primvar's buffer description to the buffer spec vector.
70  HDST_API
71  void GetBufferSpecs(HdBufferSpecVector *specs) const override;
72 
73  /// Computes and returns a hash value for the underlying data.
74  HDST_API
75  size_t ComputeHash() const override;
76 
77  /// Extracts the primvar from the source computation.
78  HDST_API
79  bool Resolve() override;
80 
81  /// Returns a raw pointer to the primvar data.
82  HDST_API
83  void const *GetData() const override;
84 
85  /// Returns the tuple data format of the primvar data.
86  HDST_API
87  HdTupleType GetTupleType() const override;
88 
89  /// Returns a count of the number of elements.
90  HDST_API
91  size_t GetNumElements() const override;
92 
93 protected:
94  /// Returns true if the binding to the source computation was successful.
95  HDST_API
96  bool _CheckValid() const override;
97 
98 private:
99  // TfHash support.
100  template <class HashState>
101  friend void TfHashAppend(HashState &h,
102  HdStExtCompPrimvarBufferSource const &);
103 
104  TfToken _primvarName;
106  size_t _sourceOutputIdx;
107  HdTupleType _tupleType;
108  void const *_rawDataPtr;
109 
110  HdStExtCompPrimvarBufferSource() = delete;
111  HdStExtCompPrimvarBufferSource(
112  const HdStExtCompPrimvarBufferSource &) = delete;
113  HdStExtCompPrimvarBufferSource &operator = (
114  const HdStExtCompPrimvarBufferSource &) = delete;
115 };
116 
118 
119 #endif // PXR_IMAGING_HD_ST_EXT_COMP_PRIMVAR_BUFFER_SOURCE_H
HDST_API bool _CheckValid() const override
Returns true if the binding to the source computation was successful.
friend void TfHashAppend(HashState &h, HdStExtCompPrimvarBufferSource const &)
HDST_API void const * GetData() const override
Returns a raw pointer to the primvar data.
HDST_API size_t GetNumElements() const override
Returns a count of the number of elements.
HDST_API bool Resolve() override
Extracts the primvar from the source computation.
HDST_API void GetBufferSpecs(HdBufferSpecVector *specs) const override
Adds this Primvar's buffer description to the buffer spec vector.
Definition: token.h:87
HDST_API HdTupleType GetTupleType() const override
Returns the tuple data format of the primvar data.
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:803
HDST_API ~HdStExtCompPrimvarBufferSource() override
std::vector< struct HdBufferSpec > HdBufferSpecVector
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2002
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
#define HDST_API
Definition: api.h:40
HDST_API size_t ComputeHash() const override
Computes and returns a hash value for the underlying data.
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
HDST_API TfToken const & GetName() const override
Returns the name of the primvar.
std::shared_ptr< class HdStExtCompCpuComputation > HdStExtCompCpuComputationSharedPtr