X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=resource_pool.cpp;h=eba79237678611bf474c065f81111e49531cfb94;hp=5abc1b28b81729671bd0e4758ae9803d53c096f9;hb=1400c353ad03f4d31f665be0d02e8e360f69ef5c;hpb=7ea0b3a5be9bafaa2d1fa5a17ce285a725ce132b diff --git a/resource_pool.cpp b/resource_pool.cpp index 5abc1b2..eba7923 100644 --- a/resource_pool.cpp +++ b/resource_pool.cpp @@ -186,6 +186,9 @@ void ResourcePool::release_glsl_program(GLuint glsl_program_num) GLuint ResourcePool::create_2d_texture(GLint internal_format, GLsizei width, GLsizei height) { + assert(width > 0); + assert(height > 0); + pthread_mutex_lock(&lock); // See if there's a texture on the freelist we can use. for (list::iterator freelist_it = texture_freelist.begin(); @@ -291,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); @@ -398,6 +401,7 @@ void ResourcePool::cleanup_unlinked_fbos(void *context) pair key(context, fbo_num); assert(fbo_formats.count(key) != 0); if (fbo_formats[key].texture_num == 0) { + fbo_formats.erase(key); glDeleteFramebuffers(1, &fbo_num); check_error(); fbo_freelist[context].erase(freelist_it++);