diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2019-05-14 14:45:55 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2019-05-14 14:54:05 +0300 |
commit | bf45a46f814092cf8b03909ad2d30f4a17b62f10 (patch) | |
tree | cd10307f73680ba8bfe0a5648059b042af94b213 /source/blender/gpu | |
parent | 6bb7eb17065100a8ff6bb9eee2f3f7448e89e674 (diff) |
GPU: Fixup and add assert to GPU_VERT_ATTR_NAMES_BUF_LEN
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/GPU_vertex_buffer.h | 2 | ||||
-rw-r--r-- | source/blender/gpu/GPU_vertex_format.h | 7 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_vertex_format.c | 2 |
3 files changed, 9 insertions, 2 deletions
diff --git a/source/blender/gpu/GPU_vertex_buffer.h b/source/blender/gpu/GPU_vertex_buffer.h index 3e178e193dc..58d48a18fc5 100644 --- a/source/blender/gpu/GPU_vertex_buffer.h +++ b/source/blender/gpu/GPU_vertex_buffer.h @@ -55,7 +55,7 @@ typedef struct GPUVertBuf { /** 0 indicates not yet allocated. */ uint32_t vbo_id; /** Usage hint for GL optimisation. */ - uint usage : 2; + GPUUsageType usage : 2; /** Data has been touched and need to be reuploaded to GPU. */ uint dirty : 1; unsigned char *data; /* NULL indicates data in VRAM (unmapped) */ diff --git a/source/blender/gpu/GPU_vertex_format.h b/source/blender/gpu/GPU_vertex_format.h index 74fad51f571..b0ff7c1820f 100644 --- a/source/blender/gpu/GPU_vertex_format.h +++ b/source/blender/gpu/GPU_vertex_format.h @@ -28,6 +28,7 @@ #include "GPU_common.h" #include "BLI_compiler_compat.h" +#include "BLI_assert.h" #define GPU_VERT_ATTR_MAX_LEN 16 #define GPU_VERT_ATTR_MAX_NAMES 4 @@ -70,6 +71,12 @@ typedef struct GPUVertAttr { uchar names[GPU_VERT_ATTR_MAX_NAMES]; } GPUVertAttr; +BLI_STATIC_ASSERT(GPU_VERT_ATTR_NAMES_BUF_LEN <= 256, + "We use uchar as index inside the name buffer " + "so GPU_VERT_ATTR_NAMES_BUF_LEN needs to be be " + "smaller than GPUVertFormat->name_offset and " + "GPUVertAttr->names maximum value"); + typedef struct GPUVertFormat { /** 0 to 16 (GPU_VERT_ATTR_MAX_LEN). */ uint attr_len : 5; diff --git a/source/blender/gpu/intern/gpu_vertex_format.c b/source/blender/gpu/intern/gpu_vertex_format.c index 34e46caae7e..37e1f9cf9da 100644 --- a/source/blender/gpu/intern/gpu_vertex_format.c +++ b/source/blender/gpu/intern/gpu_vertex_format.c @@ -116,7 +116,7 @@ uint vertex_buffer_size(const GPUVertFormat *format, uint vertex_len) return format->stride * vertex_len; } -static char copy_attr_name(GPUVertFormat *format, const char *name) +static uchar copy_attr_name(GPUVertFormat *format, const char *name) { /* strncpy does 110% of what we need; let's do exactly 100% */ uchar name_offset = format->name_offset; |