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 terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_IMAGING_HD_ST_EXT_COMP_PRIMVAR_BUFFER_SOURCE_H
8 #define PXR_IMAGING_HD_ST_EXT_COMP_PRIMVAR_BUFFER_SOURCE_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hdSt/api.h"
12 
14 #include "pxr/imaging/hd/types.h"
15 
16 #include "pxr/base/tf/token.h"
17 
18 #include <memory>
19 
21 
22 
24  std::shared_ptr<class HdStExtCompCpuComputation>;
25 
26 /// Hd Buffer Source that binds a primvar to a Ext Computation output.
27 /// This buffer source is compatible with being bound to a Bar.
29 {
30 public:
31 
32  /// Constructs a new primvar buffer source called primvarName and
33  /// binds it to the output called sourceOutputName from the
34  /// computation identified by source.
35  ///
36  /// Default value provides type information for the primvar and may
37  /// be used in the event of an error.
38  HDST_API
40  const TfToken &primvarName,
42  const TfToken &sourceOutputName,
43  const HdTupleType &valueType);
44 
45  HDST_API
47 
48  /// Returns the name of the primvar.
49  HDST_API
50  TfToken const &GetName() const override;
51 
52  /// Adds this Primvar's buffer description to the buffer spec vector.
53  HDST_API
54  void GetBufferSpecs(HdBufferSpecVector *specs) const override;
55 
56  /// Computes and returns a hash value for the underlying data.
57  HDST_API
58  size_t ComputeHash() const override;
59 
60  /// Extracts the primvar from the source computation.
61  HDST_API
62  bool Resolve() override;
63 
64  /// Returns a raw pointer to the primvar data.
65  HDST_API
66  void const *GetData() const override;
67 
68  /// Returns the tuple data format of the primvar data.
69  HDST_API
70  HdTupleType GetTupleType() const override;
71 
72  /// Returns a count of the number of elements.
73  HDST_API
74  size_t GetNumElements() const override;
75 
76 protected:
77  /// Returns true if the binding to the source computation was successful.
78  HDST_API
79  bool _CheckValid() const override;
80 
81 private:
82  // TfHash support.
83  template <class HashState>
84  friend void TfHashAppend(HashState &h,
85  HdStExtCompPrimvarBufferSource const &);
86 
87  TfToken _primvarName;
89  size_t _sourceOutputIdx;
90  HdTupleType _tupleType;
91  void const *_rawDataPtr;
92 
93  HdStExtCompPrimvarBufferSource() = delete;
94  HdStExtCompPrimvarBufferSource(
95  const HdStExtCompPrimvarBufferSource &) = delete;
96  HdStExtCompPrimvarBufferSource &operator = (
97  const HdStExtCompPrimvarBufferSource &) = delete;
98 };
99 
101 
102 #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:70
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:1425
#define HDST_API
Definition: api.h:23
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:74
HDST_API TfToken const & GetName() const override
Returns the name of the primvar.
std::shared_ptr< class HdStExtCompCpuComputation > HdStExtCompCpuComputationSharedPtr