/** * Walk over all shaders and programs to delete any variants which * belong to the given context. * This is called during context tear-down. */ void st_destroy_program_variants(struct st_context *st) { /* ARB vert/frag program */ _mesa_HashWalk(st->ctx->Shared->Programs, destroy_program_variants_cb, st); /* GLSL vert/frag/geom shaders */ _mesa_HashWalk(st->ctx->Shared->ShaderObjects, destroy_shader_program_variants_cb, st); }
void st_destroy_context( struct st_context *st ) { struct pipe_context *pipe = st->pipe; struct gl_context *ctx = st->ctx; GLuint i; _mesa_HashWalk(ctx->Shared->TexObjects, destroy_tex_sampler_cb, st); st_reference_fragprog(st, &st->fp, NULL); st_reference_geomprog(st, &st->gp, NULL); st_reference_vertprog(st, &st->vp, NULL); /* release framebuffer surfaces */ for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) { pipe_surface_reference(&st->state.framebuffer.cbufs[i], NULL); } pipe_surface_reference(&st->state.framebuffer.zsbuf, NULL); _mesa_delete_program_cache(st->ctx, st->pixel_xfer.cache); _vbo_DestroyContext(st->ctx); st_destroy_program_variants(st); _mesa_free_context_data(ctx); /* This will free the st_context too, so 'st' must not be accessed * afterwards. */ st_destroy_context_priv(st); st = NULL; pipe->destroy( pipe ); free(ctx); }
/** * Compute total size (in bytes) of all textures for the given context. * For debugging purposes. */ GLuint _mesa_total_texture_memory(struct gl_context *ctx) { GLuint tgt, total = 0; _mesa_HashWalk(ctx->Shared->TexObjects, count_tex_size, &total); /* plus, the default texture objects */ for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { total += texture_size(ctx->Shared->DefaultTex[tgt]); } return total; }
void st_destroy_context( struct st_context *st ) { struct pipe_context *pipe = st->pipe; struct cso_context *cso = st->cso_context; struct gl_context *ctx = st->ctx; GLuint i; _mesa_HashWalk(ctx->Shared->TexObjects, destroy_tex_sampler_cb, st); /* need to unbind and destroy CSO objects before anything else */ cso_release_all(st->cso_context); st_reference_fragprog(st, &st->fp, NULL); st_reference_geomprog(st, &st->gp, NULL); st_reference_vertprog(st, &st->vp, NULL); /* release framebuffer surfaces */ for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) { pipe_surface_reference(&st->state.framebuffer.cbufs[i], NULL); } pipe_surface_reference(&st->state.framebuffer.zsbuf, NULL); pipe->set_index_buffer(pipe, NULL); for (i = 0; i < PIPE_SHADER_TYPES; i++) { pipe->set_constant_buffer(pipe, i, 0, NULL); } _mesa_delete_program_cache(st->ctx, st->pixel_xfer.cache); _vbo_DestroyContext(st->ctx); st_destroy_program_variants(st); _mesa_free_context_data(ctx); /* This will free the st_context too, so 'st' must not be accessed * afterwards. */ st_destroy_context_priv(st); st = NULL; cso_destroy_context(cso); pipe->destroy( pipe ); free(ctx); }
/** * Return true if any active transform feedback object is using a program. */ bool _mesa_transform_feedback_is_using_program(struct gl_context *ctx, struct gl_shader_program *shProg) { struct using_program_tuple callback_data; callback_data.shProg = shProg; callback_data.found = false; _mesa_HashWalk(ctx->TransformFeedback.Objects, active_xfb_object_references_program, &callback_data); /* Also check DefaultObject, as it's not in the Objects hash table. */ active_xfb_object_references_program(0, ctx->TransformFeedback.DefaultObject, &callback_data); return callback_data.found; }
/** * Deallocate a shared state object and all children structures. * * \param ctx GL context. * \param shared shared state pointer. * * Frees the display lists, the texture objects (calling the driver texture * deletion callback to free its private data) and the vertex programs, as well * as their hash tables. * * \sa alloc_shared_state(). */ void _mesa_free_shared_state(GLcontext *ctx, struct gl_shared_state *shared) { GLuint i; /* * Free display lists */ _mesa_HashDeleteAll(shared->DisplayList, delete_displaylist_cb, ctx); _mesa_DeleteHashTable(shared->DisplayList); #if FEATURE_ARB_shader_objects _mesa_HashWalk(shared->ShaderObjects, free_shader_program_data_cb, ctx); _mesa_HashDeleteAll(shared->ShaderObjects, delete_shader_cb, ctx); _mesa_DeleteHashTable(shared->ShaderObjects); #endif _mesa_HashDeleteAll(shared->Programs, delete_program_cb, ctx); _mesa_DeleteHashTable(shared->Programs); _mesa_HashDeleteAll(shared->ArrayObjects, delete_arrayobj_cb, ctx); _mesa_DeleteHashTable(shared->ArrayObjects); #if FEATURE_ARB_vertex_program _mesa_reference_vertprog(ctx, &shared->DefaultVertexProgram, NULL); #endif #if FEATURE_ARB_fragment_program _mesa_reference_fragprog(ctx, &shared->DefaultFragmentProgram, NULL); #endif #if FEATURE_ATI_fragment_shader _mesa_HashDeleteAll(shared->ATIShaders, delete_fragshader_cb, ctx); _mesa_DeleteHashTable(shared->ATIShaders); _mesa_delete_ati_fragment_shader(ctx, shared->DefaultFragmentShader); #endif #if FEATURE_ARB_vertex_buffer_object || FEATURE_ARB_pixel_buffer_object _mesa_HashDeleteAll(shared->BufferObjects, delete_bufferobj_cb, ctx); _mesa_DeleteHashTable(shared->BufferObjects); #endif #if FEATURE_EXT_framebuffer_object _mesa_HashDeleteAll(shared->FrameBuffers, delete_framebuffer_cb, ctx); _mesa_DeleteHashTable(shared->FrameBuffers); _mesa_HashDeleteAll(shared->RenderBuffers, delete_renderbuffer_cb, ctx); _mesa_DeleteHashTable(shared->RenderBuffers); #endif /* * Free texture objects (after FBOs since some textures might have * been bound to FBOs). */ ASSERT(ctx->Driver.DeleteTexture); /* the default textures */ for (i = 0; i < NUM_TEXTURE_TARGETS; i++) { ctx->Driver.DeleteTexture(ctx, shared->DefaultTex[i]); } /* all other textures */ _mesa_HashDeleteAll(shared->TexObjects, delete_texture_cb, ctx); _mesa_DeleteHashTable(shared->TexObjects); _glthread_DESTROY_MUTEX(shared->Mutex); _glthread_DESTROY_MUTEX(shared->TexMutex); _mesa_free(shared); }