mesa: Move compute_num_levels from st_gen_mipmap.c to mipmap.c.
authorKenneth Graunke <kenneth@whitecape.org>
Sun, 19 Jun 2016 07:36:48 +0000 (00:36 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Fri, 16 Feb 2018 18:48:10 +0000 (10:48 -0800)
I want to use compute_num_levels inside i965.  Rather than duplicating
it, move it from mesa/st to core Mesa, and make it non-static.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/mesa/main/mipmap.c
src/mesa/main/mipmap.h
src/mesa/state_tracker/st_gen_mipmap.c

index fc36d408f91baf9e7dd2edc79855e4aa8c570c7a..1ed82c52ab6d9e8fb80912dca7c65c91594edc8a 100644 (file)
 #include "util/format_r11g11b10f.h"
 
 
+/**
+ * Compute the expected number of mipmap levels in the texture given
+ * the width/height/depth of the base image and the GL_TEXTURE_BASE_LEVEL/
+ * GL_TEXTURE_MAX_LEVEL settings.  This will tell us how many mipmap
+ * levels should be generated.
+ */
+unsigned
+_mesa_compute_num_levels(struct gl_context *ctx,
+                         struct gl_texture_object *texObj,
+                         GLenum target)
+{
+   const struct gl_texture_image *baseImage;
+   GLuint numLevels;
+
+   baseImage = _mesa_get_tex_image(ctx, texObj, target, texObj->BaseLevel);
+
+   numLevels = texObj->BaseLevel + baseImage->MaxNumLevels;
+   numLevels = MIN2(numLevels, (GLuint) texObj->MaxLevel + 1);
+   if (texObj->Immutable)
+      numLevels = MIN2(numLevels, texObj->NumLevels);
+   assert(numLevels >= 1);
+
+   return numLevels;
+}
 
 static GLint
 bytes_per_pixel(GLenum datatype, GLuint comps)
index d11c7fada37b994cf13526912780a7859aeba8b9..1f108f7e5d8e82111927f69cea5d208421eec8d6 100644 (file)
 
 #include "mtypes.h"
 
+unsigned
+_mesa_compute_num_levels(struct gl_context *ctx,
+                         struct gl_texture_object *texObj,
+                         GLenum target);
 
 extern void
 _mesa_generate_mipmap_level(GLenum target,
index 16b914a88459e995cd676c4a41b03813c382eaf8..f2aa8005a035151065163b2fa337176b5f90906e 100644 (file)
 #include "st_cb_texture.h"
 
 
-/**
- * Compute the expected number of mipmap levels in the texture given
- * the width/height/depth of the base image and the GL_TEXTURE_BASE_LEVEL/
- * GL_TEXTURE_MAX_LEVEL settings.  This will tell us how many mipmap
- * levels should be generated.
- */
-static GLuint
-compute_num_levels(struct gl_context *ctx,
-                   struct gl_texture_object *texObj,
-                   GLenum target)
-{
-   const struct gl_texture_image *baseImage;
-   GLuint numLevels;
-
-   baseImage = _mesa_get_tex_image(ctx, texObj, target, texObj->BaseLevel);
-
-   numLevels = texObj->BaseLevel + baseImage->MaxNumLevels;
-   numLevels = MIN2(numLevels, (GLuint) texObj->MaxLevel + 1);
-   if (texObj->Immutable)
-      numLevels = MIN2(numLevels, texObj->NumLevels);
-   assert(numLevels >= 1);
-
-   return numLevels;
-}
-
-
 /**
  * Called via ctx->Driver.GenerateMipmap().
  */
@@ -92,7 +66,7 @@ st_generate_mipmap(struct gl_context *ctx, GLenum target,
    assert(pt->nr_samples < 2);
 
    /* find expected last mipmap level to generate*/
-   lastLevel = compute_num_levels(ctx, texObj, target) - 1;
+   lastLevel = _mesa_compute_num_levels(ctx, texObj, target) - 1;
 
    if (lastLevel == 0)
       return;