Merge branch 'glsl-compiler-1' of git+ssh://brianp@git.freedesktop.org/git/mesa/mesa into glsl-compiler-1

This commit is contained in:
Brian 2007-02-26 13:11:20 -07:00
commit 25ea5ea27e
12 changed files with 230 additions and 214 deletions

View file

@ -14,7 +14,11 @@ uniform vec4 BallCenter; // ball center in modelling coordinates
void main()
{
ECposition = gl_ModelViewMatrix * gl_Vertex;
//orig: ECposition = gl_ModelViewMatrix * gl_Vertex;
ECposition = gl_TextureMatrix[0] * gl_Vertex;
ECposition = gl_ModelViewMatrix * ECposition;
ECballCenter = gl_ModelViewMatrix * BallCenter;
gl_Position = ftransform();
}

View file

@ -17,6 +17,7 @@
static const char *VertShaderText =
"void main() {\n"
" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
" gl_TexCoord[0] = gl_MultiTexCoord0;\n"
"}\n";
static const char *FragShaderText =

View file

@ -51,10 +51,21 @@ static struct uniform_info Uniforms[] = {
};
static GLint win = 0;
static GLboolean Anim = GL_FALSE;
static GLfloat TexRot = 0.0;
static GLfloat xRot = 0.0f, yRot = 0.0f, zRot = 0.0f;
static void
Idle(void)
{
TexRot += 2.0;
if (TexRot > 360.0)
TexRot -= 360.0;
glutPostRedisplay();
}
static void
Redisplay(void)
{
@ -65,6 +76,11 @@ Redisplay(void)
glRotatef(yRot, 0.0f, 1.0f, 0.0f);
glRotatef(zRot, 0.0f, 0.0f, 1.0f);
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glRotatef(TexRot, 0.0f, 1.0f, 0.0f);
glMatrixMode(GL_MODELVIEW);
glutSolidSphere(2.0, 20, 10);
glPopMatrix();
@ -106,6 +122,13 @@ Key(unsigned char key, int x, int y)
(void) y;
switch(key) {
case 'a':
Anim = !Anim;
if (Anim)
glutIdleFunc(Idle);
else
glutIdleFunc(NULL);
break;
case 'z':
zRot += step;
break;

View file

@ -129,7 +129,7 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
driver->NewProgram = _mesa_new_program;
driver->DeleteProgram = _mesa_delete_program;
#if FEATURE_MESA_program_debug
driver->GetFragmentProgramRegister = _mesa_get_program_register;
driver->GetProgramRegister = _mesa_get_program_register;
#endif /* FEATURE_MESA_program_debug */
/* simple state commands */

View file

@ -201,6 +201,7 @@
#define MAX_PROGRAM_MATRIX_STACK_DEPTH 4
#define MAX_PROGRAM_CALL_DEPTH 8
#define MAX_PROGRAM_TEMPS 128
#define MAX_PROGRAM_ADDRESS_REGS 2
#define MAX_UNIFORMS 128
#define MAX_VARYING 8
/*@}*/

View file

@ -570,9 +570,9 @@ struct dd_function_table {
/** Notify driver that a program string has been specified. */
void (*ProgramStringNotify)(GLcontext *ctx, GLenum target,
struct gl_program *prog);
/** Get value of a fragment program register during program execution. */
void (*GetFragmentProgramRegister)(GLcontext *ctx, enum register_file file,
GLuint index, GLfloat val[4]);
/** Get value of a program register during program execution. */
void (*GetProgramRegister)(GLcontext *ctx, enum register_file file,
GLuint index, GLfloat val[4]);
/** Query if program can be loaded onto hardware */
GLboolean (*IsProgramNative)(GLcontext *ctx, GLenum target,

View file

@ -141,9 +141,7 @@ _mesa_GetProgramRegisterfvMESA(GLenum target,
"glGetProgramRegisterfvMESA(registerName)");
return;
}
#if 0 /* FIX ME */
ctx->Driver.GetVertexProgramRegister(ctx, PROGRAM_TEMPORARY, i, v);
#endif
ctx->Driver.GetProgramRegister(ctx, PROGRAM_TEMPORARY, i, v);
}
else if (reg[0] == 'v' && reg[1] == '[') {
/* Vertex Input attribute */
@ -154,10 +152,7 @@ _mesa_GetProgramRegisterfvMESA(GLenum target,
_mesa_sprintf(number, "%d", i);
if (_mesa_strncmp(reg + 2, name, 4) == 0 ||
_mesa_strncmp(reg + 2, number, _mesa_strlen(number)) == 0) {
#if 0 /* FIX ME */
ctx->Driver.GetVertexProgramRegister(ctx, PROGRAM_INPUT,
i, v);
#endif
ctx->Driver.GetProgramRegister(ctx, PROGRAM_INPUT, i, v);
return;
}
}
@ -210,7 +205,7 @@ _mesa_GetProgramRegisterfvMESA(GLenum target,
"glGetProgramRegisterfvMESA(registerName)");
return;
}
ctx->Driver.GetFragmentProgramRegister(ctx, PROGRAM_TEMPORARY,
ctx->Driver.GetProgramRegister(ctx, PROGRAM_TEMPORARY,
i, v);
}
else if (reg[0] == 'f' && reg[1] == '[') {
@ -219,8 +214,7 @@ _mesa_GetProgramRegisterfvMESA(GLenum target,
for (i = 0; i < ctx->Const.FragmentProgram.MaxAttribs; i++) {
const char *name = _mesa_nv_fragment_input_register_name(i);
if (_mesa_strncmp(reg + 2, name, 4) == 0) {
ctx->Driver.GetFragmentProgramRegister(ctx,
PROGRAM_INPUT, i, v);
ctx->Driver.GetProgramRegister(ctx, PROGRAM_INPUT, i, v);
return;
}
}
@ -230,18 +224,18 @@ _mesa_GetProgramRegisterfvMESA(GLenum target,
}
else if (_mesa_strcmp(reg, "o[COLR]") == 0) {
/* Fragment output color */
ctx->Driver.GetFragmentProgramRegister(ctx, PROGRAM_OUTPUT,
FRAG_RESULT_COLR, v);
ctx->Driver.GetProgramRegister(ctx, PROGRAM_OUTPUT,
FRAG_RESULT_COLR, v);
}
else if (_mesa_strcmp(reg, "o[COLH]") == 0) {
/* Fragment output color */
ctx->Driver.GetFragmentProgramRegister(ctx, PROGRAM_OUTPUT,
FRAG_RESULT_COLH, v);
ctx->Driver.GetProgramRegister(ctx, PROGRAM_OUTPUT,
FRAG_RESULT_COLH, v);
}
else if (_mesa_strcmp(reg, "o[DEPR]") == 0) {
/* Fragment output depth */
ctx->Driver.GetFragmentProgramRegister(ctx, PROGRAM_OUTPUT,
FRAG_RESULT_DEPR, v);
ctx->Driver.GetProgramRegister(ctx, PROGRAM_OUTPUT,
FRAG_RESULT_DEPR, v);
}
else {
/* try user-defined identifiers */

View file

@ -74,66 +74,30 @@ static const GLfloat ZeroVec[4] = { 0.0F, 0.0F, 0.0F, 0.0F };
#if FEATURE_MESA_program_debug
static struct gl_program_machine *CurrentMachine = NULL;
/**
* For GL_MESA_program_debug.
* Return current value (4*GLfloat) of a program register.
* Called via ctx->Driver.GetFragmentProgramRegister().
*/
void
_mesa_get_program_register(GLcontext *ctx, enum register_file file,
GLuint index, GLfloat val[4])
{
if (CurrentMachine) {
switch (file) {
case PROGRAM_INPUT:
if (CurrentMachine->CurProgram->Target == GL_VERTEX_PROGRAM_ARB) {
COPY_4V(val, CurrentMachine->VertAttribs[index]);
}
else {
COPY_4V(val,
CurrentMachine->Attribs[index][CurrentMachine->CurElement]);
}
break;
case PROGRAM_OUTPUT:
COPY_4V(val, CurrentMachine->Outputs[index]);
break;
case PROGRAM_TEMPORARY:
COPY_4V(val, CurrentMachine->Temporaries[index]);
break;
default:
_mesa_problem(NULL,
"bad register file in _swrast_get_program_register");
}
}
}
#endif /* FEATURE_MESA_program_debug */
/**
* Return a pointer to the 4-element float vector specified by the given
* source register.
*/
static INLINE const GLfloat *
get_register_pointer(GLcontext * ctx,
const struct prog_src_register *source,
get_register_pointer(const struct prog_src_register *source,
const struct gl_program_machine *machine)
{
if (source->RelAddr) {
const GLint reg = source->Index + machine->AddressReg[0][0];
ASSERT( (source->File == PROGRAM_ENV_PARAM) ||
(source->File == PROGRAM_STATE_VAR) );
if (reg < 0 || reg > MAX_NV_VERTEX_PROGRAM_PARAMS)
return ZeroVec;
else if (source->File == PROGRAM_ENV_PARAM)
return ctx->VertexProgram.Parameters[reg];
if (source->File == PROGRAM_ENV_PARAM)
if (reg < 0 || reg >= MAX_PROGRAM_ENV_PARAMS)
return ZeroVec;
else
return machine->EnvParams[reg];
else {
const struct gl_program_parameter_list *params;
ASSERT(source->File == PROGRAM_LOCAL_PARAM ||
source->File == PROGRAM_STATE_VAR);
return machine->CurProgram->Parameters->ParameterValues[reg];
params = machine->CurProgram->Parameters;
if (reg < 0 || reg >= params->NumParameters)
return ZeroVec;
else
return params->ParameterValues[reg];
}
}
@ -162,10 +126,7 @@ get_register_pointer(GLcontext * ctx,
case PROGRAM_ENV_PARAM:
ASSERT(source->Index < MAX_PROGRAM_ENV_PARAMS);
if (machine->CurProgram->Target == GL_VERTEX_PROGRAM_ARB)
return ctx->VertexProgram.Parameters[source->Index];
else
return ctx->FragmentProgram.Parameters[source->Index];
return machine->EnvParams[source->Index];
case PROGRAM_STATE_VAR:
/* Fallthrough */
@ -179,7 +140,7 @@ get_register_pointer(GLcontext * ctx,
return machine->CurProgram->Parameters->ParameterValues[source->Index];
default:
_mesa_problem(ctx,
_mesa_problem(NULL,
"Invalid input register file %d in get_register_pointer()",
source->File);
return NULL;
@ -187,16 +148,39 @@ get_register_pointer(GLcontext * ctx,
}
#if FEATURE_MESA_program_debug
static struct gl_program_machine *CurrentMachine = NULL;
/**
* For GL_MESA_program_debug.
* Return current value (4*GLfloat) of a program register.
* Called via ctx->Driver.GetProgramRegister().
*/
void
_mesa_get_program_register(GLcontext *ctx, enum register_file file,
GLuint index, GLfloat val[4])
{
if (CurrentMachine) {
struct prog_src_register src;
const GLfloat *reg;
src.File = file;
src.Index = index;
reg = get_register_pointer(&src, CurrentMachine);
COPY_4V(val, reg);
}
}
#endif /* FEATURE_MESA_program_debug */
/**
* Fetch a 4-element float vector from the given source register.
* Apply swizzling and negating as needed.
*/
static void
fetch_vector4(GLcontext * ctx,
const struct prog_src_register *source,
fetch_vector4(const struct prog_src_register *source,
const struct gl_program_machine *machine, GLfloat result[4])
{
const GLfloat *src = get_register_pointer(ctx, source, machine);
const GLfloat *src = get_register_pointer(source, machine);
ASSERT(src);
if (source->Swizzle == SWIZZLE_NOOP) {
@ -354,11 +338,10 @@ fetch_vector4_deriv(GLcontext * ctx,
* As above, but only return result[0] element.
*/
static void
fetch_vector1(GLcontext * ctx,
const struct prog_src_register *source,
fetch_vector1(const struct prog_src_register *source,
const struct gl_program_machine *machine, GLfloat result[4])
{
const GLfloat *src = get_register_pointer(ctx, source, machine);
const GLfloat *src = get_register_pointer(source, machine);
ASSERT(src);
result[0] = src[GET_SWZ(source->Swizzle, 0)];
@ -632,19 +615,19 @@ init_machine_deriv(GLcontext * ctx,
/**
* Execute the given vertex/fragment program.
*
* \param ctx - rendering context
* \param program - the fragment program to execute
* \param machine - machine state (register file)
* \param maxInst - max number of instructions to execute
* \param ctx rendering context
* \param program the program to execute
* \param machine machine state (must be initialized)
* \return GL_TRUE if program completed or GL_FALSE if program executed KIL.
*/
GLboolean
_mesa_execute_program(GLcontext * ctx,
const struct gl_program *program, GLuint maxInst,
struct gl_program_machine *machine, GLuint element)
const struct gl_program *program,
struct gl_program_machine *machine)
{
const GLuint MAX_EXEC = 10000;
GLint pc, total = 0;
const GLuint numInst = program->NumInstructions;
const GLuint maxExec = 10000;
GLint pc, numExec = 0;
machine->CurProgram = program;
@ -656,7 +639,14 @@ _mesa_execute_program(GLcontext * ctx,
CurrentMachine = machine;
#endif
for (pc = 0; pc < maxInst; pc++) {
if (program->Target == GL_VERTEX_PROGRAM_ARB) {
machine->EnvParams = ctx->VertexProgram.Parameters;
}
else {
machine->EnvParams = ctx->FragmentProgram.Parameters;
}
for (pc = 0; pc < numInst; pc++) {
const struct prog_instruction *inst = program->Instructions + pc;
#if FEATURE_MESA_program_debug
@ -676,7 +666,7 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_ABS:
{
GLfloat a[4], result[4];
fetch_vector4(ctx, &inst->SrcReg[0], machine, a);
fetch_vector4(&inst->SrcReg[0], machine, a);
result[0] = FABSF(a[0]);
result[1] = FABSF(a[1]);
result[2] = FABSF(a[2]);
@ -687,8 +677,8 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_ADD:
{
GLfloat a[4], b[4], result[4];
fetch_vector4(ctx, &inst->SrcReg[0], machine, a);
fetch_vector4(ctx, &inst->SrcReg[1], machine, b);
fetch_vector4(&inst->SrcReg[0], machine, a);
fetch_vector4(&inst->SrcReg[1], machine, b);
result[0] = a[0] + b[0];
result[1] = a[1] + b[1];
result[2] = a[2] + b[2];
@ -704,7 +694,7 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_ARL:
{
GLfloat t[4];
fetch_vector4(ctx, &inst->SrcReg[0], machine, t);
fetch_vector4(&inst->SrcReg[0], machine, t);
machine->AddressReg[0][0] = (GLint) FLOORF(t[0]);
}
break;
@ -743,9 +733,9 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_CMP:
{
GLfloat a[4], b[4], c[4], result[4];
fetch_vector4(ctx, &inst->SrcReg[0], machine, a);
fetch_vector4(ctx, &inst->SrcReg[1], machine, b);
fetch_vector4(ctx, &inst->SrcReg[2], machine, c);
fetch_vector4(&inst->SrcReg[0], machine, a);
fetch_vector4(&inst->SrcReg[1], machine, b);
fetch_vector4(&inst->SrcReg[2], machine, c);
result[0] = a[0] < 0.0F ? b[0] : c[0];
result[1] = a[1] < 0.0F ? b[1] : c[1];
result[2] = a[2] < 0.0F ? b[2] : c[2];
@ -756,7 +746,7 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_COS:
{
GLfloat a[4], result[4];
fetch_vector1(ctx, &inst->SrcReg[0], machine, a);
fetch_vector1(&inst->SrcReg[0], machine, a);
result[0] = result[1] = result[2] = result[3]
= (GLfloat) _mesa_cos(a[0]);
store_vector4(inst, machine, result);
@ -776,11 +766,11 @@ _mesa_execute_program(GLcontext * ctx,
* Finally, find the difference in the register values for
* the original and derivative runs.
*/
fetch_vector4(ctx, &inst->SrcReg[0], machine, program, a);
fetch_vector4(&inst->SrcReg[0], machine, program, a);
init_machine_deriv(ctx, machine, program, span,
'X', &dMachine);
execute_program(ctx, program, pc, &dMachine, span, column);
fetch_vector4(ctx, &inst->SrcReg[0], &dMachine, program,
fetch_vector4(&inst->SrcReg[0], &dMachine, program,
aNext);
result[0] = aNext[0] - a[0];
result[1] = aNext[1] - a[1];
@ -802,9 +792,9 @@ _mesa_execute_program(GLcontext * ctx,
column, result)) {
init_machine_deriv(ctx, machine, program, span,
'Y', &dMachine);
fetch_vector4(ctx, &inst->SrcReg[0], machine, program, a);
fetch_vector4(&inst->SrcReg[0], machine, program, a);
execute_program(ctx, program, pc, &dMachine, span, column);
fetch_vector4(ctx, &inst->SrcReg[0], &dMachine, program,
fetch_vector4(&inst->SrcReg[0], &dMachine, program,
aNext);
result[0] = aNext[0] - a[0];
result[1] = aNext[1] - a[1];
@ -820,8 +810,8 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_DP3:
{
GLfloat a[4], b[4], result[4];
fetch_vector4(ctx, &inst->SrcReg[0], machine, a);
fetch_vector4(ctx, &inst->SrcReg[1], machine, b);
fetch_vector4(&inst->SrcReg[0], machine, a);
fetch_vector4(&inst->SrcReg[1], machine, b);
result[0] = result[1] = result[2] = result[3] = DOT3(a, b);
store_vector4(inst, machine, result);
if (DEBUG_PROG) {
@ -833,8 +823,8 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_DP4:
{
GLfloat a[4], b[4], result[4];
fetch_vector4(ctx, &inst->SrcReg[0], machine, a);
fetch_vector4(ctx, &inst->SrcReg[1], machine, b);
fetch_vector4(&inst->SrcReg[0], machine, a);
fetch_vector4(&inst->SrcReg[1], machine, b);
result[0] = result[1] = result[2] = result[3] = DOT4(a, b);
store_vector4(inst, machine, result);
if (DEBUG_PROG) {
@ -847,8 +837,8 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_DPH:
{
GLfloat a[4], b[4], result[4];
fetch_vector4(ctx, &inst->SrcReg[0], machine, a);
fetch_vector4(ctx, &inst->SrcReg[1], machine, b);
fetch_vector4(&inst->SrcReg[0], machine, a);
fetch_vector4(&inst->SrcReg[1], machine, b);
result[0] = result[1] = result[2] = result[3] =
a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + b[3];
store_vector4(inst, machine, result);
@ -857,8 +847,8 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_DST: /* Distance vector */
{
GLfloat a[4], b[4], result[4];
fetch_vector4(ctx, &inst->SrcReg[0], machine, a);
fetch_vector4(ctx, &inst->SrcReg[1], machine, b);
fetch_vector4(&inst->SrcReg[0], machine, a);
fetch_vector4(&inst->SrcReg[1], machine, b);
result[0] = 1.0F;
result[1] = a[1] * b[1];
result[2] = a[2];
@ -869,7 +859,7 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_EXP:
{
GLfloat t[4], q[4], floor_t0;
fetch_vector1(ctx, &inst->SrcReg[0], machine, t);
fetch_vector1(&inst->SrcReg[0], machine, t);
floor_t0 = FLOORF(t[0]);
if (floor_t0 > FLT_MAX_EXP) {
SET_POS_INFINITY(q[0]);
@ -895,7 +885,7 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_EX2: /* Exponential base 2 */
{
GLfloat a[4], result[4];
fetch_vector1(ctx, &inst->SrcReg[0], machine, a);
fetch_vector1(&inst->SrcReg[0], machine, a);
result[0] = result[1] = result[2] = result[3] =
(GLfloat) _mesa_pow(2.0, a[0]);
store_vector4(inst, machine, result);
@ -904,7 +894,7 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_FLR:
{
GLfloat a[4], result[4];
fetch_vector4(ctx, &inst->SrcReg[0], machine, a);
fetch_vector4(&inst->SrcReg[0], machine, a);
result[0] = FLOORF(a[0]);
result[1] = FLOORF(a[1]);
result[2] = FLOORF(a[2]);
@ -915,7 +905,7 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_FRC:
{
GLfloat a[4], result[4];
fetch_vector4(ctx, &inst->SrcReg[0], machine, a);
fetch_vector4(&inst->SrcReg[0], machine, a);
result[0] = a[0] - FLOORF(a[0]);
result[1] = a[1] - FLOORF(a[1]);
result[2] = a[2] - FLOORF(a[2]);
@ -944,7 +934,7 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_INT: /* float to int */
{
GLfloat a[4], result[4];
fetch_vector4(ctx, &inst->SrcReg[0], machine, a);
fetch_vector4(&inst->SrcReg[0], machine, a);
result[0] = (GLfloat) (GLint) a[0];
result[1] = (GLfloat) (GLint) a[1];
result[2] = (GLfloat) (GLint) a[2];
@ -960,7 +950,7 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_KIL: /* ARB_f_p only */
{
GLfloat a[4];
fetch_vector4(ctx, &inst->SrcReg[0], machine, a);
fetch_vector4(&inst->SrcReg[0], machine, a);
if (a[0] < 0.0F || a[1] < 0.0F || a[2] < 0.0F || a[3] < 0.0F) {
return GL_FALSE;
}
@ -969,7 +959,7 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_LG2: /* log base 2 */
{
GLfloat a[4], result[4];
fetch_vector1(ctx, &inst->SrcReg[0], machine, a);
fetch_vector1(&inst->SrcReg[0], machine, a);
result[0] = result[1] = result[2] = result[3] = LOG2(a[0]);
store_vector4(inst, machine, result);
}
@ -978,7 +968,7 @@ _mesa_execute_program(GLcontext * ctx,
{
const GLfloat epsilon = 1.0F / 256.0F; /* from NV VP spec */
GLfloat a[4], result[4];
fetch_vector4(ctx, &inst->SrcReg[0], machine, a);
fetch_vector4(&inst->SrcReg[0], machine, a);
a[0] = MAX2(a[0], 0.0F);
a[1] = MAX2(a[1], 0.0F);
/* XXX ARB version clamps a[3], NV version doesn't */
@ -1007,7 +997,7 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_LOG:
{
GLfloat t[4], q[4], abs_t0;
fetch_vector1(ctx, &inst->SrcReg[0], machine, t);
fetch_vector1(&inst->SrcReg[0], machine, t);
abs_t0 = FABSF(t[0]);
if (abs_t0 != 0.0F) {
/* Since we really can't handle infinite values on VMS
@ -1044,9 +1034,9 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_LRP:
{
GLfloat a[4], b[4], c[4], result[4];
fetch_vector4(ctx, &inst->SrcReg[0], machine, a);
fetch_vector4(ctx, &inst->SrcReg[1], machine, b);
fetch_vector4(ctx, &inst->SrcReg[2], machine, c);
fetch_vector4(&inst->SrcReg[0], machine, a);
fetch_vector4(&inst->SrcReg[1], machine, b);
fetch_vector4(&inst->SrcReg[2], machine, 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];
@ -1064,9 +1054,9 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_MAD:
{
GLfloat a[4], b[4], c[4], result[4];
fetch_vector4(ctx, &inst->SrcReg[0], machine, a);
fetch_vector4(ctx, &inst->SrcReg[1], machine, b);
fetch_vector4(ctx, &inst->SrcReg[2], machine, c);
fetch_vector4(&inst->SrcReg[0], machine, a);
fetch_vector4(&inst->SrcReg[1], machine, b);
fetch_vector4(&inst->SrcReg[2], machine, 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];
@ -1084,8 +1074,8 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_MAX:
{
GLfloat a[4], b[4], result[4];
fetch_vector4(ctx, &inst->SrcReg[0], machine, a);
fetch_vector4(ctx, &inst->SrcReg[1], machine, b);
fetch_vector4(&inst->SrcReg[0], machine, a);
fetch_vector4(&inst->SrcReg[1], machine, b);
result[0] = MAX2(a[0], b[0]);
result[1] = MAX2(a[1], b[1]);
result[2] = MAX2(a[2], b[2]);
@ -1101,8 +1091,8 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_MIN:
{
GLfloat a[4], b[4], result[4];
fetch_vector4(ctx, &inst->SrcReg[0], machine, a);
fetch_vector4(ctx, &inst->SrcReg[1], machine, b);
fetch_vector4(&inst->SrcReg[0], machine, a);
fetch_vector4(&inst->SrcReg[1], machine, b);
result[0] = MIN2(a[0], b[0]);
result[1] = MIN2(a[1], b[1]);
result[2] = MIN2(a[2], b[2]);
@ -1113,7 +1103,7 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_MOV:
{
GLfloat result[4];
fetch_vector4(ctx, &inst->SrcReg[0], machine, result);
fetch_vector4(&inst->SrcReg[0], machine, result);
store_vector4(inst, machine, result);
if (DEBUG_PROG) {
printf("MOV (%g %g %g %g)\n",
@ -1124,8 +1114,8 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_MUL:
{
GLfloat a[4], b[4], result[4];
fetch_vector4(ctx, &inst->SrcReg[0], machine, a);
fetch_vector4(ctx, &inst->SrcReg[1], machine, b);
fetch_vector4(&inst->SrcReg[0], machine, a);
fetch_vector4(&inst->SrcReg[1], machine, b);
result[0] = a[0] * b[0];
result[1] = a[1] * b[1];
result[2] = a[2] * b[2];
@ -1141,7 +1131,7 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_NOISE1:
{
GLfloat a[4], result[4];
fetch_vector1(ctx, &inst->SrcReg[0], machine, a);
fetch_vector1(&inst->SrcReg[0], machine, a);
result[0] =
result[1] =
result[2] = result[3] = _slang_library_noise1(a[0]);
@ -1151,7 +1141,7 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_NOISE2:
{
GLfloat a[4], result[4];
fetch_vector4(ctx, &inst->SrcReg[0], machine, a);
fetch_vector4(&inst->SrcReg[0], machine, a);
result[0] =
result[1] =
result[2] = result[3] = _slang_library_noise2(a[0], a[1]);
@ -1161,7 +1151,7 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_NOISE3:
{
GLfloat a[4], result[4];
fetch_vector4(ctx, &inst->SrcReg[0], machine, a);
fetch_vector4(&inst->SrcReg[0], machine, a);
result[0] =
result[1] =
result[2] =
@ -1172,7 +1162,7 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_NOISE4:
{
GLfloat a[4], result[4];
fetch_vector4(ctx, &inst->SrcReg[0], machine, a);
fetch_vector4(&inst->SrcReg[0], machine, a);
result[0] =
result[1] =
result[2] =
@ -1188,7 +1178,7 @@ _mesa_execute_program(GLcontext * ctx,
GLhalfNV hx, hy;
GLuint *rawResult = (GLuint *) result;
GLuint twoHalves;
fetch_vector4(ctx, &inst->SrcReg[0], machine, a);
fetch_vector4(&inst->SrcReg[0], machine, a);
hx = _mesa_float_to_half(a[0]);
hy = _mesa_float_to_half(a[1]);
twoHalves = hx | (hy << 16);
@ -1201,7 +1191,7 @@ _mesa_execute_program(GLcontext * ctx,
{
GLfloat a[4], result[4];
GLuint usx, usy, *rawResult = (GLuint *) result;
fetch_vector4(ctx, &inst->SrcReg[0], machine, a);
fetch_vector4(&inst->SrcReg[0], machine, a);
a[0] = CLAMP(a[0], 0.0F, 1.0F);
a[1] = CLAMP(a[1], 0.0F, 1.0F);
usx = IROUND(a[0] * 65535.0F);
@ -1215,7 +1205,7 @@ _mesa_execute_program(GLcontext * ctx,
{
GLfloat a[4], result[4];
GLuint ubx, uby, ubz, ubw, *rawResult = (GLuint *) result;
fetch_vector4(ctx, &inst->SrcReg[0], machine, a);
fetch_vector4(&inst->SrcReg[0], machine, 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);
@ -1233,7 +1223,7 @@ _mesa_execute_program(GLcontext * ctx,
{
GLfloat a[4], result[4];
GLuint ubx, uby, ubz, ubw, *rawResult = (GLuint *) result;
fetch_vector4(ctx, &inst->SrcReg[0], machine, a);
fetch_vector4(&inst->SrcReg[0], machine, 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);
@ -1250,8 +1240,8 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_POW:
{
GLfloat a[4], b[4], result[4];
fetch_vector1(ctx, &inst->SrcReg[0], machine, a);
fetch_vector1(ctx, &inst->SrcReg[1], machine, b);
fetch_vector1(&inst->SrcReg[0], machine, a);
fetch_vector1(&inst->SrcReg[1], machine, b);
result[0] = result[1] = result[2] = result[3]
= (GLfloat) _mesa_pow(a[0], b[0]);
store_vector4(inst, machine, result);
@ -1260,7 +1250,7 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_RCP:
{
GLfloat a[4], result[4];
fetch_vector1(ctx, &inst->SrcReg[0], machine, a);
fetch_vector1(&inst->SrcReg[0], machine, a);
if (DEBUG_PROG) {
if (a[0] == 0)
printf("RCP(0)\n");
@ -1282,8 +1272,8 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_RFL: /* reflection vector */
{
GLfloat axis[4], dir[4], result[4], tmpX, tmpW;
fetch_vector4(ctx, &inst->SrcReg[0], machine, axis);
fetch_vector4(ctx, &inst->SrcReg[1], machine, dir);
fetch_vector4(&inst->SrcReg[0], machine, axis);
fetch_vector4(&inst->SrcReg[1], machine, dir);
tmpW = DOT3(axis, axis);
tmpX = (2.0F * DOT3(axis, dir)) / tmpW;
result[0] = tmpX * axis[0] - dir[0];
@ -1296,7 +1286,7 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_RSQ: /* 1 / sqrt() */
{
GLfloat a[4], result[4];
fetch_vector1(ctx, &inst->SrcReg[0], machine, a);
fetch_vector1(&inst->SrcReg[0], machine, a);
a[0] = FABSF(a[0]);
result[0] = result[1] = result[2] = result[3] = INV_SQRTF(a[0]);
store_vector4(inst, machine, result);
@ -1308,7 +1298,7 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_SCS: /* sine and cos */
{
GLfloat a[4], result[4];
fetch_vector1(ctx, &inst->SrcReg[0], machine, a);
fetch_vector1(&inst->SrcReg[0], machine, a);
result[0] = (GLfloat) _mesa_cos(a[0]);
result[1] = (GLfloat) _mesa_sin(a[0]);
result[2] = 0.0; /* undefined! */
@ -1319,8 +1309,8 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_SEQ: /* set on equal */
{
GLfloat a[4], b[4], result[4];
fetch_vector4(ctx, &inst->SrcReg[0], machine, a);
fetch_vector4(ctx, &inst->SrcReg[1], machine, b);
fetch_vector4(&inst->SrcReg[0], machine, a);
fetch_vector4(&inst->SrcReg[1], machine, 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;
@ -1337,8 +1327,8 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_SGE: /* set on greater or equal */
{
GLfloat a[4], b[4], result[4];
fetch_vector4(ctx, &inst->SrcReg[0], machine, a);
fetch_vector4(ctx, &inst->SrcReg[1], machine, b);
fetch_vector4(&inst->SrcReg[0], machine, a);
fetch_vector4(&inst->SrcReg[1], machine, 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;
@ -1349,8 +1339,8 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_SGT: /* set on greater */
{
GLfloat a[4], b[4], result[4];
fetch_vector4(ctx, &inst->SrcReg[0], machine, a);
fetch_vector4(ctx, &inst->SrcReg[1], machine, b);
fetch_vector4(&inst->SrcReg[0], machine, a);
fetch_vector4(&inst->SrcReg[1], machine, 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;
@ -1365,7 +1355,7 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_SIN:
{
GLfloat a[4], result[4];
fetch_vector1(ctx, &inst->SrcReg[0], machine, a);
fetch_vector1(&inst->SrcReg[0], machine, a);
result[0] = result[1] = result[2] = result[3]
= (GLfloat) _mesa_sin(a[0]);
store_vector4(inst, machine, result);
@ -1374,8 +1364,8 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_SLE: /* set on less or equal */
{
GLfloat a[4], b[4], result[4];
fetch_vector4(ctx, &inst->SrcReg[0], machine, a);
fetch_vector4(ctx, &inst->SrcReg[1], machine, b);
fetch_vector4(&inst->SrcReg[0], machine, a);
fetch_vector4(&inst->SrcReg[1], machine, 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;
@ -1386,8 +1376,8 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_SLT: /* set on less */
{
GLfloat a[4], b[4], result[4];
fetch_vector4(ctx, &inst->SrcReg[0], machine, a);
fetch_vector4(ctx, &inst->SrcReg[1], machine, b);
fetch_vector4(&inst->SrcReg[0], machine, a);
fetch_vector4(&inst->SrcReg[1], machine, 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;
@ -1398,8 +1388,8 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_SNE: /* set on not equal */
{
GLfloat a[4], b[4], result[4];
fetch_vector4(ctx, &inst->SrcReg[0], machine, a);
fetch_vector4(ctx, &inst->SrcReg[1], machine, b);
fetch_vector4(&inst->SrcReg[0], machine, a);
fetch_vector4(&inst->SrcReg[1], machine, 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;
@ -1416,8 +1406,8 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_SUB:
{
GLfloat a[4], b[4], result[4];
fetch_vector4(ctx, &inst->SrcReg[0], machine, a);
fetch_vector4(ctx, &inst->SrcReg[1], machine, b);
fetch_vector4(&inst->SrcReg[0], machine, a);
fetch_vector4(&inst->SrcReg[1], machine, b);
result[0] = a[0] - b[0];
result[1] = a[1] - b[1];
result[2] = a[2] - b[2];
@ -1433,7 +1423,7 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_SWZ: /* extended swizzle */
{
const struct prog_src_register *source = &inst->SrcReg[0];
const GLfloat *src = get_register_pointer(ctx, source, machine);
const GLfloat *src = get_register_pointer(source, machine);
GLfloat result[4];
GLuint i;
for (i = 0; i < 4; i++) {
@ -1472,7 +1462,7 @@ _mesa_execute_program(GLcontext * ctx,
else
#endif
lambda = 0.0;
fetch_vector4(ctx, &inst->SrcReg[0], machine, coord);
fetch_vector4(&inst->SrcReg[0], machine, coord);
machine->FetchTexelLod(ctx, coord, lambda, inst->TexSrcUnit,
color);
if (DEBUG_PROG) {
@ -1498,7 +1488,7 @@ _mesa_execute_program(GLcontext * ctx,
else
#endif
lambda = 0.0;
fetch_vector4(ctx, &inst->SrcReg[0], machine, coord);
fetch_vector4(&inst->SrcReg[0], machine, coord);
/* coord[3] is the bias to add to lambda */
bias = texUnit->LodBias + coord[3];
if (texUnit->_Current)
@ -1512,9 +1502,9 @@ _mesa_execute_program(GLcontext * ctx,
/* Texture lookup w/ partial derivatives for LOD */
{
GLfloat texcoord[4], dtdx[4], dtdy[4], color[4];
fetch_vector4(ctx, &inst->SrcReg[0], machine, texcoord);
fetch_vector4(ctx, &inst->SrcReg[1], machine, dtdx);
fetch_vector4(ctx, &inst->SrcReg[2], machine, dtdy);
fetch_vector4(&inst->SrcReg[0], machine, texcoord);
fetch_vector4(&inst->SrcReg[1], machine, dtdx);
fetch_vector4(&inst->SrcReg[2], machine, dtdy);
machine->FetchTexelDeriv(ctx, texcoord, dtdx, dtdy,
inst->TexSrcUnit, color);
store_vector4(inst, machine, color);
@ -1531,7 +1521,7 @@ _mesa_execute_program(GLcontext * ctx,
else
#endif
lambda = 0.0;
fetch_vector4(ctx, &inst->SrcReg[0], machine, texcoord);
fetch_vector4(&inst->SrcReg[0], machine, texcoord);
/* Not so sure about this test - if texcoord[3] is
* zero, we'd probably be fine except for an ASSERT in
* IROUND_POS() which gets triggered by the inf values created.
@ -1557,7 +1547,7 @@ _mesa_execute_program(GLcontext * ctx,
else
#endif
lambda = 0.0;
fetch_vector4(ctx, &inst->SrcReg[0], machine, texcoord);
fetch_vector4(&inst->SrcReg[0], machine, texcoord);
if (inst->TexSrcTarget != TEXTURE_CUBE_INDEX &&
texcoord[3] != 0.0) {
texcoord[0] /= texcoord[3];
@ -1574,7 +1564,7 @@ _mesa_execute_program(GLcontext * ctx,
GLfloat a[4], result[4];
const GLuint *rawBits = (const GLuint *) a;
GLhalfNV hx, hy;
fetch_vector1(ctx, &inst->SrcReg[0], machine, a);
fetch_vector1(&inst->SrcReg[0], machine, a);
hx = rawBits[0] & 0xffff;
hy = rawBits[0] >> 16;
result[0] = result[2] = _mesa_half_to_float(hx);
@ -1587,7 +1577,7 @@ _mesa_execute_program(GLcontext * ctx,
GLfloat a[4], result[4];
const GLuint *rawBits = (const GLuint *) a;
GLushort usx, usy;
fetch_vector1(ctx, &inst->SrcReg[0], machine, a);
fetch_vector1(&inst->SrcReg[0], machine, a);
usx = rawBits[0] & 0xffff;
usy = rawBits[0] >> 16;
result[0] = result[2] = usx * (1.0f / 65535.0f);
@ -1599,7 +1589,7 @@ _mesa_execute_program(GLcontext * ctx,
{
GLfloat a[4], result[4];
const GLuint *rawBits = (const GLuint *) a;
fetch_vector1(ctx, &inst->SrcReg[0], machine, a);
fetch_vector1(&inst->SrcReg[0], machine, a);
result[0] = (((rawBits[0] >> 0) & 0xff) - 128) / 127.0F;
result[1] = (((rawBits[0] >> 8) & 0xff) - 128) / 127.0F;
result[2] = (((rawBits[0] >> 16) & 0xff) - 128) / 127.0F;
@ -1611,7 +1601,7 @@ _mesa_execute_program(GLcontext * ctx,
{
GLfloat a[4], result[4];
const GLuint *rawBits = (const GLuint *) a;
fetch_vector1(ctx, &inst->SrcReg[0], machine, a);
fetch_vector1(&inst->SrcReg[0], machine, a);
result[0] = ((rawBits[0] >> 0) & 0xff) / 255.0F;
result[1] = ((rawBits[0] >> 8) & 0xff) / 255.0F;
result[2] = ((rawBits[0] >> 16) & 0xff) / 255.0F;
@ -1622,8 +1612,8 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_XPD: /* cross product */
{
GLfloat a[4], b[4], result[4];
fetch_vector4(ctx, &inst->SrcReg[0], machine, a);
fetch_vector4(ctx, &inst->SrcReg[1], machine, b);
fetch_vector4(&inst->SrcReg[0], machine, a);
fetch_vector4(&inst->SrcReg[1], machine, b);
result[0] = a[1] * b[2] - a[2] * b[1];
result[1] = a[2] * b[0] - a[0] * b[2];
result[2] = a[0] * b[1] - a[1] * b[0];
@ -1634,9 +1624,9 @@ _mesa_execute_program(GLcontext * ctx,
case OPCODE_X2D: /* 2-D matrix transform */
{
GLfloat a[4], b[4], c[4], result[4];
fetch_vector4(ctx, &inst->SrcReg[0], machine, a);
fetch_vector4(ctx, &inst->SrcReg[1], machine, b);
fetch_vector4(ctx, &inst->SrcReg[2], machine, c);
fetch_vector4(&inst->SrcReg[0], machine, a);
fetch_vector4(&inst->SrcReg[1], machine, b);
fetch_vector4(&inst->SrcReg[2], machine, 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];
@ -1648,7 +1638,7 @@ _mesa_execute_program(GLcontext * ctx,
{
if (inst->SrcReg[0].File != -1) {
GLfloat a[4];
fetch_vector4(ctx, &inst->SrcReg[0], machine, a);
fetch_vector4(&inst->SrcReg[0], machine, a);
_mesa_printf("%s%g, %g, %g, %g\n", (const char *) inst->Data,
a[0], a[1], a[2], a[3]);
}
@ -1666,11 +1656,10 @@ _mesa_execute_program(GLcontext * ctx,
}
total++;
if (total > MAX_EXEC) {
numExec++;
if (numExec > maxExec) {
_mesa_problem(ctx, "Infinite loop detected in fragment program");
return GL_TRUE;
abort();
}
} /* for pc */

View file

@ -55,9 +55,9 @@ struct gl_program_machine
GLfloat Temporaries[MAX_PROGRAM_TEMPS][4];
GLfloat Outputs[MAX_PROGRAM_OUTPUTS][4];
GLfloat (*EnvParams)[4]; /**< Vertex or Fragment env parameters */
GLuint CondCodes[4]; /**< COND_* value for x/y/z/w */
GLint AddressReg[MAX_VERTEX_PROGRAM_ADDRESS_REGS][4];
GLint AddressReg[MAX_PROGRAM_ADDRESS_REGS][4];
GLuint CallStack[MAX_PROGRAM_CALL_DEPTH]; /**< For CAL/RET instructions */
GLuint StackDepth; /**< Index/ptr to top of CallStack[] */
@ -74,8 +74,8 @@ _mesa_get_program_register(GLcontext *ctx, enum register_file file,
extern GLboolean
_mesa_execute_program(GLcontext *ctx,
const struct gl_program *program, GLuint maxInst,
struct gl_program_machine *machine, GLuint element);
const struct gl_program *program,
struct gl_program_machine *machine);
#endif /* PROG_EXECUTE_H */

View file

@ -147,9 +147,7 @@ run_program(GLcontext *ctx, SWspan *span, GLuint start, GLuint end)
if (span->array->mask[i]) {
init_machine(ctx, &machine, program, span, i);
if (_mesa_execute_program(ctx, &program->Base,
program->Base.NumInstructions,
&machine, i)) {
if (_mesa_execute_program(ctx, &program->Base, &machine)) {
/* Store result color */
COPY_4V(span->array->attribs[FRAG_ATTRIB_COL0][i],
machine.Outputs[FRAG_RESULT_COLR]);

View file

@ -217,7 +217,6 @@ struct vertex_buffer
GLvector4f *ColorPtr[2]; /* _TNL_BIT_COLOR0 */
GLvector4f *SecondaryColorPtr[2]; /* _TNL_BIT_COLOR1 */
GLvector4f *FogCoordPtr; /* _TNL_BIT_FOG */
GLvector4f *VaryingPtr[MAX_VARYING];
const struct _mesa_prim *Primitive;
GLuint PrimitiveCount;

View file

@ -49,7 +49,7 @@
*/
struct vp_stage_data {
/** The results of running the vertex program go into these arrays. */
GLvector4f attribs[VERT_RESULT_MAX];
GLvector4f results[VERT_RESULT_MAX];
GLvector4f ndcCoords; /**< normalized device coords */
GLubyte *clipmask; /**< clip flags */
@ -196,7 +196,8 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage )
struct vertex_buffer *VB = &tnl->vb;
struct gl_vertex_program *program = ctx->VertexProgram._Current;
struct gl_program_machine machine;
GLuint i;
GLuint outputs[VERT_RESULT_MAX], numOutputs;
GLuint i, j;
#define FORCE_PROG_EXECUTE_C 1
#if FORCE_PROG_EXECUTE_C
@ -214,6 +215,13 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage )
_mesa_load_state_parameters(ctx, program->Base.Parameters);
}
numOutputs = 0;
for (i = 0; i < VERT_RESULT_MAX; i++) {
if (program->Base.OutputsWritten & (1 << i)) {
outputs[numOutputs++] = i;
}
}
for (i = 0; i < VB->Count; i++) {
GLuint attr;
@ -244,13 +252,12 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage )
const GLuint size = VB->AttribPtr[attr]->size;
const GLuint stride = VB->AttribPtr[attr]->stride;
const GLfloat *data = (GLfloat *) (ptr + stride * i);
COPY_CLEAN_4V(machine.VertAttribs/*Inputs*/[attr], size, data);
COPY_CLEAN_4V(machine.VertAttribs[attr], size, data);
}
}
/* execute the program */
_mesa_execute_program(ctx, &program->Base, program->Base.NumInstructions,
&machine, 0);
_mesa_execute_program(ctx, &program->Base, &machine);
/* Fixup fog an point size results if needed */
if (ctx->Fog.Enabled &&
@ -264,9 +271,9 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage )
}
/* copy the output registers into the VB->attribs arrays */
/* XXX (optimize) could use a conditional and smaller loop limit here */
for (attr = 0; attr < VERT_RESULT_MAX; attr++) {
COPY_4V(store->attribs[attr].data[i], machine.Outputs[attr]);
for (j = 0; j < numOutputs; j++) {
const GLuint attr = outputs[j];
COPY_4V(store->results[attr].data[i], machine.Outputs[attr]);
}
#if 0
printf("HPOS: %f %f %f %f\n",
@ -280,31 +287,31 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage )
/* Setup the VB pointers so that the next pipeline stages get
* their data from the right place (the program output arrays).
*/
VB->ClipPtr = &store->attribs[VERT_RESULT_HPOS];
VB->ClipPtr = &store->results[VERT_RESULT_HPOS];
VB->ClipPtr->size = 4;
VB->ClipPtr->count = VB->Count;
VB->ColorPtr[0] = &store->attribs[VERT_RESULT_COL0];
VB->ColorPtr[1] = &store->attribs[VERT_RESULT_BFC0];
VB->SecondaryColorPtr[0] = &store->attribs[VERT_RESULT_COL1];
VB->SecondaryColorPtr[1] = &store->attribs[VERT_RESULT_BFC1];
VB->FogCoordPtr = &store->attribs[VERT_RESULT_FOGC];
VB->ColorPtr[0] = &store->results[VERT_RESULT_COL0];
VB->ColorPtr[1] = &store->results[VERT_RESULT_BFC0];
VB->SecondaryColorPtr[0] = &store->results[VERT_RESULT_COL1];
VB->SecondaryColorPtr[1] = &store->results[VERT_RESULT_BFC1];
VB->FogCoordPtr = &store->results[VERT_RESULT_FOGC];
VB->AttribPtr[VERT_ATTRIB_COLOR0] = &store->attribs[VERT_RESULT_COL0];
VB->AttribPtr[VERT_ATTRIB_COLOR1] = &store->attribs[VERT_RESULT_COL1];
VB->AttribPtr[VERT_ATTRIB_FOG] = &store->attribs[VERT_RESULT_FOGC];
VB->AttribPtr[_TNL_ATTRIB_POINTSIZE] = &store->attribs[VERT_RESULT_PSIZ];
VB->AttribPtr[VERT_ATTRIB_COLOR0] = &store->results[VERT_RESULT_COL0];
VB->AttribPtr[VERT_ATTRIB_COLOR1] = &store->results[VERT_RESULT_COL1];
VB->AttribPtr[VERT_ATTRIB_FOG] = &store->results[VERT_RESULT_FOGC];
VB->AttribPtr[_TNL_ATTRIB_POINTSIZE] = &store->results[VERT_RESULT_PSIZ];
for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
VB->TexCoordPtr[i] =
VB->AttribPtr[_TNL_ATTRIB_TEX0 + i]
= &store->attribs[VERT_RESULT_TEX0 + i];
= &store->results[VERT_RESULT_TEX0 + i];
}
for (i = 0; i < ctx->Const.MaxVarying; i++) {
if (program->Base.OutputsWritten & (1 << (VERT_RESULT_VAR0 + i))) {
/* Note: varying results get put into the generic attributes */
VB->AttribPtr[VERT_ATTRIB_GENERIC0+i]
= &store->attribs[VERT_RESULT_VAR0 + i];
= &store->results[VERT_RESULT_VAR0 + i];
}
}
@ -366,8 +373,8 @@ static GLboolean init_vp( GLcontext *ctx,
/* Allocate arrays of vertex output values */
for (i = 0; i < VERT_RESULT_MAX; i++) {
_mesa_vector4f_alloc( &store->attribs[i], 0, size, 32 );
store->attribs[i].size = 4;
_mesa_vector4f_alloc( &store->results[i], 0, size, 32 );
store->results[i].size = 4;
}
/* a few other misc allocations */
@ -390,7 +397,7 @@ static void dtr( struct tnl_pipeline_stage *stage )
/* free the vertex program result arrays */
for (i = 0; i < VERT_RESULT_MAX; i++)
_mesa_vector4f_free( &store->attribs[i] );
_mesa_vector4f_free( &store->results[i] );
/* free misc arrays */
_mesa_vector4f_free( &store->ndcCoords );