When the texture freelist is too large, cut from the back, not the front.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 17 Jun 2014 19:54:28 +0000 (21:54 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 17 Jun 2014 19:54:28 +0000 (21:54 +0200)
All the other freelists had this right, but the texture freelist would
start pruning the _newest_ entries, which obviously gave poor performance.

Patch by Christophe Thommeret.

resource_pool.cpp

index 39af866..eba7923 100644 (file)
@@ -294,8 +294,8 @@ void ResourcePool::release_2d_texture(GLuint texture_num)
        texture_freelist_bytes += estimate_texture_size(texture_formats[texture_num]);
 
        while (texture_freelist_bytes > texture_freelist_max_bytes) {
-               GLuint free_texture_num = texture_freelist.front();
-               texture_freelist.pop_front();
+               GLuint free_texture_num = texture_freelist.back();
+               texture_freelist.pop_back();
                assert(texture_formats.count(free_texture_num) != 0);
                texture_freelist_bytes -= estimate_texture_size(texture_formats[free_texture_num]);
                texture_formats.erase(free_texture_num);