diff options
author | Brian <[email protected]> | 2008-01-25 08:17:52 -0700 |
---|---|---|
committer | Brian <[email protected]> | 2008-01-25 08:20:10 -0700 |
commit | 235da629dceb23bfddea1eadfcf771d2794d6119 (patch) | |
tree | 12bb5e34b092ae19fa62dc89433fca5ae6dfea83 /src/mesa/pipe | |
parent | 4c4f691069411c77b33a6bfca64766f861cbc823 (diff) |
Cell: propogate vertex info to SPUs, use it for attrib interpolation
Diffstat (limited to 'src/mesa/pipe')
-rw-r--r-- | src/mesa/pipe/cell/common.h | 7 | ||||
-rw-r--r-- | src/mesa/pipe/cell/ppu/cell_state.h | 1 | ||||
-rw-r--r-- | src/mesa/pipe/cell/ppu/cell_state_derived.c | 5 | ||||
-rw-r--r-- | src/mesa/pipe/cell/ppu/cell_state_emit.c | 6 | ||||
-rw-r--r-- | src/mesa/pipe/cell/spu/spu_main.c | 19 | ||||
-rw-r--r-- | src/mesa/pipe/cell/spu/spu_main.h | 4 | ||||
-rw-r--r-- | src/mesa/pipe/cell/spu/spu_tri.c | 46 |
7 files changed, 55 insertions, 33 deletions
diff --git a/src/mesa/pipe/cell/common.h b/src/mesa/pipe/cell/common.h index 5c437daac6f..af7f27bc831 100644 --- a/src/mesa/pipe/cell/common.h +++ b/src/mesa/pipe/cell/common.h @@ -64,6 +64,7 @@ #define CELL_CMD_BATCH 6 #define CELL_CMD_STATE_DEPTH_STENCIL 7 #define CELL_CMD_STATE_SAMPLER 8 +#define CELL_CMD_STATE_VERTEX_INFO 9 #define CELL_NUM_BATCH_BUFFERS 3 @@ -103,11 +104,11 @@ struct cell_command_clear_surface struct cell_command_render { - uint opcode; - uint prim_type; + uint opcode; /**< CELL_CMD_RENDER */ + uint prim_type; /**< PIPE_PRIM_x */ uint num_verts; uint vertex_size; /**< bytes per vertex */ - uint dummy; /* XXX this dummy field works around a compiler bug */ + uint dummy; /* XXX this dummy field works around a compiler bug */ uint num_indexes; const void *vertex_data; const ushort *index_data; diff --git a/src/mesa/pipe/cell/ppu/cell_state.h b/src/mesa/pipe/cell/ppu/cell_state.h index fbca7c95744..3a71ba14fa8 100644 --- a/src/mesa/pipe/cell/ppu/cell_state.h +++ b/src/mesa/pipe/cell/ppu/cell_state.h @@ -19,6 +19,7 @@ #define CELL_NEW_VERTEX 0x1000 #define CELL_NEW_VS 0x2000 #define CELL_NEW_CONSTANTS 0x4000 +#define CELL_NEW_VERTEX_INFO 0x8000 diff --git a/src/mesa/pipe/cell/ppu/cell_state_derived.c b/src/mesa/pipe/cell/ppu/cell_state_derived.c index f3b3ae8544d..56daf5dfde0 100644 --- a/src/mesa/pipe/cell/ppu/cell_state_derived.c +++ b/src/mesa/pipe/cell/ppu/cell_state_derived.c @@ -30,6 +30,7 @@ #include "pipe/draw/draw_context.h" #include "pipe/draw/draw_vertex.h" #include "cell_context.h" +#include "cell_batch.h" #include "cell_state.h" #include "cell_state_emit.h" @@ -85,6 +86,7 @@ calculate_vertex_layout( struct cell_context *cell ) assert(src >= 0); draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_POS, src); + /* * Loop over fragment shader inputs, searching for the matching output * from the vertex shader. @@ -126,6 +128,9 @@ calculate_vertex_layout( struct cell_context *cell ) } draw_compute_vertex_size(vinfo); + + /* XXX only signal this if format really changes */ + cell->dirty |= CELL_NEW_VERTEX_INFO; } diff --git a/src/mesa/pipe/cell/ppu/cell_state_emit.c b/src/mesa/pipe/cell/ppu/cell_state_emit.c index e7d14d0d252..e5b7c925143 100644 --- a/src/mesa/pipe/cell/ppu/cell_state_emit.c +++ b/src/mesa/pipe/cell/ppu/cell_state_emit.c @@ -49,4 +49,10 @@ cell_emit_state(struct cell_context *cell) cell_batch_append(cell, cell->sampler[0], sizeof(struct pipe_sampler_state)); } + + if (cell->dirty & CELL_NEW_VERTEX_INFO) { + uint cmd = CELL_CMD_STATE_VERTEX_INFO; + cell_batch_append(cell, &cmd, 4); + cell_batch_append(cell, &cell->vertex_info, sizeof(struct vertex_info)); + } } diff --git a/src/mesa/pipe/cell/spu/spu_main.c b/src/mesa/pipe/cell/spu/spu_main.c index 1d0de7b1f9e..880f8de550e 100644 --- a/src/mesa/pipe/cell/spu/spu_main.c +++ b/src/mesa/pipe/cell/spu/spu_main.c @@ -391,6 +391,17 @@ cmd_state_sampler(const struct pipe_sampler_state *state) static void +cmd_state_vertex_info(const struct vertex_info *vinfo) +{ + if (Debug) + printf("SPU %u: VERTEX_INFO num_attribs=%u\n", spu.init.id, + vinfo->num_attribs); + memcpy(&spu.vertex_info, vinfo, sizeof(*vinfo)); +} + + + +static void cmd_finish(void) { if (Debug) @@ -472,7 +483,6 @@ cmd_batch(uint opcode) /* Tell PPU we're done copying the buffer to local store */ release_batch_buffer(buf); - for (pos = 0; pos < usize; /* no incr */) { switch (buffer[pos]) { case CELL_CMD_FRAMEBUFFER: @@ -509,10 +519,13 @@ cmd_batch(uint opcode) pos += (1 + sizeof(struct pipe_depth_stencil_alpha_state) / 4); break; case CELL_CMD_STATE_SAMPLER: - cmd_state_sampler((struct pipe_sampler_state *) - &buffer[pos+1]); + cmd_state_sampler((struct pipe_sampler_state *) &buffer[pos+1]); pos += (1 + sizeof(struct pipe_sampler_state) / 4); break; + case CELL_CMD_STATE_VERTEX_INFO: + cmd_state_vertex_info((struct vertex_info *) &buffer[pos+1]); + pos += (1 + sizeof(struct vertex_info) / 4); + break; default: printf("SPU %u: bad opcode: 0x%x\n", spu.init.id, buffer[pos]); ASSERT(0); diff --git a/src/mesa/pipe/cell/spu/spu_main.h b/src/mesa/pipe/cell/spu/spu_main.h index 3ef73c9473d..e4359bf60d0 100644 --- a/src/mesa/pipe/cell/spu/spu_main.h +++ b/src/mesa/pipe/cell/spu/spu_main.h @@ -30,6 +30,7 @@ #include "pipe/cell/common.h" +#include "pipe/draw/draw_vertex.h" #include "pipe/p_state.h" @@ -59,6 +60,9 @@ struct spu_global struct pipe_depth_stencil_alpha_state depth_stencil; struct pipe_blend_state blend; struct pipe_sampler_state sampler[PIPE_MAX_SAMPLERS]; + + struct vertex_info vertex_info; + /* XXX more state to come */ } ALIGN16_ATTRIB; diff --git a/src/mesa/pipe/cell/spu/spu_tri.c b/src/mesa/pipe/cell/spu/spu_tri.c index 1d73c5171ce..3d0d106c10e 100644 --- a/src/mesa/pipe/cell/spu/spu_tri.c +++ b/src/mesa/pipe/cell/spu/spu_tri.c @@ -42,7 +42,7 @@ * Simplified types taken from other parts of Gallium */ struct vertex_header { - float data[2][4]; /* pos and color */ + float data[0][4]; }; struct prim_header { @@ -727,40 +727,32 @@ static void tri_persp_coeff( struct setup_stage *setup, */ static void setup_tri_coefficients( struct setup_stage *setup ) { -#if 0 - const enum interp_mode *interp = setup->softpipe->vertex_info.interp_mode; - unsigned slot, j; - - /* z and w are done by linear interpolation: - */ - tri_linear_coeff(setup, 0, 2); - tri_linear_coeff(setup, 0, 3); +#if 1 + uint i; - /* setup interpolation for all the remaining attributes: - */ - for (slot = 1; slot < setup->quad.nr_attrs; slot++) { - switch (interp[slot]) { + for (i = 0; i < spu.vertex_info.num_attribs; i++) { + switch (spu.vertex_info.interp_mode[i]) { + case INTERP_NONE: + break; + case INTERP_POS: + tri_linear_coeff(setup, i, 2, 3); /* slot 0, z */ + /* XXX interp W if PERSPECTIVE... */ + break; case INTERP_CONSTANT: - for (j = 0; j < NUM_CHANNELS; j++) - const_coeff(setup, slot, j); - break; - + /* fall-through */ case INTERP_LINEAR: - for (j = 0; j < NUM_CHANNELS; j++) - tri_linear_coeff(setup, slot, j); - break; - + tri_linear_coeff(setup, i, 0, 4); /* slot 1, color */ + break; case INTERP_PERSPECTIVE: - for (j = 0; j < NUM_CHANNELS; j++) - tri_persp_coeff(setup, slot, j); - break; - + break; default: - /* invalid interp mode */ - assert(0); + ASSERT(0); } } #else + ASSERT(spu.vertex_info.interp_mode[0] == INTERP_POS); + ASSERT(spu.vertex_info.interp_mode[1] == INTERP_LINEAR || + spu.vertex_info.interp_mode[1] == INTERP_CONSTANT); tri_linear_coeff(setup, 0, 2, 3); /* slot 0, z */ tri_linear_coeff(setup, 1, 0, 4); /* slot 1, color */ #endif |