@@ -344,6 +344,7 @@ class GLUniform {
344344	//  In multiples of 4 bytes
345345	const  GLuint _std430Size;
346346	const  GLuint _std430Alignment;
347+ 	const  GLuint _bufferSize;
347348	GLuint _nextUniformOffset;
348349
349350	const  UpdateType _updateType;
@@ -362,6 +363,7 @@ class GLUniform {
362363		_type ( type ),
363364		_std430Size ( std430Size ),
364365		_std430Alignment ( std430Alignment ),
366+ 		_bufferSize ( components ? components * 4  : std430Size ),
365367		_nextUniformOffset ( components ? components * 4  : std430Size ),
366368		_updateType ( updateType ),
367369		_components ( components ),
@@ -385,11 +387,10 @@ class GLUniform {
385387			currentValue = p->uniformStorage  + _uniformStorageOffset;
386388		}
387389
388- 		const  uint32_t  size = _components ? _std430Size * _components : _std430Size;
389- 		const  bool  updated = memcmp ( currentValue, value, size * sizeof ( uint32_t  ) );
390+ 		const  bool  updated = memcmp ( currentValue, value, _bufferSize * sizeof ( uint32_t  ) );
390391
391392		if  ( updated ) {
392- 			memcpy ( currentValue, value, size  * sizeof ( uint32_t  ) );
393+ 			memcpy ( currentValue, value, _bufferSize  * sizeof ( uint32_t  ) );
393394			_shader->uniformsUpdated  = true ;
394395		}
395396
@@ -420,8 +421,7 @@ class GLUniform {
420421			return  buffer;
421422		}
422423
423- 		const  uint32_t  size = _components ? _std430Size * _components : _std430Size;
424- 		memcpy ( buffer, currentValue, size * sizeof ( uint32_t  ) );
424+ 		memcpy ( buffer, currentValue, _bufferSize * sizeof ( uint32_t  ) );
425425
426426		return  buffer + _nextUniformOffset;
427427	}
0 commit comments