@@ -343,6 +343,7 @@ class GLUniform {
343343 // In multiples of 4 bytes
344344 const GLuint _std430Size;
345345 const GLuint _std430Alignment;
346+ const GLuint _bufferSize;
346347 GLuint _nextUniformOffset;
347348
348349 const UpdateType _updateType;
@@ -361,6 +362,7 @@ class GLUniform {
361362 _type ( type ),
362363 _std430Size ( std430Size ),
363364 _std430Alignment ( std430Alignment ),
365+ _bufferSize ( components ? components * 4 : std430Size ),
364366 _nextUniformOffset ( components ? components * 4 : std430Size ),
365367 _updateType ( updateType ),
366368 _components ( components ),
@@ -384,11 +386,10 @@ class GLUniform {
384386 currentValue = p->uniformStorage + _uniformStorageOffset;
385387 }
386388
387- const uint32_t size = _components ? _std430Size * _components : _std430Size;
388- const bool updated = memcmp ( currentValue, value, size * sizeof ( uint32_t ) );
389+ const bool updated = memcmp ( currentValue, value, _bufferSize * sizeof ( uint32_t ) );
389390
390391 if ( updated ) {
391- memcpy ( currentValue, value, size * sizeof ( uint32_t ) );
392+ memcpy ( currentValue, value, _bufferSize * sizeof ( uint32_t ) );
392393 _shader->uniformsUpdated = true ;
393394 }
394395
@@ -419,8 +420,7 @@ class GLUniform {
419420 return buffer;
420421 }
421422
422- const uint32_t size = _components ? _std430Size * _components : _std430Size;
423- memcpy ( buffer, currentValue, size * sizeof ( uint32_t ) );
423+ memcpy ( buffer, currentValue, _bufferSize * sizeof ( uint32_t ) );
424424
425425 return buffer + _nextUniformOffset;
426426 }
0 commit comments