diff options
author | Brian <[email protected]> | 2006-12-20 09:27:42 -0700 |
---|---|---|
committer | Brian <[email protected]> | 2006-12-20 09:27:42 -0700 |
commit | 9e4bae9ccac5a76a2361c5c3cbe377a3c6b6a95b (patch) | |
tree | 49457c5d38d27a54d59d3e0429f8dcd46eab6882 /src/mesa/main | |
parent | 65a18442e5d846940714bb662f5b1bb47ab60c29 (diff) |
Fix shader object reference counting and hash table deallocation.
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/context.c | 26 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 20 | ||||
-rw-r--r-- | src/mesa/main/shaders.h | 5 |
3 files changed, 28 insertions, 23 deletions
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 2196591ba26..0e2a7804769 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -131,7 +131,7 @@ #include "math/m_xform.h" #include "math/mathmod.h" #endif -#include "shaders.h" +#include "shader_api.h" #ifdef USE_SPARC_ASM #include "sparc/sparc.h" @@ -877,13 +877,22 @@ delete_arrayobj_cb(GLuint id, void *data, void *userData) } /** - * Callback for deleting an shader object. Called by _mesa_HashDeleteAll(). + * Callback for deleting shader and shader programs objects. + * Called by _mesa_HashDeleteAll(). */ static void -delete_shaderobj_cb(GLuint id, void *data, void *userData) +delete_shader_cb(GLuint id, void *data, void *userData) { - /* XXX probably need to fix this */ - _mesa_free(data); + GLcontext *ctx = (GLcontext *) userData; + struct gl_shader *sh = (struct gl_shader *) data; + if (sh->Type == GL_FRAGMENT_SHADER || sh->Type == GL_VERTEX_SHADER) { + _mesa_free_shader(ctx, sh); + } + else { + struct gl_shader_program *shProg = (struct gl_shader_program *) data; + ASSERT(shProg->Type == GL_SHADER_PROGRAM); + _mesa_free_shader_program(ctx, shProg); + } } @@ -948,11 +957,8 @@ free_shared_state( GLcontext *ctx, struct gl_shared_state *ss ) _mesa_DeleteHashTable(ss->ArrayObjects); #if FEATURE_ARB_shader_objects - /* XXX SLANG TO-DO */ - /* - struct _mesa_HashTable *ShaderObjects; - struct _mesa_HashTable *ProgramObjects; - */ + _mesa_HashDeleteAll(ss->ShaderObjects, delete_shader_cb, ctx); + _mesa_DeleteHashTable(ss->ShaderObjects); #endif #if FEATURE_EXT_framebuffer_object diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 57f174a7d47..e73c625a825 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2049,16 +2049,17 @@ struct gl_query_state /** - * A GLSL shader object + * A GLSL shader object. */ struct gl_shader { GLenum Type; /**< GL_FRAGMENT_SHADER || GL_VERTEX_SHADER (first field!) */ GLuint Name; /**< AKA the handle */ - GLint RefCount; + GLint RefCount; /**< Reference count */ + GLboolean DeletePending; + const GLchar *Source; /**< Source code string */ GLboolean CompileStatus; - GLboolean DeletePending; GLuint NumPrograms; /**< size of Programs[] array */ struct gl_program **Programs; /**< Post-compile assembly code */ GLchar *InfoLog; @@ -2066,15 +2067,19 @@ struct gl_shader /** - * This corresponds to a GLSL "program" and is basically a linked collection - * of "shaders". + * A GLSL program object. Basically a linked collection of "shaders". */ struct gl_shader_program { GLenum Type; /**< Always GL_SHADER_PROGRAM (internal token) */ GLuint Name; /**< aka handle or ID */ - GLuint NumShaders; /**< total number of shaders in this program */ - struct gl_shader **Shaders; /**< List of the shaders */ + GLint RefCount; /**< Reference count */ + GLboolean DeletePending; + + GLuint NumShaders; /**< number of attached shaders */ + struct gl_shader **Shaders; /**< List of attached the shaders */ + + /* post-link info: */ struct gl_vertex_program *VertexProgram; /**< Linked vertex program */ struct gl_fragment_program *FragmentProgram; /**< Linked fragment prog */ struct gl_program_parameter_list *Uniforms; /**< Plus constants, etc */ @@ -2082,7 +2087,6 @@ struct gl_shader_program struct gl_program_parameter_list *Attributes; /**< Vertex attributes */ GLboolean LinkStatus; /**< GL_LINK_STATUS */ GLboolean Validated; - GLboolean DeletePending; GLchar *InfoLog; }; diff --git a/src/mesa/main/shaders.h b/src/mesa/main/shaders.h index a098c4c3315..17339ccf623 100644 --- a/src/mesa/main/shaders.h +++ b/src/mesa/main/shaders.h @@ -233,9 +233,4 @@ _mesa_UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -/*** XXXX temporary here ! */ -extern void -_mesa_init_shader_state(GLcontext *ctx); - - #endif /* SHADERS_H */ |