mesa: simplify some code with new _mesa_cube_face_target() function
authorBrian Paul <brianp@vmware.com>
Thu, 11 Feb 2016 15:14:27 +0000 (08:14 -0700)
committerBrian Paul <brianp@vmware.com>
Fri, 12 Feb 2016 22:11:38 +0000 (15:11 -0700)
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
src/mesa/main/mipmap.c
src/mesa/main/texobj.c
src/mesa/main/textureview.c

index 7fd6fbf53606911ed75adaffd0e354eafbe17df6..5a02780b96071403e23b94cb396f3411c2b6c398 100644 (file)
@@ -1838,12 +1838,7 @@ _mesa_prepare_mipmap_level(struct gl_context *ctx,
 
    for (face = 0; face < numFaces; face++) {
       struct gl_texture_image *dstImage;
-      GLenum target;
-
-      if (numFaces == 1)
-         target = texObj->Target;
-      else
-         target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + face;
+      const GLenum target = _mesa_cube_face_target(texObj->Target, face);
 
       dstImage = _mesa_get_tex_image(ctx, texObj, target, level);
       if (!dstImage) {
index c63d443bf29d2a9accfff856c32008dba45d5db3..d8407f04340f42c88b15f71b242efc26a6ef2dd9 100644 (file)
@@ -1036,12 +1036,7 @@ _mesa_get_fallback_texture(struct gl_context *ctx, gl_texture_index tex)
 
       /* need a loop here just for cube maps */
       for (face = 0; face < numFaces; face++) {
-         GLenum faceTarget;
-
-         if (target == GL_TEXTURE_CUBE_MAP)
-            faceTarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X + face;
-         else
-            faceTarget = target;
+         const GLenum faceTarget = _mesa_cube_face_target(target, face);
 
          /* initialize level[0] texture image */
          texImage = _mesa_get_tex_image(ctx, texObj, faceTarget, 0);
index 04b7d73da5c9ff25db91066b5bede62e5f0638ff..316d8280338e0ba6188d790ff74cc366f972130c 100644 (file)
@@ -211,10 +211,7 @@ initialize_texture_fields(struct gl_context *ctx,
    for (level = 0; level < levels; level++) {
       for (face = 0; face < numFaces; face++) {
          struct gl_texture_image *texImage;
-         GLenum faceTarget = target;
-
-         if (target == GL_TEXTURE_CUBE_MAP)
-            faceTarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X + face;
+         const GLenum faceTarget = _mesa_cube_face_target(target, face);
 
          texImage = _mesa_get_tex_image(ctx, texObj, faceTarget, level);
 
@@ -536,9 +533,7 @@ _mesa_TextureView(GLuint texture, GLenum target, GLuint origtexture,
    newViewNumLevels = MIN2(numlevels, origTexObj->NumLevels - minlevel);
    newViewNumLayers = MIN2(numlayers, origTexObj->NumLayers - minlayer);
 
-   faceTarget = origTexObj->Target;
-   if (faceTarget == GL_TEXTURE_CUBE_MAP)
-      faceTarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X + minlayer;
+   faceTarget = _mesa_cube_face_target(origTexObj->Target, minlayer);
 
    /* Get a reference to what will become this View's base level */
    origTexImage = _mesa_select_tex_image(origTexObj, faceTarget, minlevel);