diff options
author | Brian Paul <[email protected]> | 2005-11-12 17:53:14 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2005-11-12 17:53:14 +0000 |
commit | de99760bf3511d05185799c4fb4347f9e5f420f4 (patch) | |
tree | a0bda8570a2943b4c7dabc51b7a61e5c5344eded /src/mesa/main | |
parent | 77ee31930a1b0cc7766939415f4f04ed6a1fa4ac (diff) |
Move stuff common to vertex/fragment_program into the base class, including:
Instructions, InputsRead, OutputsWritten, and Parameters.
Also, added debug functions: _mesa_print_instruction(),
_mesa_print_program_parameters() and revamp _mesa_print_program().
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/context.h | 4 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 29 | ||||
-rw-r--r-- | src/mesa/main/state.c | 6 | ||||
-rw-r--r-- | src/mesa/main/texenvprogram.c | 19 | ||||
-rw-r--r-- | src/mesa/main/texstate.c | 2 |
5 files changed, 33 insertions, 27 deletions
diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h index 8b7e7c9952b..9c6ef520792 100644 --- a/src/mesa/main/context.h +++ b/src/mesa/main/context.h @@ -321,9 +321,9 @@ do { \ (CTX)->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR) \ || (CTX)->Fog.ColorSumEnabled \ || ((CTX)->VertexProgram._Enabled && \ - ((CTX)->VertexProgram.Current->InputsRead & VERT_BIT_COLOR1)) \ + ((CTX)->VertexProgram.Current->Base.InputsRead & VERT_BIT_COLOR1)) \ || ((CTX)->FragmentProgram._Enabled && \ - ((CTX)->FragmentProgram.Current->InputsRead & FRAG_BIT_COL1)) \ + ((CTX)->FragmentProgram.Current->Base.InputsRead & FRAG_BIT_COL1)) \ ) diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index ba0d1c27dc2..1a90583295c 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1761,18 +1761,33 @@ struct program GLenum Target; GLenum Format; /**< String encoding format */ GLboolean Resident; + + struct prog_instruction *Instructions; + + GLbitfield InputsRead; /* Bitmask of which input regs are read */ + GLbitfield OutputsWritten; /* Bitmask of which output regs are written to */ + + /** Named parameters, constants, etc. from program text */ + struct program_parameter_list *Parameters; + /** Numbered local parameters */ GLfloat LocalParams[MAX_PROGRAM_LOCAL_PARAMS][4]; - GLuint NumInstructions; /* GL_ARB_vertex/fragment_program */ + + /** Logical counts */ + /*@{*/ + GLuint NumInstructions; GLuint NumTemporaries; GLuint NumParameters; GLuint NumAttributes; GLuint NumAddressRegs; - /* native, h/w counts */ + /*@}*/ + /** Native, actual h/w counts */ + /*@{*/ GLuint NumNativeInstructions; GLuint NumNativeTemporaries; GLuint NumNativeParameters; GLuint NumNativeAttributes; GLuint NumNativeAddressRegs; + /*@}*/ }; @@ -1780,12 +1795,8 @@ struct program struct vertex_program { struct program Base; /* base class */ - struct prog_instruction *Instructions; /* Compiled instructions */ GLboolean IsNVProgram; /* GL_NV_vertex_program ? */ GLboolean IsPositionInvariant; /* GL_NV_vertex_program1_1 */ - GLbitfield InputsRead; /* Bitmask of which input regs are read */ - GLbitfield OutputsWritten; /* Bitmask of which output regs are written to */ - struct program_parameter_list *Parameters; /**< array [NumParameters] */ void *TnlData; /* should probably use Base.DriverData */ }; @@ -1794,10 +1805,7 @@ struct vertex_program struct fragment_program { struct program Base; /**< base class */ - struct prog_instruction *Instructions; /**< Compiled instructions */ - GLbitfield InputsRead; /**< Bitmask of which input regs are read */ - GLbitfield OutputsWritten; /**< Bitmask of which output regs are written to */ - GLbitfield TexturesUsed[MAX_TEXTURE_IMAGE_UNITS]; /**< TEXTURE_x_INDEX bitmask */ + GLbitfield TexturesUsed[MAX_TEXTURE_IMAGE_UNITS]; /**< TEXTURE_x_BIT bitmask */ GLuint NumAluInstructions; /**< GL_ARB_fragment_program */ GLuint NumTexInstructions; GLuint NumTexIndirections; @@ -1805,7 +1813,6 @@ struct fragment_program GLuint NumNativeTexInstructions; GLuint NumNativeTexIndirections; GLenum FogOption; - struct program_parameter_list *Parameters; /**< array [NumParameters] */ GLboolean UsesKill; }; diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 1d8bc18f244..7eb68db845a 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -930,11 +930,11 @@ update_program(GLcontext *ctx) * have a runable program or shader. */ ctx->VertexProgram._Enabled = ctx->VertexProgram.Enabled - && ctx->VertexProgram.Current->Instructions; + && ctx->VertexProgram.Current->Base.Instructions; ctx->FragmentProgram._Enabled = ctx->FragmentProgram.Enabled - && ctx->FragmentProgram.Current->Instructions; + && ctx->FragmentProgram.Current->Base.Instructions; ctx->ATIFragmentShader._Enabled = ctx->ATIFragmentShader.Enabled - && ctx->ATIFragmentShader.Current->Instructions; + && ctx->ATIFragmentShader.Current->Base.Instructions; ctx->FragmentProgram._Current = ctx->FragmentProgram.Current; ctx->FragmentProgram._Active = ctx->FragmentProgram._Enabled; diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index 8cd8a8630eb..9e041811475 100644 --- a/src/mesa/main/texenvprogram.c +++ b/src/mesa/main/texenvprogram.c @@ -428,7 +428,7 @@ static struct ureg register_param6( struct texenv_fragment_program *p, tokens[3] = s3; tokens[4] = s4; tokens[5] = s5; - idx = _mesa_add_state_reference( p->program->Parameters, tokens ); + idx = _mesa_add_state_reference( p->program->Base.Parameters, tokens ); return make_ureg(PROGRAM_STATE_VAR, idx); } @@ -441,7 +441,7 @@ static struct ureg register_param6( struct texenv_fragment_program *p, static struct ureg register_input( struct texenv_fragment_program *p, GLuint input ) { - p->program->InputsRead |= (1<<input); + p->program->Base.InputsRead |= (1 << input); return make_ureg(PROGRAM_INPUT, input); } @@ -478,7 +478,7 @@ emit_op(struct texenv_fragment_program *p, struct ureg src2 ) { GLuint nr = p->program->Base.NumInstructions++; - struct prog_instruction *inst = &p->program->Instructions[nr]; + struct prog_instruction *inst = &p->program->Base.Instructions[nr]; _mesa_memset(inst, 0, sizeof(*inst)); inst->Opcode = op; @@ -577,7 +577,7 @@ static struct ureg register_const4f( struct texenv_fragment_program *p, values[1] = s1; values[2] = s2; values[3] = s3; - idx = _mesa_add_unnamed_constant( p->program->Parameters, values ); + idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values ); return make_ureg(PROGRAM_STATE_VAR, idx); } @@ -986,7 +986,7 @@ static void create_new_program(struct state_key *key, GLcontext *ctx, p.state = key; p.program = program; - p.program->Instructions = MALLOC(sizeof(struct prog_instruction) * 100); + p.program->Base.Instructions = MALLOC(sizeof(struct prog_instruction) * 100); p.program->Base.NumInstructions = 0; p.program->Base.Target = GL_FRAGMENT_PROGRAM_ARB; p.program->NumTexIndirections = 1; /* correct? */ @@ -997,10 +997,10 @@ static void create_new_program(struct state_key *key, GLcontext *ctx, p.program->Base.NumTemporaries = p.program->Base.NumParameters = p.program->Base.NumAttributes = p.program->Base.NumAddressRegs = 0; - p.program->Parameters = _mesa_new_parameter_list(); + p.program->Base.Parameters = _mesa_new_parameter_list(); - p.program->InputsRead = 0; - p.program->OutputsWritten = 1 << FRAG_RESULT_COLR; + p.program->Base.InputsRead = 0; + p.program->Base.OutputsWritten = 1 << FRAG_RESULT_COLR; for (unit = 0; unit < MAX_TEXTURE_UNITS; unit++) p.src_texture[unit] = undef; @@ -1076,8 +1076,7 @@ static void create_new_program(struct state_key *key, GLcontext *ctx, &p.program->Base ); if (DISASSEM) { - _mesa_print_program(p.program->NumTexInstructions + p.program->NumAluInstructions, - p.program->Instructions); + _mesa_print_program(&p.program->Base); _mesa_printf("\n"); } diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index 043ca3bac38..b352d1a5ad6 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -3072,7 +3072,7 @@ update_texture_state( GLcontext *ctx ) */ if (ctx->FragmentProgram._Enabled) { ctx->Texture._EnabledCoordUnits |= - (ctx->FragmentProgram.Current->InputsRead >> FRAG_ATTRIB_TEX0); + (ctx->FragmentProgram.Current->Base.InputsRead >> FRAG_ATTRIB_TEX0); } } |