diff options
author | Keith Whitwell <[email protected]> | 2006-09-05 10:01:24 +0000 |
---|---|---|
committer | Keith Whitwell <[email protected]> | 2006-09-05 10:01:24 +0000 |
commit | d5cbb49c2229c3eee4f3a4643c9142af8f3ad379 (patch) | |
tree | 8521e72b9573913c68418d07fb941dff23b209a8 /src/mesa | |
parent | 74b2166ff8e285ab2f9e49b48531619863ac78b2 (diff) |
Dynamically allocate instruction store for tnl programs according to
requirements.
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_vs_tnl.c | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_vs_tnl.c b/src/mesa/drivers/dri/i965/brw_vs_tnl.c index bfa0ddf80c4..cf3b904793d 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_tnl.c +++ b/src/mesa/drivers/dri/i965/brw_vs_tnl.c @@ -242,7 +242,6 @@ static void make_state_key( GLcontext *ctx, struct state_key *key ) */ #define PREFER_DP4 1 -#define BRW_TNL_MAX_INSN 256 /* Use uregs to represent registers internally, translate to Mesa's * expected formats on emit. @@ -269,6 +268,7 @@ struct tnl_program { const struct state_key *state; struct gl_vertex_program *program; + GLuint nr_instructions; GLuint temp_in_use; GLuint temp_reserved; @@ -517,24 +517,28 @@ static void emit_op3fn(struct tnl_program *p, GLuint line) { GLuint nr = p->program->Base.NumInstructions++; - struct prog_instruction *inst = &p->program->Base.Instructions[nr]; - if (p->program->Base.NumInstructions > BRW_TNL_MAX_INSN) { - _mesa_problem(0, "Out of instructions in emit_op3fn\n"); - return; + if (nr >= p->nr_instructions) { + p->program->Base.Instructions = + _mesa_realloc(p->program->Base.Instructions, + sizeof(struct prog_instruction) * p->nr_instructions, + sizeof(struct prog_instruction) * (p->nr_instructions *= 2)); } - - inst->Opcode = op; - inst->StringPos = 0; - inst->Data = 0; + + { + struct prog_instruction *inst = &p->program->Base.Instructions[nr]; + inst->Opcode = op; + inst->StringPos = 0; + inst->Data = 0; - emit_arg( &inst->SrcReg[0], src0 ); - emit_arg( &inst->SrcReg[1], src1 ); - emit_arg( &inst->SrcReg[2], src2 ); + emit_arg( &inst->SrcReg[0], src0 ); + emit_arg( &inst->SrcReg[1], src1 ); + emit_arg( &inst->SrcReg[2], src2 ); - emit_dst( &inst->DstReg, dest, mask ); + emit_dst( &inst->DstReg, dest, mask ); - debug_insn(inst, fn, line); + debug_insn(inst, fn, line); + } } @@ -1454,13 +1458,15 @@ static void build_new_tnl_program( const struct state_key *key, p.eye_normal = undef; p.identity = undef; p.temp_in_use = 0; + p.nr_instructions = 16; if (max_temps >= sizeof(int) * 8) p.temp_reserved = 0; else p.temp_reserved = ~((1<<max_temps)-1); - p.program->Base.Instructions = MALLOC(sizeof(struct prog_instruction) * BRW_TNL_MAX_INSN); + p.program->Base.Instructions = + _mesa_malloc(sizeof(struct prog_instruction) * p.nr_instructions); p.program->Base.String = 0; p.program->Base.NumInstructions = p.program->Base.NumTemporaries = |