* Get texture sample at texcoord.
* XXX this is extremely primitive for now.
*/
-uint
+vector float
sample_texture_nearest(vector float texcoord)
{
vector float tc = spu_mul(texcoord, spu.tex_size);
vector unsigned int ij = spu_and(itc, TILE_SIZE-1); /* intra tile addr */
uint pos = get_tex_tile(itc);
uint texel = tex_tiles[pos].ui[spu_extract(ij, 1)][spu_extract(ij, 0)];
- return texel;
+ return spu_unpack_A8R8G8B8(texel);
}
-uint
+vector float
sample_texture_bilinear(vector float texcoord)
{
static const vector unsigned int offset10 = {1, 0, 0, 0};
}
/* get texels from tiles and convert to float[4] */
- vector float texel00 = spu_unpack_color(tex_tiles[pos00].ui[spu_extract(ij00, 1)][spu_extract(ij00, 0)]);
- vector float texel01 = spu_unpack_color(tex_tiles[pos01].ui[spu_extract(ij01, 1)][spu_extract(ij01, 0)]);
- vector float texel10 = spu_unpack_color(tex_tiles[pos10].ui[spu_extract(ij10, 1)][spu_extract(ij10, 0)]);
- vector float texel11 = spu_unpack_color(tex_tiles[pos11].ui[spu_extract(ij11, 1)][spu_extract(ij11, 0)]);
+ vector float texel00 = spu_unpack_A8R8G8B8(tex_tiles[pos00].ui[spu_extract(ij00, 1)][spu_extract(ij00, 0)]);
+ vector float texel01 = spu_unpack_A8R8G8B8(tex_tiles[pos01].ui[spu_extract(ij01, 1)][spu_extract(ij01, 0)]);
+ vector float texel10 = spu_unpack_A8R8G8B8(tex_tiles[pos10].ui[spu_extract(ij10, 1)][spu_extract(ij10, 0)]);
+ vector float texel11 = spu_unpack_A8R8G8B8(tex_tiles[pos11].ui[spu_extract(ij11, 1)][spu_extract(ij11, 0)]);
/* Compute weighting factors in [0,1]
* Multiply texcoord by 1024, AND with 1023, convert back to float.
texel_sum = spu_add(texel_sum, texel10);
texel_sum = spu_add(texel_sum, texel11);
- /* convert to uint color */
- uint texel = spu_pack_R8G8B8A8(texel_sum);
-
- return texel;
+ return texel_sum;
}
if (spu_extract(spu_orx(mask), 0)) {
const int ix = x - setup.cliprect_minx;
const int iy = y - setup.cliprect_miny;
+ const vector unsigned char shuffle = spu.color_shuffle;
+ vector float colors[4];
spu.cur_ctile_status = TILE_STATUS_DIRTY;
eval_coeff(2, (float) x, (float) y, texcoords);
if (spu_extract(mask, 0))
- spu.ctile.ui[iy][ix] = spu.sample_texture(texcoords[0]);
+ colors[0] = spu.sample_texture(texcoords[0]);
if (spu_extract(mask, 1))
- spu.ctile.ui[iy][ix+1] = spu.sample_texture(texcoords[1]);
+ colors[1] = spu.sample_texture(texcoords[1]);
if (spu_extract(mask, 2))
- spu.ctile.ui[iy+1][ix] = spu.sample_texture(texcoords[2]);
+ colors[2] = spu.sample_texture(texcoords[2]);
if (spu_extract(mask, 3))
- spu.ctile.ui[iy+1][ix+1] = spu.sample_texture(texcoords[3]);
+ colors[3] = spu.sample_texture(texcoords[3]);
}
else {
/* simple shading */
- const vector unsigned char shuffle = spu.color_shuffle;
- vector float colors[4];
eval_coeff(1, (float) x, (float) y, colors);
+ }
-#if 0
- if (spu.blend.blend_enable)
- blend_quad(ix % TILE_SIZE, iy % TILE_SIZE, colors);
+#if 1
+ if (spu.blend.blend_enable)
+ blend_quad(ix % TILE_SIZE, iy % TILE_SIZE, colors);
#endif
- if (spu_extract(mask, 0))
- spu.ctile.ui[iy][ix] = spu_pack_color_shuffle(colors[0], shuffle);
- if (spu_extract(mask, 1))
- spu.ctile.ui[iy][ix+1] = spu_pack_color_shuffle(colors[1], shuffle);
- if (spu_extract(mask, 2))
- spu.ctile.ui[iy+1][ix] = spu_pack_color_shuffle(colors[2], shuffle);
- if (spu_extract(mask, 3))
- spu.ctile.ui[iy+1][ix+1] = spu_pack_color_shuffle(colors[3], shuffle);
- }
+ if (spu_extract(mask, 0))
+ spu.ctile.ui[iy][ix] = spu_pack_color_shuffle(colors[0], shuffle);
+ if (spu_extract(mask, 1))
+ spu.ctile.ui[iy][ix+1] = spu_pack_color_shuffle(colors[1], shuffle);
+ if (spu_extract(mask, 2))
+ spu.ctile.ui[iy+1][ix] = spu_pack_color_shuffle(colors[2], shuffle);
+ if (spu_extract(mask, 3))
+ spu.ctile.ui[iy+1][ix+1] = spu_pack_color_shuffle(colors[3], shuffle);
#if 0
/* SIMD_Z with swizzled color buffer (someday) */