Showing the changes to interface/src/gpu/GLBackend.cpp (1 of 2 files). Show all
Unified · Split
| @@ -113,15 +113,7 @@ static const GLenum _elementTypeToGLType[NUM_TYPES]= { · 112 unmodified lines | ||
| 113 | 113 | |
| 114 | 114 | |
| 115 | 115 | GLBackend::GLBackend() : |
| 116 | − _needInputFormatUpdate(true), | |
| 117 | − _inputFormat(0), | |
| 118 | − _inputBuffersState(0), | |
| 119 | − _inputBuffers(_inputBuffersState.size(), BufferPointer(0)), | |
| 120 | − _inputBufferOffsets(_inputBuffersState.size(), 0), | |
| 121 | − _inputBufferStrides(_inputBuffersState.size(), 0), | |
| 122 | − _indexBuffer(0), | |
| 123 | − _indexBufferOffset(0), | |
| 124 | − _inputAttributeActivation(0), | |
| 116 | + _input(), | |
| 125 | 117 | _transform() |
| 126 | 118 | { |
| 127 | 119 | |
| @@ -203,9 +195,9 @@ void GLBackend::do_drawIndexed(Batch& batch, uint32 paramOffset) { · 75 unmodified lines | ||
| 203 | 195 | uint32 numIndices = batch._params[paramOffset + 1]._uint; |
| 204 | 196 | uint32 startIndex = batch._params[paramOffset + 0]._uint; |
| 205 | 197 | |
| 206 | − GLenum glType = _elementTypeToGLType[_indexBufferType]; | |
| 198 | + GLenum glType = _elementTypeToGLType[_input._indexBufferType]; | |
| 207 | 199 | |
| 208 | − glDrawElements(mode, numIndices, glType, reinterpret_cast<GLvoid*>(startIndex + _indexBufferOffset)); | |
| 200 | + glDrawElements(mode, numIndices, glType, reinterpret_cast<GLvoid*>(startIndex + _input._indexBufferOffset)); | |
| 209 | 201 | CHECK_GL_ERROR(); |
| 210 | 202 | } |
| 211 | 203 | |
| @@ -220,9 +212,9 @@ void GLBackend::do_drawIndexedInstanced(Batch& batch, uint32 paramOffset) { · 8 unmodified lines | ||
| 220 | 212 | void GLBackend::do_setInputFormat(Batch& batch, uint32 paramOffset) { |
| 221 | 213 | Stream::FormatPointer format = batch._streamFormats.get(batch._params[paramOffset]._uint); |
| 222 | 214 | |
| 223 | − if (format != _inputFormat) { | |
| 224 | − _inputFormat = format; | |
| 225 | − _needInputFormatUpdate = true; | |
| 215 | + if (format != _input._format) { | |
| 216 | + _input._format = format; | |
| 217 | + _input._invalidFormat = true; | |
| 226 | 218 | } |
| 227 | 219 | } |
| 228 | 220 | |
| @@ -233,10 +225,10 @@ void GLBackend::do_setInputBuffer(Batch& batch, uint32 paramOffset) { · 4 unmodified lines | ||
| 233 | 225 | uint32 channel = batch._params[paramOffset + 3]._uint; |
| 234 | 226 | |
| 235 | 227 | if (channel < getNumInputBuffers()) { |
| 236 | − _inputBuffers[channel] = buffer; | |
| 237 | − _inputBufferOffsets[channel] = offset; | |
| 238 | − _inputBufferStrides[channel] = stride; | |
| 239 | − _inputBuffersState.set(channel); | |
| 228 | + _input._buffers[channel] = buffer; | |
| 229 | + _input._bufferOffsets[channel] = offset; | |
| 230 | + _input._bufferStrides[channel] = stride; | |
| 231 | + _input._buffersState.set(channel); | |
| 240 | 232 | } |
| 241 | 233 | } |
| 242 | 234 | |
| @@ -252,14 +244,14 @@ static const GLenum attributeSlotToClassicAttribName[NUM_CLASSIC_ATTRIBS] = { · 9 unmodified lines | ||
| 252 | 244 | #endif |
| 253 | 245 | |
| 254 | 246 | void GLBackend::updateInput() { |
| 255 | − if (_needInputFormatUpdate || _inputBuffersState.any()) { | |
| 247 | + if (_input._invalidFormat || _input._buffersState.any()) { | |
| 256 | 248 | |
| 257 | − if (_needInputFormatUpdate) { | |
| 258 | − InputActivationCache newActivation; | |
| 249 | + if (_input._invalidFormat) { | |
| 250 | + InputStageState::ActivationCache newActivation; | |
| 259 | 251 | |
| 260 | 252 | // Check expected activation |
| 261 | − if (_inputFormat) { | |
| 262 | − const Stream::Format::AttributeMap& attributes = _inputFormat->getAttributes(); | |
| 253 | + if (_input._format) { | |
| 254 | + const Stream::Format::AttributeMap& attributes = _input._format->getAttributes(); | |
| 263 | 255 | for (Stream::Format::AttributeMap::const_iterator it = attributes.begin(); it != attributes.end(); it++) { |
| 264 | 256 | const Stream::Attribute& attrib = (*it).second; |
| 265 | 257 | newActivation.set(attrib._slot); |
| @@ -269,7 +261,7 @@ void GLBackend::updateInput() { · 3 unmodified lines | ||
| 269 | 261 | // Manage Activation what was and what is expected now |
| 270 | 262 | for (unsigned int i = 0; i < newActivation.size(); i++) { |
| 271 | 263 | bool newState = newActivation[i]; |
| 272 | − if (newState != _inputAttributeActivation[i]) { | |
| 264 | + if (newState != _input._attributeActivation[i]) { | |
| 273 | 265 | #if defined(SUPPORT_LEGACY_OPENGL) |
| 274 | 266 | if (i < NUM_CLASSIC_ATTRIBS) { |
| 275 | 267 | if (newState) { |
| @@ -290,31 +282,31 @@ void GLBackend::updateInput() { · 14 unmodified lines | ||
| 290 | 282 | } |
| 291 | 283 | CHECK_GL_ERROR(); |
| 292 | 284 | |
| 293 | − _inputAttributeActivation.flip(i); | |
| 285 | + _input._attributeActivation.flip(i); | |
| 294 | 286 | } |
| 295 | 287 | } |
| 296 | 288 | } |
| 297 | 289 | |
| 298 | 290 | // now we need to bind the buffers and assign the attrib pointers |
| 299 | − if (_inputFormat) { | |
| 300 | − const Buffers& buffers = _inputBuffers; | |
| 301 | − const Offsets& offsets = _inputBufferOffsets; | |
| 302 | − const Offsets& strides = _inputBufferStrides; | |
| 291 | + if (_input._format) { | |
| 292 | + const Buffers& buffers = _input._buffers; | |
| 293 | + const Offsets& offsets = _input._bufferOffsets; | |
| 294 | + const Offsets& strides = _input._bufferStrides; | |
| 303 | 295 | |
| 304 | − const Stream::Format::AttributeMap& attributes = _inputFormat->getAttributes(); | |
| 296 | + const Stream::Format::AttributeMap& attributes = _input._format->getAttributes(); | |
| 305 | 297 | |
| 306 | − for (Stream::Format::ChannelMap::const_iterator channelIt = _inputFormat->getChannels().begin(); | |
| 307 | − channelIt != _inputFormat->getChannels().end(); | |
| 298 | + for (Stream::Format::ChannelMap::const_iterator channelIt = _input._format->getChannels().begin(); | |
| 299 | + channelIt != _input._format->getChannels().end(); | |
| 308 | 300 | channelIt++) { |
| 309 | 301 | const Stream::Format::ChannelMap::value_type::second_type& channel = (*channelIt).second; |
| 310 | 302 | if ((*channelIt).first < buffers.size()) { |
| 311 | 303 | int bufferNum = (*channelIt).first; |
| 312 | 304 | |
| 313 | − if (_inputBuffersState.test(bufferNum) || _needInputFormatUpdate) { | |
| 305 | + if (_input._buffersState.test(bufferNum) || _input._invalidFormat) { | |
| 314 | 306 | GLuint vbo = gpu::GLBackend::getBufferID((*buffers[bufferNum])); |
| 315 | 307 | glBindBuffer(GL_ARRAY_BUFFER, vbo); |
| 316 | 308 | CHECK_GL_ERROR(); |
| 317 | − _inputBuffersState[bufferNum] = false; | |
| 309 | + _input._buffersState[bufferNum] = false; | |
| 318 | 310 | |
| 319 | 311 | for (unsigned int i = 0; i < channel._slots.size(); i++) { |
| 320 | 312 | const Stream::Attribute& attrib = attributes.at(channel._slots[i]); |
| @@ -354,7 +346,7 @@ void GLBackend::updateInput() { · 33 unmodified lines | ||
| 354 | 346 | } |
| 355 | 347 | } |
| 356 | 348 | // everything format related should be in sync now |
| 357 | − _needInputFormatUpdate = false; | |
| 349 | + _input._invalidFormat = false; | |
| 358 | 350 | } |
| 359 | 351 | |
| 360 | 352 | /* TODO: Fancy version GL4.4 |
| @@ -415,10 +407,10 @@ void GLBackend::updateInput() { · 54 unmodified lines | ||
| 415 | 407 | |
| 416 | 408 | |
| 417 | 409 | void GLBackend::do_setIndexBuffer(Batch& batch, uint32 paramOffset) { |
| 418 | − _indexBufferType = (Type) batch._params[paramOffset + 2]._uint; | |
| 410 | + _input._indexBufferType = (Type) batch._params[paramOffset + 2]._uint; | |
| 419 | 411 | BufferPointer indexBuffer = batch._buffers.get(batch._params[paramOffset + 1]._uint); |
| 420 | − _indexBufferOffset = batch._params[paramOffset + 0]._uint; | |
| 421 | − _indexBuffer = indexBuffer; | |
| 412 | + _input._indexBufferOffset = batch._params[paramOffset + 0]._uint; | |
| 413 | + _input._indexBuffer = indexBuffer; | |
| 422 | 414 | if (indexBuffer) { |
| 423 | 415 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, getBufferID(*indexBuffer)); |
| 424 | 416 | } else { |