summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers
diff options
context:
space:
mode:
authorBrian <[email protected]>2008-04-01 11:35:53 -0600
committerBrian <[email protected]>2008-04-01 11:35:53 -0600
commite7b23d36df1ab3ac5b54ef8e4e56c4fd46db8257 (patch)
tree09ad402fb532af6f6af945db3b26294704074459 /src/gallium/drivers
parentc14da8f52407529f20f819e31a01356535de0117 (diff)
cell: checkpoint: more multi-texture work
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/cell/ppu/cell_texture.c8
-rw-r--r--src/gallium/drivers/cell/spu/spu_main.c2
-rw-r--r--src/gallium/drivers/cell/spu/spu_main.h2
-rw-r--r--src/gallium/drivers/cell/spu/spu_texture.c6
-rw-r--r--src/gallium/drivers/cell/spu/spu_texture.h4
-rw-r--r--src/gallium/drivers/cell/spu/spu_tri.c34
6 files changed, 42 insertions, 14 deletions
diff --git a/src/gallium/drivers/cell/ppu/cell_texture.c b/src/gallium/drivers/cell/ppu/cell_texture.c
index 9c694e136d8..c59d1f7f231 100644
--- a/src/gallium/drivers/cell/ppu/cell_texture.c
+++ b/src/gallium/drivers/cell/ppu/cell_texture.c
@@ -245,9 +245,13 @@ void
cell_update_texture_mapping(struct cell_context *cell)
{
uint face = 0, level = 0, zslice = 0;
+ uint i;
+
+ for (i = 0; i < CELL_MAX_SAMPLERS; i++) {
+ if (cell->texture[i])
+ cell_tile_texture(cell, cell->texture[i]);
+ }
- if (cell->texture[0])
- cell_tile_texture(cell, cell->texture[0]);
#if 0
if (cell->tex_surf && cell->tex_map) {
pipe_surface_unmap(cell->tex_surf);
diff --git a/src/gallium/drivers/cell/spu/spu_main.c b/src/gallium/drivers/cell/spu/spu_main.c
index 5b5a570a3cd..a840d01596a 100644
--- a/src/gallium/drivers/cell/spu/spu_main.c
+++ b/src/gallium/drivers/cell/spu/spu_main.c
@@ -333,7 +333,7 @@ cmd_state_texture(const struct cell_command_texture *texture)
const uint width = texture->width;
const uint height = texture->height;
- if (Debug) {
+ if (1||Debug) {
printf("SPU %u: TEXTURE [%u] at %p size %u x %u\n", spu.init.id,
texture->unit, texture->start,
texture->width, texture->height);
diff --git a/src/gallium/drivers/cell/spu/spu_main.h b/src/gallium/drivers/cell/spu/spu_main.h
index 2bfad3535a1..26e050cfc3e 100644
--- a/src/gallium/drivers/cell/spu/spu_main.h
+++ b/src/gallium/drivers/cell/spu/spu_main.h
@@ -152,7 +152,7 @@ struct spu_global
/** for converting RGBA to PIPE_FORMAT_x colors */
vector unsigned char color_shuffle;
- vector float (*sample_texture)(vector float texcoord);
+ vector float (*sample_texture)(uint unit, vector float texcoord);
} ALIGN16_ATTRIB;
diff --git a/src/gallium/drivers/cell/spu/spu_texture.c b/src/gallium/drivers/cell/spu/spu_texture.c
index 4612501eb3b..58a426cc409 100644
--- a/src/gallium/drivers/cell/spu/spu_texture.c
+++ b/src/gallium/drivers/cell/spu/spu_texture.c
@@ -104,9 +104,8 @@ get_four_texels(vec_uint4 x, vec_uint4 y, vec_uint4 *texels)
* XXX this is extremely primitive for now.
*/
vector float
-sample_texture_nearest(vector float texcoord)
+sample_texture_nearest(uint unit, vector float texcoord)
{
- const uint unit = 0;
vector float tc = spu_mul(texcoord, spu.texture[unit].tex_size);
vector unsigned int itc = spu_convtu(tc, 0); /* convert to int */
itc = spu_and(itc, spu.texture[unit].tex_size_mask); /* mask (GL_REPEAT) */
@@ -116,9 +115,8 @@ sample_texture_nearest(vector float texcoord)
vector float
-sample_texture_bilinear(vector float texcoord)
+sample_texture_bilinear(uint unit, vector float texcoord)
{
- const uint unit = 0;
static const vec_uint4 offset_x = {0, 0, 1, 1};
static const vec_uint4 offset_y = {0, 1, 0, 1};
diff --git a/src/gallium/drivers/cell/spu/spu_texture.h b/src/gallium/drivers/cell/spu/spu_texture.h
index 95eb87080f1..f7c9738be88 100644
--- a/src/gallium/drivers/cell/spu/spu_texture.h
+++ b/src/gallium/drivers/cell/spu/spu_texture.h
@@ -37,11 +37,11 @@ invalidate_tex_cache(void);
extern vector float
-sample_texture_nearest(vector float texcoord);
+sample_texture_nearest(uint unit, vector float texcoord);
extern vector float
-sample_texture_bilinear(vector float texcoord);
+sample_texture_bilinear(uint unit, vector float texcoord);
#endif /* SPU_TEXTURE_H */
diff --git a/src/gallium/drivers/cell/spu/spu_tri.c b/src/gallium/drivers/cell/spu/spu_tri.c
index 17e337bbdf6..51abcb17577 100644
--- a/src/gallium/drivers/cell/spu/spu_tri.c
+++ b/src/gallium/drivers/cell/spu/spu_tri.c
@@ -311,17 +311,43 @@ emit_quad( int x, int y, mask_t mask )
if (spu.texture[0].start) {
/* texture mapping */
+ const uint unit = 0;
vector float texcoords[4];
eval_coeff(2, (float) x, (float) y, texcoords);
if (spu_extract(mask, 0))
- colors[0] = spu.sample_texture(texcoords[0]);
+ colors[0] = spu.sample_texture(unit, texcoords[0]);
if (spu_extract(mask, 1))
- colors[1] = spu.sample_texture(texcoords[1]);
+ colors[1] = spu.sample_texture(unit, texcoords[1]);
if (spu_extract(mask, 2))
- colors[2] = spu.sample_texture(texcoords[2]);
+ colors[2] = spu.sample_texture(unit, texcoords[2]);
if (spu_extract(mask, 3))
- colors[3] = spu.sample_texture(texcoords[3]);
+ colors[3] = spu.sample_texture(unit, texcoords[3]);
+
+
+ if (spu.texture[1].start) {
+ /* multi-texture mapping */
+ const uint unit = 1;
+ vector float colors1[4];
+
+ eval_coeff(3, (float) x, (float) y, texcoords);
+
+ if (spu_extract(mask, 0))
+ colors1[0] = spu.sample_texture(unit, texcoords[0]);
+ if (spu_extract(mask, 1))
+ colors1[1] = spu.sample_texture(unit, texcoords[1]);
+ if (spu_extract(mask, 2))
+ colors1[2] = spu.sample_texture(unit, texcoords[2]);
+ if (spu_extract(mask, 3))
+ colors1[3] = spu.sample_texture(unit, texcoords[3]);
+
+ /* hack: modulate first texture by second */
+ colors[0] = spu_mul(colors[0], colors1[0]);
+ colors[1] = spu_mul(colors[1], colors1[1]);
+ colors[2] = spu_mul(colors[2], colors1[2]);
+ colors[3] = spu_mul(colors[3], colors1[3]);
+ }
+
}
else {
/* simple shading */