From a328e469d328f8b6fd5afdfc21d576fa1a2c43fc Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 13 Dec 2006 14:58:13 -0700 Subject: Checkpoint work for new GLSL compiler back-end. Among changes: Remove ctx->FragmentProgram._Active Remove _UseTexEnvProgram Move _MaintainTnlProgram, _MaintainTexEnvProgram, _TexEnvProgram and _TnlProgram fields. Remove/disable old GLSL interpreter code. --- src/mesa/tnl/t_vp_build.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src/mesa/tnl/t_vp_build.c') diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c index 805d05ae72..a68127e653 100644 --- a/src/mesa/tnl/t_vp_build.c +++ b/src/mesa/tnl/t_vp_build.c @@ -382,11 +382,14 @@ static struct ureg register_const4f( struct tnl_program *p, { GLfloat values[4]; GLint idx; + GLuint swizzle; values[0] = s0; values[1] = s1; values[2] = s2; values[3] = s3; - idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values, 4 ); + idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values, 4, + &swizzle ); + ASSERT(swizzle == SWIZZLE_NOOP); return make_ureg(PROGRAM_STATE_VAR, idx); } @@ -1495,7 +1498,7 @@ void _tnl_UpdateFixedFunctionProgram( GLcontext *ctx ) GLuint hash; const struct gl_vertex_program *prev = ctx->VertexProgram._Current; - if (ctx->VertexProgram._Enabled == GL_FALSE) { + if (!ctx->VertexProgram._Current) { /* Grab all the relevent state and put it in a single structure: */ key = make_state_key(ctx); @@ -1503,45 +1506,42 @@ void _tnl_UpdateFixedFunctionProgram( GLcontext *ctx ) /* Look for an already-prepared program for this state: */ - ctx->_TnlProgram = (struct gl_vertex_program *) + ctx->VertexProgram._TnlProgram = (struct gl_vertex_program *) search_cache( tnl->vp_cache, hash, key, sizeof(*key) ); /* OK, we'll have to build a new one: */ - if (!ctx->_TnlProgram) { + if (!ctx->VertexProgram._TnlProgram) { if (0) _mesa_printf("Build new TNL program\n"); - ctx->_TnlProgram = (struct gl_vertex_program *) + ctx->VertexProgram._TnlProgram = (struct gl_vertex_program *) ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0); - create_new_program( key, ctx->_TnlProgram, + create_new_program( key, ctx->VertexProgram._TnlProgram, ctx->Const.VertexProgram.MaxTemps ); if (ctx->Driver.ProgramStringNotify) ctx->Driver.ProgramStringNotify( ctx, GL_VERTEX_PROGRAM_ARB, - &ctx->_TnlProgram->Base ); + &ctx->VertexProgram._TnlProgram->Base ); - cache_item(tnl->vp_cache, hash, key, ctx->_TnlProgram ); + cache_item(tnl->vp_cache, hash, key, ctx->VertexProgram._TnlProgram ); } else { FREE(key); if (0) _mesa_printf("Found existing TNL program for key %x\n", hash); } - ctx->VertexProgram._Current = ctx->_TnlProgram; - } - else { - ctx->VertexProgram._Current = ctx->VertexProgram.Current; + ctx->VertexProgram._Current = ctx->VertexProgram._TnlProgram; } /* Tell the driver about the change. Could define a new target for * this? */ - if (ctx->VertexProgram._Current != prev && - ctx->Driver.BindProgram) + if (ctx->VertexProgram._Current != prev && ctx->Driver.BindProgram) { ctx->Driver.BindProgram(ctx, GL_VERTEX_PROGRAM_ARB, (struct gl_program *) ctx->VertexProgram._Current); + } } void _tnl_ProgramCacheInit( GLcontext *ctx ) -- cgit v1.2.3 From 60a7200c0de7fc2925430b466739b4021087d14c Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 15 Dec 2006 10:08:59 -0700 Subject: updated includes --- src/mesa/tnl/t_vb_arbprogram.c | 4 +++- src/mesa/tnl/t_vb_program.c | 3 ++- src/mesa/tnl/t_vp_build.c | 7 +++++-- 3 files changed, 10 insertions(+), 4 deletions(-) (limited to 'src/mesa/tnl/t_vp_build.c') diff --git a/src/mesa/tnl/t_vb_arbprogram.c b/src/mesa/tnl/t_vb_arbprogram.c index b7975f3a4e..c59d98e118 100644 --- a/src/mesa/tnl/t_vb_arbprogram.c +++ b/src/mesa/tnl/t_vb_arbprogram.c @@ -37,13 +37,15 @@ #include "arbprogparse.h" #include "light.h" #include "program.h" +#include "prog_instruction.h" +#include "prog_parameter.h" +#include "prog_statevars.h" #include "programopt.h" #include "math/m_matrix.h" #include "t_context.h" #include "t_pipeline.h" #include "t_vb_arbprogram.h" #include "tnl.h" -#include "program_instruction.h" #define DISASSEM 0 diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c index c901de0588..9df649c5e6 100644 --- a/src/mesa/tnl/t_vb_program.c +++ b/src/mesa/tnl/t_vb_program.c @@ -42,7 +42,8 @@ #include "program.h" #include "simple_list.h" #include "mtypes.h" -#include "program_instruction.h" +#include "prog_instruction.h" +#include "prog_statevars.h" #include "nvvertexec.h" #include "nvprogram.h" diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c index a68127e653..5e146bfb36 100644 --- a/src/mesa/tnl/t_vp_build.c +++ b/src/mesa/tnl/t_vp_build.c @@ -33,11 +33,14 @@ #include "glheader.h" #include "macros.h" #include "enums.h" +#include "program.h" +#include "prog_instruction.h" +#include "prog_parameter.h" +#include "prog_print.h" +#include "prog_statevars.h" #include "t_context.h" /* NOTE: very light dependency on this */ #include "t_vp_build.h" -#include "shader/program.h" -#include "shader/program_instruction.h" struct state_key { unsigned light_global_enabled:1; -- cgit v1.2.3 From ff917003f6ed35b9ef966397a58c80dc7df98bff Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 24 Jan 2007 14:14:14 -0700 Subject: use FRAG_BIT_TEX() --- src/mesa/tnl/t_vp_build.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa/tnl/t_vp_build.c') diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c index 5e146bfb36..d80afaf245 100644 --- a/src/mesa/tnl/t_vp_build.c +++ b/src/mesa/tnl/t_vp_build.c @@ -1213,7 +1213,7 @@ static void build_texture_transform( struct tnl_program *p ) for (i = 0; i < MAX_TEXTURE_UNITS; i++) { - if (!(p->state->fragprog_inputs_read & (FRAG_BIT_TEX0<state->fragprog_inputs_read & (FRAG_BIT_TEX(i)))) continue; if (p->state->unit[i].texgen_enabled || -- cgit v1.2.3 From e713c21bd09468887faceebcba9a62a406321c07 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 24 Jan 2007 14:15:01 -0700 Subject: remove some parenthesis --- src/mesa/tnl/t_vp_build.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa/tnl/t_vp_build.c') diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c index d80afaf245..47fed32904 100644 --- a/src/mesa/tnl/t_vp_build.c +++ b/src/mesa/tnl/t_vp_build.c @@ -1213,7 +1213,7 @@ static void build_texture_transform( struct tnl_program *p ) for (i = 0; i < MAX_TEXTURE_UNITS; i++) { - if (!(p->state->fragprog_inputs_read & (FRAG_BIT_TEX(i)))) + if (!(p->state->fragprog_inputs_read & FRAG_BIT_TEX(i))) continue; if (p->state->unit[i].texgen_enabled || -- cgit v1.2.3 From cf92c727979e434d148b23d20f2e4e0f4bc4de61 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 5 Feb 2007 15:00:07 -0700 Subject: Initial implementation of high-level flow-control instructions. IF/ELSE/ENDIF and BEGIN_LOOP/END_LOOP/BREAK instructions seem to work. Disabled by default though until better tested. Implemented IR_NOT, but needs optimization. --- src/mesa/shader/slang/slang_codegen.c | 88 ++++++++++++++++++++++++++++++++--- src/mesa/shader/slang/slang_emit.c | 72 ++++++++++++++++++++++++++++ src/mesa/shader/slang/slang_ir.h | 2 + src/mesa/swrast/s_fragprog.c | 38 ++++++++++++--- src/mesa/tnl/t_vp_build.c | 2 +- 5 files changed, 189 insertions(+), 13 deletions(-) (limited to 'src/mesa/tnl/t_vp_build.c') diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c index 72f58a9ebd..2dd9ccc6fd 100644 --- a/src/mesa/shader/slang/slang_codegen.c +++ b/src/mesa/shader/slang/slang_codegen.c @@ -47,6 +47,8 @@ #include "slang_print.h" +static GLboolean UseHighLevelInstructions = GL_TRUE; + static slang_ir_node * _slang_gen_operation(slang_assemble_ctx * A, slang_operation *oper); @@ -506,6 +508,7 @@ new_node(slang_ir_opcode op, slang_ir_node *left, slang_ir_node *right) n->Children[0] = left; n->Children[1] = right; n->Writemask = WRITEMASK_XYZW; + n->InstLocation = -1; } return n; } @@ -567,6 +570,26 @@ new_jump(slang_atom target) } +static slang_ir_node * +new_begin_loop(void) +{ + slang_ir_node *n = new_node(IR_BEGIN_LOOP, NULL, NULL); + return n; +} + + +static slang_ir_node * +new_end_loop(slang_ir_node *beginNode) +{ + slang_ir_node *n = new_node(IR_END_LOOP, NULL, NULL); + assert(beginNode); + if (n) { + n->BranchNode = beginNode; + } + return n; +} + + /** * New IR_VAR node - a reference to a previously declared variable. */ @@ -1304,7 +1327,7 @@ _slang_gen_function_call_name(slang_assemble_ctx *A, const char *name, /** - * Generate IR tree for a while-loop. + * Generate IR tree for a while-loop. Use BRA-nch instruction. */ static slang_ir_node * _slang_gen_while(slang_assemble_ctx * A, const slang_operation *oper) @@ -1313,7 +1336,7 @@ _slang_gen_while(slang_assemble_ctx * A, const slang_operation *oper) * label "__startWhile" * eval expr (child[0]), updating condcodes * branch if false to "__endWhile" - * code body + * body code * jump "__startWhile" * label "__endWhile" */ @@ -1353,6 +1376,51 @@ _slang_gen_while(slang_assemble_ctx * A, const slang_operation *oper) } +/** + * Generate IR tree for a while-loop using high-level BGNLOOP/ENDLOOP, + * IF/ENDIF instructions. + */ +static slang_ir_node * +_slang_gen_hl_while(slang_assemble_ctx * A, const slang_operation *oper) +{ + /* + * BGNLOOP + * eval expr (child[0]), updating condcodes + * IF !expr THEN + * BRK + * ENDIF + * body code + * ENDLOOP + */ + slang_ir_node *beginLoop, *endLoop, *ifThen, *endif; + slang_ir_node *brk, *cond, *body, *tree; + + beginLoop = new_begin_loop(); + + cond = _slang_gen_operation(A, &oper->children[0]); + cond = new_node(IR_NOT, cond, NULL); + cond = _slang_gen_cond(cond); + + ifThen = new_node(IR_IF, cond, NULL); + tree = new_seq(beginLoop, ifThen); + + brk = new_node(IR_BREAK, NULL, NULL); + tree = new_seq(tree, brk); + + endif = new_node(IR_ENDIF, NULL, NULL); + tree = new_seq(tree, endif); + + body = _slang_gen_operation(A, &oper->children[1]); + if (body) + tree = new_seq(tree, body); + + endLoop = new_end_loop(beginLoop); + tree = new_seq(tree, endLoop); + + return tree; +} + + /** * Generate IR tree for a do-while-loop. */ @@ -1517,7 +1585,7 @@ _slang_gen_if(slang_assemble_ctx * A, const slang_operation *oper) * IF/ELSE/ENDIF instructions */ static slang_ir_node * -_slang_gen_if2(slang_assemble_ctx * A, const slang_operation *oper) +_slang_gen_hl_if(slang_assemble_ctx * A, const slang_operation *oper) { /* * eval expr (child[0]), updating condcodes @@ -1529,6 +1597,10 @@ _slang_gen_if2(slang_assemble_ctx * A, const slang_operation *oper) * "false" code block * label "__endif" */ + /* XXX special cases to check for: + * if body of conditiona is just a "break", emit a conditional break + * instruction. + */ const GLboolean haveElseClause = !_slang_is_noop(&oper->children[2]); slang_ir_node *ifNode, *cond, *trueBody, *elseNode, *falseBody, *endifNode; slang_ir_node *tree; @@ -2261,7 +2333,10 @@ _slang_gen_operation(slang_assemble_ctx * A, slang_operation *oper) return _slang_gen_operation(A, &oper->children[0]); break; case slang_oper_while: - return _slang_gen_while(A, oper); + if (UseHighLevelInstructions) + return _slang_gen_hl_while(A, oper); + else + return _slang_gen_while(A, oper); case slang_oper_do: return _slang_gen_do(A, oper); case slang_oper_for: @@ -2427,8 +2502,9 @@ _slang_gen_operation(slang_assemble_ctx * A, slang_operation *oper) case slang_oper_identifier: return _slang_gen_variable(A, oper); case slang_oper_if: - if (A->program->Target == GL_FRAGMENT_PROGRAM_ARB) { - return _slang_gen_if(A, oper); + if (A->program->Target == GL_FRAGMENT_PROGRAM_ARB + && UseHighLevelInstructions) { + return _slang_gen_hl_if(A, oper); } else { /* XXX update tnl executor */ diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c index 756bbe9587..311eea1e6a 100644 --- a/src/mesa/shader/slang/slang_emit.c +++ b/src/mesa/shader/slang/slang_emit.c @@ -1005,6 +1005,42 @@ emit_cond(slang_var_table *vt, slang_ir_node *n, struct gl_program *prog) } +/** + * Logical-NOT + */ +static struct prog_instruction * +emit_not(slang_var_table *vt, slang_ir_node *n, struct gl_program *prog) +{ + GLfloat zero = 0.0; + slang_ir_storage st; + struct prog_instruction *inst; + + /* need zero constant */ + st.File = PROGRAM_CONSTANT; + st.Size = 1; + st.Index = _mesa_add_unnamed_constant(prog->Parameters, &zero, + 1, &st.Swizzle); + + /* child expr */ + (void) emit(vt, n->Children[0], prog); + /* XXXX if child instr is SGT convert to SLE, if SEQ, SNE, etc */ + + if (!n->Store) + if (!alloc_temp_storage(vt, n, n->Children[0]->Store->Size)) + return NULL; + + inst = new_instruction(prog, OPCODE_SEQ); + storage_to_dst_reg(&inst->DstReg, n->Store, n->Writemask); + storage_to_src_reg(&inst->SrcReg[0], n->Children[0]->Store); + storage_to_src_reg(&inst->SrcReg[1], &st); + + free_temp_storage(vt, n->Children[0]); + + return inst; +} + + + /** * Remove any SWIZZLE_NIL terms from given swizzle mask (smear prev term). * Ex: fix_swizzle("zyNN") -> "zyyy" @@ -1202,6 +1238,9 @@ emit(slang_var_table *vt, slang_ir_node *n, struct gl_program *prog) case IR_COND: return emit_cond(vt, n, prog); + case IR_NOT: + return emit_not(vt, n, prog); + case IR_LABEL: return emit_label(n->Target, prog); case IR_JUMP: @@ -1235,6 +1274,39 @@ emit(slang_var_table *vt, slang_ir_node *n, struct gl_program *prog) return inst; } + case IR_BEGIN_LOOP: + { + /* save location of this instruction, used by OPCODE_ENDLOOP */ + n->InstLocation = prog->NumInstructions; + (void) new_instruction(prog, OPCODE_BGNLOOP); + } + break; + case IR_END_LOOP: + { + struct prog_instruction *inst; + inst = new_instruction(prog, OPCODE_ENDLOOP); + assert(n->BranchNode); + assert(n->BranchNode->InstLocation >= 0); + /* The instruction BranchTarget points to top of loop */ + inst->BranchTarget = n->BranchNode->InstLocation; + return inst; + } + case IR_CONT: + return new_instruction(prog, OPCODE_CONT); + case IR_BREAK: + { + struct prog_instruction *inst; + inst = new_instruction(prog, OPCODE_BRK); + inst->DstReg.CondMask = COND_TR; /* always true */ + return inst; + } + case IR_BEGIN_SUB: + return new_instruction(prog, OPCODE_BGNSUB); + case IR_END_SUB: + return new_instruction(prog, OPCODE_ENDSUB); + case IR_RETURN: + return new_instruction(prog, OPCODE_RET); + default: _mesa_problem(NULL, "Unexpected IR opcode in emit()\n"); abort(); diff --git a/src/mesa/shader/slang/slang_ir.h b/src/mesa/shader/slang/slang_ir.h index ac1ea4dbb4..df5fc06779 100644 --- a/src/mesa/shader/slang/slang_ir.h +++ b/src/mesa/shader/slang/slang_ir.h @@ -150,6 +150,8 @@ typedef struct slang_ir_node_ GLfloat Value[4]; /**< If Opcode == IR_FLOAT */ slang_variable *Var; /**< If Opcode == IR_VAR or IR_VAR_DECL */ slang_ir_storage *Store; /**< location of result of this operation */ + GLint InstLocation; /**< Location of instruction emitted for this node */ + struct slang_ir_node_ *BranchNode; /**< Used for branch instructions */ } slang_ir_node; diff --git a/src/mesa/swrast/s_fragprog.c b/src/mesa/swrast/s_fragprog.c index 00231aeae8..287dd9b1db 100644 --- a/src/mesa/swrast/s_fragprog.c +++ b/src/mesa/swrast/s_fragprog.c @@ -625,7 +625,7 @@ execute_program( GLcontext *ctx, GLuint column ) { const GLuint MAX_EXEC = 10000; - GLuint pc, total = 0; + GLint pc, total = 0, loopDepth = 0; if (DEBUG_FRAG) { printf("execute fragment program --------------------\n"); @@ -642,7 +642,7 @@ execute_program( GLcontext *ctx, } if (DEBUG_FRAG) { - _mesa_print_instruction(inst); + _mesa_print_instruction(inst, 0); } switch (inst->Opcode) { @@ -676,8 +676,13 @@ execute_program( GLcontext *ctx, } break; case OPCODE_BGNLOOP: /* begin loop */ + loopDepth++; break; case OPCODE_ENDLOOP: /* end loop */ + loopDepth--; + assert(loopDepth >= 0); + /* subtract 1 here since pc is incremented by for(pc) loop */ + pc = inst->BranchTarget - 1; /* go to matching BNGLOOP */ break; case OPCODE_BGNSUB: /* begin subroutine */ break; @@ -701,7 +706,19 @@ execute_program( GLcontext *ctx, } break; case OPCODE_BRK: /* break out of loop */ - /* assert inside loop */ + if (loopDepth == 0) { + _mesa_problem(ctx, "BRK not inside a loop"); + } + /* search for OPCODE_ENDLOOP */ + do { + pc++; + inst = program->Base.Instructions + pc; + if (inst->Opcode == OPCODE_ENDLOOP) { + loopDepth--; + assert(loopDepth >= 0); + break; + } + } while (pc < maxInst); break; case OPCODE_CAL: /* Call subroutine */ { @@ -880,20 +897,25 @@ execute_program( GLcontext *ctx, /* do if-clause (just continue execution) */ } else { - /* do else-clause, or go to endif */ + /* search for else-clause or endif */ + /* XXX could encode location of the else/endif statement + * in the IF instruction to avoid searching... + */ GLint ifDepth = 1; do { pc++; inst = program->Base.Instructions + pc; if (inst->Opcode == OPCODE_END) { /* mal-formed program! */ - abort(); + _mesa_problem(ctx, "END found before ELSE/ENDIF"); + return GL_FALSE; } else if (inst->Opcode == OPCODE_IF) { + /* nested if */ ifDepth++; } else if (inst->Opcode == OPCODE_ELSE) { - if (ifDepth == 0) { + if (ifDepth == 1) { /* ok, continue normal execution */ break; } @@ -1335,6 +1357,10 @@ execute_program( GLcontext *ctx, result[2] = (a[2] > b[2]) ? 1.0F : 0.0F; result[3] = (a[3] > b[3]) ? 1.0F : 0.0F; store_vector4( inst, machine, result ); + if (DEBUG_FRAG) { + printf("SGT %g %g %g %g\n", + result[0], result[1], result[2], result[3]); + } } break; case OPCODE_SIN: diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c index 47fed32904..6fb14e7caa 100644 --- a/src/mesa/tnl/t_vp_build.c +++ b/src/mesa/tnl/t_vp_build.c @@ -497,7 +497,7 @@ static void debug_insn( struct prog_instruction *inst, const char *fn, } _mesa_printf("%d:\t", line); - _mesa_print_instruction(inst); + _mesa_print_instruction(inst, 0); } } -- cgit v1.2.3 From 501ee87180047dd04afc69103c31e1eae5374bf1 Mon Sep 17 00:00:00 2001 From: Brian Date: Sat, 17 Feb 2007 09:15:00 -0700 Subject: Lots of changes to prog_print.c code. Mainly, allow printing programs in either ARB, NV or "debug" formats. --- src/mesa/shader/prog_print.c | 352 ++++++++++++++++++++++++++++++++++++++----- src/mesa/shader/prog_print.h | 24 ++- src/mesa/swrast/s_fragprog.c | 3 +- src/mesa/tnl/t_vp_build.c | 2 +- 4 files changed, 336 insertions(+), 45 deletions(-) (limited to 'src/mesa/tnl/t_vp_build.c') diff --git a/src/mesa/shader/prog_print.c b/src/mesa/shader/prog_print.c index 0adb589daa..647ade9505 100644 --- a/src/mesa/shader/prog_print.c +++ b/src/mesa/shader/prog_print.c @@ -37,11 +37,12 @@ #include "prog_statevars.h" + /** * Return string name for given program/register file. */ static const char * -program_file_string(enum register_file f) +file_string(enum register_file f, gl_prog_print_mode mode) { switch (f) { case PROGRAM_TEMPORARY: @@ -76,6 +77,213 @@ program_file_string(enum register_file f) } +/** + * Return ARB_v/f_prog-style input attrib string. + */ +static const char * +arb_input_attrib_string(GLint index, GLenum progType) +{ + const char *vertAttribs[] = { + "vertex.position", + "vertex.weight", + "vertex.normal", + "vertex.color.primary", + "vertex.color.secondary", + "vertex.fogcoord", + "vertex.(six)", + "vertex.(seven)", + "vertex.texcoord[0]", + "vertex.texcoord[1]", + "vertex.texcoord[2]", + "vertex.texcoord[3]", + "vertex.texcoord[4]", + "vertex.texcoord[5]", + "vertex.texcoord[6]", + "vertex.texcoord[7]" + }; + const char *fragAttribs[] = { + "fragment.position", + "fragment.color.primary", + "fragment.color.secondary", + "fragment.fogcoord", + "fragment.texcoord[0]", + "fragment.texcoord[1]", + "fragment.texcoord[2]", + "fragment.texcoord[3]", + "fragment.texcoord[4]", + "fragment.texcoord[5]", + "fragment.texcoord[6]", + "fragment.texcoord[7]", + "fragment.varying[0]", + "fragment.varying[1]", + "fragment.varying[2]", + "fragment.varying[3]", + "fragment.varying[4]", + "fragment.varying[5]", + "fragment.varying[6]", + "fragment.varying[7]" + }; + + if (progType == GL_VERTEX_PROGRAM_ARB) { + assert(index < sizeof(vertAttribs) / sizeof(vertAttribs[0])); + return vertAttribs[index]; + } + else { + assert(index < sizeof(fragAttribs) / sizeof(fragAttribs[0])); + return fragAttribs[index]; + } +} + + +/** + * Return ARB_v/f_prog-style output attrib string. + */ +static const char * +arb_output_attrib_string(GLint index, GLenum progType) +{ + const char *vertResults[] = { + "result.position", + "result.color.primary", + "result.color.secondary", + "result.fogcoord", + "result.texcoord[0]", + "result.texcoord[1]", + "result.texcoord[2]", + "result.texcoord[3]", + "result.texcoord[4]", + "result.texcoord[5]", + "result.texcoord[6]", + "result.texcoord[7]", + "result.varying[0]", + "result.varying[1]", + "result.varying[2]", + "result.varying[3]", + "result.varying[4]", + "result.varying[5]", + "result.varying[6]", + "result.varying[7]" + }; + const char *fragResults[] = { + "result.color", + "result.depth" + }; + + if (progType == GL_VERTEX_PROGRAM_ARB) { + assert(index < sizeof(vertResults) / sizeof(vertResults[0])); + return vertResults[index]; + } + else { + assert(index < sizeof(fragResults) / sizeof(fragResults[0])); + return fragResults[index]; + } +} + + +/** + * Return string representation of the given register. + * Note that some types of registers (like PROGRAM_UNIFORM) aren't defined + * by the ARB/NV program languages so we've taken some liberties here. + * \param file the register file (PROGRAM_INPUT, PROGRAM_TEMPORARY, etc) + * \param index number of the register in the register file + * \param mode the output format/mode/style + * \param prog pointer to containing program + */ +static const char * +reg_string(enum register_file f, GLint index, gl_prog_print_mode mode, + const struct gl_program *prog) +{ + static char str[100]; + + str[0] = 0; + + switch (mode) { + case PROG_PRINT_DEBUG: + sprintf(str, "%s[%d]", file_string(f, mode), index); + break; + + case PROG_PRINT_ARB: + switch (f) { + case PROGRAM_INPUT: + sprintf(str, "%s", arb_input_attrib_string(index, prog->Target)); + break; + case PROGRAM_OUTPUT: + sprintf(str, "%s", arb_output_attrib_string(index, prog->Target)); + break; + case PROGRAM_TEMPORARY: + sprintf(str, "temp%d", index); + break; + case PROGRAM_ENV_PARAM: + sprintf(str, "program.env[%d]", index); + break; + case PROGRAM_LOCAL_PARAM: + sprintf(str, "program.local[%d]", index); + break; + case PROGRAM_VARYING: /* extension */ + sprintf(str, "varying[%d]", index); + break; + case PROGRAM_CONSTANT: /* extension */ + sprintf(str, "constant[%d]", index); + break; + case PROGRAM_UNIFORM: /* extension */ + sprintf(str, "uniform[%d]", index); + break; + case PROGRAM_STATE_VAR: + { + struct gl_program_parameter *param + = prog->Parameters->Parameters + index; + sprintf(str, _mesa_program_state_string(param->StateIndexes)); + } + break; + case PROGRAM_ADDRESS: + sprintf(str, "A%d", index); + break; + default: + _mesa_problem(NULL, "bad file in reg_string()"); + } + break; + + case PROG_PRINT_NV: + switch (f) { + case PROGRAM_INPUT: + if (prog->Target == GL_VERTEX_PROGRAM_ARB) + sprintf(str, "v[%d]", index); + else + sprintf(str, "f[%d]", index); + break; + case PROGRAM_OUTPUT: + sprintf(str, "o[%d]", index); + break; + case PROGRAM_TEMPORARY: + sprintf(str, "R%d", index); + break; + case PROGRAM_ENV_PARAM: + sprintf(str, "c[%d]", index); + break; + case PROGRAM_VARYING: /* extension */ + sprintf(str, "varying[%d]", index); + break; + case PROGRAM_UNIFORM: /* extension */ + sprintf(str, "uniform[%d]", index); + break; + case PROGRAM_CONSTANT: /* extension */ + sprintf(str, "constant[%d]", index); + break; + case PROGRAM_STATE_VAR: /* extension */ + sprintf(str, "state[%d]", index); + break; + default: + _mesa_problem(NULL, "bad file in reg_string()"); + } + break; + + default: + _mesa_problem(NULL, "bad mode in reg_string()"); + } + + return str; +} + + /** * Return a string representation of the given swizzle word. * If extended is true, use extended (comma-separated) format. @@ -172,22 +380,38 @@ condcode_string(GLuint condcode) static void -print_dst_reg(const struct prog_dst_register *dstReg) +print_dst_reg(const struct prog_dst_register *dstReg, gl_prog_print_mode mode, + const struct gl_program *prog) { - _mesa_printf(" %s[%d]%s", - program_file_string((enum register_file) dstReg->File), + _mesa_printf("%s%s", + reg_string((enum register_file) dstReg->File, + dstReg->Index, mode, prog), + writemask_string(dstReg->WriteMask)); + +#if 0 + _mesa_printf("%s[%d]%s", + file_string((enum register_file) dstReg->File, mode), dstReg->Index, writemask_string(dstReg->WriteMask)); +#endif } static void -print_src_reg(const struct prog_src_register *srcReg) +print_src_reg(const struct prog_src_register *srcReg, gl_prog_print_mode mode, + const struct gl_program *prog) { + _mesa_printf("%s%s", + reg_string((enum register_file) srcReg->File, + srcReg->Index, mode, prog), + swizzle_string(srcReg->Swizzle, + srcReg->NegateBase, GL_FALSE)); +#if 0 _mesa_printf("%s[%d]%s", - program_file_string((enum register_file) srcReg->File), + file_string((enum register_file) srcReg->File, mode), srcReg->Index, swizzle_string(srcReg->Swizzle, srcReg->NegateBase, GL_FALSE)); +#endif } static void @@ -200,10 +424,11 @@ print_comment(const struct prog_instruction *inst) } -void -_mesa_print_alu_instruction(const struct prog_instruction *inst, - const char *opcode_string, - GLuint numRegs) +static void +print_alu_instruction(const struct prog_instruction *inst, + const char *opcode_string, GLuint numRegs, + gl_prog_print_mode mode, + const struct gl_program *prog) { GLuint j; @@ -215,8 +440,9 @@ _mesa_print_alu_instruction(const struct prog_instruction *inst, if (inst->SaturateMode == SATURATE_ZERO_ONE) _mesa_printf("_SAT"); + _mesa_printf(" "); if (inst->DstReg.File != PROGRAM_UNDEFINED) { - print_dst_reg(&inst->DstReg); + print_dst_reg(&inst->DstReg, mode, prog); } else { _mesa_printf(" ???"); @@ -226,7 +452,7 @@ _mesa_print_alu_instruction(const struct prog_instruction *inst, _mesa_printf(", "); for (j = 0; j < numRegs; j++) { - print_src_reg(inst->SrcReg + j); + print_src_reg(inst->SrcReg + j, mode, prog); if (j + 1 < numRegs) _mesa_printf(", "); } @@ -235,11 +461,21 @@ _mesa_print_alu_instruction(const struct prog_instruction *inst, } +void +_mesa_print_instruction(const struct prog_instruction *inst) +{ + /* note: 4th param should be ignored for PROG_PRINT_DEBUG */ + _mesa_print_instruction_opt(inst, 0, PROG_PRINT_DEBUG, NULL); +} + + /** * Print a single vertex/fragment program instruction. */ GLint -_mesa_print_instruction(const struct prog_instruction *inst, GLint indent) +_mesa_print_instruction_opt(const struct prog_instruction *inst, GLint indent, + gl_prog_print_mode mode, + const struct gl_program *prog) { GLuint i; @@ -260,7 +496,8 @@ _mesa_print_instruction(const struct prog_instruction *inst, GLint indent) if (inst->SrcReg[0].File != PROGRAM_UNDEFINED) { _mesa_printf(", "); _mesa_printf("%s[%d]%s", - program_file_string((enum register_file) inst->SrcReg[0].File), + file_string((enum register_file) inst->SrcReg[0].File, + mode), inst->SrcReg[0].Index, swizzle_string(inst->SrcReg[0].Swizzle, inst->SrcReg[0].NegateBase, GL_FALSE)); @@ -273,9 +510,11 @@ _mesa_print_instruction(const struct prog_instruction *inst, GLint indent) _mesa_printf("SWZ"); if (inst->SaturateMode == SATURATE_ZERO_ONE) _mesa_printf("_SAT"); - print_dst_reg(&inst->DstReg); + _mesa_printf(" "); + print_dst_reg(&inst->DstReg, mode, prog); _mesa_printf("%s[%d], %s", - program_file_string((enum register_file) inst->SrcReg[0].File), + file_string((enum register_file) inst->SrcReg[0].File, + mode), inst->SrcReg[0].Index, swizzle_string(inst->SrcReg[0].Swizzle, inst->SrcReg[0].NegateBase, GL_TRUE)); @@ -287,9 +526,10 @@ _mesa_print_instruction(const struct prog_instruction *inst, GLint indent) _mesa_printf("%s", _mesa_opcode_string(inst->Opcode)); if (inst->SaturateMode == SATURATE_ZERO_ONE) _mesa_printf("_SAT"); - print_dst_reg(&inst->DstReg); + _mesa_printf(" "); + print_dst_reg(&inst->DstReg, mode, prog); _mesa_printf(", "); - print_src_reg(&inst->SrcReg[0]); + print_src_reg(&inst->SrcReg[0], mode, prog); _mesa_printf(", texture[%d], ", inst->TexSrcUnit); switch (inst->TexSrcTarget) { case TEXTURE_1D_INDEX: _mesa_printf("1D"); break; @@ -304,7 +544,7 @@ _mesa_print_instruction(const struct prog_instruction *inst, GLint indent) break; case OPCODE_ARL: _mesa_printf("ARL addr.x, "); - print_src_reg(&inst->SrcReg[0]); + print_src_reg(&inst->SrcReg[0], mode, prog); print_comment(inst); break; case OPCODE_BRA: @@ -319,49 +559,48 @@ _mesa_print_instruction(const struct prog_instruction *inst, GLint indent) print_comment(inst); break; case OPCODE_IF: - _mesa_printf("IF (%s%s) (if false, goto %d)", + _mesa_printf("IF (%s%s); # (if false, goto %d)", condcode_string(inst->DstReg.CondMask), swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE), inst->BranchTarget); print_comment(inst); return indent + 3; case OPCODE_ELSE: - _mesa_printf("ELSE (goto %d)\n", inst->BranchTarget); + _mesa_printf("ELSE; # (goto %d)\n", inst->BranchTarget); return indent + 3; case OPCODE_ENDIF: - _mesa_printf("ENDIF\n"); + _mesa_printf("ENDIF;\n"); break; case OPCODE_BGNLOOP: - _mesa_printf("BGNLOOP (end at %d)\n", inst->BranchTarget); + _mesa_printf("BGNLOOP; # (end at %d)\n", inst->BranchTarget); return indent + 3; case OPCODE_ENDLOOP: - _mesa_printf("ENDLOOP (goto %d)\n", inst->BranchTarget); + _mesa_printf("ENDLOOP; # (goto %d)\n", inst->BranchTarget); break; case OPCODE_BRK: - _mesa_printf("BRK (%s%s) (goto %d)", + _mesa_printf("BRK (%s%s); #(goto %d)", condcode_string(inst->DstReg.CondMask), swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE), inst->BranchTarget); print_comment(inst); break; case OPCODE_CONT: - _mesa_printf("CONT (%s%s) (goto %d)", + _mesa_printf("CONT (%s%s); #(goto %d)", condcode_string(inst->DstReg.CondMask), swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE), inst->BranchTarget); print_comment(inst); break; case OPCODE_BGNSUB: - _mesa_printf("SUB;\n"); + _mesa_printf("SUB"); print_comment(inst); return indent + 3; case OPCODE_ENDSUB: - _mesa_printf("ENDSUB;\n"); + _mesa_printf("ENDSUB"); print_comment(inst); break; case OPCODE_END: - _mesa_printf("END"); - print_comment(inst); + _mesa_printf("END\n"); break; case OPCODE_NOP: _mesa_printf("NOP"); @@ -370,9 +609,10 @@ _mesa_print_instruction(const struct prog_instruction *inst, GLint indent) /* XXX may need other special-case instructions */ default: /* typical alu instruction */ - _mesa_print_alu_instruction(inst, - _mesa_opcode_string(inst->Opcode), - _mesa_num_inst_src_regs(inst->Opcode)); + print_alu_instruction(inst, + _mesa_opcode_string(inst->Opcode), + _mesa_num_inst_src_regs(inst->Opcode), + mode, prog); break; } return indent; @@ -380,16 +620,50 @@ _mesa_print_instruction(const struct prog_instruction *inst, GLint indent) /** - * Print a vertx/fragment program to stdout. - * XXX this function could be greatly improved. + * Print program to stdout, default options. */ void _mesa_print_program(const struct gl_program *prog) +{ + _mesa_print_program_opt(prog, PROG_PRINT_ARB, GL_TRUE); +} + + +/** + * Print program, with options. + */ +void +_mesa_print_program_opt(const struct gl_program *prog, + gl_prog_print_mode mode, + GLboolean lineNumbers) { GLuint i, indent = 0; + + switch (prog->Target) { + case GL_VERTEX_PROGRAM_ARB: + if (mode == PROG_PRINT_ARB) + _mesa_printf("!!ARBvp1.0\n"); + else if (mode == PROG_PRINT_NV) + _mesa_printf("!!VP1.0\n"); + else + _mesa_printf("# Vertex Program/Shader\n"); + break; + case GL_FRAGMENT_PROGRAM_ARB: + case GL_FRAGMENT_PROGRAM_NV: + if (mode == PROG_PRINT_ARB) + _mesa_printf("!!ARBfp1.0\n"); + else if (mode == PROG_PRINT_NV) + _mesa_printf("!!FP1.0\n"); + else + _mesa_printf("# Fragment Program/Shader\n"); + break; + } + for (i = 0; i < prog->NumInstructions; i++) { - _mesa_printf("%3d: ", i); - indent = _mesa_print_instruction(prog->Instructions + i, indent); + if (lineNumbers) + _mesa_printf("%3d: ", i); + indent = _mesa_print_instruction_opt(prog->Instructions + i, + indent, mode, prog); } } @@ -424,14 +698,16 @@ _mesa_print_program_parameters(GLcontext *ctx, const struct gl_program *prog) void _mesa_print_parameter_list(const struct gl_program_parameter_list *list) { + const gl_prog_print_mode mode = PROG_PRINT_DEBUG; GLuint i; + _mesa_printf("param list %p\n", (void *) list); for (i = 0; i < list->NumParameters; i++){ struct gl_program_parameter *param = list->Parameters + i; const GLfloat *v = list->ParameterValues[i]; _mesa_printf("param[%d] sz=%d %s %s = {%.3g, %.3g, %.3g, %.3g};\n", i, param->Size, - program_file_string(list->Parameters[i].Type), + file_string(list->Parameters[i].Type, mode), param->Name, v[0], v[1], v[2], v[3]); } } diff --git a/src/mesa/shader/prog_print.h b/src/mesa/shader/prog_print.h index 19aaa53800..79c599f5a7 100644 --- a/src/mesa/shader/prog_print.h +++ b/src/mesa/shader/prog_print.h @@ -27,17 +27,31 @@ #define PROG_PRINT_H -extern GLint -_mesa_print_instruction(const struct prog_instruction *inst, GLint indent); +/** + * The output style to use when printing programs. + */ +typedef enum { + PROG_PRINT_ARB, + PROG_PRINT_NV, + PROG_PRINT_DEBUG +} gl_prog_print_mode; + extern void -_mesa_print_alu_instruction(const struct prog_instruction *inst, - const char *opcode_string, - GLuint numRegs); +_mesa_print_instruction(const struct prog_instruction *inst); + +extern GLint +_mesa_print_instruction_opt(const struct prog_instruction *inst, GLint indent, + gl_prog_print_mode mode, + const struct gl_program *prog); extern void _mesa_print_program(const struct gl_program *prog); +extern void +_mesa_print_program_opt(const struct gl_program *prog, gl_prog_print_mode mode, + GLboolean lineNumbers); + extern void _mesa_print_program_parameters(GLcontext *ctx, const struct gl_program *prog); diff --git a/src/mesa/swrast/s_fragprog.c b/src/mesa/swrast/s_fragprog.c index fe41c0b5f4..89907f73c6 100644 --- a/src/mesa/swrast/s_fragprog.c +++ b/src/mesa/swrast/s_fragprog.c @@ -554,6 +554,7 @@ init_machine_deriv( GLcontext *ctx, _mesa_memcpy(dMachine, machine, sizeof(struct fp_machine)); if (program->Base.Target == GL_FRAGMENT_PROGRAM_NV) { + /* XXX also need to do this when using valgrind */ /* Clear temporary registers (undefined for ARB_f_p) */ _mesa_bzero( (void*) machine->Temporaries, MAX_NV_FRAGMENT_PROGRAM_TEMPS * 4 * sizeof(GLfloat)); @@ -665,7 +666,7 @@ execute_program( GLcontext *ctx, } if (DEBUG_FRAG) { - _mesa_print_instruction(inst, 0); + _mesa_print_instruction(inst); } switch (inst->Opcode) { diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c index 6fb14e7caa..47fed32904 100644 --- a/src/mesa/tnl/t_vp_build.c +++ b/src/mesa/tnl/t_vp_build.c @@ -497,7 +497,7 @@ static void debug_insn( struct prog_instruction *inst, const char *fn, } _mesa_printf("%d:\t", line); - _mesa_print_instruction(inst, 0); + _mesa_print_instruction(inst); } } -- cgit v1.2.3 From 6531952b3c979be0dc95704beb3c3b9dad1dc37b Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 21 Feb 2007 11:08:21 -0700 Subject: adjustments to STATE_ token layout/format so token[1] is always the array index --- src/mesa/shader/arbprogparse.c | 47 ++++++++----- src/mesa/shader/prog_statevars.c | 129 ++++++++++++++++++++-------------- src/mesa/shader/prog_statevars.h | 15 ++-- src/mesa/shader/programopt.c | 14 ++-- src/mesa/shader/slang/slang_builtin.c | 54 +++++++------- src/mesa/shader/slang/slang_emit.c | 3 +- src/mesa/tnl/t_vp_build.c | 30 ++++---- 7 files changed, 166 insertions(+), 126 deletions(-) (limited to 'src/mesa/tnl/t_vp_build.c') diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c index e240d88aaa..4c200f74cc 100644 --- a/src/mesa/shader/arbprogparse.c +++ b/src/mesa/shader/arbprogparse.c @@ -1010,7 +1010,7 @@ parse_matrix (GLcontext * ctx, const GLubyte ** inst, struct arb_program *Progra switch (mat) { case MATRIX_MODELVIEW: - *matrix = STATE_MODELVIEW; + *matrix = STATE_MODELVIEW_MATRIX; *matrix_idx = parse_integer (inst, Program); if (*matrix_idx > 0) { program_error(ctx, Program->Position, @@ -1020,15 +1020,15 @@ parse_matrix (GLcontext * ctx, const GLubyte ** inst, struct arb_program *Progra break; case MATRIX_PROJECTION: - *matrix = STATE_PROJECTION; + *matrix = STATE_PROJECTION_MATRIX; break; case MATRIX_MVP: - *matrix = STATE_MVP; + *matrix = STATE_MVP_MATRIX; break; case MATRIX_TEXTURE: - *matrix = STATE_TEXTURE; + *matrix = STATE_TEXTURE_MATRIX; *matrix_idx = parse_integer (inst, Program); if (*matrix_idx >= (GLint) ctx->Const.MaxTextureUnits) { program_error(ctx, Program->Position, "Invalid Texture Unit"); @@ -1046,7 +1046,7 @@ parse_matrix (GLcontext * ctx, const GLubyte ** inst, struct arb_program *Progra break; case MATRIX_PROGRAM: - *matrix = STATE_PROGRAM; + *matrix = STATE_PROGRAM_MATRIX; *matrix_idx = parse_integer (inst, Program); if (*matrix_idx >= (GLint) ctx->Const.MaxProgramMatrices) { program_error(ctx, Program->Position, "Invalid Program Matrix"); @@ -1187,10 +1187,12 @@ parse_state_single_item (GLcontext * ctx, const GLubyte ** inst, case STATE_FOG: switch (*(*inst)++) { case FOG_COLOR: - state_tokens[0] = STATE_FOG_COLOR; + state_tokens[0] = STATE_FOG; + state_tokens[1] = STATE_FOG_COLOR; break; case FOG_PARAMS: - state_tokens[0] = STATE_FOG_PARAMS; + state_tokens[0] = STATE_FOG; + state_tokens[1] = STATE_FOG_PARAMS; break; } break; @@ -1285,17 +1287,16 @@ parse_state_single_item (GLcontext * ctx, const GLubyte ** inst, /* XXX: I think this is the correct format for a matrix row */ case STATE_MATRIX_ROWS: - state_tokens[0] = STATE_MATRIX; if (parse_matrix - (ctx, inst, Program, &state_tokens[1], &state_tokens[2], - &state_tokens[5])) + (ctx, inst, Program, &state_tokens[0], &state_tokens[1], + &state_tokens[4])) return 1; - state_tokens[3] = parse_integer (inst, Program); /* The first row to grab */ + state_tokens[2] = parse_integer (inst, Program); /* The first row to grab */ if ((**inst) != 0) { /* Either the last row, 0 */ - state_tokens[4] = parse_integer (inst, Program); - if (state_tokens[4] < state_tokens[3]) { + state_tokens[3] = parse_integer (inst, Program); + if (state_tokens[3] < state_tokens[2]) { program_error(ctx, Program->Position, "Second matrix index less than the first"); /* state_tokens[4] vs. state_tokens[3] */ @@ -1303,7 +1304,7 @@ parse_state_single_item (GLcontext * ctx, const GLubyte ** inst, } } else { - state_tokens[4] = state_tokens[3]; + state_tokens[3] = state_tokens[2]; (*inst)++; } break; @@ -1730,14 +1731,18 @@ parse_param_elements (GLcontext * ctx, const GLubyte ** inst, /* If we adding STATE_MATRIX that has multiple rows, we need to * unroll it and call _mesa_add_state_reference() for each row */ - if ((state_tokens[0] == STATE_MATRIX) - && (state_tokens[3] != state_tokens[4])) { + if ((state_tokens[0] == STATE_MODELVIEW_MATRIX || + state_tokens[0] == STATE_PROJECTION_MATRIX || + state_tokens[0] == STATE_MVP_MATRIX || + state_tokens[0] == STATE_TEXTURE_MATRIX || + state_tokens[0] == STATE_PROGRAM_MATRIX) + && (state_tokens[2] != state_tokens[3])) { GLint row; - GLint first_row = state_tokens[3]; - GLint last_row = state_tokens[4]; + const GLint first_row = state_tokens[2]; + const GLint last_row = state_tokens[3]; for (row = first_row; row <= last_row; row++) { - state_tokens[3] = state_tokens[4] = row; + state_tokens[2] = state_tokens[3] = row; idx = _mesa_add_state_reference(Program->Base.Parameters, state_tokens); @@ -3357,6 +3362,10 @@ print_state_token (GLint token) fprintf (stderr, "STATE_TEXGEN "); break; + case STATE_FOG: + fprintf (stderr, "STATE_FOG "); + break; + case STATE_FOG_COLOR: fprintf (stderr, "STATE_FOG_COLOR "); break; diff --git a/src/mesa/shader/prog_statevars.c b/src/mesa/shader/prog_statevars.c index 3a54ab8c58..d6c552a71f 100644 --- a/src/mesa/shader/prog_statevars.c +++ b/src/mesa/shader/prog_statevars.c @@ -243,14 +243,17 @@ _mesa_fetch_state(GLcontext *ctx, const gl_state_index state[], COPY_4V(value, ctx->Texture.Unit[unit].EnvColor); } return; - case STATE_FOG_COLOR: - COPY_4V(value, ctx->Fog.Color); - return; - case STATE_FOG_PARAMS: - value[0] = ctx->Fog.Density; - value[1] = ctx->Fog.Start; - value[2] = ctx->Fog.End; - value[3] = 1.0F / (ctx->Fog.End - ctx->Fog.Start); + case STATE_FOG: + if (state[1] == STATE_FOG_COLOR) { + COPY_4V(value, ctx->Fog.Color); + } + else { + ASSERT(state[1] == STATE_FOG_PARAMS); + value[0] = ctx->Fog.Density; + value[1] = ctx->Fog.Start; + value[2] = ctx->Fog.End; + value[3] = 1.0F / (ctx->Fog.End - ctx->Fog.Start); + } return; case STATE_CLIPPLANE: { @@ -270,7 +273,12 @@ _mesa_fetch_state(GLcontext *ctx, const gl_state_index state[], value[2] = ctx->Point.Params[2]; value[3] = 1.0F; return; - case STATE_MATRIX: + case STATE_MODELVIEW_MATRIX: + case STATE_PROJECTION_MATRIX: + case STATE_MVP_MATRIX: + case STATE_TEXTURE_MATRIX: + case STATE_PROGRAM_MATRIX: + /*case STATE_MATRIX:*/ { /* state[1] = modelview, projection, texture, etc. */ /* state[2] = which texture matrix or program matrix */ @@ -279,26 +287,38 @@ _mesa_fetch_state(GLcontext *ctx, const gl_state_index state[], /* state[5] = transpose, inverse or invtrans */ const GLmatrix *matrix; +#if 0 const gl_state_index mat = state[1]; const GLuint index = (GLuint) state[2]; const GLuint firstRow = (GLuint) state[3]; const GLuint lastRow = (GLuint) state[4]; const gl_state_index modifier = state[5]; +#else + const gl_state_index mat = state[0]; + const GLuint index = (GLuint) state[1]; + const GLuint firstRow = (GLuint) state[2]; + const GLuint lastRow = (GLuint) state[3]; + const gl_state_index modifier = state[4]; +#endif const GLfloat *m; GLuint row, i; - if (mat == STATE_MODELVIEW) { + ASSERT(firstRow >= 0); + ASSERT(firstRow < 4); + ASSERT(lastRow >= 0); + ASSERT(lastRow < 4); + if (mat == STATE_MODELVIEW_MATRIX) { matrix = ctx->ModelviewMatrixStack.Top; } - else if (mat == STATE_PROJECTION) { + else if (mat == STATE_PROJECTION_MATRIX) { matrix = ctx->ProjectionMatrixStack.Top; } - else if (mat == STATE_MVP) { + else if (mat == STATE_MVP_MATRIX) { matrix = &ctx->_ModelProjectMatrix; } - else if (mat == STATE_TEXTURE) { + else if (mat == STATE_TEXTURE_MATRIX) { matrix = ctx->TextureMatrixStack[index].Top; } - else if (mat == STATE_PROGRAM) { + else if (mat == STATE_PROGRAM_MATRIX) { matrix = ctx->ProgramMatrixStack[index].Top; } else { @@ -432,8 +452,11 @@ _mesa_program_state_flags(const GLint state[STATE_LENGTH]) case STATE_TEXENV_COLOR: return _NEW_TEXTURE; + case STATE_FOG: +#if 0 case STATE_FOG_COLOR: case STATE_FOG_PARAMS: +#endif return _NEW_FOG; case STATE_CLIPPLANE: @@ -443,23 +466,16 @@ _mesa_program_state_flags(const GLint state[STATE_LENGTH]) case STATE_POINT_ATTENUATION: return _NEW_POINT; - case STATE_MATRIX: - switch (state[1]) { - case STATE_MODELVIEW: - return _NEW_MODELVIEW; - case STATE_PROJECTION: - return _NEW_PROJECTION; - case STATE_MVP: - return _NEW_MODELVIEW | _NEW_PROJECTION; - case STATE_TEXTURE: - return _NEW_TEXTURE_MATRIX; - case STATE_PROGRAM: - return _NEW_TRACK_MATRIX; - default: - _mesa_problem(NULL, - "unexpected matrix in _mesa_program_state_flags()"); - return 0; - } + case STATE_MODELVIEW_MATRIX: + return _NEW_MODELVIEW; + case STATE_PROJECTION_MATRIX: + return _NEW_PROJECTION; + case STATE_MVP_MATRIX: + return _NEW_MODELVIEW | _NEW_PROJECTION; + case STATE_TEXTURE_MATRIX: + return _NEW_TEXTURE_MATRIX; + case STATE_PROGRAM_MATRIX: + return _NEW_TRACK_MATRIX; case STATE_DEPTH_RANGE: return _NEW_VIEWPORT; @@ -520,11 +536,14 @@ append_token(char *dst, gl_state_index k) case STATE_TEXGEN: append(dst, "texgen"); break; + case STATE_FOG: + append(dst, "fog"); + break; case STATE_FOG_COLOR: - append(dst, "fog.color"); + append(dst, ".color"); break; case STATE_FOG_PARAMS: - append(dst, "fog.params"); + append(dst, ".params"); break; case STATE_CLIPPLANE: append(dst, "clip"); @@ -535,22 +554,19 @@ append_token(char *dst, gl_state_index k) case STATE_POINT_ATTENUATION: append(dst, "point.attenuation"); break; - case STATE_MATRIX: - append(dst, "matrix."); - break; - case STATE_MODELVIEW: + case STATE_MODELVIEW_MATRIX: append(dst, "modelview"); break; - case STATE_PROJECTION: + case STATE_PROJECTION_MATRIX: append(dst, "projection"); break; - case STATE_MVP: + case STATE_MVP_MATRIX: append(dst, "mvp"); break; - case STATE_TEXTURE: + case STATE_TEXTURE_MATRIX: append(dst, "texture"); break; - case STATE_PROGRAM: + case STATE_PROGRAM_MATRIX: append(dst, "program"); break; case STATE_MATRIX_INVERSE: @@ -703,8 +719,9 @@ _mesa_program_state_string(const GLint state[STATE_LENGTH]) append_index(str, state[1]); /* tex unit [i] */ append(str, "color"); break; - case STATE_FOG_COLOR: - case STATE_FOG_PARAMS: + case STATE_FOG: + append(str, "fog"); + append_token(str, (gl_state_index) state[1]); /* color or params */ break; case STATE_CLIPPLANE: append_index(str, state[1]); /* plane [i] */ @@ -713,18 +730,22 @@ _mesa_program_state_string(const GLint state[STATE_LENGTH]) case STATE_POINT_SIZE: case STATE_POINT_ATTENUATION: break; - case STATE_MATRIX: + case STATE_MODELVIEW_MATRIX: + case STATE_PROJECTION_MATRIX: + case STATE_MVP_MATRIX: + case STATE_TEXTURE_MATRIX: + case STATE_PROGRAM_MATRIX: { - /* state[1] = modelview, projection, texture, etc. */ - /* state[2] = which texture matrix or program matrix */ - /* state[3] = first row to fetch */ - /* state[4] = last row to fetch */ - /* state[5] = transpose, inverse or invtrans */ - const gl_state_index mat = (gl_state_index) state[1]; - const GLuint index = (GLuint) state[2]; - const GLuint firstRow = (GLuint) state[3]; - const GLuint lastRow = (GLuint) state[4]; - const gl_state_index modifier = (gl_state_index) state[5]; + /* state[0] = modelview, projection, texture, etc. */ + /* state[1] = which texture matrix or program matrix */ + /* state[2] = first row to fetch */ + /* state[3] = last row to fetch */ + /* state[4] = transpose, inverse or invtrans */ + const gl_state_index mat = (gl_state_index) state[0]; + const GLuint index = (GLuint) state[1]; + const GLuint firstRow = (GLuint) state[2]; + const GLuint lastRow = (GLuint) state[3]; + const gl_state_index modifier = (gl_state_index) state[4]; append_token(str, mat); if (index) append_index(str, index); diff --git a/src/mesa/shader/prog_statevars.h b/src/mesa/shader/prog_statevars.h index 95e38ca7b6..1b686d8078 100644 --- a/src/mesa/shader/prog_statevars.h +++ b/src/mesa/shader/prog_statevars.h @@ -40,6 +40,9 @@ * fragment programs. * A string such as "state.light[0].ambient" gets translated into a * sequence of tokens such as [ STATE_LIGHT, 0, STATE_AMBIENT ]. + * + * For state that's an array, like STATE_CLIPPLANE, the 2nd token [1] should + * always be the array index. */ typedef enum gl_state_index_ { STATE_MATERIAL = 100, /* start at 100 so small ints are seen as ints */ @@ -51,6 +54,7 @@ typedef enum gl_state_index_ { STATE_TEXGEN, + STATE_FOG, STATE_FOG_COLOR, STATE_FOG_PARAMS, @@ -59,12 +63,11 @@ typedef enum gl_state_index_ { STATE_POINT_SIZE, STATE_POINT_ATTENUATION, - STATE_MATRIX, - STATE_MODELVIEW, - STATE_PROJECTION, - STATE_MVP, - STATE_TEXTURE, - STATE_PROGRAM, + STATE_MODELVIEW_MATRIX, + STATE_PROJECTION_MATRIX, + STATE_MVP_MATRIX, + STATE_TEXTURE_MATRIX, + STATE_PROGRAM_MATRIX, STATE_MATRIX_INVERSE, STATE_MATRIX_TRANSPOSE, STATE_MATRIX_INVTRANS, diff --git a/src/mesa/shader/programopt.c b/src/mesa/shader/programopt.c index a33e6b49ac..ca11a4e547 100644 --- a/src/mesa/shader/programopt.c +++ b/src/mesa/shader/programopt.c @@ -57,10 +57,10 @@ _mesa_insert_mvp_code(GLcontext *ctx, struct gl_vertex_program *vprog) * XXX we should check if these state vars are already declared. */ static const GLint mvpState[4][5] = { - { STATE_MATRIX, STATE_MVP, 0, 0, 0 }, /* state.matrix.mvp.row[0] */ - { STATE_MATRIX, STATE_MVP, 0, 1, 1 }, /* state.matrix.mvp.row[1] */ - { STATE_MATRIX, STATE_MVP, 0, 2, 2 }, /* state.matrix.mvp.row[2] */ - { STATE_MATRIX, STATE_MVP, 0, 3, 3 }, /* state.matrix.mvp.row[3] */ + { STATE_MVP_MATRIX, 0, 0, 0, 0 }, /* state.matrix.mvp.row[0] */ + { STATE_MVP_MATRIX, 0, 1, 1, 0 }, /* state.matrix.mvp.row[1] */ + { STATE_MVP_MATRIX, 0, 2, 2, 0 }, /* state.matrix.mvp.row[2] */ + { STATE_MVP_MATRIX, 0, 3, 3, 0 }, /* state.matrix.mvp.row[3] */ }; GLint mvpRef[4]; @@ -125,8 +125,10 @@ _mesa_insert_mvp_code(GLcontext *ctx, struct gl_vertex_program *vprog) void _mesa_append_fog_code(GLcontext *ctx, struct gl_fragment_program *fprog) { - static const GLint fogParamsState[] = { STATE_FOG_PARAMS, 0, 0, 0, 0 }; - static const GLint fogColorState[] = { STATE_FOG_COLOR, 0, 0, 0, 0 }; + static const GLint fogParamsState[] + = { STATE_FOG, STATE_FOG_PARAMS, 0, 0, 0 }; + static const GLint fogColorState[] + = { STATE_FOG, STATE_FOG_COLOR, 0, 0, 0 }; struct prog_instruction *newInst, *inst; const GLuint origLen = fprog->Base.NumInstructions; const GLuint newLen = origLen + 6; diff --git a/src/mesa/shader/slang/slang_builtin.c b/src/mesa/shader/slang/slang_builtin.c index b4aecdb3ad..71a102e45c 100644 --- a/src/mesa/shader/slang/slang_builtin.c +++ b/src/mesa/shader/slang/slang_builtin.c @@ -70,15 +70,15 @@ _slang_lookup_statevar(const char *name, GLint index, }; static const struct state_info state[] = { { "gl_ModelViewMatrix", 4, SWIZZLE_NOOP, - { STATE_MATRIX, STATE_MODELVIEW, 0, 0, 0, 0 } }, + { STATE_MODELVIEW_MATRIX, 0, 0, 0, 0, 0 } }, { "gl_NormalMatrix", 3, SWIZZLE_NOOP, - { STATE_MATRIX, STATE_MODELVIEW, 0, 0, 0, 0 } }, + { STATE_MODELVIEW_MATRIX, 0, 0, 0, 0, 0 } }, { "gl_ProjectionMatrix", 4, SWIZZLE_NOOP, - { STATE_MATRIX, STATE_PROJECTION, 0, 0, 0, 0 } }, + { STATE_PROJECTION_MATRIX, 0, 0, 0, 0, 0 } }, { "gl_ModelViewProjectionMatrix", 4, SWIZZLE_NOOP, - { STATE_MATRIX, STATE_MVP, 0, 0, 0, 0 } }, + { STATE_MVP_MATRIX, 0, 0, 0, 0, 0 } }, { "gl_TextureMatrix", 4, SWIZZLE_NOOP, - { STATE_MATRIX, STATE_TEXTURE, 0, 0, 0, 0 } }, + { STATE_TEXTURE_MATRIX, 0, 0, 0, 0, 0 } }, { "gl_NormalScale", 1, SWIZZLE_NOOP, { STATE_INTERNAL, STATE_NORMAL_SCALE, 0, 0, 0, 0} }, @@ -157,17 +157,17 @@ _slang_lookup_statevar(const char *name, GLint index, { "gl_Fog", 1, SWIZZLE_NOOP, - { STATE_FOG_COLOR, 0, 0, 0, 0, 0 } }, + { STATE_FOG, STATE_FOG_COLOR, 0, 0, 0, 0 } }, { "gl_Fog.color", 1, SWIZZLE_NOOP, - { STATE_FOG_COLOR, 0, 0, 0, 0, 0 } }, + { STATE_FOG, STATE_FOG_COLOR, 0, 0, 0, 0 } }, { "gl_Fog.density", 1, SWIZZLE_XXXX, - { STATE_FOG_PARAMS, 0, 0, 0, 0, 0 } }, + { STATE_FOG, STATE_FOG_PARAMS, 0, 0, 0, 0 } }, { "gl_Fog.start", 1, SWIZZLE_YYYY, - { STATE_FOG_PARAMS, 0, 0, 0, 0, 0 } }, + { STATE_FOG, STATE_FOG_PARAMS, 0, 0, 0, 0 } }, { "gl_Fog.end", 1, SWIZZLE_ZZZZ, - { STATE_FOG_PARAMS, 0, 0, 0, 0, 0 } }, + { STATE_FOG, STATE_FOG_PARAMS, 0, 0, 0, 0 } }, { "gl_Fog.scale", 1, SWIZZLE_WWWW, - { STATE_FOG_PARAMS, 0, 0, 0, 0, 0 } }, + { STATE_FOG, STATE_FOG_PARAMS, 0, 0, 0, 0 } }, { "gl_ClipPlane", 1, SWIZZLE_NOOP, { STATE_CLIPPLANE, 0, 0, 0, 0, 0 } }, @@ -190,7 +190,7 @@ _slang_lookup_statevar(const char *name, GLint index, indexesCopy[j] = state[i].Indexes[j]; /* load rows */ for (j = 0; j < state[i].NumRows; j++) { - indexesCopy[3] = indexesCopy[4] = j; /* jth row of matrix */ + indexesCopy[2] = indexesCopy[3] = j; /* jth row of matrix */ pos[j] = _mesa_add_state_reference(paramList, indexesCopy); assert(pos[j] >= 0); } @@ -256,19 +256,19 @@ struct state_uniform_info { static const struct state_uniform_info Uniforms[] = { - { "gl_ModelViewMatrix", { STATE_MATRIX, STATE_MODELVIEW }, + { "gl_ModelViewMatrix", { STATE_MODELVIEW_MATRIX, INDEX_POS }, { MT_FIELD, MT_FIELD, MT_FIELD, MT_FIELD, MT_FIELD} }, - { "gl_ProjectionMatrix", { STATE_MATRIX, STATE_PROJECTION }, + { "gl_ProjectionMatrix", { STATE_PROJECTION_MATRIX, INDEX_POS }, { MT_FIELD, MT_FIELD, MT_FIELD, MT_FIELD, MT_FIELD} }, - { "gl_ModelViewProjectionMatrix", { STATE_MATRIX, STATE_MVP }, + { "gl_ModelViewProjectionMatrix", { STATE_MVP_MATRIX, INDEX_POS }, { MT_FIELD, MT_FIELD, MT_FIELD, MT_FIELD, MT_FIELD} }, - { "gl_NormalMatrix", { STATE_MATRIX, STATE_MODELVIEW }, + { "gl_NormalMatrix", { STATE_MODELVIEW_MATRIX, INDEX_POS }, { MT_FIELD, MT_FIELD, MT_FIELD, MT_FIELD, MT_FIELD} }, - { "gl_TextureMatrix", { STATE_MATRIX, STATE_TEXTURE }, + { "gl_TextureMatrix", { STATE_TEXTURE_MATRIX, INDEX_POS }, { MT_FIELD, MT_FIELD, MT_FIELD, MT_FIELD, MT_FIELD} }, @@ -286,13 +286,13 @@ static const struct state_uniform_info Uniforms[] = { } }, - { "gl_Fog", { 0, 0 }, + { "gl_Fog", { STATE_FOG, 0 }, { - { "color", STATE_FOG_COLOR, 0, SWIZZLE_NOOP }, - { "density", STATE_FOG_PARAMS, 0, SWIZZLE_XXXX }, - { "start", STATE_FOG_PARAMS, 0, SWIZZLE_YYYY }, - { "end", STATE_FOG_PARAMS, 0, SWIZZLE_ZZZZ }, - { "scale", STATE_FOG_PARAMS, 0, SWIZZLE_WWWW } + { "color", STATE_FOG_COLOR, 1, SWIZZLE_NOOP }, + { "density", STATE_FOG_PARAMS, 1, SWIZZLE_XXXX }, + { "start", STATE_FOG_PARAMS, 1, SWIZZLE_YYYY }, + { "end", STATE_FOG_PARAMS, 1, SWIZZLE_ZZZZ }, + { "scale", STATE_FOG_PARAMS, 1, SWIZZLE_WWWW } } }, @@ -349,7 +349,11 @@ lookup_statevar(const char *var, GLint index, const char *field, } } - if (tokens[0] == STATE_MATRIX) { + if (tokens[0] == STATE_MODELVIEW_MATRIX || + tokens[0] == STATE_PROJECTION_MATRIX || + tokens[0] == STATE_MVP_MATRIX || + tokens[0] == STATE_TEXTURE_MATRIX || + tokens[0] == STATE_PROGRAM_MATRIX) { /* a matrix */ GLuint j; GLint pos[4]; @@ -359,7 +363,7 @@ lookup_statevar(const char *var, GLint index, const char *field, indexesCopy[j] = tokens[j]; /* load rows */ for (j = 0; j < 4/*state[i].NumRows*/; j++) { - indexesCopy[3] = indexesCopy[4] = j; /* jth row of matrix */ + indexesCopy[2] = indexesCopy[3] = j; /* jth row of matrix */ pos[j] = _mesa_add_state_reference(paramList, (GLint*) indexesCopy); assert(pos[j] >= 0); } diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c index 7584857493..cef6299d62 100644 --- a/src/mesa/shader/slang/slang_emit.c +++ b/src/mesa/shader/slang/slang_emit.c @@ -1354,7 +1354,7 @@ emit_struct_field(slang_var_table *vt, slang_ir_node *n, n->Store->Index = _slang_alloc_statevar(n, prog->Parameters); return NULL; } - +#if 0 if (n->Children[0]->Store->File == PROGRAM_STATE_VAR) { /* state variable sub-field */ GLint pos; @@ -1371,6 +1371,7 @@ emit_struct_field(slang_var_table *vt, slang_ir_node *n, n->Store->Index = pos; n->Store->Swizzle = swizzle; } +#endif else { _mesa_problem(NULL, "structs/fields not supported yet"); } diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c index 47fed32904..9065e3421f 100644 --- a/src/mesa/tnl/t_vp_build.c +++ b/src/mesa/tnl/t_vp_build.c @@ -636,14 +636,14 @@ static struct ureg get_eye_position( struct tnl_program *p ) p->eye_position = reserve_temp(p); if (PREFER_DP4) { - register_matrix_param6( p, STATE_MATRIX, STATE_MODELVIEW, 0, 0, 3, - STATE_MATRIX, modelview ); + register_matrix_param6( p, STATE_MODELVIEW_MATRIX, 0, 0, 3, + 0, 0, modelview ); emit_matrix_transform_vec4(p, p->eye_position, modelview, pos); } else { - register_matrix_param6( p, STATE_MATRIX, STATE_MODELVIEW, 0, 0, 3, - STATE_MATRIX_TRANSPOSE, modelview ); + register_matrix_param6( p, STATE_MODELVIEW_MATRIX, 0, 0, 3, + STATE_MATRIX_TRANSPOSE, 0, modelview ); emit_transpose_matrix_transform_vec4(p, p->eye_position, modelview, pos); } @@ -671,8 +671,8 @@ static struct ureg get_eye_normal( struct tnl_program *p ) struct ureg normal = register_input(p, VERT_ATTRIB_NORMAL ); struct ureg mvinv[3]; - register_matrix_param6( p, STATE_MATRIX, STATE_MODELVIEW, 0, 0, 2, - STATE_MATRIX_INVTRANS, mvinv ); + register_matrix_param6( p, STATE_MODELVIEW_MATRIX, 0, 0, 2, + STATE_MATRIX_INVTRANS, 0, mvinv ); p->eye_normal = reserve_temp(p); @@ -706,13 +706,13 @@ static void build_hpos( struct tnl_program *p ) struct ureg mvp[4]; if (PREFER_DP4) { - register_matrix_param6( p, STATE_MATRIX, STATE_MVP, 0, 0, 3, - STATE_MATRIX, mvp ); + register_matrix_param6( p, STATE_MVP_MATRIX, 0, 0, 3, + 0, 0, mvp ); emit_matrix_transform_vec4( p, hpos, mvp, pos ); } else { - register_matrix_param6( p, STATE_MATRIX, STATE_MVP, 0, 0, 3, - STATE_MATRIX_TRANSPOSE, mvp ); + register_matrix_param6( p, STATE_MVP_MATRIX, 0, 0, 3, + STATE_MATRIX_TRANSPOSE, 0, mvp ); emit_transpose_matrix_transform_vec4( p, hpos, mvp, pos ); } } @@ -1109,7 +1109,7 @@ static void build_fog( struct tnl_program *p ) } if (p->state->tnl_do_vertex_fog) { - struct ureg params = register_param1(p, STATE_FOG_PARAMS); + struct ureg params = register_param2(p, STATE_FOG, STATE_FOG_PARAMS); struct ureg tmp = get_temp(p); switch (p->state->fog_mode) { @@ -1303,13 +1303,13 @@ static void build_texture_transform( struct tnl_program *p ) out_texgen : register_input(p, VERT_ATTRIB_TEX0+i)); if (PREFER_DP4) { - register_matrix_param6( p, STATE_MATRIX, STATE_TEXTURE, i, - 0, 3, STATE_MATRIX, texmat ); + register_matrix_param6( p, STATE_TEXTURE_MATRIX, i, 0, 3, + 0, 0, texmat ); emit_matrix_transform_vec4( p, out, texmat, in ); } else { - register_matrix_param6( p, STATE_MATRIX, STATE_TEXTURE, i, - 0, 3, STATE_MATRIX_TRANSPOSE, texmat ); + register_matrix_param6( p, STATE_TEXTURE_MATRIX, i, 0, 3, + STATE_MATRIX_TRANSPOSE, 0, texmat ); emit_transpose_matrix_transform_vec4( p, out, texmat, in ); } } -- cgit v1.2.3 From f958aabdf3e3dc82827628cab97b159bd5089651 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 21 Feb 2007 15:23:11 -0700 Subject: more minor changes to STATE_ indexing --- src/mesa/shader/arbprogparse.c | 12 +++-- src/mesa/shader/prog_statevars.c | 99 +++++++++++++++++++++++----------------- src/mesa/shader/prog_statevars.h | 4 +- src/mesa/tnl/t_vp_build.c | 6 +-- 4 files changed, 72 insertions(+), 49 deletions(-) (limited to 'src/mesa/tnl/t_vp_build.c') diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c index 4c200f74cc..0ac35a5768 100644 --- a/src/mesa/shader/arbprogparse.c +++ b/src/mesa/shader/arbprogparse.c @@ -1138,7 +1138,7 @@ parse_state_single_item (GLcontext * ctx, const GLubyte ** inst, state_tokens[2] = STATE_ATTENUATION; break; case LIGHT_HALF: - state_tokens[2] = STATE_HALF; + state_tokens[2] = STATE_HALF_VECTOR; break; case LIGHT_SPOT_DIRECTION: state_tokens[2] = STATE_SPOT_DIRECTION; @@ -1276,11 +1276,13 @@ parse_state_single_item (GLcontext * ctx, const GLubyte ** inst, case STATE_POINT: switch (*(*inst++)) { case POINT_SIZE: - state_tokens[0] = STATE_POINT_SIZE; + state_tokens[0] = STATE_POINT; + state_tokens[1] = STATE_POINT_SIZE; break; case POINT_ATTENUATION: - state_tokens[0] = STATE_POINT_ATTENUATION; + state_tokens[0] = STATE_POINT; + state_tokens[1] = STATE_POINT_ATTENUATION; break; } break; @@ -3378,6 +3380,10 @@ print_state_token (GLint token) fprintf (stderr, "STATE_CLIPPLANE "); break; + case STATE_POINT: + fprintf (stderr, "STATE_POINT "); + break; + case STATE_POINT_SIZE: fprintf (stderr, "STATE_POINT_SIZE "); break; diff --git a/src/mesa/shader/prog_statevars.c b/src/mesa/shader/prog_statevars.c index d6c552a71f..53778183c5 100644 --- a/src/mesa/shader/prog_statevars.c +++ b/src/mesa/shader/prog_statevars.c @@ -116,7 +116,10 @@ _mesa_fetch_state(GLcontext *ctx, const gl_state_index state[], COPY_3V(value, ctx->Light.Light[ln].EyeDirection); value[3] = ctx->Light.Light[ln]._CosCutoff; return; - case STATE_HALF: + case STATE_SPOT_CUTOFF: + value[0] = ctx->Light.Light[ln].SpotCutoff; + return; + case STATE_HALF_VECTOR: { GLfloat eye_z[] = {0, 0, 1}; @@ -261,17 +264,20 @@ _mesa_fetch_state(GLcontext *ctx, const gl_state_index state[], COPY_4V(value, ctx->Transform.EyeUserPlane[plane]); } return; - case STATE_POINT_SIZE: - value[0] = ctx->Point.Size; - value[1] = ctx->Point.MinSize; - value[2] = ctx->Point.MaxSize; - value[3] = ctx->Point.Threshold; - return; - case STATE_POINT_ATTENUATION: - value[0] = ctx->Point.Params[0]; - value[1] = ctx->Point.Params[1]; - value[2] = ctx->Point.Params[2]; - value[3] = 1.0F; + case STATE_POINT: + if (state[1] == STATE_POINT_SIZE) { + value[0] = ctx->Point.Size; + value[1] = ctx->Point.MinSize; + value[2] = ctx->Point.MaxSize; + value[3] = ctx->Point.Threshold; + } + else { + ASSERT(state[1] == STATE_POINT_ATTENUATION); + value[0] = ctx->Point.Params[0]; + value[1] = ctx->Point.Params[1]; + value[2] = ctx->Point.Params[2]; + value[3] = 1.0F; + } return; case STATE_MODELVIEW_MATRIX: case STATE_PROJECTION_MATRIX: @@ -399,12 +405,13 @@ _mesa_fetch_state(GLcontext *ctx, const gl_state_index state[], } return; + case STATE_NORMAL_SCALE: + ASSIGN_4V(value, ctx->_ModelViewInvScale, 0, 0, 1); + return; + case STATE_INTERNAL: { switch (state[1]) { - case STATE_NORMAL_SCALE: - ASSIGN_4V(value, ctx->_ModelViewInvScale, 0, 0, 1); - break; case STATE_TEXRECT_SCALE: { const int unit = (int) state[2]; const struct gl_texture_object *texObj = ctx->Texture.Unit[unit]._Current; @@ -462,8 +469,7 @@ _mesa_program_state_flags(const GLint state[STATE_LENGTH]) case STATE_CLIPPLANE: return _NEW_TRANSFORM; - case STATE_POINT_SIZE: - case STATE_POINT_ATTENUATION: + case STATE_POINT: return _NEW_POINT; case STATE_MODELVIEW_MATRIX: @@ -484,10 +490,11 @@ _mesa_program_state_flags(const GLint state[STATE_LENGTH]) case STATE_VERTEX_PROGRAM: return _NEW_PROGRAM; + case STATE_NORMAL_SCALE: + return _NEW_MODELVIEW; + case STATE_INTERNAL: switch (state[1]) { - case STATE_NORMAL_SCALE: - return _NEW_MODELVIEW; case STATE_TEXRECT_SCALE: return _NEW_TEXTURE; default: @@ -520,7 +527,7 @@ append_token(char *dst, gl_state_index k) { switch (k) { case STATE_MATERIAL: - append(dst, "material."); + append(dst, "material"); break; case STATE_LIGHT: append(dst, "light"); @@ -548,26 +555,29 @@ append_token(char *dst, gl_state_index k) case STATE_CLIPPLANE: append(dst, "clip"); break; + case STATE_POINT: + append(dst, "point"); + break; case STATE_POINT_SIZE: - append(dst, "point.size"); + append(dst, "size"); break; case STATE_POINT_ATTENUATION: - append(dst, "point.attenuation"); + append(dst, "attenuation"); break; case STATE_MODELVIEW_MATRIX: - append(dst, "modelview"); + append(dst, "matrix.modelview"); break; case STATE_PROJECTION_MATRIX: - append(dst, "projection"); + append(dst, "matrix.projection"); break; case STATE_MVP_MATRIX: - append(dst, "mvp"); + append(dst, "matrix.mvp"); break; case STATE_TEXTURE_MATRIX: - append(dst, "texture"); + append(dst, "matrix.texture"); break; case STATE_PROGRAM_MATRIX: - append(dst, "program"); + append(dst, "matrix.program"); break; case STATE_MATRIX_INVERSE: append(dst, ".inverse"); @@ -579,22 +589,22 @@ append_token(char *dst, gl_state_index k) append(dst, ".invtrans"); break; case STATE_AMBIENT: - append(dst, "ambient"); + append(dst, ".ambient"); break; case STATE_DIFFUSE: - append(dst, "diffuse"); + append(dst, ".diffuse"); break; case STATE_SPECULAR: - append(dst, "specular"); + append(dst, ".specular"); break; case STATE_EMISSION: - append(dst, "emission"); + append(dst, ".emission"); break; case STATE_SHININESS: - append(dst, "shininess"); + append(dst, "lshininess"); break; - case STATE_HALF: - append(dst, "half"); + case STATE_HALF_VECTOR: + append(dst, ".half"); break; case STATE_POSITION: append(dst, ".position"); @@ -605,6 +615,9 @@ append_token(char *dst, gl_state_index k) case STATE_SPOT_DIRECTION: append(dst, ".spot.direction"); break; + case STATE_SPOT_CUTOFF: + append(dst, ".spot.cutoff"); + break; case STATE_TEXGEN_EYE_S: append(dst, "eye.s"); break; @@ -644,8 +657,10 @@ append_token(char *dst, gl_state_index k) case STATE_LOCAL: append(dst, "local"); break; - case STATE_INTERNAL: case STATE_NORMAL_SCALE: + append(dst, "normalScale"); + break; + case STATE_INTERNAL: case STATE_POSITION_NORMALIZED: append(dst, "(internal)"); break; @@ -667,7 +682,7 @@ static void append_index(char *dst, GLint index) { char s[20]; - _mesa_sprintf(s, "[%d].", index); + _mesa_sprintf(s, "[%d]", index); append(dst, s); } @@ -691,7 +706,6 @@ _mesa_program_state_string(const GLint state[STATE_LENGTH]) append_token(str, (gl_state_index) state[2]); break; case STATE_LIGHT: - append(str, "light"); append_index(str, state[1]); /* light number [i]. */ append_token(str, (gl_state_index) state[2]); /* coefficients */ break; @@ -725,10 +739,10 @@ _mesa_program_state_string(const GLint state[STATE_LENGTH]) break; case STATE_CLIPPLANE: append_index(str, state[1]); /* plane [i] */ - append(str, "plane"); + append(str, ".plane"); break; - case STATE_POINT_SIZE: - case STATE_POINT_ATTENUATION: + case STATE_POINT: + append_token(str, state[1]); break; case STATE_MODELVIEW_MATRIX: case STATE_PROJECTION_MATRIX: @@ -746,8 +760,9 @@ _mesa_program_state_string(const GLint state[STATE_LENGTH]) const GLuint firstRow = (GLuint) state[2]; const GLuint lastRow = (GLuint) state[3]; const gl_state_index modifier = (gl_state_index) state[4]; - append_token(str, mat); - if (index) + if (index || + mat == STATE_TEXTURE_MATRIX || + mat == STATE_PROGRAM_MATRIX) append_index(str, index); if (modifier) append_token(str, modifier); diff --git a/src/mesa/shader/prog_statevars.h b/src/mesa/shader/prog_statevars.h index 1b686d8078..a1170d6684 100644 --- a/src/mesa/shader/prog_statevars.h +++ b/src/mesa/shader/prog_statevars.h @@ -60,6 +60,7 @@ typedef enum gl_state_index_ { STATE_CLIPPLANE, + STATE_POINT, STATE_POINT_SIZE, STATE_POINT_ATTENUATION, @@ -77,11 +78,12 @@ typedef enum gl_state_index_ { STATE_SPECULAR, STATE_EMISSION, STATE_SHININESS, - STATE_HALF, + STATE_HALF_VECTOR, STATE_POSITION, STATE_ATTENUATION, STATE_SPOT_DIRECTION, + STATE_SPOT_CUTOFF, STATE_TEXGEN_EYE_S, STATE_TEXGEN_EYE_T, diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c index 9065e3421f..8b75dff96a 100644 --- a/src/mesa/tnl/t_vp_build.c +++ b/src/mesa/tnl/t_vp_build.c @@ -946,7 +946,7 @@ static void build_lighting( struct tnl_program *p ) */ VPpli = register_param3(p, STATE_LIGHT, i, STATE_POSITION_NORMALIZED); - half = register_param3(p, STATE_LIGHT, i, STATE_HALF); + half = register_param3(p, STATE_LIGHT, i, STATE_HALF_VECTOR); } else { struct ureg Ppli = register_param3(p, STATE_LIGHT, i, @@ -1328,8 +1328,8 @@ static void build_texture_transform( struct tnl_program *p ) static void build_pointsize( struct tnl_program *p ) { struct ureg eye = get_eye_position(p); - struct ureg state_size = register_param1(p, STATE_POINT_SIZE); - struct ureg state_attenuation = register_param1(p, STATE_POINT_ATTENUATION); + struct ureg state_size = register_param2(p, STATE_POINT, STATE_POINT_SIZE); + struct ureg state_attenuation = register_param2(p, STATE_POINT, STATE_POINT_ATTENUATION); struct ureg out = register_output(p, VERT_RESULT_PSIZ); struct ureg ut = get_temp(p); -- cgit v1.2.3 From 776bc9cf55b116e17dddde4d097985b51879c83f Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 22 Feb 2007 09:29:46 -0700 Subject: Undo some STATE_POINT/FOG changes. Max length of state token array is now 5. --- src/mesa/shader/arbprogparse.c | 6 +-- src/mesa/shader/prog_parameter.c | 2 +- src/mesa/shader/prog_statevars.c | 71 ++++++++++++----------------------- src/mesa/shader/prog_statevars.h | 4 +- src/mesa/shader/programopt.c | 9 +++-- src/mesa/shader/slang/slang_builtin.c | 18 ++++++--- src/mesa/tnl/t_vp_build.c | 4 +- 7 files changed, 48 insertions(+), 66 deletions(-) (limited to 'src/mesa/tnl/t_vp_build.c') diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c index 480fdf512c..9dbcb60a17 100644 --- a/src/mesa/shader/arbprogparse.c +++ b/src/mesa/shader/arbprogparse.c @@ -1276,13 +1276,11 @@ parse_state_single_item (GLcontext * ctx, const GLubyte ** inst, case STATE_POINT: switch (*(*inst++)) { case POINT_SIZE: - state_tokens[0] = STATE_POINT; - state_tokens[1] = STATE_POINT_SIZE; + state_tokens[0] = STATE_POINT_SIZE; break; case POINT_ATTENUATION: - state_tokens[0] = STATE_POINT; - state_tokens[1] = STATE_POINT_ATTENUATION; + state_tokens[0] = STATE_POINT_ATTENUATION; break; } break; diff --git a/src/mesa/shader/prog_parameter.c b/src/mesa/shader/prog_parameter.c index 3ebd559119..505c5016ac 100644 --- a/src/mesa/shader/prog_parameter.c +++ b/src/mesa/shader/prog_parameter.c @@ -379,7 +379,7 @@ _mesa_add_state_reference(struct gl_program_parameter_list *paramList, /* Check if the state reference is already in the list */ for (index = 0; index < (GLint) paramList->NumParameters; index++) { GLuint i, match = 0; - for (i = 0; i < 6; i++) { + for (i = 0; i < STATE_LENGTH; i++) { if (paramList->Parameters[index].StateIndexes[i] == stateTokens[i]) { match++; } diff --git a/src/mesa/shader/prog_statevars.c b/src/mesa/shader/prog_statevars.c index 53778183c5..0d70af3b27 100644 --- a/src/mesa/shader/prog_statevars.c +++ b/src/mesa/shader/prog_statevars.c @@ -246,17 +246,14 @@ _mesa_fetch_state(GLcontext *ctx, const gl_state_index state[], COPY_4V(value, ctx->Texture.Unit[unit].EnvColor); } return; - case STATE_FOG: - if (state[1] == STATE_FOG_COLOR) { - COPY_4V(value, ctx->Fog.Color); - } - else { - ASSERT(state[1] == STATE_FOG_PARAMS); - value[0] = ctx->Fog.Density; - value[1] = ctx->Fog.Start; - value[2] = ctx->Fog.End; - value[3] = 1.0F / (ctx->Fog.End - ctx->Fog.Start); - } + case STATE_FOG_COLOR: + COPY_4V(value, ctx->Fog.Color); + return; + case STATE_FOG_PARAMS: + value[0] = ctx->Fog.Density; + value[1] = ctx->Fog.Start; + value[2] = ctx->Fog.End; + value[3] = 1.0F / (ctx->Fog.End - ctx->Fog.Start); return; case STATE_CLIPPLANE: { @@ -264,20 +261,17 @@ _mesa_fetch_state(GLcontext *ctx, const gl_state_index state[], COPY_4V(value, ctx->Transform.EyeUserPlane[plane]); } return; - case STATE_POINT: - if (state[1] == STATE_POINT_SIZE) { - value[0] = ctx->Point.Size; - value[1] = ctx->Point.MinSize; - value[2] = ctx->Point.MaxSize; - value[3] = ctx->Point.Threshold; - } - else { - ASSERT(state[1] == STATE_POINT_ATTENUATION); - value[0] = ctx->Point.Params[0]; - value[1] = ctx->Point.Params[1]; - value[2] = ctx->Point.Params[2]; - value[3] = 1.0F; - } + case STATE_POINT_SIZE: + value[0] = ctx->Point.Size; + value[1] = ctx->Point.MinSize; + value[2] = ctx->Point.MaxSize; + value[3] = ctx->Point.Threshold; + return; + case STATE_POINT_ATTENUATION: + value[0] = ctx->Point.Params[0]; + value[1] = ctx->Point.Params[1]; + value[2] = ctx->Point.Params[2]; + value[3] = 1.0F; return; case STATE_MODELVIEW_MATRIX: case STATE_PROJECTION_MATRIX: @@ -459,17 +453,15 @@ _mesa_program_state_flags(const GLint state[STATE_LENGTH]) case STATE_TEXENV_COLOR: return _NEW_TEXTURE; - case STATE_FOG: -#if 0 case STATE_FOG_COLOR: case STATE_FOG_PARAMS: -#endif return _NEW_FOG; case STATE_CLIPPLANE: return _NEW_TRANSFORM; - case STATE_POINT: + case STATE_POINT_SIZE: + case STATE_POINT_ATTENUATION: return _NEW_POINT; case STATE_MODELVIEW_MATRIX: @@ -543,26 +535,20 @@ append_token(char *dst, gl_state_index k) case STATE_TEXGEN: append(dst, "texgen"); break; - case STATE_FOG: - append(dst, "fog"); - break; case STATE_FOG_COLOR: - append(dst, ".color"); + append(dst, "fog.color"); break; case STATE_FOG_PARAMS: - append(dst, ".params"); + append(dst, "fog.params"); break; case STATE_CLIPPLANE: append(dst, "clip"); break; - case STATE_POINT: - append(dst, "point"); - break; case STATE_POINT_SIZE: - append(dst, "size"); + append(dst, "point.size"); break; case STATE_POINT_ATTENUATION: - append(dst, "attenuation"); + append(dst, "point.attenuation"); break; case STATE_MODELVIEW_MATRIX: append(dst, "matrix.modelview"); @@ -733,17 +719,10 @@ _mesa_program_state_string(const GLint state[STATE_LENGTH]) append_index(str, state[1]); /* tex unit [i] */ append(str, "color"); break; - case STATE_FOG: - append(str, "fog"); - append_token(str, (gl_state_index) state[1]); /* color or params */ - break; case STATE_CLIPPLANE: append_index(str, state[1]); /* plane [i] */ append(str, ".plane"); break; - case STATE_POINT: - append_token(str, state[1]); - break; case STATE_MODELVIEW_MATRIX: case STATE_PROJECTION_MATRIX: case STATE_MVP_MATRIX: diff --git a/src/mesa/shader/prog_statevars.h b/src/mesa/shader/prog_statevars.h index 91713f3d1d..82169342cd 100644 --- a/src/mesa/shader/prog_statevars.h +++ b/src/mesa/shader/prog_statevars.h @@ -32,7 +32,7 @@ * Number of STATE_* values we need to address any GL state. * Used to dimension arrays. */ -#define STATE_LENGTH 6 +#define STATE_LENGTH 5 /** @@ -54,13 +54,11 @@ typedef enum gl_state_index_ { STATE_TEXGEN, - STATE_FOG, STATE_FOG_COLOR, STATE_FOG_PARAMS, STATE_CLIPPLANE, - STATE_POINT, STATE_POINT_SIZE, STATE_POINT_ATTENUATION, diff --git a/src/mesa/shader/programopt.c b/src/mesa/shader/programopt.c index 05a05cd369..18da39c2d3 100644 --- a/src/mesa/shader/programopt.c +++ b/src/mesa/shader/programopt.c @@ -56,7 +56,7 @@ _mesa_insert_mvp_code(GLcontext *ctx, struct gl_vertex_program *vprog) * Setup state references for the modelview/projection matrix. * XXX we should check if these state vars are already declared. */ - static const GLint mvpState[4][5] = { + static const GLint mvpState[4][STATE_LENGTH] = { { STATE_MVP_MATRIX, 0, 0, 0, 0 }, /* state.matrix.mvp.row[0] */ { STATE_MVP_MATRIX, 0, 1, 1, 0 }, /* state.matrix.mvp.row[1] */ { STATE_MVP_MATRIX, 0, 2, 2, 0 }, /* state.matrix.mvp.row[2] */ @@ -125,9 +125,10 @@ _mesa_insert_mvp_code(GLcontext *ctx, struct gl_vertex_program *vprog) void _mesa_append_fog_code(GLcontext *ctx, struct gl_fragment_program *fprog) { - static const GLint fogPStateOpt[] = { STATE_INTERNAL, - STATE_FOG_PARAMS_OPTIMIZED, 0, 0, 0 }; - static const GLint fogColorState[] = { STATE_FOG, STATE_FOG_COLOR, 0, 0, 0}; + static const GLint fogPStateOpt[STATE_LENGTH] + = { STATE_INTERNAL, STATE_FOG_PARAMS_OPTIMIZED, 0, 0, 0 }; + static const GLint fogColorState[STATE_LENGTH] + = { STATE_FOG_COLOR, 0, 0, 0, 0}; struct prog_instruction *newInst, *inst; const GLuint origLen = fprog->Base.NumInstructions; const GLuint newLen = origLen + 5; diff --git a/src/mesa/shader/slang/slang_builtin.c b/src/mesa/shader/slang/slang_builtin.c index 47e6bcbcc4..7f4290b91f 100644 --- a/src/mesa/shader/slang/slang_builtin.c +++ b/src/mesa/shader/slang/slang_builtin.c @@ -99,6 +99,13 @@ lookup_statevar(const char *var, GLint index1, GLint index2, const char *field, tokens[0] = STATE_CLIPPLANE; tokens[1] = index1; } + else if (strcmp(var, "gl_Point") == 0) { + if (strcmp(field, "size") == 0) { + tokens[0] = STATE_POINT_SIZE; + *swizzleOut = SWIZZLE_XXXX; + } + /* XXX finish */ + } else if (strcmp(var, "gl_FrontMaterial") == 0 || strcmp(var, "gl_BackMaterial") == 0) { tokens[0] = STATE_MATERIAL; @@ -269,24 +276,23 @@ lookup_statevar(const char *var, GLint index1, GLint index2, const char *field, tokens[2] = STATE_TEXGEN_OBJECT_Q; } else if (strcmp(var, "gl_Fog") == 0) { - tokens[0] = STATE_FOG; if (strcmp(field, "color") == 0) { - tokens[1] = STATE_FOG_COLOR; + tokens[0] = STATE_FOG_COLOR; } else if (strcmp(field, "density") == 0) { - tokens[1] = STATE_FOG_PARAMS; + tokens[0] = STATE_FOG_PARAMS; *swizzleOut = SWIZZLE_XXXX; } else if (strcmp(field, "start") == 0) { - tokens[1] = STATE_FOG_PARAMS; + tokens[0] = STATE_FOG_PARAMS; *swizzleOut = SWIZZLE_YYYY; } else if (strcmp(field, "end") == 0) { - tokens[1] = STATE_FOG_PARAMS; + tokens[0] = STATE_FOG_PARAMS; *swizzleOut = SWIZZLE_ZZZZ; } else if (strcmp(field, "scale") == 0) { - tokens[1] = STATE_FOG_PARAMS; + tokens[0] = STATE_FOG_PARAMS; *swizzleOut = SWIZZLE_WWWW; } else { diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c index 283782588a..17f115f4a2 100644 --- a/src/mesa/tnl/t_vp_build.c +++ b/src/mesa/tnl/t_vp_build.c @@ -1323,8 +1323,8 @@ static void build_texture_transform( struct tnl_program *p ) static void build_pointsize( struct tnl_program *p ) { struct ureg eye = get_eye_position(p); - struct ureg state_size = register_param2(p, STATE_POINT, STATE_POINT_SIZE); - struct ureg state_attenuation = register_param2(p, STATE_POINT, STATE_POINT_ATTENUATION); + struct ureg state_size = register_param1(p, STATE_POINT_SIZE); + struct ureg state_attenuation = register_param1(p, STATE_POINT_ATTENUATION); struct ureg out = register_output(p, VERT_RESULT_PSIZ); struct ureg ut = get_temp(p); -- cgit v1.2.3 From fce8409cbbe6aa5309163f3d63894233b8833308 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 23 Feb 2007 11:44:44 -0700 Subject: s/GLint/gl_state_index/, length is now 5 not 6 --- src/mesa/tnl/t_vp_build.c | 61 ++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 32 deletions(-) (limited to 'src/mesa/tnl/t_vp_build.c') diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c index 17f115f4a2..f9e5045be7 100644 --- a/src/mesa/tnl/t_vp_build.c +++ b/src/mesa/tnl/t_vp_build.c @@ -414,40 +414,37 @@ static struct ureg get_identity_param( struct tnl_program *p ) return p->identity; } -static struct ureg register_param6( struct tnl_program *p, +static struct ureg register_param5(struct tnl_program *p, GLint s0, GLint s1, GLint s2, GLint s3, - GLint s4, - GLint s5) + GLint s4) { - GLint tokens[6]; + gl_state_index tokens[STATE_LENGTH]; GLint idx; tokens[0] = s0; tokens[1] = s1; tokens[2] = s2; tokens[3] = s3; tokens[4] = s4; - tokens[5] = s5; idx = _mesa_add_state_reference( p->program->Base.Parameters, tokens ); return make_ureg(PROGRAM_STATE_VAR, idx); } -#define register_param1(p,s0) register_param6(p,s0,0,0,0,0,0) -#define register_param2(p,s0,s1) register_param6(p,s0,s1,0,0,0,0) -#define register_param3(p,s0,s1,s2) register_param6(p,s0,s1,s2,0,0,0) -#define register_param4(p,s0,s1,s2,s3) register_param6(p,s0,s1,s2,s3,0,0) +#define register_param1(p,s0) register_param5(p,s0,0,0,0,0) +#define register_param2(p,s0,s1) register_param5(p,s0,s1,0,0,0) +#define register_param3(p,s0,s1,s2) register_param5(p,s0,s1,s2,0,0) +#define register_param4(p,s0,s1,s2,s3) register_param5(p,s0,s1,s2,s3,0) -static void register_matrix_param6( struct tnl_program *p, - GLint s0, - GLint s1, - GLint s2, - GLint s3, - GLint s4, - GLint s5, +static void register_matrix_param5( struct tnl_program *p, + GLint s0, /* modelview, projection, etc */ + GLint s1, /* texture matrix number */ + GLint s2, /* first row */ + GLint s3, /* last row */ + GLint s4, /* inverse, transpose, etc */ struct ureg *matrix ) { GLint i; @@ -455,8 +452,8 @@ static void register_matrix_param6( struct tnl_program *p, /* This is a bit sad as the support is there to pull the whole * matrix out in one go: */ - for (i = 0; i <= s4 - s3; i++) - matrix[i] = register_param6( p, s0, s1, s2, i, i, s5 ); + for (i = 0; i <= s3 - s2; i++) + matrix[i] = register_param5( p, s0, s1, i, i, s4 ); } @@ -636,14 +633,14 @@ static struct ureg get_eye_position( struct tnl_program *p ) p->eye_position = reserve_temp(p); if (PREFER_DP4) { - register_matrix_param6( p, STATE_MODELVIEW_MATRIX, 0, 0, 3, - 0, 0, modelview ); + register_matrix_param5( p, STATE_MODELVIEW_MATRIX, 0, 0, 3, + 0, modelview ); emit_matrix_transform_vec4(p, p->eye_position, modelview, pos); } else { - register_matrix_param6( p, STATE_MODELVIEW_MATRIX, 0, 0, 3, - STATE_MATRIX_TRANSPOSE, 0, modelview ); + register_matrix_param5( p, STATE_MODELVIEW_MATRIX, 0, 0, 3, + STATE_MATRIX_TRANSPOSE, modelview ); emit_transpose_matrix_transform_vec4(p, p->eye_position, modelview, pos); } @@ -671,8 +668,8 @@ static struct ureg get_eye_normal( struct tnl_program *p ) struct ureg normal = register_input(p, VERT_ATTRIB_NORMAL ); struct ureg mvinv[3]; - register_matrix_param6( p, STATE_MODELVIEW_MATRIX, 0, 0, 2, - STATE_MATRIX_INVTRANS, 0, mvinv ); + register_matrix_param5( p, STATE_MODELVIEW_MATRIX, 0, 0, 2, + STATE_MATRIX_INVTRANS, mvinv ); p->eye_normal = reserve_temp(p); @@ -706,13 +703,13 @@ static void build_hpos( struct tnl_program *p ) struct ureg mvp[4]; if (PREFER_DP4) { - register_matrix_param6( p, STATE_MVP_MATRIX, 0, 0, 3, - 0, 0, mvp ); + register_matrix_param5( p, STATE_MVP_MATRIX, 0, 0, 3, + 0, mvp ); emit_matrix_transform_vec4( p, hpos, mvp, pos ); } else { - register_matrix_param6( p, STATE_MVP_MATRIX, 0, 0, 3, - STATE_MATRIX_TRANSPOSE, 0, mvp ); + register_matrix_param5( p, STATE_MVP_MATRIX, 0, 0, 3, + STATE_MATRIX_TRANSPOSE, mvp ); emit_transpose_matrix_transform_vec4( p, hpos, mvp, pos ); } } @@ -1300,13 +1297,13 @@ static void build_texture_transform( struct tnl_program *p ) out_texgen : register_input(p, VERT_ATTRIB_TEX0+i)); if (PREFER_DP4) { - register_matrix_param6( p, STATE_TEXTURE_MATRIX, i, 0, 3, - 0, 0, texmat ); + register_matrix_param5( p, STATE_TEXTURE_MATRIX, i, 0, 3, + 0, texmat ); emit_matrix_transform_vec4( p, out, texmat, in ); } else { - register_matrix_param6( p, STATE_TEXTURE_MATRIX, i, 0, 3, - STATE_MATRIX_TRANSPOSE, 0, texmat ); + register_matrix_param5( p, STATE_TEXTURE_MATRIX, i, 0, 3, + STATE_MATRIX_TRANSPOSE, texmat ); emit_transpose_matrix_transform_vec4( p, out, texmat, in ); } } -- cgit v1.2.3