From 0a92c88a51f8719ac256e93968ff8a3e3723a81d Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 23 Apr 2014 09:59:55 -0600 Subject: [PATCH] swrast: move texture_slices() calls out of loops MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: José Fonseca --- src/mesa/swrast/s_texture.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c index 9273e94f94b..5fd80ca4d83 100644 --- a/src/mesa/swrast/s_texture.c +++ b/src/mesa/swrast/s_texture.c @@ -269,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; @@ -289,7 +289,9 @@ _swrast_map_texture(struct gl_context *ctx, struct gl_texture_object *texObj) continue; } - for (i = 0; i < texture_slices(texImage); i++) { + slices = texture_slices(texImage); + + for (i = 0; i < slices; i++) { GLubyte *map; GLint rowStride; @@ -327,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; @@ -338,7 +340,9 @@ _swrast_unmap_texture(struct gl_context *ctx, struct gl_texture_object *texObj) if (!swImage->ImageSlices) continue; - for (i = 0; i < texture_slices(texImage); i++) { + slices = texture_slices(texImage); + + for (i = 0; i < slices; i++) { if (swImage->ImageSlices[i]) { ctx->Driver.UnmapTextureImage(ctx, texImage, i); swImage->ImageSlices[i] = NULL; -- 2.30.2