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_curve.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_curve.c')
-rw-r--r--source/blender/draw/intern/draw_cache_impl_curve.c59
1 files changed, 8 insertions, 51 deletions
diff --git a/source/blender/draw/intern/draw_cache_impl_curve.c b/source/blender/draw/intern/draw_cache_impl_curve.c
index 79d94ef15d8..6f5fb177a64 100644
--- a/source/blender/draw/intern/draw_cache_impl_curve.c
+++ b/source/blender/draw/intern/draw_cache_impl_curve.c
@@ -325,10 +325,7 @@ typedef struct CurveBatchCache {
/* Wireframes */
struct {
- GPUVertBuf *elem_vbo;
- GPUTexture *elem_tx;
- GPUTexture *verts_tx;
- uint tri_count;
+ GPUBatch *batch;
} face_wire;
/* 3d text */
@@ -450,10 +447,7 @@ static void curve_batch_cache_clear(Curve *cu)
GPU_BATCH_DISCARD_ARRAY_SAFE(cache->surface.shaded_triangles, cache->surface.mat_len);
GPU_BATCH_DISCARD_SAFE(cache->surface.batch);
- 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);
- cache->face_wire.tri_count = 0;
+ GPU_BATCH_DISCARD_SAFE(cache->face_wire.batch);
/* don't own vbo & elems */
GPU_BATCH_DISCARD_SAFE(cache->wire.batch);
@@ -801,40 +795,6 @@ static GPUBatch *curve_batch_cache_get_pos_and_normals(CurveRenderData *rdata, C
return cache->surface.batch;
}
-static GPUTexture *curve_batch_cache_get_edges_overlay_texture_buf(CurveRenderData *rdata, CurveBatchCache *cache)
-{
- BLI_assert(rdata->types & CU_DATATYPE_SURFACE);
-
- if (cache->face_wire.elem_tx != NULL) {
- return cache->face_wire.elem_tx;
- }
-
- ListBase *lb = &rdata->ob_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 *curve_batch_cache_get_vert_pos_and_nor_in_order_buf(CurveRenderData *rdata, CurveBatchCache *cache)
-{
- BLI_assert(rdata->types & CU_DATATYPE_SURFACE);
-
- if (cache->face_wire.verts_tx == NULL) {
- curve_batch_cache_get_pos_and_normals(rdata, cache);
- GPU_vertbuf_use(cache->surface.verts); /* Upload early for buffer texture creation. */
- cache->face_wire.verts_tx = GPU_texture_create_buffer(GPU_R32F, cache->surface.verts->vbo_id);
- }
-
- return cache->face_wire.verts_tx;
-}
-
/** \} */
@@ -1074,24 +1034,21 @@ GPUBatch **DRW_curve_batch_cache_get_surface_shaded(
return cache->surface.shaded_triangles;
}
-void DRW_curve_batch_cache_get_wireframes_face_texbuf(
- Curve *cu, CurveCache *ob_curve_cache,
- GPUTexture **verts_data, GPUTexture **face_indices, int *tri_count, bool UNUSED(reduce_len))
+GPUBatch *DRW_curve_batch_cache_get_wireframes_face(Curve *cu, CurveCache *ob_curve_cache)
{
CurveBatchCache *cache = curve_batch_cache_get(cu);
- if (cache->face_wire.elem_tx == NULL || cache->face_wire.verts_tx == NULL) {
+ if (cache->face_wire.batch == NULL) {
CurveRenderData *rdata = curve_render_data_create(cu, ob_curve_cache, CU_DATATYPE_SURFACE);
- curve_batch_cache_get_edges_overlay_texture_buf(rdata, cache);
- curve_batch_cache_get_vert_pos_and_nor_in_order_buf(rdata, cache);
+ ListBase *lb = &rdata->ob_curve_cache->disp;
+
+ cache->face_wire.batch = DRW_displist_create_edges_overlay_batch(lb);
curve_render_data_free(rdata);
}
- *tri_count = cache->face_wire.tri_count;
- *face_indices = cache->face_wire.elem_tx;
- *verts_data = cache->face_wire.verts_tx;
+ return cache->face_wire.batch;
}
/* -------------------------------------------------------------------- */