Split texfilter enums to match common hardware usage.
authorKeith Whitwell <keith@tungstengraphics.com>
Thu, 9 Aug 2007 18:09:19 +0000 (19:09 +0100)
committerKeith Whitwell <keith@tungstengraphics.com>
Thu, 9 Aug 2007 18:09:44 +0000 (19:09 +0100)
src/mesa/pipe/p_defines.h
src/mesa/pipe/p_state.h
src/mesa/pipe/softpipe/sp_tex_sample.c
src/mesa/state_tracker/st_atom_sampler.c

index 9eb4c3743488471d09e84fe96e9746ef445b18f4..efbb3239a2ecff1d3a4f444283a31331ca057846 100644 (file)
 #define PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE     6
 #define PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER   7
 
-#define PIPE_TEX_FILTER_NEAREST                0
-#define PIPE_TEX_FILTER_LINEAR                 1
-#define PIPE_TEX_FILTER_NEAREST_MIPMAP_NEAREST 2
-#define PIPE_TEX_FILTER_NEAREST_MIPMAP_LINEAR  3
-#define PIPE_TEX_FILTER_LINEAR_MIPMAP_NEAREST  4
-#define PIPE_TEX_FILTER_LINEAR_MIPMAP_LINEAR   5
+/* Between mipmaps, ie mipfilter
+ */
+#define PIPE_TEX_MIPFILTER_NEAREST  0
+#define PIPE_TEX_MIPFILTER_LINEAR   1
+#define PIPE_TEX_MIPFILTER_NONE     2
+
+/* Within a mipmap, ie min/mag filter 
+ */
+#define PIPE_TEX_FILTER_NEAREST      0
+#define PIPE_TEX_FILTER_LINEAR       1
+//#define PIPE_TEX_FILTER_ANISO        2
+
 
 #define PIPE_TEX_COMPARE_NONE          0
 #define PIPE_TEX_COMPARE_R_TO_TEXTURE  1
index ee29e38a48c5c3525fb28bccc148b865f6c4e378..64a475ba00d5e9a8fae752908f17142e0728f729 100644 (file)
@@ -213,8 +213,9 @@ struct pipe_sampler_state
    GLuint wrap_s:3;        /**< PIPE_TEX_WRAP_x */
    GLuint wrap_t:3;        /**< PIPE_TEX_WRAP_x */
    GLuint wrap_r:3;        /**< PIPE_TEX_WRAP_x */
-   GLuint min_filter:3;    /**< PIPE_TEX_FILTER_x */
-   GLuint mag_filter:1;    /**< PIPE_TEX_FILTER_LINEAR or _NEAREST */
+   GLuint min_img_filter:2;    /**< PIPE_TEX_FILTER_x */
+   GLuint min_mip_filter:2;    /**< PIPE_TEX_MIPFILTER_x */
+   GLuint mag_img_filter:2;    /**< PIPE_TEX_FILTER_x */
    GLuint compare:1;       /**< shadow/depth compare enabled? */
    GLenum compare_mode:1;  /**< PIPE_TEX_COMPARE_x */
    GLenum compare_func:3;  /**< PIPE_FUNC_x */
