summaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2012-02-19 20:08:51 -0700
committerBrian Paul <[email protected]>2012-02-24 07:59:59 -0700
commit3e88e432244336518e1bbcf303ee53eae4df2a02 (patch)
tree84c97e4d1e2606a6743bdc8b4e03e8588846aa70 /src/mesa/state_tracker
parent62c69c340e71e97ddeaa757e033b8132399b9438 (diff)
st/mesa: stop using MAX_WIDTH in st_cb_texture.c
Reviewed-by: José Fonseca <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c37
1 files changed, 27 insertions, 10 deletions
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index d887455e605..ea59ccf255c 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/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 */