swrast: move texture_slices() calls out of loops
authorBrian Paul <brianp@vmware.com>
Wed, 23 Apr 2014 15:59:55 +0000 (09:59 -0600)
committerBrian Paul <brianp@vmware.com>
Thu, 24 Apr 2014 14:16:01 +0000 (08:16 -0600)
Reviewed-by: José Fonseca <jfonseca@vmware.com>
src/mesa/swrast/s_texture.c

index 9273e94f94b6a98a28be0a384b53d4021cd20a0f..5fd80ca4d83c0f9162ec0feab43fa7eee989e110 100644 (file)
@@ -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;