draw: move incoming vertex state into draw->pt
authorKeith Whitwell <keith@tungstengraphics.com>
Sat, 19 Apr 2008 16:27:52 +0000 (17:27 +0100)
committerKeith Whitwell <keith@tungstengraphics.com>
Sat, 19 Apr 2008 16:27:52 +0000 (17:27 +0100)
This state is effectively private to the vertex processing part
of the draw module.

src/gallium/auxiliary/draw/draw_context.c
src/gallium/auxiliary/draw/draw_private.h
src/gallium/auxiliary/draw/draw_pt.c
src/gallium/auxiliary/draw/draw_pt.h
src/gallium/auxiliary/draw/draw_pt_elts.c
src/gallium/auxiliary/draw/draw_pt_fetch.c
src/gallium/auxiliary/draw/draw_pt_fetch_emit.c
src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c
src/gallium/auxiliary/draw/draw_pt_vcache.c
src/mesa/state_tracker/st_draw.c

index 3e69867d113aad171bb8ba23d325da5f99025132..4988d67faa1a48bbac041a2465ac2c7c78eec1ed 100644 (file)
@@ -62,8 +62,6 @@ struct draw_context *draw_create( void )
 
    draw->reduced_prim = ~0; /* != any of PIPE_PRIM_x */
 
-   draw_set_mapped_element_buffer( draw, 0, NULL );
-
    tgsi_exec_machine_init(&draw->machine);
 
    /* FIXME: give this machine thing a proper constructor:
@@ -188,8 +186,8 @@ draw_set_vertex_buffers(struct draw_context *draw,
 {
    assert(count <= PIPE_MAX_ATTRIBS);
 
-   memcpy(draw->vertex_buffer, buffers, count * sizeof(buffers[0]));
-   draw->nr_vertex_buffers = count;
+   memcpy(draw->pt.vertex_buffer, buffers, count * sizeof(buffers[0]));
+   draw->pt.nr_vertex_buffers = count;
 }
 
 
@@ -200,8 +198,8 @@ draw_set_vertex_elements(struct draw_context *draw,
 {
    assert(count <= PIPE_MAX_ATTRIBS);
 
-   memcpy(draw->vertex_element, elements, count * sizeof(elements[0]));
-   draw->nr_vertex_elements = count;
+   memcpy(draw->pt.vertex_element, elements, count * sizeof(elements[0]));
+   draw->pt.nr_vertex_elements = count;
 }
 
 
@@ -212,7 +210,7 @@ void
 draw_set_mapped_vertex_buffer(struct draw_context *draw,
                               unsigned attr, const void *buffer)
 {
-   draw->user.vbuffer[attr] = buffer;
+   draw->pt.user.vbuffer[attr] = buffer;
 }
 
 
@@ -220,7 +218,7 @@ void
 draw_set_mapped_constant_buffer(struct draw_context *draw,
                                 const void *buffer)
 {
-   draw->user.constants = buffer;
+   draw->pt.user.constants = buffer;
 }
 
 
@@ -337,18 +335,10 @@ void draw_set_render( struct draw_context *draw,
 void draw_set_edgeflags( struct draw_context *draw,
                          const unsigned *edgeflag )
 {
-   draw->user.edgeflag = edgeflag;
+   draw->pt.user.edgeflag = edgeflag;
 }
 
 
-boolean draw_get_edgeflag( struct draw_context *draw,
-                           unsigned idx )
-{
-   if (draw->user.edgeflag)
-      return (draw->user.edgeflag[idx/32] & (1 << (idx%32))) != 0;
-   else
-      return 1;
-}
 
 
 /**
@@ -365,8 +355,8 @@ void
 draw_set_mapped_element_buffer( struct draw_context *draw,
                                 unsigned eltSize, void *elements )
 {
-   draw->user.elts = elements;
-   draw->user.eltSize = eltSize;
+   draw->pt.user.elts = elements;
+   draw->pt.user.eltSize = eltSize;
 }
 
 
index 6cf3e54e28d9ebaa0f153f45314d68dbdc8c33a0..27f61c2f40f1328500f70f84e24d5945ad9c1a0d 100644 (file)
@@ -149,6 +149,29 @@ struct draw_context
       struct {
          struct draw_pt_front_end *vcache;
       } front;
+
+      struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
+      unsigned nr_vertex_buffers;
+
+      struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS];
+      unsigned nr_vertex_elements;
+
+      /* user-space vertex data, buffers */
+      struct {
+         const unsigned *edgeflag;
+
+         /** vertex element/index buffer (ex: glDrawElements) */
+         const void *elts;
+         /** bytes per index (0, 1, 2 or 4) */
+         unsigned eltSize;
+         
+         /** vertex arrays */
+         const void *vbuffer[PIPE_MAX_ATTRIBS];
+         
+         /** constant buffer (for vertex shader) */
+         const void *constants;
+      } user;
+
    } pt;
 
    boolean flushing;
@@ -157,33 +180,12 @@ struct draw_context
    const struct pipe_rasterizer_state *rasterizer;
    struct pipe_viewport_state viewport;
 
