Mesa (master): i965: STATIC_ASSERT that there aren' t too many BRW_NEW_* flags.

Paul Berry stereotype441 at kemper.freedesktop.org
Mon Aug 19 15:29:18 UTC 2013


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

Author: Paul Berry <stereotype441 at gmail.com>
Date:   Sun Aug 18 09:19:35 2013 -0700

i965: STATIC_ASSERT that there aren't too many BRW_NEW_* flags.

We are getting close to the maximum number of BRW_NEW_* bits that can
be stored in brw->state.dirty.brw without overflowing 32 bits, and
geometry shaders are going to add more.  Add a STATIC_ASSERT so that
we will be alerted when we need to switch to 64 bits.

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

---

 src/mesa/drivers/dri/i965/brw_context.c |    5 +++++
 src/mesa/drivers/dri/i965/brw_context.h |    1 +
 2 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index 11d438b..44a35d1 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -448,6 +448,11 @@ brwCreateContext(int api,
    brw->state.dirty.mesa = ~0;
    brw->state.dirty.brw = ~0;
 
+   /* Make sure that brw->state.dirty.brw has enough bits to hold all possible
+    * dirty flags.
+    */
+   STATIC_ASSERT(BRW_NUM_STATE_BITS <= 8 * sizeof(brw->state.dirty.brw));
+
    brw->emit_state_always = 0;
 
    brw->batch.need_workaround_flush = true;
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index 4067645..419cf17 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -155,6 +155,7 @@ enum brw_state_id {
    BRW_STATE_UNIFORM_BUFFER,
    BRW_STATE_META_IN_PROGRESS,
    BRW_STATE_INTERPOLATION_MAP,
+   BRW_NUM_STATE_BITS
 };
 
 #define BRW_NEW_URB_FENCE               (1 << BRW_STATE_URB_FENCE)




More information about the mesa-commit mailing list