Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 330 vs 331 for /trunk/Source Code/Hardware/Video/OpenGL/Buffers/VertexBuffer/glGenericVertexData.cpp

Diff revisions: vs.
  @@ -32,7 +32,7 @@
32 32 }
33 33 // Persistently mapped buffers require explicit synchronization
34 34 if (persistentMapped) {
35 - _lockManager = New glBufferLockManager(true);
35 + _lockManager = MemoryManager_NEW glBufferLockManager(true);
36 36 }
37 37 }
38 38
  @@ -76,21 +76,21 @@
76 76 if (_numQueries > 0) {
77 77 for (U8 i = 0; i < 2; ++i) {
78 78 glDeleteQueries(_numQueries, _feedbackQueries[i]);
79 - MemoryManager::SAFE_DELETE_ARRAY( _feedbackQueries[i] );
80 - MemoryManager::SAFE_DELETE_ARRAY( _resultAvailable[i] );
79 + MemoryManager::DELETE_ARRAY( _feedbackQueries[i] );
80 + MemoryManager::DELETE_ARRAY( _resultAvailable[i] );
81 81 }
82 82 }
83 83
84 84 // Delete the rest of the data
85 - MemoryManager::SAFE_DELETE_ARRAY( _prevResult );
86 - MemoryManager::SAFE_DELETE_ARRAY( _bufferSet );
87 - MemoryManager::SAFE_DELETE_ARRAY( _bufferPersistent );
88 - MemoryManager::SAFE_DELETE_ARRAY( _elementCount );
89 - MemoryManager::SAFE_DELETE_ARRAY( _elementSize );
90 - MemoryManager::SAFE_DELETE_ARRAY( _sizeFactor );
91 - MemoryManager::SAFE_DELETE_ARRAY( _startDestOffset );
92 - MemoryManager::SAFE_DELETE_ARRAY( _readOffset );
93 - MemoryManager::SAFE_DELETE( _lockManager );
85 + MemoryManager::DELETE_ARRAY( _prevResult );
86 + MemoryManager::DELETE_ARRAY( _bufferSet );
87 + MemoryManager::DELETE_ARRAY( _bufferPersistent );
88 + MemoryManager::DELETE_ARRAY( _elementCount );
89 + MemoryManager::DELETE_ARRAY( _elementSize );
90 + MemoryManager::DELETE_ARRAY( _sizeFactor );
91 + MemoryManager::DELETE_ARRAY( _startDestOffset );
92 + MemoryManager::DELETE_ARRAY( _readOffset );
93 + MemoryManager::DELETE( _lockManager );
94 94 if (_bufferPersistentData != nullptr) {
95 95 free(_bufferPersistentData);
96 96 }
  @@ -114,8 +114,8 @@
