VR-Forces 4.10 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtGlBuffer.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2020 VT-MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 #pragma once
10 
11 #include <string>
12 
17 
18 #include <iostream>
19 
20 namespace makVrv
21 {
28  {
29  public:
36  DtGlBuffer(const char * name, DtBufferType type, DtUsage usage, DtCpuAccess accessType, bool hasStagingBuffer);
37 
39  virtual ~DtGlBuffer();
40 
41  private:
43  DtGlBuffer(const DtGlBuffer &other) = delete;
45  DtGlBuffer &operator=(const DtGlBuffer &other) = delete;
46 
47  public:
48 
50  virtual void tearDown(void);
51 
53  virtual unsigned int releaseHandle(void);
54 
58  virtual bool updateBuffer(const int sizeToTransferInBytes, const void* data);
59 
64  virtual bool updateBuffer(const int offsetInBytes, const int sizeToTransferInBytes, const void* data);
65 
69  virtual void clearBuffer(unsigned int clearValue);
70 
72  virtual void bind() const;
76  virtual void unbind() const;
78 
79 
81  virtual unsigned char* stagingBuffer(void) const;
87 
90  virtual unsigned char* stagingBufferWithSize(unsigned int requestedSizeInBytes);
91 
94  virtual void syncStagingBufferToGpu(unsigned int offset, unsigned int sizeInBytes);
95 
98  virtual void syncStagingBufferToGpu();
100 
105  virtual bool bufferSubData(unsigned int offset, unsigned int sizeInBytes, const void *data);
106 
107 
109  virtual void resetStagingBuffer();
110 
112  virtual int sizeInBytes(void) const;
113 
115  virtual const unsigned int handle(void) const;
116 
118  virtual void setResizeMultiplier(float rmul);
119 
124  virtual void setUseIncrementalUpdate(bool incrementalUpdate);
125 
127  virtual bool useIncrementalUpdate();
128 
130  virtual float resizeMultiplier();
131 
133  unsigned int type(void) const;
134 
137  virtual uint64_t gpuResidentAddress();
138 
142  virtual const void* mapForReading(void) const;
143 
147  virtual void unMap(void) const;
148 
153  template <class T>
154  void printContents(std::ostream& outputStream, const std::string& strNumPrefix, const std::string& strValPrefix) const
155  {
156  if (myHandle == 0)
157  {
158  return;
159  }
160  const T* pRepType = (const T*)(mapForReading());
161  if (pRepType)
162  {
163  const size_t numOfRepTypes = sizeInBytes() / sizeof(T);
164  outputStream << strNumPrefix << numOfRepTypes << std::endl;
165  for (int i = 0; i < numOfRepTypes; ++i)
166  {
167  outputStream << strValPrefix <<"[" << i << "]: "<< pRepType[i] << std::endl;
168  }
169  }
170  unMap();
171  }
172 
173  protected:
174 
177  virtual bool createAndBindBuffer();
178 
181  virtual int calculateNewSize(int requestedNewSizeInBytes);
182 
183  protected:
184 
185  std::string myName;
186  unsigned int myHandle;
187  unsigned int myType;
190  unsigned char* myStagingBuffer;
194 
199 
200  mutable bool myMutableIsMapped;
201  };
202 
203 }
int myLastBufferTransferOffset
Definition: DtGlBuffer.h:196
Dll export defines.
DtUsage myUsage
Definition: DtGlBuffer.h:192
DtBufferType
An abstract buffer type (vertex buffer, index buffer, etc) Used, for example, to create DtGlBuffers o...
Definition: DtBufferType.h:15
int mySizeInBytes
Definition: DtGlBuffer.h:188
bool myMutableIsMapped
Definition: DtGlBuffer.h:200
DtCpuAccess myAccessType
Definition: DtGlBuffer.h:193
std::string myName
Definition: DtGlBuffer.h:185
Buffer Usage enums.
DtUsage
Definition: DtUsage.h:13
Enumerations for cpu access required by textures/buffers.
unsigned int myHandle
Definition: DtGlBuffer.h:186
unsigned int myType
Definition: DtGlBuffer.h:187
binderNoArgs< _Fn > bind(const _Fn &_Func, const _Ty &_Left)
Definition: DtSTLUtilities.h:76
bool myUseIncrementalUpdate
Definition: DtGlBuffer.h:195
unsigned char * myStagingBuffer
Definition: DtGlBuffer.h:190
bool myIsResident
Definition: DtGlBuffer.h:198
bool myHasStagingBuffer
Definition: DtGlBuffer.h:191
A generic OpenGL buffer.
Definition: DtGlBuffer.h:27
Buffer Type enums.
uint64_t myResidentAddress
Definition: DtGlBuffer.h:197
#define DT_DLL_VRVGRAPHICSUTILS
Definition: vrvGraphicsUtils.h:18
voidpf uLong offset
Definition: ioapi.h:42
DtCpuAccess
Definition: DtCpuAccess.h:13
void printContents(std::ostream &outputStream, const std::string &strNumPrefix, const std::string &strValPrefix) const
Template function to print the contents of the buffer.
Definition: DtGlBuffer.h:154
float myResizeMultiplier
Definition: DtGlBuffer.h:189

Document ID: Generated on Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)