@@ -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 ),
@@ -390,11 +392,10 @@ class GLUniform {
390392 currentValue = p->uniformStorage + _uniformStorageOffset;
391393 }
392394
393- const uint32_t size = _components ? _std430Size * _components : _std430Size;
394- const bool updated = memcmp ( currentValue, value, size * sizeof ( uint32_t ) );
395+ const bool updated = memcmp ( currentValue, value, _bufferSize * sizeof ( uint32_t ) );
395396
396397 if ( updated ) {
397- memcpy ( currentValue, value, size * sizeof ( uint32_t ) );
398+ memcpy ( currentValue, value, _bufferSize * sizeof ( uint32_t ) );
398399 _shader->uniformsUpdated = true ;
399400 }
400401
@@ -425,8 +426,7 @@ class GLUniform {
425426 return buffer;
426427 }
427428
428- const uint32_t size = _components ? _std430Size * _components : _std430Size;
429- memcpy ( buffer, currentValue, size * sizeof ( uint32_t ) );
429+ memcpy ( buffer, currentValue, _bufferSize * sizeof ( uint32_t ) );
430430
431431 return buffer + _nextUniformOffset;
432432 }
0 commit comments