From ea0cd87ecbe9fc3c5503ccad7f87a895a458d6d4 Mon Sep 17 00:00:00 2001 From: marha Date: Thu, 1 May 2014 16:56:41 +0200 Subject: xkeyboard-config libxcb xserver mesa git update 1 May 2014 xserver commit 2535b76c0d32bc1dd0ddaca06a419a68a4757df1 libxcb commit d978a4f69b30b630f28d07f1003cf290284d24d8 xkeyboard-config commit 5274a69ee85fb6c425c33c631fa8ea1310a8f097 mesa commit a773fdc64da8ba88d8c7f8e383c45248b0c3aa19 --- mesalib/src/mesa/swrast/s_texture.c | 66 +++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 28 deletions(-) (limited to 'mesalib/src/mesa/swrast/s_texture.c') diff --git a/mesalib/src/mesa/swrast/s_texture.c b/mesalib/src/mesa/swrast/s_texture.c index c08a4e9d1..9ccd0e347 100644 --- a/mesalib/src/mesa/swrast/s_texture.c +++ b/mesalib/src/mesa/swrast/s_texture.c @@ -177,8 +177,8 @@ _swrast_free_texture_image_buffer(struct gl_context *ctx, * Error checking for debugging only. */ static void -_mesa_check_map_teximage(struct gl_texture_image *texImage, - GLuint slice, GLuint x, GLuint y, GLuint w, GLuint h) +check_map_teximage(const struct gl_texture_image *texImage, + GLuint slice, GLuint x, GLuint y, GLuint w, GLuint h) { if (texImage->TexObject->Target == GL_TEXTURE_1D) @@ -216,7 +216,16 @@ _swrast_map_teximage(struct gl_context *ctx, GLint stride, texelSize; GLuint bw, bh; - _mesa_check_map_teximage(texImage, slice, x, y, w, h); + check_map_teximage(texImage, slice, x, y, w, h); + + if (!swImage->Buffer) { + /* Either glTexImage was called with a NULL argument or + * we ran out of memory when allocating texture memory, + */ + *mapOut = NULL; + *rowStrideOut = 0; + return; + } texelSize = _mesa_get_format_bytes(texImage->TexFormat); stride = _mesa_format_row_stride(texImage->TexFormat, texImage->Width); @@ -225,12 +234,6 @@ _swrast_map_teximage(struct gl_context *ctx, assert(x % bw == 0); assert(y % bh == 0); - if (!swImage->Buffer) { - /* probably ran out of memory when allocating tex mem */ - *mapOut = NULL; - return; - } - /* This function can only be used with a swrast-allocated buffer, in which * case ImageSlices is populated with pointers into Buffer. */ @@ -266,7 +269,7 @@ _swrast_map_texture(struct gl_context *ctx, struct gl_texture_object *texObj) for (level = texObj->BaseLevel; level < MAX_TEXTURE_LEVELS; level++) { struct gl_texture_image *texImage = texObj->Image[face][level]; struct swrast_texture_image *swImage = swrast_texture_image(texImage); - unsigned int i; + unsigned int i, slices; if (!texImage) continue; @@ -279,7 +282,16 @@ _swrast_map_texture(struct gl_context *ctx, struct gl_texture_object *texObj) continue; } - for (i = 0; i < texture_slices(texImage); i++) { + if (!swImage->ImageSlices) { + swImage->ImageSlices = + calloc(texture_slices(texImage), sizeof(void *)); + if (!swImage->ImageSlices) + continue; + } + + slices = texture_slices(texImage); + + for (i = 0; i < slices; i++) { GLubyte *map; GLint rowStride; @@ -317,7 +329,7 @@ _swrast_unmap_texture(struct gl_context *ctx, struct gl_texture_object *texObj) for (level = texObj->BaseLevel; level < MAX_TEXTURE_LEVELS; level++) { struct gl_texture_image *texImage = texObj->Image[face][level]; struct swrast_texture_image *swImage = swrast_texture_image(texImage); - unsigned int i; + unsigned int i, slices; if (!texImage) continue; @@ -325,7 +337,12 @@ _swrast_unmap_texture(struct gl_context *ctx, struct gl_texture_object *texObj) if (swImage->Buffer) return; - for (i = 0; i < texture_slices(texImage); i++) { + if (!swImage->ImageSlices) + continue; + + slices = texture_slices(texImage); + + for (i = 0; i < slices; i++) { if (swImage->ImageSlices[i]) { ctx->Driver.UnmapTextureImage(ctx, texImage, i); swImage->ImageSlices[i] = NULL; @@ -342,16 +359,13 @@ _swrast_unmap_texture(struct gl_context *ctx, struct gl_texture_object *texObj) void _swrast_map_textures(struct gl_context *ctx) { - GLbitfield enabledUnits = ctx->Texture._EnabledUnits; + int unit; - /* loop over enabled texture units */ - while (enabledUnits) { - GLuint unit = ffs(enabledUnits) - 1; + for (unit = 0; unit <= ctx->Texture._MaxEnabledTexImageUnit; unit++) { struct gl_texture_object *texObj = ctx->Texture.Unit[unit]._Current; - - _swrast_map_texture(ctx, texObj); - enabledUnits &= ~(1 << unit); + if (texObj) + _swrast_map_texture(ctx, texObj); } } @@ -362,15 +376,11 @@ _swrast_map_textures(struct gl_context *ctx) void _swrast_unmap_textures(struct gl_context *ctx) { - GLbitfield enabledUnits = ctx->Texture._EnabledUnits; - - /* loop over enabled texture units */ - while (enabledUnits) { - GLuint unit = ffs(enabledUnits) - 1; + int unit; + for (unit = 0; unit <= ctx->Texture._MaxEnabledTexImageUnit; unit++) { struct gl_texture_object *texObj = ctx->Texture.Unit[unit]._Current; - - _swrast_unmap_texture(ctx, texObj); - enabledUnits &= ~(1 << unit); + if (texObj) + _swrast_unmap_texture(ctx, texObj); } } -- cgit v1.2.3