gallium: remove PIPE_TEX_FILTER_ANISO
authorLuca Barbieri <luca@luca-barbieri.com>
Wed, 6 Jan 2010 10:35:47 +0000 (10:35 +0000)
committerKeith Whitwell <keithw@vmware.com>
Wed, 6 Jan 2010 10:35:47 +0000 (10:35 +0000)
This patch removes PIPE_TEX_FILTER_ANISO.

Anisotropic filtering is enabled if and only if max_anisotropy > 1.0.
Values between 0.0 and 1.0, inclusive, of max_anisotropy are to be
considered equivalent, and meaning to turn off anisotropic filtering.

This approach has the small drawback of eliminating the possibility of
enabling anisotropic filter on either minification or magnification
separately, which Radeon hardware seems to support, is currently
support by Gallium but not exposed to OpenGL.  If this is actually
useful it could be handled by splitting max_anisotropy in two values
and adding an appropriate OpenGL extension.

NOTE: some fiddling & reformatting by keithw to get this patch to
apply.  Hopefully nothing broken in the process.

13 files changed:
src/gallium/auxiliary/util/u_debug_dump.c
src/gallium/drivers/cell/spu/spu_command.c
src/gallium/drivers/i915/i915_state.c
src/gallium/drivers/i965/brw_pipe_sampler.c
src/gallium/drivers/llvmpipe/lp_bld_sample_soa.c
src/gallium/drivers/llvmpipe/lp_tex_sample_c.c
src/gallium/drivers/nv50/nv50_state.c
src/gallium/drivers/r300/r300_state.c
src/gallium/drivers/r300/r300_state_inlines.h
src/gallium/drivers/svga/svga_pipe_sampler.c
src/gallium/include/pipe/p_defines.h
src/gallium/state_trackers/vega/image.c
src/mesa/state_tracker/st_atom_sampler.c

index 09866880aead1c0276b20831d41a5e3168e089e0..61624d05c0ac359c57228480706c60013318ea65 100644 (file)
@@ -255,15 +255,13 @@ DEFINE_DEBUG_DUMP_CONTINUOUS(tex_mipfilter)
 static const char *
 debug_dump_tex_filter_names[] = {
    "PIPE_TEX_FILTER_NEAREST",
-   "PIPE_TEX_FILTER_LINEAR",
-   "PIPE_TEX_FILTER_ANISO"
+   "PIPE_TEX_FILTER_LINEAR"
 };
 
 static const char *
 debug_dump_tex_filter_short_names[] = {
    "nearest",
-   "linear",
-   "aniso"
+   "linear"
 };
 
 DEFINE_DEBUG_DUMP_CONTINUOUS(tex_filter)
index 5c0179d95462015ce358303016003bdfb0f84ac3..12b855a3db2dd21a0f41059eab543976b3658df8 100644 (file)
@@ -405,8 +405,6 @@ cmd_state_sampler(const struct cell_command_sampler *sampler)
    case PIPE_TEX_FILTER_LINEAR:
       spu.min_sample_texture_2d[unit] = sample_texture_2d_bilinear;
       break;
-   case PIPE_TEX_FILTER_ANISO:
-      /* fall-through, for now */
    case PIPE_TEX_FILTER_NEAREST:
       spu.min_sample_texture_2d[unit] = sample_texture_2d_nearest;
       break;
@@ -418,8 +416,6 @@ cmd_state_sampler(const struct cell_command_sampler *sampler)
    case PIPE_TEX_FILTER_LINEAR:
       spu.mag_sample_texture_2d[unit] = sample_texture_2d_bilinear;
       break;
-   case PIPE_TEX_FILTER_ANISO:
-      /* fall-through, for now */
    case PIPE_TEX_FILTER_NEAREST:
       spu.mag_sample_texture_2d[unit] = sample_texture_2d_nearest;
       break;
index 1528afc85996c0de454d065f22213250e062ad98..5f5b6f8e1855684bf278fdf50fe01991e0df0516 100644 (file)
@@ -74,8 +74,6 @@ static unsigned translate_img_filter( unsigned filter )
       return FILTER_NEAREST;
    case PIPE_TEX_FILTER_LINEAR:
       return FILTER_LINEAR;
-   case PIPE_TEX_FILTER_ANISO:
-      return FILTER_ANISOTROPIC;
    default:
       assert(0);
       return FILTER_NEAREST;
