Remove ctx->Point._Size and ctx->Line._Width.

The clamping for these values depends on whether we're drawing AA or non-AA
points, lines.  Defer clamping until drawing time.  Drivers could compute and
keep clamped AA and clamped non-AA values if desired.
This commit is contained in:
Brian
2007-07-21 10:06:18 -06:00
parent 5842bc3bf9
commit af2aa8e9cf
19 changed files with 74 additions and 53 deletions

View File

@@ -380,7 +380,10 @@ static void i810CullFaceFrontFace(GLcontext *ctx, GLenum unused)
static void i810LineWidth( GLcontext *ctx, GLfloat widthf )
{
i810ContextPtr imesa = I810_CONTEXT( ctx );
int width = (int)ctx->Line._Width;
/* AA, non-AA limits are same */
const int width = (int) CLAMP(ctx->Line.Width,
ctx->Const.MinLineWidth,
ctx->Const.MaxLineWidth);
imesa->LcsLineWidth = 0;
if (width & 1) imesa->LcsLineWidth |= LCS_LINEWIDTH_1_0;
@@ -396,7 +399,10 @@ static void i810LineWidth( GLcontext *ctx, GLfloat widthf )
static void i810PointSize( GLcontext *ctx, GLfloat sz )
{
i810ContextPtr imesa = I810_CONTEXT( ctx );
int size = (int)ctx->Point._Size;
/* AA, non-AA limits are same */
const int size = (int) CLAMP(ctx->Point.Size,
ctx->Const.MinPointSize,
ctx->Const.MaxPointSize);
imesa->LcsPointSize = 0;
if (size & 1) imesa->LcsPointSize |= LCS_LINEWIDTH_1_0;

View File

@@ -112,7 +112,9 @@ static __inline__ void i810_draw_quad( i810ContextPtr imesa,
static __inline__ void i810_draw_point( i810ContextPtr imesa,
i810VertexPtr tmp )
{
GLfloat sz = imesa->glCtx->Point._Size * .5;
GLfloat sz = 0.5 * CLAMP(imesa->glCtx->Point.Size,
imesa->glCtx->Const.MinPointSize,
imesa->glCtx->Const.MaxPointSize);
int vertsize = imesa->vertex_size;
GLuint *vb = i810AllocDmaLow( imesa, 2 * 4 * vertsize );
int j;

View File

@@ -173,7 +173,8 @@ static void upload_sf_unit( struct brw_context *brw )
/* _NEW_LINE */
sf.sf6.line_width = brw->attribs.Line->_Width * (1<<1);
/* XXX use ctx->Const.Min/MaxLineWidth here */
sf.sf6.line_width = CLAMP(brw->attribs.Line->Width, 1.0, 5.0) * (1<<1);
sf.sf6.line_endcap_aa_region_width = 1;
if (brw->attribs.Line->SmoothFlag)
@@ -183,7 +184,8 @@ static void upload_sf_unit( struct brw_context *brw )
/* _NEW_POINT */
sf.sf6.point_rast_rule = 1; /* opengl conventions */
sf.sf7.point_size = brw->attribs.Point->_Size * (1<<3);
/* XXX clamp max depends on AA vs. non-AA */
sf.sf7.point_size = CLAMP(brw->attribs.Point->Size, 1.0, 3.0) * (1<<3);
sf.sf7.use_point_size_state = !brw->attribs.Point->_Attenuated;
/* might be BRW_NEW_PRIMITIVE if we have to adjust pv for polygons:

View File

@@ -103,7 +103,7 @@ void TAG(translate_vertex)(GLcontext *ctx,
assert( p + 1 - (CARD32 *)src == 10 );
dst->pointSize = ctx->Point._Size;
dst->pointSize = ctx->Point.Size;
}

View File

@@ -673,7 +673,10 @@ static __inline void mach64_draw_line( mach64ContextPtr mmesa,
#if MACH64_NATIVE_VTXFMT
GLcontext *ctx = mmesa->glCtx;
const GLuint vertsize = mmesa->vertex_size;
GLint width = (GLint)(mmesa->glCtx->Line._Width * 2.0); /* 2 fractional bits for hardware */
/* 2 fractional bits for hardware: */
const int width = (int) (2.0 * CLAMP(mmesa->glCtx->Line.Width,
mmesa->glCtx->Const.MinLineWidth,
mmesa->glCtx->Const.MaxLineWidth));
GLfloat ooa;
GLuint *pxy0, *pxy1;
GLuint xy0old, xy0, xy1old, xy1;
@@ -691,9 +694,6 @@ static __inline void mach64_draw_line( mach64ContextPtr mmesa,
mach64_print_vertex( ctx, v1 );
}
if( !width )
width = 1; /* round to the nearest supported width */
pxy0 = &v0->ui[xyoffset];
xy0old = *pxy0;
xy0 = LE32_IN( &xy0old );
@@ -961,7 +961,10 @@ static __inline void mach64_draw_point( mach64ContextPtr mmesa,
#if MACH64_NATIVE_VTXFMT
GLcontext *ctx = mmesa->glCtx;
const GLuint vertsize = mmesa->vertex_size;
GLint sz = (GLint)(mmesa->glCtx->Point._Size * 2.0); /* 2 fractional bits for hardware */
/* 2 fractional bits for hardware: */
GLint sz = (GLint) (2.0 * CLAMP(mmesa->glCtx->Point.Size,
ctx->Const.MinPointSize,
ctx->Const.MaxPointSize));
GLfloat ooa;
GLuint *pxy;
GLuint xyold, xy;

View File

@@ -104,8 +104,10 @@ static void __inline__ mga_draw_quad( mgaContextPtr mmesa,
static __inline__ void mga_draw_point( mgaContextPtr mmesa,
mgaVertexPtr tmp )
{
GLfloat sz = mmesa->glCtx->Point._Size * .5;
int vertex_size = mmesa->vertex_size;
const GLfloat sz = 0.5 * CLAMP(mmesa->glCtx->Point.Size,
mmesa->glCtx->Const.MinPointSize,
mmesa->glCtx->Const.MaxPointSize);
const int vertex_size = mmesa->vertex_size;
GLuint *vb = mgaAllocDmaLow( mmesa, 6 * 4 * vertex_size );
int j;
@@ -165,7 +167,9 @@ static __inline__ void mga_draw_line( mgaContextPtr mmesa,
GLuint vertex_size = mmesa->vertex_size;
GLuint *vb = mgaAllocDmaLow( mmesa, 6 * 4 * vertex_size );
GLfloat dx, dy, ix, iy;
GLfloat width = mmesa->glCtx->Line._Width;
const GLfloat width = CLAMP(mmesa->glCtx->Line.Width,
mmesa->glCtx->Const.MinLineWidth,
mmesa->glCtx->Const.MaxLineWidth);
GLint j;
#if 0

View File

@@ -772,9 +772,11 @@ static void r200LineWidth( GLcontext *ctx, GLfloat widthf )
R200_STATECHANGE( rmesa, set );
/* Line width is stored in U6.4 format.
* Same min/max limits for AA, non-AA lines.
*/
rmesa->hw.lin.cmd[LIN_SE_LINE_WIDTH] &= ~0xffff;
rmesa->hw.lin.cmd[LIN_SE_LINE_WIDTH] |= (GLuint)(ctx->Line._Width * 16.0);
rmesa->hw.lin.cmd[LIN_SE_LINE_WIDTH] |= (GLuint)
(CLAMP(widthf, ctx->Const.MinLineWidth, ctx->Const.MaxLineWidth) * 16.0);
if ( widthf > 1.0 ) {
rmesa->hw.set.cmd[SET_SE_CNTL] |= R200_WIDELINE_ENABLE;

View File

@@ -733,8 +733,8 @@ static void r300Fogfv(GLcontext * ctx, GLenum pname, const GLfloat * param)
static void r300PointSize(GLcontext * ctx, GLfloat size)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
size = ctx->Point._Size;
/* same size limits for AA, non-AA points */
size = CLAMP(size, ctx->Const.MinPointSize, ctx->Const.MaxPointSize);
R300_STATECHANGE(r300, ps);
r300->hw.ps.cmd[R300_PS_POINTSIZE] =
@@ -749,8 +749,9 @@ static void r300LineWidth(GLcontext * ctx, GLfloat widthf)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
widthf = ctx->Line._Width;
widthf = CLAMP(widthf,
ctx->Const.MinPointSize,
ctx->Const.MaxPointSize);
R300_STATECHANGE(r300, lcntl);
r300->hw.lcntl.cmd[1] =
R300_LINE_CNT_HO | R300_LINE_CNT_VE | (int)(widthf * 6.0);

View File

@@ -131,7 +131,9 @@ static __inline__ void savage_draw_point (savageContextPtr imesa,
u_int32_t *vb = savageAllocVtxBuf (imesa, 6*vertsize);
const GLfloat x = tmp->v.x;
const GLfloat y = tmp->v.y;
const GLfloat sz = imesa->glCtx->Point._Size * .5;
const GLfloat sz = 0.5 * CLAMP(imesa->glCtx->Point.Size,
imesa->glCtx->Const.MinPointSize,
imesa->glCtx->Const.MaxPointSize);
GLuint j;
*(float *)&vb[0] = x - sz;
@@ -164,7 +166,9 @@ static __inline__ void savage_draw_line (savageContextPtr imesa,
savageVertexPtr v1 ) {
GLuint vertsize = imesa->HwVertexSize;
u_int32_t *vb = savageAllocVtxBuf (imesa, 6*vertsize);
GLfloat width = imesa->glCtx->Line._Width;
const GLfloat width = CLAMP(imesa->glCtx->Line.Width,
imesa->glCtx->Const.MinLineWidth,
imesa->glCtx->Const.MaxLineWidth);
GLfloat dx, dy, ix, iy;
GLuint j;
@@ -234,7 +238,9 @@ static __inline__ void savage_ptex_line (savageContextPtr imesa,
savageVertexPtr v1 ) {
GLuint vertsize = imesa->HwVertexSize;
u_int32_t *vb = savageAllocVtxBuf (imesa, 6*vertsize);
GLfloat width = imesa->glCtx->Line._Width;
const GLfloat width = CLAMP(imesa->glCtx->Line.Width,
imesa->glCtx->Const.MinLineWidth,
imesa->glCtx->Const.MaxLineWidth);
GLfloat dx, dy, ix, iy;
savageVertex tmp0, tmp1;
GLuint j;
@@ -281,7 +287,9 @@ static __inline__ void savage_ptex_point (savageContextPtr imesa,
u_int32_t *vb = savageAllocVtxBuf (imesa, 6*vertsize);
const GLfloat x = v0->v.x;
const GLfloat y = v0->v.y;
const GLfloat sz = imesa->glCtx->Point._Size * .5;
const GLfloat sz = 0.5 * CLAMP(imesa->glCtx->Point.Size,
imesa->glCtx->Const.MinPointSize,
imesa->glCtx->Const.MaxPointSize);
savageVertex tmp;
GLuint j;

View File

@@ -184,7 +184,7 @@ tdfx_translate_vertex( GLcontext *ctx, const tdfxVertex *src, SWvertex *dst)
}
}
dst->pointSize = ctx->Point._Size;
dst->pointSize = ctx->Point.Size;
}

View File

@@ -55,9 +55,6 @@ _mesa_LineWidth( GLfloat width )
FLUSH_VERTICES(ctx, _NEW_LINE);
ctx->Line.Width = width;
ctx->Line._Width = CLAMP(width,
ctx->Const.MinLineWidth,
ctx->Const.MaxLineWidth);
if (ctx->Driver.LineWidth)
ctx->Driver.LineWidth(ctx, width);
@@ -105,13 +102,12 @@ _mesa_LineStipple( GLint factor, GLushort pattern )
* Initializes __GLcontextRec::Line and line related constants in
* __GLcontextRec::Const.
*/
void GLAPIENTRY _mesa_init_line( GLcontext * ctx )
void GLAPIENTRY
_mesa_init_line( GLcontext * ctx )
{
/* Line group */
ctx->Line.SmoothFlag = GL_FALSE;
ctx->Line.StippleFlag = GL_FALSE;
ctx->Line.Width = 1.0;
ctx->Line._Width = 1.0;
ctx->Line.StipplePattern = 0xffff;
ctx->Line.StippleFactor = 1;
}

View File

@@ -917,7 +917,6 @@ struct gl_line_attrib
GLushort StipplePattern; /**< Stipple pattern */
GLint StippleFactor; /**< Stipple repeat factor */
GLfloat Width; /**< Line width */
GLfloat _Width; /**< Clamped Line width */
};
@@ -1063,7 +1062,6 @@ struct gl_point_attrib
{
GLboolean SmoothFlag; /**< True if GL_POINT_SMOOTH is enabled */
GLfloat Size; /**< User-specified point size */
GLfloat _Size; /**< Size clamped to Const.Min/MaxPointSize */
GLfloat Params[3]; /**< GL_EXT_point_parameters */
GLfloat MinSize, MaxSize; /**< GL_EXT_point_parameters */
GLfloat Threshold; /**< GL_EXT_point_parameters */

View File

@@ -57,10 +57,6 @@ _mesa_PointSize( GLfloat size )
FLUSH_VERTICES(ctx, _NEW_POINT);
ctx->Point.Size = size;
/* XXX correct clamp limits? */
ctx->Point._Size = CLAMP(ctx->Point.Size,
ctx->Point.MinSize,
ctx->Point.MaxSize);
if (ctx->Driver.PointSize)
ctx->Driver.PointSize(ctx, size);
@@ -253,7 +249,6 @@ _mesa_init_point(GLcontext *ctx)
ctx->Point.SmoothFlag = GL_FALSE;
ctx->Point.Size = 1.0;
ctx->Point._Size = 1.0;
ctx->Point.Params[0] = 1.0;
ctx->Point.Params[1] = 0.0;
ctx->Point.Params[2] = 0.0;

View File

@@ -1068,7 +1068,7 @@ update_tricaps(GLcontext *ctx, GLbitfield new_state)
if (1/*new_state & _NEW_POINT*/) {
if (ctx->Point.SmoothFlag)
ctx->_TriangleCaps |= DD_POINT_SMOOTH;
if (ctx->Point._Size != 1.0F)
if (ctx->Point.Size != 1.0F)
ctx->_TriangleCaps |= DD_POINT_SIZE;
if (ctx->Point._Attenuated)
ctx->_TriangleCaps |= DD_POINT_ATTEN;
@@ -1082,7 +1082,7 @@ update_tricaps(GLcontext *ctx, GLbitfield new_state)
ctx->_TriangleCaps |= DD_LINE_SMOOTH;
if (ctx->Line.StippleFlag)
ctx->_TriangleCaps |= DD_LINE_STIPPLE;
if (ctx->Line._Width != 1.0)
if (ctx->Line.Width != 1.0)
ctx->_TriangleCaps |= DD_LINE_WIDTH;
}

View File

@@ -132,7 +132,9 @@ NAME(line)(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1)
line.dx = line.x1 - line.x0;
line.dy = line.y1 - line.y0;
line.len = SQRTF(line.dx * line.dx + line.dy * line.dy);
line.halfWidth = 0.5F * ctx->Line._Width;
line.halfWidth = 0.5F * CLAMP(ctx->Line.Width,
ctx->Const.MinLineWidthAA,
ctx->Const.MaxLineWidthAA);
if (line.len == 0.0 || IS_INF_OR_NAN(line.len))
return;

View File

@@ -63,12 +63,13 @@ compute_stipple_mask( GLcontext *ctx, GLuint len, GLubyte mask[] )
static void
draw_wide_line( GLcontext *ctx, SWspan *span, GLboolean xMajor )
{
GLint width, start;
const GLint width = (GLint) CLAMP(ctx->Line.Width,
ctx->Const.MinLineWidth,
ctx->Const.MaxLineWidth);
GLint start;
ASSERT(span->end < MAX_WIDTH);
width = (GLint) CLAMP( ctx->Line._Width, MIN_LINE_WIDTH, MAX_LINE_WIDTH );
if (width & 1)
start = width / 2;
else
@@ -143,7 +144,7 @@ draw_wide_line( GLcontext *ctx, SWspan *span, GLboolean xMajor )
span.arrayMask |= SPAN_MASK; \
compute_stipple_mask(ctx, span.end, span.array->mask); \
} \
if (ctx->Line._Width > 1.0) { \
if (ctx->Line.Width > 1.0) { \
draw_wide_line(ctx, &span, (GLboolean)(dx > dy)); \
} \
else { \
@@ -161,7 +162,7 @@ draw_wide_line( GLcontext *ctx, SWspan *span, GLboolean xMajor )
span.arrayMask |= SPAN_MASK; \
compute_stipple_mask(ctx, span.end, span.array->mask); \
} \
if (ctx->Line._Width > 1.0) { \
if (ctx->Line.Width > 1.0) { \
draw_wide_line(ctx, &span, (GLboolean)(dx > dy)); \
} \
else { \
@@ -180,7 +181,7 @@ draw_wide_line( GLcontext *ctx, SWspan *span, GLboolean xMajor )
span.arrayMask |= SPAN_MASK; \
compute_stipple_mask(ctx, span.end, span.array->mask); \
} \
if (ctx->Line._Width > 1.0) { \
if (ctx->Line.Width > 1.0) { \
draw_wide_line(ctx, &span, (GLboolean)(dx > dy)); \
} \
else { \
@@ -274,7 +275,7 @@ _swrast_choose_line( GLcontext *ctx )
USE(general_line);
}
else if (ctx->Depth.Test
|| ctx->Line._Width != 1.0
|| ctx->Line.Width != 1.0
|| ctx->Line.StippleFlag) {
/* no texture, but Z, fog, width>1, stipple, etc. */
if (rgbmode)
@@ -284,6 +285,7 @@ _swrast_choose_line( GLcontext *ctx )
}
else {
ASSERT(!ctx->Depth.Test);
ASSERT(ctx->Line.Width == 1.0);
/* simple lines */
if (rgbmode)
USE(simple_no_z_rgba_line);

View File

@@ -76,7 +76,7 @@ sprite_point(GLcontext *ctx, const SWvertex *vert)
}
else {
/* use constant point size */
size = ctx->Point._Size; /* already clamped to user range */
size = ctx->Point.Size;
}
/* clamp to non-AA implementation limits */
size = CLAMP(size, ctx->Const.MinPointSize, ctx->Const.MaxPointSize);
@@ -227,7 +227,7 @@ smooth_point(GLcontext *ctx, const SWvertex *vert)
}
else {
/* use constant point size */
size = ctx->Point._Size; /* this is already clamped */
size = ctx->Point.Size;
}
/* clamp to AA implementation limits */
size = CLAMP(size, ctx->Const.MinPointSizeAA, ctx->Const.MaxPointSizeAA);
@@ -361,7 +361,7 @@ large_point(GLcontext *ctx, const SWvertex *vert)
}
else {
/* use constant point size */
size = ctx->Point._Size; /* already clamped to user range */
size = ctx->Point.Size;
}
/* clamp to non-AA implementation limits */
size = CLAMP(size, ctx->Const.MinPointSize, ctx->Const.MaxPointSize);
@@ -550,7 +550,7 @@ _swrast_choose_point(GLcontext *ctx)
else if (ctx->Point.SmoothFlag) {
swrast->Point = smooth_point;
}
else if (ctx->Point._Size > 1.0 ||
else if (ctx->Point.Size > 1.0 ||
ctx->Point._Attenuated ||
ctx->VertexProgram.PointSizeEnabled) {
swrast->Point = large_point;

View File

@@ -233,7 +233,7 @@ void _tnl_get_attr( GLcontext *ctx, const void *vin,
/* If the hardware vertex doesn't have point size then use size from
* GLcontext. XXX this will be wrong if drawing attenuated points!
*/
dest[0] = ctx->Point._Size;
dest[0] = ctx->Point.Size;
}
else {
_mesa_memcpy( dest, ctx->Current.Attrib[attr], 4*sizeof(GLfloat));

View File

@@ -184,7 +184,7 @@ void TAG(translate_vertex)(GLcontext *ctx,
}
}
dst->pointSize = ctx->Point._Size;
dst->pointSize = ctx->Point.Size;
}