GPU: Enforce Uniform buffer alignment to 16bytes

This seems to be a requirement and remove some errors in
renderdoc.
This commit is contained in:
2019-05-29 16:57:09 +02:00
parent 77f5210f22
commit 092962cf72
4 changed files with 26 additions and 0 deletions

View File

@@ -76,6 +76,9 @@ static void gpu_uniformbuffer_initialize(GPUUniformBuffer *ubo, const void *data
GPUUniformBuffer *GPU_uniformbuffer_create(int size, const void *data, char err_out[256])
{
/* Make sure that UBO is padded to size of vec4 */
BLI_assert((size % 16) == 0);
GPUUniformBuffer *ubo = MEM_callocN(sizeof(GPUUniformBufferStatic), "GPUUniformBufferStatic");
ubo->size = size;
ubo->bindpoint = -1;
@@ -149,6 +152,9 @@ GPUUniformBuffer *GPU_uniformbuffer_dynamic_create(ListBase *inputs, char err_ou
ubo->buffer.size += gputype * sizeof(float);
}
/* Round up to size of vec4 */
ubo->buffer.size = ((ubo->buffer.size + 15) / 16) * 16;
/* Allocate the data. */
ubo->data = MEM_mallocN(ubo->buffer.size, __func__);