From ce7f006e66533da9f6db61e368273f1ffcc12ace Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sat, 5 Apr 2003 00:38:09 +0000 Subject: [PATCH] fragment program named constants and named program parameters basically work now --- src/mesa/main/mtypes.h | 3 +- src/mesa/main/nvfragparse.c | 83 +++++++++++++--------- src/mesa/main/nvfragprog.h | 4 +- src/mesa/main/nvprogram.c | 33 +++++---- src/mesa/swrast/s_nvfragprog.c | 154 +++++++++++++++++++++++------------------ 5 files changed, 158 insertions(+), 119 deletions(-) diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index a1c8dac..7511790 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1,4 +1,4 @@ -/* $Id: mtypes.h,v 1.108 2003/03/29 17:01:00 brianp Exp $ */ +/* $Id: mtypes.h,v 1.109 2003/04/05 00:38:09 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -1213,6 +1213,7 @@ struct program_parameter { const char *Name; GLfloat Values[4]; + GLboolean Constant; }; diff --git a/src/mesa/main/nvfragparse.c b/src/mesa/main/nvfragparse.c index 75f4e84..03c2060 100644 --- a/src/mesa/main/nvfragparse.c +++ b/src/mesa/main/nvfragparse.c @@ -1,4 +1,4 @@ -/* $Id: nvfragparse.c,v 1.16 2003/04/01 16:17:03 brianp Exp $ */ +/* $Id: nvfragparse.c,v 1.17 2003/04/05 00:38:09 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -158,9 +158,13 @@ struct parse_state { }; -static void +/** + * Add a new program parameter (via DEFINE statement) + * \return index of the new entry in the parameter list + */ +static GLuint add_parameter(struct parse_state *parseState, - const char *name, const GLfloat values[4]) + const char *name, const GLfloat values[4], GLboolean constant) { const GLuint n = parseState->numParameters; @@ -170,6 +174,27 @@ add_parameter(struct parse_state *parseState, parseState->numParameters = n + 1; parseState->parameters[n].Name = _mesa_strdup(name); COPY_4V(parseState->parameters[n].Values, values); + parseState->parameters[n].Constant = constant; + return n; +} + + +/** + * Add a new unnamed constant to the parameter lists. + * \param parseState parsing state + * \param values four float values + * \return index of the new parameter. + */ +static GLuint +add_unnamed_constant(struct parse_state *parseState, const GLfloat values[4]) +{ + /* generate a new dummy name */ + static GLuint n = 0; + char name[20]; + _mesa_sprintf(name, "constant%d", n); + n++; + /* store it */ + return add_parameter(parseState, name, values, GL_TRUE); } @@ -185,30 +210,15 @@ lookup_parameter(struct parse_state *parseState, const char *name) } -static void -add_constant(struct parse_state *parseState, - const char *name, const GLfloat values[4]) +static const GLint +lookup_parameter_index(struct parse_state *parseState, const char *name) { - const GLuint n = parseState->numConstants; - - parseState->constants = _mesa_realloc(parseState->constants, - n * sizeof(struct program_parameter), - (n + 1) * sizeof(struct program_parameter)); - parseState->numConstants = n + 1; - parseState->constants[n].Name = _mesa_strdup(name); - COPY_4V(parseState->constants[n].Values, values); -} - - -static const GLfloat * -lookup_constant(struct parse_state *parseState, const char *name) -{ - GLuint i; - for (i = 0; i < parseState->numConstants; i++) { - if (_mesa_strcmp(parseState->constants[i].Name, name) == 0) - return parseState->constants[i].Values; + GLint i; + for (i = 0; i < parseState->numParameters; i++) { + if (_mesa_strcmp(parseState->parameters[i].Name, name) == 0) + return i; } - return NULL; + return -1; } @@ -571,7 +581,8 @@ Parse_ScalarConstant(struct parse_state *parseState, GLfloat *number) const GLfloat *constant; if (!Parse_Identifier(parseState, ident)) RETURN_ERROR1("Expected an identifier"); - constant = lookup_constant(parseState, (const char *) ident); + constant = lookup_parameter(parseState, (const char *) ident); + /* XXX Check that it's a constant and not a parameter */ if (!constant) { RETURN_ERROR1("Undefined symbol"); } @@ -1106,11 +1117,16 @@ Parse_VectorSrc(struct parse_state *parseState, RETURN_ERROR; } else if (IsLetter(token[0])){ - /* XXX named constant */ GLubyte ident[100]; + GLint paramIndex; if (!Parse_Identifier(parseState, ident)) RETURN_ERROR; - srcReg->Register = 0; /* XXX fix */ + paramIndex = lookup_parameter_index(parseState, (const char *) ident); + if (paramIndex < 0) { + RETURN_ERROR2("Undefined constant or parameter: ", ident); + } + srcReg->IsParameter = GL_TRUE; + srcReg->Register = paramIndex; } else if (IsDigit(token[0]) || token[0] == '-' || token[0] == '+'){ /* XXX literal scalar constant */ @@ -1122,10 +1138,13 @@ Parse_VectorSrc(struct parse_state *parseState, else if (token[0] == '{'){ /* XXX literal vector constant */ GLfloat values[4]; + GLuint paramIndex; (void) Parse_String(parseState, "{"); if (!Parse_VectorConstant(parseState, values)) RETURN_ERROR; - srcReg->Register = 0; /* XXX fix */ + paramIndex = add_unnamed_constant(parseState, values); + srcReg->IsParameter = GL_TRUE; + srcReg->Register = paramIndex; } else { RETURN_ERROR2("Invalid source register name", token); @@ -1247,7 +1266,7 @@ Parse_InstructionSequence(struct parse_state *parseState, if (lookup_parameter(parseState, (const char *) id)) { RETURN_ERROR2(id, "already defined"); } - add_parameter(parseState, (const char *) id, value); + add_parameter(parseState, (const char *) id, value, GL_TRUE); } else if (Parse_String(parseState, "DECLARE")) { GLubyte id[100]; @@ -1266,10 +1285,10 @@ Parse_InstructionSequence(struct parse_state *parseState, } if (!Parse_String(parseState, ";")) RETURN_ERROR1("Expected ;"); - if (lookup_constant(parseState, (const char *) id)) { + if (lookup_parameter(parseState, (const char *) id)) { RETURN_ERROR2(id, "already declared"); } - add_constant(parseState, (const char *) id, value); + add_parameter(parseState, (const char *) id, value, GL_FALSE); } else if (Parse_String(parseState, "END")) { inst->Opcode = FP_OPCODE_END; diff --git a/src/mesa/main/nvfragprog.h b/src/mesa/main/nvfragprog.h index 8d1ed13..2e9d829 100644 --- a/src/mesa/main/nvfragprog.h +++ b/src/mesa/main/nvfragprog.h @@ -1,4 +1,4 @@ -/* $Id: nvfragprog.h,v 1.5 2003/03/15 17:33:26 brianp Exp $ */ +/* $Id: nvfragprog.h,v 1.6 2003/04/05 00:38:09 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -134,8 +134,8 @@ enum fp_opcode { struct fp_src_register { - GLint RegType; /* constant, param, temp or attribute register */ GLint Register; /* or the offset from the address register */ + GLboolean IsParameter; /* true if register refers to a param or constant */ GLuint Swizzle[4]; GLboolean NegateBase; /* negate before absolute value? */ GLboolean Abs; /* take absolute value? */ diff --git a/src/mesa/main/nvprogram.c b/src/mesa/main/nvprogram.c index ef0f479..ae0a908 100644 --- a/src/mesa/main/nvprogram.c +++ b/src/mesa/main/nvprogram.c @@ -1,4 +1,4 @@ -/* $Id: nvprogram.c,v 1.10 2003/03/29 16:37:08 brianp Exp $ */ +/* $Id: nvprogram.c,v 1.11 2003/04/05 00:38:09 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -1043,7 +1043,7 @@ _mesa_ProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte *name, { struct program *prog; struct fragment_program *fragProg; - GLint reg; + GLint i; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); @@ -1059,12 +1059,14 @@ _mesa_ProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte *name, } fragProg = (struct fragment_program *) prog; - for (reg = 0; reg < fragProg->NumParameters; reg++) { - if (!_mesa_strcmp(fragProg->Parameters[reg].Name, (const char *) name)) { - fragProg->Parameters[reg].Values[0] = x; - fragProg->Parameters[reg].Values[1] = y; - fragProg->Parameters[reg].Values[2] = z; - fragProg->Parameters[reg].Values[3] = w; + for (i = 0; i < fragProg->NumParameters; i++) { + printf("test %d %s\n", i, fragProg->Parameters[i].Name); + if (!_mesa_strcmp(fragProg->Parameters[i].Name, (const char *) name)) { + ASSERT(!fragProg->Parameters[i].Constant); + fragProg->Parameters[i].Values[0] = x; + fragProg->Parameters[i].Values[1] = y; + fragProg->Parameters[i].Values[2] = z; + fragProg->Parameters[i].Values[3] = w; return; } } @@ -1105,7 +1107,7 @@ _mesa_GetProgramNamedParameterfvNV(GLuint id, GLsizei len, const GLubyte *name, { struct program *prog; struct fragment_program *fragProg; - GLint reg; + GLint i; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); @@ -1121,12 +1123,13 @@ _mesa_GetProgramNamedParameterfvNV(GLuint id, GLsizei len, const GLubyte *name, } fragProg = (struct fragment_program *) prog; - for (reg = 0; reg < fragProg->NumParameters; reg++) { - if (!_mesa_strcmp(fragProg->Parameters[reg].Name, (const char *) name)) { - params[0] = fragProg->Parameters[reg].Values[0]; - params[1] = fragProg->Parameters[reg].Values[1]; - params[2] = fragProg->Parameters[reg].Values[2]; - params[3] = fragProg->Parameters[reg].Values[3]; + for (i = 0; i < fragProg->NumParameters; i++) { + if (!_mesa_strcmp(fragProg->Parameters[i].Name, (const char *) name)) { + ASSERT(!fragProg->Parameters[i].Constant); + params[0] = fragProg->Parameters[i].Values[0]; + params[1] = fragProg->Parameters[i].Values[1]; + params[2] = fragProg->Parameters[i].Values[2]; + params[3] = fragProg->Parameters[i].Values[3]; return; } } diff --git a/src/mesa/swrast/s_nvfragprog.c b/src/mesa/swrast/s_nvfragprog.c index 7d51803..b34703b 100644 --- a/src/mesa/swrast/s_nvfragprog.c +++ b/src/mesa/swrast/s_nvfragprog.c @@ -1,4 +1,4 @@ -/* $Id: s_nvfragprog.c,v 1.12 2003/03/25 02:23:47 brianp Exp $ */ +/* $Id: s_nvfragprog.c,v 1.13 2003/04/05 00:38:10 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -99,9 +99,17 @@ fetch_texel_deriv( GLcontext *ctx, const GLfloat texcoord[4], static void fetch_vector4( const struct fp_src_register *source, const struct fp_machine *machine, + const struct fragment_program *program, GLfloat result[4] ) { - const GLfloat *src = machine->Registers[source->Register]; + const GLfloat *src; + + if (source->IsParameter) { + src = program->Parameters[source->Register].Values; + } + else { + src = machine->Registers[source->Register]; + } result[0] = src[source->Swizzle[0]]; result[1] = src[source->Swizzle[1]]; @@ -260,9 +268,17 @@ fetch_vector4_deriv( const struct fp_src_register *source, static void fetch_vector1( const struct fp_src_register *source, const struct fp_machine *machine, + const struct fragment_program *program, GLfloat result[4] ) { - const GLfloat *src = machine->Registers[source->Register]; + const GLfloat *src; + + if (source->IsParameter) { + src = program->Parameters[source->Register].Values; + } + else { + src = machine->Registers[source->Register]; + } result[0] = src[source->Swizzle[0]]; @@ -495,8 +511,8 @@ execute_program( GLcontext *ctx, case FP_OPCODE_ADD: { GLfloat a[4], b[4], result[4]; - fetch_vector4( &inst->SrcReg[0], machine, a ); - fetch_vector4( &inst->SrcReg[1], machine, b ); + fetch_vector4( &inst->SrcReg[0], machine, program, a ); + fetch_vector4( &inst->SrcReg[1], machine, program, b ); result[0] = a[0] + b[0]; result[1] = a[1] + b[1]; result[2] = a[2] + b[2]; @@ -507,7 +523,7 @@ execute_program( GLcontext *ctx, case FP_OPCODE_COS: { GLfloat a[4], result[4]; - fetch_vector1( &inst->SrcReg[0], machine, a ); + fetch_vector1( &inst->SrcReg[0], machine, program, a ); result[0] = result[1] = result[2] = result[3] = _mesa_cos(a[0]); store_vector4( inst, machine, result ); } @@ -527,7 +543,7 @@ execute_program( GLcontext *ctx, init_machine_deriv(ctx, machine, program, span, 'X', &dMachine); execute_program(ctx, program, pc, &dMachine, span); - fetch_vector4( &inst->SrcReg[0], &dMachine, aNext ); + fetch_vector4( &inst->SrcReg[0], &dMachine, program, aNext ); result[0] = aNext[0] - a[0]; result[1] = aNext[1] - a[1]; result[2] = aNext[2] - a[2]; @@ -544,7 +560,7 @@ execute_program( GLcontext *ctx, init_machine_deriv(ctx, machine, program, span, 'Y', &dMachine); execute_program(ctx, program, pc, &dMachine, span); - fetch_vector4( &inst->SrcReg[0], &dMachine, aNext ); + fetch_vector4( &inst->SrcReg[0], &dMachine, program, aNext ); result[0] = aNext[0] - a[0]; result[1] = aNext[1] - a[1]; result[2] = aNext[2] - a[2]; @@ -556,8 +572,8 @@ execute_program( GLcontext *ctx, case FP_OPCODE_DP3: { GLfloat a[4], b[4], result[4]; - fetch_vector4( &inst->SrcReg[0], machine, a ); - fetch_vector4( &inst->SrcReg[1], machine, b ); + fetch_vector4( &inst->SrcReg[0], machine, program, a ); + fetch_vector4( &inst->SrcReg[1], machine, program, b ); result[0] = result[1] = result[2] = result[3] = a[0] + b[0] + a[1] * b[1] + a[2] * b[2]; store_vector4( inst, machine, result ); @@ -566,8 +582,8 @@ execute_program( GLcontext *ctx, case FP_OPCODE_DP4: { GLfloat a[4], b[4], result[4]; - fetch_vector4( &inst->SrcReg[0], machine, a ); - fetch_vector4( &inst->SrcReg[1], machine, b ); + fetch_vector4( &inst->SrcReg[0], machine, program, a ); + fetch_vector4( &inst->SrcReg[1], machine, program, b ); result[0] = result[1] = result[2] = result[3] = a[0] + b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3]; store_vector4( inst, machine, result ); @@ -576,8 +592,8 @@ execute_program( GLcontext *ctx, case FP_OPCODE_DST: /* Distance vector */ { GLfloat a[4], b[4], result[4]; - fetch_vector4( &inst->SrcReg[0], machine, a ); - fetch_vector4( &inst->SrcReg[1], machine, b ); + fetch_vector4( &inst->SrcReg[0], machine, program, a ); + fetch_vector4( &inst->SrcReg[1], machine, program, b ); result[0] = 1.0F; result[1] = a[1] * b[1]; result[2] = a[2]; @@ -588,7 +604,7 @@ execute_program( GLcontext *ctx, case FP_OPCODE_EX2: /* Exponential base 2 */ { GLfloat a[4], result[4]; - fetch_vector1( &inst->SrcReg[0], machine, a ); + fetch_vector1( &inst->SrcReg[0], machine, program, a ); result[0] = result[1] = result[2] = result[3] = (GLfloat) _mesa_pow(2.0, a[0]); store_vector4( inst, machine, result ); @@ -597,7 +613,7 @@ execute_program( GLcontext *ctx, case FP_OPCODE_FLR: { GLfloat a[4], result[4]; - fetch_vector4( &inst->SrcReg[0], machine, a ); + fetch_vector4( &inst->SrcReg[0], machine, program, a ); result[0] = FLOORF(a[0]); result[1] = FLOORF(a[1]); result[2] = FLOORF(a[2]); @@ -608,7 +624,7 @@ execute_program( GLcontext *ctx, case FP_OPCODE_FRC: { GLfloat a[4], result[4]; - fetch_vector4( &inst->SrcReg[0], machine, a ); + fetch_vector4( &inst->SrcReg[0], machine, program, a ); result[0] = a[0] - FLOORF(a[0]); result[1] = a[1] - FLOORF(a[1]); result[2] = a[2] - FLOORF(a[2]); @@ -630,7 +646,7 @@ execute_program( GLcontext *ctx, case FP_OPCODE_LG2: /* log base 2 */ { GLfloat a[4], result[4]; - fetch_vector1( &inst->SrcReg[0], machine, a ); + fetch_vector1( &inst->SrcReg[0], machine, program, a ); result[0] = result[1] = result[2] = result[3] = LOG2(a[0]); store_vector4( inst, machine, result ); @@ -639,7 +655,7 @@ execute_program( GLcontext *ctx, case FP_OPCODE_LIT: { GLfloat a[4], result[4]; - fetch_vector4( &inst->SrcReg[0], machine, a ); + fetch_vector4( &inst->SrcReg[0], machine, program, a ); if (a[0] < 0.0F) a[0] = 0.0F; if (a[1] < 0.0F) @@ -654,9 +670,9 @@ execute_program( GLcontext *ctx, case FP_OPCODE_LRP: { GLfloat a[4], b[4], c[4], result[4]; - fetch_vector4( &inst->SrcReg[0], machine, a ); - fetch_vector4( &inst->SrcReg[1], machine, b ); - fetch_vector4( &inst->SrcReg[2], machine, c ); + fetch_vector4( &inst->SrcReg[0], machine, program, a ); + fetch_vector4( &inst->SrcReg[1], machine, program, b ); + fetch_vector4( &inst->SrcReg[2], machine, program, c ); result[0] = a[0] * b[0] + (1.0F - a[0]) * c[0]; result[1] = a[1] * b[1] + (1.0F - a[1]) * c[1]; result[2] = a[2] * b[2] + (1.0F - a[2]) * c[2]; @@ -667,9 +683,9 @@ execute_program( GLcontext *ctx, case FP_OPCODE_MAD: { GLfloat a[4], b[4], c[4], result[4]; - fetch_vector4( &inst->SrcReg[0], machine, a ); - fetch_vector4( &inst->SrcReg[1], machine, b ); - fetch_vector4( &inst->SrcReg[2], machine, c ); + fetch_vector4( &inst->SrcReg[0], machine, program, a ); + fetch_vector4( &inst->SrcReg[1], machine, program, b ); + fetch_vector4( &inst->SrcReg[2], machine, program, c ); result[0] = a[0] * b[0] + c[0]; result[1] = a[1] * b[1] + c[1]; result[2] = a[2] * b[2] + c[2]; @@ -680,8 +696,8 @@ execute_program( GLcontext *ctx, case FP_OPCODE_MAX: { GLfloat a[4], b[4], result[4]; - fetch_vector4( &inst->SrcReg[0], machine, a ); - fetch_vector4( &inst->SrcReg[1], machine, b ); + fetch_vector4( &inst->SrcReg[0], machine, program, a ); + fetch_vector4( &inst->SrcReg[1], machine, program, b ); result[0] = MAX2(a[0], b[0]); result[1] = MAX2(a[1], b[1]); result[2] = MAX2(a[2], b[2]); @@ -692,8 +708,8 @@ execute_program( GLcontext *ctx, case FP_OPCODE_MIN: { GLfloat a[4], b[4], result[4]; - fetch_vector4( &inst->SrcReg[0], machine, a ); - fetch_vector4( &inst->SrcReg[1], machine, b ); + fetch_vector4( &inst->SrcReg[0], machine, program, a ); + fetch_vector4( &inst->SrcReg[1], machine, program, b ); result[0] = MIN2(a[0], b[0]); result[1] = MIN2(a[1], b[1]); result[2] = MIN2(a[2], b[2]); @@ -704,15 +720,15 @@ execute_program( GLcontext *ctx, case FP_OPCODE_MOV: { GLfloat result[4]; - fetch_vector4( &inst->SrcReg[0], machine, result ); + fetch_vector4( &inst->SrcReg[0], machine, program, result ); store_vector4( inst, machine, result ); } break; case FP_OPCODE_MUL: { GLfloat a[4], b[4], result[4]; - fetch_vector4( &inst->SrcReg[0], machine, a ); - fetch_vector4( &inst->SrcReg[1], machine, b ); + fetch_vector4( &inst->SrcReg[0], machine, program, a ); + fetch_vector4( &inst->SrcReg[1], machine, program, b ); result[0] = a[0] * b[0]; result[1] = a[1] * b[1]; result[2] = a[2] * b[2]; @@ -726,7 +742,7 @@ execute_program( GLcontext *ctx, GLfloat a[4], result[4]; const GLuint *rawBits = (const GLuint *) a; GLuint *rawResult = (GLuint *) result; - fetch_vector4( &inst->SrcReg[0], machine, a ); + fetch_vector4( &inst->SrcReg[0], machine, program, a ); rawResult[0] = rawResult[1] = rawResult[2] = rawResult[3] = rawBits[0] | (rawBits[1] << 16); store_vector4( inst, machine, result ); @@ -736,7 +752,7 @@ execute_program( GLcontext *ctx, { GLfloat a[4], result[4]; GLuint usx, usy, *rawResult = (GLuint *) result; - fetch_vector4( &inst->SrcReg[0], machine, a ); + fetch_vector4( &inst->SrcReg[0], machine, program, a ); a[0] = CLAMP(a[0], 0.0F, 1.0F); a[1] = CLAMP(a[0], 0.0F, 1.0F); usx = IROUND(a[0] * 65535.0F); @@ -750,7 +766,7 @@ execute_program( GLcontext *ctx, { GLfloat a[4], result[4]; GLuint ubx, uby, ubz, ubw, *rawResult = (GLuint *) result; - fetch_vector4( &inst->SrcReg[0], machine, a ); + fetch_vector4( &inst->SrcReg[0], machine, program, a ); a[0] = CLAMP(a[0], -128.0F / 127.0F, 1.0F); a[1] = CLAMP(a[1], -128.0F / 127.0F, 1.0F); a[2] = CLAMP(a[2], -128.0F / 127.0F, 1.0F); @@ -768,7 +784,7 @@ execute_program( GLcontext *ctx, { GLfloat a[4], result[4]; GLuint ubx, uby, ubz, ubw, *rawResult = (GLuint *) result; - fetch_vector4( &inst->SrcReg[0], machine, a ); + fetch_vector4( &inst->SrcReg[0], machine, program, a ); a[0] = CLAMP(a[0], 0.0F, 1.0F); a[1] = CLAMP(a[1], 0.0F, 1.0F); a[2] = CLAMP(a[2], 0.0F, 1.0F); @@ -785,8 +801,8 @@ execute_program( GLcontext *ctx, case FP_OPCODE_POW: { GLfloat a[4], b[4], result[4]; - fetch_vector1( &inst->SrcReg[0], machine, a ); - fetch_vector1( &inst->SrcReg[1], machine, b ); + fetch_vector1( &inst->SrcReg[0], machine, program, a ); + fetch_vector1( &inst->SrcReg[1], machine, program, b ); result[0] = result[1] = result[2] = result[3] = _mesa_pow(a[0], b[0]); store_vector4( inst, machine, result ); @@ -795,7 +811,7 @@ execute_program( GLcontext *ctx, case FP_OPCODE_RCP: { GLfloat a[4], result[4]; - fetch_vector1( &inst->SrcReg[0], machine, a ); + fetch_vector1( &inst->SrcReg[0], machine, program, a ); result[0] = result[1] = result[2] = result[3] = 1.0F / a[0]; store_vector4( inst, machine, result ); @@ -804,8 +820,8 @@ execute_program( GLcontext *ctx, case FP_OPCODE_RFL: { GLfloat axis[4], dir[4], result[4], tmp[4]; - fetch_vector4( &inst->SrcReg[0], machine, axis ); - fetch_vector4( &inst->SrcReg[1], machine, dir ); + fetch_vector4( &inst->SrcReg[0], machine, program, axis ); + fetch_vector4( &inst->SrcReg[1], machine, program, dir ); tmp[3] = axis[0] * axis[0] + axis[1] * axis[1] + axis[2] * axis[2]; @@ -822,7 +838,7 @@ execute_program( GLcontext *ctx, case FP_OPCODE_RSQ: /* 1 / sqrt() */ { GLfloat a[4], result[4]; - fetch_vector1( &inst->SrcReg[0], machine, a ); + fetch_vector1( &inst->SrcReg[0], machine, program, a ); result[0] = result[1] = result[2] = result[3] = INV_SQRTF(a[0]); store_vector4( inst, machine, result ); } @@ -830,8 +846,8 @@ execute_program( GLcontext *ctx, case FP_OPCODE_SEQ: /* set on equal */ { GLfloat a[4], b[4], result[4]; - fetch_vector4( &inst->SrcReg[0], machine, a ); - fetch_vector4( &inst->SrcReg[1], machine, b ); + fetch_vector4( &inst->SrcReg[0], machine, program, a ); + fetch_vector4( &inst->SrcReg[1], machine, program, b ); result[0] = (a[0] == b[0]) ? 1.0F : 0.0F; result[1] = (a[1] == b[1]) ? 1.0F : 0.0F; result[2] = (a[2] == b[2]) ? 1.0F : 0.0F; @@ -848,8 +864,8 @@ execute_program( GLcontext *ctx, case FP_OPCODE_SGE: /* set on greater or equal */ { GLfloat a[4], b[4], result[4]; - fetch_vector4( &inst->SrcReg[0], machine, a ); - fetch_vector4( &inst->SrcReg[1], machine, b ); + fetch_vector4( &inst->SrcReg[0], machine, program, a ); + fetch_vector4( &inst->SrcReg[1], machine, program, b ); result[0] = (a[0] >= b[0]) ? 1.0F : 0.0F; result[1] = (a[1] >= b[1]) ? 1.0F : 0.0F; result[2] = (a[2] >= b[2]) ? 1.0F : 0.0F; @@ -860,8 +876,8 @@ execute_program( GLcontext *ctx, case FP_OPCODE_SGT: /* set on greater */ { GLfloat a[4], b[4], result[4]; - fetch_vector4( &inst->SrcReg[0], machine, a ); - fetch_vector4( &inst->SrcReg[1], machine, b ); + fetch_vector4( &inst->SrcReg[0], machine, program, a ); + fetch_vector4( &inst->SrcReg[1], machine, program, b ); result[0] = (a[0] > b[0]) ? 1.0F : 0.0F; result[1] = (a[1] > b[1]) ? 1.0F : 0.0F; result[2] = (a[2] > b[2]) ? 1.0F : 0.0F; @@ -872,7 +888,7 @@ execute_program( GLcontext *ctx, case FP_OPCODE_SIN: { GLfloat a[4], result[4]; - fetch_vector1( &inst->SrcReg[0], machine, a ); + fetch_vector1( &inst->SrcReg[0], machine, program, a ); result[0] = result[1] = result[2] = result[3] = _mesa_sin(a[0]); store_vector4( inst, machine, result ); } @@ -880,8 +896,8 @@ execute_program( GLcontext *ctx, case FP_OPCODE_SLE: /* set on less or equal */ { GLfloat a[4], b[4], result[4]; - fetch_vector4( &inst->SrcReg[0], machine, a ); - fetch_vector4( &inst->SrcReg[1], machine, b ); + fetch_vector4( &inst->SrcReg[0], machine, program, a ); + fetch_vector4( &inst->SrcReg[1], machine, program, b ); result[0] = (a[0] <= b[0]) ? 1.0F : 0.0F; result[1] = (a[1] <= b[1]) ? 1.0F : 0.0F; result[2] = (a[2] <= b[2]) ? 1.0F : 0.0F; @@ -892,8 +908,8 @@ execute_program( GLcontext *ctx, case FP_OPCODE_SLT: /* set on less */ { GLfloat a[4], b[4], result[4]; - fetch_vector4( &inst->SrcReg[0], machine, a ); - fetch_vector4( &inst->SrcReg[1], machine, b ); + fetch_vector4( &inst->SrcReg[0], machine, program, a ); + fetch_vector4( &inst->SrcReg[1], machine, program, b ); result[0] = (a[0] < b[0]) ? 1.0F : 0.0F; result[1] = (a[1] < b[1]) ? 1.0F : 0.0F; result[2] = (a[2] < b[2]) ? 1.0F : 0.0F; @@ -904,8 +920,8 @@ execute_program( GLcontext *ctx, case FP_OPCODE_SNE: /* set on not equal */ { GLfloat a[4], b[4], result[4]; - fetch_vector4( &inst->SrcReg[0], machine, a ); - fetch_vector4( &inst->SrcReg[1], machine, b ); + fetch_vector4( &inst->SrcReg[0], machine, program, a ); + fetch_vector4( &inst->SrcReg[1], machine, program, b ); result[0] = (a[0] != b[0]) ? 1.0F : 0.0F; result[1] = (a[1] != b[1]) ? 1.0F : 0.0F; result[2] = (a[2] != b[2]) ? 1.0F : 0.0F; @@ -922,8 +938,8 @@ execute_program( GLcontext *ctx, case FP_OPCODE_SUB: { GLfloat a[4], b[4], result[4]; - fetch_vector4( &inst->SrcReg[0], machine, a ); - fetch_vector4( &inst->SrcReg[1], machine, b ); + fetch_vector4( &inst->SrcReg[0], machine, program, a ); + fetch_vector4( &inst->SrcReg[1], machine, program, b ); result[0] = a[0] - b[0]; result[1] = a[1] - b[1]; result[2] = a[2] - b[2]; @@ -935,7 +951,7 @@ execute_program( GLcontext *ctx, /* Texel lookup */ { GLfloat texcoord[4], color[4]; - fetch_vector4( &inst->SrcReg[0], machine, texcoord ); + fetch_vector4( &inst->SrcReg[0], machine, program, texcoord ); /* XXX: Undo perspective divide from interpolate_texcoords() */ fetch_texel( ctx, texcoord, inst->TexSrcUnit, color ); store_vector4( inst, machine, color ); @@ -945,9 +961,9 @@ execute_program( GLcontext *ctx, /* Texture lookup w/ partial derivatives for LOD */ { GLfloat texcoord[4], dtdx[4], dtdy[4], color[4]; - fetch_vector4( &inst->SrcReg[0], machine, texcoord ); - fetch_vector4( &inst->SrcReg[1], machine, dtdx ); - fetch_vector4( &inst->SrcReg[2], machine, dtdy ); + fetch_vector4( &inst->SrcReg[0], machine, program, texcoord ); + fetch_vector4( &inst->SrcReg[1], machine, program, dtdx ); + fetch_vector4( &inst->SrcReg[2], machine, program, dtdy ); fetch_texel_deriv( ctx, texcoord, dtdx, dtdy, inst->TexSrcUnit, color ); store_vector4( inst, machine, color ); @@ -957,7 +973,7 @@ execute_program( GLcontext *ctx, /* Texture lookup w/ perspective divide */ { GLfloat texcoord[4], color[4]; - fetch_vector4( &inst->SrcReg[0], machine, texcoord ); + fetch_vector4( &inst->SrcReg[0], machine, program, texcoord ); /* Already did perspective divide in interpolate_texcoords() */ fetch_texel( ctx, texcoord, inst->TexSrcUnit, color ); store_vector4( inst, machine, color ); @@ -969,7 +985,7 @@ execute_program( GLcontext *ctx, GLfloat a[4], result[4]; const GLuint *rawBits = (const GLuint *) a; GLuint *rawResult = (GLuint *) result; - fetch_vector1( &inst->SrcReg[0], machine, a ); + fetch_vector1( &inst->SrcReg[0], machine, program, a ); rawResult[0] = rawBits[0] & 0xffff; rawResult[1] = (rawBits[0] >> 16) & 0xffff; rawResult[2] = rawBits[0] & 0xffff; @@ -981,7 +997,7 @@ execute_program( GLcontext *ctx, { GLfloat a[4], result[4]; const GLuint *rawBits = (const GLuint *) a; - fetch_vector1( &inst->SrcReg[0], machine, a ); + fetch_vector1( &inst->SrcReg[0], machine, program, a ); result[0] = (GLfloat) ((rawBits[0] >> 0) & 0xffff) / 65535.0F; result[1] = (GLfloat) ((rawBits[0] >> 16) & 0xffff) / 65535.0F; result[2] = result[0]; @@ -993,7 +1009,7 @@ execute_program( GLcontext *ctx, { GLfloat a[4], result[4]; const GLuint *rawBits = (const GLuint *) a; - fetch_vector1( &inst->SrcReg[0], machine, a ); + fetch_vector1( &inst->SrcReg[0], machine, program, a ); result[0] = (((rawBits[0] >> 0) & 0xff) - 128) / 127.0F; result[0] = (((rawBits[0] >> 8) & 0xff) - 128) / 127.0F; result[0] = (((rawBits[0] >> 16) & 0xff) - 128) / 127.0F; @@ -1005,7 +1021,7 @@ execute_program( GLcontext *ctx, { GLfloat a[4], result[4]; const GLuint *rawBits = (const GLuint *) a; - fetch_vector1( &inst->SrcReg[0], machine, a ); + fetch_vector1( &inst->SrcReg[0], machine, program, a ); result[0] = ((rawBits[0] >> 0) & 0xff) / 255.0F; result[0] = ((rawBits[0] >> 8) & 0xff) / 255.0F; result[0] = ((rawBits[0] >> 16) & 0xff) / 255.0F; @@ -1016,9 +1032,9 @@ execute_program( GLcontext *ctx, case FP_OPCODE_X2D: /* 2-D matrix transform */ { GLfloat a[4], b[4], c[4], result[4]; - fetch_vector4( &inst->SrcReg[0], machine, a ); - fetch_vector4( &inst->SrcReg[1], machine, b ); - fetch_vector4( &inst->SrcReg[2], machine, c ); + fetch_vector4( &inst->SrcReg[0], machine, program, a ); + fetch_vector4( &inst->SrcReg[1], machine, program, b ); + fetch_vector4( &inst->SrcReg[2], machine, program, c ); result[0] = a[0] + b[0] * c[0] + b[1] * c[1]; result[1] = a[1] + b[0] * c[2] + b[1] * c[3]; result[2] = a[2] + b[0] * c[0] + b[1] * c[1]; -- 2.7.4