diff options
author | Brian <[email protected]> | 2006-12-19 18:46:56 -0700 |
---|---|---|
committer | Brian <[email protected]> | 2006-12-19 18:46:56 -0700 |
commit | 65a18442e5d846940714bb662f5b1bb47ab60c29 (patch) | |
tree | db8554850401753e441a8c49b815f48f7df5a150 /src/mesa/main | |
parent | 0bf5dbe002a64e198f55724cc1542602c012490f (diff) |
Clean-up and re-org of the main GLSL object types.
Use the gl_shader struct as it should be.
Renamed gl_linked_program to gl_shader_program.
Store both shaders and programs in the same hash table and use the Type field
to distinguish them.
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/context.c | 3 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 25 | ||||
-rw-r--r-- | src/mesa/main/state.c | 9 |
3 files changed, 19 insertions, 18 deletions
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index c5220b5b2eb..2196591ba26 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -706,7 +706,6 @@ alloc_shared_state( GLcontext *ctx ) #if FEATURE_ARB_shader_objects ss->ShaderObjects = _mesa_NewHashTable(); - ss->ProgramObjects = _mesa_NewHashTable(); #endif ss->Default1D = (*ctx->Driver.NewTextureObject)(ctx, 0, GL_TEXTURE_1D); @@ -785,8 +784,6 @@ alloc_shared_state( GLcontext *ctx ) #if FEATURE_ARB_shader_objects if (ss->ShaderObjects) _mesa_DeleteHashTable (ss->ShaderObjects); - if (ss->ProgramObjects) - _mesa_DeleteHashTable (ss->ProgramObjects); #endif #if FEATURE_EXT_framebuffer_object diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 4a8f7d22e30..57f174a7d47 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -45,6 +45,12 @@ /** + * Special, internal token + */ +#define GL_SHADER_PROGRAM 0x9999 + + +/** * Color channel data type. */ #if CHAN_BITS == 8 @@ -2044,13 +2050,13 @@ struct gl_query_state /** * A GLSL shader object - * A collection of one or more gl_programs... */ struct gl_shader { - GLenum Type; /**< GL_FRAGMENT_SHADER || GL_VERTEX_SHADER */ + GLenum Type; /**< GL_FRAGMENT_SHADER || GL_VERTEX_SHADER (first field!) */ GLuint Name; /**< AKA the handle */ - GLchar *Source; /**< Source code string */ + GLint RefCount; + const GLchar *Source; /**< Source code string */ GLboolean CompileStatus; GLboolean DeletePending; GLuint NumPrograms; /**< size of Programs[] array */ @@ -2061,15 +2067,14 @@ struct gl_shader /** * This corresponds to a GLSL "program" and is basically a linked collection - * of "shaders" (which are Mesa gl_programs). - * Yes, the terminology is a bit confusing. + * of "shaders". */ -struct gl_linked_program +struct gl_shader_program { - GLenum Type; + 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_program **Shaders; /**< List of the shaders */ + struct gl_shader **Shaders; /**< List of the shaders */ 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 */ @@ -2089,7 +2094,7 @@ struct gl_shader_state { GLboolean _VertexShaderPresent; GLboolean _FragmentShaderPresent; - struct gl_linked_program *CurrentProgram; + struct gl_shader_program *CurrentProgram; }; @@ -2150,8 +2155,8 @@ struct gl_shared_state #endif #if FEATURE_ARB_shader_objects + /** Table of both gl_shader and gl_shader_program objects */ struct _mesa_HashTable *ShaderObjects; - struct _mesa_HashTable *ProgramObjects; #endif #if FEATURE_EXT_framebuffer_object diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 1d8666888ef..947d3136d5b 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -949,8 +949,7 @@ update_arrays( GLcontext *ctx ) static void update_program(GLcontext *ctx) { - const struct gl_linked_program *linked = ctx->Shader.CurrentProgram; - + const struct gl_shader_program *shProg = ctx->Shader.CurrentProgram; /* These _Enabled flags indicate if the program is enabled AND valid. */ ctx->VertexProgram._Enabled = ctx->VertexProgram.Enabled @@ -973,10 +972,10 @@ update_program(GLcontext *ctx) ctx->FragmentProgram._Current = NULL; - if (linked && linked->LinkStatus) { + if (shProg && shProg->LinkStatus) { /* Use shader programs */ - ctx->VertexProgram._Current = linked->VertexProgram; - ctx->FragmentProgram._Current = linked->FragmentProgram; + ctx->VertexProgram._Current = shProg->VertexProgram; + ctx->FragmentProgram._Current = shProg->FragmentProgram; } else { if (ctx->VertexProgram._Enabled) { |