Loading...
Searching...
No Matches
bufferUtils.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_BUFFER_UTILS_H
8#define PXR_IMAGING_HD_ST_BUFFER_UTILS_H
9
10#include "pxr/pxr.h"
11#include "pxr/imaging/hdSt/api.h"
12#include "pxr/imaging/hd/types.h"
13#include "pxr/imaging/hgi/buffer.h"
14
15#include "pxr/base/vt/value.h"
16
17PXR_NAMESPACE_OPEN_SCOPE
18
20
23HDST_API
24VtValue HdStReadBuffer(HgiBufferHandle const& buffer,
25 HdTupleType tupleType,
26 int offset,
27 int stride,
28 int numElements,
29 int elementStride,
30 HdStResourceRegistry *resourceRegistry);
31
37public:
39 HgiBufferHandle const& srcBuffer, HgiBufferHandle const& dstBuffer) :
40 _srcBuffer(srcBuffer), _dstBuffer(dstBuffer) {}
41
44 HDST_API
45 void AddRange(ptrdiff_t readOffset,
46 ptrdiff_t writeOffset,
47 ptrdiff_t copySize);
48
50 HDST_API
51 void Commit(class HgiBlitCmds* blitCmds);
52
53private:
54 struct _CopyUnit {
55 _CopyUnit(ptrdiff_t read, ptrdiff_t write, ptrdiff_t size)
56 : readOffset(read), writeOffset(write), copySize(size) {}
57
58 bool Concat(_CopyUnit const &next) {
59 if (readOffset + copySize == next.readOffset &&
60 writeOffset + copySize == next.writeOffset) {
61 copySize += next.copySize;
62 return true;
63 }
64 return false;
65 }
66
67 ptrdiff_t readOffset;
68 ptrdiff_t writeOffset;
69 ptrdiff_t copySize;
70 };
71
72 std::vector<_CopyUnit> _queue;
73 HgiBufferHandle _srcBuffer;
74 HgiBufferHandle _dstBuffer;
75};
76
77
78PXR_NAMESPACE_CLOSE_SCOPE
79
80#endif // PXR_IMAGING_HD_ST_GL_UTILS_H
A utility class to perform batched buffer copy.
Definition: bufferUtils.h:36
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:38
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:90
HdTupleType represents zero, one, or more values of the same HdType.
Definition: types.h:343