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-06-18 23:25:37 +0300
committerClément Foucault <foucault.clem@gmail.com>2019-06-18 23:28:31 +0300
commitba152cc88d945af0392d36ce62452a277ba37e03 (patch)
tree2e0219f126496d7584d9b80f3a26bfe75a57309e
parent82f569d75e68a3e7e3f2435e17fa16e9a47376f4 (diff)
MeshBatchCache: Speedup: Do not return valid batch if geometry is empty
There was a huge overhead of batches that had no geometry. The loose wire batch was the culprit.
-rw-r--r--source/blender/draw/intern/draw_cache_impl_mesh.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c
index 961602625f0..f4acb586c5e 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -2059,6 +2059,8 @@ typedef struct MeshBatchCache {
/* Valid only if edge_detection is up to date. */
bool is_manifold;
+
+ bool no_loose_wire;
} MeshBatchCache;
BLI_INLINE void mesh_batch_cache_add_request(MeshBatchCache *cache, DRWBatchFlag new_flag)
@@ -3850,6 +3852,7 @@ static void mesh_create_loops_line_strips(MeshRenderData *rdata,
static void mesh_create_loose_edges_lines(MeshRenderData *rdata,
GPUIndexBuf *ibo,
+ bool *r_no_loose_wire,
const bool use_hide)
{
const int vert_len = mesh_render_data_verts_len_get_maybe_mapped(rdata);
@@ -3892,6 +3895,8 @@ static void mesh_create_loose_edges_lines(MeshRenderData *rdata,
}
}
+ *r_no_loose_wire = (elb.index_len == 0);
+
GPU_indexbuf_build_in_place(&elb, ibo);
}
@@ -4291,7 +4296,12 @@ GPUBatch *DRW_mesh_batch_cache_get_loose_edges(Mesh *me)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
mesh_batch_cache_add_request(cache, MBC_LOOSE_EDGES);
- return DRW_batch_request(&cache->batch.loose_edges);
+ if (cache->no_loose_wire) {
+ return NULL;
+ }
+ else {
+ return DRW_batch_request(&cache->batch.loose_edges);
+ }
}
GPUBatch *DRW_mesh_batch_cache_get_surface_weights(Mesh *me)
@@ -5304,7 +5314,8 @@ void DRW_mesh_batch_cache_create_requested(
rdata, cache->ibo.edges_adj_lines, &cache->is_manifold, use_hide);
}
if (DRW_ibo_requested(cache->ibo.loose_edges_lines)) {
- mesh_create_loose_edges_lines(rdata, cache->ibo.loose_edges_lines, use_hide);
+ mesh_create_loose_edges_lines(
+ rdata, cache->ibo.loose_edges_lines, &cache->no_loose_wire, use_hide);
}
if (DRW_ibo_requested(cache->ibo.surf_tris)) {
mesh_create_surf_tris(rdata, cache->ibo.surf_tris, use_hide);