[Mesa-dev] [PATCH 4/4] swrast: move texture_slices() calls out of loops

Brian Paul brianp at vmware.com
Wed Apr 23 09:01:51 PDT 2014


---
 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 9273e94..5fd80ca 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;
-- 
1.7.10.4



More information about the mesa-dev mailing list