Instructions, InputsRead, OutputsWritten, and Parameters.
Also, added debug functions: _mesa_print_instruction(),
_mesa_print_program_parameters() and revamp _mesa_print_program().
case PROGRAM_STATE_VAR:
case PROGRAM_NAMED_PARAM:
src = i915_emit_param4fv(
- p, program->Parameters->ParameterValues[source->Index] );
+ p, program->Base.Parameters->ParameterValues[source->Index] );
break;
default:
static void upload_program( struct i915_fragment_program *p )
{
const struct fragment_program *program = p->ctx->FragmentProgram._Current;
- const struct prog_instruction *inst = program->Instructions;
+ const struct prog_instruction *inst = program->Base.Instructions;
/* _mesa_debug_fp_inst(program->Base.NumInstructions, inst); */
static void check_wpos( struct i915_fragment_program *p )
{
- GLuint inputs = p->FragProg.InputsRead;
+ GLuint inputs = p->FragProg.Base.InputsRead;
GLint i;
p->wpos_tex = -1;
GLint i;
if (p->nr_params)
- _mesa_load_state_parameters(p->ctx, p->FragProg.Parameters);
+ _mesa_load_state_parameters(p->ctx, p->FragProg.Base.Parameters);
for (i = 0; i < p->nr_params; i++) {
GLint reg = p->param[i].reg;
struct i915_fragment_program *p =
(struct i915_fragment_program *)ctx->FragmentProgram._Current;
- GLuint inputsRead = p->FragProg.InputsRead;
+ const GLuint inputsRead = p->FragProg.Base.InputsRead;
GLuint s4 = i915->state.Ctx[I915_CTXREG_LIS4] & ~S4_VFMT_MASK;
GLuint s2 = S2_TEXCOORD_NONE;
int i, offset = 0;
TNLcontext *tnl = TNL_CONTEXT(ctx);
intelContextPtr intel = INTEL_CONTEXT(ctx);
GLuint flags = ctx->_TriangleCaps;
- struct fragment_program *program = ctx->FragmentProgram._Current;
- GLboolean have_wpos = (program && (program->InputsRead & FRAG_BIT_WPOS));
+ struct fragment_program *fprog = ctx->FragmentProgram._Current;
+ GLboolean have_wpos = (fprog && (fprog->Base.InputsRead & FRAG_BIT_WPOS));
GLuint index = 0;
if (INTEL_DEBUG & DEBUG_STATE)
struct r300_vertex_shader_fragment params;
int pos_end;
- unsigned long num_temporaries; /* Number of temp vars used by program */
+ int num_temporaries; /* Number of temp vars used by program */
int inputs[VERT_ATTRIB_MAX];
int outputs[VERT_RESULT_MAX];
};
break;
case PROGRAM_STATE_VAR:
case PROGRAM_NAMED_PARAM:
- r = emit_param4fv(rp, rp->mesa_program.Parameters->ParameterValues[fpsrc.Index]);
+ r = emit_param4fv(rp, rp->mesa_program.Base.Parameters->ParameterValues[fpsrc.Index]);
break;
default:
ERROR("unknown SrcReg->File %x\n", fpsrc.File);
static GLboolean parse_program(struct r300_fragment_program *rp)
{
struct fragment_program *mp = &rp->mesa_program;
- const struct prog_instruction *inst = mp->Instructions;
+ const struct prog_instruction *inst = mp->Base.Instructions;
struct prog_instruction *fpi;
pfs_reg_t src0, src1, src2, dest, temp;
int flags = 0;
return GL_FALSE;
}
- for (fpi=mp->Instructions; fpi->Opcode != OPCODE_END; fpi++) {
+ for (fpi=mp->Base.Instructions; fpi->Opcode != OPCODE_END; fpi++) {
if (fpi->Saturate) {
flags = PFS_FLAG_SAT;
}
{
struct fragment_program *mp = &rp->mesa_program;
struct prog_instruction *fpi;
- GLuint InputsRead = mp->InputsRead;
+ GLuint InputsRead = mp->Base.InputsRead;
GLuint temps_used = 0; /* for rp->temps[] */
int i;
* Possibly not too bad actually, as we could add to this later and
* find out when inputs are last used so we can reuse them as temps.
*/
- if (!mp->Instructions) {
+ if (!mp->Base.Instructions) {
ERROR("No instructions found in program\n");
return;
}
- for (fpi=mp->Instructions;fpi->Opcode != OPCODE_END; fpi++) {
+ for (fpi=mp->Base.Instructions;fpi->Opcode != OPCODE_END; fpi++) {
for (i=0;i<3;i++) {
if (fpi->SrcReg[i].File == PROGRAM_TEMPORARY) {
if (!(temps_used & (1 << fpi->SrcReg[i].Index))) {
/* Ask Mesa nicely to fill in ParameterValues for us */
if (rp->param_nr)
- _mesa_load_state_parameters(rp->ctx, mp->Parameters);
+ _mesa_load_state_parameters(rp->ctx, mp->Base.Parameters);
for (i=0;i<rp->param_nr;i++)
COPY_4V(rp->constant[rp->param[i].idx], rp->param[i].values);
fprintf(stderr, "Mesa program:\n");
fprintf(stderr, "-------------\n");
- _mesa_print_program(rp->mesa_program.NumTexInstructions +
- rp->mesa_program.NumAluInstructions,
- rp->mesa_program.Instructions);
+ _mesa_print_program(&rp->mesa_program.Base);
fflush(stdout);
fprintf(stderr, "Hardware program\n");
}
if (hw_tcl_on) {
- GLuint InputsRead = CURRENT_VERTEX_SHADER(ctx)->InputsRead;
+ GLuint InputsRead = CURRENT_VERTEX_SHADER(ctx)->Base.InputsRead;
struct r300_vertex_program *prog=(struct r300_vertex_program *)CURRENT_VERTEX_SHADER(ctx);
if (InputsRead & (1<<VERT_ATTRIB_POS)) {
inputs |= _TNL_BIT_POS;
r300->hw.vof.cmd[R300_VOF_CNTL_0]=0;
r300->hw.vof.cmd[R300_VOF_CNTL_1]=0;
if (hw_tcl_on){
- GLuint OutputsWritten = CURRENT_VERTEX_SHADER(ctx)->OutputsWritten;
+ GLuint OutputsWritten = CURRENT_VERTEX_SHADER(ctx)->Base.OutputsWritten;
if(OutputsWritten & (1<<VERT_RESULT_HPOS))
r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT;
((arg2) << R300_FPI2_ARG2A_SHIFT))
extern void debug_vp(GLcontext *ctx, struct vertex_program *vp);
-extern void dump_program_params(GLcontext *ctx, struct vertex_program *vp);
#endif /* __R300_PROGRAM_H__ */
GLuint OutputsWritten;
if(hw_tcl_on)
- OutputsWritten = CURRENT_VERTEX_SHADER(ctx)->OutputsWritten;
+ OutputsWritten = CURRENT_VERTEX_SHADER(ctx)->Base.OutputsWritten;
R300_STATECHANGE(r300, txe);
R300_STATECHANGE(r300, tex.filter);
int i;
if(hw_tcl_on)
- OutputsWritten = CURRENT_VERTEX_SHADER(ctx)->OutputsWritten;
+ OutputsWritten = CURRENT_VERTEX_SHADER(ctx)->Base.OutputsWritten;
else
OutputsWritten = r300->state.render_inputs;
if (ctx->FragmentProgram._Current)
- InputsRead = ctx->FragmentProgram._Current->InputsRead;
+ InputsRead = ctx->FragmentProgram._Current->Base.InputsRead;
else {
fprintf(stderr, "No ctx->FragmentProgram._Current!!\n");
return; /* This should only ever happen once.. */
GLuint OutputsWritten;
if(hw_tcl_on)
- OutputsWritten = CURRENT_VERTEX_SHADER(ctx)->OutputsWritten;
+ OutputsWritten = CURRENT_VERTEX_SHADER(ctx)->Base.OutputsWritten;
/* This needs to be rewritten - it is a hack at best */
XPD v,v v cross product
*/
-void dump_program_params(GLcontext *ctx, struct vertex_program *vp)
-{
- int i;
- int pi;
-
- fprintf(stderr, "NumInstructions=%d\n", vp->Base.NumInstructions);
- fprintf(stderr, "NumTemporaries=%d\n", vp->Base.NumTemporaries);
- fprintf(stderr, "NumParameters=%d\n", vp->Base.NumParameters);
- fprintf(stderr, "NumAttributes=%d\n", vp->Base.NumAttributes);
- fprintf(stderr, "NumAddressRegs=%d\n", vp->Base.NumAddressRegs);
-
- _mesa_load_state_parameters(ctx, vp->Parameters);
-
-#if 0
- for(pi=0; pi < vp->Base.NumParameters; pi++){
- fprintf(stderr, "{ ");
- for(i=0; i < 4; i++)
- fprintf(stderr, "%f ", vp->Base.LocalParams[pi][i]);
- fprintf(stderr, "}\n");
- }
-#endif
- for(pi=0; pi < vp->Parameters->NumParameters; pi++){
- fprintf(stderr, "param %02d:", pi);
-
- switch(vp->Parameters->Parameters[pi].Type){
-
- case PROGRAM_NAMED_PARAM:
- fprintf(stderr, "%s", vp->Parameters->Parameters[pi].Name);
- fprintf(stderr, "(NAMED_PARAMETER)");
- break;
-
- case PROGRAM_CONSTANT:
- fprintf(stderr, "(CONSTANT)");
- break;
-
- case PROGRAM_STATE_VAR:
- fprintf(stderr, "(STATE)\n");
- break;
-
- default:
- fprintf(stderr, "(UNK)\n");
- break;
- }
-
- fprintf(stderr, "{ ");
- for(i=0; i < 4; i++)
- fprintf(stderr, "%f ", vp->Parameters->ParameterValues[pi][i]);
- fprintf(stderr, "}\n");
-
- }
-}
-
+/*
+ * XXX get rid of this function. Use _mesa_print_program() instead.
+ */
void debug_vp(GLcontext *ctx, struct vertex_program *vp)
{
struct prog_instruction *vpi;
int i, operand_index;
int operator_index;
- dump_program_params(ctx, vp);
+ _mesa_print_program_parameters(ctx, &vp->Base);
- vpi=vp->Instructions;
+ vpi=vp->Base.Instructions;
for(;; vpi++){
if(vpi->Opcode == OPCODE_END)
int pi;
struct vertex_program *mesa_vp=(void *)vp;
float *dst_o=dst;
+ struct program_parameter_list *paramList;
- _mesa_load_state_parameters(ctx, mesa_vp->Parameters);
+ _mesa_load_state_parameters(ctx, mesa_vp->Base.Parameters);
//debug_vp(ctx, mesa_vp);
- if(mesa_vp->Parameters->NumParameters * 4 > VSF_MAX_FRAGMENT_LENGTH){
+ if(mesa_vp->Base.Parameters->NumParameters * 4 > VSF_MAX_FRAGMENT_LENGTH){
fprintf(stderr, "%s:Params exhausted\n", __FUNCTION__);
exit(-1);
}
- for(pi=0; pi < mesa_vp->Parameters->NumParameters; pi++){
- switch(mesa_vp->Parameters->Parameters[pi].Type){
+ paramList = mesa_vp->Base.Parameters;
+ for(pi=0; pi < paramList->NumParameters; pi++){
+ switch(paramList->Parameters[pi].Type){
case PROGRAM_STATE_VAR:
case PROGRAM_NAMED_PARAM:
//fprintf(stderr, "%s", vp->Parameters->Parameters[pi].Name);
case PROGRAM_CONSTANT:
- *dst++=mesa_vp->Parameters->ParameterValues[pi][0];
- *dst++=mesa_vp->Parameters->ParameterValues[pi][1];
- *dst++=mesa_vp->Parameters->ParameterValues[pi][2];
- *dst++=mesa_vp->Parameters->ParameterValues[pi][3];
+ *dst++=paramList->ParameterValues[pi][0];
+ *dst++=paramList->ParameterValues[pi][1];
+ *dst++=paramList->ParameterValues[pi][2];
+ *dst++=paramList->ParameterValues[pi][3];
break;
default: _mesa_problem(NULL, "Bad param type in %s", __FUNCTION__);
for(i=0; i < VERT_RESULT_MAX; i++)
vp->outputs[i] = -1;
- assert(mesa_vp->OutputsWritten & (1 << VERT_RESULT_HPOS));
- assert(mesa_vp->OutputsWritten & (1 << VERT_RESULT_COL0));
+ assert(mesa_vp->Base.OutputsWritten & (1 << VERT_RESULT_HPOS));
+ assert(mesa_vp->Base.OutputsWritten & (1 << VERT_RESULT_COL0));
/* Assign outputs */
- if(mesa_vp->OutputsWritten & (1 << VERT_RESULT_HPOS))
+ if(mesa_vp->Base.OutputsWritten & (1 << VERT_RESULT_HPOS))
vp->outputs[VERT_RESULT_HPOS] = cur_reg++;
- if(mesa_vp->OutputsWritten & (1 << VERT_RESULT_PSIZ))
+ if(mesa_vp->Base.OutputsWritten & (1 << VERT_RESULT_PSIZ))
vp->outputs[VERT_RESULT_PSIZ] = cur_reg++;
- if(mesa_vp->OutputsWritten & (1 << VERT_RESULT_COL0))
+ if(mesa_vp->Base.OutputsWritten & (1 << VERT_RESULT_COL0))
vp->outputs[VERT_RESULT_COL0] = cur_reg++;
#if 0 /* Not supported yet */
- if(mesa_vp->OutputsWritten & (1 << VERT_RESULT_BFC0))
+ if(mesa_vp->Base.OutputsWritten & (1 << VERT_RESULT_BFC0))
vp->outputs[VERT_RESULT_BFC0] = cur_reg++;
- if(mesa_vp->OutputsWritten & (1 << VERT_RESULT_COL1))
+ if(mesa_vp->Base.OutputsWritten & (1 << VERT_RESULT_COL1))
vp->outputs[VERT_RESULT_COL1] = cur_reg++;
- if(mesa_vp->OutputsWritten & (1 << VERT_RESULT_BFC1))
+ if(mesa_vp->Base.OutputsWritten & (1 << VERT_RESULT_BFC1))
vp->outputs[VERT_RESULT_BFC1] = cur_reg++;
- if(mesa_vp->OutputsWritten & (1 << VERT_RESULT_FOGC))
+ if(mesa_vp->Base.OutputsWritten & (1 << VERT_RESULT_FOGC))
vp->outputs[VERT_RESULT_FOGC] = cur_reg++;
#endif
for(i=VERT_RESULT_TEX0; i <= VERT_RESULT_TEX7; i++)
- if(mesa_vp->OutputsWritten & (1 << i))
+ if(mesa_vp->Base.OutputsWritten & (1 << i))
vp->outputs[i] = cur_reg++;
o_inst=vp->program.body.i;
- for(vpi=mesa_vp->Instructions; vpi->Opcode != OPCODE_END; vpi++, o_inst++){
+ for(vpi=mesa_vp->Base.Instructions; vpi->Opcode != OPCODE_END; vpi++, o_inst++){
operands=op_operands(vpi->Opcode);
are_srcs_scalar=operands & SCALAR_FLAG;
(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)) \
)
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;
+ /*@}*/
};
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 */
};
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;
GLuint NumNativeTexInstructions;
GLuint NumNativeTexIndirections;
GLenum FogOption;
- struct program_parameter_list *Parameters; /**< array [NumParameters] */
GLboolean UsesKill;
};
* 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;
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);
}
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);
}
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;
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);
}
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? */
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;
&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");
}
*/
if (ctx->FragmentProgram._Enabled) {
ctx->Texture._EnabledCoordUnits |=
- (ctx->FragmentProgram.Current->InputsRead >> FRAG_ATTRIB_TEX0);
+ (ctx->FragmentProgram.Current->Base.InputsRead >> FRAG_ATTRIB_TEX0);
}
}
}
_mesa_memcpy(newInstructions, ap.FPInstructions,
ap.Base.NumInstructions * sizeof(struct prog_instruction));
- if (program->Instructions)
- _mesa_free(program->Instructions);
- program->Instructions = newInstructions;
+ if (program->Base.Instructions)
+ _mesa_free(program->Base.Instructions);
+ program->Base.Instructions = newInstructions;
program->Base.String = ap.Base.String;
program->Base.NumInstructions = ap.Base.NumInstructions;
program->Base.NumTemporaries = ap.Base.NumTemporaries;
program->Base.NumParameters = ap.Base.NumParameters;
program->Base.NumAttributes = ap.Base.NumAttributes;
program->Base.NumAddressRegs = ap.Base.NumAddressRegs;
- program->NumAluInstructions = ap.NumAluInstructions;
- program->NumTexInstructions = ap.NumTexInstructions;
- program->NumTexIndirections = ap.NumTexIndirections;
- program->InputsRead = ap.InputsRead;
- program->OutputsWritten = ap.OutputsWritten;
+ program->NumAluInstructions = ap.NumAluInstructions;
+ program->NumTexInstructions = ap.NumTexInstructions;
+ program->NumTexIndirections = ap.NumTexIndirections;
+ program->Base.InputsRead = ap.Base.InputsRead;
+ program->Base.OutputsWritten = ap.Base.OutputsWritten;
for (i = 0; i < MAX_TEXTURE_IMAGE_UNITS; i++)
program->TexturesUsed[i] = ap.TexturesUsed[i];
- if (program->Parameters) {
+ if (program->Base.Parameters) {
/* free previous program's parameters */
- _mesa_free_parameter_list(program->Parameters);
+ _mesa_free_parameter_list(program->Base.Parameters);
}
- program->Parameters = ap.Parameters;
+ program->Base.Parameters = ap.Base.Parameters;
program->FogOption = ap.FogOption;
#if DEBUG_FP
- _mesa_print_program(ap.Base.NumInstructions, ap.FPInstructions);
+ _mesa_print_program(&program.Base);
#endif
}
_mesa_error(ctx, GL_INVALID_OPERATION, msg);
}
- Program->InputsRead |= (1 << *inputReg);
+ Program->Base.InputsRead |= (1 << *inputReg);
return err;
}
break;
}
- Program->OutputsWritten |= (1 << *outputReg);
+ Program->Base.OutputsWritten |= (1 << *outputReg);
return 0;
}
for (row = first_row; row <= last_row; row++) {
state_tokens[3] = state_tokens[4] = row;
- idx =
- _mesa_add_state_reference (Program->Parameters,
- state_tokens);
+ idx = _mesa_add_state_reference(Program->Base.Parameters,
+ state_tokens);
if (param_var->param_binding_begin == ~0U)
param_var->param_binding_begin = idx;
param_var->param_binding_length++;
}
}
else {
- idx =
- _mesa_add_state_reference (Program->Parameters, state_tokens);
+ idx = _mesa_add_state_reference(Program->Base.Parameters,
+ state_tokens);
if (param_var->param_binding_begin == ~0U)
param_var->param_binding_begin = idx;
param_var->param_binding_length++;
case PARAM_PROGRAM_ELEMENT:
if (parse_program_single_item (ctx, inst, Program, state_tokens))
return 1;
- idx = _mesa_add_state_reference (Program->Parameters, state_tokens);
+ idx = _mesa_add_state_reference (Program->Base.Parameters, state_tokens);
if (param_var->param_binding_begin == ~0U)
param_var->param_binding_begin = idx;
param_var->param_binding_length++;
for (new_idx = start_idx; new_idx <= end_idx; new_idx++) {
state_tokens[2] = new_idx;
- idx =
- _mesa_add_state_reference (Program->Parameters,
- state_tokens);
+ idx = _mesa_add_state_reference(Program->Base.Parameters,
+ state_tokens);
param_var->param_binding_length++;
Program->Base.NumParameters++;
}
case PARAM_CONSTANT:
parse_constant (inst, const_values, Program, use);
- idx =
- _mesa_add_named_constant (Program->Parameters,
- (char *) param_var->name, const_values);
+ idx = _mesa_add_named_constant(Program->Base.Parameters,
+ (char *) param_var->name,
+ const_values);
if (param_var->param_binding_begin == ~0U)
param_var->param_binding_begin = idx;
param_var->param_binding_length++;
program->Base.NumTemporaries =
program->Base.NumParameters =
program->Base.NumAttributes = program->Base.NumAddressRegs = 0;
- program->Parameters = _mesa_new_parameter_list ();
- program->InputsRead = 0x0;
- program->OutputsWritten = 0x0;
+ program->Base.Parameters = _mesa_new_parameter_list ();
+ program->Base.InputsRead = 0x0;
+ program->Base.OutputsWritten = 0x0;
program->Position = 0;
program->MajorVersion = program->MinorVersion = 0;
program->PrecisionOption = GL_DONT_CARE;
struct arb_program
{
struct program Base;
+#if 0
struct program_parameter_list *Parameters;
GLbitfield InputsRead;
GLbitfield OutputsWritten;
+#endif
GLuint Position; /* Just used for error reporting while parsing */
GLuint MajorVersion;
}
_mesa_memcpy(newInstructions, ap.VPInstructions,
ap.Base.NumInstructions * sizeof(struct prog_instruction));
- if (program->Instructions)
- _mesa_free(program->Instructions);
- program->Instructions = newInstructions;
+ if (program->Base.Instructions)
+ _mesa_free(program->Base.Instructions);
+ program->Base.Instructions = newInstructions;
program->Base.String = ap.Base.String;
program->Base.NumInstructions = ap.Base.NumInstructions;
program->Base.NumTemporaries = ap.Base.NumTemporaries;
program->Base.NumAttributes = ap.Base.NumAttributes;
program->Base.NumAddressRegs = ap.Base.NumAddressRegs;
program->IsPositionInvariant = ap.HintPositionInvariant;
- program->InputsRead = ap.InputsRead;
- program->OutputsWritten = ap.OutputsWritten;
+ program->Base.InputsRead = ap.Base.InputsRead;
+ program->Base.OutputsWritten = ap.Base.OutputsWritten;
- if (program->Parameters) {
+ if (program->Base.Parameters) {
/* free previous program's parameters */
- _mesa_free_parameter_list(program->Parameters);
+ _mesa_free_parameter_list(program->Base.Parameters);
}
- program->Parameters = ap.Parameters;
+ program->Base.Parameters = ap.Base.Parameters;
#if DEBUG_VP
- _mesa_print_program(ap.Base.NumInstructions, ap.VPInstructions);
+ _mesa_print_program(&program->Base);
#endif
}
}
program->Base.String = programString;
program->Base.Format = GL_PROGRAM_FORMAT_ASCII_ARB;
- if (program->Instructions) {
- FREE(program->Instructions);
+ if (program->Base.Instructions) {
+ _mesa_free(program->Base.Instructions);
}
- program->Instructions = newInst;
- program->InputsRead = parseState.inputsRead;
- program->OutputsWritten = parseState.outputsWritten;
+ program->Base.Instructions = newInst;
+ program->Base.InputsRead = parseState.inputsRead;
+ program->Base.OutputsWritten = parseState.outputsWritten;
for (u = 0; u < ctx->Const.MaxTextureImageUnits; u++)
program->TexturesUsed[u] = parseState.texturesUsed[u];
/* save program parameters */
- program->Parameters = parseState.parameters;
+ program->Base.Parameters = parseState.parameters;
/* allocate registers for declared program parameters */
#if 00
_mesa_printf("-");
}
if (src->File == PROGRAM_NAMED_PARAM) {
- if (program->Parameters->Parameters[src->Index].Type == PROGRAM_CONSTANT) {
- _mesa_printf("{%g, %g, %g, %g}",
- program->Parameters->ParameterValues[src->Index][0],
- program->Parameters->ParameterValues[src->Index][1],
- program->Parameters->ParameterValues[src->Index][2],
- program->Parameters->ParameterValues[src->Index][3]);
+ if (program->Base.Parameters->Parameters[src->Index].Type
+ == PROGRAM_CONSTANT) {
+ const GLfloat *v;
+ v = program->Base.Parameters->ParameterValues[src->Index];
+ _mesa_printf("{%g, %g, %g, %g}", v[0], v[1], v[2], v[3]);
}
else {
ASSERT(program->Parameters->Parameters[src->Index].Type
== PROGRAM_NAMED_PARAM);
- _mesa_printf("%s", program->Parameters->Parameters[src->Index].Name);
+ _mesa_printf("%s", program->Base.Parameters->Parameters[src->Index].Name);
}
}
else if (src->File == PROGRAM_OUTPUT) {
{
const struct prog_instruction *inst;
- for (inst = program->Instructions; inst->Opcode != OPCODE_END; inst++) {
+ for (inst = program->Base.Instructions; inst->Opcode != OPCODE_END; inst++) {
int i;
for (i = 0; Instructions[i].name; i++) {
if (inst->Opcode == Instructions[i].opcode) {
}
fragProg = (struct fragment_program *) prog;
- v = _mesa_lookup_parameter_value(fragProg->Parameters, len, (char *) name);
+ v = _mesa_lookup_parameter_value(fragProg->Base.Parameters, len,
+ (char *) name);
if (v) {
v[0] = x;
v[1] = y;
}
fragProg = (struct fragment_program *) prog;
- v = _mesa_lookup_parameter_value(fragProg->Parameters, len, (char *) name);
+ v = _mesa_lookup_parameter_value(fragProg->Base.Parameters,
+ len, (char *) name);
if (v) {
params[0] = v[0];
params[1] = v[1];
}
else {
/* Using and ARB vertex program */
- if (ctx->VertexProgram.Current->Parameters) {
+ if (ctx->VertexProgram.Current->Base.Parameters) {
/* Grab the state GL state and put into registers */
_mesa_load_state_parameters(ctx,
- ctx->VertexProgram.Current->Parameters);
+ ctx->VertexProgram.Current->Base.Parameters);
}
}
}
else if (source->File == PROGRAM_ENV_PARAM)
return state->Parameters[reg];
else
- return state->Current->Parameters->ParameterValues[reg];
+ return state->Current->Base.Parameters->ParameterValues[reg];
}
else {
switch (source->File) {
return state->Parameters[source->Index];
case PROGRAM_STATE_VAR:
ASSERT(source->Index < state->Current->Parameters->NumParameters);
- return state->Current->Parameters->ParameterValues[source->Index];
+ return state->Current->Base.Parameters->ParameterValues[source->Index];
default:
_mesa_problem(NULL,
"Bad source register file in get_register_pointer");
ctx->VertexProgram.Inputs[VERT_ATTRIB_POS]);
/* XXX: This could go elsewhere */
- ctx->VertexProgram.Current->OutputsWritten |= VERT_BIT_POS;
+ ctx->VertexProgram.Current->Base.OutputsWritten |= VERT_BIT_POS;
}
- for (inst = program->Instructions; ; inst++) {
+
+ for (inst = program->Base.Instructions; ; inst++) {
if (ctx->VertexProgram.CallbackEnabled &&
ctx->VertexProgram.Callback) {
/* copy the compiled instructions */
assert(parseState.numInst <= MAX_NV_VERTEX_PROGRAM_INSTRUCTIONS);
newInst = (struct prog_instruction *)
- MALLOC(parseState.numInst * sizeof(struct prog_instruction));
+ _mesa_malloc(parseState.numInst * sizeof(struct prog_instruction));
if (!newInst) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV");
- FREE(programString);
+ _mesa_free(programString);
return; /* out of memory */
}
- MEMCPY(newInst, instBuffer,
- parseState.numInst * sizeof(struct prog_instruction));
+ _mesa_memcpy(newInst, instBuffer,
+ parseState.numInst * sizeof(struct prog_instruction));
/* install the program */
program->Base.Target = target;
if (program->Base.String) {
- FREE(program->Base.String);
+ _mesa_free(program->Base.String);
}
program->Base.String = programString;
program->Base.Format = GL_PROGRAM_FORMAT_ASCII_ARB;
- if (program->Instructions) {
- FREE(program->Instructions);
+ if (program->Base.Instructions) {
+ _mesa_free(program->Base.Instructions);
}
- program->Instructions = newInst;
- program->InputsRead = parseState.inputsRead;
- program->OutputsWritten = parseState.outputsWritten;
+ program->Base.Instructions = newInst;
+ program->Base.InputsRead = parseState.inputsRead;
+ program->Base.OutputsWritten = parseState.outputsWritten;
program->IsPositionInvariant = parseState.isPositionInvariant;
program->IsNVProgram = GL_TRUE;
break;
case OPCODE_PRINT:
_mesa_printf("PRINT '%s'", inst->Data);
- if (inst->SrcReg[0].File) {
+ if (inst->SrcReg[0].File != PROGRAM_UNDEFINED) {
_mesa_printf(", ");
PrintSrcReg(&inst->SrcReg[0]);
_mesa_printf(";\n");
{
const struct prog_instruction *inst;
- for (inst = program->Instructions; ; inst++) {
+ for (inst = program->Base.Instructions; ; inst++) {
_mesa_print_nv_vertex_instruction(inst);
if (inst->Opcode == OPCODE_END)
return;
if (prog->String)
_mesa_free(prog->String);
- if (prog->Target == GL_VERTEX_PROGRAM_NV ||
- prog->Target == GL_VERTEX_STATE_PROGRAM_NV) {
- struct vertex_program *vprog = (struct vertex_program *) prog;
- if (vprog->Instructions) {
- GLuint i;
- for (i = 0; i < vprog->Base.NumInstructions; i++) {
- if (vprog->Instructions[i].Data)
- _mesa_free(vprog->Instructions[i].Data);
- }
- _mesa_free(vprog->Instructions);
- }
- if (vprog->Parameters)
- _mesa_free_parameter_list(vprog->Parameters);
- }
- else if (prog->Target == GL_FRAGMENT_PROGRAM_NV ||
- prog->Target == GL_FRAGMENT_PROGRAM_ARB) {
- struct fragment_program *fprog = (struct fragment_program *) prog;
- if (fprog->Instructions) {
- GLuint i;
- for (i = 0; i < fprog->Base.NumInstructions; i++) {
- if (fprog->Instructions[i].Data)
- _mesa_free(fprog->Instructions[i].Data);
- }
- _mesa_free(fprog->Instructions);
+
+ if (prog->Instructions) {
+ GLuint i;
+ for (i = 0; i < prog->NumInstructions; i++) {
+ if (prog->Instructions[i].Data)
+ _mesa_free(prog->Instructions[i].Data);
}
- if (fprog->Parameters)
- _mesa_free_parameter_list(fprog->Parameters);
+ _mesa_free(prog->Instructions);
}
- else if (prog->Target == GL_FRAGMENT_SHADER_ATI) {
+
+ if (prog->Parameters)
+ _mesa_free_parameter_list(prog->Parameters);
+
+ if (prog->Target == GL_FRAGMENT_SHADER_ATI) {
struct ati_fragment_shader *atifs = (struct ati_fragment_shader *)prog;
GLuint i;
for (i = 0; i < MAX_NUM_PASSES_ATI; i++) {
/**
- * Print a vertx/fragment program to stdout.
- * XXX this function could be greatly improved.
+ * Print a single vertex/fragment program instruction.
*/
void
-_mesa_print_program(GLuint count, const struct prog_instruction *inst)
+_mesa_print_instruction(const struct prog_instruction *inst)
{
- GLuint i;
+ switch (inst->Opcode) {
+ case OPCODE_PRINT:
+ _mesa_printf("PRINT '%s'", inst->Data);
+ if (inst->SrcReg[0].File != PROGRAM_UNDEFINED) {
+ _mesa_printf(", ");
+ _mesa_printf("%s[%d]%s",
+ program_file_string(inst->SrcReg[0].File),
+ inst->SrcReg[0].Index,
+ swizzle_string(inst->SrcReg[0].Swizzle,
+ inst->SrcReg[0].NegateBase));
+ }
+ _mesa_printf(";\n");
+ break;
+ /* XXX check for a bunch of other special-case instructions */
+ default:
+ /* typical alu instruction */
+ {
+ const GLuint numRegs = _mesa_num_inst_src_regs(inst->Opcode);
+ GLuint j;
- for (i = 0; i < count; i++) {
- /* inst number */
- _mesa_printf("%3d: ", i);
+ _mesa_printf("%s", _mesa_opcode_string(inst->Opcode));
+
+ /* frag prog only */
+ if (inst->Saturate)
+ _mesa_printf("_SAT");
+
+ if (inst->DstReg.File != PROGRAM_UNDEFINED) {
+ _mesa_printf(" %s[%d]%s",
+ program_file_string(inst->DstReg.File),
+ inst->DstReg.Index,
+ writemask_string(inst->DstReg.WriteMask));
+ }
- switch (inst[i].Opcode) {
- case OPCODE_PRINT:
- _mesa_printf("PRINT '%s'", inst[i].Data);
- if (inst->SrcReg[0].File != PROGRAM_UNDEFINED) {
+ if (numRegs > 0)
_mesa_printf(", ");
+
+ for (j = 0; j < numRegs; j++) {
_mesa_printf("%s[%d]%s",
- program_file_string(inst[i].SrcReg[0].File),
- inst[i].SrcReg[0].Index,
- swizzle_string(inst[i].SrcReg[0].Swizzle,
- inst[i].SrcReg[0].NegateBase));
+ program_file_string(inst->SrcReg[j].File),
+ inst->SrcReg[j].Index,
+ swizzle_string(inst->SrcReg[j].Swizzle,
+ inst->SrcReg[j].NegateBase));
+ if (j + 1 < numRegs)
+ _mesa_printf(", ");
}
+
_mesa_printf(";\n");
- break;
- /* XXX check for a bunch of other special-case instructions */
- default:
- /* typical alu instruction */
- {
- const GLuint numRegs = _mesa_num_inst_src_regs(inst[i].Opcode);
- GLuint j;
-
- _mesa_printf("%s", _mesa_opcode_string(inst[i].Opcode));
-
- /* frag prog only */
- if (inst[i].Saturate)
- _mesa_printf("_SAT");
-
- if (inst[i].DstReg.File != PROGRAM_UNDEFINED) {
- _mesa_printf(" %s[%d]%s",
- program_file_string(inst[i].DstReg.File),
- inst[i].DstReg.Index,
- writemask_string(inst[i].DstReg.WriteMask));
- }
+ }
+ }
+}
- if (numRegs > 0)
- _mesa_printf(", ");
- for (j = 0; j < numRegs; j++) {
- _mesa_printf("%s[%d]%s",
- program_file_string(inst[i].SrcReg[j].File),
- inst[i].SrcReg[j].Index,
- swizzle_string(inst[i].SrcReg[j].Swizzle,
- inst[i].SrcReg[j].NegateBase));
- if (j + 1 < numRegs)
- _mesa_printf(", ");
- }
+/**
+ * Print a vertx/fragment program to stdout.
+ * XXX this function could be greatly improved.
+ */
+void
+_mesa_print_program(const struct program *prog)
+{
+ GLuint i;
+ for (i = 0; i < prog->NumInstructions; i++) {
+ _mesa_printf("%3d: ", i);
+ _mesa_print_instruction(prog->Instructions + i);
+ }
+}
- _mesa_printf(";\n");
- }
+
+/**
+ * Print all of a program's parameters.
+ */
+void
+_mesa_print_program_parameters(GLcontext *ctx, const struct program *prog)
+{
+ GLint i;
+
+ _mesa_printf("NumInstructions=%d\n", prog->NumInstructions);
+ _mesa_printf("NumTemporaries=%d\n", prog->NumTemporaries);
+ _mesa_printf("NumParameters=%d\n", prog->NumParameters);
+ _mesa_printf("NumAttributes=%d\n", prog->NumAttributes);
+ _mesa_printf("NumAddressRegs=%d\n", prog->NumAddressRegs);
+
+ _mesa_load_state_parameters(ctx, prog->Parameters);
+
+#if 0
+ _mesa_printf("Local Params:\n");
+ for (i = 0; i < MAX_PROGRAM_LOCAL_PARAMS; i++){
+ const GLfloat *p = prog->LocalParams[i];
+ _mesa_printf("%2d: %f, %f, %f, %f\n", i, p[0], p[1], p[2], p[3]);
+ }
+#endif
+
+ for (i = 0; i < prog->Parameters->NumParameters; i++){
+ const GLfloat *p = prog->Parameters->ParameterValues[i];
+ _mesa_printf("param %02d:", i);
+
+ switch (prog->Parameters->Parameters[i].Type) {
+ case PROGRAM_NAMED_PARAM:
+ _mesa_printf("%s", prog->Parameters->Parameters[i].Name);
+ _mesa_printf("(NAMED_PARAMETER)");
+ break;
+ case PROGRAM_CONSTANT:
+ _mesa_printf("(CONSTANT)");
+ break;
+ case PROGRAM_STATE_VAR:
+ _mesa_printf("(STATE)\n");
+ break;
+ default:
+ _mesa_printf("(UNK)\n");
+ break;
}
+
+ _mesa_printf("{ %f, %f, %f, %f }\n", p[0], p[1], p[2], p[3]);
}
}
-
/**********************************************************************/
/* API functions */
/**********************************************************************/
else {
/* try user-defined identifiers */
const GLfloat *value = _mesa_lookup_parameter_value(
- ctx->FragmentProgram.Current->Parameters, -1, reg);
+ ctx->FragmentProgram.Current->Base.Parameters, -1, reg);
if (value) {
COPY_4V(v, value);
}
extern void
-_mesa_print_program(GLuint count, const struct prog_instruction *inst);
+_mesa_print_instruction(const struct prog_instruction *inst);
+
+extern void
+_mesa_print_program(const struct program *prog);
+
+extern void
+_mesa_print_program_parameters(GLcontext *ctx, const struct program *prog);
/*
{
if (ctx->FragmentProgram._Active) {
struct fragment_program *program = ctx->FragmentProgram._Current;
- _mesa_load_state_parameters(ctx, program->Parameters);
+ _mesa_load_state_parameters(ctx, program->Base.Parameters);
}
}
/* Fallthrough */
case PROGRAM_NAMED_PARAM:
ASSERT(source->Index < (GLint) program->Parameters->NumParameters);
- src = program->Parameters->ParameterValues[source->Index];
+ src = program->Base.Parameters->ParameterValues[source->Index];
break;
default:
_mesa_problem(ctx, "Invalid input register file %d in fetch_vector4", source->File);
}
/* Add derivatives */
- if (program->InputsRead & (1 << FRAG_ATTRIB_WPOS)) {
+ if (program->Base.InputsRead & (1 << FRAG_ATTRIB_WPOS)) {
GLfloat *wpos = (GLfloat*) machine->Inputs[FRAG_ATTRIB_WPOS];
if (xOrY == 'X') {
wpos[0] += 1.0F;
wpos[3] += span->dwdy;
}
}
- if (program->InputsRead & (1 << FRAG_ATTRIB_COL0)) {
+ if (program->Base.InputsRead & (1 << FRAG_ATTRIB_COL0)) {
GLfloat *col0 = (GLfloat*) machine->Inputs[FRAG_ATTRIB_COL0];
if (xOrY == 'X') {
col0[0] += span->drdx * (1.0F / CHAN_MAXF);
col0[3] += span->dady * (1.0F / CHAN_MAXF);
}
}
- if (program->InputsRead & (1 << FRAG_ATTRIB_COL1)) {
+ if (program->Base.InputsRead & (1 << FRAG_ATTRIB_COL1)) {
GLfloat *col1 = (GLfloat*) machine->Inputs[FRAG_ATTRIB_COL1];
if (xOrY == 'X') {
col1[0] += span->dsrdx * (1.0F / CHAN_MAXF);
col1[3] += 0.0; /*XXX fix */
}
}
- if (program->InputsRead & (1 << FRAG_ATTRIB_FOGC)) {
+ if (program->Base.InputsRead & (1 << FRAG_ATTRIB_FOGC)) {
GLfloat *fogc = (GLfloat*) machine->Inputs[FRAG_ATTRIB_FOGC];
if (xOrY == 'X') {
fogc[0] += span->dfogdx;
}
}
for (u = 0; u < ctx->Const.MaxTextureCoordUnits; u++) {
- if (program->InputsRead & (1 << (FRAG_ATTRIB_TEX0 + u))) {
+ if (program->Base.InputsRead & (1 << (FRAG_ATTRIB_TEX0 + u))) {
GLfloat *tex = (GLfloat*) machine->Inputs[FRAG_ATTRIB_TEX0 + u];
/* XXX perspective-correct interpolation */
if (xOrY == 'X') {
#endif
for (pc = 0; pc < maxInst; pc++) {
- const struct prog_instruction *inst = program->Instructions + pc;
+ const struct prog_instruction *inst = program->Base.Instructions + pc;
if (ctx->FragmentProgram.CallbackEnabled &&
ctx->FragmentProgram.Callback) {
const struct fragment_program *program,
const struct sw_span *span, GLuint col )
{
- GLuint inputsRead = program->InputsRead;
+ GLuint inputsRead = program->Base.InputsRead;
GLuint u;
if (ctx->FragmentProgram.CallbackEnabled)
ctx->_CurrentProgram = GL_FRAGMENT_PROGRAM_ARB; /* or NV, doesn't matter */
- if (program->Parameters) {
- _mesa_load_state_parameters(ctx, program->Parameters);
+ if (program->Base.Parameters) {
+ _mesa_load_state_parameters(ctx, program->Base.Parameters);
}
for (i = 0; i < span->end; i++) {
UNCLAMPED_FLOAT_TO_CHAN(span->array->rgba[i][ACOMP], colOut[3]);
}
/* depth value */
- if (program->OutputsWritten & (1 << FRAG_RESULT_DEPR)) {
+ if (program->Base.OutputsWritten & (1 << FRAG_RESULT_DEPR)) {
const GLfloat depth
= ctx->FragmentProgram.Machine.Outputs[FRAG_RESULT_DEPR][2];
span->array->z[i] = IROUND(depth * ctx->DrawBuffer->_DepthMaxF);
}
}
- if (program->OutputsWritten & (1 << FRAG_RESULT_DEPR)) {
+ if (program->Base.OutputsWritten & (1 << FRAG_RESULT_DEPR)) {
span->interpMask &= ~SPAN_Z;
span->arrayMask |= SPAN_Z;
}
/* Compile instructions:
*/
for (i = 0; i < program->Base.NumInstructions; i++) {
- cvp_emit_inst(&cp, &program->Instructions[i]);
+ cvp_emit_inst(&cp, &program->Base.Instructions[i]);
}
/* Finish up:
if (!program || program->IsNVProgram)
return GL_TRUE;
- if (program->Parameters) {
- _mesa_load_state_parameters(ctx, program->Parameters);
+ if (program->Base.Parameters) {
+ _mesa_load_state_parameters(ctx, program->Base.Parameters);
}
p = (struct tnl_compiled_program *)program->TnlData;
m->nr_inputs = m->nr_outputs = 0;
for (i = 0; i < _TNL_ATTRIB_MAX; i++) {
- if (program->InputsRead & (1<<i)) {
+ if (program->Base.InputsRead & (1<<i)) {
GLuint j = m->nr_inputs++;
m->input[j].idx = i;
m->input[j].data = (GLfloat *)m->VB->AttribPtr[i]->data;
}
for (i = 0; i < VERT_RESULT_MAX; i++) {
- if (program->OutputsWritten & (1<<i)) {
+ if (program->Base.OutputsWritten & (1 << i)) {
GLuint j = m->nr_outputs++;
m->output[j].idx = i;
m->output[j].data = (GLfloat *)m->attribs[i].data;
VB->ClipPtr = &m->attribs[VERT_RESULT_HPOS];
VB->ClipPtr->count = VB->Count;
- outputs = program->OutputsWritten;
+ outputs = program->Base.OutputsWritten;
if (outputs & (1<<VERT_RESULT_COL0)) {
VB->ColorPtr[0] = &m->attribs[VERT_RESULT_COL0];
m->File[FILE_LOCAL_PARAM] = program->Base.LocalParams;
m->File[FILE_ENV_PARAM] = ctx->VertexProgram.Parameters;
/* GL_NV_vertex_programs can't reference GL state */
- if (program->Parameters)
- m->File[FILE_STATE_PARAM] = program->Parameters->ParameterValues;
+ if (program->Base.Parameters)
+ m->File[FILE_STATE_PARAM] = program->Base.Parameters->ParameterValues;
else
m->File[FILE_STATE_PARAM] = NULL;
}
/* the vertex array case */
for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) {
- if (program->InputsRead & (1 << attr)) {
+ if (program->Base.InputsRead & (1 << attr)) {
const GLubyte *ptr = (const GLubyte*) VB->AttribPtr[attr]->data;
const GLuint size = VB->AttribPtr[attr]->size;
const GLuint stride = VB->AttribPtr[attr]->stride;
/* Fixup fog an point size results if needed */
if (ctx->Fog.Enabled &&
- (program->OutputsWritten & (1 << VERT_RESULT_FOGC)) == 0) {
+ (program->Base.OutputsWritten & (1 << VERT_RESULT_FOGC)) == 0) {
ctx->VertexProgram.Outputs[VERT_RESULT_FOGC][0] = 1.0;
}
if (ctx->VertexProgram.PointSizeEnabled &&
- (program->OutputsWritten & (1 << VERT_RESULT_PSIZ)) == 0) {
+ (program->Base.OutputsWritten & (1 << VERT_RESULT_PSIZ)) == 0) {
ctx->VertexProgram.Outputs[VERT_RESULT_PSIZ][0] = ctx->Point.Size;
}
/*
* Mesa 3-D graphics library
- * Version: 6.3.1
+ * Version: 6.5
*
* Copyright (C) 2005 Tungsten Graphics All Rights Reserved.
*
*/
assert(fp);
- key->fragprog_inputs_read = fp->InputsRead;
+ key->fragprog_inputs_read = fp->Base.InputsRead;
key->separate_specular = (ctx->Light.Model.ColorControl ==
GL_SEPARATE_SPECULAR_COLOR);
static struct ureg register_input( struct tnl_program *p, GLuint input )
{
- p->program->InputsRead |= (1<<input);
+ p->program->Base.InputsRead |= (1<<input);
return make_ureg(PROGRAM_INPUT, input);
}
static struct ureg register_output( struct tnl_program *p, GLuint output )
{
- p->program->OutputsWritten |= (1<<output);
+ p->program->Base.OutputsWritten |= (1<<output);
return make_ureg(PROGRAM_OUTPUT, output);
}
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);
}
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);
}
}
_mesa_printf("%d:\t", line);
- _mesa_print_program(1, inst);
+ _mesa_print_instruction(inst);
}
}
GLuint line)
{
GLuint nr = p->program->Base.NumInstructions++;
- struct prog_instruction *inst = &p->program->Instructions[nr];
+ struct prog_instruction *inst = &p->program->Base.Instructions[nr];
if (p->program->Base.NumInstructions > MAX_INSN) {
_mesa_problem(0, "Out of instructions in emit_op3fn\n");
else
p.temp_reserved = ~((1<<max_temps)-1);
- p.program->Instructions = MALLOC(sizeof(struct prog_instruction) * MAX_INSN);
+ p.program->Base.Instructions
+ = MALLOC(sizeof(struct prog_instruction) * MAX_INSN);
p.program->Base.String = 0;
p.program->Base.NumInstructions =
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->InputsRead = 0;
- p.program->OutputsWritten = 0;
+ p.program->Base.Parameters = _mesa_new_parameter_list();
+ p.program->Base.InputsRead = 0;
+ p.program->Base.OutputsWritten = 0;
build_tnl_program( &p );
}