/* Authors:
* Keith Whitwell <keith@tungstengraphics.com>
+ * Daniel Borca <dborca@users.sourceforge.net>
*/
GLuint tmu0_source = fxMesa->tmu_source[0];
GLuint tmu1_source = fxMesa->tmu_source[1];
GLfloat (*tc0)[4], (*tc1)[4];
- GLubyte (*col)[4];
- GLuint tc0_stride, tc1_stride, col_stride;
- GLuint tc0_size, tc1_size;
+ GLfloat (*col)[4], (*spec)[4];
+ GLuint tc0_stride, tc1_stride, col_stride, spec_stride;
+ GLuint tc0_size, tc1_size, col_size;
GLfloat (*proj)[4] = VB->NdcPtr->data;
GLuint proj_stride = VB->NdcPtr->stride;
+ GLfloat (*psize)[4];
+ GLuint psize_stride;
+ GLfloat (*fog)[4];
+ GLuint fog_stride;
GrVertex *v = (GrVertex *)dest;
GLfloat u0scale,v0scale,u1scale,v1scale;
const GLubyte *mask = VB->ClipMask;
const GLfloat *const s = ctx->Viewport._WindowMap.m;
int i;
+ if (IND & SETUP_PSIZ) {
+ psize = VB->PointSizePtr->data;
+ psize_stride = VB->PointSizePtr->stride;
+ }
if (IND & SETUP_TMU0) {
tc0 = VB->TexCoordPtr[tmu0_source]->data;
}
if (IND & SETUP_RGBA) {
- if (VB->ColorPtr[0]->Type != GL_UNSIGNED_BYTE)
- import_float_colors( ctx );
- col = VB->ColorPtr[0]->Ptr;
- col_stride = VB->ColorPtr[0]->StrideB;
+ col = VB->ColorPtr[0]->data;
+ col_stride = VB->ColorPtr[0]->stride;
+ col_size = VB->ColorPtr[0]->size;
+ }
+
+ if (IND & SETUP_SPEC) {
+ spec = VB->SecondaryColorPtr[0]->data;
+ spec_stride = VB->SecondaryColorPtr[0]->stride;
+ }
+
+ if (IND & SETUP_FOGC) {
+ fog = VB->FogCoordPtr->data;
+ fog_stride = VB->FogCoordPtr->stride;
}
if (start) {
proj = (GLfloat (*)[4])((GLubyte *)proj + start * proj_stride);
+ if (IND & SETUP_PSIZ)
+ psize = (GLfloat (*)[4])((GLubyte *)psize + start * psize_stride);
if (IND & SETUP_TMU0)
tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + start * tc0_stride);
if (IND & SETUP_TMU1)
tc1 = (GLfloat (*)[4])((GLubyte *)tc1 + start * tc1_stride);
if (IND & SETUP_RGBA)
- STRIDE_4UB(col, start * col_stride);
+ STRIDE_4F(col, start * col_stride);
+ if (IND & SETUP_SPEC)
+ STRIDE_4F(spec, start * spec_stride);
+ if (IND & SETUP_FOGC)
+ fog = (GLfloat (*)[4])((GLubyte *)fog + start * fog_stride);
}
for (i=start; i < end; i++, v++) {
+ if (IND & SETUP_PSIZ) {
+ v->psize = psize[0][0];
+ psize = (GLfloat (*)[4])((GLubyte *)psize + psize_stride);
+ }
+
if (IND & SETUP_XYZW) {
if (mask[i] == 0) {
/* unclipped */
VIEWPORT_Y(v->y, proj[0][1]);
VIEWPORT_Z(v->ooz, proj[0][2]);
v->oow = proj[0][3];
- } else {
- /* clipped */
- v->oow = 1.0;
- }
- if (IND & SETUP_SNAP) {
+ if (IND & SETUP_SNAP) {
#if defined(USE_IEEE)
- const float snapper = (3L << 18);
- v->x += snapper;
- v->x -= snapper;
- v->y += snapper;
- v->y -= snapper;
+ const float snapper = (3L << 18);
+ v->x += snapper;
+ v->x -= snapper;
+ v->y += snapper;
+ v->y -= snapper;
#else
- v->x = ((int) (v->x * 16.0f)) * (1.0f / 16.0f);
- v->y = ((int) (v->y * 16.0f)) * (1.0f / 16.0f);
+ v->x = ((int) (v->x * 16.0f)) * (1.0f / 16.0f);
+ v->y = ((int) (v->y * 16.0f)) * (1.0f / 16.0f);
#endif
- }
+ }
+ } else {
+ /* clipped */
+ v->oow = 1.0;
+ }
proj = (GLfloat (*)[4])((GLubyte *)proj + proj_stride);
}
if (IND & SETUP_RGBA) {
- v->pargb[2] = col[0][0];
- v->pargb[1] = col[0][1];
- v->pargb[0] = col[0][2];
- v->pargb[3] = col[0][3];
- STRIDE_4UB(col, col_stride);
+#if FX_PACKEDCOLOR
+ UNCLAMPED_FLOAT_TO_UBYTE(v->pargb[2], col[0][0]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v->pargb[1], col[0][1]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v->pargb[0], col[0][2]);
+ if (col_size == 4) {
+ UNCLAMPED_FLOAT_TO_UBYTE(v->pargb[3], col[0][3]);
+ } else {
+ v->pargb[3] = 255;
+ }
+#else /* !FX_PACKEDCOLOR */
+ CNORM(v->r, col[0][0]);
+ CNORM(v->g, col[0][1]);
+ CNORM(v->b, col[0][2]);
+ if (col_size == 4) {
+ CNORM(v->a, col[0][3]);
+ } else {
+ v->a = 255.0f;
+ }
+#endif /* !FX_PACKEDCOLOR */
+ STRIDE_4F(col, col_stride);
+ }
+ if (IND & SETUP_SPEC) {
+#if FX_PACKEDCOLOR
+ UNCLAMPED_FLOAT_TO_UBYTE(v->pspec[2], spec[0][0]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v->pspec[1], spec[0][1]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v->pspec[0], spec[0][2]);
+#else /* !FX_PACKEDCOLOR */
+ CNORM(v->r1, spec[0][0]);
+ CNORM(v->g1, spec[0][1]);
+ CNORM(v->b1, spec[0][2]);
+#endif /* !FX_PACKEDCOLOR */
+ STRIDE_4F(spec, spec_stride);
+ }
+ if (IND & SETUP_FOGC) {
+ v->fog = CLAMP(fog[0][0], 0.0f, 1.0f);
+ fog = (GLfloat (*)[4])((GLubyte *)fog + fog_stride);
}
if (IND & SETUP_TMU0) {
GLfloat w = v->oow;
GrVertex *dst = (GrVertex *) (fxverts + edst);
const GrVertex *out = (const GrVertex *) (fxverts + eout);
const GrVertex *in = (const GrVertex *) (fxverts + ein);
- const GLfloat wout = 1.0F / out->oow;
- const GLfloat win = 1.0F / in->oow;
+ const GLfloat wout = oow / out->oow;
+ const GLfloat win = oow / in->oow;
VIEWPORT_X(dst->x, dstclip[0] * oow);
VIEWPORT_Y(dst->y, dstclip[1] * oow);
}
+#if FX_PACKEDCOLOR
INTERP_UB( t, dst->pargb[0], out->pargb[0], in->pargb[0] );
INTERP_UB( t, dst->pargb[1], out->pargb[1], in->pargb[1] );
INTERP_UB( t, dst->pargb[2], out->pargb[2], in->pargb[2] );
INTERP_UB( t, dst->pargb[3], out->pargb[3], in->pargb[3] );
+#else /* !FX_PACKEDCOLOR */
+ INTERP_F( t, dst->r, out->r, in->r );
+ INTERP_F( t, dst->g, out->g, in->g );
+ INTERP_F( t, dst->b, out->b, in->b );
+ INTERP_F( t, dst->a, out->a, in->a );
+#endif /* !FX_PACKEDCOLOR */
+
+ if (IND & SETUP_SPEC) {
+#if FX_PACKEDCOLOR
+ INTERP_UB( t, dst->pspec[0], out->pspec[0], in->pspec[0] );
+ INTERP_UB( t, dst->pspec[1], out->pspec[1], in->pspec[1] );
+ INTERP_UB( t, dst->pspec[2], out->pspec[2], in->pspec[2] );
+#else /* !FX_PACKEDCOLOR */
+ INTERP_F( t, dst->r1, out->r1, in->r1 );
+ INTERP_F( t, dst->g1, out->g1, in->g1 );
+ INTERP_F( t, dst->b1, out->b1, in->b1 );
+#endif /* !FX_PACKEDCOLOR */
+ }
+
+ if (IND & SETUP_FOGC) {
+ INTERP_F( t, dst->fog, out->fog, in->fog );
+ }
if (IND & SETUP_TMU0) {
+ INTERP_F( t,
+ dst->tmuvtx[0].sow,
+ out->tmuvtx[0].sow * wout,
+ in->tmuvtx[0].sow * win );
+ INTERP_F( t,
+ dst->tmuvtx[0].tow,
+ out->tmuvtx[0].tow * wout,
+ in->tmuvtx[0].tow * win );
if (IND & SETUP_PTEX) {
- INTERP_F( t,
- dst->tmuvtx[0].sow,
- out->tmuvtx[0].sow * wout,
- in->tmuvtx[0].sow * win );
INTERP_F( t,
- dst->tmuvtx[0].tow,
- out->tmuvtx[0].tow * wout,
- in->tmuvtx[0].tow * win );
- INTERP_F( t,
dst->tmuvtx[0].oow,
out->tmuvtx[0].oow * wout,
in->tmuvtx[0].oow * win );
-
- dst->tmuvtx[0].sow *= oow;
- dst->tmuvtx[0].tow *= oow;
- dst->tmuvtx[0].oow *= oow;
- } else {
- INTERP_F( t,
- dst->tmuvtx[0].sow,
- out->tmuvtx[0].sow * wout,
- in->tmuvtx[0].sow * win );
- INTERP_F( t,
- dst->tmuvtx[0].tow,
- out->tmuvtx[0].tow * wout,
- in->tmuvtx[0].tow * win );
-
- dst->tmuvtx[0].sow *= oow;
- dst->tmuvtx[0].tow *= oow;
}
}
if (IND & SETUP_TMU1) {
+ INTERP_F( t,
+ dst->tmuvtx[1].sow,
+ out->tmuvtx[1].sow * wout,
+ in->tmuvtx[1].sow * win );
+ INTERP_F( t,
+ dst->tmuvtx[1].tow,
+ out->tmuvtx[1].tow * wout,
+ in->tmuvtx[1].tow * win );
if (IND & SETUP_PTEX) {
- INTERP_F( t,
- dst->tmuvtx[1].sow,
- out->tmuvtx[1].sow * wout,
- in->tmuvtx[1].sow * win );
INTERP_F( t,
- dst->tmuvtx[1].tow,
- out->tmuvtx[1].tow * wout,
- in->tmuvtx[1].tow * win );
- INTERP_F( t,
dst->tmuvtx[1].oow,
out->tmuvtx[1].oow * wout,
in->tmuvtx[1].oow * win );
-
- dst->tmuvtx[1].sow *= oow;
- dst->tmuvtx[1].tow *= oow;
- dst->tmuvtx[1].oow *= oow;
- } else {
- INTERP_F( t,
- dst->tmuvtx[1].sow,
- out->tmuvtx[1].sow * wout,
- in->tmuvtx[1].sow * win );
- INTERP_F( t,
- dst->tmuvtx[1].tow,
- out->tmuvtx[1].tow * wout,
- in->tmuvtx[1].tow * win );
-
- dst->tmuvtx[1].sow *= oow;
- dst->tmuvtx[1].tow *= oow;
}
}
}
{
setup_tab[IND].emit = TAG(emit);
+ if (IND & SETUP_SPEC) {
+ setup_tab[IND].copy_pv = copy_pv2;
+ } else {
+ setup_tab[IND].copy_pv = copy_pv;
+ }
+
#if ((IND & SETUP_XYZW) && (IND & SETUP_RGBA))
setup_tab[IND].check_tex_sizes = TAG(check_tex_sizes);
setup_tab[IND].interp = TAG(interp);
+ setup_tab[IND].vertex_format = 0;
if (IND & SETUP_PTEX) {
- setup_tab[IND].vertex_format = (GR_STWHINT_W_DIFF_TMU0 |
- GR_STWHINT_W_DIFF_TMU1);
- }
- else {
- setup_tab[IND].vertex_format = 0;
+ setup_tab[IND].vertex_format |= GR_STWHINT_W_DIFF_TMU0;
}
#if (IND & SETUP_TMU1)
- setup_tab[IND].vertex_format |= GR_STWHINT_ST_DIFF_TMU1;
+ setup_tab[IND].vertex_format |= GR_STWHINT_ST_DIFF_TMU1;
+ if (IND & SETUP_PTEX) {
+ setup_tab[IND].vertex_format |= GR_STWHINT_W_DIFF_TMU1;
+ }
#endif
#endif