index dcc9485cf60c00b67b8bac5b3a8931870467a291..40350eec750671240315bbce4dbc5b74f414cb85 100644 (file)
@@ -417,7 +417,7 @@ sp_get_sample_1d(struct tgsi_sampler *sampler,
    struct pipe_surface *ps
       = pipe->get_tex_surface(pipe, sampler->texture, 0, 0, 0);
 
-   switch (sampler->state->min_filter) {
+   switch (sampler->state->min_img_filter) {
    case PIPE_TEX_FILTER_NEAREST:
       {
          GLint x;
@@ -450,9 +450,7 @@ sp_get_sample_1d(struct tgsi_sampler *sampler,
 static GLuint
 choose_mipmap_level(struct tgsi_sampler *sampler, GLfloat lambda)
 {
-   if (sampler->state->min_filter == sampler->state->mag_filter) {
-      assert(sampler->state->min_filter == PIPE_TEX_FILTER_LINEAR ||
-            sampler->state->min_filter == PIPE_TEX_FILTER_NEAREST);
+   if (sampler->state->min_mip_filter == PIPE_TEX_MIPFILTER_NONE) {
       return 0;
    }
    else {
@@ -485,15 +483,14 @@ sp_get_sample_2d(struct tgsi_sampler *sampler,
    GLint level0;
 
    if (lambda < 0.0)
-      filter = sampler->state->mag_filter;
+      filter = sampler->state->mag_img_filter;
    else
-      filter = sampler->state->min_filter;
+      filter = sampler->state->min_img_filter;
 
    level0 = choose_mipmap_level(sampler, lambda);
 
    switch (filter) {
    case PIPE_TEX_FILTER_NEAREST:
-   case PIPE_TEX_FILTER_NEAREST_MIPMAP_NEAREST:
       {
          GLint x = nearest_texcoord(sampler->state->wrap_s, strq[0],
                                     sampler->texture->level[level0].width);
index 066ce7860f3f19eed6ee0f64ca366f6033705905..7d568baf9e69bb21e2a1a48ca1d513db9037b57a 100644 (file)
@@ -69,28 +69,50 @@ gl_wrap_to_sp(GLenum wrap)
 
 
 static GLuint
-gl_filter_to_sp(GLenum filter)
+gl_filter_to_mip_filter(GLenum filter)
 {
    switch (filter) {
    case GL_NEAREST:
-      return PIPE_TEX_FILTER_NEAREST;
    case GL_LINEAR:
-      return PIPE_TEX_FILTER_LINEAR;
+      return PIPE_TEX_MIPFILTER_NONE;
+
    case GL_NEAREST_MIPMAP_NEAREST:
-      return PIPE_TEX_FILTER_NEAREST_MIPMAP_NEAREST;
+   case GL_LINEAR_MIPMAP_NEAREST:
+      return PIPE_TEX_MIPFILTER_NEAREST;
+
    case GL_NEAREST_MIPMAP_LINEAR:
-      return PIPE_TEX_FILTER_NEAREST_MIPMAP_LINEAR;
+   case GL_LINEAR_MIPMAP_LINEAR:
+      return PIPE_TEX_MIPFILTER_LINEAR;
+
+   default:
+      assert(0);
+      return PIPE_TEX_MIPFILTER_NONE;
+   }
+}
+
+
+static GLuint
+gl_filter_to_img_filter(GLenum filter)
+{
+   switch (filter) {
+   case GL_NEAREST:
+   case GL_NEAREST_MIPMAP_NEAREST:
+   case GL_NEAREST_MIPMAP_LINEAR:
+      return PIPE_TEX_FILTER_NEAREST;
+
+   case GL_LINEAR:
    case GL_LINEAR_MIPMAP_NEAREST:
-      return PIPE_TEX_FILTER_LINEAR_MIPMAP_NEAREST;
    case GL_LINEAR_MIPMAP_LINEAR:
-      return PIPE_TEX_FILTER_LINEAR_MIPMAP_LINEAR;
+      return PIPE_TEX_FILTER_LINEAR;
+
    default:
-      abort();
-      return 0;
+      assert(0);
+      return PIPE_TEX_FILTER_NEAREST;
    }
 }
 
 
+
 static void 
 update_samplers(struct st_context *st)
 {
@@ -108,12 +130,14 @@ update_samplers(struct st_context *st)
          sampler.wrap_t = gl_wrap_to_sp(texobj->WrapT);
          sampler.wrap_r = gl_wrap_to_sp(texobj->WrapR);
 
-         sampler.min_filter = gl_filter_to_sp(texobj->MinFilter);
-         sampler.mag_filter = gl_filter_to_sp(texobj->MagFilter);
+         sampler.min_img_filter = gl_filter_to_img_filter(texobj->MinFilter);
+         sampler.min_mip_filter = gl_filter_to_mip_filter(texobj->MinFilter);
+         sampler.mag_img_filter = gl_filter_to_img_filter(texobj->MagFilter);
 
          sampler.lod_bias = st->ctx->Texture.Unit[u].LodBias;
          sampler.min_lod = texobj->MinLod;
          sampler.max_lod = texobj->MaxLod;
+        sampler.max_anisotropy = texobj->MaxAnisotropy;
 
          /* XXX more sampler state here */
       }