This patch changes the arrays in brw_vue_map (which only ever contain values from -1 to 58) from ints to signed chars. This reduces the size of the struct from 488 bytes to 136 bytes. --- src/mesa/drivers/dri/i965/brw_context.h | 4 ++-- src/mesa/drivers/dri/i965/brw_vs.c | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 11722e7..506a957 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -368,7 +368,7 @@ struct brw_vue_map { * additional processing is applied before storing them in the VUE), the * value is -1. */ - int vert_result_to_slot[BRW_VARYING_SLOT_MAX]; + signed char vert_result_to_slot[BRW_VARYING_SLOT_MAX]; /** * Map from VUE slot to gl_varying_slot value. For slots that do not @@ -379,7 +379,7 @@ struct brw_vue_map { * simplifies code that uses the value stored in slot_to_vert_result to * create a bit mask). */ - int slot_to_vert_result[BRW_VARYING_SLOT_MAX]; + signed char slot_to_vert_result[BRW_VARYING_SLOT_MAX]; /** * Total number of VUE slots in use diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c index c8ca018..7e941dd 100644 --- a/src/mesa/drivers/dri/i965/brw_vs.c +++ b/src/mesa/drivers/dri/i965/brw_vs.c @@ -66,6 +66,12 @@ brw_compute_vue_map(struct brw_context *brw, struct brw_vs_compile *c, vue_map->slots_valid = slots_valid; int i; + /* Make sure that the values we store in vue_map->vert_result_to_slot and + * vue_map->slot_to_vert_result won't overflow the signed chars that are + * used to store them. + */ + STATIC_ASSERT(BRW_VARYING_SLOT_MAX <= 128); + vue_map->num_slots = 0; for (i = 0; i < BRW_VARYING_SLOT_MAX; ++i) { vue_map->vert_result_to_slot[i] = -1; -- 1.8.2 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev