diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-04-12 12:49:19 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-04-12 12:51:14 +0300 |
commit | 0c9a2def8b1e40a0b5a3ed348d1fd92cc13096ff (patch) | |
tree | 8749b8080b9b02514cc7f9d08dab6391ce716844 /source/blender/draw | |
parent | b380f4927e30bc2877b4f3a760fefa0dfc3614e1 (diff) |
Draw Engine: remove hard coded limit on array sizes
This removes MAX_STORAGE, MAX_BUFFERS, MAX_TEXTURES, MAX_PASSES limits.
Actual memory saving isn't so important, it just means we don't need to
manually bump these based on changes to engines.
Diffstat (limited to 'source/blender/draw')
20 files changed, 101 insertions, 70 deletions
diff --git a/source/blender/draw/DRW_engine.h b/source/blender/draw/DRW_engine.h index 87cfa8e8e3b..60e8e40ea61 100644 --- a/source/blender/draw/DRW_engine.h +++ b/source/blender/draw/DRW_engine.h @@ -49,6 +49,9 @@ void DRW_engines_register(void); void DRW_engines_free(void); void DRW_engine_register(struct DrawEngineType *draw_engine_type); +void DRW_engine_viewport_data_size_get( + const void *engine_type, + int *r_fbl_len, int *r_txl_len, int *r_psl_len, int *r_stl_len); void DRW_draw_view(const struct bContext *C); diff --git a/source/blender/draw/engines/clay/clay.c b/source/blender/draw/engines/clay/clay.c index c1e01e3375e..3f65efc2b28 100644 --- a/source/blender/draw/engines/clay/clay.c +++ b/source/blender/draw/engines/clay/clay.c @@ -73,14 +73,12 @@ typedef struct CLAY_Storage { DRWShadingGroup *shgrps[MAX_CLAY_MAT]; } CLAY_Storage; -/* keep it under MAX_STORAGE */ typedef struct CLAY_StorageList { struct CLAY_Storage *storage; struct GPUUniformBuffer *mat_ubo; struct g_data *g_data; } CLAY_StorageList; -/* keep it under MAX_BUFFERS */ typedef struct CLAY_FramebufferList { /* default */ struct GPUFrameBuffer *default_fb; @@ -88,7 +86,6 @@ typedef struct CLAY_FramebufferList { struct GPUFrameBuffer *dupli_depth; } CLAY_FramebufferList; -/* keep it under MAX_TEXTURES */ typedef struct CLAY_TextureList { /* default */ struct GPUTexture *color; @@ -97,7 +94,6 @@ typedef struct CLAY_TextureList { struct GPUTexture *depth_dup; } CLAY_TextureList; -/* keep it under MAX_PASSES */ typedef struct CLAY_PassList { struct DRWPass *depth_pass; struct DRWPass *depth_pass_cull; @@ -650,9 +646,12 @@ static void CLAY_engine_free(void) } } +static const DrawEngineDataSize CLAY_data_size = DRW_VIEWPORT_DATA_SIZE(CLAY_Data); + DrawEngineType draw_engine_clay_type = { NULL, NULL, N_("Clay"), + &CLAY_data_size, &CLAY_engine_init, &CLAY_engine_free, &CLAY_cache_init, diff --git a/source/blender/draw/engines/eevee/eevee.c b/source/blender/draw/engines/eevee/eevee.c index 301ec8b11d1..ae345ae97f0 100644 --- a/source/blender/draw/engines/eevee/eevee.c +++ b/source/blender/draw/engines/eevee/eevee.c @@ -268,9 +268,12 @@ static void EEVEE_collection_settings_create(RenderEngine *UNUSED(engine), IDPro // BKE_collection_engine_property_add_int(props, "high_quality_sphere_lamps", false); } +static const DrawEngineDataSize EEVEE_data_size = DRW_VIEWPORT_DATA_SIZE(EEVEE_Data); + DrawEngineType draw_engine_eevee_type = { NULL, NULL, N_("Eevee"), + &EEVEE_data_size, &EEVEE_engine_init, &EEVEE_engine_free, &EEVEE_cache_init, diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h index 7ed80ac68c2..59029b1f1af 100644 --- a/source/blender/draw/engines/eevee/eevee_private.h +++ b/source/blender/draw/engines/eevee/eevee_private.h @@ -32,7 +32,6 @@ struct Object; #define MAX_SHADOW_CASCADE 8 #define MAX_CASCADE_NUM 4 -/* keep it under MAX_PASSES */ typedef struct EEVEE_PassList { struct DRWPass *shadow_pass; struct DRWPass *depth_pass; @@ -41,7 +40,6 @@ typedef struct EEVEE_PassList { struct DRWPass *tonemap; } EEVEE_PassList; -/* keep it under MAX_BUFFERS */ typedef struct EEVEE_FramebufferList { struct GPUFrameBuffer *main; /* HDR */ struct GPUFrameBuffer *shadow_cube_fb; @@ -49,7 +47,6 @@ typedef struct EEVEE_FramebufferList { struct GPUFrameBuffer *shadow_cascade_fb; } EEVEE_FramebufferList; -/* keep it under MAX_TEXTURES */ typedef struct EEVEE_TextureList { struct GPUTexture *color; /* R11_G11_B10 */ struct GPUTexture *shadow_depth_cube_pool; @@ -57,7 +54,6 @@ typedef struct EEVEE_TextureList { struct GPUTexture *shadow_depth_cascade_pool; } EEVEE_TextureList; -/* keep it under MAX_STORAGE */ typedef struct EEVEE_StorageList { /* Lamps */ /* XXX this should be per-scenelayer and not per_viewport */ diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index 0a7d4dcbfec..c9435b532f7 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -63,17 +63,38 @@ struct DefaultFramebufferList; struct DefaultTextureList; struct LampEngineData; struct RenderEngineType; +struct ViewportEngineData; +struct ViewportEngineData_Info; typedef struct DRWUniform DRWUniform; typedef struct DRWInterface DRWInterface; typedef struct DRWPass DRWPass; typedef struct DRWShadingGroup DRWShadingGroup; +#define DRW_VIEWPORT_LIST_SIZE(list) (sizeof(list) == sizeof(char) ? 0 : ((sizeof(list)) / sizeof(void *))) + +/* Unused members must be either pass list or 'char *' when not usd. */ +#define DRW_VIEWPORT_DATA_SIZE(ty) { \ + DRW_VIEWPORT_LIST_SIZE(*(((ty *)NULL)->fbl)), \ + DRW_VIEWPORT_LIST_SIZE(*(((ty *)NULL)->txl)), \ + DRW_VIEWPORT_LIST_SIZE(*(((ty *)NULL)->psl)), \ + DRW_VIEWPORT_LIST_SIZE(*(((ty *)NULL)->stl)) \ +} + +typedef struct DrawEngineDataSize { + int fbl_len; + int txl_len; + int psl_len; + int stl_len; +} DrawEngineDataSize; + typedef struct DrawEngineType { struct DrawEngineType *next, *prev; char idname[32]; + const DrawEngineDataSize *vedata_size; + void (*engine_init)(void *vedata); void (*engine_free)(void); diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 5ad46a75da1..e065e14a002 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -1308,6 +1308,7 @@ void DRW_framebuffer_blit(struct GPUFrameBuffer *fb_read, struct GPUFrameBuffer } /* ****************************************** Viewport ******************************************/ + static void *DRW_viewport_engine_data_get(void *engine_type) { void *data = GPU_viewport_engine_data_get(DST.viewport, engine_type); @@ -1318,6 +1319,26 @@ static void *DRW_viewport_engine_data_get(void *engine_type) return data; } +void DRW_engine_viewport_data_size_get( + const void *engine_type_v, + int *r_fbl_len, int *r_txl_len, int *r_psl_len, int *r_stl_len) +{ + const DrawEngineType *engine_type = engine_type_v; + + if (r_fbl_len) { + *r_fbl_len = engine_type->vedata_size->fbl_len; + } + if (r_txl_len) { + *r_txl_len = engine_type->vedata_size->txl_len; + } + if (r_psl_len) { + *r_psl_len = engine_type->vedata_size->psl_len; + } + if (r_stl_len) { + *r_stl_len = engine_type->vedata_size->stl_len; + } +} + const float *DRW_viewport_size_get(void) { return &DST.size[0]; @@ -1739,7 +1760,7 @@ static void DRW_debug_gpu_stats(void) draw_stat(&rect, 0, v, engine->idname, sizeof(engine->idname)); v++; - for (int i = 0; i < MAX_PASSES; ++i) { + for (int i = 0; i < engine->vedata_size->psl_len; ++i) { DRWPass *pass = data->psl->passes[i]; if (pass != NULL) { GLuint64 time; diff --git a/source/blender/draw/modes/edit_armature_mode.c b/source/blender/draw/modes/edit_armature_mode.c index 6111b9b160b..68e3112f03b 100644 --- a/source/blender/draw/modes/edit_armature_mode.c +++ b/source/blender/draw/modes/edit_armature_mode.c @@ -35,24 +35,22 @@ extern GlobalsUboStorage ts; /* *********** LISTS *********** */ -/* keep it under MAX_PASSES */ typedef struct EDIT_ARMATURE_PassList { struct DRWPass *bone_solid; struct DRWPass *bone_wire; struct DRWPass *relationship; } EDIT_ARMATURE_PassList; -/* keep it under MAX_STORAGE */ typedef struct EDIT_ARMATURE_StorageList { struct g_data *g_data; } EDIT_ARMATURE_StorageList; typedef struct EDIT_ARMATURE_Data { void *engine_type; - void *fbl; - void *txl; + char *fbl; + char *txl; EDIT_ARMATURE_PassList *psl; - void *stl; + EDIT_ARMATURE_StorageList *stl; } EDIT_ARMATURE_Data; /* *********** STATIC *********** */ @@ -126,9 +124,12 @@ void EDIT_ARMATURE_collection_settings_create(CollectionEngineSettings *ces) } #endif +static const DrawEngineDataSize EDIT_ARMATURE_data_size = DRW_VIEWPORT_DATA_SIZE(EDIT_ARMATURE_Data); + DrawEngineType draw_engine_edit_armature_type = { NULL, NULL, N_("EditArmatureMode"), + &EDIT_ARMATURE_data_size, NULL, NULL, &EDIT_ARMATURE_cache_init, diff --git a/source/blender/draw/modes/edit_curve_mode.c b/source/blender/draw/modes/edit_curve_mode.c index 7a2bfa2792a..2cb03018254 100644 --- a/source/blender/draw/modes/edit_curve_mode.c +++ b/source/blender/draw/modes/edit_curve_mode.c @@ -46,7 +46,6 @@ extern struct GlobalsUboStorage ts; /* draw_common.c */ * initialize most of them and EDIT_CURVE_cache_init() * for EDIT_CURVE_PassList */ -/* keep it under MAX_PASSES */ typedef struct EDIT_CURVE_PassList { /* Declare all passes here and init them in * EDIT_CURVE_cache_init(). @@ -54,14 +53,12 @@ typedef struct EDIT_CURVE_PassList { struct DRWPass *pass; } EDIT_CURVE_PassList; -/* keep it under MAX_BUFFERS */ typedef struct EDIT_CURVE_FramebufferList { /* Contains all framebuffer objects needed by this engine. * Only contains (GPUFrameBuffer *) */ struct GPUFrameBuffer *fb; } EDIT_CURVE_FramebufferList; -/* keep it under MAX_TEXTURES */ typedef struct EDIT_CURVE_TextureList { /* Contains all framebuffer textures / utility textures * needed by this engine. Only viewport specific textures @@ -69,7 +66,6 @@ typedef struct EDIT_CURVE_TextureList { struct GPUTexture *texture; } EDIT_CURVE_TextureList; -/* keep it under MAX_STORAGE */ typedef struct EDIT_CURVE_StorageList { /* Contains any other memory block that the engine needs. * Only directly MEM_(m/c)allocN'ed blocks because they are @@ -259,9 +255,12 @@ void EDIT_CURVE_collection_settings_create(CollectionEngineSettings *ces) } #endif +static const DrawEngineDataSize EDIT_CURVE_data_size = DRW_VIEWPORT_DATA_SIZE(EDIT_CURVE_Data); + DrawEngineType draw_engine_edit_curve_type = { NULL, NULL, N_("EditCurveMode"), + &EDIT_CURVE_data_size, &EDIT_CURVE_engine_init, &EDIT_CURVE_engine_free, &EDIT_CURVE_cache_init, diff --git a/source/blender/draw/modes/edit_lattice_mode.c b/source/blender/draw/modes/edit_lattice_mode.c index 994682ecbed..ea5256b42a5 100644 --- a/source/blender/draw/modes/edit_lattice_mode.c +++ b/source/blender/draw/modes/edit_lattice_mode.c @@ -46,7 +46,6 @@ extern struct GlobalsUboStorage ts; /* draw_common.c */ * initialize most of them and EDIT_LATTICE_cache_init() * for EDIT_LATTICE_PassList */ -/* keep it under MAX_PASSES */ typedef struct EDIT_LATTICE_PassList { /* Declare all passes here and init them in * EDIT_LATTICE_cache_init(). @@ -54,14 +53,12 @@ typedef struct EDIT_LATTICE_PassList { struct DRWPass *pass; } EDIT_LATTICE_PassList; -/* keep it under MAX_BUFFERS */ typedef struct EDIT_LATTICE_FramebufferList { /* Contains all framebuffer objects needed by this engine. * Only contains (GPUFrameBuffer *) */ struct GPUFrameBuffer *fb; } EDIT_LATTICE_FramebufferList; -/* keep it under MAX_TEXTURES */ typedef struct EDIT_LATTICE_TextureList { /* Contains all framebuffer textures / utility textures * needed by this engine. Only viewport specific textures @@ -69,7 +66,6 @@ typedef struct EDIT_LATTICE_TextureList { struct GPUTexture *texture; } EDIT_LATTICE_TextureList; -/* keep it under MAX_STORAGE */ typedef struct EDIT_LATTICE_StorageList { /* Contains any other memory block that the engine needs. * Only directly MEM_(m/c)allocN'ed blocks because they are @@ -257,9 +253,12 @@ void EDIT_LATTICE_collection_settings_create(CollectionEngineSettings *ces) } #endif +static const DrawEngineDataSize EDIT_LATTICE_data_size = DRW_VIEWPORT_DATA_SIZE(EDIT_LATTICE_Data); + DrawEngineType draw_engine_edit_lattice_type = { NULL, NULL, N_("EditLatticeMode"), + &EDIT_LATTICE_data_size, &EDIT_LATTICE_engine_init, &EDIT_LATTICE_engine_free, &EDIT_LATTICE_cache_init, diff --git a/source/blender/draw/modes/edit_mesh_mode.c b/source/blender/draw/modes/edit_mesh_mode.c index dc53ca44f25..08a6a6e778b 100644 --- a/source/blender/draw/modes/edit_mesh_mode.c +++ b/source/blender/draw/modes/edit_mesh_mode.c @@ -54,7 +54,6 @@ extern char datatoc_common_globals_lib_glsl[]; extern char datatoc_gpu_shader_uniform_color_frag_glsl[]; /* *********** LISTS *********** */ -/* keep it under MAX_PASSES */ typedef struct EDIT_MESH_PassList { struct DRWPass *depth_hidden_wire; struct DRWPass *edit_face_overlay; @@ -64,18 +63,15 @@ typedef struct EDIT_MESH_PassList { struct DRWPass *normals; } EDIT_MESH_PassList; -/* keep it under MAX_BUFFERS */ typedef struct EDIT_MESH_FramebufferList { struct GPUFrameBuffer *occlude_wire_fb; } EDIT_MESH_FramebufferList; -/* keep it under MAX_TEXTURES */ typedef struct EDIT_MESH_TextureList { struct GPUTexture *occlude_wire_depth_tx; struct GPUTexture *occlude_wire_color_tx; } EDIT_MESH_TextureList; -/* keep it under MAX_STORAGE */ typedef struct EDIT_MESH_StorageList { struct g_data *g_data; } EDIT_MESH_StorageList; @@ -85,7 +81,7 @@ typedef struct EDIT_MESH_Data { EDIT_MESH_FramebufferList *fbl; EDIT_MESH_TextureList *txl; EDIT_MESH_PassList *psl; - void *stl; + EDIT_MESH_StorageList *stl; } EDIT_MESH_Data; /* *********** STATIC *********** */ @@ -529,9 +525,12 @@ static void EDIT_MESH_engine_free(void) DRW_shader_free(e_data.normals_sh); } +static const DrawEngineDataSize EDIT_MESH_data_size = DRW_VIEWPORT_DATA_SIZE(EDIT_MESH_Data); + DrawEngineType draw_engine_edit_mesh_type = { NULL, NULL, N_("EditMeshMode"), + &EDIT_MESH_data_size, &EDIT_MESH_engine_init, &EDIT_MESH_engine_free, &EDIT_MESH_cache_init, diff --git a/source/blender/draw/modes/edit_metaball_mode.c b/source/blender/draw/modes/edit_metaball_mode.c index d5cc2a0f07b..20d78fdffda 100644 --- a/source/blender/draw/modes/edit_metaball_mode.c +++ b/source/blender/draw/modes/edit_metaball_mode.c @@ -46,7 +46,6 @@ extern struct GlobalsUboStorage ts; /* draw_common.c */ * initialize most of them and EDIT_METABALL_cache_init() * for EDIT_METABALL_PassList */ -/* keep it under MAX_PASSES */ typedef struct EDIT_METABALL_PassList { /* Declare all passes here and init them in * EDIT_METABALL_cache_init(). @@ -54,14 +53,12 @@ typedef struct EDIT_METABALL_PassList { struct DRWPass *pass; } EDIT_METABALL_PassList; -/* keep it under MAX_BUFFERS */ typedef struct EDIT_METABALL_FramebufferList { /* Contains all framebuffer objects needed by this engine. * Only contains (GPUFrameBuffer *) */ struct GPUFrameBuffer *fb; } EDIT_METABALL_FramebufferList; -/* keep it under MAX_TEXTURES */ typedef struct EDIT_METABALL_TextureList { /* Contains all framebuffer textures / utility textures * needed by this engine. Only viewport specific textures @@ -69,7 +66,6 @@ typedef struct EDIT_METABALL_TextureList { struct GPUTexture *texture; } EDIT_METABALL_TextureList; -/* keep it under MAX_STORAGE */ typedef struct EDIT_METABALL_StorageList { /* Contains any other memory block that the engine needs. * Only directly MEM_(m/c)allocN'ed blocks because they are @@ -257,9 +253,12 @@ void EDIT_METABALL_collection_settings_create(CollectionEngineSettings *ces) } #endif +static const DrawEngineDataSize EDIT_METABALL_data_size = DRW_VIEWPORT_DATA_SIZE(EDIT_METABALL_Data); + DrawEngineType draw_engine_edit_metaball_type = { NULL, NULL, N_("EditMetaballMode"), + &EDIT_METABALL_data_size, &EDIT_METABALL_engine_init, &EDIT_METABALL_engine_free, &EDIT_METABALL_cache_init, diff --git a/source/blender/draw/modes/edit_surface_mode.c b/source/blender/draw/modes/edit_surface_mode.c index d30cfb77f47..c09a10dcc91 100644 --- a/source/blender/draw/modes/edit_surface_mode.c +++ b/source/blender/draw/modes/edit_surface_mode.c @@ -46,7 +46,6 @@ extern struct GlobalsUboStorage ts; /* draw_common.c */ * initialize most of them and EDIT_SURFACE_cache_init() * for EDIT_SURFACE_PassList */ -/* keep it under MAX_PASSES */ typedef struct EDIT_SURFACE_PassList { /* Declare all passes here and init them in * EDIT_SURFACE_cache_init(). @@ -54,14 +53,12 @@ typedef struct EDIT_SURFACE_PassList { struct DRWPass *pass; } EDIT_SURFACE_PassList; -/* keep it under MAX_BUFFERS */ typedef struct EDIT_SURFACE_FramebufferList { /* Contains all framebuffer objects needed by this engine. * Only contains (GPUFrameBuffer *) */ struct GPUFrameBuffer *fb; } EDIT_SURFACE_FramebufferList; -/* keep it under MAX_TEXTURES */ typedef struct EDIT_SURFACE_TextureList { /* Contains all framebuffer textures / utility textures * needed by this engine. Only viewport specific textures @@ -69,7 +66,6 @@ typedef struct EDIT_SURFACE_TextureList { struct GPUTexture *texture; } EDIT_SURFACE_TextureList; -/* keep it under MAX_STORAGE */ typedef struct EDIT_SURFACE_StorageList { /* Contains any other memory block that the engine needs. * Only directly MEM_(m/c)allocN'ed blocks because they are @@ -257,9 +253,12 @@ void EDIT_SURFACE_collection_settings_create(CollectionEngineSettings *ces) } #endif +static const DrawEngineDataSize EDIT_SURFACE_data_size = DRW_VIEWPORT_DATA_SIZE(EDIT_SURFACE_Data); + DrawEngineType draw_engine_edit_surface_type = { NULL, NULL, N_("EditSurfaceMode"), + &EDIT_SURFACE_data_size, &EDIT_SURFACE_engine_init, &EDIT_SURFACE_engine_free, &EDIT_SURFACE_cache_init, diff --git a/source/blender/draw/modes/edit_text_mode.c b/source/blender/draw/modes/edit_text_mode.c index fc11ed90ea7..f105e2d316c 100644 --- a/source/blender/draw/modes/edit_text_mode.c +++ b/source/blender/draw/modes/edit_text_mode.c @@ -46,7 +46,6 @@ extern struct GlobalsUboStorage ts; /* draw_common.c */ * initialize most of them and EDIT_TEXT_cache_init() * for EDIT_TEXT_PassList */ -/* keep it under MAX_PASSES */ typedef struct EDIT_TEXT_PassList { /* Declare all passes here and init them in * EDIT_TEXT_cache_init(). @@ -54,14 +53,12 @@ typedef struct EDIT_TEXT_PassList { struct DRWPass *pass; } EDIT_TEXT_PassList; -/* keep it under MAX_BUFFERS */ typedef struct EDIT_TEXT_FramebufferList { /* Contains all framebuffer objects needed by this engine. * Only contains (GPUFrameBuffer *) */ struct GPUFrameBuffer *fb; } EDIT_TEXT_FramebufferList; -/* keep it under MAX_TEXTURES */ typedef struct EDIT_TEXT_TextureList { /* Contains all framebuffer textures / utility textures * needed by this engine. Only viewport specific textures @@ -69,7 +66,6 @@ typedef struct EDIT_TEXT_TextureList { struct GPUTexture *texture; } EDIT_TEXT_TextureList; -/* keep it under MAX_STORAGE */ typedef struct EDIT_TEXT_StorageList { /* Contains any other memory block that the engine needs. * Only directly MEM_(m/c)allocN'ed blocks because they are @@ -257,9 +253,12 @@ void EDIT_TEXT_collection_settings_create(CollectionEngineSettings *ces) } #endif +static const DrawEngineDataSize EDIT_TEXT_data_size = DRW_VIEWPORT_DATA_SIZE(EDIT_TEXT_Data); + DrawEngineType draw_engine_edit_text_type = { NULL, NULL, N_("EditTextMode"), + &EDIT_TEXT_data_size, &EDIT_TEXT_engine_init, &EDIT_TEXT_engine_free, &EDIT_TEXT_cache_init, diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index 8e9d328cecf..ad4da8870f2 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -60,7 +60,6 @@ extern char datatoc_object_grid_vert_glsl[]; extern char datatoc_common_globals_lib_glsl[]; /* *********** LISTS *********** */ -/* keep it under MAX_PASSES */ typedef struct OBJECT_PassList { struct DRWPass *non_meshes; struct DRWPass *ob_center; @@ -78,30 +77,27 @@ typedef struct OBJECT_PassList { struct DRWPass *bone_wire; } OBJECT_PassList; -/* keep it under MAX_BUFFERS */ typedef struct OBJECT_FramebufferList { struct GPUFrameBuffer *outlines; struct GPUFrameBuffer *blur; } OBJECT_FramebufferList; -/* keep it under MAX_TEXTURES */ typedef struct OBJECT_TextureList { struct GPUTexture *outlines_depth_tx; struct GPUTexture *outlines_color_tx; struct GPUTexture *outlines_blur_tx; } OBJECT_TextureList; -/* keep it under MAX_STORAGE */ typedef struct OBJECT_StorageList { struct g_data *g_data; } OBJECT_StorageList; typedef struct OBJECT_Data { void *engine_type; - void *fbl; - void *txl; + OBJECT_FramebufferList *fbl; + OBJECT_TextureList *txl; OBJECT_PassList *psl; - void *stl; + OBJECT_StorageList *stl; } OBJECT_Data; /* *********** STATIC *********** */ @@ -1218,9 +1214,12 @@ void OBJECT_collection_settings_create(IDProperty *props) BKE_collection_engine_property_add_int(props, "show_backface_culling", false); } +static const DrawEngineDataSize OBJECT_data_size = DRW_VIEWPORT_DATA_SIZE(OBJECT_Data); + DrawEngineType draw_engine_object_type = { NULL, NULL, N_("ObjectMode"), + &OBJECT_data_size, &OBJECT_engine_init, &OBJECT_engine_free, &OBJECT_cache_init, diff --git a/source/blender/draw/modes/paint_texture_mode.c b/source/blender/draw/modes/paint_texture_mode.c index a795727e816..06799e549e5 100644 --- a/source/blender/draw/modes/paint_texture_mode.c +++ b/source/blender/draw/modes/paint_texture_mode.c @@ -46,7 +46,6 @@ extern struct GlobalsUboStorage ts; /* draw_common.c */ * initialize most of them and PAINT_TEXTURE_cache_init() * for PAINT_TEXTURE_PassList */ -/* keep it under MAX_PASSES */ typedef struct PAINT_TEXTURE_PassList { /* Declare all passes here and init them in * PAINT_TEXTURE_cache_init(). @@ -54,14 +53,12 @@ typedef struct PAINT_TEXTURE_PassList { struct DRWPass *pass; } PAINT_TEXTURE_PassList; -/* keep it under MAX_BUFFERS */ typedef struct PAINT_TEXTURE_FramebufferList { /* Contains all framebuffer objects needed by this engine. * Only contains (GPUFrameBuffer *) */ struct GPUFrameBuffer *fb; } PAINT_TEXTURE_FramebufferList; -/* keep it under MAX_TEXTURES */ typedef struct PAINT_TEXTURE_TextureList { /* Contains all framebuffer textures / utility textures * needed by this engine. Only viewport specific textures @@ -69,7 +66,6 @@ typedef struct PAINT_TEXTURE_TextureList { struct GPUTexture *texture; } PAINT_TEXTURE_TextureList; -/* keep it under MAX_STORAGE */ typedef struct PAINT_TEXTURE_StorageList { /* Contains any other memory block that the engine needs. * Only directly MEM_(m/c)allocN'ed blocks because they are @@ -257,9 +253,12 @@ void PAINT_TEXTURE_collection_settings_create(CollectionEngineSettings *ces) } #endif +static const DrawEngineDataSize PAINT_TEXTURE_data_size = DRW_VIEWPORT_DATA_SIZE(PAINT_TEXTURE_Data); + DrawEngineType draw_engine_paint_texture_type = { NULL, NULL, N_("PaintTextureMode"), + &PAINT_TEXTURE_data_size, &PAINT_TEXTURE_engine_init, &PAINT_TEXTURE_engine_free, &PAINT_TEXTURE_cache_init, diff --git a/source/blender/draw/modes/paint_vertex_mode.c b/source/blender/draw/modes/paint_vertex_mode.c index cd72881357f..61bd376072f 100644 --- a/source/blender/draw/modes/paint_vertex_mode.c +++ b/source/blender/draw/modes/paint_vertex_mode.c @@ -46,7 +46,6 @@ extern struct GlobalsUboStorage ts; /* draw_common.c */ * initialize most of them and PAINT_VERTEX_cache_init() * for PAINT_VERTEX_PassList */ -/* keep it under MAX_PASSES */ typedef struct PAINT_VERTEX_PassList { /* Declare all passes here and init them in * PAINT_VERTEX_cache_init(). @@ -54,14 +53,12 @@ typedef struct PAINT_VERTEX_PassList { struct DRWPass *pass; } PAINT_VERTEX_PassList; -/* keep it under MAX_BUFFERS */ typedef struct PAINT_VERTEX_FramebufferList { /* Contains all framebuffer objects needed by this engine. * Only contains (GPUFrameBuffer *) */ struct GPUFrameBuffer *fb; } PAINT_VERTEX_FramebufferList; -/* keep it under MAX_TEXTURES */ typedef struct PAINT_VERTEX_TextureList { /* Contains all framebuffer textures / utility textures * needed by this engine. Only viewport specific textures @@ -69,7 +66,6 @@ typedef struct PAINT_VERTEX_TextureList { struct GPUTexture *texture; } PAINT_VERTEX_TextureList; -/* keep it under MAX_STORAGE */ typedef struct PAINT_VERTEX_StorageList { /* Contains any other memory block that the engine needs. * Only directly MEM_(m/c)allocN'ed blocks because they are @@ -257,9 +253,12 @@ void PAINT_VERTEX_collection_settings_create(CollectionEngineSettings *ces) } #endif +static const DrawEngineDataSize PAINT_VERTEX_data_size = DRW_VIEWPORT_DATA_SIZE(PAINT_VERTEX_Data); + DrawEngineType draw_engine_paint_vertex_type = { NULL, NULL, N_("PaintVertexMode"), + &PAINT_VERTEX_data_size, &PAINT_VERTEX_engine_init, &PAINT_VERTEX_engine_free, &PAINT_VERTEX_cache_init, diff --git a/source/blender/draw/modes/paint_weight_mode.c b/source/blender/draw/modes/paint_weight_mode.c index 4e5bcd7e042..fa02ac3f3d8 100644 --- a/source/blender/draw/modes/paint_weight_mode.c +++ b/source/blender/draw/modes/paint_weight_mode.c @@ -46,7 +46,6 @@ extern struct GlobalsUboStorage ts; /* draw_common.c */ * initialize most of them and PAINT_WEIGHT_cache_init() * for PAINT_WEIGHT_PassList */ -/* keep it under MAX_PASSES */ typedef struct PAINT_WEIGHT_PassList { /* Declare all passes here and init them in * PAINT_WEIGHT_cache_init(). @@ -54,14 +53,12 @@ typedef struct PAINT_WEIGHT_PassList { struct DRWPass *pass; } PAINT_WEIGHT_PassList; -/* keep it under MAX_BUFFERS */ typedef struct PAINT_WEIGHT_FramebufferList { /* Contains all framebuffer objects needed by this engine. * Only contains (GPUFrameBuffer *) */ struct GPUFrameBuffer *fb; } PAINT_WEIGHT_FramebufferList; -/* keep it under MAX_TEXTURES */ typedef struct PAINT_WEIGHT_TextureList { /* Contains all framebuffer textures / utility textures * needed by this engine. Only viewport specific textures @@ -69,7 +66,6 @@ typedef struct PAINT_WEIGHT_TextureList { struct GPUTexture *texture; } PAINT_WEIGHT_TextureList; -/* keep it under MAX_STORAGE */ typedef struct PAINT_WEIGHT_StorageList { /* Contains any other memory block that the engine needs. * Only directly MEM_(m/c)allocN'ed blocks because they are @@ -254,9 +250,12 @@ void PAINT_WEIGHT_collection_settings_create(CollectionEngineSettings *ces) } #endif +static const DrawEngineDataSize PAINT_WEIGHT_data_size = DRW_VIEWPORT_DATA_SIZE(PAINT_WEIGHT_Data); + DrawEngineType draw_engine_paint_weight_type = { NULL, NULL, N_("PaintWeightMode"), + &PAINT_WEIGHT_data_size, &PAINT_WEIGHT_engine_init, &PAINT_WEIGHT_engine_free, &PAINT_WEIGHT_cache_init, diff --git a/source/blender/draw/modes/particle_mode.c b/source/blender/draw/modes/particle_mode.c index 2fa32946196..e51be560476 100644 --- a/source/blender/draw/modes/particle_mode.c +++ b/source/blender/draw/modes/particle_mode.c @@ -40,7 +40,6 @@ * initialize most of them and PARTICLE_cache_init() * for PARTICLE_PassList */ -/* keep it under MAX_PASSES */ typedef struct PARTICLE_PassList { /* Declare all passes here and init them in * PARTICLE_cache_init(). @@ -48,14 +47,12 @@ typedef struct PARTICLE_PassList { struct DRWPass *pass; } PARTICLE_PassList; -/* keep it under MAX_BUFFERS */ typedef struct PARTICLE_FramebufferList { /* Contains all framebuffer objects needed by this engine. * Only contains (GPUFrameBuffer *) */ struct GPUFrameBuffer *fb; } PARTICLE_FramebufferList; -/* keep it under MAX_TEXTURES */ typedef struct PARTICLE_TextureList { /* Contains all framebuffer textures / utility textures * needed by this engine. Only viewport specific textures @@ -63,7 +60,6 @@ typedef struct PARTICLE_TextureList { struct GPUTexture *texture; } PARTICLE_TextureList; -/* keep it under MAX_STORAGE */ typedef struct PARTICLE_StorageList { /* Contains any other memory block that the engine needs. * Only directly MEM_(m/c)allocN'ed blocks because they are @@ -252,9 +248,12 @@ void PARTICLE_collection_settings_create(CollectionEngineSettings *ces) } #endif +static const DrawEngineDataSize PARTICLE_data_size = DRW_VIEWPORT_DATA_SIZE(PARTICLE_Data); + DrawEngineType draw_engine_particle_type = { NULL, NULL, N_("ParticleMode"), + &PARTICLE_data_size, &PARTICLE_engine_init, &PARTICLE_engine_free, &PARTICLE_cache_init, diff --git a/source/blender/draw/modes/pose_mode.c b/source/blender/draw/modes/pose_mode.c index e779e2f4ca3..390becf2d91 100644 --- a/source/blender/draw/modes/pose_mode.c +++ b/source/blender/draw/modes/pose_mode.c @@ -40,7 +40,6 @@ * initialize most of them and POSE_cache_init() * for POSE_PassList */ -/* keep it under MAX_PASSES */ typedef struct POSE_PassList { /* Declare all passes here and init them in * POSE_cache_init(). @@ -48,14 +47,12 @@ typedef struct POSE_PassList { struct DRWPass *pass; } POSE_PassList; -/* keep it under MAX_BUFFERS */ typedef struct POSE_FramebufferList { /* Contains all framebuffer objects needed by this engine. * Only contains (GPUFrameBuffer *) */ struct GPUFrameBuffer *fb; } POSE_FramebufferList; -/* keep it under MAX_TEXTURES */ typedef struct POSE_TextureList { /* Contains all framebuffer textures / utility textures * needed by this engine. Only viewport specific textures @@ -63,7 +60,6 @@ typedef struct POSE_TextureList { struct GPUTexture *texture; } POSE_TextureList; -/* keep it under MAX_STORAGE */ typedef struct POSE_StorageList { /* Contains any other memory block that the engine needs. * Only directly MEM_(m/c)allocN'ed blocks because they are @@ -252,9 +248,12 @@ void POSE_collection_settings_create(CollectionEngineSettings *ces) } #endif +static const DrawEngineDataSize POSE_data_size = DRW_VIEWPORT_DATA_SIZE(POSE_Data); + DrawEngineType draw_engine_pose_type = { NULL, NULL, N_("PoseMode"), + &POSE_data_size, &POSE_engine_init, &POSE_engine_free, &POSE_cache_init, diff --git a/source/blender/draw/modes/sculpt_mode.c b/source/blender/draw/modes/sculpt_mode.c index 2fdd240ca79..14140ae6711 100644 --- a/source/blender/draw/modes/sculpt_mode.c +++ b/source/blender/draw/modes/sculpt_mode.c @@ -40,7 +40,6 @@ * initialize most of them and SCULPT_cache_init() * for SCULPT_PassList */ -/* keep it under MAX_PASSES */ typedef struct SCULPT_PassList { /* Declare all passes here and init them in * SCULPT_cache_init(). @@ -48,14 +47,12 @@ typedef struct SCULPT_PassList { struct DRWPass *pass; } SCULPT_PassList; -/* keep it under MAX_BUFFERS */ typedef struct SCULPT_FramebufferList { /* Contains all framebuffer objects needed by this engine. * Only contains (GPUFrameBuffer *) */ struct GPUFrameBuffer *fb; } SCULPT_FramebufferList; -/* keep it under MAX_TEXTURES */ typedef struct SCULPT_TextureList { /* Contains all framebuffer textures / utility textures * needed by this engine. Only viewport specific textures @@ -63,7 +60,6 @@ typedef struct SCULPT_TextureList { struct GPUTexture *texture; } SCULPT_TextureList; -/* keep it under MAX_STORAGE */ typedef struct SCULPT_StorageList { /* Contains any other memory block that the engine needs. * Only directly MEM_(m/c)allocN'ed blocks because they are @@ -251,9 +247,12 @@ void SCULPT_collection_settings_create(CollectionEngineSettings *ces) } #endif +static const DrawEngineDataSize SCULPT_data_size = DRW_VIEWPORT_DATA_SIZE(SCULPT_Data); + DrawEngineType draw_engine_sculpt_type = { NULL, NULL, N_("SculptMode"), + &SCULPT_data_size, &SCULPT_engine_init, &SCULPT_engine_free, &SCULPT_cache_init, |