[Mesa-dev] [PATCH 3/4] mesa: Move compute_num_levels from st_gen_mipmap.c to mipmap.c.
Marek Olšák
maraeo at gmail.com
Sat Jan 20 21:43:25 UTC 2018
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Marek
On Thu, Jan 18, 2018 at 10:31 AM, Kenneth Graunke <kenneth at whitecape.org> wrote:
> 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.
> ---
> src/mesa/main/mipmap.c | 24 ++++++++++++++++++++++++
> src/mesa/main/mipmap.h | 4 ++++
> src/mesa/state_tracker/st_gen_mipmap.c | 28 +---------------------------
> 3 files changed, 29 insertions(+), 27 deletions(-)
>
> diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c
> index fc36d408f91..1ed82c52ab6 100644
> --- a/src/mesa/main/mipmap.c
> +++ b/src/mesa/main/mipmap.c
> @@ -42,6 +42,30 @@
> #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)
> diff --git a/src/mesa/main/mipmap.h b/src/mesa/main/mipmap.h
> index d11c7fada37..1f108f7e5d8 100644
> --- a/src/mesa/main/mipmap.h
> +++ b/src/mesa/main/mipmap.h
> @@ -28,6 +28,10 @@
>
> #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,
> diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c
> index 16b914a8845..f2aa8005a03 100644
> --- a/src/mesa/state_tracker/st_gen_mipmap.c
> +++ b/src/mesa/state_tracker/st_gen_mipmap.c
> @@ -44,32 +44,6 @@
> #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;
> --
> 2.15.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list