Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2019-05-29 17:57:09 +0300
committerClément Foucault <foucault.clem@gmail.com>2019-05-30 14:42:21 +0300
commit092962cf72e77abb3693f9f337b341bfc066d711 (patch)
tree2b15bb247d976583d62e12617c79a531e0cbc4aa /source/blender/gpu/intern
parent77f5210f22332b3594fabe08bee5809fc8333dba (diff)
GPU: Enforce Uniform buffer alignment to 16bytes
This seems to be a requirement and remove some errors in renderdoc.
Diffstat (limited to 'source/blender/gpu/intern')
-rw-r--r--source/blender/gpu/intern/gpu_material.c3
-rw-r--r--source/blender/gpu/intern/gpu_uniformbuffer.c6
2 files changed, 9 insertions, 0 deletions
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c
index 007a13a06ef..f5051a1d767 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -262,8 +262,11 @@ typedef struct GPUSssKernelData {
float kernel[SSS_SAMPLES][4];
float param[3], max_radius;
int samples;
+ int pad[3];
} GPUSssKernelData;
+BLI_STATIC_ASSERT_ALIGN(GPUSssKernelData, 16)
+
static void sss_calculate_offsets(GPUSssKernelData *kd, int count, float exponent)
{
float step = 2.0f / (float)(count - 1);
diff --git a/source/blender/gpu/intern/gpu_uniformbuffer.c b/source/blender/gpu/intern/gpu_uniformbuffer.c
index d7766c51f38..46dcc6c6f78 100644
--- a/source/blender/gpu/intern/gpu_uniformbuffer.c
+++ b/source/blender/gpu/intern/gpu_uniformbuffer.c
@@ -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__);