HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
bufferArrayRangeGL.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_BUFFER_ARRAY_RANGE_GL_H
25 #define PXR_IMAGING_HD_ST_BUFFER_ARRAY_RANGE_GL_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hdSt/api.h"
29 #include "pxr/imaging/hd/version.h"
30 #include "pxr/base/tf/token.h"
32 
33 #include <memory>
34 
36 
37 
38 class HdBufferArrayGL;
39 
41  std::shared_ptr<class HdStBufferArrayRangeGL>;
42 
44 
46  std::shared_ptr<class HdStBufferResourceGL>;
48  std::vector< std::pair<TfToken, HdStBufferResourceGLSharedPtr> >;
49 
50 /// \class HdStBufferArrayRangeGL
51 ///
52 /// Interface class for representing range (subset) locator of HdBufferArray.
53 ///
54 /// Each memory management strategy defines a specialized range class which is
55 /// inherited of this interface so that client (drawItem) can be agnostic about
56 /// the implementation detail of aggregation.
57 ///
59 {
60 public:
61  /// Destructor (do nothing).
62  /// The specialized range class may want to do something for garbage
63  /// collection in its destructor. However, be careful not do any
64  /// substantial work here (obviously including any kind of GL calls),
65  /// since the destructor gets called frequently on various contexts.
66  HDST_API
67  virtual ~HdStBufferArrayRangeGL();
68 
69  /// Returns the GPU resource. If the buffer array contains more than one
70  /// resource, this method raises a coding error.
71  virtual HdStBufferResourceGLSharedPtr GetResource() const = 0;
72 
73  /// Returns the named GPU resource.
75 
76  /// Returns the list of all named GPU resources for this bufferArrayRange.
77  virtual HdStBufferResourceGLNamedList const& GetResources() const = 0;
78 
79  /// Sets the bufferSpecs for all resources.
80  HDST_API
81  virtual void GetBufferSpecs(HdBufferSpecVector *bufferSpecs) const override;
82 };
83 
85 std::ostream &operator <<(std::ostream &out,
86  const HdStBufferArrayRangeGL &self);
87 
88 /// \class HdStBufferArrayRangeGLContainer
89 ///
90 /// A resizable container of HdBufferArrayRanges.
91 ///
93 {
94 public:
95  /// Constructor
96  HdStBufferArrayRangeGLContainer(int size) : _ranges(size) { }
97 
98  /// Set \p range into the container at \p index.
99  /// If the size of container is smaller than index, resize it.
100  HDST_API
102 
103  /// Returns the bar at \p index. returns null if either the index
104  // is out of range or not yet set.
105  HDST_API
106  HdStBufferArrayRangeGLSharedPtr const &Get(int index) const;
107 
108 private:
109  std::vector<HdStBufferArrayRangeGLSharedPtr> _ranges;
110 };
111 
112 
114 
115 #endif // HD_BUFFER_ARRAY_RANGE_GL_H
HDST_API std::ostream & operator<<(std::ostream &out, const HdStBufferArrayRangeGL &self)
GLenum GLint * range
Definition: glew.h:3500
GLsizeiptr size
Definition: glew.h:1681
GLuint const GLchar * name
Definition: glew.h:1814
virtual HdStBufferResourceGLSharedPtr GetResource() const =0
std::shared_ptr< class HdStBufferResourceGL > HdStBufferResourceGLSharedPtr
GLuint index
Definition: glew.h:1814
std::vector< std::pair< TfToken, HdStBufferResourceGLSharedPtr > > HdStBufferResourceGLNamedList
Definition: token.h:87
HdStBufferArrayRangeGLContainer(int size)
Constructor.
virtual HdStBufferResourceGLNamedList const & GetResources() const =0
Returns the list of all named GPU resources for this bufferArrayRange.
virtual HDST_API void GetBufferSpecs(HdBufferSpecVector *bufferSpecs) const override
Sets the bufferSpecs for all resources.
HDST_API HdStBufferArrayRangeGLSharedPtr const & Get(int index) const
Returns the bar at index. returns null if either the index.
std::shared_ptr< class HdStBufferArrayRangeGL > HdStBufferArrayRangeGLSharedPtr
std::vector< struct HdBufferSpec > HdBufferSpecVector
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1346
HDST_API void Set(int index, HdStBufferArrayRangeGLSharedPtr const &range)
#define HDST_API
Definition: api.h:40
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
virtual HDST_API ~HdStBufferArrayRangeGL()