mesa: move _mesa_update_fetch_functions() calls into swrast
authorBrian Paul <brianp@vmware.com>
Sat, 17 Sep 2011 20:50:48 +0000 (14:50 -0600)
committerBrian Paul <brianp@vmware.com>
Sat, 17 Sep 2011 20:57:40 +0000 (14:57 -0600)
Do it during swrast state validation since the FetchTexel() functions
are only called from swrast now and not core Mesa.
Remove assertions in mipmap.c since they're no longer appropriate.

src/mesa/main/mipmap.c
src/mesa/main/teximage.c
src/mesa/main/texparam.c
src/mesa/state_tracker/st_cb_texture.c
src/mesa/swrast/s_context.c

index 869243d..6dfa423 100644 (file)
@@ -1955,8 +1955,6 @@ generate_mipmap_uncompressed(struct gl_context *ctx, GLenum target,
                                  dstDepth, border, srcImage->InternalFormat,
                                  srcImage->TexFormat);
       dstImage->DriverData = NULL;
-      dstImage->FetchTexelc = srcImage->FetchTexelc;
-      dstImage->FetchTexelf = srcImage->FetchTexelf;
 
       /* Alloc new teximage data buffer */
       {
@@ -1970,8 +1968,6 @@ generate_mipmap_uncompressed(struct gl_context *ctx, GLenum target,
       }
 
       ASSERT(dstImage->TexFormat);
-      ASSERT(dstImage->FetchTexelc);
-      ASSERT(dstImage->FetchTexelf);
 
       _mesa_generate_mipmap_level(target, datatype, comps, border,
                                   srcWidth, srcHeight, srcDepth,
index cb4a5b4..e11acc4 100644 (file)
@@ -42,7 +42,6 @@
 #include "mfeatures.h"
 #include "state.h"
 #include "texcompress.h"
-#include "texfetch.h"
 #include "teximage.h"
 #include "texstate.h"
 #include "texpal.h"
@@ -1104,7 +1103,7 @@ _mesa_init_teximage_fields(struct gl_context *ctx, GLenum target,
                            GLint border, GLenum internalFormat,
                            gl_format format)
 {
-   GLint i, dims;
+   GLint i;
 
    ASSERT(img);
    ASSERT(width >= 0);
@@ -1176,10 +1175,6 @@ _mesa_init_teximage_fields(struct gl_context *ctx, GLenum target,
    }
 
    img->TexFormat = format;
-
-   dims = _mesa_get_texture_dimensions(target);
-
-   _mesa_set_fetch_functions(img, dims);
 }
 
 
index 19a01a1..f7f0049 100644 (file)
@@ -432,7 +432,6 @@ set_tex_parameteri(struct gl_context *ctx,
            if (texObj->Sampler.sRGBDecode != decode) {
               flush(ctx);
               texObj->Sampler.sRGBDecode = decode;
-              _mesa_update_fetch_functions(texObj);
            }
            return GL_TRUE;
         }
index eab02fb..2a971c5 100644 (file)
@@ -38,7 +38,6 @@
 #include "main/pbo.h"
 #include "main/pixeltransfer.h"
 #include "main/texcompress.h"
-#include "main/texfetch.h"
 #include "main/texgetimage.h"
 #include "main/teximage.h"
 #include "main/texobj.h"
@@ -552,8 +551,6 @@ st_TexImage(struct gl_context * ctx,
    stImage->base.Face = _mesa_tex_target_to_face(target);
    stImage->base.Level = level;
 
-   _mesa_set_fetch_functions(texImage, dims);
-
    /* Release the reference to a potentially orphaned buffer.   
     * Release any old malloced memory.
     */
@@ -975,8 +972,6 @@ st_get_tex_image(struct gl_context * ctx, GLenum target, GLint level,
 
    dest = (GLubyte *) pixels;
 
-   _mesa_set_fetch_functions(texImage, get_texture_dims(target));
-
    for (i = 0; i < depth; i++) {
       if (compressed_dst) {
         _mesa_get_compressed_teximage(ctx, target, level, dest,
index df21335..963b705 100644 (file)
@@ -31,6 +31,7 @@
 #include "main/colormac.h"
 #include "main/mtypes.h"
 #include "main/teximage.h"
+#include "main/texfetch.h"
 #include "program/prog_parameter.h"
 #include "program/prog_statevars.h"
 #include "swrast.h"
@@ -469,11 +470,14 @@ _swrast_update_texture_samplers(struct gl_context *ctx)
       return; /* pipe hack */
 
    for (u = 0; u < ctx->Const.MaxTextureImageUnits; u++) {
-      const struct gl_texture_object *tObj = ctx->Texture.Unit[u]._Current;
+      struct gl_texture_object *tObj = ctx->Texture.Unit[u]._Current;
       /* Note: If tObj is NULL, the sample function will be a simple
        * function that just returns opaque black (0,0,0,1).
        */
-      swrast->TextureSample[u] = _swrast_choose_texture_sample_func(ctx, tObj);
+      if (tObj) {
+         _mesa_update_fetch_functions(tObj);
+         swrast->TextureSample[u] = _swrast_choose_texture_sample_func(ctx, tObj);
+      }
    }
 }