Cell: send actual vertex size in the render command
authorBrian <brian.paul@tungstengraphics.com>
Thu, 24 Jan 2008 23:47:23 +0000 (16:47 -0700)
committerBrian <brian.paul@tungstengraphics.com>
Thu, 24 Jan 2008 23:47:23 +0000 (16:47 -0700)
src/mesa/pipe/cell/common.h
src/mesa/pipe/cell/ppu/cell_render.c
src/mesa/pipe/cell/ppu/cell_vbuf.c
src/mesa/pipe/cell/spu/spu_main.c

index 4c998722a26fb68a9daeb326291eaa63ca91641d..cd2b61e6e9428497fa798f89a96ff39d3185d7c9 100644 (file)
@@ -96,12 +96,14 @@ struct cell_command_clear_surface
 
 #define CELL_MAX_VBUF_SIZE    (16 * 1024)
 #define CELL_MAX_VBUF_INDEXES 1024
-#define CELL_MAX_ATTRIBS      2 /* temporary! */
+
+
 struct cell_command_render
 {
    uint opcode;
    uint prim_type;
-   uint num_verts, num_attribs;
+   uint num_verts;
+   uint vertex_size;  /**< bytes per vertex */
    uint num_indexes;
    const void *vertex_data;
    const ushort *index_data;
index ecdd47e28b09150bb39c4f82dbe23e8bb01d500c..4ab277a4b241720895e1ca6e8bab90e08fa6280f 100644 (file)
@@ -152,7 +152,7 @@ cell_flush_prim_buffer(struct cell_context *cell)
       struct cell_command_render *render = &cell_global.command[i].render;
       render->prim_type = PIPE_PRIM_TRIANGLES;
       render->num_verts = cell->prim_buffer.num_verts;
-      render->num_attribs = CELL_MAX_ATTRIBS;
+      render->vertex_size = cell->vertex_info->size * 4;
       render->xmin = cell->prim_buffer.xmin;
       render->ymin = cell->prim_buffer.ymin;
       render->xmax = cell->prim_buffer.xmax;
index a420de041afa05cf9f459f963413996731441895..711d03b49fcdf7ab8a682fe2868043858210230c 100644 (file)
@@ -31,7 +31,9 @@
  */
 
 
+#include "cell_batch.h"
 #include "cell_context.h"
+#include "cell_flush.h"
 #include "cell_spu.h"
 #include "cell_vbuf.h"
 #include "pipe/draw/draw_vbuf.h"
@@ -141,26 +143,7 @@ cell_vbuf_draw(struct vbuf_render *vbr,
    if (cvbr->prim != PIPE_PRIM_TRIANGLES)
       return; /* only render tris for now */
 
-#if 0
-   for (i = 0; i < cell->num_spus; i++) {
-      struct cell_command_render *render = &cell_global.command[i].render;
-      render->opcode = CELL_CMD_RENDER;
-      render->prim_type = cvbr->prim;
-      render->num_verts = nr_vertices;
-      render->num_attribs = CELL_MAX_ATTRIBS; /* XXX fix */
-      render->vertex_data = vertices;
-      render->index_data = indices;
-      render->num_indexes = nr_indices;
-      render->xmin = xmin;
-      render->ymin = ymin;
-      render->xmax = xmax;
-      render->ymax = ymax;
-
-      ASSERT_ALIGN16(render->vertex_data);
-      ASSERT_ALIGN16(render->index_data);
-      send_mbox_message(cell_global.spe_contexts[i], CELL_CMD_RENDER);
-   }
-#else
+   /* build/insert batch RENDER command */
    {
       struct cell_command_render *render
          = (struct cell_command_render *)
@@ -168,7 +151,7 @@ cell_vbuf_draw(struct vbuf_render *vbr,
       render->opcode = CELL_CMD_RENDER;
       render->prim_type = cvbr->prim;
       render->num_verts = nr_vertices;
-      render->num_attribs = CELL_MAX_ATTRIBS; /* XXX fix */
+      render->vertex_size = 4 * cell->vertex_info.size;
       render->vertex_data = vertices;
       render->index_data = indices;
       render->num_indexes = nr_indices;
@@ -180,7 +163,6 @@ cell_vbuf_draw(struct vbuf_render *vbr,
       ASSERT_ALIGN16(render->vertex_data);
       ASSERT_ALIGN16(render->index_data);
    }
-#endif
 
 #if 01
    /* XXX this is temporary */
index 2e5cb76b4a20e48db05831736b12bff06551c128..03dbef051b582ffa5b9418d02b64b0d2b2c612c7 100644 (file)
@@ -210,8 +210,8 @@ cmd_render(const struct cell_command_render *render)
    /* we'll DMA into these buffers */
    ubyte vertex_data[CELL_MAX_VBUF_SIZE] ALIGN16_ATTRIB;
    ushort indexes[CELL_MAX_VBUF_INDEXES] ALIGN16_ATTRIB;
-
-   uint i, j, vertex_size, vertex_bytes, index_bytes;
+   uint i, j, total_vertex_bytes, total_index_bytes;
+   const uint vertex_size = render->vertex_size; /* in bytes */
 
    if (Debug) {
       printf("SPU %u: RENDER prim %u, indices: %u, nr_vert: %u\n",
@@ -228,36 +228,34 @@ cmd_render(const struct cell_command_render *render)
    ASSERT_ALIGN16(render->vertex_data);
    ASSERT_ALIGN16(render->index_data);
 
-   vertex_size = render->num_attribs * 4 * sizeof(float);
-
    /* how much vertex data */
-   vertex_bytes = render->num_verts * vertex_size;
-   index_bytes = render->num_indexes * sizeof(ushort);
-   if (index_bytes < 16)
-      index_bytes = 16;
+   total_vertex_bytes = render->num_verts * vertex_size;
+   total_index_bytes = render->num_indexes * sizeof(ushort);
+   if (total_index_bytes < 16)
+      total_index_bytes = 16;
    else
-      index_bytes = (index_bytes + 15) & ~0xf; /* multiple of 16 */
+      total_index_bytes = (total_index_bytes + 15) & ~0xf; /* multiple of 16 */
 
    /*
-   printf("VBUF: indices at %p,  vertices at %p  vertex_bytes %u  ind_bytes %u\n",
-          render->index_data, render->vertex_data, vertex_bytes, index_bytes);
+   printf("VBUF: indices at %p,  vertices at %p  total_vertex_bytes %u  ind_bytes %u\n",
+          render->index_data, render->vertex_data, total_vertex_bytes, total_index_bytes);
    */
 
-   ASSERT(vertex_bytes % 16 == 0);
+   ASSERT(total_vertex_bytes % 16 == 0);
    /* get vertex data from main memory */
    mfc_get(vertex_data,  /* dest */
            (unsigned int) render->vertex_data,  /* src */
-           vertex_bytes,  /* size */
+           total_vertex_bytes,  /* size */
            TAG_VERTEX_BUFFER,
            0, /* tid */
            0  /* rid */);
 
-   ASSERT(index_bytes % 16 == 0);
+   ASSERT(total_index_bytes % 16 == 0);
 
    /* get index data from main memory */
    mfc_get(indexes,  /* dest */
            (unsigned int) render->index_data,  /* src */
-           index_bytes,
+           total_index_bytes,
            TAG_INDEX_BUFFER,
            0, /* tid */
            0  /* rid */);