HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
bufferArrayRange.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_BUFFER_ARRAY_RANGE_H
8 #define PXR_IMAGING_HD_ST_BUFFER_ARRAY_RANGE_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hdSt/api.h"
12 #include "pxr/imaging/hd/version.h"
13 #include "pxr/base/tf/token.h"
15 
16 #include <memory>
17 
19 
20 
21 class HdBufferArrayGL;
23 
25  std::shared_ptr<class HdStBufferArrayRange>;
26 
27 class HdStBufferResource;
28 
30  std::shared_ptr<class HdStBufferResource>;
32  std::vector< std::pair<TfToken, HdStBufferResourceSharedPtr> >;
33 
34 /// \class HdStBufferArrayRange
35 ///
36 /// Interface class for representing range (subset) locator of HdBufferArray.
37 ///
38 /// Each memory management strategy defines a specialized range class which is
39 /// inherited of this interface so that client (drawItem) can be agnostic about
40 /// the implementation detail of aggregation.
41 ///
43 {
44 public:
45  HdStBufferArrayRange(HdStResourceRegistry* resourceRegistry);
46 
47  /// Destructor (do nothing).
48  /// The specialized range class may want to do something for garbage
49  /// collection in its destructor. However, be careful not do any
50  /// substantial work here (obviously including any kind of GL calls),
51  /// since the destructor gets called frequently on various contexts.
52  HDST_API
53  virtual ~HdStBufferArrayRange();
54 
55  /// Returns the GPU resource. If the buffer array contains more than one
56  /// resource, this method raises a coding error.
57  virtual HdStBufferResourceSharedPtr GetResource() const = 0;
58 
59  /// Returns the named GPU resource.
61 
62  /// Returns the list of all named GPU resources for this bufferArrayRange.
63  virtual HdStBufferResourceNamedList const& GetResources() const = 0;
64 
65  /// Sets the bufferSpecs for all resources.
66  HDST_API
67  virtual void GetBufferSpecs(HdBufferSpecVector *bufferSpecs) const override;
68 
69  virtual int GetElementStride() const {
70  return 0;
71  }
72 
73 protected:
75 
77 
78 private:
79  HdStResourceRegistry* _resourceRegistry;
80 };
81 
83 std::ostream &operator <<(std::ostream &out,
84  const HdStBufferArrayRange &self);
85 
86 /// \class HdStBufferArrayRangeContainer
87 ///
88 /// A resizable container of HdBufferArrayRanges.
89 ///
91 {
92 public:
93  /// Constructor
94  HdStBufferArrayRangeContainer(int size) : _ranges(size) { }
95 
96  /// Set \p range into the container at \p index.
97  /// If the size of container is smaller than index, resize it.
98  HDST_API
99  void Set(int index, HdStBufferArrayRangeSharedPtr const &range);
100 
101  /// Returns the bar at \p index. returns null if either the index
102  // is out of range or not yet set.
103  HDST_API
104  HdStBufferArrayRangeSharedPtr const &Get(int index) const;
105 
106 private:
107  std::vector<HdStBufferArrayRangeSharedPtr> _ranges;
108 };
109 
110 
112 
113 #endif // HD_BUFFER_ARRAY_RANGE_GL_H
std::shared_ptr< class HdStBufferArrayRange > HdStBufferArrayRangeSharedPtr
virtual HDST_API void GetBufferSpecs(HdBufferSpecVector *bufferSpecs) const override
Sets the bufferSpecs for all resources.
GLenum GLint * range
Definition: glcorearb.h:1925
std::vector< std::pair< TfToken, HdStBufferResourceSharedPtr > > HdStBufferResourceNamedList
Definition: token.h:70
HdStBufferArrayRange(HdStResourceRegistry *resourceRegistry)
virtual int GetElementStride() const
GLuint const GLchar * name
Definition: glcorearb.h:786
std::vector< struct HdBufferSpec > HdBufferSpecVector
std::shared_ptr< class HdStBufferResource > HdStBufferResourceSharedPtr
HDST_API HdStBufferArrayRangeSharedPtr const & Get(int index) const
Returns the bar at index. returns null if either the index.
GLsizeiptr size
Definition: glcorearb.h:664
HDST_API void Set(int index, HdStBufferArrayRangeSharedPtr const &range)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define HDST_API
Definition: api.h:23
GLuint index
Definition: glcorearb.h:786
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
HdStResourceRegistry * GetResourceRegistry()
HD_API std::ostream & operator<<(std::ostream &out, const HdBufferArrayRange &self)
HdStBufferArrayRangeContainer(int size)
Constructor.
virtual HdStBufferResourceNamedList const & GetResources() const =0
Returns the list of all named GPU resources for this bufferArrayRange.
virtual HdStBufferResourceSharedPtr GetResource() const =0
virtual HDST_API ~HdStBufferArrayRange()