Cell: choose bilinear vs. nearest filtering according to sampler state
authorBrian <brian.paul@tungstengraphics.com>
Mon, 4 Feb 2008 20:23:07 +0000 (13:23 -0700)
committerBen Skeggs <skeggsb@gmail.com>
Fri, 15 Feb 2008 02:50:29 +0000 (13:50 +1100)
src/mesa/pipe/cell/spu/spu_main.c
src/mesa/pipe/cell/spu/spu_main.h
src/mesa/pipe/cell/spu/spu_texture.c
src/mesa/pipe/cell/spu/spu_texture.h
src/mesa/pipe/cell/spu/spu_tri.c

index 412661061abd6efbef064a926ffb7a7cbc4b44d5..48e016fc8b4184a8e653a6cbd32622646232b6a1 100644 (file)
@@ -252,6 +252,10 @@ cmd_state_sampler(const struct pipe_sampler_state *state)
              spu.init.id);
 
    memcpy(&spu.sampler[0], state, sizeof(*state));
+   if (spu.sampler[0].min_img_filter == PIPE_TEX_FILTER_LINEAR)
+      spu.sample_texture = sample_texture_bilinear;
+   else
+      spu.sample_texture = sample_texture_nearest;
 }
 
 
index 02b62ee5cd513969ba97573d2de5577ba17ac6e7..fb98b0d88978c1a51e8c6d6d7fc2dd7e4e79baed 100644 (file)
@@ -114,6 +114,8 @@ struct spu_global
    vector float tex_size;
    vector unsigned int tex_size_mask; /**< == int(size - 1) */
 
+   uint (*sample_texture)(vector float texcoord);
+
 } ALIGN16_ATTRIB;
 
 
index 6e243f7fa3a59eb354748e24d4d0ef671ec65212..ecacf2ec8876e55188401a2d1ca9f8cc044929d1 100644 (file)
@@ -131,7 +131,7 @@ get_tex_tile(vector unsigned int ij)
  * XXX this is extremely primitive for now.
  */
 uint
-sample_texture(vector float texcoord)
+sample_texture_nearest(vector float texcoord)
 {
    vector float tc = spu_mul(texcoord, spu.tex_size);
    vector unsigned int itc = spu_convtu(tc, 0);  /* convert to int */
index 25cbe9b3c64b9c17c8597c62e2b97f2d8911deef..0e000bfebfd05cb48d5156314db93f966e3de2a8 100644 (file)
@@ -37,7 +37,7 @@ invalidate_tex_cache(void);
 
 
 extern uint
-sample_texture(vector float texcoord);
+sample_texture_nearest(vector float texcoord);
 
 
 extern uint
index c148c75dd61d4ebcac592b6f0e01c3bad7bd36b4..7b422f71a8d26d043f92e5104e50dd17428f0ca2 100644 (file)
@@ -309,13 +309,13 @@ emit_quad( int x, int y, mask_t mask )
          eval_coeff(2, (float) x, (float) y, texcoords);
 
          if (spu_extract(mask, 0))
-            spu.ctile.ui[iy][ix] = sample_texture(texcoords[0].v);
+            spu.ctile.ui[iy][ix] = spu.sample_texture(texcoords[0].v);
          if (spu_extract(mask, 1))
-            spu.ctile.ui[iy][ix+1] = sample_texture(texcoords[1].v);
+            spu.ctile.ui[iy][ix+1] = spu.sample_texture(texcoords[1].v);
          if (spu_extract(mask, 2))
-            spu.ctile.ui[iy+1][ix] = sample_texture(texcoords[2].v);
+            spu.ctile.ui[iy+1][ix] = spu.sample_texture(texcoords[2].v);
          if (spu_extract(mask, 3))
-            spu.ctile.ui[iy+1][ix+1] = sample_texture(texcoords[3].v);
+            spu.ctile.ui[iy+1][ix+1] = spu.sample_texture(texcoords[3].v);
       }
       else {
          /* simple shading */