114 114 // Prepare our generic queries
115 115 _numQueries = numQueries;
116 116 for (U8 i = 0; i < 2; ++i) {
117 - _feedbackQueries[i] = New GLuint[_numQueries];
118 - _resultAvailable[i] = New bool[_numQueries];
117 + _feedbackQueries[i] = MemoryManager_NEW GLuint[_numQueries];
118 + _resultAvailable[i] = MemoryManager_NEW bool[_numQueries];
119 119 }
120 120 // Create our generic query objects
121 121 for (U8 i = 0; i < 2; ++i) {
  @@ -124,29 +124,29 @@
124 124 glGenQueries(_numQueries, _feedbackQueries[i]);
125 125 }
126 126 // How many times larger should the buffer be than the actual data to offset reading and writing
127 - _sizeFactor = New GLuint[numBuffers];
127 + _sizeFactor = MemoryManager_NEW GLuint[numBuffers];
128 128 memset(_sizeFactor, 0, numBuffers * sizeof(GLuint));
129 129 // Allocate buffers for all possible data that we may use with this object
130 130 // Query results from the previous frame
131 - _prevResult = New GLuint[_numQueries];
131 + _prevResult = MemoryManager_NEW GLuint[_numQueries];
132 132 memset(_prevResult, 0, sizeof(GLuint) * _numQueries);
133 133 // Flags to verify if each buffer was created
134 - _bufferSet = New bool[numBuffers];
134 + _bufferSet = MemoryManager_NEW bool[numBuffers];
135 135 memset(_bufferSet, false, numBuffers * sizeof(bool));
136 136 // The element count for each buffer
137 - _elementCount = New GLuint[numBuffers];
137 + _elementCount = MemoryManager_NEW GLuint[numBuffers];
138 138 memset(_elementCount, 0, numBuffers * sizeof(GLuint));
139 139 // The element size for each buffer (in bytes)
140 - _elementSize = New size_t[numBuffers];
140 + _elementSize = MemoryManager_NEW size_t[numBuffers];
141 141 memset(_elementSize, 0, numBuffers * sizeof(size_t));
142 142 // Current buffer write head position for 3x buffer updates
143 - _startDestOffset = New size_t[numBuffers];
143 + _startDestOffset = MemoryManager_NEW size_t[numBuffers];
144 144 memset(_startDestOffset, 0, numBuffers * sizeof(size_t));
145 145 // Current buffer read head position for 3x buffer updates
146 - _readOffset = New size_t[numBuffers];
146 + _readOffset = MemoryManager_NEW size_t[numBuffers];
147 147 memset(_readOffset, 0, numBuffers * sizeof(size_t));
148 148 // A flag to check if the buffer is or isn't persistently mapped
149 - _bufferPersistent = New bool[numBuffers];
149 + _bufferPersistent = MemoryManager_NEW bool[numBuffers];
150 150 memset(_bufferPersistent, false, numBuffers * sizeof(bool));
151 151 // Persistently mapped data (array of void* pointers)
152 152 _bufferPersistentData = (void**)malloc(sizeof(void*) * numBuffers);
  @@ -163,13 +163,18 @@
163 163 return GenericVertexData::frameStarted(evt);
164 164 }
165 165
166 - /// Bind a specific range of the transform feedback buffer for writing (specified in the number of elements to offset by and the number of elements to be written)
166 + /// Bind a specific range of the transform feedback buffer for writing
167 + /// (specified in the number of elements to offset by and the number of elements to be written)
167 168 void glGenericVertexData::BindFeedbackBufferRange(U32 buffer, U32 elementCountOffset, size_t elementCount) {
168 169 // Only feedback buffers can be used with this method
169 170 DIVIDE_ASSERT(isFeedbackBuffer(buffer), "glGenericVertexData error: called bind buffer range for non-feedback buffer!");
170 171
171 172 GL_API::setActiveTransformFeedback(_transformFeedback);
172 - glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, getBindPoint(_bufferObjects[buffer]), _bufferObjects[buffer], elementCountOffset * _elementSize[buffer], elementCount * _elementSize[buffer]);
173 + glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER,
174 + getBindPoint(_bufferObjects[buffer]),
175 + _bufferObjects[buffer],
176 + elementCountOffset * _elementSize[buffer],
177 + elementCount * _elementSize[buffer]);
173 178 }
174 179
175 180 /// Submit a draw command to the GPU using this object and the specified command
  @@ -197,7 +202,9 @@
197 202
198 203 // Submit the draw command
199 204 if (!Config::Profile::DISABLE_DRAWS) {
200 - GLenum type = command.renderWireframe() ? GL_LINE_LOOP : GLUtil::GL_ENUM_TABLE::glPrimitiveTypeTable[command.primitiveType()];
205 + GLenum type = command.renderWireframe() ? GL_LINE_LOOP :
206 + GLUtil::GL_ENUM_TABLE::glPrimitiveTypeTable[command.primitiveType()];
207 +
201 208 glDrawArraysIndirect(type, (void*)(cmd.baseInstance * sizeof(IndirectDrawCommand)));
202 209 }
203 210
  @@ -213,16 +220,26 @@
