[Mesa-dev] [PATCH 5/9] i965: treat the fixed blorp clear base mrf as constant

Pohjolainen, Topi topi.pohjolainen at intel.com
Thu Nov 28 23:56:39 PST 2013


On Thu, Nov 28, 2013 at 11:45:54PM -0800, Kenneth Graunke wrote:
> On 11/27/2013 01:13 PM, Topi Pohjolainen wrote:
> > Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
> > ---
> >  src/mesa/drivers/dri/i965/brw_blorp_clear.cpp | 7 ++-----
> >  1 file changed, 2 insertions(+), 5 deletions(-)
> > 
> > diff --git a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
> > index a937edb..d25c6cb 100644
> > --- a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
> > +++ b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
> > @@ -108,7 +108,7 @@ private:
> >     struct brw_reg clear_rgba;
> >  
> >     /* MRF used for render target writes */
> > -   GLuint base_mrf;
> > +   static const unsigned base_mrf = 2;
> >  };
> >  
> >  brw_blorp_const_color_program::brw_blorp_const_color_program(
> > @@ -117,8 +117,7 @@ brw_blorp_const_color_program::brw_blorp_const_color_program(
> >     : mem_ctx(ralloc_context(NULL)),
> >       brw(brw),
> >       key(key),
> > -     clear_rgba(),
> > -     base_mrf(0)
> > +     clear_rgba()
> >  {
> >     brw_init_compile(brw, &func, mem_ctx);
> >  }
> > @@ -362,8 +361,6 @@ brw_blorp_const_color_program::alloc_regs()
> >  
> >     /* Make sure we didn't run out of registers */
> >     assert(reg <= GEN7_MRF_HACK_START);
> > -
> > -   this->base_mrf = 2;
> >  }
> >  
> >  const GLuint *
> > 
> 
> I like changing this from a mutable class member into a constant.
> 
> However, I would go one step further and just make it a local variable
> in brw_blorp_const_color_program::compile().
> 
> (When variables are only used in one function, I prefer declaring them
> there rather than creating class members.)

I fully agree, this is in fact leftover from a previous version where I had the
non-replicated logic in its own member function. But as all the logic is now in
one place, there is no point having the constant as a member anymore. Thanks
for pointing it out!


More information about the mesa-dev mailing list