summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mesa/main/texenvprogram.c2
-rw-r--r--src/mesa/shader/arbprogparse.c6
-rw-r--r--src/mesa/shader/nvfragparse.c2
-rw-r--r--src/mesa/shader/nvvertparse.c2
-rw-r--r--src/mesa/shader/program.c40
-rw-r--r--src/mesa/shader/program_instruction.h2
-rw-r--r--src/mesa/shader/programopt.c5
7 files changed, 32 insertions, 27 deletions
diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c
index 5f798cc7df4..5cdb2342cd4 100644
--- a/src/mesa/main/texenvprogram.c
+++ b/src/mesa/main/texenvprogram.c
@@ -474,7 +474,7 @@ emit_op(struct texenv_fragment_program *p,
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 );
diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c
index 300f6676832..43e3bc183d4 100644
--- a/src/mesa/shader/arbprogparse.c
+++ b/src/mesa/shader/arbprogparse.c
@@ -2650,7 +2650,7 @@ parse_fp_instruction (GLcontext * ctx, const GLubyte ** inst,
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;
@@ -3142,7 +3142,7 @@ parse_vp_instruction (GLcontext * ctx, const GLubyte ** inst,
/* 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;
@@ -3684,7 +3684,7 @@ parse_instructions(GLcontext * ctx, const GLubyte * inst,
/* 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);
diff --git a/src/mesa/shader/nvfragparse.c b/src/mesa/shader/nvfragparse.c
index 49ce220944e..5f3a30b7416 100644
--- a/src/mesa/shader/nvfragparse.c
+++ b/src/mesa/shader/nvfragparse.c
@@ -1273,7 +1273,7 @@ Parse_InstructionSequence(struct parse_state *parseState,
GLubyte token[100];
/* Initialize the instruction */
- _mesa_init_instruction(inst);
+ _mesa_init_instructions(inst, 1);
/* special instructions */
if (Parse_String(parseState, "DEFINE")) {
diff --git a/src/mesa/shader/nvvertparse.c b/src/mesa/shader/nvvertparse.c
index f3821d7f43a..ecfe8ec334f 100644
--- a/src/mesa/shader/nvvertparse.c
+++ b/src/mesa/shader/nvvertparse.c
@@ -1143,7 +1143,7 @@ Parse_InstructionSequence(struct parse_state *parseState,
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))
diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c
index 8ac38ae1199..96c1388f846 100644
--- a/src/mesa/shader/program.c
+++ b/src/mesa/shader/program.c
@@ -1307,26 +1307,32 @@ _mesa_load_state_parameters(GLcontext *ctx,
/**
* 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;
+ }
}
diff --git a/src/mesa/shader/program_instruction.h b/src/mesa/shader/program_instruction.h
index 93bcfc240a9..cdec0ceb2a5 100644
--- a/src/mesa/shader/program_instruction.h
+++ b/src/mesa/shader/program_instruction.h
@@ -343,7 +343,7 @@ struct prog_instruction
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);
diff --git a/src/mesa/shader/programopt.c b/src/mesa/shader/programopt.c
index 55991dcce34..b17f5afc699 100644
--- a/src/mesa/shader/programopt.c
+++ b/src/mesa/shader/programopt.c
@@ -85,8 +85,8 @@ _mesa_insert_mvp_code(GLcontext *ctx, struct gl_vertex_program *vprog)
* 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;
@@ -191,8 +191,7 @@ _mesa_append_fog_code(GLcontext *ctx, struct gl_fragment_program *fprog)
}
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) {