Mesa (master): mesa: consolidate multiple next_mipmap_level_size

Brian Paul brianp at kemper.freedesktop.org
Fri Dec 13 19:44:52 UTC 2013


Module: Mesa
Branch: master
Commit: bb5947de995d6425a681e591ed9566688772a3ca
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=bb5947de995d6425a681e591ed9566688772a3ca

Author: Courtney Goeltzenleuchter <courtney at LunarG.com>
Date:   Mon Nov 25 16:31:26 2013 -0700

mesa: consolidate multiple next_mipmap_level_size

Refactor to make next_mipmap_level_size defined in mipmap.c a
_mesa_ helper function that can then be used by texture_view

Signed-off-by: Courtney Goeltzenleuchter <courtney at LunarG.com>

Reviewed-by: Brian Paul <brianp at vmware.com>

---

 src/mesa/main/mipmap.c     |    8 ++++----
 src/mesa/main/mipmap.h     |    4 ++++
 src/mesa/main/texstorage.c |   25 +++----------------------
 3 files changed, 11 insertions(+), 26 deletions(-)

diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c
index 180f891..0330157 100644
--- a/src/mesa/main/mipmap.c
+++ b/src/mesa/main/mipmap.c
@@ -1767,8 +1767,8 @@ _mesa_generate_mipmap_level(GLenum target,
  * compute next (level+1) image size
  * \return GL_FALSE if no smaller size can be generated (eg. src is 1x1x1 size)
  */
-static GLboolean
-next_mipmap_level_size(GLenum target, GLint border,
+GLboolean
+_mesa_next_mipmap_level_size(GLenum target, GLint border,
                        GLint srcWidth, GLint srcHeight, GLint srcDepth,
                        GLint *dstWidth, GLint *dstHeight, GLint *dstDepth)
 {
@@ -1911,7 +1911,7 @@ generate_mipmap_uncompressed(struct gl_context *ctx, GLenum target,
       srcDepth = srcImage->Depth;
       border = srcImage->Border;
 
-      nextLevel = next_mipmap_level_size(target, border,
+      nextLevel = _mesa_next_mipmap_level_size(target, border,
                                          srcWidth, srcHeight, srcDepth,
                                          &dstWidth, &dstHeight, &dstDepth);
       if (!nextLevel)
@@ -2102,7 +2102,7 @@ generate_mipmap_compressed(struct gl_context *ctx, GLenum target,
       srcDepth = srcImage->Depth;
       border = srcImage->Border;
 
-      nextLevel = next_mipmap_level_size(target, border,
+      nextLevel = _mesa_next_mipmap_level_size(target, border,
                                          srcWidth, srcHeight, srcDepth,
                                          &dstWidth, &dstHeight, &dstDepth);
       if (!nextLevel)
diff --git a/src/mesa/main/mipmap.h b/src/mesa/main/mipmap.h
index d5bd1d8..ee91df0 100644
--- a/src/mesa/main/mipmap.h
+++ b/src/mesa/main/mipmap.h
@@ -51,5 +51,9 @@ extern void
 _mesa_generate_mipmap(struct gl_context *ctx, GLenum target,
                       struct gl_texture_object *texObj);
 
+extern GLboolean
+_mesa_next_mipmap_level_size(GLenum target, GLint border,
+                       GLint srcWidth, GLint srcHeight, GLint srcDepth,
+                       GLint *dstWidth, GLint *dstHeight, GLint *dstDepth);
 
 #endif /* MIPMAP_H */
diff --git a/src/mesa/main/texstorage.c b/src/mesa/main/texstorage.c
index 83561c1..1dd63a3 100644
--- a/src/mesa/main/texstorage.c
+++ b/src/mesa/main/texstorage.c
@@ -37,6 +37,7 @@
 #include "macros.h"
 #include "teximage.h"
 #include "texobj.h"
+#include "mipmap.h"
 #include "texstorage.h"
 #include "mtypes.h"
 
@@ -98,27 +99,6 @@ legal_texobj_target(struct gl_context *ctx, GLuint dims, GLenum target)
 }
 
 
-/**
- * Compute the size of the next mipmap level.
- */
-static void
-next_mipmap_level_size(GLenum target,
-                       GLint *width, GLint *height, GLint *depth)
-{
-   if (*width > 1) {
-      *width /= 2;
-   }
-
-   if ((*height > 1) && (target != GL_TEXTURE_1D_ARRAY)) {
-      *height /= 2;
-   }
-
-   if ((*depth > 1) && (target != GL_TEXTURE_2D_ARRAY)) {
-      *depth /= 2;
-   }
-}
-
-
 /** Helper to get a particular texture image in a texture object */
 static struct gl_texture_image *
 get_tex_image(struct gl_context *ctx, 
@@ -162,7 +142,8 @@ initialize_texture_fields(struct gl_context *ctx,
                                     0, internalFormat, texFormat);
       }
 
-      next_mipmap_level_size(target, &levelWidth, &levelHeight, &levelDepth);
+      _mesa_next_mipmap_level_size(target, 0, levelWidth, levelHeight, levelDepth,
+                                   &levelWidth, &levelHeight, &levelDepth);
    }
    return GL_TRUE;
 }




More information about the mesa-commit mailing list