From 47cf442c1164b6b406117fccfb8b564602741ee3 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 16 May 2001 20:27:12 +0000 Subject: use DEFARRAY, etc macros to work around 32k data limit on Macs (Tom Goon) --- src/mesa/main/image.c | 28 ++++++++++++++---- src/mesa/swrast/s_aatriangle.c | 3 +- src/mesa/swrast/s_aatritemp.h | 54 +++++++++++++++++++++++++--------- src/mesa/swrast/s_copypix.c | 36 ++++++++++++++++++----- src/mesa/swrast/s_drawpix.c | 17 +++++++++-- src/mesa/swrast/s_readpix.c | 6 ++-- src/mesa/swrast/s_texture.c | 6 ++-- src/mesa/swrast/s_triangle.c | 66 +++++++++++++++++++++++++++++++++--------- src/mesa/swrast/s_tritemp.h | 7 ++++- 9 files changed, 174 insertions(+), 49 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index 86883aa2cfa..df7a89d005f 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -1,4 +1,4 @@ -/* $Id: image.c,v 1.60 2001/05/15 21:21:08 brianp Exp $ */ +/* $Id: image.c,v 1.61 2001/05/16 20:27:12 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -805,7 +805,9 @@ _mesa_pack_float_rgba_span( GLcontext *ctx, if (transferOps) { /* make copy of incoming data */ - GLfloat rgbaCopy[MAX_WIDTH][4]; + DEFMARRAY(GLfloat, rgbaCopy, MAX_WIDTH, 4); /* mac 32k limitation */ + CHECKARRAY(rgbaCopy, return); /* mac 32k limitation */ + for (i = 0; i < n; i++) { rgbaCopy[i][0] = rgbaIn[i][0]; rgbaCopy[i][1] = rgbaIn[i][1]; @@ -866,9 +868,12 @@ _mesa_pack_float_rgba_span( GLcontext *ctx, /* min/max here */ if (transferOps & IMAGE_MIN_MAX_BIT) { _mesa_update_minmax(ctx, n, (CONST GLfloat (*)[4]) rgba); - if (ctx->MinMax.Sink) + if (ctx->MinMax.Sink) { + UNDEFARRAY(rgbaCopy); /* mac 32k limitation */ return; + } } + UNDEFARRAY(rgbaCopy); /* mac 32k limitation */ } else { /* use incoming data, not a copy */ @@ -1735,8 +1740,10 @@ _mesa_pack_rgba_span( GLcontext *ctx, } else { /* general solution */ - GLfloat rgba[MAX_WIDTH][4]; GLuint i; + DEFMARRAY(GLfloat, rgba, MAX_WIDTH, 4); /* mac 32k limitation */ + CHECKARRAY(rgba, return); /* mac 32k limitation */ + assert(n <= MAX_WIDTH); /* convert color components to floating point */ for (i=0;i_backface_sign; +#ifdef DO_RGBA + CHECKARRAY(rgba, return); /* mac 32k limitation */ +#endif +#ifdef DO_SPEC + CHECKARRAY(spec, return); +#endif +#if defined(DO_TEX) || defined(DO_MULTITEX) + CHECKARRAY(s, return); + CHECKARRAY(t, return); + CHECKARRAY(u, return); + CHECKARRAY(lambda, return); +#endif + /* determine bottom to top order of vertices */ { GLfloat y0 = v0->win[1]; @@ -532,6 +547,19 @@ #endif } } + +#ifdef DO_RGBA + UNDEFARRAY(rgba); /* mac 32k limitation */ +#endif +#ifdef DO_SPEC + UNDEFARRAY(spec); +#endif +#if defined(DO_TEX) || defined(DO_MULTITEX) + UNDEFARRAY(s); + UNDEFARRAY(t); + UNDEFARRAY(u); + UNDEFARRAY(lambda); +#endif } diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c index 36e9974d387..a4a34ba5925 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.17 2001/05/15 21:30:27 brianp Exp $ */ +/* $Id: s_copypix.c,v 1.18 2001/05/16 20:27:12 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -432,8 +432,10 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, if (transferOps) { const GLfloat scale = (1.0F / CHAN_MAXF); - GLfloat rgbaFloat[MAX_WIDTH][4]; GLint k; + DEFMARRAY(GLfloat, rgbaFloat, MAX_WIDTH, 4); /* mac 32k limitation */ + CHECKARRAY(rgbaFloat, return); + /* convert chan to float */ for (k = 0; k < width; k++) { rgbaFloat[k][RCOMP] = (GLfloat) rgba[k][RCOMP] * scale; @@ -504,14 +506,22 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, rgba[k][BCOMP] = (GLchan) CLAMP(b, 0, CHAN_MAX); rgba[k][ACOMP] = (GLchan) CLAMP(a, 0, CHAN_MAX); } + UNDEFARRAY(rgbaFloat); /* mac 32k limitation */ } if (ctx->Texture._ReallyEnabled && ctx->Pixel.PixelTextureEnabled) { - GLfloat s[MAX_WIDTH], t[MAX_WIDTH], r[MAX_WIDTH], q[MAX_WIDTH]; - GLchan primary_rgba[MAX_WIDTH][4]; GLuint unit; - /* XXX not sure how multitexture is supposed to work here */ + GLchan primary_rgba[MAX_WIDTH][4]; + DEFARRAY(GLfloat, s, MAX_WIDTH); /* mac 32k limitation */ + DEFARRAY(GLfloat, t, MAX_WIDTH); /* mac 32k limitation */ + DEFARRAY(GLfloat, r, MAX_WIDTH); /* mac 32k limitation */ + DEFARRAY(GLfloat, q, MAX_WIDTH); /* mac 32k limitation */ + CHECKARRAY(s, return); /* mac 32k limitation */ + CHECKARRAY(t, return); + CHECKARRAY(r, return); + CHECKARRAY(q, return); + /* XXX not sure how multitexture is supposed to work here */ MEMCPY(primary_rgba, rgba, 4 * width * sizeof(GLchan)); for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { @@ -521,6 +531,11 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, (CONST GLchan (*)[4]) primary_rgba, rgba); } + + UNDEFARRAY(s); /* mac 32k limitation */ + UNDEFARRAY(t); + UNDEFARRAY(r); + UNDEFARRAY(q); } if (quick_draw && dy >= 0 && dy < ctx->DrawBuffer->Height) { @@ -673,14 +688,16 @@ static void copy_depth_pixels( GLcontext *ctx, GLint srcx, GLint srcy, GLdepth zspan[MAX_WIDTH]; GLfloat *p, *tmpImage; GLuint indexes[MAX_WIDTH]; - GLchan rgba[MAX_WIDTH][4]; GLint sy, dy, stepy; GLint i, j; const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F; GLint overlapping; + DEFMARRAY(GLubyte, rgba, MAX_WIDTH, 4); /* mac 32k limitation */ + CHECKARRAY(rgba, return); /* mac 32k limitation */ if (!ctx->Visual.depthBits) { _mesa_error( ctx, GL_INVALID_OPERATION, "glCopyPixels" ); + UNDEFARRAY(rgba); /* mac 32k limitation */ return; } @@ -720,6 +737,7 @@ static void copy_depth_pixels( GLcontext *ctx, GLint srcx, GLint srcy, tmpImage = (GLfloat *) MALLOC(width * height * sizeof(GLfloat)); if (!tmpImage) { _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyPixels" ); + UNDEFARRAY(rgba); /* mac 32k limitation */ return; } p = tmpImage; @@ -770,8 +788,10 @@ static void copy_depth_pixels( GLcontext *ctx, GLint srcx, GLint srcy, } } - if (overlapping) - FREE(tmpImage); + UNDEFARRAY(rgba); /* mac 32k limitation */ + + if (overlapping) + FREE(tmpImage); } diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c index e914eb70136..59b2d0294b3 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.18 2001/05/15 21:30:27 brianp Exp $ */ +/* $Id: s_drawpix.c,v 1.19 2001/05/16 20:27:12 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -818,11 +818,18 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y, continue; if (ctx->Texture._ReallyEnabled && ctx->Pixel.PixelTextureEnabled) { - GLfloat s[MAX_WIDTH], t[MAX_WIDTH], r[MAX_WIDTH], q[MAX_WIDTH]; GLchan primary_rgba[MAX_WIDTH][4]; GLuint unit; - /* XXX not sure how multitexture is supposed to work here */ + DEFARRAY(GLfloat, s, MAX_WIDTH); /* mac 32k limitation */ + DEFARRAY(GLfloat, t, MAX_WIDTH); + DEFARRAY(GLfloat, r, MAX_WIDTH); + DEFARRAY(GLfloat, q, MAX_WIDTH); + CHECKARRAY(s, return); /* mac 32k limitation */ + CHECKARRAY(t, return); + CHECKARRAY(r, return); + CHECKARRAY(q, return); + /* XXX not sure how multitexture is supposed to work here */ MEMCPY(primary_rgba, rgba, 4 * width * sizeof(GLchan)); for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { @@ -834,6 +841,10 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y, rgba); } } + UNDEFARRAY(s); /* mac 32k limitation */ + UNDEFARRAY(t); + UNDEFARRAY(r); + UNDEFARRAY(q); } if (quickDraw) { diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c index d95bba64c86..5fc03da27d7 100644 --- a/src/mesa/swrast/s_readpix.c +++ b/src/mesa/swrast/s_readpix.c @@ -1,4 +1,4 @@ -/* $Id: s_readpix.c,v 1.11 2001/03/19 02:25:36 keithw Exp $ */ +/* $Id: s_readpix.c,v 1.12 2001/05/16 20:27:12 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -451,13 +451,15 @@ read_rgba_pixels( GLcontext *ctx, * there. This fixes conformance failures with 16-bit color * buffers, for example. */ - GLfloat rgbaf[MAX_WIDTH][4]; + DEFMARRAY(GLfloat, rgbaf, MAX_WIDTH, 4); /* mac 32k limitation */ + CHECKARRAY(rgbaf, return); /* mac 32k limitation */ _mesa_chan_to_float_span(ctx, readWidth, (CONST GLchan (*)[4]) rgba, rgbaf); _mesa_pack_float_rgba_span(ctx, readWidth, (CONST GLfloat (*)[4]) rgbaf, format, type, dst, packing, ctx->_ImageTransferState); + UNDEFARRAY(rgbaf); /* mac 32k limitation */ } else { /* GLubytes are fine */ diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c index ae18bff0dee..a5a64d04662 100644 --- a/src/mesa/swrast/s_texture.c +++ b/src/mesa/swrast/s_texture.c @@ -1,4 +1,4 @@ -/* $Id: s_texture.c,v 1.29 2001/05/14 23:11:13 brianp Exp $ */ +/* $Id: s_texture.c,v 1.30 2001/05/16 20:27:12 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -1743,12 +1743,13 @@ texture_combine(const GLcontext *ctx, CONST GLchan (*texel)[4], GLchan (*rgba)[4]) { - GLchan ccolor [3][3*MAX_WIDTH][4]; const GLchan (*argRGB [3])[4]; const GLchan (*argA [3])[4]; GLuint i, j; const GLuint RGBshift = textureUnit->CombineScaleShiftRGB; const GLuint Ashift = textureUnit->CombineScaleShiftA; + DEFMNARRAY(GLubyte, ccolor, 3, 3 * MAX_WIDTH, 4); /* mac 32k limitation */ + CHECKARRAY(ccolor, return); /* mac 32k limitation */ ASSERT(ctx->Extensions.EXT_texture_env_combine || ctx->Extensions.ARB_texture_env_combine); @@ -2084,6 +2085,7 @@ texture_combine(const GLcontext *ctx, rgba[i][ACOMP] = rgba[i][RCOMP]; } } + UNDEFARRAY(ccolor); /* mac 32k limitation */ } #undef PROD diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c index b3c58101237..2c117b869cb 100644 --- a/src/mesa/swrast/s_triangle.c +++ b/src/mesa/swrast/s_triangle.c @@ -1,4 +1,4 @@ -/* $Id: s_triangle.c,v 1.27 2001/05/15 21:30:27 brianp Exp $ */ +/* $Id: s_triangle.c,v 1.28 2001/05/16 20:27:12 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -1606,17 +1606,33 @@ static void lin_persp_textured_triangle( GLcontext *ctx, static void rasterize_span(GLcontext *ctx, const struct triangle_span *span) { - GLchan rgba[MAX_WIDTH][4]; - GLchan spec[MAX_WIDTH][4]; - GLuint index[MAX_WIDTH]; - GLuint z[MAX_WIDTH]; - GLfloat fog[MAX_WIDTH]; - GLfloat sTex[MAX_WIDTH], tTex[MAX_WIDTH], rTex[MAX_WIDTH]; - GLfloat lambda[MAX_WIDTH]; - GLfloat msTex[MAX_TEXTURE_UNITS][MAX_WIDTH]; - GLfloat mtTex[MAX_TEXTURE_UNITS][MAX_WIDTH]; - GLfloat mrTex[MAX_TEXTURE_UNITS][MAX_WIDTH]; - GLfloat mLambda[MAX_TEXTURE_UNITS][MAX_WIDTH]; + DEFMARRAY(GLchan, rgba, MAX_WIDTH, 4); + DEFMARRAY(GLchan, spec, MAX_WIDTH, 4); + DEFARRAY(GLuint, index, MAX_WIDTH); + DEFARRAY(GLuint, z, MAX_WIDTH); + DEFARRAY(GLfloat, fog, MAX_WIDTH); + DEFARRAY(GLfloat, sTex, MAX_WIDTH); + DEFARRAY(GLfloat, tTex, MAX_WIDTH); + DEFARRAY(GLfloat, rTex, MAX_WIDTH); + DEFARRAY(GLfloat, lambda, MAX_WIDTH); + DEFMARRAY(GLfloat, msTex, MAX_TEXTURE_UNITS, MAX_WIDTH); + DEFMARRAY(GLfloat, mtTex, MAX_TEXTURE_UNITS, MAX_WIDTH); + DEFMARRAY(GLfloat, mrTex, MAX_TEXTURE_UNITS, MAX_WIDTH); + DEFMARRAY(GLfloat, mLambda, MAX_TEXTURE_UNITS, MAX_WIDTH); + + CHECKARRAY(rgba, return); + CHECKARRAY(spec, return); + CHECKARRAY(index, return); + CHECKARRAY(z, return); + CHECKARRAY(fog, return); + CHECKARRAY(sTex, return); + CHECKARRAY(tTex, return); + CHECKARRAY(rTex, return); + CHECKARRAY(lambda, return); + CHECKARRAY(msTex, return); + CHECKARRAY(mtTex, return); + CHECKARRAY(mrTex, return); + CHECKARRAY(mLambda, return); if (span->activeMask & SPAN_RGBA) { GLfixed r = span->red; @@ -1837,6 +1853,20 @@ rasterize_span(GLcontext *ctx, const struct triangle_span *span) else { _mesa_problem(ctx, "rasterize_span() should only be used for texturing"); } + + UNDEFARRAY(rgba); + UNDEFARRAY(spec); + UNDEFARRAY(index); + UNDEFARRAY(z); + UNDEFARRAY(fog); + UNDEFARRAY(sTex); + UNDEFARRAY(tTex); + UNDEFARRAY(rTex); + UNDEFARRAY(lambda); + UNDEFARRAY(msTex); + UNDEFARRAY(mtTex); + UNDEFARRAY(mrTex); + UNDEFARRAY(mLambda); } @@ -1863,6 +1893,12 @@ static void general_textured_triangle( GLcontext *ctx, const struct gl_texture_image *texImage = obj->Image[obj->BaseLevel];\ const GLboolean flatShade = (ctx->Light.ShadeModel==GL_FLAT); \ GLfixed rFlat, gFlat, bFlat, aFlat; \ + DEFARRAY(GLfloat, sSpan, MAX_WIDTH); /* mac 32k limitation */ \ + DEFARRAY(GLfloat, tSpan, MAX_WIDTH); /* mac 32k limitation */ \ + DEFARRAY(GLfloat, uSpan, MAX_WIDTH); /* mac 32k limitation */ \ + CHECKARRAY(sSpan, return); /* mac 32k limitation */ \ + CHECKARRAY(tSpan, return); /* mac 32k limitation */ \ + CHECKARRAY(uSpan, return); /* mac 32k limitation */ \ if (flatShade) { \ rFlat = IntToFixed(v2->color[RCOMP]); \ gFlat = IntToFixed(v2->color[GCOMP]); \ @@ -1877,7 +1913,6 @@ static void general_textured_triangle( GLcontext *ctx, GLdepth zSpan[MAX_WIDTH]; \ GLfloat fogSpan[MAX_WIDTH]; \ GLchan rgbaSpan[MAX_WIDTH][4]; \ - GLfloat sSpan[MAX_WIDTH], tSpan[MAX_WIDTH], uSpan[MAX_WIDTH]; \ GLuint i; \ if (flatShade) { \ span.red = rFlat; span.redStep = 0; \ @@ -1912,6 +1947,11 @@ static void general_textured_triangle( GLcontext *ctx, zSpan, fogSpan, sSpan, tSpan, uSpan, \ NULL, rgbaSpan, NULL, NULL, GL_POLYGON ); +#define CLEANUP_CODE \ + UNDEFARRAY(sSpan); /* mac 32k limitation */ \ + UNDEFARRAY(tSpan); \ + UNDEFARRAY(uSpan); + #include "s_tritemp.h" } diff --git a/src/mesa/swrast/s_tritemp.h b/src/mesa/swrast/s_tritemp.h index 09e12235067..142bd0992e5 100644 --- a/src/mesa/swrast/s_tritemp.h +++ b/src/mesa/swrast/s_tritemp.h @@ -1,4 +1,4 @@ -/* $Id: s_tritemp.h,v 1.16 2001/05/14 16:23:04 brianp Exp $ */ +/* $Id: s_tritemp.h,v 1.17 2001/05/16 20:27:12 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -60,6 +60,7 @@ * * Optionally, one may provide one-time setup code per triangle: * SETUP_CODE - code which is to be executed once per triangle + * CLEANUP_CODE - code to execute at end of triangle * * The following macro MUST be defined: * RENDER_SPAN(span) - code to write a span of pixels. @@ -1187,10 +1188,14 @@ } /* for subTriangle */ } +#ifdef CLEANUP_CODE + CLEANUP_CODE +#endif } } #undef SETUP_CODE +#undef CLEANUP_CODE #undef RENDER_SPAN #undef PIXEL_TYPE -- cgit v1.2.3