GLuint nr = p->program->Base.NumInstructions++;
struct prog_instruction *inst = &p->program->Base.Instructions[nr];
- _mesa_init_instruction(inst);
+ _mesa_init_instructions(inst, 1);
inst->Opcode = op;
emit_arg( &inst->SrcReg[0], src0 );
GLubyte instClass, type, code;
GLboolean rel;
- _mesa_init_instruction(fp);
+ _mesa_init_instructions(fp, 1);
/* Record the position in the program string for debugging */
fp->StringPos = Program->Position;
/* The actual opcode name */
code = *(*inst)++;
- _mesa_init_instruction(vp);
+ _mesa_init_instructions(vp, 1);
/* Record the position in the program string for debugging */
vp->StringPos = Program->Position;
/* Finally, tag on an OPCODE_END instruction */
{
const GLuint numInst = Program->Base.NumInstructions;
- _mesa_init_instruction(Program->Base.Instructions + numInst);
+ _mesa_init_instructions(Program->Base.Instructions + numInst, 1);
Program->Base.Instructions[numInst].Opcode = OPCODE_END;
/* YYY Wrong Position in program, whatever, at least not random -> crash
Program->Position = parse_position (&inst);
GLubyte token[100];
/* Initialize the instruction */
- _mesa_init_instruction(inst);
+ _mesa_init_instructions(inst, 1);
/* special instructions */
if (Parse_String(parseState, "DEFINE")) {
struct prog_instruction *inst = program + parseState->numInst;
/* Initialize the instruction */
- _mesa_init_instruction(inst);
+ _mesa_init_instructions(inst, 1);
if (Parse_String(parseState, "MOV")) {
if (!Parse_UnaryOpInstruction(parseState, inst, OPCODE_MOV))
/**
* Initialize program instruction fields to defaults.
+ * \param inst first instruction to initialize
+ * \param count number of instructions to initialize
*/
void
-_mesa_init_instruction(struct prog_instruction *inst)
+_mesa_init_instructions(struct prog_instruction *inst, GLuint count)
{
- _mesa_bzero(inst, sizeof(struct prog_instruction));
-
- inst->SrcReg[0].File = PROGRAM_UNDEFINED;
- inst->SrcReg[0].Swizzle = SWIZZLE_NOOP;
- inst->SrcReg[1].File = PROGRAM_UNDEFINED;
- inst->SrcReg[1].Swizzle = SWIZZLE_NOOP;
- inst->SrcReg[2].File = PROGRAM_UNDEFINED;
- inst->SrcReg[2].Swizzle = SWIZZLE_NOOP;
-
- inst->DstReg.File = PROGRAM_UNDEFINED;
- inst->DstReg.WriteMask = WRITEMASK_XYZW;
- inst->DstReg.CondMask = COND_TR;
- inst->DstReg.CondSwizzle = SWIZZLE_NOOP;
-
- inst->SaturateMode = SATURATE_OFF;
- inst->Precision = FLOAT32;
+ GLuint i;
+
+ _mesa_bzero(inst, count * sizeof(struct prog_instruction));
+
+ for (i = 0; i < count; i++) {
+ inst[i].SrcReg[0].File = PROGRAM_UNDEFINED;
+ inst[i].SrcReg[0].Swizzle = SWIZZLE_NOOP;
+ inst[i].SrcReg[1].File = PROGRAM_UNDEFINED;
+ inst[i].SrcReg[1].Swizzle = SWIZZLE_NOOP;
+ inst[i].SrcReg[2].File = PROGRAM_UNDEFINED;
+ inst[i].SrcReg[2].Swizzle = SWIZZLE_NOOP;
+
+ inst[i].DstReg.File = PROGRAM_UNDEFINED;
+ inst[i].DstReg.WriteMask = WRITEMASK_XYZW;
+ inst[i].DstReg.CondMask = COND_TR;
+ inst[i].DstReg.CondSwizzle = SWIZZLE_NOOP;
+
+ inst[i].SaturateMode = SATURATE_OFF;
+ inst[i].Precision = FLOAT32;
+ }
}
extern void
-_mesa_init_instruction(struct prog_instruction *inst);
+_mesa_init_instructions(struct prog_instruction *inst, GLuint count);
extern GLuint
_mesa_num_inst_src_regs(enum prog_opcode opcode);
* newInst[2] = DP4 result.position.z, mvp.row[2], vertex.position;
* newInst[3] = DP4 result.position.w, mvp.row[3], vertex.position;
*/
+ _mesa_init_instructions(newInst, 4);
for (i = 0; i < 4; i++) {
- _mesa_init_instruction(newInst + i);
newInst[i].Opcode = OPCODE_DP4;
newInst[i].DstReg.File = PROGRAM_OUTPUT;
newInst[i].DstReg.Index = VERT_RESULT_HPOS;
}
assert(inst->Opcode == OPCODE_END); /* we'll overwrite this inst */
- for (i = 0; i < 6; i++)
- _mesa_init_instruction(inst + i);
+ _mesa_init_instructions(inst, 6);
/* emit instructions to compute fog blending factor */
if (fprog->FogOption == GL_LINEAR) {