How does that work? Are we sending more than "uniform_count" uniforms to the shader anywhere? Or is this about the potential padding introduced by align?
Both in SM1 or when we work with arrays we commonly declare uniforms leaving the padding uninitialized: ``` uniform 0 float 1.0 uniform 4 float 2.0 uniform 8 float 3.0 ``` so the aim is to initialize it, including the padding after the last uniform declared.
My idea was to initialize the new values in the array after a reallocation happens, before inserting the values provided at the offset position, to ensure that we initialize the padding.
In the latter case, we need to clear a fair bit less than we do here.
Ah, I see it now.
We may also want to consider clearing with a value other than zero.
Yep, I think it makes sense to initialize to a sentry value other than zero, maybe 127 ?
btw, I forgot to multiply the amount of bytes by the size of each uniform. So the final instruction should be: ``` memset(runner->uniforms + initial_count, 127, (runner->uniform_count - initial_count) * sizeof(*runner->uniforms)); ```