diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2019-05-11 18:45:20 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2019-05-14 11:57:03 +0300 |
commit | 754ecd61aa28345dd474ca901b8ca60ecbd4e88a (patch) | |
tree | f67860bdf2289cc180d9224829e4805b9ac2d07a /source/blender/draw/intern/draw_cache.c | |
parent | 8406fabc87446238a1168df5d57470c84edad85f (diff) |
DRW: Change Procedural function to use a GPUBatch
This is in order to have VAO handled by thoses batches instead of using a
common VAO. Even if the VAO has no importance in these case using a batch
will help when transitioning to Vulkan.
Diffstat (limited to 'source/blender/draw/intern/draw_cache.c')
-rw-r--r-- | source/blender/draw/intern/draw_cache.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index e9896261004..c40e9772340 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -46,6 +46,9 @@ /* Batch's only (free'd as an array) */ static struct DRWShapeCache { + GPUBatch *drw_procedural_verts; + GPUBatch *drw_procedural_lines; + GPUBatch *drw_procedural_tris; GPUBatch *drw_single_vertice; GPUBatch *drw_cursor; GPUBatch *drw_cursor_only_circle; @@ -138,6 +141,54 @@ void DRW_shape_cache_reset(void) } /* -------------------------------------------------------------------- */ +/** \name Procedural Batches + * \{ */ + +GPUBatch *drw_cache_procedural_points_get(void) +{ + if (!SHC.drw_procedural_verts) { + /* TODO(fclem) get rid of this dummy VBO. */ + GPUVertFormat format = {0}; + GPU_vertformat_attr_add(&format, "dummy", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 1); + + SHC.drw_procedural_verts = GPU_batch_create_ex(GPU_PRIM_POINTS, vbo, NULL, GPU_BATCH_OWNS_VBO); + } + return SHC.drw_procedural_verts; +} + +GPUBatch *drw_cache_procedural_lines_get(void) +{ + if (!SHC.drw_procedural_lines) { + /* TODO(fclem) get rid of this dummy VBO. */ + GPUVertFormat format = {0}; + GPU_vertformat_attr_add(&format, "dummy", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 1); + + SHC.drw_procedural_lines = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); + } + return SHC.drw_procedural_lines; +} + +GPUBatch *drw_cache_procedural_triangles_get(void) +{ + if (!SHC.drw_procedural_tris) { + /* TODO(fclem) get rid of this dummy VBO. */ + GPUVertFormat format = {0}; + GPU_vertformat_attr_add(&format, "dummy", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 1); + + SHC.drw_procedural_tris = GPU_batch_create_ex(GPU_PRIM_TRIS, vbo, NULL, GPU_BATCH_OWNS_VBO); + } + return SHC.drw_procedural_tris; +} + +/** \} */ + +/* -------------------------------------------------------------------- */ /** \name Helper functions * \{ */ |