ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/rendercache.c
(Generate patch)

Comparing deliantra/Deliantra-Client/rendercache.c (file contents):
Revision 1.12 by root, Sun Nov 18 03:10:35 2018 UTC vs.
Revision 1.15 by root, Mon Nov 19 01:23:01 2018 UTC

1#include <vector> 1#include <vector>
2
3#include "salloc.h"
2 4
3struct rc_key_t 5struct rc_key_t
4{ 6{
5 GLenum mode; 7 GLenum mode;
6 GLenum format; // 0, GL_T2F_V3F, GL_V2F 8 GLenum format; // 0, GL_T2F_V3F, GL_V2F
37 uint8_t u, v, w, h; 39 uint8_t u, v, w, h;
38 uint16_t x, y; 40 uint16_t x, y;
39 }; 41 };
40 42
41 struct array_t 43 struct array_t
42 : std::vector<uint8_t> 44 : std::vector<uint8_t, slice_allocator<uint8_t>>
43 { 45 {
44 using std::vector<uint8_t>::vector; 46 using std::vector<uint8_t, slice_allocator<uint8_t>>::vector;
45 47
46 template<typename T> 48 template<typename T>
47 T &append () 49 T &append ()
48 { 50 {
49 auto ofs = size (); 51 auto ofs = size ();
82 c.y = y + h; 84 c.y = y + h;
83 } 85 }
84 } 86 }
85 }; 87 };
86 88
89 int drawcount = 0;
87 ska::flat_hash_map<rc_key_t, array_t> h; 90 ska::flat_hash_map<rc_key_t, array_t> h;
88 91
89 void clear () 92 void clear ()
90 { 93 {
94 drawcount = 0;
91 h.clear (); 95 h.clear ();
92 } 96 }
93 97
94 array_t &array (const rc_key_t &k) 98 array_t &array (const rc_key_t &k)
95 { 99 {
126 //glUnlockArraysEXT (); 130 //glUnlockArraysEXT ();
127 } 131 }
128 else 132 else
129 { 133 {
130 // optimised character quad storage. slower but nice on memory. 134 // optimised character quad storage. slower but nice on memory.
131 // reduces storage requirements from 80 bytes/char to 6-8 135 // reduces storage requirements from 80 bytes/char to 8
132 auto *c = (glyph_data *) arr.data (); 136 auto *c = (glyph_data *) arr.data ();
133 auto *e = (glyph_data *)(arr.data () + arr.size ()); 137 auto *e = (glyph_data *)(arr.data () + arr.size ());
134 138
135 glBegin (key.mode); // practically must be quads 139 glBegin (key.mode); // practically must be quads
136 140
147 glEnd (); 151 glEnd ();
148 } 152 }
149 } 153 }
150 154
151 glDisable (GL_TEXTURE_2D); 155 glDisable (GL_TEXTURE_2D);
156
157 if (ecb_expect_false (++drawcount == 16))
158 for (auto &&it = h.begin (); it != h.end (); ++it)
159 it->second.shrink_to_fit ();
152 } 160 }
153}; 161};
154 162

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines