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 HDST_GL_UTILS_H
25 #define HDST_GL_UTILS_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/glf/glew.h"
29 #include "pxr/imaging/hdSt/api.h"
30 #include "pxr/imaging/hd/types.h"
31 #include "pxr/base/vt/value.h"
32 
33 PXR_NAMESPACE_OPEN_SCOPE
34 
35 class HdStGLUtils {
36 public:
37 
38  HDST_API
39  static bool IsGpuComputeEnabled();
40 
43  HDST_API
44  static VtValue ReadBuffer(GLint vbo,
45  HdTupleType tupleType,
46  int vboOffset,
47  int stride,
48  int numElements);
49 
52  HDST_API
53  static bool GetShaderCompileStatus(GLuint shader,
54  std::string * reason = NULL);
55 
58  HDST_API
59  static bool GetProgramLinkStatus(GLuint program,
60  std::string * reason = NULL);
61 };
62 
68 public:
69  HdStGLBufferRelocator(GLint srcBuffer, GLint dstBuffer) :
70  _srcBuffer(srcBuffer), _dstBuffer(dstBuffer) {}
71 
74  HDST_API
75  void AddRange(ptrdiff_t readOffset,
76  ptrdiff_t writeOffset,
77  ptrdiff_t copySize);
78 
80  HDST_API
81  void Commit();
82 
83 private:
84  struct _CopyUnit {
85  _CopyUnit(ptrdiff_t read, ptrdiff_t write, ptrdiff_t size)
86  : readOffset(read), writeOffset(write), copySize(size) {}
87 
88  bool Concat(_CopyUnit const &next) {
89  if (readOffset + copySize == next.readOffset &&
90  writeOffset + copySize == next.writeOffset) {
91  copySize += next.copySize;
92  return true;
93  }
94  return false;
95  }
96 
97  ptrdiff_t readOffset;
98  ptrdiff_t writeOffset;
99  ptrdiff_t copySize;
100  };
101 
102  std::vector<_CopyUnit> _queue;
103  GLint _srcBuffer;
104  GLint _dstBuffer;
105 };
106 
107 
108 PXR_NAMESPACE_CLOSE_SCOPE
109 
110 #endif // HDST_GL_UTILS_H
HdTupleType represents zero, one, or more values of the same HdType.
Definition: types.h:239
HDST_API void Commit()
Execute GL buffer copy command to flush all scheduled range copies.
A utility class to perform batched buffer copy.
Definition: glUtils.h:67
HDST_API void AddRange(ptrdiff_t readOffset, ptrdiff_t writeOffset, ptrdiff_t copySize)
Schedule the range to be copied.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:182