summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/glide/fxtris.c
diff options
context:
space:
mode:
authorDaniel Borca <[email protected]>2004-07-05 06:47:17 +0000
committerDaniel Borca <[email protected]>2004-07-05 06:47:17 +0000
commit3e94fd34449210c8b548a2a30f248fb5bd73478b (patch)
treed067d234e6dbd75799948b915742920e14f983e3 /src/mesa/drivers/glide/fxtris.c
parentfd003824ad18fd78cbecf32fb5e8e58cf2f9cdba (diff)
added GL_ARB_point_sprite.
color masking correctly implemented for 15bpp. small fixes for textures and tri engine.
Diffstat (limited to 'src/mesa/drivers/glide/fxtris.c')
-rw-r--r--src/mesa/drivers/glide/fxtris.c116
1 files changed, 93 insertions, 23 deletions
diff --git a/src/mesa/drivers/glide/fxtris.c b/src/mesa/drivers/glide/fxtris.c
index 6620eb678ab..e2b6c45a42a 100644
--- a/src/mesa/drivers/glide/fxtris.c
+++ b/src/mesa/drivers/glide/fxtris.c
@@ -274,6 +274,63 @@ static void fx_draw_point( fxMesaContext fxMesa,
#endif
#define __GL_COSF cos
#define __GL_SINF sin
+static void fx_draw_point_sprite ( fxMesaContext fxMesa,
+ GrVertex *v0, GLfloat psize )
+{
+ const GLcontext *ctx = fxMesa->glCtx;
+
+ GLfloat radius;
+ GrVertex _v_[4];
+ GLuint ts0 = fxMesa->tmu_source[0];
+ GLuint ts1 = fxMesa->tmu_source[1];
+ GLfloat w = v0->oow;
+ GLfloat u0scale = fxMesa->s0scale * w;
+ GLfloat v0scale = fxMesa->t0scale * w;
+ GLfloat u1scale = fxMesa->s1scale * w;
+ GLfloat v1scale = fxMesa->t1scale * w;
+
+ radius = psize / 2.;
+ _v_[0] = *v0;
+ _v_[1] = *v0;
+ _v_[2] = *v0;
+ _v_[3] = *v0;
+ /* CLIP_LOOP ?!? */
+ /* point coverage? */
+ /* we don't care about culling here (see fxSetupCull) */
+
+ _v_[0].x -= radius;
+ _v_[0].y += radius;
+ _v_[1].x += radius;
+ _v_[1].y += radius;
+ _v_[2].x += radius;
+ _v_[2].y -= radius;
+ _v_[3].x -= radius;
+ _v_[3].y -= radius;
+
+ if (ctx->Point.CoordReplace[ts0]) {
+ _v_[0].tmuvtx[0].sow = 0;
+ _v_[0].tmuvtx[0].tow = 0;
+ _v_[1].tmuvtx[0].sow = u0scale;
+ _v_[1].tmuvtx[0].tow = 0;
+ _v_[2].tmuvtx[0].sow = u0scale;
+ _v_[2].tmuvtx[0].tow = v0scale;
+ _v_[3].tmuvtx[0].sow = 0;
+ _v_[3].tmuvtx[0].tow = v0scale;
+ }
+ if (ctx->Point.CoordReplace[ts1]) {
+ _v_[0].tmuvtx[1].sow = 0;
+ _v_[0].tmuvtx[1].tow = 0;
+ _v_[1].tmuvtx[1].sow = u1scale;
+ _v_[1].tmuvtx[1].tow = 0;
+ _v_[2].tmuvtx[1].sow = u1scale;
+ _v_[2].tmuvtx[1].tow = v1scale;
+ _v_[3].tmuvtx[1].sow = 0;
+ _v_[3].tmuvtx[1].tow = v1scale;
+ }
+
+ grDrawVertexArrayContiguous(GR_TRIANGLE_FAN, 4, _v_, sizeof(GrVertex));
+}
+
static void fx_draw_point_wide ( fxMesaContext fxMesa,
GrVertex *v0 )
{
@@ -285,6 +342,11 @@ static void fx_draw_point_wide ( fxMesaContext fxMesa,
const GLcontext *ctx = fxMesa->glCtx;
const GLfloat psize = (ctx->_TriangleCaps & DD_POINT_ATTEN) ? v0->psize : ctx->Point.Size;
+ if (ctx->Point.PointSprite) {
+ fx_draw_point_sprite(fxMesa, v0, psize);
+ return;
+ }
+
_v_[0] = v0;
_v_[1] = &vtxB;
_v_[2] = &vtxC;
@@ -355,6 +417,11 @@ static void fx_draw_point_wide_aa ( fxMesaContext fxMesa,
const GLcontext *ctx = fxMesa->glCtx;
const GLfloat psize = (ctx->_TriangleCaps & DD_POINT_ATTEN) ? v0->psize : ctx->Point.Size;
+ if (ctx->Point.PointSprite) {
+ fx_draw_point_sprite(fxMesa, v0, psize);
+ return;
+ }
+
radius = psize / 2.;
n = IROUND(psize * 2); /* radius x 4 */
if (n < 4) n = 4;
@@ -905,27 +972,16 @@ static void fx_render_vb_quads( GLcontext *ctx,
INIT(GL_QUADS);
-#if 1
- /* [dBorca] Hack alert:
- * since VTX-0-2 we get here with start = 0, count = 2,
- * causing around 4 billion triangles. Revise this after
- * a while
- */
- if (count < 3) {
- return;
- }
-#endif
-
- for (i = start ; i < count-3 ; i += 4 ) {
+ for (i = start + 3 ; i < count ; i += 4 ) {
#define VERT(x) (fxVB + (x))
GrVertex *_v_[4];
- _v_[0] = VERT(i+3);
- _v_[1] = VERT(i+0);
- _v_[2] = VERT(i+1);
- _v_[3] = VERT(i+2);
+ _v_[0] = VERT(i);
+ _v_[1] = VERT(i-3);
+ _v_[2] = VERT(i-2);
+ _v_[3] = VERT(i-1);
grDrawVertexArray(GR_TRIANGLE_FAN, 4, _v_);
- /*grDrawTriangle( VERT(i), VERT(i+1), VERT(i+3) );*/
- /*grDrawTriangle( VERT(i+1), VERT(i+2), VERT(i+3) );*/
+ /*grDrawTriangle( VERT(i-3), VERT(i-2), VERT(i) );*/
+ /*grDrawTriangle( VERT(i-2), VERT(i-1), VERT(i) );*/
#undef VERT
}
}
@@ -1092,12 +1148,22 @@ static void fxRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
static void fxFastRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
GLuint n )
{
+ int i;
fxMesaContext fxMesa = FX_CONTEXT( ctx );
GrVertex *vertptr = fxMesa->verts;
- const GrVertex *start = VERT(elts[0]);
- int i;
- for (i = 2 ; i < n ; i++) {
- grDrawTriangle( start, VERT(elts[i-1]), VERT(elts[i]) );
+ if (n == 3) {
+ grDrawTriangle( VERT(elts[0]), VERT(elts[1]), VERT(elts[2]) );
+ } else if (n <= 32) {
+ GrVertex *newvptr[32];
+ for (i = 0 ; i < n ; i++) {
+ newvptr[i] = VERT(elts[i]);
+ }
+ grDrawVertexArray(GR_TRIANGLE_FAN, n, newvptr);
+ } else {
+ const GrVertex *start = VERT(elts[0]);
+ for (i = 2 ; i < n ; i++) {
+ grDrawTriangle( start, VERT(elts[i-1]), VERT(elts[i]) );
+ }
}
}
@@ -1196,7 +1262,7 @@ void fxDDChooseRenderState(GLcontext *ctx)
fx_render_tab_verts[0] = fx_render_pw_verts;
fx_render_tab_elts[0] = fx_render_pw_elts;
}
- tnl->Driver.Render.Points = rast_tab[FX_FALLBACK_BIT].points;
+ tnl->Driver.Render.Points = rast_tab[index|FX_FALLBACK_BIT].points;
} else {
fx_render_tab_verts[0] = fx_render_vb_points;
fx_render_tab_elts[0] = fx_render_points_elts;
@@ -1431,6 +1497,10 @@ void fxDDInitTriFuncs( GLcontext *ctx )
}
+/* [dBorca] Hack alert:
+ * doesn't work with blending.
+ * need to take care of stencil.
+ */
GLboolean fxMultipass_ColorSum (GLcontext *ctx, GLuint pass)
{
fxMesaContext fxMesa = FX_CONTEXT(ctx);