fix span->facing computation and gl_FrontFacing initialization
This commit is contained in:
@@ -120,7 +120,7 @@ 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] = (GLfloat) span->facing;
|
||||
machine->Attribs[FRAG_ATTRIB_FOGC][col][1] = 1.0 - span->facing;
|
||||
}
|
||||
|
||||
machine->CurElement = col;
|
||||
|
@@ -136,7 +136,7 @@ static void NAME(GLcontext *ctx, const SWvertex *v0,
|
||||
EdgeT eMaj, eTop, eBot;
|
||||
GLfloat oneOverArea;
|
||||
const SWvertex *vMin, *vMid, *vMax; /* Y(vMin)<=Y(vMid)<=Y(vMax) */
|
||||
GLfloat bf = SWRAST_CONTEXT(ctx)->_BackfaceCullSign;
|
||||
GLfloat bf = SWRAST_CONTEXT(ctx)->_BackfaceSign;
|
||||
const GLint snapMask = ~((FIXED_ONE / (1 << SUB_PIXEL_BITS)) - 1); /* for x/y coord snapping */
|
||||
GLfixed vMin_fx, vMin_fy, vMid_fx, vMid_fy, vMax_fx, vMax_fy;
|
||||
|
||||
@@ -234,18 +234,17 @@ static void NAME(GLcontext *ctx, const SWvertex *v0,
|
||||
/* compute area, oneOverArea and perform backface culling */
|
||||
{
|
||||
const GLfloat area = eMaj.dx * eBot.dy - eBot.dx * eMaj.dy;
|
||||
/* Do backface culling */
|
||||
|
||||
if (area * bf < 0.0)
|
||||
return;
|
||||
|
||||
if (IS_INF_OR_NAN(area) || area == 0.0F)
|
||||
return;
|
||||
|
||||
if (area * bf * swrast->_BackfaceCullSign < 0.0)
|
||||
return;
|
||||
|
||||
oneOverArea = 1.0F / area;
|
||||
|
||||
/* 0 = front, 1 = back */
|
||||
span.facing = oneOverArea * swrast->_BackfaceSign > 0.0F;
|
||||
span.facing = oneOverArea * bf > 0.0F;
|
||||
}
|
||||
|
||||
/* Edge setup. For a triangle strip these could be reused... */
|
||||
|
Reference in New Issue
Block a user