summaryrefslogtreecommitdiff
path: root/src/mesa/swrast/s_drawpix.c
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2002-04-19 14:05:50 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2002-04-19 14:05:50 +0000
commitbf80e1ed620836e2ca0dd3f7d2d4cb187d17563d (patch)
tree8666b72f2ff74ac9499d2f9668212fcf4f2e3f5b /src/mesa/swrast/s_drawpix.c
parent05be7ae1253ad68d80816395c3d09665e5619ebc (diff)
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.
Diffstat (limited to 'src/mesa/swrast/s_drawpix.c')
-rw-r--r--src/mesa/swrast/s_drawpix.c223
1 files changed, 109 insertions, 114 deletions
diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c
index 82998ba57c..e0e6e7868d 100644
--- a/src/mesa/swrast/s_drawpix.c
+++ b/src/mesa/swrast/s_drawpix.c
@@ -1,4 +1,4 @@
-/* $Id: s_drawpix.c,v 1.32 2002/04/12 15:39:59 brianp Exp $ */
+/* $Id: s_drawpix.c,v 1.33 2002/04/19 14:05:50 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -102,19 +102,18 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
const struct gl_pixelstore_attrib *unpack = &ctx->Unpack;
- 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->Current.RasterPosValid) {
return GL_TRUE; /* no-op */
}
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 & ~CLIP_BIT) == 0
&& ctx->Texture._ReallyEnabled == 0
@@ -238,10 +237,10 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
/* with zooming */
GLint row;
for (row=0; row<drawHeight; row++) {
- span.x = destX;
- span.y = destY;
- span.end = drawWidth;
- _mesa_write_zoomed_rgba_span(ctx, &span,
+ span->x = destX;
+ span->y = destY;
+ span->end = drawWidth;
+ _mesa_write_zoomed_rgba_span(ctx, span,
(CONST GLchan (*)[4]) src, zoomY0);
src += rowLength * 4;
destY++;
@@ -278,10 +277,10 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
/* with zooming */
GLint row;
for (row=0; row<drawHeight; row++) {
- span.x = destX;
- span.y = destY;
- span.end = drawWidth;
- _mesa_write_zoomed_rgb_span(ctx, &span,
+ span->x = destX;
+ span->y = destY;
+ span->end = drawWidth;
+ _mesa_write_zoomed_rgb_span(ctx, span,
(CONST GLchan (*)[3]) src, zoomY0);
src += rowLength * 3;
destY++;
@@ -302,12 +301,12 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
for (row=0; row<drawHeight; row++) {
GLint i;
for (i=0;i<drawWidth;i++) {
- span.color.rgb[i][0] = src[i];
- span.color.rgb[i][1] = src[i];
- span.color.rgb[i][2] = src[i];
+ span->color.rgb[i][0] = src[i];
+ span->color.rgb[i][1] = src[i];
+ span->color.rgb[i][2] = src[i];
}
(*swrast->Driver.WriteRGBSpan)(ctx, drawWidth, destX, destY,
- (CONST GLchan (*)[3]) span.color.rgb, NULL);
+ (CONST GLchan (*)[3]) span->color.rgb, NULL);
src += rowLength;
destY++;
}
@@ -319,13 +318,13 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
for (row=0; row<drawHeight; row++) {
GLint i;
for (i=0;i<drawWidth;i++) {
- span.color.rgb[i][0] = src[i];
- span.color.rgb[i][1] = src[i];
- span.color.rgb[i][2] = src[i];
+ span->color.rgb[i][0] = src[i];
+ span->color.rgb[i][1] = src[i];
+ span->color.rgb[i][2] = src[i];
}
destY--;
(*swrast->Driver.WriteRGBSpan)(ctx, drawWidth, destX, destY,
- (CONST GLchan (*)[3]) span.color.rgb, NULL);
+ (CONST GLchan (*)[3]) span->color.rgb, NULL);
src += rowLength;
}
}
@@ -336,15 +335,15 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
for (row=0; row<drawHeight; row++) {
GLint i;
for (i=0;i<drawWidth;i++) {
- span.color.rgb[i][0] = src[i];
- span.color.rgb[i][1] = src[i];
- span.color.rgb[i][2] = src[i];
+ span->color.rgb[i][0] = src[i];
+ span->color.rgb[i][1] = src[i];
+ span->color.rgb[i][2] = src[i];
}
- span.x = destX;
- span.y = destY;
- span.end = drawWidth;
- _mesa_write_zoomed_rgb_span(ctx, &span,
- (CONST GLchan (*)[3]) span.color.rgb, zoomY0);
+ span->x = destX;
+ span->y = destY;
+ span->end = drawWidth;
+ _mesa_write_zoomed_rgb_span(ctx, span,
+ (CONST GLchan (*)[3]) span->color.rgb, zoomY0);
src += rowLength;
destY++;
}
@@ -365,13 +364,13 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
GLint i;
GLchan *ptr = src;
for (i=0;i<drawWidth;i++) {
- span.color.rgba[i][0] = *ptr;
- span.color.rgba[i][1] = *ptr;
- span.color.rgba[i][2] = *ptr++;
- span.color.rgba[i][3] = *ptr++;
+ span->color.rgba[i][0] = *ptr;
+ span->color.rgba[i][1] = *ptr;
+ span->color.rgba[i][2] = *ptr++;
+ span->color.rgba[i][3] = *ptr++;
}
(*swrast->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY,
- (CONST GLchan (*)[4]) span.color.rgba, NULL);
+ (CONST GLchan (*)[4]) span->color.rgba, NULL);
src += rowLength*2;
destY++;
}
@@ -384,14 +383,14 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
GLint i;
GLchan *ptr = src;
for (i=0;i<drawWidth;i++) {
- span.color.rgba[i][0] = *ptr;
- span.color.rgba[i][1] = *ptr;
- span.color.rgba[i][2] = *ptr++;
- span.color.rgba[i][3] = *ptr++;
+ span->color.rgba[i][0] = *ptr;
+ span->color.rgba[i][1] = *ptr;
+ span->color.rgba[i][2] = *ptr++;
+ span->color.rgba[i][3] = *ptr++;
}
destY--;
(*swrast->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY,
- (CONST GLchan (*)[4]) span.color.rgba, NULL);
+ (CONST GLchan (*)[4]) span->color.rgba, NULL);
src += rowLength*2;
}
}
@@ -403,16 +402,16 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
GLchan *ptr = src;
GLint i;
for (i=0;i<drawWidth;i++) {
- span.color.rgba[i][0] = *ptr;
- span.color.rgba[i][1] = *ptr;
- span.color.rgba[i][2] = *ptr++;
- span.color.rgba[i][3] = *ptr++;
+ span->color.rgba[i][0] = *ptr;
+ span->color.rgba[i][1] = *ptr;
+ span->color.rgba[i][2] = *ptr++;
+ span->color.rgba[i][3] = *ptr++;
}
- span.x = destX;
- span.y = destY;
- span.end = drawWidth;
- _mesa_write_zoomed_rgba_span(ctx, &span,
- (CONST GLchan (*)[4]) span.color.rgba, zoomY0);
+ span->x = destX;
+ span->y = destY;
+ span->end = drawWidth;
+ _mesa_write_zoomed_rgba_span(ctx, span,
+ (CONST GLchan (*)[4]) span->color.rgba, zoomY0);
src += rowLength*2;
destY++;
}
@@ -429,9 +428,9 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
GLint row;
for (row=0; row<drawHeight; row++) {
ASSERT(drawWidth < MAX_WIDTH);
- _mesa_map_ci8_to_rgba(ctx, drawWidth, src, span.color.rgba);
+ _mesa_map_ci8_to_rgba(ctx, drawWidth, src, span->color.rgba);
(*swrast->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY,
- (const GLchan (*)[4]) span.color.rgba, NULL);
+ (const GLchan (*)[4]) span->color.rgba, NULL);
src += rowLength;
destY++;
}
@@ -442,10 +441,10 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
GLint row;
for (row=0; row<drawHeight; row++) {
ASSERT(drawWidth < MAX_WIDTH);
- _mesa_map_ci8_to_rgba(ctx, drawWidth, src, span.color.rgba);
+ _mesa_map_ci8_to_rgba(ctx, drawWidth, src, span->color.rgba);
destY--;
(*swrast->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY,
- (CONST GLchan (*)[4]) span.color.rgba, NULL);
+ (CONST GLchan (*)[4]) span->color.rgba, NULL);
src += rowLength;
}
return GL_TRUE;
@@ -455,12 +454,12 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
GLint row;
for (row=0; row<drawHeight; row++) {
ASSERT(drawWidth < MAX_WIDTH);
- _mesa_map_ci8_to_rgba(ctx, drawWidth, src, span.color.rgba);
- span.x = destX;
- span.y = destY;
- span.end = drawWidth;
- _mesa_write_zoomed_rgba_span(ctx, &span,
- (CONST GLchan (*)[4]) span.color.rgba, zoomY0);
+ _mesa_map_ci8_to_rgba(ctx, drawWidth, src, span->color.rgba);
+ span->x = destX;
+ span->y = destY;
+ span->end = drawWidth;
+ _mesa_write_zoomed_rgba_span(ctx, span,
+ (CONST GLchan (*)[4]) span->color.rgba, zoomY0);
src += rowLength;
destY++;
}
@@ -509,15 +508,14 @@ draw_index_pixels( GLcontext *ctx, GLint x, GLint y,
const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0;
const GLint desty = y;
GLint row, drawWidth = (width > MAX_WIDTH) ? MAX_WIDTH : width;
- struct sw_span span;
+ struct sw_span *span = SWRAST_CONTEXT(ctx)->span;
INIT_SPAN(span, GL_BITMAP, drawWidth, 0, SPAN_INDEX);
- /*span.arrayMask |= SPAN_INDEX;*/
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);
/*
* General solution
@@ -526,16 +524,16 @@ draw_index_pixels( GLcontext *ctx, GLint x, GLint y,
const GLvoid *source = _mesa_image_address(&ctx->Unpack,
pixels, width, height, GL_COLOR_INDEX, type, 0, row, 0);
_mesa_unpack_index_span(ctx, drawWidth, GL_UNSIGNED_INT,
- span.color.index,
+ span->color.index,
type, source, &ctx->Unpack,
ctx->_ImageTransferState);
- span.x = x;
- span.y = y;
- span.end = drawWidth;
+ span->x = x;
+ span->y = y;
+ span->end = drawWidth;
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);
}
}
@@ -612,11 +610,9 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y,
const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0;
const GLint desty = y;
GLint drawWidth = (width > MAX_WIDTH) ? MAX_WIDTH : width;
- struct sw_span span;
+ struct sw_span *span = SWRAST_CONTEXT(ctx)->span;
INIT_SPAN(span, GL_BITMAP, drawWidth, 0, SPAN_Z);
- /*span.arrayMask |= SPAN_Z;
- span.end = drawWidth;*/
if (type != GL_BYTE
&& type != GL_UNSIGNED_BYTE
@@ -629,50 +625,50 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y,
return;
}
- _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 (type==GL_UNSIGNED_SHORT && ctx->Visual.depthBits == 16
&& !bias_or_scale && !zoom && ctx->Visual.rgbMode) {
/* Special case: directly write 16-bit depth values */
GLint row;
- span.x = x;
- span.y = y;
- span.end = drawWidth;
- for (row = 0; row < height; row++, span.y++) {
+ span->x = x;
+ span->y = y;
+ span->end = drawWidth;
+ for (row = 0; row < height; row++, span->y++) {
const GLushort *zptr = (const GLushort *)
_mesa_image_address(&ctx->Unpack, pixels, width, height,
GL_DEPTH_COMPONENT, type, 0, row, 0);
GLint i;
for (i = 0; i < drawWidth; i++)
- span.zArray[i] = zptr[i];
- _mesa_write_rgba_span(ctx, &span);
+ span->zArray[i] = zptr[i];
+ _mesa_write_rgba_span(ctx, span);
}
}
else if (type==GL_UNSIGNED_INT && ctx->Visual.depthBits == 32
&& !bias_or_scale && !zoom && ctx->Visual.rgbMode) {
/* Special case: directly write 32-bit depth values */
GLint row;
- span.x = x;
- span.y = y;
- span.end = drawWidth;
- for (row = 0; row < height; row++, span.y++) {
+ span->x = x;
+ span->y = y;
+ span->end = drawWidth;
+ for (row = 0; row < height; row++, span->y++) {
const GLuint *zptr = (const GLuint *)
_mesa_image_address(&ctx->Unpack, pixels, width, height,
GL_DEPTH_COMPONENT, type, 0, row, 0);
- MEMCPY(span.zArray, zptr, drawWidth * sizeof(GLdepth));
- _mesa_write_rgba_span(ctx, &span);
+ MEMCPY(span->zArray, zptr, drawWidth * sizeof(GLdepth));
+ _mesa_write_rgba_span(ctx, span);
}
}
else {
/* General case */
GLint row;
- span.x = x;
- span.y = y;
- span.end = drawWidth;
- for (row = 0; row < height; row++, span.y++) {
+ span->x = x;
+ span->y = y;
+ span->end = drawWidth;
+ for (row = 0; row < height; row++, span->y++) {
GLfloat fspan[MAX_WIDTH];
const GLvoid *src = _mesa_image_address(&ctx->Unpack,
pixels, width, height, GL_DEPTH_COMPONENT, type, 0, row, 0);
@@ -683,21 +679,21 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y,
const GLfloat zs = ctx->DepthMaxF;
GLint i;
for (i = 0; i < drawWidth; i++) {
- span.zArray[i] = (GLdepth) (fspan[i] * zs + 0.5F);
+ span->zArray[i] = (GLdepth) (fspan[i] * zs + 0.5F);
}
}
if (ctx->Visual.rgbMode) {
if (zoom)
- _mesa_write_zoomed_rgba_span(ctx, &span,
- (const GLchan (*)[4]) span.color.rgba, desty);
+ _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);
}
}
}
@@ -719,10 +715,9 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
GLboolean quickDraw;
GLfloat *convImage = NULL;
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 (!_mesa_is_legal_format_and_type(format, type)) {
_mesa_error(ctx, GL_INVALID_ENUM, "glDrawPixels(format or type)");
@@ -734,13 +729,13 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
return;
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 && x >= 0 && y >= 0
- && x + width <= ctx->DrawBuffer->Width
- && y + height <= ctx->DrawBuffer->Height) {
+ && x + width <= (GLint) ctx->DrawBuffer->Width
+ && y + height <= (GLint) ctx->DrawBuffer->Height) {
quickDraw = GL_TRUE;
}
else {
@@ -810,7 +805,7 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
const GLvoid *source = _mesa_image_address(unpack,
pixels, width, height, format, type, 0, row, 0);
_mesa_unpack_chan_color_span(ctx, width, GL_RGBA,
- (GLchan *) span.color.rgba,
+ (GLchan *) span->color.rgba,
format, type, source, unpack,
transferOps);
@@ -819,26 +814,26 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
continue;
if (ctx->Pixel.PixelTextureEnabled && ctx->Texture._ReallyEnabled) {
- span.end = width;
- _swrast_pixel_texture(ctx, &span);
+ span->end = width;
+ _swrast_pixel_texture(ctx, span);
}
if (quickDraw) {
(*swrast->Driver.WriteRGBASpan)(ctx, width, x, y,
- (CONST GLchan (*)[4]) span.color.rgba, NULL);
+ (CONST GLchan (*)[4]) span->color.rgba, NULL);
}
else if (zoom) {
- span.x = x;
- span.y = y;
- span.end = width;
- _mesa_write_zoomed_rgba_span(ctx, &span,
- (CONST GLchan (*)[4]) span.color.rgba, desty);
+ span->x = x;
+ span->y = y;
+ span->end = width;
+ _mesa_write_zoomed_rgba_span(ctx, span,
+ (CONST GLchan (*)[4]) span->color.rgba, desty);
}
else {
- span.x = x;
- span.y = y;
- span.end = width;
- _mesa_write_rgba_span(ctx, &span);
+ span->x = x;
+ span->y = y;
+ span->end = width;
+ _mesa_write_rgba_span(ctx, span);
}
}
}