--- deliantra/Deliantra-Client/rendercache.c 2018/11/18 03:10:35 1.12 +++ deliantra/Deliantra-Client/rendercache.c 2018/11/19 01:37:28 1.16 @@ -1,5 +1,7 @@ #include +#include "salloc.h" + struct rc_key_t { GLenum mode; @@ -39,9 +41,9 @@ }; struct array_t - : std::vector + : std::vector> { - using std::vector::vector; + using std::vector>::vector; template T &append () @@ -84,10 +86,12 @@ } }; - ska::flat_hash_map h; + int drawcount = 0; + ska::flat_hash_map, std::equal_to, slice_allocator> h; void clear () { + drawcount = 0; h.clear (); } @@ -128,7 +132,7 @@ else { // optimised character quad storage. slower but nice on memory. - // reduces storage requirements from 80 bytes/char to 6-8 + // reduces storage requirements from 80 bytes/char to 8 auto *c = (glyph_data *) arr.data (); auto *e = (glyph_data *)(arr.data () + arr.size ()); @@ -149,6 +153,10 @@ } glDisable (GL_TEXTURE_2D); + + if (ecb_expect_false (++drawcount == 16)) + for (auto &&it = h.begin (); it != h.end (); ++it) + it->second.shrink_to_fit (); } };