aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/pipe
diff options
context:
space:
mode:
authorBrian <[email protected]>2008-02-04 09:54:21 -0700
committerBrian <[email protected]>2008-02-04 09:54:21 -0700
commit18105195a86b8294b578462febf47692832e8705 (patch)
treee77fe0348d57100b01547a46cf0c3f79a777bd12 /src/mesa/pipe
parente967a5c746f340a76b27181b4ead1035101cece3 (diff)
Cell: checkpoint: start to SIMD-ize texture sampling
Diffstat (limited to 'src/mesa/pipe')
-rw-r--r--src/mesa/pipe/cell/spu/spu_main.c10
-rw-r--r--src/mesa/pipe/cell/spu/spu_main.h4
-rw-r--r--src/mesa/pipe/cell/spu/spu_texture.c17
-rw-r--r--src/mesa/pipe/cell/spu/spu_texture.h2
-rw-r--r--src/mesa/pipe/cell/spu/spu_tri.c8
5 files changed, 33 insertions, 8 deletions
diff --git a/src/mesa/pipe/cell/spu/spu_main.c b/src/mesa/pipe/cell/spu/spu_main.c
index ba4d180cc0c..412661061ab 100644
--- a/src/mesa/pipe/cell/spu/spu_main.c
+++ b/src/mesa/pipe/cell/spu/spu_main.c
@@ -263,6 +263,16 @@ cmd_state_texture(const struct cell_command_texture *texture)
spu.init.id, texture->start, texture->width, texture->height);
memcpy(&spu.texture, texture, sizeof(*texture));
+ spu.tex_size = VEC_LITERAL(vector float,
+ spu.texture.width,
+ spu.texture.height,
+ 0.0,
+ 0.0);
+ spu.tex_size_mask = VEC_LITERAL(vector unsigned int,
+ spu.texture.width - 1,
+ spu.texture.height - 1,
+ 0,
+ 0);
}
diff --git a/src/mesa/pipe/cell/spu/spu_main.h b/src/mesa/pipe/cell/spu/spu_main.h
index 7a12715b0bc..02b62ee5cd5 100644
--- a/src/mesa/pipe/cell/spu/spu_main.h
+++ b/src/mesa/pipe/cell/spu/spu_main.h
@@ -110,6 +110,10 @@ struct spu_global
/** for converting RGBA to PIPE_FORMAT_x colors */
vector unsigned char color_shuffle;
+
+ vector float tex_size;
+ vector unsigned int tex_size_mask; /**< == int(size - 1) */
+
} ALIGN16_ATTRIB;
diff --git a/src/mesa/pipe/cell/spu/spu_texture.c b/src/mesa/pipe/cell/spu/spu_texture.c
index c1dc6bfe902..1cf958806fc 100644
--- a/src/mesa/pipe/cell/spu/spu_texture.c
+++ b/src/mesa/pipe/cell/spu/spu_texture.c
@@ -128,12 +128,23 @@ get_tex_tile(uint i, uint j)
* XXX this is extremely primitive for now.
*/
uint
-sample_texture(float4 texcoord)
+sample_texture(vector float texcoord)
{
+#if 0
/* wrap/repeat */
- uint i = (uint) (texcoord.f[0] * spu.texture.width) % spu.texture.width;
- uint j = (uint) (texcoord.f[1] * spu.texture.height) % spu.texture.height;
+ uint i = (uint) (spu_extract(texcoord, 0) * spu.texture.width) % spu.texture.width;
+ uint j = (uint) (spu_extract(texcoord, 1) * spu.texture.height) % spu.texture.height;
uint pos = get_tex_tile(i, j);
uint texel = tex_tiles[pos].ui[j % TILE_SIZE][i % TILE_SIZE];
return texel;
+#else
+ vector float tc = spu_mul(texcoord, spu.tex_size);
+ vector unsigned int itc = spu_convtu(tc, 0);
+ itc = spu_and(itc, spu.tex_size_mask);
+ uint i = spu_extract(itc, 0);
+ uint j = spu_extract(itc, 1);
+ uint pos = get_tex_tile(i, j);
+ uint texel = tex_tiles[pos].ui[j % TILE_SIZE][i % TILE_SIZE];
+ return texel;
+#endif
}
diff --git a/src/mesa/pipe/cell/spu/spu_texture.h b/src/mesa/pipe/cell/spu/spu_texture.h
index 938a42b5495..5bc8e71879b 100644
--- a/src/mesa/pipe/cell/spu/spu_texture.h
+++ b/src/mesa/pipe/cell/spu/spu_texture.h
@@ -37,7 +37,7 @@ invalidate_tex_cache(void);
extern uint
-sample_texture(float4 texcoord);
+sample_texture(vector float texcoord);
#endif /* SPU_TEXTURE_H */
diff --git a/src/mesa/pipe/cell/spu/spu_tri.c b/src/mesa/pipe/cell/spu/spu_tri.c
index 3f46e75d7ce..c148c75dd61 100644
--- a/src/mesa/pipe/cell/spu/spu_tri.c
+++ b/src/mesa/pipe/cell/spu/spu_tri.c
@@ -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]);
+ spu.ctile.ui[iy][ix] = sample_texture(texcoords[0].v);
if (spu_extract(mask, 1))
- spu.ctile.ui[iy][ix+1] = sample_texture(texcoords[1]);
+ spu.ctile.ui[iy][ix+1] = sample_texture(texcoords[1].v);
if (spu_extract(mask, 2))
- spu.ctile.ui[iy+1][ix] = sample_texture(texcoords[2]);
+ spu.ctile.ui[iy+1][ix] = sample_texture(texcoords[2].v);
if (spu_extract(mask, 3))
- spu.ctile.ui[iy+1][ix+1] = sample_texture(texcoords[3]);
+ spu.ctile.ui[iy+1][ix+1] = sample_texture(texcoords[3].v);
}
else {
/* simple shading */