Fix deletion of compute shaders.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 15 Nov 2017 23:34:47 +0000 (00:34 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 15 Nov 2017 23:34:47 +0000 (00:34 +0100)
resource_pool.cpp

index e6f9bb6..2cf470f 100644 (file)
@@ -90,6 +90,15 @@ void ResourcePool::delete_program(GLuint glsl_program_num)
                        break;
                }
        }
+       for (map<string, GLuint>::iterator program_it = compute_programs.begin();
+            program_it != compute_programs.end();
+            ++program_it) {
+               if (program_it->second == glsl_program_num) {
+                       compute_programs.erase(program_it);
+                       found_program = true;
+                       break;
+               }
+       }
        assert(found_program);
 
        map<GLuint, stack<GLuint>>::iterator instance_list_it = program_instances.find(glsl_program_num);
@@ -105,11 +114,19 @@ void ResourcePool::delete_program(GLuint glsl_program_num)
 
        map<GLuint, ShaderSpec>::iterator shader_it =
                program_shaders.find(glsl_program_num);
-       assert(shader_it != program_shaders.end());
-
-       glDeleteShader(shader_it->second.vs_obj);
-       glDeleteShader(shader_it->second.fs_obj);
-       program_shaders.erase(shader_it);
+       if (shader_it == program_shaders.end()) {
+               // Should be a compute shader.
+               map<GLuint, ComputeShaderSpec>::iterator compute_shader_it =
+                       compute_program_shaders.find(glsl_program_num);
+               assert(compute_shader_it != compute_program_shaders.end());
+
+               glDeleteShader(compute_shader_it->second.cs_obj);
+               compute_program_shaders.erase(compute_shader_it);
+       } else {
+               glDeleteShader(shader_it->second.vs_obj);
+               glDeleteShader(shader_it->second.fs_obj);
+               program_shaders.erase(shader_it);
+       }
 }
 
 GLuint ResourcePool::compile_glsl_program(const string& vertex_shader,