213 220 }
214 221
215 222 /// Specify the structure and data of the given buffer
216 - void glGenericVertexData::SetBuffer(U32 buffer, U32 elementCount, size_t elementSize, U8 sizeFactor, void* data, bool dynamic, bool stream, bool persistentMapped) {
223 + void glGenericVertexData::SetBuffer(U32 buffer,
224 + U32 elementCount,
225 + size_t elementSize,
226 + U8 sizeFactor,
227 + void* data,
228 + bool dynamic,
229 + bool stream,
230 + bool persistentMapped) {
217 231 // Make sure the buffer exists
218 - DIVIDE_ASSERT(buffer >= 0 && buffer < _bufferObjects.size(), "glGenericVertexData error: set buffer called for invalid buffer index!");
232 + DIVIDE_ASSERT(buffer >= 0 && buffer < _bufferObjects.size(),
233 + "glGenericVertexData error: set buffer called for invalid buffer index!");
219 234 // glBufferData on persistentMapped buffers is not allowed
220 - DIVIDE_ASSERT(!_bufferSet[buffer], "glGenericVertexData error: set buffer called for an already created buffer!");
235 + DIVIDE_ASSERT(!_bufferSet[buffer],
236 + "glGenericVertexData error: set buffer called for an already created buffer!");
221 237 // Make sure we allow persistent mapping
222 238 if (persistentMapped) {
223 239 persistentMapped = _persistentMapped;
224 240 }
225 - DIVIDE_ASSERT((persistentMapped && _persistentMapped) || !persistentMapped, "glGenericVertexData error: persistent map flag is not compatible with object details!");
241 + DIVIDE_ASSERT((persistentMapped && _persistentMapped) || !persistentMapped,
242 + "glGenericVertexData error: persistent map flag is not compatible with object details!");
226 243 // Remember the element count and size for the current buffer
227 244 _elementCount[buffer] = elementCount;
228 245 _elementSize[buffer] = elementSize;
  @@ -236,7 +253,8 @@
236 253 glNamedBufferStorageEXT(currentBuffer, bufferSize * sizeFactor, NULL, flag);
237 254 // Map the entire buffer range
238 255 _bufferPersistentData[buffer] = glMapNamedBufferRangeEXT(currentBuffer, 0, bufferSize * 3, flag);
239 - DIVIDE_ASSERT(data != nullptr, "glGenericVertexData error: persistent mapping failed when setting the current buffer!");
256 + DIVIDE_ASSERT(data != nullptr,
257 + "glGenericVertexData error: persistent mapping failed when setting the current buffer!");
240 258 // Create sizeFactor copies of the data and store them in the buffer
241 259 for(U8 i = 0; i < sizeFactor; ++i) {
242 260 U8* dst = (U8*)_bufferPersistentData[buffer] + bufferSize * i;
  @@ -302,7 +320,8 @@
302 320
303 321 /// Update internal attribute data
304 322 void glGenericVertexData::SetAttributeInternal(AttributeDescriptor& descriptor) {
305 - DIVIDE_ASSERT(_elementSize[descriptor.bufferIndex()] != 0, "glGenericVertexData error: attribute's parent buffer has an invalid element size!");
323 + DIVIDE_ASSERT(_elementSize[descriptor.bufferIndex()] != 0,
324 + "glGenericVertexData error: attribute's parent buffer has an invalid element size!");
306 325 // Early out if the attribute didn't change
307 326 if (!descriptor.dirty()) {
308 327 return;
  @@ -333,7 +352,8 @@
333 352
334 353 /// Return the number of primitives written to a transform feedback buffer that used the specified query ID
335 354 U32 glGenericVertexData::GetFeedbackPrimitiveCount(U8 queryID) {
336 - DIVIDE_ASSERT(queryID < _numQueries && !_bufferObjects.empty(), "glGenericVertexData error: Current object isn't ready for query processing!");
355 + DIVIDE_ASSERT(queryID < _numQueries && !_bufferObjects.empty(),
356 + "glGenericVertexData error: Current object isn't ready for query processing!");
337 357 // Double buffered queries return the results from the previous draw call to avoid stalling the GPU pipeline
338 358 U32 queryEntry = _doubleBufferedQuery ? _currentReadQuery : _currentWriteQuery;
339 359 // If the requested query has valid data available, retrieve that data from the GPU