All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
bufferArrayRange.h
1 //
2 // Copyright 2016 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 HD_BUFFER_ARRAY_RANGE_H
25 #define HD_BUFFER_ARRAY_RANGE_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hd/api.h"
29 #include "pxr/imaging/hd/version.h"
30 #include "pxr/base/tf/token.h"
31 #include "pxr/base/vt/value.h"
32 #include "pxr/imaging/hd/bufferResource.h"
33 #include "pxr/imaging/hd/bufferArray.h"
34 
35 #include <boost/noncopyable.hpp>
36 #include <boost/shared_ptr.hpp>
37 
38 PXR_NAMESPACE_OPEN_SCOPE
39 
40 
41 typedef std::vector<struct HdBufferSpec> HdBufferSpecVector;
42 typedef boost::shared_ptr<class HdBufferSource> HdBufferSourceSharedPtr;
43 typedef boost::shared_ptr<class HdBufferArrayRange> HdBufferArrayRangeSharedPtr;
44 
53 class HdBufferArrayRange : boost::noncopyable {
54 public:
60  HD_API
61  virtual ~HdBufferArrayRange();
62 
64  virtual bool IsValid() const = 0;
65 
67  virtual bool IsAssigned() const = 0;
68 
70  virtual bool IsImmutable() const = 0;
71 
74  virtual bool Resize(int numElements) = 0;
75 
77  virtual void CopyData(HdBufferSourceSharedPtr const &bufferSource) = 0;
78 
80  virtual VtValue ReadData(TfToken const &name) const = 0;
81 
83  virtual int GetOffset() const = 0;
84 
86  virtual int GetIndex() const = 0;
87 
89  virtual size_t GetNumElements() const = 0;
90 
92  virtual size_t GetVersion() const = 0;
93 
96  virtual void IncrementVersion() = 0;
97 
99  virtual size_t GetMaxNumElements() const = 0;
100 
102  virtual HdBufferArrayUsageHint GetUsageHint() const = 0;
103 
105  virtual void SetBufferArray(HdBufferArray *bufferArray) = 0;
106 
108  virtual void DebugDump(std::ostream &out) const = 0;
109 
111  bool IsAggregatedWith(HdBufferArrayRangeSharedPtr const &other) const {
112  return (other && (_GetAggregation() == other->_GetAggregation()));
113  }
114 
116  virtual void GetBufferSpecs(HdBufferSpecVector *bufferSpecs) const = 0;
117 
118 protected:
120  virtual const void *_GetAggregation() const = 0;
121 
122 };
123 
124 HD_API
125 std::ostream &operator <<(std::ostream &out,
126  const HdBufferArrayRange &self);
127 
133 {
134 public:
136  HdBufferArrayRangeContainer(int size) : _ranges(size) { }
137 
140  HD_API
141  void Set(int index, HdBufferArrayRangeSharedPtr const &range);
142 
144  // is out of range or not yet set.
145  HD_API
146  HdBufferArrayRangeSharedPtr const &Get(int index) const;
147 
148 private:
149  std::vector<HdBufferArrayRangeSharedPtr> _ranges;
150 };
151 
152 
153 PXR_NAMESPACE_CLOSE_SCOPE
154 
155 #endif // HD_BUFFER_ARRAY_RANGE_H
virtual bool IsValid() const =0
Returns true if this range is valid.
The union provides a set of flags that provide hints to the memory management system about the proper...
Definition: bufferArray.h:74
Similar to a VAO, this object is a bundle of coherent buffers.
Definition: bufferArray.h:92
virtual VtValue ReadData(TfToken const &name) const =0
Read back the buffer content.
bool IsAggregatedWith(HdBufferArrayRangeSharedPtr const &other) const
Returns true if the underlying buffer array is aggregated to other&#39;s.
virtual bool IsImmutable() const =0
Returns true if this range is marked as immutable.
virtual size_t GetVersion() const =0
Returns the version of the buffer array.
Interface class for representing range (subset) locator of HdBufferArray.
virtual size_t GetMaxNumElements() const =0
Returns the max number of elements.
A resizable container of HdBufferArrayRanges.
virtual bool IsAssigned() const =0
Returns true is the range has been assigned to a buffer.
HD_API void Set(int index, HdBufferArrayRangeSharedPtr const &range)
Set range into the container at index.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
HdBufferArrayRangeContainer(int size)
Constructor.
virtual void CopyData(HdBufferSourceSharedPtr const &bufferSource)=0
Copy source data into buffer.
virtual void DebugDump(std::ostream &out) const =0
Debug output.
virtual void GetBufferSpecs(HdBufferSpecVector *bufferSpecs) const =0
Gets the bufferSpecs for all resources.
virtual bool Resize(int numElements)=0
Resize memory area for this range.
virtual int GetOffset() const =0
Returns the relative offset for this range.
virtual const void * _GetAggregation() const =0
Returns the aggregation container to be used in IsAggregatedWith()
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
virtual HD_API ~HdBufferArrayRange()
Destructor (do nothing).
virtual HdBufferArrayUsageHint GetUsageHint() const =0
Gets the usage hint on the underlying buffer array.
virtual void IncrementVersion()=0
Increment the version of the buffer array.
HD_API HdBufferArrayRangeSharedPtr const & Get(int index) const
Returns the bar at index. returns null if either the index.
virtual int GetIndex() const =0
Returns the index for this range.
virtual size_t GetNumElements() const =0
Returns the number of elements.
virtual void SetBufferArray(HdBufferArray *bufferArray)=0
Sets the buffer array associated with this buffer;.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:182