All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
glUtils.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_GL_UTILS_H
25 #define PXR_IMAGING_HD_ST_GL_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 
34 PXR_NAMESPACE_OPEN_SCOPE
35 
36 class HdStGLUtils {
37 public:
38 
41  HDST_API
42  static VtValue ReadBuffer(uint64_t vbo,
43  HdTupleType tupleType,
44  int vboOffset,
45  int stride,
46  int numElements);
47 };
48 
54 public:
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 
70 private:
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 
95 PXR_NAMESPACE_CLOSE_SCOPE
96 
97 #endif // PXR_IMAGING_HD_ST_GL_UTILS_H
HDST_API void Commit(class HgiBlitCmds *blitCmds)
Execute Hgi buffer copy command to flush all scheduled range copies.
HdTupleType represents zero, one, or more values of the same HdType.
Definition: types.h:325
HDST_API void AddRange(ptrdiff_t readOffset, ptrdiff_t writeOffset, ptrdiff_t copySize)
Schedule the range to be copied.
A utility class to perform batched buffer copy.
Definition: glUtils.h:53
A graphics API independent abstraction of resource copy commands.
Definition: blitCmds.h:54
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:168