diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2019-05-13 18:56:20 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2019-05-14 11:57:03 +0300 |
commit | 8bc8a62c57f91326ab3f8850785dce5452b5d703 (patch) | |
tree | c578b9786bc3e519f36f782cd74abd77ad52b344 /source/blender/draw/intern/DRW_render.h | |
parent | 20d9cd3a1fbd763dbe002e9baf2e3ba7fbb66f2f (diff) |
DRW: Refactor: Use DRWCall to accumulate per instance attributes
This is a big change that cleanup a lot of confusing code.
- The instancing/batching data buffer distribution in draw_instance_data.c.
- The selection & drawing code in draw_manager_exec.c
- Prety much every non-meshes object drawing (object_mode.c).
Most of the changes are just renaming but there still a chance a typo might
have sneek through.
The Batching/Instancing Shading groups are replace by DRWCallBuffers. This
is cleaner and conceptually more in line with what a DRWShadingGroup should
be.
There is still some little confusion in draw_common.c where some function
takes shgroup as input and some don't.
Diffstat (limited to 'source/blender/draw/intern/DRW_render.h')
-rw-r--r-- | source/blender/draw/intern/DRW_render.h | 75 |
1 files changed, 35 insertions, 40 deletions
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index 1c943c18ed3..401ed50c1dc 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -44,6 +44,7 @@ #include "DNA_world_types.h" #include "GPU_framebuffer.h" +#include "GPU_primitive.h" #include "GPU_texture.h" #include "GPU_shader.h" @@ -83,6 +84,9 @@ typedef struct DRWPass DRWPass; typedef struct DRWShadingGroup DRWShadingGroup; typedef struct DRWUniform DRWUniform; +/* Opaque type to avoid usage as a DRWCall but it is exactly the same thing. */ +typedef struct DRWCallBuffer DRWCallBuffer; + /* TODO Put it somewhere else? */ typedef struct BoundSphere { float center[3], radius; @@ -319,8 +323,8 @@ typedef enum { DRW_STATE_DEPTH_GREATER_EQUAL = (1 << 7), DRW_STATE_CULL_BACK = (1 << 8), DRW_STATE_CULL_FRONT = (1 << 9), - DRW_STATE_WIRE = (1 << 10), - DRW_STATE_POINT = (1 << 11), + DRW_STATE_WIRE = (1 << 10), /* TODO remove */ + DRW_STATE_POINT = (1 << 11), /* TODO remove */ /** Polygon offset. Does not work with lines and points. */ DRW_STATE_OFFSET_POSITIVE = (1 << 12), /** Polygon offset. Does not work with lines and points. */ @@ -374,19 +378,11 @@ struct GPUVertFormat *DRW_shgroup_instance_format_array(const DRWInstanceAttrFor } \ } while (0) +/* TODO(fclem): Remove the _create suffix. */ DRWShadingGroup *DRW_shgroup_create(struct GPUShader *shader, DRWPass *pass); DRWShadingGroup *DRW_shgroup_create_sub(DRWShadingGroup *shgroup); DRWShadingGroup *DRW_shgroup_material_create(struct GPUMaterial *material, DRWPass *pass); -DRWShadingGroup *DRW_shgroup_instance_create(struct GPUShader *shader, - DRWPass *pass, - struct GPUBatch *geom, - struct GPUVertFormat *format); -DRWShadingGroup *DRW_shgroup_point_batch_create(struct GPUShader *shader, DRWPass *pass); -DRWShadingGroup *DRW_shgroup_line_batch_create_with_format(struct GPUShader *shader, - DRWPass *pass, - struct GPUVertFormat *format); -DRWShadingGroup *DRW_shgroup_line_batch_create(struct GPUShader *shader, DRWPass *pass); DRWShadingGroup *DRW_shgroup_transform_feedback_create(struct GPUShader *shader, DRWPass *pass, struct GPUVertBuf *tf_target); @@ -394,20 +390,17 @@ DRWShadingGroup *DRW_shgroup_transform_feedback_create(struct GPUShader *shader, /* return final visibility */ typedef bool(DRWCallVisibilityFn)(bool vis_in, void *user_data); -void DRW_shgroup_instance_batch(DRWShadingGroup *shgroup, struct GPUBatch *batch); - -void DRW_shgroup_call_add(DRWShadingGroup *shgroup, struct GPUBatch *geom, float (*obmat)[4]); +/* TODO(fclem): Remove the _add suffix. */ +void DRW_shgroup_call_add(DRWShadingGroup *sh, struct GPUBatch *geom, float (*obmat)[4]); void DRW_shgroup_call_range_add( - DRWShadingGroup *shgroup, struct GPUBatch *geom, float (*obmat)[4], uint v_sta, uint v_count); -void DRW_shgroup_call_procedural_points_add(DRWShadingGroup *shgroup, - uint point_len, - float (*obmat)[4]); -void DRW_shgroup_call_procedural_lines_add(DRWShadingGroup *shgroup, - uint line_count, - float (*obmat)[4]); -void DRW_shgroup_call_procedural_triangles_add(DRWShadingGroup *shgroup, - uint tria_count, + DRWShadingGroup *sh, struct GPUBatch *geom, float (*obmat)[4], uint v_sta, uint v_ct); + +void DRW_shgroup_call_procedural_points_add(DRWShadingGroup *sh, uint point_ct, float (*obmat)[4]); +void DRW_shgroup_call_procedural_lines_add(DRWShadingGroup *sh, uint line_ct, float (*obmat)[4]); +void DRW_shgroup_call_procedural_triangles_add(DRWShadingGroup *sh, + uint tri_ct, float (*obmat)[4]); + void DRW_shgroup_call_object_add_ex(DRWShadingGroup *shgroup, struct GPUBatch *geom, struct Object *ob, @@ -422,31 +415,33 @@ void DRW_shgroup_call_object_add_with_callback(DRWShadingGroup *shgroup, DRWCallVisibilityFn *callback, void *user_data); -void DRW_shgroup_call_sculpt_add(DRWShadingGroup *shading_group, - Object *object, - bool use_wire, - bool use_mask, - bool use_vert_color); -void DRW_shgroup_call_sculpt_with_materials_add(DRWShadingGroup **shgroups, - Object *ob, - bool use_vcol); - -/* Used for drawing a batch with instancing without instance attributes. */ void DRW_shgroup_call_instances_add(DRWShadingGroup *shgroup, struct GPUBatch *geom, float (*obmat)[4], uint count); -void DRW_shgroup_call_dynamic_add_array(DRWShadingGroup *shgroup, - const void *attr[], - uint attr_len); -#define DRW_shgroup_call_dynamic_add(shgroup, ...) \ +void DRW_shgroup_call_instances_with_attribs_add(DRWShadingGroup *shgroup, + struct GPUBatch *geom, + float (*obmat)[4], + struct GPUBatch *inst_attributes); + +void DRW_shgroup_call_sculpt_add(DRWShadingGroup *sh, Object *ob, bool wire, bool mask, bool vcol); +void DRW_shgroup_call_sculpt_with_materials_add(DRWShadingGroup **sh, Object *ob, bool vcol); + +DRWCallBuffer *DRW_shgroup_call_buffer_add(DRWShadingGroup *shading_group, + struct GPUVertFormat *format, + GPUPrimType prim_type); +DRWCallBuffer *DRW_shgroup_call_buffer_instance_add(DRWShadingGroup *shading_group, + struct GPUVertFormat *format, + struct GPUBatch *geom); + +void DRW_buffer_add_entry_array(DRWCallBuffer *buffer, const void *attr[], uint attr_len); + +#define DRW_buffer_add_entry(buffer, ...) \ do { \ const void *array[] = {__VA_ARGS__}; \ - DRW_shgroup_call_dynamic_add_array(shgroup, array, (sizeof(array) / sizeof(*array))); \ + DRW_buffer_add_entry_array(buffer, array, (sizeof(array) / sizeof(*array))); \ } while (0) -uint DRW_shgroup_get_instance_count(const DRWShadingGroup *shgroup); - void DRW_shgroup_state_enable(DRWShadingGroup *shgroup, DRWState state); void DRW_shgroup_state_disable(DRWShadingGroup *shgroup, DRWState state); void DRW_shgroup_stencil_mask(DRWShadingGroup *shgroup, uint mask); |