Mesa (master): i965: Shrink brw_vue_map struct.

Paul Berry stereotype441 at kemper.freedesktop.org
Sun Mar 24 17:57:14 UTC 2013


Module: Mesa
Branch: master
Commit: a593a1b2768a0d95765d2f86f1cbf69e490449ff
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a593a1b2768a0d95765d2f86f1cbf69e490449ff

Author: Paul Berry <stereotype441 at gmail.com>
Date:   Thu Mar 21 17:14:53 2013 -0700

i965: Shrink brw_vue_map struct.

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.

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

v2: fix STATIC_ASSERT to use 127 instead of 128.

Reviewed-by: Eric Anholt <eric at anholt.net>

---

 src/mesa/drivers/dri/i965/brw_context.h |    4 ++--
 src/mesa/drivers/dri/i965/brw_vs.c      |    8 ++++++++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index 01ef032..8ff70c9 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -369,7 +369,7 @@ struct brw_vue_map {
     * additional processing is applied before storing them in the VUE), the
     * value is -1.
     */
-   int varying_to_slot[BRW_VARYING_SLOT_COUNT];
+   signed char varying_to_slot[BRW_VARYING_SLOT_COUNT];
 
    /**
     * Map from VUE slot to gl_varying_slot value.  For slots that do not
@@ -380,7 +380,7 @@ struct brw_vue_map {
     * simplifies code that uses the value stored in slot_to_varying to
     * create a bit mask).
     */
-   int slot_to_varying[BRW_VARYING_SLOT_COUNT];
+   signed char slot_to_varying[BRW_VARYING_SLOT_COUNT];
 
    /**
     * 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 1a19a79..e093dd1 100644
--- a/src/mesa/drivers/dri/i965/brw_vs.c
+++ b/src/mesa/drivers/dri/i965/brw_vs.c
@@ -66,6 +66,14 @@ 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->varying_to_slot and
+    * vue_map->slot_to_varying won't overflow the signed chars that are used
+    * to store them.  Note that since vue_map->slot_to_varying sometimes holds
+    * values equal to BRW_VARYING_SLOT_COUNT, we need to ensure that
+    * BRW_VARYING_SLOT_COUNT is <= 127, not 128.
+    */
+   STATIC_ASSERT(BRW_VARYING_SLOT_COUNT <= 127);
+
    vue_map->num_slots = 0;
    for (i = 0; i < BRW_VARYING_SLOT_COUNT; ++i) {
       vue_map->varying_to_slot[i] = -1;




More information about the mesa-commit mailing list