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
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/draw/engines/gpencil/gpencil_engine.h')
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_engine.h95
1 files changed, 70 insertions, 25 deletions
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index 8e68fdef952..0fe25ba9f0f 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -40,7 +40,10 @@ struct RenderLayer;
#define GPENCIL_CACHE_BLOCK_SIZE 8
#define GPENCIL_MAX_SHGROUPS 65536
-#define GPENCIL_MIN_BATCH_SLOTS_CHUNK 16
+#define GPENCIL_GROUPS_BLOCK_SIZE 1024
+
+/* used to expand VBOs. Size has a big impact in the speed */
+#define GPENCIL_VBO_BLOCK_SIZE 128
#define GPENCIL_COLOR_SOLID 0
#define GPENCIL_COLOR_TEXTURE 1
@@ -60,7 +63,8 @@ struct RenderLayer;
typedef struct tGPencilObjectCache {
struct Object *ob;
struct bGPdata *gpd;
- int init_grp, end_grp;
+ DRWShadingGroup *init_grp;
+ DRWShadingGroup *end_grp;
int idx; /*original index, can change after sort */
/* effects */
@@ -82,8 +86,10 @@ typedef struct tGPencilObjectCache {
float obmat[4][4];
float zdepth; /* z-depth value to sort gp object */
bool is_dup_ob; /* flag to tag duplicate objects */
- bool is_dup_data; /* other object uses datablock already */
- int data_idx; /* derived data index */
+
+ /* GPU data size */
+ int tot_vertex;
+ int tot_triangles;
} tGPencilObjectCache;
/* *********** LISTS *********** */
@@ -98,8 +104,6 @@ typedef struct GPENCIL_shgroup {
int fill_style;
int keep_size;
float obj_scale;
- struct DRWShadingGroup *shgrps_fill;
- struct DRWShadingGroup *shgrps_stroke;
} GPENCIL_shgroup;
typedef struct GPENCIL_Storage {
@@ -276,24 +280,57 @@ typedef struct GPENCIL_e_data {
} GPENCIL_e_data; /* Engine data */
/* GPUBatch Cache */
+typedef struct GpencilBatchCacheElem {
+ GPUBatch *batch;
+ GPUVertBuf *vbo;
+ int vbo_len;
+ /* attr ids */
+ GPUVertFormat format;
+ uint pos_id;
+ uint color_id;
+ uint thickness_id;
+ uint uvdata_id;
+
+ /* size for VBO alloc */
+ int tot_vertex;
+} GpencilBatchCacheElem;
+
+typedef struct GpencilBatchGroup {
+ bGPDlayer *gpl; /* reference to original layer */
+ bGPDframe *gpf; /* reference to original frame */
+ bGPDstroke *gps; /* reference to original stroke */
+ short type; /* type of element */
+ bool onion; /* the group is part of onion skin */
+ int vertex_idx; /* index of vertex data */
+} GpencilBatchGroup;
+
+typedef enum GpencilBatchGroup_Type {
+ eGpencilBatchGroupType_Stroke = 1,
+ eGpencilBatchGroupType_Point = 2,
+ eGpencilBatchGroupType_Fill = 3,
+ eGpencilBatchGroupType_Edit = 4,
+ eGpencilBatchGroupType_Edlin = 5,
+} GpencilBatchGroup_Type;
+
typedef struct GpencilBatchCache {
- /* For normal strokes, a variable number of batch can be needed depending of number of strokes.
- It could use the stroke number as total size, but when activate the onion skining, the number
- can change, so the size is changed dynamically.
- */
- GPUBatch **batch_stroke;
- GPUBatch **batch_fill;
- GPUBatch **batch_edit;
- GPUBatch **batch_edlin;
+ GpencilBatchCacheElem b_stroke;
+ GpencilBatchCacheElem b_point;
+ GpencilBatchCacheElem b_fill;
+ GpencilBatchCacheElem b_edit;
+ GpencilBatchCacheElem b_edlin;
/* settings to determine if cache is invalid */
bool is_dirty;
bool is_editmode;
int cache_frame;
- /* keep information about the size of the cache */
- int cache_size; /* total batch slots available */
- int cache_idx; /* current slot index */
+ /* data with the shading groups */
+ int grp_used; /* total groups in arrays */
+ int grp_size; /* max size of the array */
+ struct GpencilBatchGroup *grp_cache; /* array of elements */
+
+ int tot_layers;
+ struct bGPDframe *derived_array; /* runtime data created by modifiers */
} GpencilBatchCache;
/* general drawing functions */
@@ -302,23 +339,24 @@ struct DRWShadingGroup *DRW_gpencil_shgroup_stroke_create(
struct Object *ob, struct bGPdata *gpd, struct MaterialGPencilStyle *gp_style, int id, bool onion);
void DRW_gpencil_populate_datablock(
struct GPENCIL_e_data *e_data, void *vedata,
- struct Scene *scene,
struct Object *ob, struct tGPencilObjectCache *cache_ob);
void DRW_gpencil_populate_buffer_strokes(
struct GPENCIL_e_data *e_data, void *vedata, struct ToolSettings *ts, struct Object *ob);
void DRW_gpencil_populate_multiedit(
struct GPENCIL_e_data *e_data, void *vedata,
- struct Scene *scene, struct Object *ob, struct tGPencilObjectCache *cache_ob);
+ struct Object *ob, struct tGPencilObjectCache *cache_ob);
void DRW_gpencil_triangulate_stroke_fill(struct Object *ob, struct bGPDstroke *gps);
+void DRW_gpencil_populate_particles(struct GPENCIL_e_data *e_data, void *vedata);
void DRW_gpencil_multisample_ensure(struct GPENCIL_Data *vedata, int rect_w, int rect_h);
/* create geometry functions */
-struct GPUBatch *DRW_gpencil_get_point_geom(struct bGPDstroke *gps, short thickness, const float ink[4]);
-struct GPUBatch *DRW_gpencil_get_stroke_geom(struct bGPDstroke *gps, short thickness, const float ink[4]);
-struct GPUBatch *DRW_gpencil_get_fill_geom(struct Object *ob, struct bGPDstroke *gps, const float color[4]);
-struct GPUBatch *DRW_gpencil_get_edit_geom(struct bGPDstroke *gps, float alpha, short dflag);
-struct GPUBatch *DRW_gpencil_get_edlin_geom(struct bGPDstroke *gps, float alpha, short dflag);
+void DRW_gpencil_get_point_geom(struct GpencilBatchCacheElem *be, struct bGPDstroke *gps, short thickness, const float ink[4]);
+void DRW_gpencil_get_stroke_geom(struct GpencilBatchCacheElem *be, struct bGPDstroke *gps, short thickness, const float ink[4]);
+void DRW_gpencil_get_fill_geom(struct GpencilBatchCacheElem *be, struct Object *ob, struct bGPDstroke *gps, const float color[4]);
+void DRW_gpencil_get_edit_geom(struct GpencilBatchCacheElem *be, struct bGPDstroke *gps, float alpha, short dflag);
+void DRW_gpencil_get_edlin_geom(struct GpencilBatchCacheElem *be, struct bGPDstroke *gps, float alpha, short dflag);
+
struct GPUBatch *DRW_gpencil_get_buffer_stroke_geom(struct bGPdata *gpd, short thickness);
struct GPUBatch *DRW_gpencil_get_buffer_fill_geom(struct bGPdata *gpd);
struct GPUBatch *DRW_gpencil_get_buffer_point_geom(struct bGPdata *gpd, short thickness);
@@ -329,8 +367,15 @@ struct tGPencilObjectCache *gpencil_object_cache_add(
struct tGPencilObjectCache *cache_array, struct Object *ob,
int *gp_cache_size, int *gp_cache_used);
+/* shading groups cache functions */
+struct GpencilBatchGroup *gpencil_group_cache_add(
+ struct GpencilBatchGroup *cache_array,
+ struct bGPDlayer *gpl, struct bGPDframe *gpf, struct bGPDstroke *gps,
+ const short type, const bool onion,
+ const int vertex_idx,
+ int *grp_size, int *grp_used);
+
/* geometry batch cache functions */
-void gpencil_batch_cache_check_free_slots(struct Object *ob);
struct GpencilBatchCache *gpencil_batch_cache_get(struct Object *ob, int cfra);
/* effects */