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-07-14 17:49:44 +0300
committerClément Foucault <foucault.clem@gmail.com>2019-08-14 20:05:26 +0300
commit9c010c44f4201ab114b3facc69d0343525a1779f (patch)
tree744271becd24cead6c900e4f023d8c0bfa6138b6 /source/blender/draw/modes/edit_mesh_mode.c
parent45a45f7d66211e82a3a3288782ad9523e8fdc516 (diff)
Mesh Batch Cache: Refactor + Multithread
For clarity sake, the batch cache now uses exclusively per Loop attributes. While this is a bit of a waste of VRAM (for the few case where per vert attribs are enough) it reduces the complexity and amount of overall VBO to update in general situations. This patch also makes the VertexBuffers filling multithreaded. This make the update of dense meshes a bit faster. The main bottleneck is the IndexBuffers update which cannot be multithreaded efficiently (have to increment a counter and/or do a final sorting pass). We introduce the concept of "extract" functions/step. All extract functions are executed in one thread each and if possible, using multiple thread for looping over all elements. Reviewed By: brecht Differential Revision: http://developer.blender.org/D5424
Diffstat (limited to 'source/blender/draw/modes/edit_mesh_mode.c')
-rw-r--r--source/blender/draw/modes/edit_mesh_mode.c35
1 files changed, 10 insertions, 25 deletions
diff --git a/source/blender/draw/modes/edit_mesh_mode.c b/source/blender/draw/modes/edit_mesh_mode.c
index f0e35e47a66..f8247d7929e 100644
--- a/source/blender/draw/modes/edit_mesh_mode.c
+++ b/source/blender/draw/modes/edit_mesh_mode.c
@@ -128,8 +128,7 @@ typedef struct EDIT_MESH_Shaders {
GPUShader *depth;
/* Mesh analysis shader */
- GPUShader *mesh_analysis_face;
- GPUShader *mesh_analysis_vertex;
+ GPUShader *mesh_analysis;
} EDIT_MESH_Shaders;
/* *********** STATIC *********** */
@@ -307,15 +306,9 @@ static void EDIT_MESH_engine_init(void *vedata)
});
/* Mesh Analysis */
- sh_data->mesh_analysis_face = GPU_shader_create_from_arrays({
+ sh_data->mesh_analysis = GPU_shader_create_from_arrays({
.vert = (const char *[]){lib, datatoc_edit_mesh_overlay_mesh_analysis_vert_glsl, NULL},
.frag = (const char *[]){datatoc_edit_mesh_overlay_mesh_analysis_frag_glsl, NULL},
- .defs = (const char *[]){sh_cfg_data->def, "#define FACE_COLOR\n", NULL},
- });
- sh_data->mesh_analysis_vertex = GPU_shader_create_from_arrays({
- .vert = (const char *[]){lib, datatoc_edit_mesh_overlay_mesh_analysis_vert_glsl, NULL},
- .frag = (const char *[]){datatoc_edit_mesh_overlay_mesh_analysis_frag_glsl, NULL},
- .defs = (const char *[]){sh_cfg_data->def, "#define VERTEX_COLOR\n", NULL},
});
MEM_freeN(lib);
@@ -548,10 +541,9 @@ static void EDIT_MESH_cache_init(void *vedata)
/* Mesh Analysis Pass */
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND_ALPHA;
psl->mesh_analysis_pass = DRW_pass_create("Mesh Analysis", state);
- const bool is_vertex_color = scene->toolsettings->statvis.type == SCE_STATVIS_SHARP;
- g_data->mesh_analysis_shgrp = DRW_shgroup_create(
- is_vertex_color ? sh_data->mesh_analysis_vertex : sh_data->mesh_analysis_face,
- psl->mesh_analysis_pass);
+ g_data->mesh_analysis_shgrp = DRW_shgroup_create(sh_data->mesh_analysis,
+ psl->mesh_analysis_pass);
+ DRW_shgroup_uniform_texture(g_data->mesh_analysis_shgrp, "weightTex", G_draw.weight_ramp);
if (rv3d->rflag & RV3D_CLIPPING) {
DRW_shgroup_state_enable(g_data->mesh_analysis_shgrp, DRW_STATE_CLIP_PLANES);
}
@@ -704,17 +696,10 @@ static void EDIT_MESH_cache_populate(void *vedata, Object *ob)
geom = DRW_cache_mesh_surface_weights_get(ob);
DRW_shgroup_call_no_cull(g_data->fweights_shgrp, geom, ob);
}
-
- if (do_show_mesh_analysis && !XRAY_ACTIVE(v3d)) {
- Mesh *me = (Mesh *)ob->data;
- BMEditMesh *embm = me->edit_mesh;
- const bool is_original = embm->mesh_eval_final &&
- (embm->mesh_eval_final->runtime.is_original == true);
- if (is_original) {
- geom = DRW_cache_mesh_surface_mesh_analysis_get(ob);
- if (geom) {
- DRW_shgroup_call_no_cull(g_data->mesh_analysis_shgrp, geom, ob);
- }
+ else if (do_show_mesh_analysis && !XRAY_ACTIVE(v3d)) {
+ geom = DRW_cache_mesh_surface_mesh_analysis_get(ob);
+ if (geom) {
+ DRW_shgroup_call_no_cull(g_data->mesh_analysis_shgrp, geom, ob);
}
}
@@ -727,7 +712,7 @@ static void EDIT_MESH_cache_populate(void *vedata, Object *ob)
}
if (vnormals_do) {
- geom = DRW_mesh_batch_cache_get_edit_vertices(ob->data);
+ geom = DRW_mesh_batch_cache_get_edit_vnors(ob->data);
DRW_shgroup_call_no_cull(g_data->vnormals_shgrp, geom, ob);
}
if (lnormals_do) {