All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dispatchBuffer.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 HDST_DISPATCH_BUFFER_H
25 #define HDST_DISPATCH_BUFFER_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hd/version.h"
29 #include "pxr/imaging/hd/bufferArray.h"
30 #include "pxr/imaging/hd/bufferSpec.h"
31 #include "pxr/imaging/hdSt/api.h"
32 #include "pxr/imaging/hdSt/bufferArrayRangeGL.h"
33 #include "pxr/imaging/hdSt/bufferResourceGL.h"
34 
35 #include <boost/shared_ptr.hpp>
36 
37 PXR_NAMESPACE_OPEN_SCOPE
38 
39 
40 typedef boost::shared_ptr<class HdStDispatchBuffer> HdStDispatchBufferSharedPtr;
41 
91 public:
93  HDST_API
94  HdStDispatchBuffer(TfToken const &role, int count,
95  unsigned int commandNumUints);
96 
98  HDST_API
100 
102  HDST_API
103  void CopyData(std::vector<GLuint> const &data);
104 
106  HDST_API
107  void AddBufferResourceView(TfToken const &name,
108  HdTupleType tupleType, int offset);
109 
111  int GetCount() const { return _count; }
112 
114  unsigned int GetCommandNumUints() const { return _commandNumUints; }
115 
118  HdStBufferArrayRangeGLSharedPtr GetBufferArrayRange() const {
119  return _bar;
120  }
121 
123  HdStBufferResourceGLSharedPtr GetEntireResource() const {
124  return _entireResource;
125  }
126 
127  // HdBufferArray overrides. they are not supported in this class.
128  HDST_API
129  virtual bool GarbageCollect();
130  HDST_API
131  virtual void Reallocate(
132  std::vector<HdBufferArrayRangeSharedPtr> const &,
133  HdBufferArraySharedPtr const &);
134 
135  HDST_API
136  virtual void DebugDump(std::ostream &out) const;
137 
140  HDST_API
141  HdStBufferResourceGLSharedPtr GetResource() const;
142 
147  HDST_API
148  HdStBufferResourceGLSharedPtr GetResource(TfToken const& name);
149 
151  HdStBufferResourceGLNamedList const& GetResources() const {return _resourceList;}
152 
153 protected:
155  HDST_API
156  HdStBufferResourceGLSharedPtr _AddResource(TfToken const& name,
157  HdTupleType tupleType,
158  int offset,
159  int stride);
160 
161 private:
162  int _count;
163  unsigned int _commandNumUints;
164  HdStBufferResourceGLNamedList _resourceList;
165  HdStBufferResourceGLSharedPtr _entireResource;
166  HdStBufferArrayRangeGLSharedPtr _bar; // Alternative to range list in base class
167 };
168 
169 
170 PXR_NAMESPACE_CLOSE_SCOPE
171 
172 #endif // HDST_DISPATCH_BUFFER_H
Similar to a VAO, this object is a bundle of coherent buffers.
Definition: bufferArray.h:92
HdStBufferResourceGLNamedList const & GetResources() const
Returns the list of all named GPU resources for this bufferArray.
HdTupleType represents zero, one, or more values of the same HdType.
Definition: types.h:239
A VBO of a simple array of GLuint.
virtual HDST_API void Reallocate(std::vector< HdBufferArrayRangeSharedPtr > const &, HdBufferArraySharedPtr const &)
Performs reallocation.
HDST_API void AddBufferResourceView(TfToken const &name, HdTupleType tupleType, int offset)
Add an interleaved view to this buffer.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
HDST_API ~HdStDispatchBuffer()
Destructor.
virtual HDST_API bool GarbageCollect()
Performs compaction if necessary and returns true if it becomes empty.
HDST_API void CopyData(std::vector< GLuint > const &data)
Update entire buffer data.
HDST_API HdStBufferResourceGLSharedPtr _AddResource(TfToken const &name, HdTupleType tupleType, int offset, int stride)
Adds a new, named GPU resource and returns it.
HdStBufferResourceGLSharedPtr GetEntireResource() const
Returns entire buffer as a single HdBufferResource.
HDST_API HdStBufferResourceGLSharedPtr GetResource() const
Returns the GPU resource.
int GetCount() const
Returns the dispatch count.
HdStBufferArrayRangeGLSharedPtr GetBufferArrayRange() const
Returns a bar which locates all interleaved resources of the entire buffer.
virtual HDST_API void DebugDump(std::ostream &out) const
Debug output.
unsigned int GetCommandNumUints() const
Returns the number of GLuints in a single draw command.
HDST_API HdStDispatchBuffer(TfToken const &role, int count, unsigned int commandNumUints)
Constructor. commandNumUints is given in how many integers.