From c4f44c07c6662d1ce08603945ccc4fa5afaa742a Mon Sep 17 00:00:00 2001 From: marha Date: Mon, 27 Feb 2012 07:24:18 +0100 Subject: fontconfig pixman mesa git update 27 Feb 2012 --- mesalib/src/mesa/swrast/s_aalinetemp.h | 2 +- mesalib/src/mesa/swrast/s_aatritemp.h | 2 +- mesalib/src/mesa/swrast/s_bitmap.c | 2 +- mesalib/src/mesa/swrast/s_blend.c | 2 +- mesalib/src/mesa/swrast/s_chan.h | 8 ++++ mesalib/src/mesa/swrast/s_context.c | 31 ++++++++++++++ mesalib/src/mesa/swrast/s_context.h | 7 ++++ mesalib/src/mesa/swrast/s_copypix.c | 27 +++++++++--- mesalib/src/mesa/swrast/s_depth.c | 10 ++++- mesalib/src/mesa/swrast/s_drawpix.c | 77 +++++++++++++++++++--------------- mesalib/src/mesa/swrast/s_lines.c | 2 +- mesalib/src/mesa/swrast/s_logic.c | 2 +- mesalib/src/mesa/swrast/s_masking.c | 2 +- mesalib/src/mesa/swrast/s_points.c | 6 +-- mesalib/src/mesa/swrast/s_span.c | 5 ++- mesalib/src/mesa/swrast/s_span.h | 21 +++++----- mesalib/src/mesa/swrast/s_stencil.c | 15 +++++-- mesalib/src/mesa/swrast/s_texcombine.c | 8 ++-- mesalib/src/mesa/swrast/s_triangle.c | 11 ++--- mesalib/src/mesa/swrast/s_zoom.c | 22 +++++++--- mesalib/src/mesa/swrast/swrast.h | 28 +++++++++++++ 21 files changed, 209 insertions(+), 81 deletions(-) (limited to 'mesalib/src/mesa/swrast') diff --git a/mesalib/src/mesa/swrast/s_aalinetemp.h b/mesalib/src/mesa/swrast/s_aalinetemp.h index ba9f8abb9..a517fb697 100644 --- a/mesalib/src/mesa/swrast/s_aalinetemp.h +++ b/mesalib/src/mesa/swrast/s_aalinetemp.h @@ -91,7 +91,7 @@ NAME(plot)(struct gl_context *ctx, struct LineInfo *line, int ix, int iy) ATTRIB_LOOP_END #endif - if (line->span.end == MAX_WIDTH) { + if (line->span.end == SWRAST_MAX_WIDTH) { _swrast_write_rgba_span(ctx, &(line->span)); line->span.end = 0; /* reset counter */ } diff --git a/mesalib/src/mesa/swrast/s_aatritemp.h b/mesalib/src/mesa/swrast/s_aatritemp.h index 77b3ae6ec..9cdb35fd2 100644 --- a/mesalib/src/mesa/swrast/s_aatritemp.h +++ b/mesalib/src/mesa/swrast/s_aatritemp.h @@ -196,7 +196,7 @@ span.array = SWRAST_CONTEXT(ctx)->SpanArrays + omp_get_thread_num(); #endif /* skip over fragments with zero coverage */ - while (startX < MAX_WIDTH) { + while (startX < SWRAST_MAX_WIDTH) { coverage = compute_coveragef(pMin, pMid, pMax, startX, iy); if (coverage > 0.0F) break; diff --git a/mesalib/src/mesa/swrast/s_bitmap.c b/mesalib/src/mesa/swrast/s_bitmap.c index 18f1c1866..3a2792913 100644 --- a/mesalib/src/mesa/swrast/s_bitmap.c +++ b/mesalib/src/mesa/swrast/s_bitmap.c @@ -123,7 +123,7 @@ _swrast_Bitmap( struct gl_context *ctx, GLint px, GLint py, src++; } - if (count + width >= MAX_WIDTH || row + 1 == height) { + if (count + width >= SWRAST_MAX_WIDTH || row + 1 == height) { /* flush the span */ span.end = count; _swrast_write_rgba_span(ctx, &span); diff --git a/mesalib/src/mesa/swrast/s_blend.c b/mesalib/src/mesa/swrast/s_blend.c index cd6e6f036..54fffbb45 100644 --- a/mesalib/src/mesa/swrast/s_blend.c +++ b/mesalib/src/mesa/swrast/s_blend.c @@ -998,7 +998,7 @@ _swrast_blend_span(struct gl_context *ctx, struct gl_renderbuffer *rb, SWspan *s SWcontext *swrast = SWRAST_CONTEXT(ctx); void *rbPixels; - ASSERT(span->end <= MAX_WIDTH); + ASSERT(span->end <= SWRAST_MAX_WIDTH); ASSERT(span->arrayMask & SPAN_RGBA); ASSERT(!ctx->Color.ColorLogicOpEnabled); diff --git a/mesalib/src/mesa/swrast/s_chan.h b/mesalib/src/mesa/swrast/s_chan.h index 94ac8b65b..1db7fae4d 100644 --- a/mesalib/src/mesa/swrast/s_chan.h +++ b/mesalib/src/mesa/swrast/s_chan.h @@ -35,6 +35,14 @@ #include "main/config.h" +/** + * Default bits per color channel: 8, 16 or 32 + */ +#ifndef CHAN_BITS +#define CHAN_BITS 8 +#endif + + /** * Color channel data type. */ diff --git a/mesalib/src/mesa/swrast/s_context.c b/mesalib/src/mesa/swrast/s_context.c index cc304d70c..63350b2e7 100644 --- a/mesalib/src/mesa/swrast/s_context.c +++ b/mesalib/src/mesa/swrast/s_context.c @@ -726,6 +726,18 @@ _swrast_CreateContext( struct gl_context *ctx ) const GLuint maxThreads = 1; #endif + assert(ctx->Const.MaxViewportWidth <= SWRAST_MAX_WIDTH); + assert(ctx->Const.MaxViewportHeight <= SWRAST_MAX_WIDTH); + + assert(ctx->Const.MaxRenderbufferSize <= SWRAST_MAX_WIDTH); + + /* make sure largest texture image is <= SWRAST_MAX_WIDTH in size */ + assert((1 << (ctx->Const.MaxTextureLevels - 1)) <= SWRAST_MAX_WIDTH); + assert((1 << (ctx->Const.MaxCubeTextureLevels - 1)) <= SWRAST_MAX_WIDTH); + assert((1 << (ctx->Const.Max3DTextureLevels - 1)) <= SWRAST_MAX_WIDTH); + + assert(PROG_MAX_WIDTH == SWRAST_MAX_WIDTH); + if (SWRAST_DEBUG) { _mesa_debug(ctx, "_swrast_CreateContext\n"); } @@ -790,6 +802,19 @@ _swrast_CreateContext( struct gl_context *ctx ) ctx->swrast_context = swrast; + swrast->stencil_temp.buf1 = (GLubyte *) malloc(SWRAST_MAX_WIDTH * sizeof(GLubyte)); + swrast->stencil_temp.buf2 = (GLubyte *) malloc(SWRAST_MAX_WIDTH * sizeof(GLubyte)); + swrast->stencil_temp.buf3 = (GLubyte *) malloc(SWRAST_MAX_WIDTH * sizeof(GLubyte)); + swrast->stencil_temp.buf4 = (GLubyte *) malloc(SWRAST_MAX_WIDTH * sizeof(GLubyte)); + + if (!swrast->stencil_temp.buf1 || + !swrast->stencil_temp.buf2 || + !swrast->stencil_temp.buf3 || + !swrast->stencil_temp.buf4) { + _swrast_DestroyContext(ctx); + return GL_FALSE; + } + return GL_TRUE; } @@ -806,6 +831,12 @@ _swrast_DestroyContext( struct gl_context *ctx ) if (swrast->ZoomedArrays) FREE( swrast->ZoomedArrays ); FREE( swrast->TexelBuffer ); + + free(swrast->stencil_temp.buf1); + free(swrast->stencil_temp.buf2); + free(swrast->stencil_temp.buf3); + free(swrast->stencil_temp.buf4); + FREE( swrast ); ctx->swrast_context = 0; diff --git a/mesalib/src/mesa/swrast/s_context.h b/mesalib/src/mesa/swrast/s_context.h index 9388c3569..26b97f78d 100644 --- a/mesalib/src/mesa/swrast/s_context.h +++ b/mesalib/src/mesa/swrast/s_context.h @@ -306,6 +306,13 @@ typedef struct /** State used during execution of fragment programs */ struct gl_program_machine FragProgMachine; + /** Temporary arrays for stencil operations. To avoid large stack + * allocations. + */ + struct { + GLubyte *buf1, *buf2, *buf3, *buf4; + } stencil_temp; + } SWcontext; diff --git a/mesalib/src/mesa/swrast/s_copypix.c b/mesalib/src/mesa/swrast/s_copypix.c index 592d35a98..cf419c328 100644 --- a/mesalib/src/mesa/swrast/s_copypix.c +++ b/mesalib/src/mesa/swrast/s_copypix.c @@ -158,7 +158,7 @@ copy_rgba_pixels(struct gl_context *ctx, GLint srcx, GLint srcy, p = NULL; } - ASSERT(width < MAX_WIDTH); + ASSERT(width < SWRAST_MAX_WIDTH); for (row = 0; row < height; row++, sy += stepy, dy += stepy) { GLvoid *rgba = span.array->attribs[FRAG_ATTRIB_COL0]; @@ -246,7 +246,7 @@ copy_depth_pixels( struct gl_context *ctx, GLint srcx, GLint srcy, { struct gl_framebuffer *fb = ctx->ReadBuffer; struct gl_renderbuffer *readRb = fb->Attachment[BUFFER_DEPTH].Renderbuffer; - GLfloat *p, *tmpImage; + GLfloat *p, *tmpImage, *depth; GLint sy, dy, stepy; GLint j; const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F; @@ -303,8 +303,13 @@ copy_depth_pixels( struct gl_context *ctx, GLint srcx, GLint srcy, p = NULL; } + depth = (GLfloat *) malloc(width * sizeof(GLfloat)); + if (!depth) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels()"); + goto end; + } + for (j = 0; j < height; j++, sy += stepy, dy += stepy) { - GLfloat depth[MAX_WIDTH]; /* get depth values */ if (overlapping) { memcpy(depth, p, width * sizeof(GLfloat)); @@ -327,6 +332,9 @@ copy_depth_pixels( struct gl_context *ctx, GLint srcx, GLint srcy, _swrast_write_rgba_span(ctx, &span); } + free(depth); + +end: if (overlapping) free(tmpImage); } @@ -342,7 +350,7 @@ copy_stencil_pixels( struct gl_context *ctx, GLint srcx, GLint srcy, struct gl_renderbuffer *rb = fb->Attachment[BUFFER_STENCIL].Renderbuffer; GLint sy, dy, stepy; GLint j; - GLubyte *p, *tmpImage; + GLubyte *p, *tmpImage, *stencil; const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F; GLint overlapping; @@ -392,9 +400,13 @@ copy_stencil_pixels( struct gl_context *ctx, GLint srcx, GLint srcy, p = NULL; } - for (j = 0; j < height; j++, sy += stepy, dy += stepy) { - GLubyte stencil[MAX_WIDTH]; + stencil = (GLubyte *) malloc(width * sizeof(GLubyte)); + if (!stencil) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels()"); + goto end; + } + for (j = 0; j < height; j++, sy += stepy, dy += stepy) { /* Get stencil values */ if (overlapping) { memcpy(stencil, p, width * sizeof(GLubyte)); @@ -416,6 +428,9 @@ copy_stencil_pixels( struct gl_context *ctx, GLint srcx, GLint srcy, } } + free(stencil); + +end: if (overlapping) free(tmpImage); } diff --git a/mesalib/src/mesa/swrast/s_depth.c b/mesalib/src/mesa/swrast/s_depth.c index c90388209..26126a932 100644 --- a/mesalib/src/mesa/swrast/s_depth.c +++ b/mesalib/src/mesa/swrast/s_depth.c @@ -419,9 +419,15 @@ _swrast_depth_bounds_test( struct gl_context *ctx, SWspan *span ) const GLuint count = span->end; GLuint i; GLboolean anyPass = GL_FALSE; - GLuint zBufferTemp[MAX_WIDTH]; + GLuint *zBufferTemp; const GLuint *zBufferVals; + zBufferTemp = (GLuint *) malloc(count * sizeof(GLuint)); + if (!zBufferTemp) { + /* don't generate a stream of OUT_OF_MEMORY errors here */ + return GL_FALSE; + } + if (span->arrayMask & SPAN_XY) zStart = NULL; else @@ -453,6 +459,8 @@ _swrast_depth_bounds_test( struct gl_context *ctx, SWspan *span ) } } + free(zBufferTemp); + return anyPass; } diff --git a/mesalib/src/mesa/swrast/s_drawpix.c b/mesalib/src/mesa/swrast/s_drawpix.c index c19808bd4..1fa64c378 100644 --- a/mesalib/src/mesa/swrast/s_drawpix.c +++ b/mesalib/src/mesa/swrast/s_drawpix.c @@ -264,34 +264,35 @@ draw_stencil_pixels( struct gl_context *ctx, GLint x, GLint y, { const GLboolean zoom = ctx->Pixel.ZoomX != 1.0 || ctx->Pixel.ZoomY != 1.0; const GLenum destType = GL_UNSIGNED_BYTE; - GLint skipPixels; + GLint row; + GLubyte *values; - /* if width > MAX_WIDTH, have to process image in chunks */ - skipPixels = 0; - while (skipPixels < width) { - const GLint spanX = x + skipPixels; - const GLint spanWidth = MIN2(width - skipPixels, MAX_WIDTH); - GLint row; - for (row = 0; row < height; row++) { - const GLint spanY = y + row; - GLubyte values[MAX_WIDTH]; - const GLvoid *source = _mesa_image_address2d(unpack, pixels, - width, height, - GL_STENCIL_INDEX, type, - row, skipPixels); - _mesa_unpack_stencil_span(ctx, spanWidth, destType, values, - type, source, unpack, - ctx->_ImageTransferState); - if (zoom) { - _swrast_write_zoomed_stencil_span(ctx, x, y, spanWidth, - spanX, spanY, values); - } - else { - _swrast_write_stencil_span(ctx, spanWidth, spanX, spanY, values); - } + values = (GLubyte *) malloc(width * sizeof(GLubyte)); + if (!values) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glDrawPixels"); + return; + } + + for (row = 0; row < height; row++) { + const GLvoid *source = _mesa_image_address2d(unpack, pixels, + width, height, + GL_STENCIL_INDEX, type, + row, 0); + _mesa_unpack_stencil_span(ctx, width, destType, values, + type, source, unpack, + ctx->_ImageTransferState); + if (zoom) { + _swrast_write_zoomed_stencil_span(ctx, x, y, width, + x, y, values); + } + else { + _swrast_write_stencil_span(ctx, width, x, y, values); } - skipPixels += spanWidth; + + y++; } + + free(values); } @@ -318,7 +319,7 @@ draw_depth_pixels( struct gl_context *ctx, GLint x, GLint y, && ctx->DrawBuffer->Visual.depthBits == 16 && !scaleOrBias && !zoom - && width <= MAX_WIDTH + && width <= SWRAST_MAX_WIDTH && !unpack->SwapBytes) { /* Special case: directly write 16-bit depth values */ GLint row; @@ -338,7 +339,7 @@ draw_depth_pixels( struct gl_context *ctx, GLint x, GLint y, else if (type == GL_UNSIGNED_INT && !scaleOrBias && !zoom - && width <= MAX_WIDTH + && width <= SWRAST_MAX_WIDTH && !unpack->SwapBytes) { /* Special case: shift 32-bit values down to Visual.depthBits */ const GLint shift = 32 - ctx->DrawBuffer->Visual.depthBits; @@ -366,11 +367,11 @@ draw_depth_pixels( struct gl_context *ctx, GLint x, GLint y, const GLuint depthMax = ctx->DrawBuffer->_DepthMax; GLint skipPixels = 0; - /* in case width > MAX_WIDTH do the copy in chunks */ + /* in case width > SWRAST_MAX_WIDTH do the copy in chunks */ while (skipPixels < width) { - const GLint spanWidth = MIN2(width - skipPixels, MAX_WIDTH); + const GLint spanWidth = MIN2(width - skipPixels, SWRAST_MAX_WIDTH); GLint row; - ASSERT(span.end <= MAX_WIDTH); + ASSERT(span.end <= SWRAST_MAX_WIDTH); for (row = 0; row < height; row++) { const GLvoid *zSrc = _mesa_image_address2d(unpack, pixels, width, height, @@ -452,9 +453,9 @@ draw_rgba_pixels( struct gl_context *ctx, GLint x, GLint y, /* use span array for temp color storage */ GLfloat *rgba = (GLfloat *) span.array->attribs[FRAG_ATTRIB_COL0]; - /* if the span is wider than MAX_WIDTH we have to do it in chunks */ + /* if the span is wider than SWRAST_MAX_WIDTH we have to do it in chunks */ while (skipPixels < width) { - const GLint spanWidth = MIN2(width - skipPixels, MAX_WIDTH); + const GLint spanWidth = MIN2(width - skipPixels, SWRAST_MAX_WIDTH); const GLubyte *source = (const GLubyte *) _mesa_image_address2d(unpack, pixels, width, height, format, @@ -588,15 +589,21 @@ draw_depth_stencil_pixels(struct gl_context *ctx, GLint x, GLint y, * Separate depth/stencil buffers, or pixel transfer ops required. */ /* XXX need to handle very wide images (skippixels) */ + GLuint *zValues; /* 32-bit Z values */ GLint i; + zValues = (GLuint *) malloc(width * sizeof(GLuint)); + if (!zValues) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glDrawPixels"); + return; + } + for (i = 0; i < height; i++) { const GLuint *depthStencilSrc = (const GLuint *) _mesa_image_address2d(&clippedUnpack, pixels, width, height, GL_DEPTH_STENCIL_EXT, type, i, 0); if (ctx->Depth.Mask) { - GLuint zValues[MAX_WIDTH]; /* 32-bit Z values */ _mesa_unpack_depth_span(ctx, width, GL_UNSIGNED_INT, /* dest type */ zValues, /* dest addr */ @@ -615,7 +622,7 @@ draw_depth_stencil_pixels(struct gl_context *ctx, GLint x, GLint y, } if (stencilMask != 0x0) { - GLubyte stencilValues[MAX_WIDTH]; + GLubyte *stencilValues = (GLubyte *) zValues; /* re-use buffer */ /* get stencil values, with shift/offset/mapping */ _mesa_unpack_stencil_span(ctx, width, stencilType, stencilValues, type, depthStencilSrc, &clippedUnpack, @@ -627,6 +634,8 @@ draw_depth_stencil_pixels(struct gl_context *ctx, GLint x, GLint y, _swrast_write_stencil_span(ctx, width, x, y + i, stencilValues); } } + + free(zValues); } } diff --git a/mesalib/src/mesa/swrast/s_lines.c b/mesalib/src/mesa/swrast/s_lines.c index ee997b08a..2078be43b 100644 --- a/mesalib/src/mesa/swrast/s_lines.c +++ b/mesalib/src/mesa/swrast/s_lines.c @@ -67,7 +67,7 @@ draw_wide_line( struct gl_context *ctx, SWspan *span, GLboolean xMajor ) ctx->Const.MaxLineWidth); GLint start; - ASSERT(span->end < MAX_WIDTH); + ASSERT(span->end < SWRAST_MAX_WIDTH); if (width & 1) start = width / 2; diff --git a/mesalib/src/mesa/swrast/s_logic.c b/mesalib/src/mesa/swrast/s_logic.c index e908a0efe..8791630a4 100644 --- a/mesalib/src/mesa/swrast/s_logic.c +++ b/mesalib/src/mesa/swrast/s_logic.c @@ -193,7 +193,7 @@ _swrast_logicop_rgba_span(struct gl_context *ctx, struct gl_renderbuffer *rb, { void *rbPixels; - ASSERT(span->end < MAX_WIDTH); + ASSERT(span->end < SWRAST_MAX_WIDTH); ASSERT(span->arrayMask & SPAN_RGBA); rbPixels = _swrast_get_dest_rgba(ctx, rb, span); diff --git a/mesalib/src/mesa/swrast/s_masking.c b/mesalib/src/mesa/swrast/s_masking.c index 2d962ebc5..4f262fa97 100644 --- a/mesalib/src/mesa/swrast/s_masking.c +++ b/mesalib/src/mesa/swrast/s_masking.c @@ -46,7 +46,7 @@ _swrast_mask_rgba_span(struct gl_context *ctx, struct gl_renderbuffer *rb, const GLuint n = span->end; void *rbPixels; - ASSERT(n < MAX_WIDTH); + ASSERT(n < SWRAST_MAX_WIDTH); ASSERT(span->arrayMask & SPAN_RGBA); rbPixels = _swrast_get_dest_rgba(ctx, rb, span); diff --git a/mesalib/src/mesa/swrast/s_points.c b/mesalib/src/mesa/swrast/s_points.c index 11b7ef7b1..acbdb2d42 100644 --- a/mesalib/src/mesa/swrast/s_points.c +++ b/mesalib/src/mesa/swrast/s_points.c @@ -439,7 +439,7 @@ large_point(struct gl_context *ctx, const SWvertex *vert) span.end++; } } - assert(span.end <= MAX_WIDTH); + assert(span.end <= SWRAST_MAX_WIDTH); _swrast_write_rgba_span(ctx, &span); } } @@ -475,7 +475,7 @@ pixel_point(struct gl_context *ctx, const SWvertex *vert) span->attrStepY[FRAG_ATTRIB_WPOS][3] = 0.0F; /* check if we need to flush */ - if (span->end >= MAX_WIDTH || + if (span->end >= SWRAST_MAX_WIDTH || (swrast->_RasterMask & (BLEND_BIT | LOGIC_OP_BIT | MASKING_BIT)) || span->facing != swrast->PointLineFacing) { if (span->end > 0) { @@ -504,7 +504,7 @@ pixel_point(struct gl_context *ctx, const SWvertex *vert) span->array->z[count] = (GLint) (vert->attrib[FRAG_ATTRIB_WPOS][2] + 0.5F); span->end = count + 1; - ASSERT(span->end <= MAX_WIDTH); + ASSERT(span->end <= SWRAST_MAX_WIDTH); } diff --git a/mesalib/src/mesa/swrast/s_span.c b/mesalib/src/mesa/swrast/s_span.c index 025e7b207..627ef1136 100644 --- a/mesalib/src/mesa/swrast/s_span.c +++ b/mesalib/src/mesa/swrast/s_span.c @@ -1164,7 +1164,7 @@ _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span) return; } - ASSERT(span->end <= MAX_WIDTH); + ASSERT(span->end <= SWRAST_MAX_WIDTH); /* Depth bounds test */ if (ctx->Depth.BoundsTest && fb->Visual.depthBits > 0) { @@ -1319,7 +1319,8 @@ _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span) /* color[fragOutput] will be written to buffer[buf] */ if (rb) { - GLchan rgbaSave[MAX_WIDTH][4]; + /* re-use one of the attribute array buffers for rgbaSave */ + GLchan (*rgbaSave)[4] = (GLchan (*)[4]) span->array->attribs[0]; struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); GLenum colorType = srb->ColorType; diff --git a/mesalib/src/mesa/swrast/s_span.h b/mesalib/src/mesa/swrast/s_span.h index ff0fe6cd9..0763c7161 100644 --- a/mesalib/src/mesa/swrast/s_span.h +++ b/mesalib/src/mesa/swrast/s_span.h @@ -32,6 +32,7 @@ #include "main/glheader.h" #include "main/mtypes.h" #include "swrast/s_chan.h" +#include "swrast/swrast.h" struct gl_context; @@ -71,24 +72,24 @@ typedef struct sw_span_arrays /* XXX someday look at transposing first two indexes for better memory * access pattern. */ - GLfloat attribs[FRAG_ATTRIB_MAX][MAX_WIDTH][4]; + GLfloat attribs[FRAG_ATTRIB_MAX][SWRAST_MAX_WIDTH][4]; /** This mask indicates which fragments are alive or culled */ - GLubyte mask[MAX_WIDTH]; + GLubyte mask[SWRAST_MAX_WIDTH]; GLenum ChanType; /**< Color channel type, GL_UNSIGNED_BYTE, GL_FLOAT */ /** Attribute arrays that don't fit into attribs[] array above */ /*@{*/ - GLubyte rgba8[MAX_WIDTH][4]; - GLushort rgba16[MAX_WIDTH][4]; + GLubyte rgba8[SWRAST_MAX_WIDTH][4]; + GLushort rgba16[SWRAST_MAX_WIDTH][4]; GLchan (*rgba)[4]; /** either == rgba8 or rgba16 */ - GLint x[MAX_WIDTH]; /**< fragment X coords */ - GLint y[MAX_WIDTH]; /**< fragment Y coords */ - GLuint z[MAX_WIDTH]; /**< fragment Z coords */ - GLuint index[MAX_WIDTH]; /**< Color indexes */ - GLfloat lambda[MAX_TEXTURE_COORD_UNITS][MAX_WIDTH]; /**< Texture LOD */ - GLfloat coverage[MAX_WIDTH]; /**< Fragment coverage for AA/smoothing */ + GLint x[SWRAST_MAX_WIDTH]; /**< fragment X coords */ + GLint y[SWRAST_MAX_WIDTH]; /**< fragment Y coords */ + GLuint z[SWRAST_MAX_WIDTH]; /**< fragment Z coords */ + GLuint index[SWRAST_MAX_WIDTH]; /**< Color indexes */ + GLfloat lambda[MAX_TEXTURE_COORD_UNITS][SWRAST_MAX_WIDTH]; /**< Texture LOD */ + GLfloat coverage[SWRAST_MAX_WIDTH]; /**< Fragment coverage for AA/smoothing */ /*@}*/ } SWspanarrays; diff --git a/mesalib/src/mesa/swrast/s_stencil.c b/mesalib/src/mesa/swrast/s_stencil.c index bbfbf44cc..3423737ee 100644 --- a/mesalib/src/mesa/swrast/s_stencil.c +++ b/mesalib/src/mesa/swrast/s_stencil.c @@ -210,7 +210,8 @@ static GLboolean do_stencil_test(struct gl_context *ctx, GLuint face, GLuint n, GLubyte stencil[], GLubyte mask[], GLint stride) { - GLubyte fail[MAX_WIDTH]; + SWcontext *swrast = SWRAST_CONTEXT(ctx); + GLubyte *fail = swrast->stencil_temp.buf2; GLboolean allfail = GL_FALSE; GLuint i, j; const GLuint valueMask = ctx->Stencil.ValueMask[face]; @@ -347,6 +348,7 @@ put_s8_values(struct gl_context *ctx, struct gl_renderbuffer *rb, GLboolean _swrast_stencil_and_ztest_span(struct gl_context *ctx, SWspan *span) { + SWcontext *swrast = SWRAST_CONTEXT(ctx); struct gl_framebuffer *fb = ctx->DrawBuffer; struct gl_renderbuffer *rb = fb->Attachment[BUFFER_STENCIL].Renderbuffer; const GLint stencilOffset = get_stencil_offset(rb->Format); @@ -354,7 +356,7 @@ _swrast_stencil_and_ztest_span(struct gl_context *ctx, SWspan *span) const GLuint face = (span->facing == 0) ? 0 : ctx->Stencil._BackFace; const GLuint count = span->end; GLubyte *mask = span->array->mask; - GLubyte stencilTemp[MAX_WIDTH]; + GLubyte *stencilTemp = swrast->stencil_temp.buf1; GLubyte *stencilBuf; if (span->arrayMask & SPAN_XY) { @@ -402,7 +404,10 @@ _swrast_stencil_and_ztest_span(struct gl_context *ctx, SWspan *span) /* * Perform depth buffering, then apply zpass or zfail stencil function. */ - GLubyte passMask[MAX_WIDTH], failMask[MAX_WIDTH], origMask[MAX_WIDTH]; + SWcontext *swrast = SWRAST_CONTEXT(ctx); + GLubyte *passMask = swrast->stencil_temp.buf2; + GLubyte *failMask = swrast->stencil_temp.buf3; + GLubyte *origMask = swrast->stencil_temp.buf4; /* save the current mask bits */ memcpy(origMask, mask, count * sizeof(GLubyte)); @@ -488,6 +493,7 @@ void _swrast_write_stencil_span(struct gl_context *ctx, GLint n, GLint x, GLint y, const GLubyte stencil[] ) { + SWcontext *swrast = SWRAST_CONTEXT(ctx); struct gl_framebuffer *fb = ctx->DrawBuffer; struct gl_renderbuffer *rb = fb->Attachment[BUFFER_STENCIL].Renderbuffer; const GLuint stencilMax = (1 << fb->Visual.stencilBits) - 1; @@ -517,7 +523,8 @@ _swrast_write_stencil_span(struct gl_context *ctx, GLint n, GLint x, GLint y, if ((stencilMask & stencilMax) != stencilMax) { /* need to apply writemask */ - GLubyte destVals[MAX_WIDTH], newVals[MAX_WIDTH]; + GLubyte *destVals = swrast->stencil_temp.buf1; + GLubyte *newVals = swrast->stencil_temp.buf2; GLint i; _mesa_unpack_ubyte_stencil_row(rb->Format, n, stencilBuf, destVals); diff --git a/mesalib/src/mesa/swrast/s_texcombine.c b/mesalib/src/mesa/swrast/s_texcombine.c index 1fce5c565..8fbf988b4 100644 --- a/mesalib/src/mesa/swrast/s_texcombine.c +++ b/mesalib/src/mesa/swrast/s_texcombine.c @@ -49,9 +49,9 @@ static inline float4_array get_texel_array(SWcontext *swrast, GLuint unit) { #ifdef _OPENMP - return (float4_array) (swrast->TexelBuffer + unit * MAX_WIDTH * 4 * omp_get_num_threads() + (MAX_WIDTH * 4 * omp_get_thread_num())); + return (float4_array) (swrast->TexelBuffer + unit * SWRAST_MAX_WIDTH * 4 * omp_get_num_threads() + (SWRAST_MAX_WIDTH * 4 * omp_get_thread_num())); #else - return (float4_array) (swrast->TexelBuffer + unit * MAX_WIDTH * 4); + return (float4_array) (swrast->TexelBuffer + unit * SWRAST_MAX_WIDTH * 4); #endif } @@ -611,7 +611,7 @@ _swrast_texture_span( struct gl_context *ctx, SWspan *span ) */ swrast->TexelBuffer = (GLfloat *) MALLOC(ctx->Const.MaxTextureImageUnits * maxThreads * - MAX_WIDTH * 4 * sizeof(GLfloat)); + SWRAST_MAX_WIDTH * 4 * sizeof(GLfloat)); if (!swrast->TexelBuffer) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "texture_combine"); return; @@ -625,7 +625,7 @@ _swrast_texture_span( struct gl_context *ctx, SWspan *span ) return; } - ASSERT(span->end <= MAX_WIDTH); + ASSERT(span->end <= SWRAST_MAX_WIDTH); /* * Save copy of the incoming fragment colors (the GL_PRIMARY_COLOR) diff --git a/mesalib/src/mesa/swrast/s_triangle.c b/mesalib/src/mesa/swrast/s_triangle.c index ddb4792f7..e89a999a9 100644 --- a/mesalib/src/mesa/swrast/s_triangle.c +++ b/mesalib/src/mesa/swrast/s_triangle.c @@ -142,7 +142,7 @@ _swrast_culltriangle( struct gl_context *ctx, #define RENDER_SPAN( span ) \ GLuint i; \ - GLubyte rgba[MAX_WIDTH][4]; \ + GLubyte (*rgba)[4] = swrast->SpanArrays->rgba8; \ span.intTex[0] -= FIXED_HALF; /* off-by-one error? */ \ span.intTex[1] -= FIXED_HALF; \ for (i = 0; i < span.end; i++) { \ @@ -200,7 +200,8 @@ _swrast_culltriangle( struct gl_context *ctx, #define RENDER_SPAN( span ) \ GLuint i; \ - GLubyte rgba[MAX_WIDTH][4]; \ + GLubyte (*rgba)[4] = swrast->SpanArrays->rgba8; \ + GLubyte *mask = swrast->SpanArrays->mask; \ span.intTex[0] -= FIXED_HALF; /* off-by-one error? */ \ span.intTex[1] -= FIXED_HALF; \ for (i = 0; i < span.end; i++) { \ @@ -215,17 +216,17 @@ _swrast_culltriangle( struct gl_context *ctx, rgba[i][BCOMP] = texture[pos+0]; \ rgba[i][ACOMP] = 0xff; \ zRow[i] = z; \ - span.array->mask[i] = 1; \ + mask[i] = 1; \ } \ else { \ - span.array->mask[i] = 0; \ + mask[i] = 0; \ } \ span.intTex[0] += span.intTexStep[0]; \ span.intTex[1] += span.intTexStep[1]; \ span.z += span.zStep; \ } \ _swrast_put_row(ctx, rb, GL_UNSIGNED_BYTE, \ - span.end, span.x, span.y, rgba, span.array->mask); + span.end, span.x, span.y, rgba, mask); #include "s_tritemp.h" diff --git a/mesalib/src/mesa/swrast/s_zoom.c b/mesalib/src/mesa/swrast/s_zoom.c index 73bff482b..768bbbafd 100644 --- a/mesalib/src/mesa/swrast/s_zoom.c +++ b/mesalib/src/mesa/swrast/s_zoom.c @@ -150,7 +150,7 @@ zoom_span( struct gl_context *ctx, GLint imgX, GLint imgY, const SWspan *span, zoomedWidth = x1 - x0; ASSERT(zoomedWidth > 0); - ASSERT(zoomedWidth <= MAX_WIDTH); + ASSERT(zoomedWidth <= SWRAST_MAX_WIDTH); /* no pixel arrays! must be horizontal spans. */ ASSERT((span->arrayMask & SPAN_XY) == 0); @@ -362,7 +362,7 @@ _swrast_write_zoomed_stencil_span(struct gl_context *ctx, GLint imgX, GLint imgY GLint width, GLint spanX, GLint spanY, const GLubyte stencil[]) { - GLubyte zoomedVals[MAX_WIDTH]; + GLubyte *zoomedVals; GLint x0, x1, y0, y1, y; GLint i, zoomedWidth; @@ -373,7 +373,11 @@ _swrast_write_zoomed_stencil_span(struct gl_context *ctx, GLint imgX, GLint imgY zoomedWidth = x1 - x0; ASSERT(zoomedWidth > 0); - ASSERT(zoomedWidth <= MAX_WIDTH); + ASSERT(zoomedWidth <= SWRAST_MAX_WIDTH); + + zoomedVals = (GLubyte *) malloc(zoomedWidth * sizeof(GLubyte)); + if (!zoomedVals) + return; /* zoom the span horizontally */ for (i = 0; i < zoomedWidth; i++) { @@ -387,6 +391,8 @@ _swrast_write_zoomed_stencil_span(struct gl_context *ctx, GLint imgX, GLint imgY for (y = y0; y < y1; y++) { _swrast_write_stencil_span(ctx, zoomedWidth, x0, y, zoomedVals); } + + free(zoomedVals); } @@ -401,7 +407,7 @@ _swrast_write_zoomed_z_span(struct gl_context *ctx, GLint imgX, GLint imgY, { struct gl_renderbuffer *rb = ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer; - GLuint zoomedVals[MAX_WIDTH]; + GLuint *zoomedVals; GLint x0, x1, y0, y1, y; GLint i, zoomedWidth; @@ -412,7 +418,11 @@ _swrast_write_zoomed_z_span(struct gl_context *ctx, GLint imgX, GLint imgY, zoomedWidth = x1 - x0; ASSERT(zoomedWidth > 0); - ASSERT(zoomedWidth <= MAX_WIDTH); + ASSERT(zoomedWidth <= SWRAST_MAX_WIDTH); + + zoomedVals = (GLuint *) malloc(zoomedWidth * sizeof(GLuint)); + if (!zoomedVals) + return; /* zoom the span horizontally */ for (i = 0; i < zoomedWidth; i++) { @@ -427,4 +437,6 @@ _swrast_write_zoomed_z_span(struct gl_context *ctx, GLint imgX, GLint imgY, GLubyte *dst = _swrast_pixel_address(rb, x0, y); _mesa_pack_uint_z_row(rb->Format, zoomedWidth, zoomedVals, dst); } + + free(zoomedVals); } diff --git a/mesalib/src/mesa/swrast/swrast.h b/mesalib/src/mesa/swrast/swrast.h index ad19eeecc..a299e6fda 100644 --- a/mesalib/src/mesa/swrast/swrast.h +++ b/mesalib/src/mesa/swrast/swrast.h @@ -35,6 +35,34 @@ #include "main/mtypes.h" #include "swrast/s_chan.h" + +/** + * If non-zero use GLdouble for walking triangle edges, for better accuracy. + */ +#define TRIANGLE_WALK_DOUBLE 0 + + +/** + * Bits per depth buffer value (max is 32). + */ +#ifndef DEFAULT_SOFTWARE_DEPTH_BITS +#define DEFAULT_SOFTWARE_DEPTH_BITS 16 +#endif +/** Depth buffer data type */ +#if DEFAULT_SOFTWARE_DEPTH_BITS <= 16 +#define DEFAULT_SOFTWARE_DEPTH_TYPE GLushort +#else +#define DEFAULT_SOFTWARE_DEPTH_TYPE GLuint +#endif + + +/** + * Max image/surface/texture size. + */ +#define SWRAST_MAX_WIDTH 16384 +#define SWRAST_MAX_HEIGHT 16384 + + /** * \struct SWvertex * \brief Data-structure to handle vertices in the software rasterizer. -- cgit v1.2.3