History

Moving all the variables for the Input stage cache into a struct just like for transformStage

Sam Gateau committed 12 years ago

Commit 5c9c78e1 parent 420118e2 files · +63 −54Browse files

Showing the changes to interface/src/gpu/GLBackend.cpp (1 of 2 files). Show all

Unified · Split

interface/src/gpu/GLBackend.cpp+30−38
@@ -113,15 +113,7 @@ static const GLenum _elementTypeToGLType[NUM_TYPES]= { · 112 unmodified lines
113113
114114
115115 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(),
125117 _transform()
126118 {
127119
@@ -203,9 +195,9 @@ void GLBackend::do_drawIndexed(Batch& batch, uint32 paramOffset) { · 75 unmodified lines
203195 uint32 numIndices = batch._params[paramOffset + 1]._uint;
204196 uint32 startIndex = batch._params[paramOffset + 0]._uint;
205197
206− GLenum glType = _elementTypeToGLType[_indexBufferType];
198+ GLenum glType = _elementTypeToGLType[_input._indexBufferType];
207199
208− glDrawElements(mode, numIndices, glType, reinterpret_cast<GLvoid*>(startIndex + _indexBufferOffset));
200+ glDrawElements(mode, numIndices, glType, reinterpret_cast<GLvoid*>(startIndex + _input._indexBufferOffset));
209201 CHECK_GL_ERROR();
210202 }
211203
@@ -220,9 +212,9 @@ void GLBackend::do_drawIndexedInstanced(Batch& batch, uint32 paramOffset) { · 8 unmodified lines
220212 void GLBackend::do_setInputFormat(Batch& batch, uint32 paramOffset) {
221213 Stream::FormatPointer format = batch._streamFormats.get(batch._params[paramOffset]._uint);
222214
223− if (format != _inputFormat) {
224− _inputFormat = format;
225− _needInputFormatUpdate = true;
215+ if (format != _input._format) {
216+ _input._format = format;
217+ _input._invalidFormat = true;
226218 }
227219 }
228220
@@ -233,10 +225,10 @@ void GLBackend::do_setInputBuffer(Batch& batch, uint32 paramOffset) { · 4 unmodified lines
233225 uint32 channel = batch._params[paramOffset + 3]._uint;
234226
235227 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);
240232 }
241233 }
242234
@@ -252,14 +244,14 @@ static const GLenum attributeSlotToClassicAttribName[NUM_CLASSIC_ATTRIBS] = { · 9 unmodified lines
252244 #endif
253245
254246 void GLBackend::updateInput() {
255− if (_needInputFormatUpdate || _inputBuffersState.any()) {
247+ if (_input._invalidFormat || _input._buffersState.any()) {
256248
257− if (_needInputFormatUpdate) {
258− InputActivationCache newActivation;
249+ if (_input._invalidFormat) {
250+ InputStageState::ActivationCache newActivation;
259251
260252 // 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();
263255 for (Stream::Format::AttributeMap::const_iterator it = attributes.begin(); it != attributes.end(); it++) {
264256 const Stream::Attribute& attrib = (*it).second;
265257 newActivation.set(attrib._slot);
@@ -269,7 +261,7 @@ void GLBackend::updateInput() { · 3 unmodified lines
269261 // Manage Activation what was and what is expected now
270262 for (unsigned int i = 0; i < newActivation.size(); i++) {
271263 bool newState = newActivation[i];
272− if (newState != _inputAttributeActivation[i]) {
264+ if (newState != _input._attributeActivation[i]) {
273265 #if defined(SUPPORT_LEGACY_OPENGL)
274266 if (i < NUM_CLASSIC_ATTRIBS) {
275267 if (newState) {
@@ -290,31 +282,31 @@ void GLBackend::updateInput() { · 14 unmodified lines
290282 }
291283 CHECK_GL_ERROR();
292284
293− _inputAttributeActivation.flip(i);
285+ _input._attributeActivation.flip(i);
294286 }
295287 }
296288 }
297289
298290 // 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;
303295
304− const Stream::Format::AttributeMap& attributes = _inputFormat->getAttributes();
296+ const Stream::Format::AttributeMap& attributes = _input._format->getAttributes();
305297
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();
308300 channelIt++) {
309301 const Stream::Format::ChannelMap::value_type::second_type& channel = (*channelIt).second;
310302 if ((*channelIt).first < buffers.size()) {
311303 int bufferNum = (*channelIt).first;
312304
313− if (_inputBuffersState.test(bufferNum) || _needInputFormatUpdate) {
305+ if (_input._buffersState.test(bufferNum) || _input._invalidFormat) {
314306 GLuint vbo = gpu::GLBackend::getBufferID((*buffers[bufferNum]));
315307 glBindBuffer(GL_ARRAY_BUFFER, vbo);
316308 CHECK_GL_ERROR();
317− _inputBuffersState[bufferNum] = false;
309+ _input._buffersState[bufferNum] = false;
318310
319311 for (unsigned int i = 0; i < channel._slots.size(); i++) {
320312 const Stream::Attribute& attrib = attributes.at(channel._slots[i]);
@@ -354,7 +346,7 @@ void GLBackend::updateInput() { · 33 unmodified lines
354346 }
355347 }
356348 // everything format related should be in sync now
357− _needInputFormatUpdate = false;
349+ _input._invalidFormat = false;
358350 }
359351
360352 /* TODO: Fancy version GL4.4
@@ -415,10 +407,10 @@ void GLBackend::updateInput() { · 54 unmodified lines
415407
416408
417409 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;
419411 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;
422414 if (indexBuffer) {
423415 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, getBufferID(*indexBuffer));
424416 } else {