[Mesa-dev] [PATCH v3 2/3] egl: introduce a log level getter function

Silvestrs Timofejevs silvestrs.timofejevs at imgtec.com
Mon Apr 1 09:51:05 UTC 2019


Hi Emil,

thank you for your review.

On Mon, Jan 14, 2019 at 07:55:07PM +0000, Emil Velikov wrote:
> On Mon, 14 Jan 2019 at 18:20, Emil Velikov <emil.l.velikov at gmail.com> wrote:
> >
> > On 2019/01/11, Silvestrs Timofejevs wrote:
> > > Being able to retrieve the log level can be useful to enable/disable
> > > debug code. The alternative, which is calling 'getenv' function every
> > > time to retrieve the log level, is more "expensive".
> > >
> > > Signed-off-by: Silvestrs Timofejevs <silvestrs.timofejevs at imgtec.com>
> > > Reviewed-by: Eric Engestrom <eric.engestrom at intel.com>
> > > ---
> > >  src/egl/main/egllog.c | 9 +++++++++
> > >  src/egl/main/egllog.h | 4 ++++
> > >  2 files changed, 13 insertions(+)
> > >
> > > diff --git a/src/egl/main/egllog.c b/src/egl/main/egllog.c
> > > index c223f49..42bae01 100644
> > > --- a/src/egl/main/egllog.c
> > > +++ b/src/egl/main/egllog.c
> > > @@ -133,6 +133,15 @@ _eglInitLogger(void)
> > >     }
> > >  }
> > >
> > > +/**
> > > + * Return the log level.
> > > + */
> > > +EGLint
> > > +_eglGetLogLevel(void)
> > > +{
> > > +   return logging.level;
> > > +}
> > > +
> > Any particular reason why are not using _eglLog()? It does not log level
> > and VA handling for us.
> >
> Right, _eglLog is being used... silly me. I've got confused by the
> mention of getenv and expensive.
> Currently the getenv() call is a once-off thing.
> 
> I'd imagine when this work originates, when that wasn't the case.
> Hence we no longer need this micro optimisation?
This macro allows me to query the log level and on that basis "disable"
the chooseconfig and getconfigs debug functionality that I have added.
See the snippet of the code from the next patch in the patch series (V3 3/3):

EGLBoolean
_eglChooseConfig(_EGLDriver *drv, _EGLDisplay *disp, const EGLint *attrib_list,
                 EGLConfig *configs, EGLint config_size, EGLint *num_configs)
{
...
   if (result && (_eglGetLogLevel() == _EGL_DEBUG))
         eglPrintConfigDebug(drv, disp, configs, *num_configs,
		                     EGL_CONFIG_DEBUG_CHOOSE);
...
}

I think querying the log level for similar reasons could be useful in future
for other other people. It's only a simple getter, is there a better way?
> 
> -Emil

Silvestrs


More information about the mesa-dev mailing list