[Mesa-dev] [RFC PATCH 3/3] gallium: remove pipe_index_buffer and set_index_buffer

Marek Olšák maraeo at gmail.com
Tue Apr 11 20:15:05 UTC 2017


From: Marek Olšák <marek.olsak at amd.com>

pipe_draw_info::indexed is replaced with index_size. index_size == 0 means
non-indexed.

Instead of pipe_index_buffer::offset, pipe_draw_info::start is used.
For indexed indirect draws, pipe_draw_info::start is added to the indirect
start. This is the only case when "start" affects indirect draws.

pipe_draw_info::index is a union. Use either index::buffer or
index::user_buffer depending on the value of pipe_draw_info
::has_user_indices.

Performance numbers with the drawoverhead microbenchmark.

Before::
   DrawElements only: 4.5 million draws/second
   DrawElements w/ nop state change: 4.4 million draws/sec (overhead: 0.000007 ms/draw)
   DrawElements w/ state change: 1.9 million draws/sec (overhead: 0.000293 ms/draw)

After:
   DrawElements only: 5.0 million draws/second
   DrawElements w/ nop state change: 4.9 million draws/sec (overhead: 0.000007 ms/draw)
   DrawElements w/ state change: 2.2 million draws/sec (overhead: 0.000254 ms/draw)

The improvement will be much smaller with real apps.
---
 src/gallium/include/pipe/p_context.h |  4 ----
 src/gallium/include/pipe/p_state.h   | 35 ++++++++++++++++++-----------------
 2 files changed, 18 insertions(+), 21 deletions(-)

diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h
index 4d5535b..4b75386 100644
--- a/src/gallium/include/pipe/p_context.h
+++ b/src/gallium/include/pipe/p_context.h
@@ -53,7 +53,6 @@ struct pipe_grid_info;
 struct pipe_fence_handle;
 struct pipe_framebuffer_state;
 struct pipe_image_view;
-struct pipe_index_buffer;
 struct pipe_query;
 struct pipe_poly_stipple;
 struct pipe_rasterizer_state;
@@ -354,9 +353,6 @@ struct pipe_context {
                                unsigned num_buffers,
                                const struct pipe_vertex_buffer * );
 
-   void (*set_index_buffer)( struct pipe_context *pipe,
-                             const struct pipe_index_buffer * );
-
    /*@}*/
 
    /**
diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
index 69d2378..7f482d4 100644
--- a/src/gallium/include/pipe/p_state.h
+++ b/src/gallium/include/pipe/p_state.h
@@ -630,19 +630,6 @@ struct pipe_vertex_element
 };
 
 
-/**
- * An index buffer.  When an index buffer is bound, all indices to vertices
- * will be looked up in the buffer.
- */
-struct pipe_index_buffer
-{
-   unsigned index_size;  /**< size of an index, in bytes */
-   unsigned offset;  /**< offset to start of data in buffer, in bytes */
-   struct pipe_resource *buffer; /**< the actual buffer */
-   const void *user_buffer;  /**< pointer to a user buffer if buffer == NULL */
-};
-
-
 struct pipe_draw_indirect_info
 {
    unsigned offset; /**< must be 4 byte aligned */
@@ -652,7 +639,7 @@ struct pipe_draw_indirect_info
 
    /* Indirect draw parameters resource is laid out as follows:
     *
-    * if indexed is TRUE:
+    * if using indexed drawing:
     *  struct {
     *     uint32_t count;
     *     uint32_t instance_count;
@@ -682,12 +669,18 @@ struct pipe_draw_indirect_info
  */
 struct pipe_draw_info
 {
-   boolean indexed;  /**< use index buffer */
+   ubyte index_size;  /**< if 0, the draw is not indexed. */
    enum pipe_prim_type mode:8;  /**< the mode of the primitive */
-   boolean primitive_restart;
+   unsigned primitive_restart:1;
+   unsigned has_user_indices:1; /**< if true, use index.user_buffer */
    ubyte vertices_per_patch; /**< the number of vertices per patch */
 
-   unsigned start;  /**< the index of the first vertex */
+   /**
+    * Direct draws: start is the index of the first vertex
+    * Non-indexed indirect draws: not used
+    * Indexed indirect draws: start is added to the indirect start.
+    */
+   unsigned start;
    unsigned count;  /**< number of vertices */
 
    unsigned start_instance; /**< first instance id */
@@ -709,6 +702,14 @@ struct pipe_draw_info
 
    /* Pointers must be at the end for an optimal structure layout on 64-bit. */
 
+   /**
+    * An index buffer.  When an index buffer is bound, all indices to vertices
+    * will be looked up from the buffer.
+    *
+    * If has_user_indices, use index.user_buffer, else use index.buffer.
+    */
+   union pipe_buffer_binding index;
+
    struct pipe_draw_indirect_info *indirect; /**< Indirect draw. */
 
    /**
-- 
2.7.4



More information about the mesa-dev mailing list