[Mesa-dev] [PATCH 1/5] i965: Add a help function brw_insn_index to get the instruction index

Yuanhan Liu yuanhan.liu at linux.intel.com
Mon Dec 5 02:24:51 PST 2011


The reason to add a help function instead of just use 'insn - p->store'
instead is that this help function includes an assert.

Signed-off-by: Yuanhan Liu <yuanhan.liu at linux.intel.com>
---
 src/mesa/drivers/dri/i965/brw_eu.h |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_eu.h b/src/mesa/drivers/dri/i965/brw_eu.h
index dcb1fc9..c7eefe3 100644
--- a/src/mesa/drivers/dri/i965/brw_eu.h
+++ b/src/mesa/drivers/dri/i965/brw_eu.h
@@ -786,6 +786,13 @@ static INLINE struct brw_instruction *current_insn( struct brw_compile *p)
    return &p->store[p->nr_insn];
 }
 
+static INLINE int
+brw_insn_index(struct brw_compile *p, struct brw_instruction *insn)
+{
+   assert((insn - p->store < (int)p->nr_insn) && (insn - p->store > 0));
+   return insn - p->store;
+}
+
 void brw_pop_insn_state( struct brw_compile *p );
 void brw_push_insn_state( struct brw_compile *p );
 void brw_set_mask_control( struct brw_compile *p, GLuint value );
-- 
1.7.4.4



More information about the mesa-dev mailing list