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
path: root/source
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
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')
-rw-r--r--source/blender/draw/engines/eevee/eevee_private.h11
-rw-r--r--source/blender/gpu/intern/gpu_material.c3
-rw-r--r--source/blender/gpu/intern/gpu_uniformbuffer.c6
-rw-r--r--source/blender/makesdna/DNA_lightprobe_types.h6
4 files changed, 26 insertions, 0 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h
index 2e652dff232..6b82c7aa915 100644
--- a/source/blender/draw/engines/eevee/eevee_private.h
+++ b/source/blender/draw/engines/eevee/eevee_private.h
@@ -401,8 +401,15 @@ typedef struct EEVEE_ShadowRender {
int shadow_samples_len;
float shadow_samples_len_inv;
float exponent;
+ float pad2;
} EEVEE_ShadowRender;
+BLI_STATIC_ASSERT_ALIGN(EEVEE_Light, 16)
+BLI_STATIC_ASSERT_ALIGN(EEVEE_Shadow, 16)
+BLI_STATIC_ASSERT_ALIGN(EEVEE_ShadowCube, 16)
+BLI_STATIC_ASSERT_ALIGN(EEVEE_ShadowCascade, 16)
+BLI_STATIC_ASSERT_ALIGN(EEVEE_ShadowRender, 16)
+
/* This is just a really long bitflag with special function to access it. */
#define MAX_LIGHTBITS_FIELDS (MAX_LIGHT / 8)
typedef struct EEVEE_LightBits {
@@ -685,8 +692,12 @@ typedef struct EEVEE_CommonUniformBuffer {
int hiz_mip_offset; /* int */
int ray_type; /* int */
float ray_depth; /* float */
+
+ float pad_common_ubo;
} EEVEE_CommonUniformBuffer;
+BLI_STATIC_ASSERT_ALIGN(EEVEE_CommonUniformBuffer, 16)
+
/* ray_type (keep in sync with rayType) */
#define EEVEE_RAY_CAMERA 0
#define EEVEE_RAY_SHADOW 1
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__);
diff --git a/source/blender/makesdna/DNA_lightprobe_types.h b/source/blender/makesdna/DNA_lightprobe_types.h
index 92b343fbeb9..c5121481f88 100644
--- a/source/blender/makesdna/DNA_lightprobe_types.h
+++ b/source/blender/makesdna/DNA_lightprobe_types.h
@@ -25,6 +25,8 @@
#include "DNA_listBase.h"
#include "DNA_ID.h"
+#include "BLI_assert.h"
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -141,6 +143,10 @@ typedef struct LightGridCache {
float visibility_bias, visibility_bleed, visibility_range, _pad5;
} LightGridCache;
+/* Theses are used as ubo data. They need to be aligned to size of vec4. */
+BLI_STATIC_ASSERT_ALIGN(LightProbeCache, 16)
+BLI_STATIC_ASSERT_ALIGN(LightGridCache, 16)
+
/* ------ Eevee Lightcache ------- */
typedef struct LightCacheTexture {