Loading...
Searching...
No Matches
bufferUtils.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_BUFFER_UTILS_H
25#define PXR_IMAGING_HD_ST_BUFFER_UTILS_H
26
27#include "pxr/pxr.h"
28#include "pxr/imaging/hdSt/api.h"
29#include "pxr/imaging/hd/types.h"
30#include "pxr/imaging/hgi/buffer.h"
31
32#include "pxr/base/vt/value.h"
33
34PXR_NAMESPACE_OPEN_SCOPE
35
37
40HDST_API
41VtValue HdStReadBuffer(HgiBufferHandle const& buffer,
42 HdTupleType tupleType,
43 int offset,
44 int stride,
45 int numElements,
46 int elementStride,
47 HdStResourceRegistry *resourceRegistry);
48
54public:
56 HgiBufferHandle const& srcBuffer, HgiBufferHandle const& dstBuffer) :
57 _srcBuffer(srcBuffer), _dstBuffer(dstBuffer) {}
58
61 HDST_API
62 void AddRange(ptrdiff_t readOffset,
63 ptrdiff_t writeOffset,
64 ptrdiff_t copySize);
65
67 HDST_API
68 void Commit(class HgiBlitCmds* blitCmds);
69
70private:
71 struct _CopyUnit {
72 _CopyUnit(ptrdiff_t read, ptrdiff_t write, ptrdiff_t size)
73 : readOffset(read), writeOffset(write), copySize(size) {}
74
75 bool Concat(_CopyUnit const &next) {
76 if (readOffset + copySize == next.readOffset &&
77 writeOffset + copySize == next.writeOffset) {
78 copySize += next.copySize;
79 return true;
80 }
81 return false;
82 }
83
84 ptrdiff_t readOffset;
85 ptrdiff_t writeOffset;
86 ptrdiff_t copySize;
87 };
88
89 std::vector<_CopyUnit> _queue;
90 HgiBufferHandle _srcBuffer;
91 HgiBufferHandle _dstBuffer;
92};
93
94
95PXR_NAMESPACE_CLOSE_SCOPE
96
97#endif // PXR_IMAGING_HD_ST_GL_UTILS_H
A utility class to perform batched buffer copy.
Definition: bufferUtils.h:53
HDST_API void Commit(class HgiBlitCmds *blitCmds)
Execute Hgi buffer copy command to flush all scheduled range copies.
HDST_API void AddRange(ptrdiff_t readOffset, ptrdiff_t writeOffset, ptrdiff_t copySize)
Schedule the range to be copied.
A central registry of all GPU resources.
A graphics API independent abstraction of resource copy commands.
Definition: blitCmds.h:55
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:164
HdTupleType represents zero, one, or more values of the same HdType.
Definition: types.h:358