From bf80e1ed620836e2ca0dd3f7d2d4cb187d17563d Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 19 Apr 2002 14:05:50 +0000 Subject: Allocate a sw_span struct in the swrast context instead of allocating it on the stack frame in the point/line/triangle functions. (Klaus Niederkrueger) This should solve the performance problem Karl found on Windows. --- src/mesa/swrast/s_copypix.c | 142 +++++++++++++++++++++----------------------- 1 file changed, 69 insertions(+), 73 deletions(-) (limited to 'src/mesa/swrast/s_copypix.c') diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c index d784471827..bea0af4883 100644 --- a/src/mesa/swrast/s_copypix.c +++ b/src/mesa/swrast/s_copypix.c @@ -1,4 +1,4 @@ -/* $Id: s_copypix.c,v 1.36 2002/04/19 00:38:27 brianp Exp $ */ +/* $Id: s_copypix.c,v 1.37 2002/04/19 14:05:50 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -107,15 +107,14 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F; const GLuint transferOps = ctx->_ImageTransferState; GLfloat *dest, *tmpImage, *convImage; - struct sw_span span; + struct sw_span *span = swrast->span; INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_RGBA); - /*span.arrayMask |= SPAN_RGBA;*/ if (ctx->Depth.Test) - _mesa_span_default_z(ctx, &span); + _mesa_span_default_z(ctx, span); if (ctx->Fog.Enabled) - _mesa_span_default_fog(ctx, &span); + _mesa_span_default_fog(ctx, span); if (SWRAST_CONTEXT(ctx)->_RasterMask == 0 @@ -252,15 +251,15 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, GLint g = (GLint) (src[i * 4 + GCOMP] * CHAN_MAXF); GLint b = (GLint) (src[i * 4 + BCOMP] * CHAN_MAXF); GLint a = (GLint) (src[i * 4 + ACOMP] * CHAN_MAXF); - span.color.rgba[i][RCOMP] = (GLchan) CLAMP(r, 0, CHAN_MAX); - span.color.rgba[i][GCOMP] = (GLchan) CLAMP(g, 0, CHAN_MAX); - span.color.rgba[i][BCOMP] = (GLchan) CLAMP(b, 0, CHAN_MAX); - span.color.rgba[i][ACOMP] = (GLchan) CLAMP(a, 0, CHAN_MAX); + span->color.rgba[i][RCOMP] = (GLchan) CLAMP(r, 0, CHAN_MAX); + span->color.rgba[i][GCOMP] = (GLchan) CLAMP(g, 0, CHAN_MAX); + span->color.rgba[i][BCOMP] = (GLchan) CLAMP(b, 0, CHAN_MAX); + span->color.rgba[i][ACOMP] = (GLchan) CLAMP(a, 0, CHAN_MAX); } if (ctx->Pixel.PixelTextureEnabled && ctx->Texture._ReallyEnabled) { - span.end = width; - _swrast_pixel_texture(ctx, &span); + span->end = width; + _swrast_pixel_texture(ctx, span); } /* write row to framebuffer */ @@ -268,21 +267,21 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, dy = desty + row; if (quick_draw && dy >= 0 && dy < (GLint) ctx->DrawBuffer->Height) { (*swrast->Driver.WriteRGBASpan)( ctx, width, destx, dy, - (const GLchan (*)[4])span.color.rgba, NULL ); + (const GLchan (*)[4])span->color.rgba, NULL ); } else if (zoom) { - span.x = destx; - span.y = dy; - span.end = width; - _mesa_write_zoomed_rgba_span(ctx, &span, - (CONST GLchan (*)[4])span.color.rgba, + span->x = destx; + span->y = dy; + span->end = width; + _mesa_write_zoomed_rgba_span(ctx, span, + (CONST GLchan (*)[4])span->color.rgba, desty); } else { - span.x = destx; - span.y = dy; - span.end = width; - _mesa_write_rgba_span(ctx, &span); + span->x = destx; + span->y = dy; + span->end = width; + _mesa_write_rgba_span(ctx, span); } } @@ -306,10 +305,9 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F; GLint overlapping; const GLuint transferOps = ctx->_ImageTransferState; - struct sw_span span; + struct sw_span *span = swrast->span; INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_RGBA); - /*span.arrayMask |= SPAN_RGBA;*/ if (ctx->Pixel.Convolution2DEnabled || ctx->Pixel.Separable2DEnabled) { copy_conv_rgba_pixels(ctx, srcx, srcy, width, height, destx, desty); @@ -334,9 +332,9 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, ctx->Pixel.ZoomX, ctx->Pixel.ZoomY); if (ctx->Depth.Test) - _mesa_span_default_z(ctx, &span); + _mesa_span_default_z(ctx, span); if (ctx->Fog.Enabled) - _mesa_span_default_fog(ctx, &span); + _mesa_span_default_fog(ctx, span); if (SWRAST_CONTEXT(ctx)->_RasterMask == 0 && !zoom @@ -392,7 +390,7 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, /* Get source pixels */ if (overlapping) { /* get from buffered image */ - MEMCPY(span.color.rgba, p, width * sizeof(GLchan) * 4); + MEMCPY(span->color.rgba, p, width * sizeof(GLchan) * 4); p += width * 4; } else { @@ -413,7 +411,7 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, ctx->ReadBuffer->Alpha = ctx->ReadBuffer->BackRightAlpha; } } - _mesa_read_rgba_span( ctx, ctx->ReadBuffer, width, srcx, sy, span.color.rgba ); + _mesa_read_rgba_span( ctx, ctx->ReadBuffer, width, srcx, sy, span->color.rgba ); } if (changeBuffer) { @@ -431,10 +429,10 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, /* convert chan to float */ for (k = 0; k < width; k++) { - rgbaFloat[k][RCOMP] = (GLfloat) span.color.rgba[k][RCOMP] * scale; - rgbaFloat[k][GCOMP] = (GLfloat) span.color.rgba[k][GCOMP] * scale; - rgbaFloat[k][BCOMP] = (GLfloat) span.color.rgba[k][BCOMP] * scale; - rgbaFloat[k][ACOMP] = (GLfloat) span.color.rgba[k][ACOMP] * scale; + rgbaFloat[k][RCOMP] = (GLfloat) span->color.rgba[k][RCOMP] * scale; + rgbaFloat[k][GCOMP] = (GLfloat) span->color.rgba[k][GCOMP] * scale; + rgbaFloat[k][BCOMP] = (GLfloat) span->color.rgba[k][BCOMP] * scale; + rgbaFloat[k][ACOMP] = (GLfloat) span->color.rgba[k][ACOMP] * scale; } /* scale & bias */ if (transferOps & IMAGE_SCALE_BIAS_BIT) { @@ -494,36 +492,36 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, GLint g = (GLint) (rgbaFloat[k][GCOMP] * CHAN_MAXF); GLint b = (GLint) (rgbaFloat[k][BCOMP] * CHAN_MAXF); GLint a = (GLint) (rgbaFloat[k][ACOMP] * CHAN_MAXF); - span.color.rgba[k][RCOMP] = (GLchan) CLAMP(r, 0, CHAN_MAX); - span.color.rgba[k][GCOMP] = (GLchan) CLAMP(g, 0, CHAN_MAX); - span.color.rgba[k][BCOMP] = (GLchan) CLAMP(b, 0, CHAN_MAX); - span.color.rgba[k][ACOMP] = (GLchan) CLAMP(a, 0, CHAN_MAX); + span->color.rgba[k][RCOMP] = (GLchan) CLAMP(r, 0, CHAN_MAX); + span->color.rgba[k][GCOMP] = (GLchan) CLAMP(g, 0, CHAN_MAX); + span->color.rgba[k][BCOMP] = (GLchan) CLAMP(b, 0, CHAN_MAX); + span->color.rgba[k][ACOMP] = (GLchan) CLAMP(a, 0, CHAN_MAX); } UNDEFARRAY(rgbaFloat); /* mac 32k limitation */ } if (ctx->Pixel.PixelTextureEnabled && ctx->Texture._ReallyEnabled) { - span.end = width; - _swrast_pixel_texture(ctx, &span); + span->end = width; + _swrast_pixel_texture(ctx, span); } if (quick_draw && dy >= 0 && dy < (GLint) ctx->DrawBuffer->Height) { (*swrast->Driver.WriteRGBASpan)( ctx, width, destx, dy, - (const GLchan (*)[4])span.color.rgba, NULL ); + (const GLchan (*)[4])span->color.rgba, NULL ); } else if (zoom) { - span.x = destx; - span.y = dy; - span.end = width; - _mesa_write_zoomed_rgba_span(ctx, &span, - (CONST GLchan (*)[4]) span.color.rgba, + span->x = destx; + span->y = dy; + span->end = width; + _mesa_write_zoomed_rgba_span(ctx, span, + (CONST GLchan (*)[4]) span->color.rgba, desty); } else { - span.x = destx; - span.y = dy; - span.end = width; - _mesa_write_rgba_span(ctx, &span); + span->x = destx; + span->y = dy; + span->end = width; + _mesa_write_rgba_span(ctx, span); } } @@ -548,10 +546,9 @@ static void copy_ci_pixels( GLcontext *ctx, const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F; const GLboolean shift_or_offset = ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset; GLint overlapping; - struct sw_span span; + struct sw_span *span = swrast->span; INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_INDEX); - /*span.arrayMask |= SPAN_INDEX;*/ /* Determine if copy should be bottom-to-top or top-to-bottom */ if (srcyPixel.ZoomX, ctx->Pixel.ZoomY); if (ctx->Depth.Test) - _mesa_span_default_z(ctx, &span); + _mesa_span_default_z(ctx, span); if (ctx->Fog.Enabled) - _mesa_span_default_fog(ctx, &span); + _mesa_span_default_fog(ctx, span); /* If read and draw buffer are different we must do buffer switching */ changeBuffer = ctx->Pixel.ReadBuffer != ctx->Color.DrawBuffer @@ -607,7 +604,7 @@ static void copy_ci_pixels( GLcontext *ctx, for (j = 0; j < height; j++, sy += stepy, dy += stepy) { if (overlapping) { - MEMCPY(span.color.index, p, width * sizeof(GLuint)); + MEMCPY(span->color.index, p, width * sizeof(GLuint)); p += width; } else { @@ -616,7 +613,7 @@ static void copy_ci_pixels( GLcontext *ctx, ctx->Pixel.DriverReadBuffer ); } _mesa_read_index_span( ctx, ctx->ReadBuffer, width, srcx, sy, - span.color.index ); + span->color.index ); } if (changeBuffer) { @@ -626,19 +623,19 @@ static void copy_ci_pixels( GLcontext *ctx, } if (shift_or_offset) { - _mesa_shift_and_offset_ci( ctx, width, span.color.index ); + _mesa_shift_and_offset_ci( ctx, width, span->color.index ); } if (ctx->Pixel.MapColorFlag) { - _mesa_map_ci( ctx, width, span.color.index ); + _mesa_map_ci( ctx, width, span->color.index ); } - span.x = destx; - span.y = dy; - span.end = width; + span->x = destx; + span->y = dy; + span->end = width; if (zoom) - _mesa_write_zoomed_index_span(ctx, &span, desty); + _mesa_write_zoomed_index_span(ctx, span, desty); else - _mesa_write_index_span(ctx, &span); + _mesa_write_index_span(ctx, span); } /* Restore pixel source to be the draw buffer (for blending, etc) */ @@ -664,10 +661,9 @@ static void copy_depth_pixels( GLcontext *ctx, GLint srcx, GLint srcy, GLint i, j; const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F; GLint overlapping; - struct sw_span span; + struct sw_span *span = SWRAST_CONTEXT(ctx)->span; INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_Z); - /*span.arrayMask |= SPAN_Z;*/ if (!ctx->Visual.depthBits) { _mesa_error( ctx, GL_INVALID_OPERATION, "glCopyPixels" ); @@ -691,9 +687,9 @@ static void copy_depth_pixels( GLcontext *ctx, GLint srcx, GLint srcy, overlapping = regions_overlap(srcx, srcy, destx, desty, width, height, ctx->Pixel.ZoomX, ctx->Pixel.ZoomY); - _mesa_span_default_color(ctx, &span); + _mesa_span_default_color(ctx, span); if (ctx->Fog.Enabled) - _mesa_span_default_fog(ctx, &span); + _mesa_span_default_fog(ctx, span); if (overlapping) { GLint ssy = sy; @@ -725,25 +721,25 @@ static void copy_depth_pixels( GLcontext *ctx, GLint srcx, GLint srcy, for (i = 0; i < width; i++) { GLfloat d = depth[i] * ctx->Pixel.DepthScale + ctx->Pixel.DepthBias; - span.zArray[i] = (GLdepth) (CLAMP(d, 0.0F, 1.0F) * ctx->DepthMax); + span->zArray[i] = (GLdepth) (CLAMP(d, 0.0F, 1.0F) * ctx->DepthMax); } - span.x = destx; - span.y = dy; - span.end = width; + span->x = destx; + span->y = dy; + span->end = width; if (ctx->Visual.rgbMode) { if (zoom) - _mesa_write_zoomed_rgba_span( ctx, &span, - (const GLchan (*)[4])span.color.rgba, + _mesa_write_zoomed_rgba_span( ctx, span, + (const GLchan (*)[4])span->color.rgba, desty ); else - _mesa_write_rgba_span(ctx, &span); + _mesa_write_rgba_span(ctx, span); } else { if (zoom) - _mesa_write_zoomed_index_span( ctx, &span, desty ); + _mesa_write_zoomed_index_span( ctx, span, desty ); else - _mesa_write_index_span(ctx, &span); + _mesa_write_index_span(ctx, span); } } -- cgit v1.2.3