@@ -347,6 +347,7 @@ class GLUniform {
347347 const GLuint _std430BaseSize;
348348 GLuint _std430Size; // includes padding that depends on the other uniforms in the struct
349349 const GLuint _std430Alignment;
350+ const GLuint _bufferSize;
350351 GLuint _nextUniformOffset;
351352
352353 const UpdateType _updateType;
@@ -366,6 +367,7 @@ class GLUniform {
366367 _std430BaseSize ( std430Size ),
367368 _std430Size ( std430Size ),
368369 _std430Alignment ( std430Alignment ),
370+ _bufferSize ( components ? components * 4 : std430Size ),
369371 _nextUniformOffset ( components ? components * 4 : std430Size ),
370372 _updateType ( updateType ),
371373 _components ( components ),
@@ -389,11 +391,10 @@ class GLUniform {
389391 currentValue = p->uniformStorage + _uniformStorageOffset;
390392 }
391393
392- const uint32_t size = _components ? _std430Size * _components : _std430Size;
393- const bool updated = memcmp ( currentValue, value, size * sizeof ( uint32_t ) );
394+ const bool updated = memcmp ( currentValue, value, _bufferSize * sizeof ( uint32_t ) );
394395
395396 if ( updated ) {
396- memcpy ( currentValue, value, size * sizeof ( uint32_t ) );
397+ memcpy ( currentValue, value, _bufferSize * sizeof ( uint32_t ) );
397398 _shader->uniformsUpdated = true ;
398399 }
399400
@@ -424,8 +425,7 @@ class GLUniform {
424425 return buffer;
425426 }
426427
427- const uint32_t size = _components ? _std430Size * _components : _std430Size;
428- memcpy ( buffer, currentValue, size * sizeof ( uint32_t ) );
428+ memcpy ( buffer, currentValue, _bufferSize * sizeof ( uint32_t ) );
429429
430430 return buffer + _nextUniformOffset;
431431 }
0 commit comments