diff options
author | marha <marha@users.sourceforge.net> | 2012-02-27 07:24:18 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-02-27 07:24:18 +0100 |
commit | c4f44c07c6662d1ce08603945ccc4fa5afaa742a (patch) | |
tree | 5daa31bcbf8c90e74d99d679611a2d44f3ccede1 /mesalib/src/mesa | |
parent | 5fb4fb602bde5140dcea45464e3b70a49078ad2e (diff) | |
download | vcxsrv-c4f44c07c6662d1ce08603945ccc4fa5afaa742a.tar.gz vcxsrv-c4f44c07c6662d1ce08603945ccc4fa5afaa742a.tar.bz2 vcxsrv-c4f44c07c6662d1ce08603945ccc4fa5afaa742a.zip |
fontconfig pixman mesa git update 27 Feb 2012
Diffstat (limited to 'mesalib/src/mesa')
33 files changed, 493 insertions, 366 deletions
diff --git a/mesalib/src/mesa/SConscript b/mesalib/src/mesa/SConscript index e9b1f6aaf..10a04689d 100644 --- a/mesalib/src/mesa/SConscript +++ b/mesalib/src/mesa/SConscript @@ -384,7 +384,7 @@ if env['gles']: # # Assembly sources # -if env['gcc'] and env['platform'] != 'windows': +if env['gcc'] and env['platform'] not in ('darwin', 'windows'): if env['machine'] == 'x86': env.Append(CPPDEFINES = [ 'USE_X86_ASM', diff --git a/mesalib/src/mesa/drivers/dri/swrast/swrast.c b/mesalib/src/mesa/drivers/dri/swrast/swrast.c index d18dd0927..22d71bf10 100644 --- a/mesalib/src/mesa/drivers/dri/swrast/swrast.c +++ b/mesalib/src/mesa/drivers/dri/swrast/swrast.c @@ -469,7 +469,7 @@ dri_create_buffer(__DRIscreen * sPriv, dPriv->driverPrivate = drawable; drawable->dPriv = dPriv; - drawable->row = malloc(MAX_WIDTH * 4); + drawable->row = malloc(SWRAST_MAX_WIDTH * 4); if (drawable->row == NULL) goto drawable_fail; diff --git a/mesalib/src/mesa/drivers/windows/gdi/wgl.c b/mesalib/src/mesa/drivers/windows/gdi/wgl.c index 61850c26f..d99473bb3 100644 --- a/mesalib/src/mesa/drivers/windows/gdi/wgl.c +++ b/mesalib/src/mesa/drivers/windows/gdi/wgl.c @@ -33,6 +33,7 @@ #include "main/config.h" #include "glapi/glapi.h" +#include "swrast/swrast.h" #include "GL/wmesa.h" /* protos for wmesa* functions */ /* diff --git a/mesalib/src/mesa/main/config.h b/mesalib/src/mesa/main/config.h index 7b7740ebe..8bf741f99 100644 --- a/mesalib/src/mesa/main/config.h +++ b/mesalib/src/mesa/main/config.h @@ -46,9 +46,6 @@ /** Maximum texture matrix stack depth */ #define MAX_TEXTURE_STACK_DEPTH 10 -/** Maximum color matrix stack depth */ -#define MAX_COLOR_STACK_DEPTH 4 - /** Maximum attribute stack depth */ #define MAX_ATTRIB_STACK_DEPTH 16 @@ -74,11 +71,7 @@ #define MAX_AUX_BUFFERS 1 /** Maximum order (degree) of curves */ -#ifdef AMIGA -# define MAX_EVAL_ORDER 12 -#else -# define MAX_EVAL_ORDER 30 -#endif +#define MAX_EVAL_ORDER 30 /** Maximum Name stack depth */ #define MAX_NAME_STACK_DEPTH 64 @@ -115,7 +108,9 @@ /** Maximum rectangular texture size - GL_NV_texture_rectangle */ #define MAX_TEXTURE_RECT_SIZE 16384 -/** Maximum number of layers in a 1D or 2D array texture - GL_MESA_texture_array */ +/** + * Maximum number of layers in a 1D or 2D array texture - GL_MESA_texture_array + */ #define MAX_ARRAY_TEXTURE_LAYERS 64 /** @@ -141,34 +136,9 @@ #define MAX_TEXTURE_UNITS ((MAX_TEXTURE_COORD_UNITS > MAX_TEXTURE_IMAGE_UNITS) ? MAX_TEXTURE_COORD_UNITS : MAX_TEXTURE_IMAGE_UNITS) -/** - * Maximum viewport/image width. Must accomodate all texture sizes too. - */ - -#ifndef MAX_WIDTH -# define MAX_WIDTH 16384 -#endif -/** Maximum viewport/image height */ -#ifndef MAX_HEIGHT -# define MAX_HEIGHT 16384 -#endif - -/* XXX: hack to prevent stack overflow on windows until all temporary arrays - * [MAX_WIDTH] are allocated from the heap */ -#ifdef WIN32 -#undef MAX_TEXTURE_LEVELS -#undef MAX_3D_TEXTURE_LEVELS -#undef MAX_CUBE_TEXTURE_LEVELS -#undef MAX_TEXTURE_RECT_SIZE -#undef MAX_WIDTH -#undef MAX_HEIGHT -#define MAX_TEXTURE_LEVELS 13 -#define MAX_3D_TEXTURE_LEVELS 9 -#define MAX_CUBE_TEXTURE_LEVELS 13 -#define MAX_TEXTURE_RECT_SIZE 4096 -#define MAX_WIDTH 4096 -#define MAX_HEIGHT 4096 -#endif +/** Maximum viewport size */ +#define MAX_VIEWPORT_WIDTH 16384 +#define MAX_VIEWPORT_HEIGHT 16384 /** Maxmimum size for CVA. May be overridden by the drivers. */ #define MAX_ARRAY_LOCK_SIZE 3000 @@ -176,14 +146,6 @@ /** Subpixel precision for antialiasing, window coordinate snapping */ #define SUB_PIXEL_BITS 4 -/** Size of histogram tables */ -#define HISTOGRAM_TABLE_SIZE 256 - -/** Max convolution filter width */ -#define MAX_CONVOLUTION_WIDTH 9 -/** Max convolution filter height */ -#define MAX_CONVOLUTION_HEIGHT 9 - /** For GL_ARB_texture_compression */ #define MAX_COMPRESSED_TEXTURE_FORMATS 25 @@ -280,6 +242,7 @@ /** For GL_EXT_framebuffer_object */ /*@{*/ #define MAX_COLOR_ATTACHMENTS 8 +#define MAX_RENDERBUFFER_SIZE 16384 /*@}*/ /** For GL_ATI_envmap_bump - support bump mapping on first 8 units */ @@ -299,46 +262,6 @@ /*@}*/ -/** - * \name Mesa-specific parameters - */ -/*@{*/ - - -/** - * 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 - - -/** - * Bits per stencil value: 8 - */ -#define STENCIL_BITS 8 - - -/** - * For swrast, bits per color channel: 8, 16 or 32 - */ -#ifndef CHAN_BITS -#define CHAN_BITS 8 -#endif - - /* * Color channel component order * diff --git a/mesalib/src/mesa/main/context.c b/mesalib/src/mesa/main/context.c index 43e7438ad..8d48904f8 100644 --- a/mesalib/src/mesa/main/context.c +++ b/mesalib/src/mesa/main/context.c @@ -268,7 +268,7 @@ _mesa_initialize_visual( struct gl_config *vis, if (depthBits < 0 || depthBits > 32) { return GL_FALSE; } - if (stencilBits < 0 || stencilBits > STENCIL_BITS) { + if (stencilBits < 0 || stencilBits > 8) { return GL_FALSE; } assert(accumRedBits >= 0); @@ -586,8 +586,8 @@ _mesa_init_constants(struct gl_context *ctx) ctx->Const.MaxLights = MAX_LIGHTS; ctx->Const.MaxShininess = 128.0; ctx->Const.MaxSpotExponent = 128.0; - ctx->Const.MaxViewportWidth = MAX_WIDTH; - ctx->Const.MaxViewportHeight = MAX_HEIGHT; + ctx->Const.MaxViewportWidth = MAX_VIEWPORT_WIDTH; + ctx->Const.MaxViewportHeight = MAX_VIEWPORT_HEIGHT; #if FEATURE_ARB_vertex_program init_program_limits(GL_VERTEX_PROGRAM_ARB, &ctx->Const.VertexProgram); #endif @@ -608,7 +608,7 @@ _mesa_init_constants(struct gl_context *ctx) #if FEATURE_EXT_framebuffer_object ctx->Const.MaxColorAttachments = MAX_COLOR_ATTACHMENTS; - ctx->Const.MaxRenderbufferSize = MAX_WIDTH; + ctx->Const.MaxRenderbufferSize = MAX_RENDERBUFFER_SIZE; #endif #if FEATURE_ARB_vertex_shader @@ -712,20 +712,15 @@ check_context_limits(struct gl_context *ctx) assert(ctx->Const.MaxCubeTextureLevels <= MAX_CUBE_TEXTURE_LEVELS); assert(ctx->Const.MaxTextureRectSize <= MAX_TEXTURE_RECT_SIZE); - /* make sure largest texture image is <= MAX_WIDTH in size */ - assert((1 << (ctx->Const.MaxTextureLevels - 1)) <= MAX_WIDTH); - assert((1 << (ctx->Const.MaxCubeTextureLevels - 1)) <= MAX_WIDTH); - assert((1 << (ctx->Const.Max3DTextureLevels - 1)) <= MAX_WIDTH); - /* Texture level checks */ assert(MAX_TEXTURE_LEVELS >= MAX_3D_TEXTURE_LEVELS); assert(MAX_TEXTURE_LEVELS >= MAX_CUBE_TEXTURE_LEVELS); /* Max texture size should be <= max viewport size (render to texture) */ - assert((1 << (MAX_TEXTURE_LEVELS - 1)) <= MAX_WIDTH); - - assert(ctx->Const.MaxViewportWidth <= MAX_WIDTH); - assert(ctx->Const.MaxViewportHeight <= MAX_WIDTH); + assert((1 << (ctx->Const.MaxTextureLevels - 1)) + <= ctx->Const.MaxViewportWidth); + assert((1 << (ctx->Const.MaxTextureLevels - 1)) + <= ctx->Const.MaxViewportHeight); assert(ctx->Const.MaxDrawBuffers <= MAX_DRAW_BUFFERS); diff --git a/mesalib/src/mesa/main/readpix.c b/mesalib/src/mesa/main/readpix.c index 48708a6eb..0f429ab22 100644 --- a/mesalib/src/mesa/main/readpix.c +++ b/mesalib/src/mesa/main/readpix.c @@ -110,6 +110,7 @@ read_depth_pixels( struct gl_context *ctx, GLint j; GLubyte *dst, *map; int dstStride, stride; + GLfloat *depthValues; if (!rb) return; @@ -119,8 +120,6 @@ read_depth_pixels( struct gl_context *ctx, ASSERT(y >= 0); ASSERT(x + width <= (GLint) rb->Width); ASSERT(y + height <= (GLint) rb->Height); - /* width should never be > MAX_WIDTH since we did clipping earlier */ - ASSERT(width <= MAX_WIDTH); if (fast_read_depth_pixels(ctx, x, y, width, height, type, pixels, packing)) return; @@ -136,16 +135,24 @@ read_depth_pixels( struct gl_context *ctx, return; } - /* General case (slower) */ - for (j = 0; j < height; j++, y++) { - GLfloat depthValues[MAX_WIDTH]; - _mesa_unpack_float_z_row(rb->Format, width, map, depthValues); - _mesa_pack_depth_span(ctx, width, dst, type, depthValues, packing); + depthValues = (GLfloat *) malloc(width * sizeof(GLfloat)); - dst += dstStride; - map += stride; + if (depthValues) { + /* General case (slower) */ + for (j = 0; j < height; j++, y++) { + _mesa_unpack_float_z_row(rb->Format, width, map, depthValues); + _mesa_pack_depth_span(ctx, width, dst, type, depthValues, packing); + + dst += dstStride; + map += stride; + } + } + else { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glReadPixels"); } + free(depthValues); + ctx->Driver.UnmapRenderbuffer(ctx, rb); } @@ -163,15 +170,12 @@ read_stencil_pixels( struct gl_context *ctx, struct gl_framebuffer *fb = ctx->ReadBuffer; struct gl_renderbuffer *rb = fb->Attachment[BUFFER_STENCIL].Renderbuffer; GLint j; - GLubyte *map; + GLubyte *map, *stencil; GLint stride; if (!rb) return; - /* width should never be > MAX_WIDTH since we did clipping earlier */ - ASSERT(width <= MAX_WIDTH); - ctx->Driver.MapRenderbuffer(ctx, rb, x, y, width, height, GL_MAP_READ_BIT, &map, &stride); if (!map) { @@ -179,19 +183,27 @@ read_stencil_pixels( struct gl_context *ctx, return; } - /* process image row by row */ - for (j = 0; j < height; j++) { - GLvoid *dest; - GLubyte stencil[MAX_WIDTH]; + stencil = (GLubyte *) malloc(width * sizeof(GLubyte)); - _mesa_unpack_ubyte_stencil_row(rb->Format, width, map, stencil); - dest = _mesa_image_address2d(packing, pixels, width, height, - GL_STENCIL_INDEX, type, j, 0); + if (stencil) { + /* process image row by row */ + for (j = 0; j < height; j++) { + GLvoid *dest; - _mesa_pack_stencil_span(ctx, width, type, dest, stencil, packing); + _mesa_unpack_ubyte_stencil_row(rb->Format, width, map, stencil); + dest = _mesa_image_address2d(packing, pixels, width, height, + GL_STENCIL_INDEX, type, j, 0); - map += stride; + _mesa_pack_stencil_span(ctx, width, type, dest, stencil, packing); + + map += stride; + } } + else { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glReadPixels"); + } + + free(stencil); ctx->Driver.UnmapRenderbuffer(ctx, rb); } @@ -378,7 +390,7 @@ fast_read_depth_stencil_pixels_separate(struct gl_context *ctx, struct gl_framebuffer *fb = ctx->ReadBuffer; struct gl_renderbuffer *depthRb = fb->Attachment[BUFFER_DEPTH].Renderbuffer; struct gl_renderbuffer *stencilRb = fb->Attachment[BUFFER_STENCIL].Renderbuffer; - GLubyte *depthMap, *stencilMap; + GLubyte *depthMap, *stencilMap, *stencilVals; int depthStride, stencilStride, i, j; if (_mesa_get_format_datatype(depthRb->Format) != GL_UNSIGNED_NORMALIZED) @@ -399,21 +411,28 @@ fast_read_depth_stencil_pixels_separate(struct gl_context *ctx, return GL_TRUE; /* don't bother trying the slow path */ } - for (j = 0; j < height; j++) { - GLubyte stencilVals[MAX_WIDTH]; + stencilVals = (GLubyte *) malloc(width * sizeof(GLubyte)); - _mesa_unpack_uint_z_row(depthRb->Format, width, depthMap, dst); - _mesa_unpack_ubyte_stencil_row(stencilRb->Format, width, - stencilMap, stencilVals); + if (stencilVals) { + for (j = 0; j < height; j++) { + _mesa_unpack_uint_z_row(depthRb->Format, width, depthMap, dst); + _mesa_unpack_ubyte_stencil_row(stencilRb->Format, width, + stencilMap, stencilVals); - for (i = 0; i < width; i++) { - dst[i] = (dst[i] & 0xffffff00) | stencilVals[i]; - } + for (i = 0; i < width; i++) { + dst[i] = (dst[i] & 0xffffff00) | stencilVals[i]; + } - depthMap += depthStride; - stencilMap += stencilStride; - dst += dstStride / 4; + depthMap += depthStride; + stencilMap += stencilStride; + dst += dstStride / 4; + } } + else { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glReadPixels"); + } + + free(stencilVals); ctx->Driver.UnmapRenderbuffer(ctx, depthRb); ctx->Driver.UnmapRenderbuffer(ctx, stencilRb); @@ -434,6 +453,9 @@ slow_read_depth_stencil_pixels_separate(struct gl_context *ctx, struct gl_renderbuffer *stencilRb = fb->Attachment[BUFFER_STENCIL].Renderbuffer; GLubyte *depthMap, *stencilMap; int depthStride, stencilStride, j; + GLubyte *stencilVals; + GLfloat *depthVals; + /* The depth and stencil buffers might be separate, or a single buffer. * If one buffer, only map it once. @@ -460,21 +482,29 @@ slow_read_depth_stencil_pixels_separate(struct gl_context *ctx, stencilStride = depthStride; } - for (j = 0; j < height; j++) { - GLubyte stencilVals[MAX_WIDTH]; - GLfloat depthVals[MAX_WIDTH]; + stencilVals = (GLubyte *) malloc(width * sizeof(GLubyte)); + depthVals = (GLfloat *) malloc(width * sizeof(GLfloat)); - _mesa_unpack_float_z_row(depthRb->Format, width, depthMap, depthVals); - _mesa_unpack_ubyte_stencil_row(stencilRb->Format, width, - stencilMap, stencilVals); + if (stencilVals && depthVals) { + for (j = 0; j < height; j++) { + _mesa_unpack_float_z_row(depthRb->Format, width, depthMap, depthVals); + _mesa_unpack_ubyte_stencil_row(stencilRb->Format, width, + stencilMap, stencilVals); - _mesa_pack_depth_stencil_span(ctx, width, type, (GLuint *)dst, - depthVals, stencilVals, packing); + _mesa_pack_depth_stencil_span(ctx, width, type, (GLuint *)dst, + depthVals, stencilVals, packing); - depthMap += depthStride; - stencilMap += stencilStride; - dst += dstStride; + depthMap += depthStride; + stencilMap += stencilStride; + dst += dstStride; + } } + else { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glReadPixels"); + } + + free(stencilVals); + free(depthVals); ctx->Driver.UnmapRenderbuffer(ctx, depthRb); if (stencilRb != depthRb) { diff --git a/mesalib/src/mesa/main/texstore.c b/mesalib/src/mesa/main/texstore.c index e8190c392..d368b1868 100644 --- a/mesalib/src/mesa/main/texstore.c +++ b/mesalib/src/mesa/main/texstore.c @@ -2797,6 +2797,15 @@ _mesa_texstore_z24_s8(TEXSTORE_PARAMS) } else if (srcFormat == GL_DEPTH_COMPONENT || srcFormat == GL_STENCIL_INDEX) { + GLuint *depth = (GLuint *) malloc(srcWidth * sizeof(GLuint)); + GLubyte *stencil = (GLubyte *) malloc(srcWidth * sizeof(GLubyte)); + + if (!depth || !stencil) { + free(depth); + free(stencil); + return GL_FALSE; + } + /* In case we only upload depth we need to preserve the stencil */ for (img = 0; img < srcDepth; img++) { GLuint *dstRow = (GLuint *) dstSlices[img]; @@ -2806,8 +2815,6 @@ _mesa_texstore_z24_s8(TEXSTORE_PARAMS) srcFormat, srcType, img, 0, 0); for (row = 0; row < srcHeight; row++) { - GLuint depth[MAX_WIDTH]; - GLubyte stencil[MAX_WIDTH]; GLint i; GLboolean keepdepth = GL_FALSE, keepstencil = GL_FALSE; @@ -2845,6 +2852,9 @@ _mesa_texstore_z24_s8(TEXSTORE_PARAMS) dstRow += dstRowStride / sizeof(GLuint); } } + + free(depth); + free(stencil); } return GL_TRUE; } @@ -2860,6 +2870,8 @@ _mesa_texstore_s8_z24(TEXSTORE_PARAMS) const GLint srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); GLint img, row; + GLuint *depth; + GLubyte *stencil; ASSERT(dstFormat == MESA_FORMAT_S8_Z24); ASSERT(srcFormat == GL_DEPTH_STENCIL_EXT || @@ -2868,6 +2880,15 @@ _mesa_texstore_s8_z24(TEXSTORE_PARAMS) ASSERT(srcFormat != GL_DEPTH_STENCIL_EXT || srcType == GL_UNSIGNED_INT_24_8_EXT); + depth = (GLuint *) malloc(srcWidth * sizeof(GLuint)); + stencil = (GLubyte *) malloc(srcWidth * sizeof(GLubyte)); + + if (!depth || !stencil) { + free(depth); + free(stencil); + return GL_FALSE; + } + for (img = 0; img < srcDepth; img++) { GLuint *dstRow = (GLuint *) dstSlices[img]; const GLubyte *src @@ -2876,8 +2897,6 @@ _mesa_texstore_s8_z24(TEXSTORE_PARAMS) srcFormat, srcType, img, 0, 0); for (row = 0; row < srcHeight; row++) { - GLuint depth[MAX_WIDTH]; - GLubyte stencil[MAX_WIDTH]; GLint i; GLboolean keepdepth = GL_FALSE, keepstencil = GL_FALSE; @@ -2916,6 +2935,10 @@ _mesa_texstore_s8_z24(TEXSTORE_PARAMS) dstRow += dstRowStride / sizeof(GLuint); } } + + free(depth); + free(stencil); + return GL_TRUE; } @@ -2944,7 +2967,11 @@ _mesa_texstore_s8(TEXSTORE_PARAMS) const GLint srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); GLint img, row; - + GLubyte *stencil = (GLubyte *) malloc(srcWidth * sizeof(GLubyte)); + + if (!stencil) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { GLubyte *dstRow = dstSlices[img]; const GLubyte *src @@ -2953,7 +2980,6 @@ _mesa_texstore_s8(TEXSTORE_PARAMS) srcFormat, srcType, img, 0, 0); for (row = 0; row < srcHeight; row++) { - GLubyte stencil[MAX_WIDTH]; GLint i; /* get the 8-bit stencil values */ @@ -2971,6 +2997,7 @@ _mesa_texstore_s8(TEXSTORE_PARAMS) } } + free(stencil); } return GL_TRUE; diff --git a/mesalib/src/mesa/program/prog_execute.h b/mesalib/src/mesa/program/prog_execute.h index 6365b0741..1ae302c32 100644 --- a/mesalib/src/mesa/program/prog_execute.h +++ b/mesalib/src/mesa/program/prog_execute.h @@ -1,87 +1,91 @@ -/*
- * Mesa 3-D graphics library
- * Version: 7.0.3
- *
- * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#ifndef PROG_EXECUTE_H
-#define PROG_EXECUTE_H
-
-#include "main/config.h"
-#include "main/mtypes.h"
-
-
-typedef void (*FetchTexelLodFunc)(struct gl_context *ctx, const GLfloat texcoord[4],
- GLfloat lambda, GLuint unit, GLfloat color[4]);
-
-typedef void (*FetchTexelDerivFunc)(struct gl_context *ctx, const GLfloat texcoord[4],
- const GLfloat texdx[4],
- const GLfloat texdy[4],
- GLfloat lodBias,
- GLuint unit, GLfloat color[4]);
-
-
-/**
- * Virtual machine state used during execution of vertex/fragment programs.
- */
-struct gl_program_machine
-{
- const struct gl_program *CurProgram;
-
- /** Fragment Input attributes */
- GLfloat (*Attribs)[MAX_WIDTH][4];
- GLfloat (*DerivX)[4];
- GLfloat (*DerivY)[4];
- GLuint NumDeriv; /**< Max index into DerivX/Y arrays */
- GLuint CurElement; /**< Index into Attribs arrays */
-
- /** Vertex Input attribs */
- GLfloat VertAttribs[VERT_ATTRIB_MAX][4];
-
- GLfloat Temporaries[MAX_PROGRAM_TEMPS][4];
- GLfloat Outputs[MAX_PROGRAM_OUTPUTS][4];
- GLfloat (*EnvParams)[4]; /**< Vertex or Fragment env parameters */
- GLuint CondCodes[4]; /**< COND_* value for x/y/z/w */
- GLint AddressReg[MAX_PROGRAM_ADDRESS_REGS][4];
- GLfloat SystemValues[SYSTEM_VALUE_MAX][4];
-
- const GLubyte *Samplers; /** Array mapping sampler var to tex unit */
-
- GLuint CallStack[MAX_PROGRAM_CALL_DEPTH]; /**< For CAL/RET instructions */
- GLuint StackDepth; /**< Index/ptr to top of CallStack[] */
-
- /** Texture fetch functions */
- FetchTexelLodFunc FetchTexelLod;
- FetchTexelDerivFunc FetchTexelDeriv;
-};
-
-
-extern void
-_mesa_get_program_register(struct gl_context *ctx, gl_register_file file,
- GLuint index, GLfloat val[4]);
-
-extern GLboolean
-_mesa_execute_program(struct gl_context *ctx,
- const struct gl_program *program,
- struct gl_program_machine *machine);
-
-
-#endif /* PROG_EXECUTE_H */
+/* + * Mesa 3-D graphics library + * Version: 7.0.3 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef PROG_EXECUTE_H +#define PROG_EXECUTE_H + +#include "main/config.h" +#include "main/mtypes.h" + + +typedef void (*FetchTexelLodFunc)(struct gl_context *ctx, const GLfloat texcoord[4], + GLfloat lambda, GLuint unit, GLfloat color[4]); + +typedef void (*FetchTexelDerivFunc)(struct gl_context *ctx, const GLfloat texcoord[4], + const GLfloat texdx[4], + const GLfloat texdy[4], + GLfloat lodBias, + GLuint unit, GLfloat color[4]); + + +/** NOTE: This must match SWRAST_MAX_WIDTH */ +#define PROG_MAX_WIDTH 16384 + + +/** + * Virtual machine state used during execution of vertex/fragment programs. + */ +struct gl_program_machine +{ + const struct gl_program *CurProgram; + + /** Fragment Input attributes */ + GLfloat (*Attribs)[PROG_MAX_WIDTH][4]; + GLfloat (*DerivX)[4]; + GLfloat (*DerivY)[4]; + GLuint NumDeriv; /**< Max index into DerivX/Y arrays */ + GLuint CurElement; /**< Index into Attribs arrays */ + + /** Vertex Input attribs */ + GLfloat VertAttribs[VERT_ATTRIB_MAX][4]; + + GLfloat Temporaries[MAX_PROGRAM_TEMPS][4]; + GLfloat Outputs[MAX_PROGRAM_OUTPUTS][4]; + GLfloat (*EnvParams)[4]; /**< Vertex or Fragment env parameters */ + GLuint CondCodes[4]; /**< COND_* value for x/y/z/w */ + GLint AddressReg[MAX_PROGRAM_ADDRESS_REGS][4]; + GLfloat SystemValues[SYSTEM_VALUE_MAX][4]; + + const GLubyte *Samplers; /** Array mapping sampler var to tex unit */ + + GLuint CallStack[MAX_PROGRAM_CALL_DEPTH]; /**< For CAL/RET instructions */ + GLuint StackDepth; /**< Index/ptr to top of CallStack[] */ + + /** Texture fetch functions */ + FetchTexelLodFunc FetchTexelLod; + FetchTexelDerivFunc FetchTexelDeriv; +}; + + +extern void +_mesa_get_program_register(struct gl_context *ctx, gl_register_file file, + GLuint index, GLfloat val[4]); + +extern GLboolean +_mesa_execute_program(struct gl_context *ctx, + const struct gl_program *program, + struct gl_program_machine *machine); + + +#endif /* PROG_EXECUTE_H */ diff --git a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c index de4c189a8..18d0e53d4 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c @@ -824,9 +824,10 @@ draw_stencil_pixels(struct gl_context *ctx, GLint x, GLint y, enum pipe_transfer_usage usage; struct pipe_transfer *pt; const GLboolean zoom = ctx->Pixel.ZoomX != 1.0 || ctx->Pixel.ZoomY != 1.0; - GLint skipPixels; ubyte *stmap; struct gl_pixelstore_attrib clippedUnpack = *unpack; + GLubyte *sValues; + GLuint *zValues; if (!zoom) { if (!_mesa_clip_drawpixels(ctx, &x, &y, &width, &height, @@ -862,22 +863,19 @@ draw_stencil_pixels(struct gl_context *ctx, GLint x, GLint y, pixels = _mesa_map_pbo_source(ctx, &clippedUnpack, pixels); assert(pixels); - /* if width > MAX_WIDTH, have to process image in chunks */ - skipPixels = 0; - while (skipPixels < width) { - const GLint spanX = skipPixels; - const GLint spanWidth = MIN2(width - skipPixels, MAX_WIDTH); + sValues = (GLubyte *) malloc(width * sizeof(GLubyte)); + zValues = (GLuint *) malloc(width * sizeof(GLuint)); + + if (sValues && zValues) { GLint row; for (row = 0; row < height; row++) { - GLubyte sValues[MAX_WIDTH]; - GLuint zValues[MAX_WIDTH]; GLfloat *zValuesFloat = (GLfloat*)zValues; GLenum destType = GL_UNSIGNED_BYTE; const GLvoid *source = _mesa_image_address2d(&clippedUnpack, pixels, width, height, format, type, - row, skipPixels); - _mesa_unpack_stencil_span(ctx, spanWidth, destType, sValues, + row, 0); + _mesa_unpack_stencil_span(ctx, width, destType, sValues, type, source, &clippedUnpack, ctx->_ImageTransferState); @@ -886,7 +884,7 @@ draw_stencil_pixels(struct gl_context *ctx, GLint x, GLint y, pt->resource->format == PIPE_FORMAT_Z32_FLOAT_S8X24_UINT ? GL_FLOAT : GL_UNSIGNED_INT; - _mesa_unpack_depth_span(ctx, spanWidth, ztype, zValues, + _mesa_unpack_depth_span(ctx, width, ztype, zValues, (1 << 24) - 1, type, source, &clippedUnpack); } @@ -910,63 +908,63 @@ draw_stencil_pixels(struct gl_context *ctx, GLint x, GLint y, switch (pt->resource->format) { case PIPE_FORMAT_S8_UINT: { - ubyte *dest = stmap + spanY * pt->stride + spanX; + ubyte *dest = stmap + spanY * pt->stride; assert(usage == PIPE_TRANSFER_WRITE); - memcpy(dest, sValues, spanWidth); + memcpy(dest, sValues, width); } break; case PIPE_FORMAT_Z24_UNORM_S8_UINT: if (format == GL_DEPTH_STENCIL) { - uint *dest = (uint *) (stmap + spanY * pt->stride + spanX*4); + uint *dest = (uint *) (stmap + spanY * pt->stride); GLint k; assert(usage == PIPE_TRANSFER_WRITE); - for (k = 0; k < spanWidth; k++) { + for (k = 0; k < width; k++) { dest[k] = zValues[k] | (sValues[k] << 24); } } else { - uint *dest = (uint *) (stmap + spanY * pt->stride + spanX*4); + uint *dest = (uint *) (stmap + spanY * pt->stride); GLint k; assert(usage == PIPE_TRANSFER_READ_WRITE); - for (k = 0; k < spanWidth; k++) { + for (k = 0; k < width; k++) { dest[k] = (dest[k] & 0xffffff) | (sValues[k] << 24); } } break; case PIPE_FORMAT_S8_UINT_Z24_UNORM: if (format == GL_DEPTH_STENCIL) { - uint *dest = (uint *) (stmap + spanY * pt->stride + spanX*4); + uint *dest = (uint *) (stmap + spanY * pt->stride); GLint k; assert(usage == PIPE_TRANSFER_WRITE); - for (k = 0; k < spanWidth; k++) { + for (k = 0; k < width; k++) { dest[k] = (zValues[k] << 8) | (sValues[k] & 0xff); } } else { - uint *dest = (uint *) (stmap + spanY * pt->stride + spanX*4); + uint *dest = (uint *) (stmap + spanY * pt->stride); GLint k; assert(usage == PIPE_TRANSFER_READ_WRITE); - for (k = 0; k < spanWidth; k++) { + for (k = 0; k < width; k++) { dest[k] = (dest[k] & 0xffffff00) | (sValues[k] & 0xff); } } break; case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT: if (format == GL_DEPTH_STENCIL) { - uint *dest = (uint *) (stmap + spanY * pt->stride + spanX*4); + uint *dest = (uint *) (stmap + spanY * pt->stride); GLfloat *destf = (GLfloat*)dest; GLint k; assert(usage == PIPE_TRANSFER_WRITE); - for (k = 0; k < spanWidth; k++) { + for (k = 0; k < width; k++) { destf[k*2] = zValuesFloat[k]; dest[k*2+1] = sValues[k] & 0xff; } } else { - uint *dest = (uint *) (stmap + spanY * pt->stride + spanX*4); + uint *dest = (uint *) (stmap + spanY * pt->stride); GLint k; assert(usage == PIPE_TRANSFER_READ_WRITE); - for (k = 0; k < spanWidth; k++) { + for (k = 0; k < width; k++) { dest[k*2+1] = sValues[k] & 0xff; } } @@ -976,8 +974,13 @@ draw_stencil_pixels(struct gl_context *ctx, GLint x, GLint y, } } } - skipPixels += spanWidth; } + else { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glDrawPixels()"); + } + + free(sValues); + free(zValues); _mesa_unmap_pbo_source(ctx, &clippedUnpack); diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c index d887455e6..ea59ccf25 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_texture.c +++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c @@ -684,9 +684,16 @@ decompress_with_blit(struct gl_context * ctx, /* format translation via floats */ GLuint row; enum pipe_format pformat = util_format_linear(dst_texture->format); + GLfloat *rgba; + + rgba = (GLfloat *) malloc(width * 4 * sizeof(GLfloat)); + if (!rgba) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage()"); + goto end; + } + for (row = 0; row < height; row++) { const GLbitfield transferOps = 0x0; /* bypassed for glGetTexImage() */ - GLfloat rgba[4 * MAX_WIDTH]; GLvoid *dest = _mesa_image_address2d(&ctx->Pack, pixels, width, height, format, type, row, 0); @@ -700,8 +707,11 @@ decompress_with_blit(struct gl_context * ctx, _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba, format, type, dest, &ctx->Pack, transferOps); } + + free(rgba); } +end: _mesa_unmap_pbo_dest(ctx, &ctx->Pack); pipe->transfer_destroy(pipe, tex_xfer); @@ -763,8 +773,6 @@ fallback_copy_texsubimage(struct gl_context *ctx, if (ST_DEBUG & DEBUG_FALLBACK) debug_printf("%s: fallback processing\n", __FUNCTION__); - assert(width <= MAX_WIDTH); - if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) { srcY = strb->Base.Height - srcY - height; } @@ -793,6 +801,7 @@ fallback_copy_texsubimage(struct gl_context *ctx, const GLboolean scaleOrBias = (ctx->Pixel.DepthScale != 1.0F || ctx->Pixel.DepthBias != 0.0F); GLint row, yStep; + uint *data; /* determine bottom-to-top vs. top-to-bottom order for src buffer */ if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) { @@ -804,15 +813,23 @@ fallback_copy_texsubimage(struct gl_context *ctx, yStep = 1; } - /* To avoid a large temp memory allocation, do copy row by row */ - for (row = 0; row < height; row++, srcY += yStep) { - uint data[MAX_WIDTH]; - pipe_get_tile_z(pipe, src_trans, 0, srcY, width, 1, data); - if (scaleOrBias) { - _mesa_scale_and_bias_depth_uint(ctx, width, data); + data = (uint *) malloc(width * sizeof(uint)); + + if (data) { + /* To avoid a large temp memory allocation, do copy row by row */ + for (row = 0; row < height; row++, srcY += yStep) { + pipe_get_tile_z(pipe, src_trans, 0, srcY, width, 1, data); + if (scaleOrBias) { + _mesa_scale_and_bias_depth_uint(ctx, width, data); + } + pipe_put_tile_z(pipe, stImage->transfer, 0, row, width, 1, data); } - pipe_put_tile_z(pipe, stImage->transfer, 0, row, width, 1, data); } + else { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage()"); + } + + free(data); } else { /* RGBA format */ diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c index fb36a6809..33bc6ed72 100644 --- a/mesalib/src/mesa/state_tracker/st_extensions.c +++ b/mesalib/src/mesa/state_tracker/st_extensions.c @@ -108,6 +108,14 @@ void st_init_limits(struct st_context *st) c->MaxTextureUnits = _min(c->MaxTextureImageUnits, c->MaxTextureCoordUnits); + /* Define max viewport size and max renderbuffer size in terms of + * max texture size (note: max tex RECT size = max tex 2D size). + * If this isn't true for some hardware we'll need new PIPE_CAP_ queries. + */ + c->MaxViewportWidth = + c->MaxViewportHeight = + c->MaxRenderbufferSize = c->MaxTextureRectSize; + c->MaxDrawBuffers = _clamp(screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS), 1, MAX_DRAW_BUFFERS); diff --git a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index f139e95fe..b0227855c 100644 --- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -4746,8 +4746,6 @@ get_mesa_program(struct gl_context *ctx, { glsl_to_tgsi_visitor* v = new glsl_to_tgsi_visitor(); struct gl_program *prog; - struct pipe_screen * screen = st_context(ctx)->pipe->screen; - unsigned pipe_shader_type; GLenum target; const char *target_string; bool progress; @@ -4758,17 +4756,14 @@ get_mesa_program(struct gl_context *ctx, case GL_VERTEX_SHADER: target = GL_VERTEX_PROGRAM_ARB; target_string = "vertex"; - pipe_shader_type = PIPE_SHADER_VERTEX; break; case GL_FRAGMENT_SHADER: target = GL_FRAGMENT_PROGRAM_ARB; target_string = "fragment"; - pipe_shader_type = PIPE_SHADER_FRAGMENT; break; case GL_GEOMETRY_SHADER: target = GL_GEOMETRY_PROGRAM_NV; target_string = "geometry"; - pipe_shader_type = PIPE_SHADER_GEOMETRY; break; default: assert(!"should not be reached"); @@ -4792,12 +4787,8 @@ get_mesa_program(struct gl_context *ctx, _mesa_generate_parameters_list_for_uniforms(shader_program, shader, prog->Parameters); - if (!screen->get_shader_param(screen, pipe_shader_type, - PIPE_SHADER_CAP_OUTPUT_READ)) { - /* Remove reads to output registers, and to varyings in vertex shaders. */ - lower_output_reads(shader->ir); - } - + /* Remove reads from output registers. */ + lower_output_reads(shader->ir); /* Emit intermediate IR for main(). */ visit_exec_list(shader->ir, v); 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 @@ -36,6 +36,14 @@ /** + * Default bits per color channel: 8, 16 or 32 + */ +#ifndef CHAN_BITS +#define CHAN_BITS 8 +#endif + + +/** * Color channel data type. */ #if CHAN_BITS == 8 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. |