Loading...
Searching...
No Matches
dispatchBuffer.h
1//
2// Copyright 2016 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_IMAGING_HD_ST_DISPATCH_BUFFER_H
8#define PXR_IMAGING_HD_ST_DISPATCH_BUFFER_H
9
10#include "pxr/pxr.h"
11#include "pxr/imaging/hd/version.h"
12#include "pxr/imaging/hd/bufferArray.h"
13#include "pxr/imaging/hd/bufferSpec.h"
14#include "pxr/imaging/hdSt/api.h"
15#include "pxr/imaging/hdSt/bufferArrayRange.h"
16#include "pxr/imaging/hdSt/bufferResource.h"
17
18#include <memory>
19
20PXR_NAMESPACE_OPEN_SCOPE
21
23
24using HdStDispatchBufferSharedPtr = std::shared_ptr<class HdStDispatchBuffer>;
25
75{
76public:
78 HDST_API
80 TfToken const &role,
81 int count,
82 unsigned int commandNumUints);
83
85 HDST_API
87
89 HDST_API
90 void CopyData(std::vector<uint32_t> const &data);
91
93 HDST_API
95 HdTupleType tupleType, int offset);
96
98 int GetCount() const { return _count; }
99
101 unsigned int GetCommandNumUints() const { return _commandNumUints; }
102
105 HdStBufferArrayRangeSharedPtr GetBufferArrayRange() const {
106 return _bar;
107 }
108
110 HdStBufferResourceSharedPtr GetEntireResource() const {
111 return _entireResource;
112 }
113
114 // HdBufferArray overrides. they are not supported in this class.
115 HDST_API
116 bool GarbageCollect() override;
117 HDST_API
119 std::vector<HdBufferArrayRangeSharedPtr> const &,
120 HdBufferArraySharedPtr const &) override;
121
122 HDST_API
123 void DebugDump(std::ostream &out) const override;
124
127 HDST_API
128 HdStBufferResourceSharedPtr GetResource() const;
129
134 HDST_API
135 HdStBufferResourceSharedPtr GetResource(TfToken const& name);
136
138 HdStBufferResourceNamedList const& GetResources() const {return _resourceList;}
139
140protected:
142 HDST_API
143 HdStBufferResourceSharedPtr _AddResource(TfToken const& name,
144 HdTupleType tupleType,
145 int offset,
146 int stride);
147
148private:
149 HdStResourceRegistry *_resourceRegistry;
150 int _count;
151 unsigned int _commandNumUints;
152 HdStBufferResourceNamedList _resourceList;
153 HdStBufferResourceSharedPtr _entireResource;
154 HdStBufferArrayRangeSharedPtr _bar; // Alternative to range list in base class
155};
156
157
158PXR_NAMESPACE_CLOSE_SCOPE
159
160#endif // PXR_IMAGING_HD_ST_DISPATCH_BUFFER_H
Similar to a VAO, this object is a bundle of coherent buffers.
Definition: bufferArray.h:69
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:71
HdTupleType represents zero, one, or more values of the same HdType.
Definition: types.h:343