[Mesa-dev] [PATCH 9/9] gallium: decrease the size of pipe_draw_info - 88 -> 80 bytes

Marek Olšák maraeo at gmail.com
Sun Apr 2 18:00:30 UTC 2017


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

---
 src/gallium/auxiliary/indices/u_primconvert.c | 10 ++++++++--
 src/gallium/include/pipe/p_state.h            |  2 +-
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/gallium/auxiliary/indices/u_primconvert.c b/src/gallium/auxiliary/indices/u_primconvert.c
index 2bdfade..1ffca4b 100644
--- a/src/gallium/auxiliary/indices/u_primconvert.c
+++ b/src/gallium/auxiliary/indices/u_primconvert.c
@@ -121,39 +121,45 @@ util_primconvert_draw_vbo(struct primconvert_context *pc,
    util_draw_init_info(&new_info);
    new_info.indexed = true;
    new_info.min_index = info->min_index;
    new_info.max_index = info->max_index;
    new_info.index_bias = info->index_bias;
    new_info.start_instance = info->start_instance;
    new_info.instance_count = info->instance_count;
    new_info.primitive_restart = info->primitive_restart;
    new_info.restart_index = info->restart_index;
    if (info->indexed) {
+      enum pipe_prim_type mode = 0;
+
       u_index_translator(pc->primtypes_mask,
                          info->mode, pc->saved_ib.index_size, info->count,
                          pc->api_pv, pc->api_pv,
                          info->primitive_restart ? PR_ENABLE : PR_DISABLE,
-                         &new_info.mode, &new_ib.index_size, &new_info.count,
+                         &mode, &new_ib.index_size, &new_info.count,
                          &trans_func);
+      new_info.mode = mode;
       src = ib->user_buffer;
       if (!src) {
          src = pipe_buffer_map(pc->pipe, ib->buffer,
                                PIPE_TRANSFER_READ, &src_transfer);
       }
       src = (const uint8_t *)src + ib->offset;
    }
    else {
+      enum pipe_prim_type mode = 0;
+
       u_index_generator(pc->primtypes_mask,
                         info->mode, info->start, info->count,
                         pc->api_pv, pc->api_pv,
-                        &new_info.mode, &new_ib.index_size, &new_info.count,
+                        &mode, &new_ib.index_size, &new_info.count,
                         &gen_func);
+      new_info.mode = mode;
    }
 
    u_upload_alloc(pc->pipe->stream_uploader, 0, new_ib.index_size * new_info.count, 4,
                   &new_ib.offset, &new_ib.buffer, &dst);
 
    if (info->indexed) {
       trans_func(src, info->start, info->count, new_info.count, info->restart_index, dst);
    }
    else {
       gen_func(info->start, new_info.count, dst);
diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
index d68a4d4..eeabf8b 100644
--- a/src/gallium/include/pipe/p_state.h
+++ b/src/gallium/include/pipe/p_state.h
@@ -634,21 +634,21 @@ struct pipe_index_buffer
    const void *user_buffer;  /**< pointer to a user buffer if buffer == NULL */
 };
 
 
 /**
  * Information to describe a draw_vbo call.
  */
 struct pipe_draw_info
 {
    boolean indexed;  /**< use index buffer */
-   enum pipe_prim_type mode;  /**< the mode of the primitive */
+   enum pipe_prim_type mode:8;  /**< the mode of the primitive */
    boolean primitive_restart;
    ubyte vertices_per_patch; /**< the number of vertices per patch */
 
    unsigned start;  /**< the index of the first vertex */
    unsigned count;  /**< number of vertices */
 
    unsigned start_instance; /**< first instance id */
    unsigned instance_count; /**< number of instances */
 
    unsigned drawid; /**< id of this draw in a multidraw */
-- 
2.7.4



More information about the mesa-dev mailing list