cell: more multi-texture fixes (mostly working now)
authorBrian <brian.paul@tungstengraphics.com>
Tue, 1 Apr 2008 21:42:42 +0000 (15:42 -0600)
committerBrian <brian.paul@tungstengraphics.com>
Tue, 1 Apr 2008 21:42:42 +0000 (15:42 -0600)
src/gallium/drivers/cell/spu/spu_main.c
src/gallium/drivers/cell/spu/spu_main.h
src/gallium/drivers/cell/spu/spu_texture.c
src/gallium/drivers/cell/spu/spu_tri.c

index 5b5a570a3cd98fcac4764d3d0459adc16ca6c15e..1ab1c40379a744d957687ba3997e53ce8608eacc 100644 (file)
@@ -319,10 +319,10 @@ cmd_state_sampler(const struct cell_command_sampler *sampler)
              spu.init.id, sampler->unit);
 
    spu.sampler[sampler->unit] = sampler->state;
-   if (spu.sampler[0].min_img_filter == PIPE_TEX_FILTER_LINEAR)
-      spu.sample_texture = sample_texture_bilinear;
+   if (spu.sampler[sampler->unit].min_img_filter == PIPE_TEX_FILTER_LINEAR)
+      spu.sample_texture[sampler->unit] = sample_texture_bilinear;
    else
-      spu.sample_texture = sample_texture_nearest;
+      spu.sample_texture[sampler->unit] = sample_texture_nearest;
 }
 
 
index 26e050cfc3eefff9f04c66aa560ef10d1728c06f..e9e39cbeab38b5fc101c1354af1c09c02aa500db 100644 (file)
@@ -85,6 +85,8 @@ typedef struct spu_blend_results (*logicop_func)(
     qword frag_mask);
 
 
+typedef vector float (*sample_texture_func)(uint unit, vector float texcoord);
+
 struct spu_framebuffer {
    void *color_start;              /**< addr of color surface in main memory */
    void *depth_start;              /**< addr of depth surface in main memory */
@@ -152,7 +154,7 @@ struct spu_global
    /** for converting RGBA to PIPE_FORMAT_x colors */
    vector unsigned char color_shuffle;
 
-   vector float (*sample_texture)(uint unit, vector float texcoord);
+   sample_texture_func sample_texture[CELL_MAX_SAMPLERS];
 
 } ALIGN16_ATTRIB;
 
index ba0d57b959590098270cf3115e3364a23bfa8815..ceab2469803bfb45384022f3fc93df141bd3ad30 100644 (file)
@@ -68,9 +68,8 @@ get_texel(uint unit, vec_uint4 coordinate)
 
 
 static void
-get_four_texels(vec_uint4 x, vec_uint4 y, vec_uint4 *texels)
+get_four_texels(uint unit, vec_uint4 x, vec_uint4 y, vec_uint4 *texels)
 {
-   const uint unit = 0;
    const unsigned texture_ea = (uintptr_t) spu.texture[unit].start;
    vec_uint4 tile_x = spu_rlmask(x, -5);
    vec_uint4 tile_y = spu_rlmask(y, -5);
@@ -136,7 +135,7 @@ sample_texture_bilinear(uint unit, vector float texcoord)
    x = spu_and(x, spu.texture[unit].tex_size_x_mask);
    y = spu_and(y, spu.texture[unit].tex_size_y_mask);
 
-   get_four_texels(x, y, texels);
+   get_four_texels(unit, x, y, texels);
 
    vector float texel00 = spu_unpack_A8R8G8B8(spu_extract(texels[0], 0));
    vector float texel01 = spu_unpack_A8R8G8B8(spu_extract(texels[1], 0));
index 51abcb1757748ef7ff879bca7c9a65836061bd8a..ab4ff8160a98e8f18df4a76ef3ce99b65fc09a30 100644 (file)
@@ -316,13 +316,13 @@ emit_quad( int x, int y, mask_t mask )
          eval_coeff(2, (float) x, (float) y, texcoords);
 
          if (spu_extract(mask, 0))
-            colors[0] = spu.sample_texture(unit, texcoords[0]);
+            colors[0] = spu.sample_texture[unit](unit, texcoords[0]);
          if (spu_extract(mask, 1))
-            colors[1] = spu.sample_texture(unit, texcoords[1]);
+            colors[1] = spu.sample_texture[unit](unit, texcoords[1]);
          if (spu_extract(mask, 2))
-            colors[2] = spu.sample_texture(unit, texcoords[2]);
+            colors[2] = spu.sample_texture[unit](unit, texcoords[2]);
          if (spu_extract(mask, 3))
-            colors[3] = spu.sample_texture(unit, texcoords[3]);
+            colors[3] = spu.sample_texture[unit](unit, texcoords[3]);
 
 
          if (spu.texture[1].start) {
@@ -330,16 +330,16 @@ emit_quad( int x, int y, mask_t mask )
             const uint unit = 1;
             vector float colors1[4];
 
-            eval_coeff(3, (float) x, (float) y, texcoords);
+            eval_coeff(2, (float) x, (float) y, texcoords);
 
             if (spu_extract(mask, 0))
-               colors1[0] = spu.sample_texture(unit, texcoords[0]);
+               colors1[0] = spu.sample_texture[unit](unit, texcoords[0]);
             if (spu_extract(mask, 1))
-               colors1[1] = spu.sample_texture(unit, texcoords[1]);
+               colors1[1] = spu.sample_texture[unit](unit, texcoords[1]);
             if (spu_extract(mask, 2))
-               colors1[2] = spu.sample_texture(unit, texcoords[2]);
+               colors1[2] = spu.sample_texture[unit](unit, texcoords[2]);
             if (spu_extract(mask, 3))
-               colors1[3] = spu.sample_texture(unit, texcoords[3]);
+               colors1[3] = spu.sample_texture[unit](unit, texcoords[3]);
 
             /* hack: modulate first texture by second */
             colors[0] = spu_mul(colors[0], colors1[0]);