From 9d0b8d72d8d704ff4d8e10448b60cbb42f07eecb Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 29 Jul 2009 20:07:41 -0600 Subject: mesa: add new FRAG_ATTRIB_FACE and FRAG_ATTRIB_PNTC fragment program inputs Previously, the FOGC attribute contained the fragment fog coord, front/back- face flag and the gl_PointCoord.xy values. Now each of those things are separate fragment program attributes. This simplifies quite a few things in Mesa and gallium. Need to test i965 driver and fix up point coord handling in the gallium/draw module... --- src/mesa/swrast/s_fragprog.c | 5 ++--- src/mesa/swrast/s_points.c | 26 ++++++++++++-------------- 2 files changed, 14 insertions(+), 17 deletions(-) (limited to 'src/mesa/swrast') diff --git a/src/mesa/swrast/s_fragprog.c b/src/mesa/swrast/s_fragprog.c index b71fb9eae9..613a91b0ec 100644 --- a/src/mesa/swrast/s_fragprog.c +++ b/src/mesa/swrast/s_fragprog.c @@ -157,9 +157,8 @@ init_machine(GLcontext *ctx, struct gl_program_machine *machine, /* if running a GLSL program (not ARB_fragment_program) */ if (ctx->Shader.CurrentProgram) { - /* Store front/back facing value in register FOGC.Y */ - machine->Attribs[FRAG_ATTRIB_FOGC][col][1] = 1.0 - span->facing; - /* Note FOGC.ZW is gl_PointCoord if drawing a sprite */ + /* Store front/back facing value */ + machine->Attribs[FRAG_ATTRIB_FACE][col][0] = 1.0 - span->facing; } machine->CurElement = col; diff --git a/src/mesa/swrast/s_points.c b/src/mesa/swrast/s_points.c index 0a3ad97a71..64c9cda516 100644 --- a/src/mesa/swrast/s_points.c +++ b/src/mesa/swrast/s_points.c @@ -139,7 +139,8 @@ sprite_point(GLcontext *ctx, const SWvertex *vert) } ATTRIB_LOOP_BEGIN - if (attr >= FRAG_ATTRIB_TEX0 && attr < FRAG_ATTRIB_VAR0) { + if ((attr >= FRAG_ATTRIB_TEX0 && attr <= FRAG_ATTRIB_TEX7) || + attr >= FRAG_ATTRIB_VAR0) { const GLuint u = attr - FRAG_ATTRIB_TEX0; /* a texcoord */ if (ctx->Point.CoordReplace[u]) { @@ -170,15 +171,15 @@ sprite_point(GLcontext *ctx, const SWvertex *vert) continue; } } - else if (attr == FRAG_ATTRIB_FOGC) { - /* GLSL gl_PointCoord is stored in fog.zw */ - span.attrStart[FRAG_ATTRIB_FOGC][2] = 0.0; - span.attrStart[FRAG_ATTRIB_FOGC][3] = 0.0; /* t0 set below */ - span.attrStepX[FRAG_ATTRIB_FOGC][2] = dsdx; - span.attrStepX[FRAG_ATTRIB_FOGC][3] = 0.0; - span.attrStepY[FRAG_ATTRIB_FOGC][2] = 0.0; - span.attrStepY[FRAG_ATTRIB_FOGC][3] = dtdy; - tCoords[numTcoords++] = FRAG_ATTRIB_FOGC; + else if (attr == FRAG_ATTRIB_PNTC) { + /* GLSL gl_PointCoord.xy (.zw undefined) */ + span.attrStart[FRAG_ATTRIB_PNTC][0] = 0.0; + span.attrStart[FRAG_ATTRIB_PNTC][1] = 0.0; /* t0 set below */ + span.attrStepX[FRAG_ATTRIB_PNTC][0] = dsdx; + span.attrStepX[FRAG_ATTRIB_PNTC][1] = 0.0; + span.attrStepY[FRAG_ATTRIB_PNTC][0] = 0.0; + span.attrStepY[FRAG_ATTRIB_PNTC][1] = dtdy; + tCoords[numTcoords++] = FRAG_ATTRIB_PNTC; continue; } /* use vertex's texcoord/attrib */ @@ -221,10 +222,7 @@ sprite_point(GLcontext *ctx, const SWvertex *vert) GLuint i; /* setup texcoord T for this row */ for (i = 0; i < numTcoords; i++) { - if (tCoords[i] == FRAG_ATTRIB_FOGC) - span.attrStart[FRAG_ATTRIB_FOGC][3] = tcoord; - else - span.attrStart[tCoords[i]][1] = tcoord; + span.attrStart[tCoords[i]][1] = tcoord; } /* these might get changed by span clipping */ -- cgit v1.2.3 From f7618f4f37d42461b1a6feaa392935d1ae703873 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 31 Jul 2009 13:57:03 -0600 Subject: swrast: fix incorrect texcoord attribute test --- src/mesa/swrast/s_points.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/mesa/swrast') diff --git a/src/mesa/swrast/s_points.c b/src/mesa/swrast/s_points.c index 64c9cda516..50ec2063a5 100644 --- a/src/mesa/swrast/s_points.c +++ b/src/mesa/swrast/s_points.c @@ -139,10 +139,10 @@ sprite_point(GLcontext *ctx, const SWvertex *vert) } ATTRIB_LOOP_BEGIN - if ((attr >= FRAG_ATTRIB_TEX0 && attr <= FRAG_ATTRIB_TEX7) || - attr >= FRAG_ATTRIB_VAR0) { + if (attr >= FRAG_ATTRIB_TEX0 && attr <= FRAG_ATTRIB_TEX7) { + /* a texcoord attribute */ const GLuint u = attr - FRAG_ATTRIB_TEX0; - /* a texcoord */ + ASSERT(u < Elements(ctx->Point.CoordReplace)); if (ctx->Point.CoordReplace[u]) { tCoords[numTcoords++] = attr; -- cgit v1.2.3