svga: Remove redundant svga_draw_range_elements.
authorChia-I Wu <olv@lunarg.com>
Sun, 1 Aug 2010 06:27:56 +0000 (14:27 +0800)
committerChia-I Wu <olv@lunarg.com>
Wed, 25 Aug 2010 08:06:38 +0000 (16:06 +0800)
That is, implement draw_vbo directly.  As a result,
svga_swtnl_draw_range_elements is also replaced by svga_swtnl_draw_vbo.

This commit should not have any functional change.

src/gallium/drivers/svga/svga_pipe_draw.c
src/gallium/drivers/svga/svga_swtnl.h
src/gallium/drivers/svga/svga_swtnl_draw.c

index de08bc5e562879f92cd35095077f704b5ba29c31..001ec3616c4017d1e92fb74ffff6cbd94d323c10 100644 (file)
@@ -146,23 +146,15 @@ retry:
 }
 
 
-
-
-
 static void
-svga_draw_range_elements( struct pipe_context *pipe,
-                          struct pipe_resource *index_buffer,
-                          unsigned index_size,
-                          int index_bias,
-                          unsigned min_index,
-                          unsigned max_index,
-                          unsigned prim, unsigned start, unsigned count)
+svga_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
 {
    struct svga_context *svga = svga_context( pipe );
-   unsigned reduced_prim = u_reduced_prim(prim);
+   unsigned reduced_prim = u_reduced_prim( info->mode );
+   unsigned count = info->count;
    enum pipe_error ret = 0;
 
-   if (!u_trim_pipe_prim( prim, &count ))
+   if (!u_trim_pipe_prim( info->mode, &count ))
       return;
 
    /*
@@ -187,34 +179,32 @@ svga_draw_range_elements( struct pipe_context *pipe,
       return;
 #endif
 
-   if (svga->state.sw.need_swtnl)
-   {
-      ret = svga_swtnl_draw_range_elements( svga, 
-                                            index_buffer, 
-                                            index_size,
-                                            index_bias,
-                                            min_index, max_index,
-                                            prim,
-                                            start, count );
+   if (svga->state.sw.need_swtnl) {
+      ret = svga_swtnl_draw_vbo( svga, info );
    }
    else {
-      if (index_buffer) {
+      if (info->indexed && svga->curr.ib.buffer) {
+         unsigned offset;
+
+         assert(svga->curr.ib.offset % svga->curr.ib.index_size == 0);
+         offset = svga->curr.ib.offset / svga->curr.ib.index_size;
+
          ret = retry_draw_range_elements( svga,
-                                          index_buffer,
-                                          index_size,
-                                          index_bias,
-                                          min_index,
-                                          max_index,
-                                          prim,
-                                          start,
-                                          count,
+                                          svga->curr.ib.buffer,
+                                          svga->curr.ib.index_size,
+                                          info->index_bias,
+                                          info->min_index,
+                                          info->max_index,
+                                          info->mode,
+                                          info->start + offset,
+                                          info->count,
                                           TRUE );
       }
       else {
-         ret = retry_draw_arrays( svga, 
-                                  prim, 
-                                  start, 
-                                  count,
+         ret = retry_draw_arrays( svga,
+                                  info->mode,
+                                  info->start,
+                                  info->count,
                                   TRUE );
       }
    }
@@ -226,30 +216,6 @@ svga_draw_range_elements( struct pipe_context *pipe,
 }
 
 
-static void
-svga_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
-{
-   struct svga_context *svga = svga_context(pipe);
-
-   if (info->indexed && svga->curr.ib.buffer) {
-      unsigned offset;
-
-      assert(svga->curr.ib.offset % svga->curr.ib.index_size == 0);
-      offset = svga->curr.ib.offset / svga->curr.ib.index_size;
-
-      svga_draw_range_elements(pipe, svga->curr.ib.buffer,
-                               svga->curr.ib.index_size, info->index_bias,
-                               info->min_index, info->max_index,
-                               info->mode, info->start + offset, info->count);
-   }
-   else {
-      svga_draw_range_elements(pipe, NULL, 0, 0,
-                               info->min_index, info->max_index,
-                               info->mode, info->start, info->count);
-   }
-}
-
-
 void svga_init_draw_functions( struct svga_context *svga )
 {
    svga->pipe.draw_vbo = svga_draw_vbo;
index 65c675f99c94cd6269d86d1a39a49dea2375184c..fc094e514282deb200f9d2d474fd35a938e94f6d 100644 (file)
@@ -38,15 +38,8 @@ void svga_destroy_swtnl( struct svga_context *svga );
 
 
 enum pipe_error
-svga_swtnl_draw_range_elements(struct svga_context *svga,
-                               struct pipe_resource *indexBuffer,
-                               unsigned indexSize,
-                               int indexBias,
-                               unsigned min_index,
-                               unsigned max_index,
-                               unsigned prim, 
-                               unsigned start, 
-                               unsigned count);
+svga_swtnl_draw_vbo(struct svga_context *svga,
+                    const struct pipe_draw_info *info);
 
 
 #endif
index eb71c23195b7b327ba232ba2aea2b02da00e33ba..4f83822b5cb10bdc27e0cc3f028e453c9acfdaff 100644 (file)
 
 
 enum pipe_error
-svga_swtnl_draw_range_elements(struct svga_context *svga,
-                               struct pipe_resource *indexBuffer,
-                               unsigned indexSize,
-                               int indexBias,
-                               unsigned min_index,
-                               unsigned max_index,
-                               unsigned prim, unsigned start, unsigned count)
+svga_swtnl_draw_vbo(struct svga_context *svga,
+                    const struct pipe_draw_info *info)
 {
    struct pipe_transfer *vb_transfer[PIPE_MAX_ATTRIBS];
    struct pipe_transfer *ib_transfer = NULL;
@@ -77,18 +72,22 @@ svga_swtnl_draw_range_elements(struct svga_context *svga,
    }
 
    /* Map index buffer, if present */
-   if (indexBuffer) {
-      map = pipe_buffer_map(&svga->pipe, indexBuffer,
+   map = NULL;
+   if (info->indexed && svga->curr.ib.buffer) {
+      map = pipe_buffer_map(&svga->pipe, svga->curr.ib.buffer,
                             PIPE_TRANSFER_READ,
-                           &ib_transfer);
-
-      draw_set_mapped_element_buffer_range(draw, 
-                                           indexSize, indexBias,
-                                           min_index,
-                                           max_index,
-                                           map);
+                            &ib_transfer);
+      if (map)
+         map = (const void *) ((const char *) map + svga->curr.ib.offset);
    }
-   
+
+   draw_set_mapped_element_buffer_range(draw, (map) ?
+                                        svga->curr.ib.index_size : 0,
+                                        info->index_bias,
+                                        info->min_index,
+                                        info->max_index,
+                                        map);
+
    if (svga->curr.cb[PIPE_SHADER_VERTEX]) {
       map = pipe_buffer_map(&svga->pipe,
                             svga->curr.cb[PIPE_SHADER_VERTEX],
@@ -101,7 +100,7 @@ svga_swtnl_draw_range_elements(struct svga_context *svga,
          svga->curr.cb[PIPE_SHADER_VERTEX]->width0);
    }
 
-   draw_arrays(svga->swtnl.draw, prim, start, count);
+   draw_arrays(draw, info->mode, info->start, info->count);
 
    draw_flush(svga->swtnl.draw);
 
@@ -117,8 +116,8 @@ svga_swtnl_draw_range_elements(struct svga_context *svga,
       draw_set_mapped_vertex_buffer(draw, i, NULL);
    }
 
-   if (indexBuffer) {
-      pipe_buffer_unmap(&svga->pipe, indexBuffer, ib_transfer);
+   if (ib_transfer) {
+      pipe_buffer_unmap(&svga->pipe, svga->curr.ib.buffer, ib_transfer);
       draw_set_mapped_element_buffer(draw, 0, 0, NULL);
    }