line->span.array->z[i] = (GLuint) solve_plane(fx, fy, line->zPlane);
#endif
#ifdef DO_FOG
- line->span.array->fog[i] = solve_plane(fx, fy, line->fPlane);
+ line->span.array->attribs[FRAG_ATTRIB_FOGC][i][0] = solve_plane(fx, fy, line->fPlane);
#endif
#ifdef DO_RGBA
line->span.array->rgba[i][RCOMP] = solve_plane_chan(fx, fy, line->rPlane);
else {
invQ = solve_plane_recip(fx, fy, line->vPlane[0]);
}
- line->span.array->texcoords[0][i][0] = solve_plane(fx, fy, line->sPlane[0]) * invQ;
- line->span.array->texcoords[0][i][1] = solve_plane(fx, fy, line->tPlane[0]) * invQ;
- line->span.array->texcoords[0][i][2] = solve_plane(fx, fy, line->uPlane[0]) * invQ;
+ line->span.array->attribs[FRAG_ATTRIB_TEX0][i][0] = solve_plane(fx, fy, line->sPlane[0]) * invQ;
+ line->span.array->attribs[FRAG_ATTRIB_TEX0][i][1] = solve_plane(fx, fy, line->tPlane[0]) * invQ;
+ line->span.array->attribs[FRAG_ATTRIB_TEX0][i][2] = solve_plane(fx, fy, line->uPlane[0]) * invQ;
line->span.array->lambda[0][i] = compute_lambda(line->sPlane[0],
line->tPlane[0], invQ,
line->texWidth[0],
else {
invQ = solve_plane_recip(fx, fy, line->vPlane[unit]);
}
- line->span.array->texcoords[unit][i][0] = solve_plane(fx, fy, line->sPlane[unit]) * invQ;
- line->span.array->texcoords[unit][i][1] = solve_plane(fx, fy, line->tPlane[unit]) * invQ;
- line->span.array->texcoords[unit][i][2] = solve_plane(fx, fy, line->uPlane[unit]) * invQ;
+ line->span.array->attribs[FRAG_ATTRIB_TEX0 + unit][i][0] = solve_plane(fx, fy, line->sPlane[unit]) * invQ;
+ line->span.array->attribs[FRAG_ATTRIB_TEX0 + unit][i][1] = solve_plane(fx, fy, line->tPlane[unit]) * invQ;
+ line->span.array->attribs[FRAG_ATTRIB_TEX0 + unit][i][2] = solve_plane(fx, fy, line->uPlane[unit]) * invQ;
line->span.array->lambda[unit][i] = compute_lambda(line->sPlane[unit],
line->tPlane[unit], invQ,
line->texWidth[unit], line->texHeight[unit]);
array->z[count] = (GLuint) solve_plane(cx, cy, zPlane);
#endif
#ifdef DO_FOG
- array->fog[count] = solve_plane(cx, cy, fogPlane);
+ array->attribs[FRAG_ATTRIB_FOGC][count][0] = solve_plane(cx, cy, fogPlane);
#endif
#ifdef DO_RGBA
array->rgba[count][RCOMP] = solve_plane_chan(cx, cy, rPlane);
#ifdef DO_TEX
{
const GLfloat invQ = solve_plane_recip(cx, cy, vPlane);
- array->texcoords[0][count][0] = solve_plane(cx, cy, sPlane) * invQ;
- array->texcoords[0][count][1] = solve_plane(cx, cy, tPlane) * invQ;
- array->texcoords[0][count][2] = solve_plane(cx, cy, uPlane) * invQ;
+ array->attribs[FRAG_ATTRIB_TEX0 + 0][count][0] = solve_plane(cx, cy, sPlane) * invQ;
+ array->attribs[FRAG_ATTRIB_TEX0 + 0][count][1] = solve_plane(cx, cy, tPlane) * invQ;
+ array->attribs[FRAG_ATTRIB_TEX0 + 0][count][2] = solve_plane(cx, cy, uPlane) * invQ;
array->lambda[0][count] = compute_lambda(sPlane, tPlane, vPlane,
cx, cy, invQ,
texWidth, texHeight);
for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
if (ctx->Texture.Unit[unit]._ReallyEnabled) {
GLfloat invQ = solve_plane_recip(cx, cy, vPlane[unit]);
- array->texcoords[unit][count][0] = solve_plane(cx, cy, sPlane[unit]) * invQ;
- array->texcoords[unit][count][1] = solve_plane(cx, cy, tPlane[unit]) * invQ;
- array->texcoords[unit][count][2] = solve_plane(cx, cy, uPlane[unit]) * invQ;
+ array->attribs[FRAG_ATTRIB_TEX0 + unit][count][0] = solve_plane(cx, cy, sPlane[unit]) * invQ;
+ array->attribs[FRAG_ATTRIB_TEX0 + unit][count][1] = solve_plane(cx, cy, tPlane[unit]) * invQ;
+ array->attribs[FRAG_ATTRIB_TEX0 + unit][count][2] = solve_plane(cx, cy, uPlane[unit]) * invQ;
array->lambda[unit][count] = compute_lambda(sPlane[unit],
tPlane[unit], vPlane[unit], cx, cy, invQ,
texWidth[unit], texHeight[unit]);
array->z[ix] = (GLuint) solve_plane(cx, cy, zPlane);
#endif
#ifdef DO_FOG
- array->fog[ix] = solve_plane(cx, cy, fogPlane);
+ array->attribs[FRAG_ATTRIB_FOGC][ix][0] = solve_plane(cx, cy, fogPlane);
#endif
#ifdef DO_RGBA
array->rgba[ix][RCOMP] = solve_plane_chan(cx, cy, rPlane);
#ifdef DO_TEX
{
const GLfloat invQ = solve_plane_recip(cx, cy, vPlane);
- array->texcoords[0][ix][0] = solve_plane(cx, cy, sPlane) * invQ;
- array->texcoords[0][ix][1] = solve_plane(cx, cy, tPlane) * invQ;
- array->texcoords[0][ix][2] = solve_plane(cx, cy, uPlane) * invQ;
+ array->attribs[FRAG_ATTRIB_TEX0][ix][0] = solve_plane(cx, cy, sPlane) * invQ;
+ array->attribs[FRAG_ATTRIB_TEX0][ix][1] = solve_plane(cx, cy, tPlane) * invQ;
+ array->attribs[FRAG_ATTRIB_TEX0][ix][2] = solve_plane(cx, cy, uPlane) * invQ;
array->lambda[0][ix] = compute_lambda(sPlane, tPlane, vPlane,
cx, cy, invQ, texWidth, texHeight);
}
for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
if (ctx->Texture.Unit[unit]._ReallyEnabled) {
GLfloat invQ = solve_plane_recip(cx, cy, vPlane[unit]);
- array->texcoords[unit][ix][0] = solve_plane(cx, cy, sPlane[unit]) * invQ;
- array->texcoords[unit][ix][1] = solve_plane(cx, cy, tPlane[unit]) * invQ;
- array->texcoords[unit][ix][2] = solve_plane(cx, cy, uPlane[unit]) * invQ;
+ array->attribs[FRAG_ATTRIB_TEX0 + unit][ix][0] = solve_plane(cx, cy, sPlane[unit]) * invQ;
+ array->attribs[FRAG_ATTRIB_TEX0 + unit][ix][1] = solve_plane(cx, cy, tPlane[unit]) * invQ;
+ array->attribs[FRAG_ATTRIB_TEX0 + unit][ix][2] = solve_plane(cx, cy, uPlane[unit]) * invQ;
array->lambda[unit][ix] = compute_lambda(sPlane[unit],
tPlane[unit],
vPlane[unit],
array->z[j] = array->z[j + left];
#endif
#ifdef DO_FOG
- array->fog[j] = array->fog[j + left];
+ array->attribs[FRAG_ATTRIB_FOGC][j][0]
+ = array->attribs[FRAG_ATTRIB_FOGC][j + left][0];
#endif
#ifdef DO_TEX
- COPY_4V(array->texcoords[0][j], array->texcoords[0][j + left]);
+ COPY_4V(array->attribs[FRAG_ATTRIB_TEX0 + 0][j], array->attribs[FRAG_ATTRIB_TEX0 + 0][j + left]);
#endif
#if defined(DO_MULTITEX) || defined(DO_TEX)
array->lambda[0][j] = array->lambda[0][j + left];
if (ctx->Texture.Unit[unit]._ReallyEnabled) {
GLint j;
for (j = 0; j < (GLint) n; j++) {
- array->texcoords[unit][j][0] = array->texcoords[unit][j + left][0];
- array->texcoords[unit][j][1] = array->texcoords[unit][j + left][1];
- array->texcoords[unit][j][2] = array->texcoords[unit][j + left][2];
+ array->attribs[FRAG_ATTRIB_TEX0 + unit][j][0] = array->attribs[FRAG_ATTRIB_TEX0 + unit][j + left][0];
+ array->attribs[FRAG_ATTRIB_TEX0 + unit][j][1] = array->attribs[FRAG_ATTRIB_TEX0 + unit][j + left][1];
+ array->attribs[FRAG_ATTRIB_TEX0 + unit][j][2] = array->attribs[FRAG_ATTRIB_TEX0 + unit][j + left][2];
array->lambda[unit][j] = array->lambda[unit][j + left];
}
}
ALPHA_TEST(rgba[i][ACOMP], ;);
}
else {
- GLfloat (*rgba)[4] = span->array->color.sz4.rgba;
+ GLfloat (*rgba)[4] = span->array->attribs[FRAG_ATTRIB_COL0];
const GLfloat ref = ctx->Color.AlphaRef;
ALPHA_TEST(rgba[i][ACOMP], ;);
}
if (pass_tex >= GL_TEXTURE0_ARB && pass_tex <= GL_TEXTURE7_ARB) {
pass_tex -= GL_TEXTURE0_ARB;
COPY_4V(machine->Registers[idx],
- span->array->texcoords[pass_tex][column]);
+ span->array->attribs[FRAG_ATTRIB_TEX0 + pass_tex][column]);
}
else if (pass_tex >= GL_REG_0_ATI && pass_tex <= GL_REG_5_ATI) {
pass_tex -= GL_REG_0_ATI;
if (coord_source >= GL_TEXTURE0_ARB && coord_source <= GL_TEXTURE7_ARB) {
coord_source -= GL_TEXTURE0_ARB;
- COPY_4V(tex_coords, span->array->texcoords[coord_source][column]);
+ COPY_4V(tex_coords,
+ span->array->attribs[FRAG_ATTRIB_TEX0 + coord_source][column]);
}
else if (coord_source >= GL_REG_0_ATI && coord_source <= GL_REG_5_ATI) {
coord_source -= GL_REG_0_ATI;
machine->Registers[i][j] = 0.0;
}
- COPY_4V(inputs[ATI_FS_INPUT_PRIMARY], span->array->color.sz4.rgba[col]);
- COPY_4V(inputs[ATI_FS_INPUT_SECONDARY], span->array->color.sz4.spec[col]);
+ COPY_4V(inputs[ATI_FS_INPUT_PRIMARY], span->array->attribs[FRAG_ATTRIB_COL0][col]);
+ COPY_4V(inputs[ATI_FS_INPUT_SECONDARY], span->array->attribs[FRAG_ATTRIB_COL1][col]);
}
const GLfloat *colOut = machine.Registers[0];
/*fprintf(stderr,"outputs %f %f %f %f\n",
colOut[0], colOut[1], colOut[2], colOut[3]); */
- COPY_4V(span->array->color.sz4.rgba[i], colOut);
+ COPY_4V(span->array->attribs[FRAG_ATTRIB_COL0][i], colOut);
}
}
}
ASSERT(width < MAX_WIDTH);
for (row = 0; row < height; row++, sy += stepy, dy += stepy) {
- GLvoid *rgba = span.array->color.sz4.rgba;
+ GLvoid *rgba = span.array->attribs[FRAG_ATTRIB_COL0];
/* Get row/span of source pixels */
if (overlapping) {
= _mesa_image_row_stride(unpack, width, format, type);
GLint skipPixels = 0;
/* use span array for temp color storage */
- GLfloat *rgba = (GLfloat *) span.array->color.sz4.rgba;
+ GLfloat *rgba = (GLfloat *) span.array->attribs[FRAG_ATTRIB_COL0];
/* if the span is wider than MAX_WIDTH we have to do it in chunks */
while (skipPixels < width) {
FOG_LOOP(GLushort, COMPUTE_F);
}
else {
- GLfloat (*rgba)[4] = span->array->color.sz4.rgba;
+ GLfloat (*rgba)[4] = span->array->attribs[FRAG_ATTRIB_COL0];
ASSERT(span->array->ChanType == GL_FLOAT);
FOG_LOOP(GLfloat, COMPUTE_F);
}
FOG_LOOP(GLushort, COMPUTE_F);
}
else {
- GLfloat (*rgba)[4] = span->array->color.sz4.rgba;
+ GLfloat (*rgba)[4] = span->array->attribs[FRAG_ATTRIB_COL0];
ASSERT(span->array->ChanType == GL_FLOAT);
FOG_LOOP(GLfloat, COMPUTE_F);
}
FOG_LOOP(GLushort, COMPUTE_F);
}
else {
- GLfloat (*rgba)[4] = span->array->color.sz4.rgba;
+ GLfloat (*rgba)[4] = span->array->attribs[FRAG_ATTRIB_COL0];
ASSERT(span->array->ChanType == GL_FLOAT);
FOG_LOOP(GLfloat, COMPUTE_F);
}
if (span->array->ChanType == GL_UNSIGNED_BYTE) {
GLubyte (*rgba)[4] = span->array->color.sz1.rgba;
for (i = 0; i < span->end; i++) {
- const GLfloat f = span->array->fog[i];
+ const GLfloat f = span->array->attribs[FRAG_ATTRIB_FOGC][i][0];
const GLfloat oneMinusF = 1.0F - f;
rgba[i][RCOMP] = (GLubyte) (f * rgba[i][RCOMP] + oneMinusF * rFog);
rgba[i][GCOMP] = (GLubyte) (f * rgba[i][GCOMP] + oneMinusF * gFog);
else if (span->array->ChanType == GL_UNSIGNED_SHORT) {
GLushort (*rgba)[4] = span->array->color.sz2.rgba;
for (i = 0; i < span->end; i++) {
- const GLfloat f = span->array->fog[i];
+ const GLfloat f = span->array->attribs[FRAG_ATTRIB_FOGC][i][0];
const GLfloat oneMinusF = 1.0F - f;
rgba[i][RCOMP] = (GLushort) (f * rgba[i][RCOMP] + oneMinusF * rFog);
rgba[i][GCOMP] = (GLushort) (f * rgba[i][GCOMP] + oneMinusF * gFog);
}
}
else {
- GLfloat (*rgba)[4] = span->array->color.sz4.rgba;
+ GLfloat (*rgba)[4] = span->array->attribs[FRAG_ATTRIB_COL0];
ASSERT(span->array->ChanType == GL_FLOAT);
for (i = 0; i < span->end; i++) {
- const GLfloat f = span->array->fog[i];
+ const GLfloat f = span->array->attribs[FRAG_ATTRIB_FOGC][i][0];
const GLfloat oneMinusF = 1.0F - f;
rgba[i][RCOMP] = f * rgba[i][RCOMP] + oneMinusF * rFog;
rgba[i][GCOMP] = f * rgba[i][GCOMP] + oneMinusF * gFog;
FOG_LOOP(GLushort, COMPUTE_F);
}
else {
- GLfloat (*rgba)[4] = span->array->color.sz4.rgba;
+ GLfloat (*rgba)[4] = span->array->attribs[FRAG_ATTRIB_COL0];
ASSERT(span->array->ChanType == GL_FLOAT);
FOG_LOOP(GLfloat, COMPUTE_F);
}
*/
GLuint i;
for (i = 0; i < span->end; i++) {
- const GLfloat f = span->array->fog[i];
+ const GLfloat f = span->array->attribs[FRAG_ATTRIB_FOGC][i][0];
index[i] = (GLuint) ((GLfloat) index[i] + (1.0F - f) * fogIndex);
}
}
*/
struct fp_machine
{
+ /** Fragment Input attributes */
+ GLfloat (*Attribs)[MAX_WIDTH][4];
+ GLuint CurFrag; /**< Index into Attribs arrays */
+
GLfloat Temporaries[MAX_PROGRAM_TEMPS][4];
- GLfloat Inputs[FRAG_ATTRIB_MAX][4];
GLfloat Outputs[FRAG_RESULT_MAX][4];
GLuint CondCodes[4]; /**< COND_* value for x/y/z/w */
if (CurrentMachine) {
switch (file) {
case PROGRAM_INPUT:
- COPY_4V(val, CurrentMachine->Inputs[index]);
+ COPY_4V(val, CurrentMachine->Attribs[index][CurrentMachine->CurFrag]);
break;
case PROGRAM_OUTPUT:
COPY_4V(val, CurrentMachine->Outputs[index]);
return machine->Temporaries[source->Index];
case PROGRAM_INPUT:
ASSERT(source->Index < FRAG_ATTRIB_MAX);
- return machine->Inputs[source->Index];
+ return machine->Attribs[source->Index][machine->CurFrag];
case PROGRAM_OUTPUT:
/* This is only for PRINT */
ASSERT(source->Index < FRAG_RESULT_MAX);
/* Add derivatives */
if (program->Base.InputsRead & FRAG_BIT_WPOS) {
- GLfloat *wpos = (GLfloat*) machine->Inputs[FRAG_ATTRIB_WPOS];
+ GLfloat *wpos = machine->Attribs[FRAG_ATTRIB_WPOS][machine->CurFrag];
if (xOrY == 'X') {
wpos[0] += 1.0F;
wpos[1] += 0.0F;
}
}
if (program->Base.InputsRead & FRAG_BIT_COL0) {
- GLfloat *col0 = (GLfloat*) machine->Inputs[FRAG_ATTRIB_COL0];
+ GLfloat *col0 = machine->Attribs[FRAG_ATTRIB_COL0][machine->CurFrag];
if (xOrY == 'X') {
col0[0] += span->drdx * (1.0F / CHAN_MAXF);
col0[1] += span->dgdx * (1.0F / CHAN_MAXF);
}
}
if (program->Base.InputsRead & FRAG_BIT_COL1) {
- GLfloat *col1 = (GLfloat*) machine->Inputs[FRAG_ATTRIB_COL1];
+ GLfloat *col1 = machine->Attribs[FRAG_ATTRIB_COL1][machine->CurFrag];
if (xOrY == 'X') {
col1[0] += span->dsrdx * (1.0F / CHAN_MAXF);
col1[1] += span->dsgdx * (1.0F / CHAN_MAXF);
}
}
if (program->Base.InputsRead & FRAG_BIT_FOGC) {
- GLfloat *fogc = (GLfloat*) machine->Inputs[FRAG_ATTRIB_FOGC];
+ GLfloat *fogc = machine->Attribs[FRAG_ATTRIB_FOGC][machine->CurFrag];
if (xOrY == 'X') {
fogc[0] += span->dfogdx;
}
}
for (u = 0; u < ctx->Const.MaxTextureCoordUnits; u++) {
if (program->Base.InputsRead & FRAG_BIT_TEX(u)) {
- GLfloat *tex = (GLfloat*) machine->Inputs[FRAG_ATTRIB_TEX0 + u];
+ GLfloat *tex = machine->Attribs[FRAG_ATTRIB_TEX0 + u][machine->CurFrag];
/* XXX perspective-correct interpolation */
if (xOrY == 'X') {
tex[0] += span->texStepX[u][0];
for (v = 0; v < ctx->Const.MaxVarying; v++) {
if (program->Base.InputsRead & FRAG_BIT_VAR(v)) {
- GLfloat *var = (GLfloat*) machine->Inputs[FRAG_ATTRIB_VAR0 + v];
+ GLfloat *var = machine->Attribs[FRAG_ATTRIB_VAR0 + v][machine->CurFrag];
if (xOrY == 'X') {
var[0] += span->varStepX[v][0];
var[1] += span->varStepX[v][1];
const SWspan *span, GLuint col )
{
GLuint inputsRead = program->Base.InputsRead;
- GLuint u, v;
if (ctx->FragmentProgram.CallbackEnabled)
inputsRead = ~0;
MAX_NV_FRAGMENT_PROGRAM_TEMPS * 4 * sizeof(GLfloat));
}
- /* Load input registers */
- if (inputsRead & FRAG_BIT_WPOS) {
- GLfloat *wpos = machine->Inputs[FRAG_ATTRIB_WPOS];
- ASSERT(span->arrayMask & SPAN_Z);
- if (span->arrayMask & SPAN_XY) {
- wpos[0] = (GLfloat) span->array->x[col];
- wpos[1] = (GLfloat) span->array->y[col];
- }
- else {
- wpos[0] = (GLfloat) span->x + col;
- wpos[1] = (GLfloat) span->y;
- }
- wpos[2] = (GLfloat) span->array->z[col] / ctx->DrawBuffer->_DepthMaxF;
- wpos[3] = span->w + col * span->dwdx;
- }
- if (inputsRead & FRAG_BIT_COL0) {
- ASSERT(span->arrayMask & SPAN_RGBA);
- COPY_4V(machine->Inputs[FRAG_ATTRIB_COL0],
- span->array->color.sz4.rgba[col]);
- }
- if (inputsRead & FRAG_BIT_COL1) {
- ASSERT(span->arrayMask & SPAN_SPEC);
- COPY_4V(machine->Inputs[FRAG_ATTRIB_COL1],
- span->array->color.sz4.spec[col]);
- }
- if (inputsRead & FRAG_BIT_FOGC) {
- GLfloat *fogc = machine->Inputs[FRAG_ATTRIB_FOGC];
- ASSERT(span->arrayMask & SPAN_FOG);
- fogc[0] = span->array->fog[col];
- fogc[1] = 0.0F;
- fogc[2] = 0.0F;
- fogc[3] = 0.0F;
- }
- for (u = 0; u < ctx->Const.MaxTextureCoordUnits; u++) {
- if (inputsRead & FRAG_BIT_TEX(u)) {
- GLfloat *tex = machine->Inputs[FRAG_ATTRIB_TEX0 + u];
- /*ASSERT(ctx->Texture._EnabledCoordUnits & (1 << u));*/
- COPY_4V(tex, span->array->texcoords[u][col]);
- /*ASSERT(tex[0] != 0 || tex[1] != 0 || tex[2] != 0);*/
-#if 0
- printf("Texcoord %d: %g %g %g %g\n", u,
- tex[0], tex[1], tex[2], tex[3]);
-#endif
- }
- }
- for (v = 0; v < ctx->Const.MaxVarying; v++) {
- if (inputsRead & FRAG_BIT_VAR(v)) {
-#if 0
- printf("Frag Var %d at y=%d: %f %f %f\n", v, col,
- span->array->varying[v][col][0],
- span->array->varying[v][col][1],
- span->array->varying[v][col][2]);
-#endif
- COPY_4V(machine->Inputs[FRAG_ATTRIB_VAR0 + v],
- span->array->varying[v][col]);
- }
- }
+ /* Setup pointer to input attributes */
+ machine->Attribs = span->array->attribs;
+ machine->CurFrag = col;
/* init condition codes */
machine->CondCodes[0] = COND_EQ;
if (execute_program(ctx, program, ~0, &machine, span, i)) {
/* Store result color */
- COPY_4V(span->array->color.sz4.rgba[i],
+ COPY_4V(span->array->attribs[FRAG_ATTRIB_COL0][i],
machine.Outputs[FRAG_RESULT_COLR]);
/* Store result depth/z */
}
else {
logicop_uint4(ctx, 4 * span->end,
- (GLuint *) span->array->color.sz4.rgba,
+ (GLuint *) span->array->attribs[FRAG_ATTRIB_COL0],
(const GLuint *) rbPixels, span->array->mask);
}
}
const GLuint bMask = ctx->Color.ColorMask[BCOMP] ? ~0x0 : 0x0;
const GLuint aMask = ctx->Color.ColorMask[ACOMP] ? ~0x0 : 0x0;
const GLuint (*dst)[4] = (const GLuint (*)[4]) rbPixels;
- GLuint (*src)[4] = (GLuint (*)[4]) span->array->color.sz4.rgba;
+ GLuint (*src)[4] = (GLuint (*)[4]) span->array->attribs[FRAG_ATTRIB_COL0];
GLuint i;
for (i = 0; i < n; i++) {
src[i][RCOMP] = (src[i][RCOMP] & rMask) | (dst[i][RCOMP] & ~rMask);
#if FLAGS & TEXTURE
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
if (ctx->Texture._EnabledCoordUnits & (1 << u)) {
- COPY_4V(span->array->texcoords[u][count], texcoord[u]);
+ COPY_4V(span->array->attribs[FRAG_ATTRIB_TEX0 + u][count], texcoord[u]);
span->array->lambda[u][count] = 0.0;
}
}
r = vert->texcoord[u][0];
else /* GL_R */
r = vert->texcoord[u][2];
- span->array->texcoords[u][count][0] = s;
- span->array->texcoords[u][count][1] = t;
- span->array->texcoords[u][count][2] = r;
- span->array->texcoords[u][count][3] = 1.0F;
+ span->array->attribs[FRAG_ATTRIB_TEX0 + u][count][0] = s;
+ span->array->attribs[FRAG_ATTRIB_TEX0 + u][count][1] = t;
+ span->array->attribs[FRAG_ATTRIB_TEX0 + u][count][2] = r;
+ span->array->attribs[FRAG_ATTRIB_TEX0 + u][count][3] = 1.0F;
span->array->lambda[u][count] = 0.0; /* XXX fix? */
}
else {
- COPY_4V(span->array->texcoords[u][count], vert->texcoord[u]);
+ COPY_4V(span->array->attribs[FRAG_ATTRIB_TEX0 + u][count], vert->texcoord[u]);
}
}
}
#if FLAGS & TEXTURE
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
if (ctx->Texture.Unit[u]._ReallyEnabled) {
- COPY_4V(span->array->texcoords[u][count], texcoord[u]);
+ COPY_4V(span->array->attribs[FRAG_ATTRIB_TEX0 + u][count], texcoord[u]);
}
}
#endif
/* no convolution */
const GLint dstStride
= _mesa_image_row_stride(packing, width, format, type);
- GLfloat (*rgba)[4] = swrast->SpanArrays->color.sz4.rgba;
+ GLfloat (*rgba)[4] = swrast->SpanArrays->attribs[FRAG_ATTRIB_COL0];
GLint row;
GLubyte *dst = _mesa_image_address2d(packing, pixels, width, height,
format, type, 0, 0);
#endif
case GL_FLOAT:
{
- GLfloat (*rgba)[4] = span->array->color.sz4.rgba;
+ GLfloat (*rgba)[4] = span->array->attribs[FRAG_ATTRIB_COL0];
GLfloat r, g, b, a, dr, dg, db, da;
r = span->red;
g = span->green;
#endif
case GL_FLOAT:
{
- GLfloat (*spec)[4] = span->array->color.sz4.spec;
+ GLfloat (*spec)[4] = span->array->attribs[FRAG_ATTRIB_COL1];
#if CHAN_BITS <= 16
GLfloat r = CHAN_TO_FLOAT(FixedToChan(span->specRed));
GLfloat g = CHAN_TO_FLOAT(FixedToChan(span->specGreen));
static INLINE void
interpolate_fog(const GLcontext *ctx, SWspan *span)
{
- GLfloat *fog = span->array->fog;
+ GLfloat (*fog)[4] = span->array->attribs[FRAG_ATTRIB_FOGC];
const GLfloat fogStep = span->fogStep;
GLfloat fogCoord = span->fog;
const GLuint haveW = (span->interpMask & SPAN_W);
GLfloat w = haveW ? span->w : 1.0F;
GLuint i;
for (i = 0; i < span->end; i++) {
- fog[i] = fogCoord / w;
+ fog[i][0] = fogCoord / w;
fogCoord += fogStep;
w += wStep;
}
needLambda = GL_FALSE;
}
if (needLambda) {
- GLfloat (*texcoord)[4] = span->array->texcoords[u];
+ GLfloat (*texcoord)[4] = span->array->attribs[FRAG_ATTRIB_TEX0 + u];
GLfloat *lambda = span->array->lambda[u];
const GLfloat dsdx = span->texStepX[u][0];
const GLfloat dsdy = span->texStepY[u][0];
span->arrayMask |= SPAN_LAMBDA;
}
else {
- GLfloat (*texcoord)[4] = span->array->texcoords[u];
+ GLfloat (*texcoord)[4] = span->array->attribs[FRAG_ATTRIB_TEX0 + u];
GLfloat *lambda = span->array->lambda[u];
const GLfloat dsdx = span->texStepX[u][0];
const GLfloat dtdx = span->texStepX[u][1];
span->arrayMask |= SPAN_TEXTURE;
if (needLambda) {
/* just texture unit 0, with lambda */
- GLfloat (*texcoord)[4] = span->array->texcoords[0];
+ GLfloat (*texcoord)[4] = span->array->attribs[FRAG_ATTRIB_TEX0];
GLfloat *lambda = span->array->lambda[0];
const GLfloat dsdx = span->texStepX[0][0];
const GLfloat dsdy = span->texStepY[0][0];
}
else {
/* just texture 0, without lambda */
- GLfloat (*texcoord)[4] = span->array->texcoords[0];
+ GLfloat (*texcoord)[4] = span->array->attribs[FRAG_ATTRIB_TEX0];
const GLfloat dsdx = span->texStepX[0][0];
const GLfloat dtdx = span->texStepX[0][1];
const GLfloat drdx = span->texStepX[0][2];
GLuint k;
for (k = 0; k < span->end; k++) {
GLfloat invW = 1.0f / w;
- span->array->varying[var][k][j] = v * invW;
+ span->array->attribs[FRAG_ATTRIB_VAR0 + var][k][j] = v * invW;
v += dvdx;
w += dwdx;
}
}
+/**
+ * Fill in the arrays->attribs[FRAG_ATTRIB_WPOS] array.
+ */
+static INLINE void
+interpolate_wpos(GLcontext *ctx, SWspan *span)
+{
+ GLfloat (*wpos)[4] = span->array->attribs[FRAG_ATTRIB_WPOS];
+ GLuint i;
+ if (span->arrayMask & SPAN_XY) {
+ for (i = 0; i < span->end; i++) {
+ wpos[i][0] = (GLfloat) span->array->x[i];
+ wpos[i][1] = (GLfloat) span->array->y[i];
+ }
+ }
+ else {
+ for (i = 0; i < span->end; i++) {
+ wpos[i][0] = (GLfloat) span->x + i;
+ wpos[i][1] = (GLfloat) span->y;
+ }
+ }
+ for (i = 0; i < span->end; i++) {
+ wpos[i][2] = (GLfloat) span->array->z[i] / ctx->DrawBuffer->_DepthMaxF;
+ wpos[i][3] = span->w + i * span->dwdx;
+ }
+}
+
+
/**
* Apply the current polygon stipple pattern to a span of pixels.
*/
break;
case GL_FLOAT:
{
- GLfloat (*rgba)[4] = span->array->color.sz4.rgba;
- GLfloat (*spec)[4] = span->array->color.sz4.spec;
+ GLfloat (*rgba)[4] = span->array->attribs[FRAG_ATTRIB_COL0];
+ GLfloat (*spec)[4] = span->array->attribs[FRAG_ATTRIB_COL1];
GLuint i;
for (i = 0; i < span->end; i++) {
rgba[i][RCOMP] += spec[i][RCOMP];
}
}
else {
- GLfloat (*rgba)[4] = span->array->color.sz4.rgba;
+ GLfloat (*rgba)[4] = span->array->attribs[FRAG_ATTRIB_COL0];
for (i = 0; i < span->end; i++) {
rgba[i][ACOMP] = rgba[i][ACOMP] * coverage[i];
}
static INLINE void
clamp_colors(SWspan *span)
{
- GLfloat (*rgba)[4] = span->array->color.sz4.rgba;
+ GLfloat (*rgba)[4] = span->array->attribs[FRAG_ATTRIB_COL0];
GLuint i;
ASSERT(span->array->ChanType == GL_FLOAT);
for (i = 0; i < span->end; i++) {
src = span->array->color.sz2.rgba;
}
else {
- src = span->array->color.sz4.rgba;
+ src = span->array->attribs[FRAG_ATTRIB_COL0];
}
if (newType == GL_UNSIGNED_BYTE) {
dst = span->array->color.sz1.rgba;
dst = span->array->color.sz2.rgba;
}
else {
- dst = span->array->color.sz4.rgba;
+ dst = span->array->attribs[FRAG_ATTRIB_COL0];
}
_mesa_convert_colors(span->array->ChanType, src,
? (GLvoid *) span->array->color.sz1.rgba
: (GLvoid *) span->array->color.sz2.rgba;
_mesa_convert_colors(oldType, src,
- newType, span->array->color.sz4.rgba,
+ newType, span->array->attribs[FRAG_ATTRIB_COL0],
span->end, span->array->mask);
span->array->ChanType = newType;
}
if (ctx->Shader.CurrentProgram && span->interpMask & SPAN_VARYING)
interpolate_varying(ctx, span);
+ if (ctx->FragmentProgram._Current &&
+ (ctx->FragmentProgram._Current->Base.InputsRead & FRAG_BIT_WPOS))
+ interpolate_wpos(ctx, span);
+
/* Run fragment program/shader now */
if (ctx->FragmentProgram._Current) {
_swrast_exec_fragment_program(ctx, span);
rbPixels = span->array->color.sz2.spec;
}
else {
- rbPixels = span->array->color.sz4.spec;
+ rbPixels = span->array->attribs[FRAG_ATTRIB_COL1];
}
/* Get destination values from renderbuffer */
/**
- * \defgroup SpanFlags SPAN_*-flags
+ * \defgroup SpanFlags
* Bitflags used for interpMask and arrayMask fields below to indicate
* which interpolant values and fragment arrays are in use, respectively.
*/
union {
GLubyte sz1[MAX_WIDTH][4]; /* primary color */
GLushort sz2[MAX_WIDTH][4];
- GLfloat sz4[MAX_WIDTH][4];
} rgba;
union {
GLubyte sz1[MAX_WIDTH][4]; /* specular color and temp storage */
GLushort sz2[MAX_WIDTH][4];
- GLfloat sz4[MAX_WIDTH][4];
} spec;
};
#endif
* filled in by glDraw/CopyPixels, etc.
* These arrays are separated out of sw_span to conserve memory.
*/
-typedef struct sw_span_arrays {
+typedef struct sw_span_arrays
+{
+ /** Per-fragment attributes (indexed by FRAG_ATTRIB_* tokens) */
+ GLfloat attribs[FRAG_ATTRIB_MAX][MAX_WIDTH][4];
+
+ /** This mask indicates which fragments are alive or culled */
+ GLubyte mask[MAX_WIDTH];
+
GLenum ChanType; /**< Color channel type, GL_UNSIGNED_BYTE, GL_FLOAT */
union {
struct {
GLushort rgba[MAX_WIDTH][4];
GLushort spec[MAX_WIDTH][4];
} sz2;
- struct {
- GLfloat rgba[MAX_WIDTH][4];
- GLfloat spec[MAX_WIDTH][4];
- } sz4;
} color;
/** XXX these are temporary fields, pointing into above color arrays */
GLchan (*rgba)[4];
GLchan (*spec)[4];
-#if 0
- /* XXX rearrange and unify these arrays to so that we can
- * index all fragment inputs with the FRAG_ATTRIB_* values:
- */
- GLfloat attribs[FRAG_ATTRIB_MAX][MAX_WIDTH][4];
- /*OR*/
- typedef GLfloat (*array4f)[4];
- array4f attribs[FRAG_ATTRIB_MAX];
-#endif
-
GLint x[MAX_WIDTH]; /**< fragment X coords */
GLint y[MAX_WIDTH]; /**< fragment Y coords */
GLuint z[MAX_WIDTH]; /**< fragment Z coords */
GLuint index[MAX_WIDTH]; /**< Color indexes */
- GLfloat fog[MAX_WIDTH];
- GLfloat texcoords[MAX_TEXTURE_COORD_UNITS][MAX_WIDTH][4];
- GLfloat lambda[MAX_TEXTURE_COORD_UNITS][MAX_WIDTH];
+ GLfloat lambda[MAX_TEXTURE_COORD_UNITS][MAX_WIDTH]; /**< Texture LOD */
GLfloat coverage[MAX_WIDTH]; /**< Fragment coverage for AA/smoothing */
- GLfloat varying[MAX_VARYING][MAX_WIDTH][4]; /**< For shaders */
-
- /** This mask indicates which fragments are alive or culled */
- GLubyte mask[MAX_WIDTH];
} SWspanarrays;
* stream of these structures which would be consumed by one or more
* span-processing threads which could run in parallel.
*/
-typedef struct sw_span {
+typedef struct sw_span
+{
GLint x, y;
/** Only need to process pixels between start <= i < end */
*/
for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
if (ctx->Texture.Unit[unit]._ReallyEnabled) {
+ const GLfloat (*texcoords)[4]
+ = (const GLfloat (*)[4])
+ span->array->attribs[FRAG_ATTRIB_TEX0 + unit];
const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
const struct gl_texture_object *curObj = texUnit->_Current;
GLfloat *lambda = span->array->lambda[unit];
/* Sample the texture (span->end = number of fragments) */
swrast->TextureSample[unit]( ctx, texUnit->_Current, span->end,
- (const GLfloat (*)[4]) span->array->texcoords[unit],
- lambda, texels );
+ texcoords, lambda, texels );
/* GL_SGI_texture_color_table */
if (texUnit->ColorTableEnabled) {
GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x;
ASSERT(j >= 0);
ASSERT(j < span->end);
- COPY_4V(zoomed.array->color.sz4.rgba[i], rgba[j]);
+ COPY_4V(zoomed.array->attribs[FRAG_ATTRIB_COL0][i], rgba[j]);
}
}
}
GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x;
ASSERT(j >= 0);
ASSERT(j < span->end);
- zoomed.array->color.sz4.rgba[i][0] = rgb[j][0];
- zoomed.array->color.sz4.rgba[i][1] = rgb[j][1];
- zoomed.array->color.sz4.rgba[i][2] = rgb[j][2];
- zoomed.array->color.sz4.rgba[i][3] = 1.0F;
+ zoomed.array->attribs[FRAG_ATTRIB_COL0][i][0] = rgb[j][0];
+ zoomed.array->attribs[FRAG_ATTRIB_COL0][i][1] = rgb[j][1];
+ zoomed.array->attribs[FRAG_ATTRIB_COL0][i][2] = rgb[j][2];
+ zoomed.array->attribs[FRAG_ATTRIB_COL0][i][3] = 1.0F;
}
}
}