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:
authorClément Foucault <foucault.clem@gmail.com>2019-12-02 03:40:58 +0300
committerClément Foucault <foucault.clem@gmail.com>2019-12-02 15:15:52 +0300
commit9516921c05bd9fee5c94942eb8e38f47ba7e4351 (patch)
treeda007fc17bc6a02f849dae2e8f76f5ab304fe4dc /source/blender/draw/intern/draw_manager_data.c
parent1f6c3699a836d485ed37f443cd0fcd19e978dbb6 (diff)
Overlay Engine: Refactor & Cleanup
This is the unification of all overlays into one overlay engine as described in T65347. I went over all the code making it more future proof with less hacks and removing old / not relevent parts. Goals / Acheivements: - Remove internal shader usage (only drw shaders) - Remove viewportSize and viewportSizeInv and put them in gloabl ubo - Fixed some drawing issues: Missing probe option and Missing Alt+B clipping of some shader - Remove old (legacy) shaders dependancy (not using view UBO). - Less shader variation (less compilation time at first load and less patching needed for vulkan) - removed some geom shaders when I could - Remove static e_data (except shaders storage where it is OK) - Clear the way to fix some anoying limitations (dithered transparency, background image compositing etc...) - Wireframe drawing now uses the same batching capabilities as workbench & eevee (indirect drawing). - Reduced complexity, removed ~3000 Lines of code in draw (also removed a lot of unused shader in GPU). - Post AA to avoid complexity and cost of MSAA. Remaining issues: - ~~Armature edits, overlay toggles, (... others?) are not refreshing viewport after AA is complete~~ - FXAA is not the best for wires, maybe investigate SMAA - Maybe do something more temporally stable for AA. - ~~Paint overlays are not working with AA.~~ - ~~infront objects are difficult to select.~~ - ~~the infront wires sometimes goes through they solid counterpart (missing clear maybe?) (toggle overlays on-off when using infront+wireframe overlay in solid shading)~~ Note: I made some decision to change slightly the appearance of some objects to simplify their drawing. Namely the empty arrows end (which is now hollow/wire) and distance points of the cameras/spots being done by lines. Reviewed By: jbakker Differential Revision: https://developer.blender.org/D6296
Diffstat (limited to 'source/blender/draw/intern/draw_manager_data.c')
-rw-r--r--source/blender/draw/intern/draw_manager_data.c64
1 files changed, 53 insertions, 11 deletions
diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c
index 330f72eda18..4b3be3ab924 100644
--- a/source/blender/draw/intern/draw_manager_data.c
+++ b/source/blender/draw/intern/draw_manager_data.c
@@ -506,8 +506,14 @@ static void drw_call_obinfos_init(DRWObjectInfos *ob_infos, Object *ob)
* put it in ob->runtime and make depsgraph ensure it is up to date. */
BLI_hash_int_2d(BLI_hash_string(ob->id.name + 2), 0);
ob_infos->ob_random = random * (1.0f / (float)0xFFFFFFFF);
+ /* Object State. */
+ ob_infos->ob_flag = 1.0f; /* Required to have a correct sign */
+ ob_infos->ob_flag += (ob->base_flag & BASE_SELECTED) ? (1 << 1) : 0;
+ ob_infos->ob_flag += (ob->base_flag & BASE_FROM_DUPLI) ? (1 << 2) : 0;
+ ob_infos->ob_flag += (ob->base_flag & BASE_FROM_SET) ? (1 << 3) : 0;
+ ob_infos->ob_flag += (ob == DST.draw_ctx.obact) ? (1 << 4) : 0;
/* Negative scalling. */
- ob_infos->ob_neg_scale = (ob->transflag & OB_NEG_SCALE) ? -1.0f : 1.0f;
+ ob_infos->ob_flag *= (ob->transflag & OB_NEG_SCALE) ? -1.0f : 1.0f;
/* Object Color. */
copy_v4_v4(ob_infos->ob_color, ob->color);
}
@@ -643,12 +649,14 @@ static void drw_command_draw_range(DRWShadingGroup *shgroup,
static void drw_command_draw_instance(DRWShadingGroup *shgroup,
GPUBatch *batch,
DRWResourceHandle handle,
- uint count)
+ uint count,
+ bool use_attrib)
{
DRWCommandDrawInstance *cmd = drw_command_create(shgroup, DRW_CMD_DRAW_INSTANCE);
cmd->batch = batch;
cmd->handle = handle;
cmd->inst_count = count;
+ cmd->use_attribs = use_attrib;
}
static void drw_command_draw_procedural(DRWShadingGroup *shgroup,
@@ -788,7 +796,7 @@ void DRW_shgroup_call_instances(DRWShadingGroup *shgroup,
drw_command_set_select_id(shgroup, NULL, DST.select_id);
}
DRWResourceHandle handle = drw_resource_handle(shgroup, ob ? ob->obmat : NULL, ob);
- drw_command_draw_instance(shgroup, geom, handle, count);
+ drw_command_draw_instance(shgroup, geom, handle, count, false);
}
void DRW_shgroup_call_instances_with_attribs(DRWShadingGroup *shgroup,
@@ -797,14 +805,13 @@ void DRW_shgroup_call_instances_with_attribs(DRWShadingGroup *shgroup,
struct GPUBatch *inst_attributes)
{
BLI_assert(geom != NULL);
- BLI_assert(inst_attributes->verts[0] != NULL);
+ BLI_assert(inst_attributes != NULL);
if (G.f & G_FLAG_PICKSEL) {
drw_command_set_select_id(shgroup, NULL, DST.select_id);
}
DRWResourceHandle handle = drw_resource_handle(shgroup, ob ? ob->obmat : NULL, ob);
- GPUVertBuf *buf_inst = inst_attributes->verts[0];
- GPUBatch *batch = DRW_temp_batch_instance_request(DST.idatalist, buf_inst, geom);
- drw_command_draw(shgroup, batch, handle);
+ GPUBatch *batch = DRW_temp_batch_instance_request(DST.idatalist, NULL, inst_attributes, geom);
+ drw_command_draw_instance(shgroup, batch, handle, 0, true);
}
#define SCULPT_DEBUG_BUFFERS (G.debug_value == 889)
@@ -1027,12 +1034,33 @@ DRWCallBuffer *DRW_shgroup_call_buffer_instance(DRWShadingGroup *shgroup,
}
DRWResourceHandle handle = drw_resource_handle(shgroup, NULL, NULL);
- GPUBatch *batch = DRW_temp_batch_instance_request(DST.idatalist, callbuf->buf, geom);
+ GPUBatch *batch = DRW_temp_batch_instance_request(DST.idatalist, callbuf->buf, NULL, geom);
drw_command_draw(shgroup, batch, handle);
return callbuf;
}
+void DRW_buffer_add_entry_struct(DRWCallBuffer *callbuf, const void *data)
+{
+ GPUVertBuf *buf = callbuf->buf;
+ const bool resize = (callbuf->count == buf->vertex_alloc);
+
+ if (UNLIKELY(resize)) {
+ GPU_vertbuf_data_resize(buf, callbuf->count + DRW_BUFFER_VERTS_CHUNK);
+ }
+
+ GPU_vertbuf_vert_set(buf, callbuf->count, data);
+
+ if (G.f & G_FLAG_PICKSEL) {
+ if (UNLIKELY(resize)) {
+ GPU_vertbuf_data_resize(callbuf->buf_select, callbuf->count + DRW_BUFFER_VERTS_CHUNK);
+ }
+ GPU_vertbuf_attr_set(callbuf->buf_select, 0, callbuf->count, &DST.select_id);
+ }
+
+ callbuf->count++;
+}
+
void DRW_buffer_add_entry_array(DRWCallBuffer *callbuf, const void *attr[], uint attr_len)
{
GPUVertBuf *buf = callbuf->buf;
@@ -1595,13 +1623,17 @@ DRWView *DRW_view_create_sub(const DRWView *parent_view,
const float viewmat[4][4],
const float winmat[4][4])
{
- BLI_assert(parent_view && parent_view->parent == NULL);
+ /* Search original parent. */
+ const DRWView *ori_view = parent_view;
+ while (ori_view->parent != NULL) {
+ ori_view = ori_view->parent;
+ }
DRWView *view = BLI_memblock_alloc(DST.vmempool->views);
/* Perform copy. */
- *view = *parent_view;
- view->parent = (DRWView *)parent_view;
+ *view = *ori_view;
+ view->parent = (DRWView *)ori_view;
DRW_view_update_sub(view, viewmat, winmat);
@@ -1929,4 +1961,14 @@ void DRW_pass_sort_shgroup_z(DRWPass *pass)
pass->shgroups.last = last;
}
+/**
+ * Reverse Shading group submission order.
+ */
+void DRW_pass_sort_shgroup_reverse(DRWPass *pass)
+{
+ pass->shgroups.last = pass->shgroups.first;
+ /* WARNING: Assume that DRWShadingGroup->next is the first member. */
+ BLI_linklist_reverse((LinkNode **)&pass->shgroups.first);
+}
+
/** \} */