@@ -344,6 +344,7 @@ class GLUniform {
344344 // FIXME: the uniform structs are actually std140 so it would be more relevant to provide std140 info
345345 const GLuint _std430BaseSize;
346346 const GLuint _std430Alignment;
347+ const GLuint _bufferSize;
347348 GLuint _nextUniformOffset;
348349
349350 const UpdateType _updateType;
@@ -364,6 +365,7 @@ class GLUniform {
364365 _std430BaseSize ( std430Size ),
365366 _std430Size ( std430Size ),
366367 _std430Alignment ( std430Alignment ),
368+ _bufferSize ( components ? components * 4 : std430Size ),
367369 _nextUniformOffset ( components ? components * 4 : std430Size ),
368370 _updateType ( updateType ),
369371 _components ( components ),
@@ -388,11 +390,10 @@ class GLUniform {
388390 currentValue = p->uniformStorage + _uniformStorageOffset;
389391 }
390392
391- const uint32_t size = _components ? _std430Size * _components : _std430Size;
392- const bool updated = memcmp ( currentValue, value, size * sizeof ( uint32_t ) );
393+ const bool updated = memcmp ( currentValue, value, _bufferSize * sizeof ( uint32_t ) );
393394
394395 if ( updated ) {
395- memcpy ( currentValue, value, size * sizeof ( uint32_t ) );
396+ memcpy ( currentValue, value, _bufferSize * sizeof ( uint32_t ) );
396397 _shader->uniformsUpdated = true ;
397398 }
398399
@@ -423,8 +424,7 @@ class GLUniform {
423424 return buffer;
424425 }
425426
426- const uint32_t size = _components ? _std430Size * _components : _std430Size;
427- memcpy ( buffer, currentValue, size * sizeof ( uint32_t ) );
427+ memcpy ( buffer, currentValue, _bufferSize * sizeof ( uint32_t ) );
428428
429429 return buffer + _nextUniformOffset;
430430 }
0 commit comments