--- deliantra/Deliantra-Client/rendercache.c 2018/11/18 03:06:13 1.11 +++ deliantra/Deliantra-Client/rendercache.c 2018/11/19 01:23:01 1.15 @@ -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 () @@ -54,8 +56,8 @@ void v2f (float x, float y) { auto &vec = append (); - vec[0] = x; - vec[1] = y; + vec[0] = x / 2; + vec[1] = y / 2; } void t2f_v3f (float u, float v, float x, float y, float z) @@ -84,10 +86,12 @@ } }; + int drawcount = 0; ska::flat_hash_map 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 (); } };