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;
}
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 */
/** 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;
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);
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));
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) {
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]);