@@ -221,6 +219,9 @@ i915_create_sampler_state(struct pipe_context *pipe,
    minFilt = translate_img_filter( sampler->min_img_filter );
    magFilt = translate_img_filter( sampler->mag_img_filter );
    
+   if (sampler->max_anisotropy > 1.0)
+      minFilt = magFilt = FILTER_ANISOTROPIC;
+
    if (sampler->max_anisotropy > 2.0) {
       cso->state[0] |= SS2_MAX_ANISO_4;
    }
index 5ddc63f57ec612c4f763181ce811e700b0248b32..81712798a5dddb7e93164f56dc6d1868f11169f1 100644 (file)
@@ -48,8 +48,6 @@ static GLuint translate_img_filter( unsigned filter )
       return BRW_MAPFILTER_NEAREST;
    case PIPE_TEX_FILTER_LINEAR:
       return BRW_MAPFILTER_LINEAR;
-   case PIPE_TEX_FILTER_ANISO:
-      return BRW_MAPFILTER_ANISOTROPIC;
    default:
       assert(0);
       return BRW_MAPFILTER_NEAREST;
index 47b68b71e25ff5a6aae4255df93dd153ab2d0cf6..c46fef501098da61f2206b1a987fbfc317364263 100644 (file)
@@ -577,7 +577,6 @@ lp_build_sample_soa(LLVMBuilderRef builder,
       lp_build_sample_2d_nearest_soa(&bld, s, t, width, height, stride, data_ptr, texel);
       break;
    case PIPE_TEX_FILTER_LINEAR:
-   case PIPE_TEX_FILTER_ANISO:
       if(lp_format_is_rgba8(bld.format_desc))
          lp_build_sample_2d_linear_aos(&bld, s, t, width, height, stride, data_ptr, texel);
       else
index 68520fa4f096b65ae08bb1bbc2c3e322437dca6f..eaff6d5cdf755ed6f91c9dee5fb9a8ed16954bae 100644 (file)
@@ -1131,7 +1131,6 @@ lp_get_samples_2d_common(struct tgsi_sampler *tgsi_sampler,
       }
       break;
    case PIPE_TEX_FILTER_LINEAR:
-   case PIPE_TEX_FILTER_ANISO:
       {
          int x0[4], y0[4], x1[4], y1[4];
          float xw[4], yw[4]; /* weights */
@@ -1283,7 +1282,6 @@ lp_get_samples_3d(struct tgsi_sampler *tgsi_sampler,
       }
       break;
    case PIPE_TEX_FILTER_LINEAR:
-   case PIPE_TEX_FILTER_ANISO:
       {
          int x0[4], x1[4], y0[4], y1[4], z0[4], z1[4];
          float xw[4], yw[4], zw[4]; /* interpolation weights */
@@ -1414,7 +1412,6 @@ lp_get_samples_rect(struct tgsi_sampler *tgsi_sampler,
       }
       break;
    case PIPE_TEX_FILTER_LINEAR:
-   case PIPE_TEX_FILTER_ANISO:
       {
          int x0[4], y0[4], x1[4], y1[4];
          float xw[4], yw[4]; /* weights */
index fd0a33d7f7e5f60b54fa7d80ce7ad43cdc2abc98..1f67df814b1742a4d9e8ad748a209ff9269870f7 100644 (file)
@@ -146,7 +146,6 @@ nv50_sampler_state_create(struct pipe_context *pipe,
                  (wrap_mode(cso->wrap_r) << 6));
 
        switch (cso->mag_img_filter) {
-       case PIPE_TEX_FILTER_ANISO:
        case PIPE_TEX_FILTER_LINEAR:
                tsc[1] |= NV50TSC_1_1_MAGF_LINEAR;
                break;
@@ -157,7 +156,6 @@ nv50_sampler_state_create(struct pipe_context *pipe,
        }
 
        switch (cso->min_img_filter) {
-       case PIPE_TEX_FILTER_ANISO:
        case PIPE_TEX_FILTER_LINEAR:
                tsc[1] |= NV50TSC_1_1_MINF_LINEAR;
                break;
index 49072462ec3ff0e27ddd2d7a3fd80a9099ecdd4f..534c1b5935fd2e1a0ff2783bba049f81718bd68c 100644 (file)
@@ -556,7 +556,8 @@ static void*
 
     sampler->filter0 |= r300_translate_tex_filters(state->min_img_filter,
                                                    state->mag_img_filter,
-                                                   state->min_mip_filter);
+                                                   state->min_mip_filter,
+                                                   state->max_anisotropy > 1.0);
 
     /* Unfortunately, r300-r500 don't support floating-point mipmap lods. */
     /* We must pass these to the emit function to clamp them properly. */
index dbe42edd91068917c5797fa8c3ca3934114ab601..02adee27015974d9ef881721fd51807ac9200dc5 100644 (file)
@@ -260,35 +260,33 @@ static INLINE uint32_t r300_translate_wrap(int wrap)
 static INLINE uint32_t r300_translate_tex_filters(int min, int mag, int mip)
 {
     uint32_t retval = 0;
-    switch (min) {
+    if (is_anisotropic)
+        retval |= R300_TX_MIN_FILTER_ANISO | R300_TX_MAG_FILTER_ANISO;
+    else {
+        switch (min) {
         case PIPE_TEX_FILTER_NEAREST:
             retval |= R300_TX_MIN_FILTER_NEAREST;
             break;
         case PIPE_TEX_FILTER_LINEAR:
             retval |= R300_TX_MIN_FILTER_LINEAR;
             break;
-        case PIPE_TEX_FILTER_ANISO:
-            retval |= R300_TX_MIN_FILTER_ANISO;
-            break;
         default:
             debug_printf("r300: Unknown texture filter %d\n", min);
             assert(0);
             break;
-    }
-    switch (mag) {
+        }
+        switch (mag) {
         case PIPE_TEX_FILTER_NEAREST:
             retval |= R300_TX_MAG_FILTER_NEAREST;
             break;
         case PIPE_TEX_FILTER_LINEAR:
             retval |= R300_TX_MAG_FILTER_LINEAR;
             break;
-        case PIPE_TEX_FILTER_ANISO:
-            retval |= R300_TX_MAG_FILTER_ANISO;
-            break;
         default:
             debug_printf("r300: Unknown texture filter %d\n", mag);
             assert(0);
             break;
+        }
     }
     switch (mip) {
         case PIPE_TEX_MIPFILTER_NONE:
index 78053e755e288d644cbcb1674b66ef055a2acffa..460a101f8c0f5c8c2cb3d0a3abae99f898857fe5 100644 (file)
@@ -76,7 +76,6 @@ static INLINE unsigned translate_img_filter( unsigned filter )
    switch (filter) {
    case PIPE_TEX_FILTER_NEAREST: return SVGA3D_TEX_FILTER_NEAREST;
    case PIPE_TEX_FILTER_LINEAR:  return SVGA3D_TEX_FILTER_LINEAR;
-   case PIPE_TEX_FILTER_ANISO:   return SVGA3D_TEX_FILTER_ANISOTROPIC;
    default:
       assert(0);
       return SVGA3D_TEX_FILTER_NEAREST;
@@ -107,6 +106,8 @@ svga_create_sampler_state(struct pipe_context *pipe,
    cso->magfilter = translate_img_filter( sampler->mag_img_filter );
    cso->minfilter = translate_img_filter( sampler->min_img_filter );
    cso->aniso_level = MAX2( (unsigned) sampler->max_anisotropy, 1 );
+   if(cso->aniso_level != 1)
+      cso->magfilter = cso->minfilter = SVGA3D_TEX_FILTER_ANISOTROPIC;
    cso->lod_bias = sampler->lod_bias;
    cso->addressu = translate_wrap_mode(sampler->wrap_s);
    cso->addressv = translate_wrap_mode(sampler->wrap_t);
index c3b1e634ffc8121cbcb02650e5a41fb96142cbdd..35f3830ebcf076ba9d7305b6ba62b64bf89466ae 100644 (file)
@@ -171,8 +171,6 @@ enum pipe_texture_target {
  */
 #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 278ba6d46eb2cdff8a531936e68594ba05c865f5..1112ad9839d5811304d9b4c4ad777e51e451f47f 100644 (file)
@@ -644,7 +644,7 @@ VGint image_sampler_filter(struct vg_context *ctx)
        return PIPE_TEX_FILTER_NEAREST;
        break;
     case VG_IMAGE_QUALITY_BETTER:
-       /*return PIPE_TEX_FILTER_ANISO;*/
+       /* possibly use anisotropic filtering */
        return PIPE_TEX_FILTER_LINEAR;
        break;
     default:
index e1d6fa9ecad60cdb1a415da7232ce3031d963dfe..7b84a86ba485d35762b8888cec48c776760c7b8b 100644 (file)
@@ -213,10 +213,6 @@ update_samplers(struct st_context *st)
                             sampler->border_color);
 
         sampler->max_anisotropy = texobj->MaxAnisotropy;
-         if (sampler->max_anisotropy > 1.0) {
-            sampler->min_img_filter = PIPE_TEX_FILTER_ANISO;
-            sampler->mag_img_filter = PIPE_TEX_FILTER_ANISO;
-         }
 
          /* only care about ARB_shadow, not SGI shadow */
          if (texobj->CompareMode == GL_COMPARE_R_TO_TEXTURE) {