diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-03-30 20:16:14 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-03-30 21:09:26 +0300 |
commit | ab9adf9cdc3b2fd91dcade32ea4b4359f4897392 (patch) | |
tree | 1f9e12d6a24fa1f74cfc4ab595ac1680d0202433 /source/blender/blenfont/intern/blf_glyph.c | |
parent | 8568d38f1b0858a3138b72698babd6ba7b65d6b3 (diff) |
BLF: Use Batch API instead of IMM.
This is not a perfect win just yet. It's now calling glBufferSubData for
every call (instead of using glMapBufferRange which is almost faster), but
with this system we will be able to batch drawcalls together.
See next commit.
Diffstat (limited to 'source/blender/blenfont/intern/blf_glyph.c')
-rw-r--r-- | source/blender/blenfont/intern/blf_glyph.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 5e1debf1501..b91eceac817 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -63,6 +63,7 @@ #include "blf_internal.h" #include "BLI_strict_flags.h" +#include "BLI_math_vector.h" GlyphCacheBLF *blf_glyph_cache_find(FontBLF *font, unsigned int size, unsigned int dpi) { @@ -316,13 +317,19 @@ void blf_glyph_free(GlyphBLF *g) MEM_freeN(g); } -static void blf_texture_draw(const unsigned char color[4], float uv[2][2], float dx, float y1, float dx1, float y2) +static void blf_texture_draw(const unsigned char color[4], float uv[2][2], float x1, float y1, float x2, float y2) { + if (g_batch.glyph_ct == BLF_BATCHING_SIZE) { + blf_batching_draw(); + blf_batching_start(g_batch.font); + } + g_batch.glyph_ct++; /* Only one vertex per glyph, geometry shader expand it into a quad. */ /* TODO Get rid of Geom Shader because it's not optimal AT ALL for the GPU */ - immAttrib4ubv(BLF_COLOR_ID, color); - immAttrib4fv(BLF_COORD_ID, (float *)uv); - immVertex4f(BLF_POS_ID, dx, y1, dx1, y2); + copy_v4_fl4(GWN_vertbuf_raw_step(&g_batch.pos_step), x1 + g_batch.ofs[0], y1 + g_batch.ofs[1], + x2 + g_batch.ofs[0], y2 + g_batch.ofs[1]); + copy_v4_v4(GWN_vertbuf_raw_step(&g_batch.tex_step), (float *)uv); + copy_v4_v4_uchar(GWN_vertbuf_raw_step(&g_batch.col_step), color); } static void blf_texture5_draw(const unsigned char color_in[4], float uv[2][2], float x1, float y1, float x2, float y2) |