diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-02-08 02:40:50 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-02-08 02:41:27 +0300 |
commit | 42c99ee5f518fa036439af297416e135bc58b806 (patch) | |
tree | f3710ac676f282ca6603eae8387eb1834b6c899c /source/blender/draw/intern | |
parent | 44aaffc684dabc44047ac9540870045ccfe83aa3 (diff) |
DRW: Fix crash caused by fixing the leak (badly).
Previous commit was af425f3f7a08c09f7fbc7076b364fac75163b296
Diffstat (limited to 'source/blender/draw/intern')
-rw-r--r-- | source/blender/draw/intern/draw_instance_data.c | 2 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_instance_data.h | 2 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager.c | 9 |
3 files changed, 10 insertions, 3 deletions
diff --git a/source/blender/draw/intern/draw_instance_data.c b/source/blender/draw/intern/draw_instance_data.c index e7ce4374d1c..7f3bd246818 100644 --- a/source/blender/draw/intern/draw_instance_data.c +++ b/source/blender/draw/intern/draw_instance_data.c @@ -38,8 +38,6 @@ #include "MEM_guardedalloc.h" #include "BLI_utildefines.h" -#define MAX_INSTANCE_DATA_SIZE 32 /* Can be adjusted for more */ - struct DRWInstanceData { struct DRWInstanceData *next; bool used; /* If this data is used or not. */ diff --git a/source/blender/draw/intern/draw_instance_data.h b/source/blender/draw/intern/draw_instance_data.h index 637c0e3cc24..c8376189396 100644 --- a/source/blender/draw/intern/draw_instance_data.h +++ b/source/blender/draw/intern/draw_instance_data.h @@ -26,6 +26,8 @@ #ifndef __DRAW_INSTANCE_DATA_H__ #define __DRAW_INSTANCE_DATA_H__ +#define MAX_INSTANCE_DATA_SIZE 42 /* Can be adjusted for more */ + typedef struct DRWInstanceData DRWInstanceData; typedef struct DRWInstanceDataList DRWInstanceDataList; diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 6ab6f20013e..96454fd087e 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -315,6 +315,7 @@ static struct DRWGlobalState { DRWCallGenerate *last_callgenerate; DRWShadingGroup *last_shgroup; DRWInstanceDataList *idatalist; + DRWInstanceData *common_instance_data[MAX_INSTANCE_DATA_SIZE]; /* Rendering state */ GPUShader *shader; @@ -2676,6 +2677,7 @@ static void drw_viewport_var_init(void) } memset(viewport_matrix_override.override, 0x0, sizeof(viewport_matrix_override.override)); + memset(DST.common_instance_data, 0x0, sizeof(DST.common_instance_data)); } void DRW_viewport_matrix_get(float mat[4][4], DRWViewportMatrixType type) @@ -2824,10 +2826,15 @@ ObjectEngineData *DRW_object_engine_data_ensure( /* Allocate new data. */ if ((ob->base_flag & BASE_FROMDUPLI) != 0) { /* NOTE: data is not persistent in this case. It is reset each redraw. */ + BLI_assert(free_cb == NULL); /* No callback allowed. */ /* Round to sizeof(float) for DRW_instance_data_request(). */ const size_t t = sizeof(float) - 1; size = (size + t) & ~t; - oed = (ObjectEngineData *)DRW_instance_data_request(DST.idatalist, size / sizeof(float), 16); + size_t fsize = size / sizeof(float); + if (DST.common_instance_data[fsize] == NULL) { + DST.common_instance_data[fsize] = DRW_instance_data_request(DST.idatalist, fsize, 16); + } + oed = (ObjectEngineData *)DRW_instance_data_next(DST.common_instance_data[fsize]); memset(oed, 0, size); } else { |