Loading...
Searching...
No Matches
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
37PXR_NAMESPACE_OPEN_SCOPE
38
40
41using HdStDispatchBufferSharedPtr = std::shared_ptr<class HdStDispatchBuffer>;
42
92{
93public:
95 HDST_API
97 TfToken const &role,
98 int count,
99 unsigned int commandNumUints);
100
102 HDST_API
104
106 HDST_API
107 void CopyData(std::vector<uint32_t> const &data);
108
110 HDST_API
112 HdTupleType tupleType, int offset);
113
115 int GetCount() const { return _count; }
116
118 unsigned int GetCommandNumUints() const { return _commandNumUints; }
119
122 HdStBufferArrayRangeSharedPtr GetBufferArrayRange() const {
123 return _bar;
124 }
125
127 HdStBufferResourceSharedPtr GetEntireResource() const {
128 return _entireResource;
129 }
130
131 // HdBufferArray overrides. they are not supported in this class.
132 HDST_API
133 bool GarbageCollect() override;
134 HDST_API
136 std::vector<HdBufferArrayRangeSharedPtr> const &,
137 HdBufferArraySharedPtr const &) override;
138
139 HDST_API
140 void DebugDump(std::ostream &out) const override;
141
144 HDST_API
145 HdStBufferResourceSharedPtr GetResource() const;
146
151 HDST_API
152 HdStBufferResourceSharedPtr GetResource(TfToken const& name);
153
155 HdStBufferResourceNamedList const& GetResources() const {return _resourceList;}
156
157protected:
159 HDST_API
160 HdStBufferResourceSharedPtr _AddResource(TfToken const& name,
161 HdTupleType tupleType,
162 int offset,
163 int stride);
164
165private:
166 HdStResourceRegistry *_resourceRegistry;
167 int _count;
168 unsigned int _commandNumUints;
169 HdStBufferResourceNamedList _resourceList;
170 HdStBufferResourceSharedPtr _entireResource;
171 HdStBufferArrayRangeSharedPtr _bar; // Alternative to range list in base class
172};
173
174
175PXR_NAMESPACE_CLOSE_SCOPE
176
177#endif // PXR_IMAGING_HD_ST_DISPATCH_BUFFER_H
Similar to a VAO, this object is a bundle of coherent buffers.
Definition: bufferArray.h:88
A VBO of a simple array of unsigned integers.
HDST_API HdStBufferResourceSharedPtr _AddResource(TfToken const &name, HdTupleType tupleType, int offset, int stride)
Adds a new, named GPU resource and returns it.
HDST_API HdStBufferResourceSharedPtr GetResource(TfToken const &name)
Returns the named GPU resource.
int GetCount() const
Returns the dispatch count.
HDST_API HdStBufferResourceSharedPtr GetResource() const
Returns the GPU resource.
HDST_API void CopyData(std::vector< uint32_t > const &data)
Update entire buffer data.
HDST_API void Reallocate(std::vector< HdBufferArrayRangeSharedPtr > const &, HdBufferArraySharedPtr const &) override
Performs reallocation.
HdStBufferResourceSharedPtr GetEntireResource() const
Returns entire buffer as a single HdStBufferResource.
HDST_API bool GarbageCollect() override
Performs compaction if necessary and returns true if it becomes empty.
HDST_API void DebugDump(std::ostream &out) const override
Debug output.
HdStBufferResourceNamedList const & GetResources() const
Returns the list of all named GPU resources for this bufferArray.
HDST_API ~HdStDispatchBuffer() override
Destructor.
HDST_API void AddBufferResourceView(TfToken const &name, HdTupleType tupleType, int offset)
Add an interleaved view to this buffer.
HDST_API HdStDispatchBuffer(HdStResourceRegistry *resourceRegistry, TfToken const &role, int count, unsigned int commandNumUints)
Constructor. commandNumUints is given in how many integers.
unsigned int GetCommandNumUints() const
Returns the number of uints in a single draw command.
HdStBufferArrayRangeSharedPtr GetBufferArrayRange() const
Returns a bar which locates all interleaved resources of the entire buffer.
A central registry of all GPU resources.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:88
HdTupleType represents zero, one, or more values of the same HdType.
Definition: types.h:358