gallium: Set sampler->min_lod instead of always reallocating pipe_textures.
authorMichel Dänzer <michel@tungstengraphics.com>
Thu, 1 May 2008 16:31:39 +0000 (17:31 +0100)
committerMichel Dänzer <michel@tungstengraphics.com>
Thu, 1 May 2008 16:39:33 +0000 (17:39 +0100)
src/mesa/state_tracker/st_atom_sampler.c
src/mesa/state_tracker/st_cb_texture.c

index e1ddb53b80fc2a020a4ebfd4a8cbdd253b21b36d..0237da3693a055084a5003f8552aa5668a4b951a 100644 (file)
@@ -37,6 +37,7 @@
 #include "st_program.h"
 #include "pipe/p_context.h"
 #include "pipe/p_defines.h"
+#include "pipe/p_util.h"
 #include "cso_cache/cso_context.h"
 
 
@@ -147,17 +148,8 @@ update_samplers(struct st_context *st)
             sampler->normalized_coords = 1;
 
          sampler->lod_bias = st->ctx->Texture.Unit[su].LodBias;
-#if 1
-         sampler->min_lod = (texobj->MinLod) < 0.0 ? 0.0 : texobj->MinLod;
-         sampler->max_lod = texobj->MaxLod;
-#else
-         /* min/max lod should really be as follows (untested).
-          * Also, calculate_first_last_level() needs to be overhauled
-          * since today's hardware had real support for LOD clamping.
-          */
          sampler->min_lod = MAX2(texobj->BaseLevel, texobj->MinLod);
          sampler->max_lod = MIN2(texobj->MaxLevel, texobj->MaxLod);
-#endif
 
          sampler->border_color[0] = texobj->BorderColor[RCOMP];
          sampler->border_color[1] = texobj->BorderColor[GCOMP];
index 981246221b12237642798838051bb653e6d04fe8..5fd192a8b801411c9df815f09533dae0164e57c8 100644 (file)
@@ -1342,8 +1342,6 @@ static void
 calculate_first_last_level(struct st_texture_object *stObj)
 {
    struct gl_texture_object *tObj = &stObj->base;
-   const struct gl_texture_image *const baseImage =
-      tObj->Image[0][tObj->BaseLevel];
 
    /* These must be signed values.  MinLod and MaxLod can be negative numbers,
     * and having firstLevel and lastLevel as signed prevents the need for
@@ -1366,7 +1364,7 @@ calculate_first_last_level(struct st_texture_object *stObj)
       }
       else {
          firstLevel = 0;
-         lastLevel = MIN2(tObj->MaxLevel - tObj->BaseLevel, baseImage->MaxLog2);
+         lastLevel = MIN2(tObj->MaxLevel, tObj->Image[0][0]->WidthLog2);
       }
       break;
    case GL_TEXTURE_RECTANGLE_NV:
@@ -1489,10 +1487,7 @@ st_finalize_texture(GLcontext *ctx,
        (stObj->pt->target != gl_target_to_pipe(stObj->base.Target) ||
        stObj->pt->format !=
        st_mesa_format_to_pipe_format(firstImage->base.TexFormat->MesaFormat) ||
-       stObj->pt->last_level != stObj->lastLevel ||
-       stObj->pt->width[0] != firstImage->base.Width2 ||
-       stObj->pt->height[0] != firstImage->base.Height2 ||
-       stObj->pt->depth[0] != firstImage->base.Depth2 ||
+       stObj->pt->last_level < stObj->lastLevel ||
        stObj->pt->cpp != cpp ||
        stObj->pt->compressed != firstImage->base.IsCompressed)) {
       pipe_texture_release(&stObj->pt);