GPU: Enforce Uniform buffer alignment to 16bytes
This seems to be a requirement and remove some errors in renderdoc.
This commit is contained in:
parent
77f5210f22
commit
092962cf72
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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__);
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue