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>2018-12-07 07:03:01 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-12-07 07:33:53 +0300
commite929cad7067875bb2f1815a01daae32e441f99b7 (patch)
treee20a4173feb9ebef5b217f4234a6f7d9866a3d6b /source/blender/draw/intern/draw_cache_impl_metaball.c
parent9f5a27c5be0a0f6a9f36360e618dcf5254ae689e (diff)
DRW: Rework wireframe overlay implementation
The shader is way simpler and run way faster on lower end hardware (2x faster on intel HD5000) but did not notice any improvement on AMD Vega. This also adds a few changes to the way the wireframes are drawn: - the slider is more linearly progressive. - optimize display shows all wires and progressively decrease "inner" wires intensity. This is subject to change in the future. - text/surface/metaballs support is pretty rough. More work needs to be done. This remove the optimization introduced in f1975a46390a5bf85bb7012375f9bc1e761fc516. This also removes the GPU side "sharpness" calculation which means that animated meshes with wireframe display will update slower. The CPU sharpness calculation has still room for optimization. Also it is not excluded that GPU calculation can be added back as a separate preprocessing pass (saving the computation result [compute or feedback]). The goal here was to have more speed for static objects and remove the dependency of having buffer textures with triangle count. This is preparation work for multithreading the whole DRW manager.
Diffstat (limited to 'source/blender/draw/intern/draw_cache_impl_metaball.c')
-rw-r--r--source/blender/draw/intern/draw_cache_impl_metaball.c66
1 files changed, 10 insertions, 56 deletions
diff --git a/source/blender/draw/intern/draw_cache_impl_metaball.c b/source/blender/draw/intern/draw_cache_impl_metaball.c
index 17ca9ec317e..10f5db42bf1 100644
--- a/source/blender/draw/intern/draw_cache_impl_metaball.c
+++ b/source/blender/draw/intern/draw_cache_impl_metaball.c
@@ -59,10 +59,7 @@ typedef struct MetaBallBatchCache {
/* Wireframe */
struct {
- GPUVertBuf *elem_vbo;
- GPUTexture *elem_tx;
- GPUTexture *verts_tx;
- int tri_count;
+ GPUBatch *batch;
} face_wire;
/* settings to determine if cache is invalid */
@@ -94,10 +91,7 @@ static void metaball_batch_cache_init(MetaBall *mb)
cache->shaded_triangles = NULL;
cache->is_dirty = false;
cache->pos_nor_in_order = NULL;
- cache->face_wire.elem_vbo = NULL;
- cache->face_wire.elem_tx = NULL;
- cache->face_wire.verts_tx = NULL;
- cache->face_wire.tri_count = 0;
+ cache->face_wire.batch = NULL;
}
static MetaBallBatchCache *metaball_batch_cache_get(MetaBall *mb)
@@ -131,10 +125,7 @@ static void metaball_batch_cache_clear(MetaBall *mb)
return;
}
- GPU_VERTBUF_DISCARD_SAFE(cache->face_wire.elem_vbo);
- DRW_TEXTURE_FREE_SAFE(cache->face_wire.elem_tx);
- DRW_TEXTURE_FREE_SAFE(cache->face_wire.verts_tx);
-
+ GPU_BATCH_DISCARD_SAFE(cache->face_wire.batch);
GPU_BATCH_DISCARD_SAFE(cache->batch);
GPU_VERTBUF_DISCARD_SAFE(cache->pos_nor_in_order);
/* Note: shaded_triangles[0] is already freed by cache->batch */
@@ -157,36 +148,6 @@ static GPUVertBuf *mball_batch_cache_get_pos_and_normals(Object *ob, MetaBallBat
return cache->pos_nor_in_order;
}
-static GPUTexture *mball_batch_cache_get_edges_overlay_texture_buf(Object *ob, MetaBallBatchCache *cache)
-{
- if (cache->face_wire.elem_tx != NULL) {
- return cache->face_wire.elem_tx;
- }
-
- ListBase *lb = &ob->runtime.curve_cache->disp;
-
- /* We need a special index buffer. */
- GPUVertBuf *vbo = cache->face_wire.elem_vbo = DRW_displist_create_edges_overlay_texture_buf(lb);
-
- /* Upload data early because we need to create the texture for it. */
- GPU_vertbuf_use(vbo);
- cache->face_wire.elem_tx = GPU_texture_create_from_vertbuf(vbo);
- cache->face_wire.tri_count = vbo->vertex_alloc / 3;
-
- return cache->face_wire.elem_tx;
-}
-
-static GPUTexture *mball_batch_cache_get_vert_pos_and_nor_in_order_buf(Object *ob, MetaBallBatchCache *cache)
-{
- if (cache->face_wire.verts_tx == NULL) {
- GPUVertBuf *vbo = mball_batch_cache_get_pos_and_normals(ob, cache);
- GPU_vertbuf_use(vbo); /* Upload early for buffer texture creation. */
- cache->face_wire.verts_tx = GPU_texture_create_buffer(GPU_R32F, vbo->vbo_id);
- }
-
- return cache->face_wire.verts_tx;
-}
-
/* -------------------------------------------------------------------- */
/** \name Public Object/MetaBall API
@@ -232,26 +193,19 @@ GPUBatch **DRW_metaball_batch_cache_get_surface_shaded(Object *ob, MetaBall *mb,
}
-void DRW_metaball_batch_cache_get_wireframes_face_texbuf(
- Object *ob, struct GPUTexture **verts_data, struct GPUTexture **face_indices, int *tri_count, bool UNUSED(reduce_len))
+GPUBatch *DRW_metaball_batch_cache_get_wireframes_face(Object *ob)
{
if (!BKE_mball_is_basis(ob)) {
- *verts_data = NULL;
- *face_indices = NULL;
- *tri_count = 0;
- return;
+ return NULL;
}
MetaBall *mb = ob->data;
MetaBallBatchCache *cache = metaball_batch_cache_get(mb);
- if (cache->face_wire.verts_tx == NULL) {
- *verts_data = mball_batch_cache_get_vert_pos_and_nor_in_order_buf(ob, cache);
- *face_indices = mball_batch_cache_get_edges_overlay_texture_buf(ob, cache);
- }
- else {
- *verts_data = cache->face_wire.verts_tx;
- *face_indices = cache->face_wire.elem_tx;
+ if (cache->face_wire.batch == NULL) {
+ ListBase *lb = &ob->runtime.curve_cache->disp;
+ cache->face_wire.batch = DRW_displist_create_edges_overlay_batch(lb);
}
- *tri_count = cache->face_wire.tri_count;
+
+ return cache->face_wire.batch;
}