diff options
Diffstat (limited to 'src/mesa/pipe/cell/spu')
-rw-r--r-- | src/mesa/pipe/cell/spu/Makefile | 2 | ||||
-rw-r--r-- | src/mesa/pipe/cell/spu/spu_colorpack.h | 9 | ||||
-rw-r--r-- | src/mesa/pipe/cell/spu/spu_main.c | 12 | ||||
-rw-r--r-- | src/mesa/pipe/cell/spu/spu_main.h | 3 | ||||
-rw-r--r-- | src/mesa/pipe/cell/spu/spu_tri.c | 76 |
5 files changed, 56 insertions, 46 deletions
diff --git a/src/mesa/pipe/cell/spu/Makefile b/src/mesa/pipe/cell/spu/Makefile index 2d031bfbc61..91a631b6992 100644 --- a/src/mesa/pipe/cell/spu/Makefile +++ b/src/mesa/pipe/cell/spu/Makefile @@ -8,6 +8,8 @@ TOP = ../../../../.. include $(TOP)/configs/linux-cell +OPT_FLAGS=-g +OPT_FLAGS=-O3 PROG = g3d PROG_SPU = $(PROG)_spu diff --git a/src/mesa/pipe/cell/spu/spu_colorpack.h b/src/mesa/pipe/cell/spu/spu_colorpack.h index 56709bd9f38..9977a6ece0e 100644 --- a/src/mesa/pipe/cell/spu/spu_colorpack.h +++ b/src/mesa/pipe/cell/spu/spu_colorpack.h @@ -57,4 +57,13 @@ spu_pack_B8G8R8A8(vector float rgba) } +static INLINE unsigned int +spu_pack_color_shuffle(vector float rgba, vector unsigned char shuffle) +{ + vector unsigned int out = spu_convtu(rgba, 32); + out = spu_shuffle(out, out, shuffle); + return spu_extract(out, 0); +} + + #endif /* SPU_COLORPACK_H */ diff --git a/src/mesa/pipe/cell/spu/spu_main.c b/src/mesa/pipe/cell/spu/spu_main.c index 8e3987f6ef5..ba4d180cc0c 100644 --- a/src/mesa/pipe/cell/spu/spu_main.c +++ b/src/mesa/pipe/cell/spu/spu_main.c @@ -31,6 +31,7 @@ #include <stdio.h> #include <libmisc.h> +#include <vec_literal.h> #include "spu_main.h" #include "spu_render.h" @@ -217,6 +218,17 @@ cmd_state_framebuffer(const struct cell_command_framebuffer *cmd) spu.fb.zsize = 2; else spu.fb.zsize = 0; + + if (spu.fb.color_format == PIPE_FORMAT_A8R8G8B8_UNORM) + spu.color_shuffle = VEC_LITERAL(vector unsigned char, + 12, 0, 4, 8, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0); + else if (spu.fb.color_format == PIPE_FORMAT_B8G8R8A8_UNORM) + spu.color_shuffle = VEC_LITERAL(vector unsigned char, + 8, 4, 0, 12, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0); + else + ASSERT(0); } diff --git a/src/mesa/pipe/cell/spu/spu_main.h b/src/mesa/pipe/cell/spu/spu_main.h index cce5e708021..7a12715b0bc 100644 --- a/src/mesa/pipe/cell/spu/spu_main.h +++ b/src/mesa/pipe/cell/spu/spu_main.h @@ -107,6 +107,9 @@ struct spu_global ubyte ctile_status[MAX_HEIGHT/TILE_SIZE][MAX_WIDTH/TILE_SIZE] ALIGN16_ATTRIB; ubyte ztile_status[MAX_HEIGHT/TILE_SIZE][MAX_WIDTH/TILE_SIZE] ALIGN16_ATTRIB; + + /** for converting RGBA to PIPE_FORMAT_x colors */ + vector unsigned char color_shuffle; } ALIGN16_ATTRIB; diff --git a/src/mesa/pipe/cell/spu/spu_tri.c b/src/mesa/pipe/cell/spu/spu_tri.c index c82ca51000e..165e41a7819 100644 --- a/src/mesa/pipe/cell/spu/spu_tri.c +++ b/src/mesa/pipe/cell/spu/spu_tri.c @@ -249,28 +249,6 @@ eval_z(float x, float y) } -static INLINE void -pack_colors(uint uicolors[4], const float4 fcolors[4]) -{ - switch (spu.fb.color_format) { - case PIPE_FORMAT_A8R8G8B8_UNORM: - uicolors[0] = spu_pack_A8R8G8B8(fcolors[0].v); - uicolors[1] = spu_pack_A8R8G8B8(fcolors[1].v); - uicolors[2] = spu_pack_A8R8G8B8(fcolors[2].v); - uicolors[3] = spu_pack_A8R8G8B8(fcolors[3].v); - break; - case PIPE_FORMAT_B8G8R8A8_UNORM: - uicolors[0] = spu_pack_B8G8R8A8(fcolors[0].v); - uicolors[1] = spu_pack_B8G8R8A8(fcolors[1].v); - uicolors[2] = spu_pack_B8G8R8A8(fcolors[2].v); - uicolors[3] = spu_pack_B8G8R8A8(fcolors[3].v); - break; - default: - ASSERT(0); - } -} - - static INLINE mask_t do_depth_test(int x, int y, mask_t quadmask) { @@ -321,38 +299,44 @@ emit_quad( int x, int y, mask_t mask ) if (spu_extract(spu_orx(mask), 0)) { const int ix = x - setup.cliprect_minx; const int iy = y - setup.cliprect_miny; - uint colors[4]; /* indexed by QUAD_x */ + + if (spu.cur_ctile_status == TILE_STATUS_CLEAR) { + /* now, _really_ clear the tile */ + clear_c_tile(&spu.ctile); + } + spu.cur_ctile_status = TILE_STATUS_DIRTY; if (spu.texture.start) { + /* texture mapping */ float4 texcoords[4]; - uint i; eval_coeff(2, (float) x, (float) y, texcoords); - for (i = 0; i < 4; i++) { - colors[i] = sample_texture(texcoords[i]); - } + + if (spu_extract(mask, 0)) + spu.ctile.ui[iy][ix] = sample_texture(texcoords[0]); + if (spu_extract(mask, 1)) + spu.ctile.ui[iy][ix+1] = sample_texture(texcoords[1]); + if (spu_extract(mask, 2)) + spu.ctile.ui[iy+1][ix] = sample_texture(texcoords[2]); + if (spu_extract(mask, 3)) + spu.ctile.ui[iy+1][ix+1] = sample_texture(texcoords[3]); } else { - float4 fcolors[4]; - eval_coeff(1, (float) x, (float) y, fcolors); - pack_colors(colors, fcolors); + /* simple shading */ + const vector unsigned char shuffle = spu.color_shuffle; + float4 colors[4]; + eval_coeff(1, (float) x, (float) y, colors); + + if (spu_extract(mask, 0)) + spu.ctile.ui[iy][ix] = spu_pack_color_shuffle(colors[0].v, shuffle); + if (spu_extract(mask, 1)) + spu.ctile.ui[iy][ix+1] = spu_pack_color_shuffle(colors[1].v, shuffle); + if (spu_extract(mask, 2)) + spu.ctile.ui[iy+1][ix] = spu_pack_color_shuffle(colors[2].v, shuffle); + if (spu_extract(mask, 3)) + spu.ctile.ui[iy+1][ix+1] = spu_pack_color_shuffle(colors[3].v, shuffle); } - if (spu.cur_ctile_status == TILE_STATUS_CLEAR) { - /* now, _really_ clear the tile */ - clear_c_tile(&spu.ctile); - } - spu.cur_ctile_status = TILE_STATUS_DIRTY; - -#if 1 - if (spu_extract(mask, 0)) - spu.ctile.ui[iy][ix] = colors[QUAD_TOP_LEFT]; - if (spu_extract(mask, 1)) - spu.ctile.ui[iy][ix+1] = colors[QUAD_TOP_RIGHT]; - if (spu_extract(mask, 2)) - spu.ctile.ui[iy+1][ix] = colors[QUAD_BOTTOM_LEFT]; - if (spu_extract(mask, 3)) - spu.ctile.ui[iy+1][ix+1] = colors[QUAD_BOTTOM_RIGHT]; -#else +#if 0 /* SIMD_Z with swizzled color buffer (someday) */ vector unsigned int uicolors = *((vector unsigned int *) &colors); spu.ctile.ui4[iy/2][ix/2] = spu_sel(spu.ctile.ui4[iy/2][ix/2], uicolors, mask); |