Ejemplo n.º 1
0
ResourcePool::~ResourcePool()
{
	assert(program_refcount.empty());

	for (list<GLuint>::const_iterator freelist_it = program_freelist.begin();
	     freelist_it != program_freelist.end();
	     ++freelist_it) {
		delete_program(*freelist_it);
	}
	assert(programs.empty());
	assert(program_shaders.empty());

	for (list<GLuint>::const_iterator freelist_it = texture_freelist.begin();
	     freelist_it != texture_freelist.end();
	     ++freelist_it) {
		GLuint free_texture_num = *freelist_it;
		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);
		glDeleteTextures(1, &free_texture_num);
		check_error();
	}
	assert(texture_formats.empty());
	assert(texture_freelist_bytes == 0);

	void *context = get_gl_context_identifier();
	cleanup_unlinked_fbos(context);

	for (map<void *, std::list<FBOFormatIterator> >::iterator context_it = fbo_freelist.begin();
	     context_it != fbo_freelist.end();
	     ++context_it) {
		if (context_it->first != context) {
			// If this does not hold, the client should have called clean_context() earlier.
			assert(context_it->second.empty());
			continue;
		}
		for (list<FBOFormatIterator>::const_iterator freelist_it = context_it->second.begin();
		     freelist_it != context_it->second.end();
		     ++freelist_it) {
			FBOFormatIterator fbo_it = *freelist_it;
			glDeleteFramebuffers(1, &fbo_it->second.fbo_num);
			check_error();
			fbo_formats.erase(fbo_it);
		}
	}

	assert(fbo_formats.empty());
}
Ejemplo n.º 2
0
void ResourcePool::release_glsl_program(GLuint glsl_program_num)
{
	pthread_mutex_lock(&lock);
	map<GLuint, int>::iterator refcount_it = program_refcount.find(glsl_program_num);
	assert(refcount_it != program_refcount.end());

	if (--refcount_it->second == 0) {
		program_refcount.erase(refcount_it);
		assert(find(program_freelist.begin(), program_freelist.end(), glsl_program_num)
			== program_freelist.end());
		program_freelist.push_front(glsl_program_num);
		if (program_freelist.size() > program_freelist_max_length) {
			delete_program(program_freelist.back());
			program_freelist.pop_back();
		}
	}

	pthread_mutex_unlock(&lock);
}
Ejemplo n.º 3
0
void delete_font_renderer(FontRenderer* r) {
  delete_program(&r->sp);
  glDeleteBuffers(1, &r->vbo);
  glDeleteVertexArrays(1, &r->vao);
}