-   struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
-   unsigned nr_vertex_buffers;
-
-   struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS];
-   unsigned nr_vertex_elements;
-
    struct draw_vertex_shader *vertex_shader;
 
    boolean identity_viewport;
 
    uint num_vs_outputs;  /**< convenience, from vertex_shader */
 
-   /* user-space vertex data, buffers */
-   struct {
-      const unsigned *edgeflag;
-
-      /** vertex element/index buffer (ex: glDrawElements) */
-      const void *elts;
-      /** bytes per index (0, 1, 2 or 4) */
-      unsigned eltSize;
-
-      /** vertex arrays */
-      const void *vbuffer[PIPE_MAX_ATTRIBS];
-
-      /** constant buffer (for vertex shader) */
-      const void *constants;
-   } user;
 
    /* Clip derived state:
     */
@@ -257,9 +259,6 @@ boolean draw_need_pipeline(const struct draw_context *draw,
 
 void draw_do_flush( struct draw_context *draw, unsigned flags );
 
-boolean draw_get_edgeflag( struct draw_context *draw,
-                           unsigned idx );
-
 
 
 
index 965269251f72a1b49b0316d3de7f17a5e8b0cfb2..9f8e8d3d62e9448578b6234b2f1fd7a89e6340f4 100644 (file)
@@ -165,3 +165,11 @@ draw_arrays(struct draw_context *draw, unsigned prim,
    draw_pt_arrays(draw, prim, start, count);
 }
 
+boolean draw_pt_get_edgeflag( struct draw_context *draw,
+                              unsigned idx )
+{
+   if (draw->pt.user.edgeflag)
+      return (draw->pt.user.edgeflag[idx/32] & (1 << (idx%32))) != 0;
+   else
+      return 1;
+}
index eaf8e0374a414adffcbcd125a8ba56d2243cb50c..fd0d158fcf7cb43dc44bb83559bd899652059ec8 100644 (file)
@@ -141,13 +141,8 @@ struct draw_pt_middle_end *draw_pt_fetch_pipeline_or_emit(struct draw_context *d
 
 /* More helpers:
  */
-void draw_pt_run_pipeline( struct draw_context *draw,
-                           unsigned prim,
-                           struct vertex_header *verts,
-                           unsigned vertex_count,
-                           unsigned vertex_stride,
-                           const ushort *elts,
-                           unsigned count );
+boolean draw_pt_get_edgeflag( struct draw_context *draw,
+                              unsigned idx );
 
 
 /*******************************************************************************
index d49770e7b2de5c711b9203affe92b91209cce63f..2094c081ed4901825e616b68d48cd21268133ba2 100644 (file)
@@ -59,7 +59,7 @@ static unsigned elt_vert( const void *elts, unsigned idx )
 
 pt_elt_func draw_pt_elt_func( struct draw_context *draw )
 {
-   switch (draw->user.eltSize) {
+   switch (draw->pt.user.eltSize) {
    case 0: return elt_vert;
    case 1: return elt_ubyte;
    case 2: return elt_ushort; 
@@ -71,9 +71,9 @@ pt_elt_func draw_pt_elt_func( struct draw_context *draw )
 const void *draw_pt_elt_ptr( struct draw_context *draw,
                              unsigned start )
 {
-   const char *elts = draw->user.elts;
+   const char *elts = draw->pt.user.elts;
 
-   switch (draw->user.eltSize) {
+   switch (draw->pt.user.eltSize) {
    case 0: 
       return (const void *)(((const ubyte *)NULL) + start);
    case 1: 
index 037e3765dad01451534f360facaee09d3cb3194a..c588710b756f889f8da26b74269431b9553da489 100644 (file)
@@ -76,7 +76,7 @@ void draw_pt_fetch_prepare( struct pt_fetch *fetch,
       /* Need to set header->vertex_id = 0xffff somehow.
        */
       key.element[nr].input_format = PIPE_FORMAT_R32_FLOAT;
-      key.element[nr].input_buffer = draw->nr_vertex_buffers;
+      key.element[nr].input_buffer = draw->pt.nr_vertex_buffers;
       key.element[nr].input_offset = 0;
       key.element[nr].output_format = PIPE_FORMAT_R32_FLOAT;
       key.element[nr].output_offset = dst_offset;
@@ -90,10 +90,10 @@ void draw_pt_fetch_prepare( struct pt_fetch *fetch,
    }
       
 
-   for (i = 0; i < draw->nr_vertex_elements; i++) {
-      key.element[nr].input_format = draw->vertex_element[i].src_format;
-      key.element[nr].input_buffer = draw->vertex_element[i].vertex_buffer_index;
-      key.element[nr].input_offset = draw->vertex_element[i].src_offset;
+   for (i = 0; i < draw->pt.nr_vertex_elements; i++) {
+      key.element[nr].input_format = draw->pt.vertex_element[i].src_format;
+      key.element[nr].input_buffer = draw->pt.vertex_element[i].vertex_buffer_index;
+      key.element[nr].input_offset = draw->pt.vertex_element[i].src_offset;
       key.element[nr].output_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
       key.element[nr].output_offset = dst_offset;
 
@@ -120,7 +120,7 @@ void draw_pt_fetch_prepare( struct pt_fetch *fetch,
       {
         static struct vertex_header vh = { 0, 0, 0, 0xffff };
         fetch->translate->set_buffer(fetch->translate, 
-                                     draw->nr_vertex_buffers, 
+                                     draw->pt.nr_vertex_buffers, 
                                      &vh,
                                      0);
       }
@@ -139,12 +139,12 @@ void draw_pt_fetch_run( struct pt_fetch *fetch,
    struct translate *translate = fetch->translate;
    unsigned i;
 
-   for (i = 0; i < draw->nr_vertex_buffers; i++) {
+   for (i = 0; i < draw->pt.nr_vertex_buffers; i++) {
       translate->set_buffer(translate, 
                            i, 
-                           ((char *)draw->user.vbuffer[i] + 
-                            draw->vertex_buffer[i].buffer_offset),
-                           draw->vertex_buffer[i].pitch );
+                           ((char *)draw->pt.user.vbuffer[i] + 
+                            draw->pt.vertex_buffer[i].buffer_offset),
+                           draw->pt.vertex_buffer[i].pitch );
    }
 
    translate->run_elts( translate,
index 6e4fea460b5716bb70e6b08fc5667cbbff81d7b9..1b9b3bfaa68f7be42c9e4e757ce82289eb547de2 100644 (file)
@@ -117,7 +117,7 @@ static void fetch_emit_prepare( struct draw_pt_middle_end *middle,
    memset(&key, 0, sizeof(key));
 
    for (i = 0; i < vinfo->num_attribs; i++) {
-      const struct pipe_vertex_element *src = &draw->vertex_element[vinfo->src_index[i]];
+      const struct pipe_vertex_element *src = &draw->pt.vertex_element[vinfo->src_index[i]];
 
       unsigned emit_sz = 0;
       unsigned input_format = src->src_format;
@@ -144,7 +144,7 @@ static void fetch_emit_prepare( struct draw_pt_middle_end *middle,
          break;
       case EMIT_1F_PSIZE:
         input_format = PIPE_FORMAT_R32_FLOAT;
-        input_buffer = draw->nr_vertex_buffers;
+        input_buffer = draw->pt.nr_vertex_buffers;
         input_offset = 0;
         output_format = PIPE_FORMAT_R32_FLOAT;
         emit_sz = 1 * sizeof(float);
@@ -179,7 +179,7 @@ static void fetch_emit_prepare( struct draw_pt_middle_end *middle,
       feme->translate = translate_create( &key );
 
       feme->translate->set_buffer(feme->translate, 
-                                 draw->nr_vertex_buffers, 
+                                 draw->pt.nr_vertex_buffers, 
                                  &feme->point_size,
                                  0);
    }
index e1df594035e751129eb80b2c9cb84b9c5e7a1b2b..881e47d59d15cd534ed4a110c339b76b3ab2cad6 100644 (file)
@@ -135,7 +135,7 @@ static void fetch_pipeline_run( struct draw_pt_middle_end *middle,
       shader->run_linear(shader, 
                         (const float (*)[4])pipeline_verts->data,
                         (      float (*)[4])pipeline_verts->data,
-                        (const float (*)[4])draw->user.constants,
+                        (const float (*)[4])draw->pt.user.constants,
                         fetch_count,
                         fpme->vertex_size,
                         fpme->vertex_size);
index 5561f2b6fb4ce164c407c710a3ae5b03298b3dc6..b61bb50664fe9e1ed98a0a4d4969eb565459ab67 100644 (file)
@@ -106,7 +106,7 @@ static unsigned add_edgeflag( struct vcache_frontend *vcache,
                               unsigned idx, 
                               unsigned mask )
 {
-   if (mask && draw_get_edgeflag(vcache->draw, idx)) 
+   if (mask && draw_pt_get_edgeflag(vcache->draw, idx)) 
       return idx | DRAW_PT_EDGEFLAG;
    else
       return idx;
index f0f62246ddc81f0666c4eff655158f9e90171a19..befcb96bd89530b4fc98626d8b7f3c950f3313ef 100644 (file)
@@ -611,10 +611,10 @@ st_feedback_draw_vbo(GLcontext *ctx,
     * unmap vertex/index buffers
     */
    for (i = 0; i < PIPE_MAX_ATTRIBS; i++) {
-      if (draw->vertex_buffer[i].buffer) {
+      if (draw->pt.vertex_buffer[i].buffer) {
          pipe->winsys->buffer_unmap(pipe->winsys,
-                                    draw->vertex_buffer[i].buffer);
-         pipe_buffer_reference(winsys, &draw->vertex_buffer[i].buffer, NULL);
+                                    draw->pt.vertex_buffer[i].buffer);
+         pipe_buffer_reference(winsys, &draw->pt.vertex_buffer[i].buffer, NULL);
          draw_set_mapped_vertex_buffer(draw, i, NULL);
       }
    }