replace _mesa_logbase2 with util_logbase2
[mesa.git] / src / mesa / state_tracker / st_gen_mipmap.c
index b71a8ee57bb48eb8f0aa8d16dac1a9ba337bb16c..1983bbc76c225ebbf5295391763c68f96aa42ab0 100644 (file)
 
 
 #include "main/errors.h"
-#include "main/imports.h"
+#include "util/imports.h"
 #include "main/mipmap.h"
 #include "main/teximage.h"
 
 #include "pipe/p_context.h"
 #include "pipe/p_defines.h"
 #include "util/u_inlines.h"
-#include "util/u_format.h"
+#include "util/format/u_format.h"
 #include "util/u_gen_mipmap.h"
 
 #include "st_debug.h"
@@ -56,13 +56,16 @@ st_generate_mipmap(struct gl_context *ctx, GLenum target,
    struct st_context *st = st_context(ctx);
    struct st_texture_object *stObj = st_texture_object(texObj);
    struct pipe_resource *pt = st_get_texobj_resource(texObj);
-   const uint baseLevel = texObj->BaseLevel;
+   uint baseLevel = texObj->BaseLevel;
    enum pipe_format format;
    uint lastLevel, first_layer, last_layer;
 
    if (!pt)
       return;
 
+   if (texObj->Immutable)
+      baseLevel += texObj->MinLevel;
+
    /* not sure if this ultimately actually should work,
       but we're not supporting multisampled textures yet. */
    assert(pt->nr_samples < 2);
@@ -70,6 +73,9 @@ st_generate_mipmap(struct gl_context *ctx, GLenum target,
    /* find expected last mipmap level to generate*/
    lastLevel = _mesa_compute_num_levels(ctx, texObj, target) - 1;
 
+   if (texObj->Immutable)
+      lastLevel += texObj->MinLevel;
+
    if (lastLevel == 0)
       return;