i965: STATIC_ASSERT that there aren't too many BRW_NEW_* flags.
authorPaul Berry <stereotype441@gmail.com>
Sun, 18 Aug 2013 16:19:35 +0000 (09:19 -0700)
committerPaul Berry <stereotype441@gmail.com>
Mon, 19 Aug 2013 15:28:17 +0000 (08:28 -0700)
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@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_context.c
src/mesa/drivers/dri/i965/brw_context.h

index 11d438be3dabf5e4d3174785b6fd412ecf0d593c..44a35d1a84013a9c61c062906289a4820e40fbd4 100644 (file)
@@ -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;
index 4067645a6d3a1bf13b6cedc723437f00ac2c018f..419cf174092fd5b27e380f0c9ed5118a81853c37 100644 (file)
@@ -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)