cell: adapt to new vertex element cso
authorRoland Scheidegger <sroland@vmware.com>
Mon, 1 Mar 2010 17:47:04 +0000 (18:47 +0100)
committerRoland Scheidegger <sroland@vmware.com>
Mon, 1 Mar 2010 17:47:04 +0000 (18:47 +0100)
src/gallium/drivers/cell/ppu/cell_context.h
src/gallium/drivers/cell/ppu/cell_state_vertex.c

index a77cc5b9067804c0df716dccfe82099bab5c1e53..84ad0f342200c0fa112048278b4ddd7c91872671 100644 (file)
@@ -93,6 +93,11 @@ struct cell_buffer_list
    struct cell_buffer_node *head;
 };
 
+struct cell_velems_state
+{
+   unsigned count;
+   struct pipe_vertex_element velem[];
+}
 
 /**
  * Per-context state, subclass of pipe_context.
@@ -110,6 +115,7 @@ struct cell_context
    const struct pipe_rasterizer_state *rasterizer;
    const struct cell_vertex_shader_state *vs;
    const struct cell_fragment_shader_state *fs;
+   const struct cell_velems_state *velems;
 
    struct spe_function logic_op;
 
@@ -125,8 +131,6 @@ struct cell_context
    struct pipe_viewport_state viewport;
    struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
    uint num_vertex_buffers;
-   struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS];
-   uint num_vertex_elements;
 
    ubyte *cbuf_map[PIPE_MAX_COLOR_BUFS];
    ubyte *zsbuf_map;
index fbe55c84721497b572fb8e970eff6e0e4584cc17..35c919fb6b7badb403b056141f99b174eb2a0129 100644 (file)
 #include "cell_context.h"
 #include "cell_state.h"
 
+#include "util/u_memory.h"
 #include "draw/draw_context.h"
 
 
-static void
-cell_set_vertex_elements(struct pipe_context *pipe,
-                         unsigned count,
-                         const struct pipe_vertex_element *elements)
+void *
+cell_create_vertex_elements_state(struct pipe_context *pipe,
+                                  unsigned count,
+                                  const struct pipe_vertex_element *attribs)
 {
-   struct cell_context *cell = cell_context(pipe);
-
+   struct cell_velems_state *velems;
    assert(count <= PIPE_MAX_ATTRIBS);
+   velems = (struct cell_velems_state *) MALLOC(sizeof(struct cell_velems_state) + count * sizeof(*attribs));
+   if (velems) {
+      velems->count = count;
+      memcpy(velems->velem, attribs, sizeof(*attribs) * count);
+   }
+   return velems;
+}
+
+void
+cell_bind_vertex_elements_state(struct pipe_context *pipe,
+                                void *velems)
+{
+   struct cell_context *cell = cell_context(pipe);
+   struct cell_velems_state *cell_velems = (struct cell_velems_state *) velems;
 
-   memcpy(cell->vertex_element, elements, count * sizeof(elements[0]));
-   cell->num_vertex_elements = count;
+   cell->velems = cell_velems;
 
    cell->dirty |= CELL_NEW_VERTEX;
 
-   draw_set_vertex_elements(cell->draw, count, elements);
+   draw_set_vertex_elements(cell->draw, cell_velems->count, cell_velems->velem);
+}
+
+void
+cell_delete_vertex_elements_state(struct pipe_context *pipe, void *velems)
+{
+   FREE( velems );
 }
 
 
@@ -75,5 +94,7 @@ void
 cell_init_vertex_functions(struct cell_context *cell)
 {
    cell->pipe.set_vertex_buffers = cell_set_vertex_buffers;
-   cell->pipe.set_vertex_elements = cell_set_vertex_elements;
+   cell->pipe.create_vertex_elements_state = cell_create_vertex_elements_state;
+   cell->pipe.bind_vertex_elements_state = cell_bind_vertex_elements_state;
+   cell->pipe.delete_vertex_elements_state = cell_delete_vertex_elements_state;
 }