#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
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;
#define CELL_NEW_VERTEX 0x1000
#define CELL_NEW_VS 0x2000
#define CELL_NEW_CONSTANTS 0x4000
+#define CELL_NEW_VERTEX_INFO 0x8000
#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"
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.
}
draw_compute_vertex_size(vinfo);
+
+ /* XXX only signal this if format really changes */
+ cell->dirty |= CELL_NEW_VERTEX_INFO;
}
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));
+ }
}
}
+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)
{
/* 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:
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);
#include "pipe/cell/common.h"
+#include "pipe/draw/draw_vertex.h"
#include "pipe/p_state.h"
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;
* 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 {
*/
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