]> git.sesse.net Git - movit/blobdiff - resource_pool.cpp
Add some check_error() for shaders miscompiling.
[movit] / resource_pool.cpp
index db449dd7084f412ef63551a04a823245f7a9eff1..152793c765ace31d31a68e62070fca3503845d6a 100644 (file)
@@ -124,8 +124,11 @@ GLuint ResourcePool::compile_glsl_program(const string& vertex_shader, const str
        } else {
                // Not in the cache. Compile the shaders.
                glsl_program_num = glCreateProgram();
+               check_error();
                GLuint vs_obj = compile_shader(vertex_shader, GL_VERTEX_SHADER);
+               check_error();
                GLuint fs_obj = compile_shader(fragment_shader, GL_FRAGMENT_SHADER);
+               check_error();
                glAttachShader(glsl_program_num, vs_obj);
                check_error();
                glAttachShader(glsl_program_num, fs_obj);
@@ -294,8 +297,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);
@@ -401,6 +404,7 @@ void ResourcePool::cleanup_unlinked_fbos(void *context)
                pair<void *, GLuint> 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++);
@@ -460,6 +464,9 @@ size_t ResourcePool::estimate_texture_size(const Texture2D &texture_format)
        case GL_R16F:
                bytes_per_pixel = 2;
                break;
+       case GL_RG8:
+               bytes_per_pixel = 2;
+               break;
        case GL_R8:
                bytes_per_pixel = 1;
                break;