diff options
author | Brian Paul <[email protected]> | 2005-11-19 16:43:04 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2005-11-19 16:43:04 +0000 |
commit | 63d683091fe3a9600b65ae7ef3b554168b805406 (patch) | |
tree | 67d3aca6d541ef1a205e201ac7b2a6dda76898bf /src/mesa/main | |
parent | 430c469c5b5edd33fd29db9ab59ac1dccc02af21 (diff) |
No longer derive 'ati_fragment_shader' from 'program' class. Only the
program->Id and program->RefCount fields were used and ATI fragment shaders
didn't have too much in common with ARB/NV vertex/fragment programs anyway.
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/context.c | 8 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 105 | ||||
-rw-r--r-- | src/mesa/main/state.c | 2 |
3 files changed, 68 insertions, 47 deletions
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index b25300a0b0e..8fd9af760ef 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -100,6 +100,7 @@ #include "histogram.h" #include "hint.h" #include "hash.h" +#include "atifragshader.h" #include "light.h" #include "lines.h" #include "macros.h" @@ -692,7 +693,8 @@ alloc_shared_state( GLcontext *ctx ) goto cleanup; #endif #if FEATURE_ATI_fragment_shader - ss->DefaultFragmentShader = ctx->Driver.NewProgram(ctx, GL_FRAGMENT_SHADER_ATI, 0); + ss->ATIShaders = _mesa_NewHashTable(); + ss->DefaultFragmentShader = _mesa_new_ati_fragment_shader(ctx, 0); if (!ss->DefaultFragmentShader) goto cleanup; #endif @@ -760,7 +762,7 @@ alloc_shared_state( GLcontext *ctx ) #endif #if FEATURE_ATI_fragment_shader if (ss->DefaultFragmentShader) - ctx->Driver.DeleteProgram(ctx, ss->DefaultFragmentShader); + _mesa_delete_ati_fragment_shader(ctx, ss->DefaultFragmentShader); #endif #if FEATURE_ARB_vertex_buffer_object if (ss->BufferObjects) @@ -867,7 +869,7 @@ free_shared_state( GLcontext *ctx, struct gl_shared_state *ss ) _mesa_delete_program(ctx, ss->DefaultFragmentProgram); #endif #if FEATURE_ATI_fragment_shader - _mesa_delete_program(ctx, ss->DefaultFragmentShader); + _mesa_free(ss->DefaultFragmentShader); #endif #if FEATURE_ARB_vertex_buffer_object diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index ec21bdce467..4841e6a1515 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1699,7 +1699,7 @@ struct gl_evaluators /** - * NV_fragment_program runtime state + * State used during execution of fragment programs. */ struct fp_machine { @@ -1709,21 +1709,6 @@ struct fp_machine GLuint CondCodes[4]; }; -/** - * ATI_fragment_shader runtime state - */ -#define ATI_FS_INPUT_PRIMARY 0 -#define ATI_FS_INPUT_SECONDARY 1 - -/* 6 register sets - 2 inputs (primary, secondary) */ -struct atifs_machine -{ - GLfloat Registers[6][4]; - GLfloat PrevPassRegisters[6][4]; - GLfloat Inputs[2][4]; - GLuint pass; -}; - /** * Names of the various vertex/fragment program register files, etc. @@ -1748,8 +1733,6 @@ enum register_file /** Vertex and fragment instructions */ struct prog_instruction; -struct atifs_instruction; -struct atifs_setupinst; struct program_parameter_list; @@ -1819,22 +1802,6 @@ struct fragment_program GLboolean UsesKill; }; -struct ati_fragment_shader -{ - struct program Base; - struct atifs_instruction *Instructions[2]; - struct atifs_setupinst *SetupInst[2]; - GLfloat Constants[8][4]; - GLuint localConstDef; - GLubyte numArithInstr[2]; - GLubyte regsAssigned[2]; - GLubyte NumPasses; - GLubyte cur_pass; - GLubyte last_optype; - GLboolean interpinp1; - GLboolean isValid; - GLuint swizzlerq; -}; /** * State common to vertex and fragment programs. @@ -1852,7 +1819,7 @@ struct gl_program_state struct gl_vertex_program_state { GLboolean Enabled; /**< GL_VERTEX_PROGRAM_NV */ - GLboolean _Enabled; /**< Really enabled? */ + GLboolean _Enabled; /**< Enabled and valid program? */ GLboolean PointSizeEnabled; /**< GL_VERTEX_PROGRAM_POINT_SIZE_NV */ GLboolean TwoSideEnabled; /**< GL_VERTEX_PROGRAM_TWO_SIDE_NV */ struct vertex_program *Current; /**< ptr to currently bound program */ @@ -1881,13 +1848,13 @@ struct gl_vertex_program_state /** - * State for GL_ARB/NV_fragment_program + * Context state for GL_ARB/NV_fragment_program */ struct gl_fragment_program_state { GLboolean Enabled; /* GL_VERTEX_PROGRAM_NV */ - GLboolean _Enabled; /* Really enabled? */ - GLboolean _Active; /* Really really enabled? */ + GLboolean _Enabled; /* Enabled and valid program? */ + GLboolean _Active; struct fragment_program *Current; /* ptr to currently bound program */ struct fragment_program *_Current; /* ptr to currently active program (including internal programs) */ @@ -1904,19 +1871,63 @@ struct gl_fragment_program_state /** - * State for GL_ATI_fragment_shader + * ATI_fragment_shader runtime state + */ +#define ATI_FS_INPUT_PRIMARY 0 +#define ATI_FS_INPUT_SECONDARY 1 + +struct atifs_instruction; +struct atifs_setupinst; + +/** + * State for executing ATI fragment shader. + */ +struct atifs_machine +{ + GLfloat Registers[6][4]; /** six temporary registers */ + GLfloat PrevPassRegisters[6][4]; + GLfloat Inputs[2][4]; /** Primary, secondary input colors */ +}; + + +/** + * ATI fragment shader + */ +struct ati_fragment_shader +{ + GLuint Id; + GLint RefCount; + struct atifs_instruction *Instructions[2]; + struct atifs_setupinst *SetupInst[2]; + GLfloat Constants[8][4]; + GLbitfield LocalConstDef; /** Indicates which constants have been set */ + GLubyte numArithInstr[2]; + GLubyte regsAssigned[2]; + GLubyte NumPasses; /** 1 or 2 */ + GLubyte cur_pass; + GLubyte last_optype; + GLboolean interpinp1; + GLboolean isValid; + GLuint swizzlerq; +}; + +/** + * Context state for GL_ATI_fragment_shader */ struct gl_ati_fragment_shader_state { GLboolean Enabled; - GLboolean _Enabled; + GLboolean _Enabled; /** enabled and valid shader? */ GLboolean Compiling; - GLfloat globalConstants[8][4]; + GLfloat GlobalConstants[8][4]; struct atifs_machine Machine; /* machine state */ struct ati_fragment_shader *Current; }; +/** + * Occlusion/timer query object. + */ struct gl_query_object { GLuint Id; @@ -1926,6 +1937,9 @@ struct gl_query_object }; +/** + * Context state for query objects. + */ struct gl_query_state { struct _mesa_HashTable *QueryObjects; @@ -1934,6 +1948,9 @@ struct gl_query_state }; +/** + * Context state for vertex/fragment shaders. + */ struct gl_shader_objects_state { struct gl2_program_intf **current_program; @@ -1972,10 +1989,12 @@ struct gl_shared_state #if FEATURE_ARB_fragment_program struct program *DefaultFragmentProgram; #endif + /*@}*/ + #if FEATURE_ATI_fragment_shader - struct program *DefaultFragmentShader; + struct _mesa_HashTable *ATIShaders; + struct ati_fragment_shader *DefaultFragmentShader; #endif - /*@}*/ #if FEATURE_ARB_vertex_buffer_object || FEATURE_ARB_pixel_buffer_object struct _mesa_HashTable *BufferObjects; diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 7eb68db845a..562a0c5a451 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -934,7 +934,7 @@ update_program(GLcontext *ctx) ctx->FragmentProgram._Enabled = ctx->FragmentProgram.Enabled && ctx->FragmentProgram.Current->Base.Instructions; ctx->ATIFragmentShader._Enabled = ctx->ATIFragmentShader.Enabled - && ctx->ATIFragmentShader.Current->Base.Instructions; + && ctx->ATIFragmentShader.Current->Instructions; ctx->FragmentProgram._Current = ctx->FragmentProgram.Current; ctx->FragmentProgram._Active = ctx->FragmentProgram._Enabled; |