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 PXR_IMAGING_HD_ST_DISPATCH_BUFFER_H
25 #define PXR_IMAGING_HD_ST_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/bufferArrayRange.h"
33 #include "pxr/imaging/hdSt/bufferResource.h"
34 
35 #include <memory>
36 
37 PXR_NAMESPACE_OPEN_SCOPE
38 
40 
41 using HdStDispatchBufferSharedPtr = std::shared_ptr<class HdStDispatchBuffer>;
42 
92 public:
94  HDST_API
95  HdStDispatchBuffer(HdStResourceRegistry* resourceRegistry,
96  TfToken const &role,
97  int count,
98  unsigned int commandNumUints);
99 
101  HDST_API
103 
105  HDST_API
106  void CopyData(std::vector<uint32_t> const &data);
107 
109  HDST_API
110  void AddBufferResourceView(TfToken const &name,
111  HdTupleType tupleType, int offset);
112 
114  int GetCount() const { return _count; }
115 
117  unsigned int GetCommandNumUints() const { return _commandNumUints; }
118 
121  HdStBufferArrayRangeSharedPtr GetBufferArrayRange() const {
122  return _bar;
123  }
124 
126  HdStBufferResourceSharedPtr GetEntireResource() const {
127  return _entireResource;
128  }
129 
130  // HdBufferArray overrides. they are not supported in this class.
131  HDST_API
132  virtual bool GarbageCollect();
133  HDST_API
134  virtual void Reallocate(
135  std::vector<HdBufferArrayRangeSharedPtr> const &,
136  HdBufferArraySharedPtr const &);
137 
138  HDST_API
139  virtual void DebugDump(std::ostream &out) const;
140 
143  HDST_API
144  HdStBufferResourceSharedPtr GetResource() const;
145 
150  HDST_API
151  HdStBufferResourceSharedPtr GetResource(TfToken const& name);
152 
154  HdStBufferResourceNamedList const& GetResources() const {return _resourceList;}
155 
156 protected:
158  HDST_API
159  HdStBufferResourceSharedPtr _AddResource(TfToken const& name,
160  HdTupleType tupleType,
161  int offset,
162  int stride);
163 
164 private:
165  HdStResourceRegistry *_resourceRegistry;
166  int _count;
167  unsigned int _commandNumUints;
168  HdStBufferResourceNamedList _resourceList;
169  HdStBufferResourceSharedPtr _entireResource;
170  HdStBufferArrayRangeSharedPtr _bar; // Alternative to range list in base class
171 };
172 
173 
174 PXR_NAMESPACE_CLOSE_SCOPE
175 
176 #endif // PXR_IMAGING_HD_ST_DISPATCH_BUFFER_H
HdStBufferResourceSharedPtr GetEntireResource() const
Returns entire buffer as a single HdBufferResource.
HDST_API HdStDispatchBuffer(HdStResourceRegistry *resourceRegistry, TfToken const &role, int count, unsigned int commandNumUints)
Constructor. commandNumUints is given in how many integers.
Similar to a VAO, this object is a bundle of coherent buffers.
Definition: bufferArray.h:88
HdTupleType represents zero, one, or more values of the same HdType.
Definition: types.h:325
A VBO of a simple array of unsigned integers.
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.
HdStBufferArrayRangeSharedPtr GetBufferArrayRange() const
Returns a bar which locates all interleaved resources of the entire buffer.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
HDST_API ~HdStDispatchBuffer()
Destructor.
virtual HDST_API bool GarbageCollect()
Performs compaction if necessary and returns true if it becomes empty.
A central registry of all GPU resources.
HdStBufferResourceNamedList const & GetResources() const
Returns the list of all named GPU resources for this bufferArray.
int GetCount() const
Returns the dispatch count.
HDST_API HdStBufferResourceSharedPtr _AddResource(TfToken const &name, HdTupleType tupleType, int offset, int stride)
Adds a new, named GPU resource and returns it.
HDST_API void CopyData(std::vector< uint32_t > const &data)
Update entire buffer data.
virtual HDST_API void DebugDump(std::ostream &out) const
Debug output.
unsigned int GetCommandNumUints() const
Returns the number of uints in a single draw command.
HDST_API HdStBufferResourceSharedPtr GetResource() const
Returns the GPU resource.