<p dir="ltr"><br>
On Dec 22, 2014 2:49 PM, "Ian Romanick" <<a href="mailto:idr@freedesktop.org">idr@freedesktop.org</a>> wrote:<br>
><br>
> On 12/19/2014 06:20 PM, Jason Ekstrand wrote:<br>
> > I wrote basically this same patch when I was trying to speed up<br>
> > basically the same test. Unfortunately, I wasn't able to get much of an<br>
> > improvement out of it. Other than the one nit below,<br>
> > Reviewed-by: Jason Ekstrand <<a href="mailto:jason.ekstrand@intel.com">jason.ekstrand@intel.com</a><br>
> > <mailto:<a href="mailto:jason.ekstrand@intel.com">jason.ekstrand@intel.com</a>>><br>
> ><br>
> > On Fri, Dec 19, 2014 at 2:20 PM, Ian Romanick <<a href="mailto:idr@freedesktop.org">idr@freedesktop.org</a><br>
> > <mailto:<a href="mailto:idr@freedesktop.org">idr@freedesktop.org</a>>> wrote:<br>
> ><br>
> > From: Ian Romanick <<a href="mailto:ian.d.romanick@intel.com">ian.d.romanick@intel.com</a><br>
> > <mailto:<a href="mailto:ian.d.romanick@intel.com">ian.d.romanick@intel.com</a>>><br>
> ><br>
> > Instead of having an extra pointer indirection in one of the hottest<br>
> > loops in the driver.<br>
> ><br>
> > On Bay Trail-D using Fedora 20 compile flags (-m64 -O2 -mtune=generic<br>
> > for 64-bit and -m32 -march=i686 -mtune=atom for 32-bit), affects<br>
> > Gl32Batch7:<br>
> ><br>
> > 32-bit: Difference at 95.0% confidence 1.98515% +/- 0.20814% (n=40)<br>
> > 64-bit: Difference at 95.0% confidence 1.5163% +/- 0.811016% (n=60)<br>
> ><br>
> > Signed-off-by: Ian Romanick <<a href="mailto:ian.d.romanick@intel.com">ian.d.romanick@intel.com</a><br>
> > <mailto:<a href="mailto:ian.d.romanick@intel.com">ian.d.romanick@intel.com</a>>><br>
> > ---<br>
> > src/mesa/drivers/dri/i965/brw_context.h | 2 +-<br>
> > src/mesa/drivers/dri/i965/brw_state_upload.c | 19 ++++++++++++++++---<br>
> > 2 files changed, 17 insertions(+), 4 deletions(-)<br>
> ><br>
> > diff --git a/src/mesa/drivers/dri/i965/brw_context.h<br>
> > b/src/mesa/drivers/dri/i965/brw_context.h<br>
> > index 92eb022..5f5f807 100644<br>
> > --- a/src/mesa/drivers/dri/i965/brw_context.h<br>
> > +++ b/src/mesa/drivers/dri/i965/brw_context.h<br>
> > @@ -1384,7 +1384,7 @@ struct brw_context<br>
> > } perfmon;<br>
> ><br>
> > int num_atoms;<br>
> > - const struct brw_tracked_state **atoms;<br>
> > + const struct brw_tracked_state atoms[64];<br>
> ><br>
> ><br>
> > Maybe a #define?<br>
><br>
> Hmm... What I really wanted was to somehow use ARRAY_SIZE from the other<br>
> arrays. Since the define would only be used in one place, I don't think<br>
> it's that helpful.</p>
<p dir="ltr">If you really care, you could do a bunch of MAX2 of ARRAY_SIZE and it should evaluate as a constant expression. I don't care that much.</p>
<p dir="ltr">><br>
> > /* If (INTEL_DEBUG & DEBUG_BATCH) */<br>
> > struct {<br>
> > diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c<br>
> > b/src/mesa/drivers/dri/i965/brw_state_upload.c<br>
> > index a579781..9a5d49a 100644<br>
> > --- a/src/mesa/drivers/dri/i965/brw_state_upload.c<br>
> > +++ b/src/mesa/drivers/dri/i965/brw_state_upload.c<br>
> > @@ -357,6 +357,11 @@ void brw_init_state( struct brw_context *brw )<br>
> > const struct brw_tracked_state **atoms;<br>
> > int num_atoms;<br>
> ><br>
> > + STATIC_ASSERT(ARRAY_SIZE(gen4_atoms) <= ARRAY_SIZE(brw->atoms));<br>
> > + STATIC_ASSERT(ARRAY_SIZE(gen6_atoms) <= ARRAY_SIZE(brw->atoms));<br>
> > + STATIC_ASSERT(ARRAY_SIZE(gen7_atoms) <= ARRAY_SIZE(brw->atoms));<br>
> > + STATIC_ASSERT(ARRAY_SIZE(gen8_atoms) <= ARRAY_SIZE(brw->atoms));<br>
> > +<br>
> > brw_init_caches(brw);<br>
> ><br>
> > if (brw->gen >= 8) {<br>
> > @@ -373,9 +378,17 @@ void brw_init_state( struct brw_context *brw )<br>
> > num_atoms = ARRAY_SIZE(gen4_atoms);<br>
> > }<br>
> ><br>
> > - brw->atoms = atoms;<br>
> > brw->num_atoms = num_atoms;<br>
> ><br>
> > + /* This is to work around brw_context::atoms being declared<br>
> > const. We want<br>
> > + * it to be const, but it needs to be initialized somehow!<br>
> > + */<br>
> > + struct brw_tracked_state *context_atoms =<br>
> > + (struct brw_tracked_state *) &brw->atoms[0];<br>
> > +<br>
> > + for (int i = 0; i < num_atoms; i++)<br>
> > + context_atoms[i] = *atoms[i];<br>
> > +<br>
> > while (num_atoms--) {<br>
> > assert((*atoms)->dirty.mesa | (*atoms)->dirty.brw);<br>
> > assert((*atoms)->emit);<br>
> > @@ -607,7 +620,7 @@ void brw_upload_state(struct brw_context *brw)<br>
> > prev = *state;<br>
> ><br>
> > for (i = 0; i < brw->num_atoms; i++) {<br>
> > - const struct brw_tracked_state *atom = brw->atoms[i];<br>
> > + const struct brw_tracked_state *atom = &brw->atoms[i];<br>
> > struct brw_state_flags generated;<br>
> ><br>
> > if (check_state(state, &atom->dirty)) {<br>
> > @@ -627,7 +640,7 @@ void brw_upload_state(struct brw_context *brw)<br>
> > }<br>
> > else {<br>
> > for (i = 0; i < brw->num_atoms; i++) {<br>
> > - const struct brw_tracked_state *atom = brw->atoms[i];<br>
> > + const struct brw_tracked_state *atom = &brw->atoms[i];<br>
> ><br>
> > if (check_state(state, &atom->dirty)) {<br>
> > atom->emit(brw);<br>
> > --<br>
> > 1.8.1.4<br>
> ><br>
> > _______________________________________________<br>
> > mesa-dev mailing list<br>
> > <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a> <mailto:<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a>><br>
> > <a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
> ><br>
><br>
</p>