[Mesa-dev] [RFC 06/21] mesa/extensions: Create _mesa_extension_supported()

Nanley Chery nanleychery at gmail.com
Thu Oct 22 15:44:59 PDT 2015


On Thu, Oct 22, 2015 at 11:08 AM, Chad Versace <chad.versace at intel.com>
wrote:

> On Thu 22 Oct 2015, Emil Velikov wrote:
> > On 19 October 2015 at 23:36, Nanley Chery <nanleychery at gmail.com> wrote:
> > > From: Nanley Chery <nanley.g.chery at intel.com>
> > >
> > > Create a function which determines if an extension is supported in the
> > > current context.
> > >
> > > Signed-off-by: Nanley Chery <nanley.g.chery at intel.com>
> > > ---
> > >  src/mesa/main/extensions.c | 17 +++++++++++++++++
> > >  1 file changed, 17 insertions(+)
> > >
> > > diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
> > > index 390e026..7137bc9 100644
> > > --- a/src/mesa/main/extensions.c
> > > +++ b/src/mesa/main/extensions.c
> > > @@ -423,6 +423,23 @@ typedef unsigned short extension_index;
> > >
> > >
> > >  /**
> > > + * Given an extension enum, return whether or not the extension is
> supported
> > > + * dependent on the following factors:
> > > + * There's driver support and the OpenGL/ES version is at least that
> > > + * specified in the extension_table.
> > > + */
> > > +static inline bool
> > > +_mesa_extension_supported(const struct gl_context *ctx,
> extension_index ei)
> > > +{
> > > +   const bool *base = (bool *) &ctx->Extensions;
> > > +   const struct extension *i = extension_table + ei;
> > > +   const uint8_t api_set = 1 << ctx->API;
> > > +   return (i->api_set & api_set) &&
> > > +          (ctx->Version >= i->version[ctx->API]) &&
> > > +          base[i->offset];
> > Bikeshed: I realise that you're copying most of these, but wouldn't it
> > be better if we use more common/intuitive variable names ?
> >
> > ei -> i or idx
> > i -> ext
>
> I second Emil's suggestion.
>

> Please insert an empty line between the block of variable declarations
> and the return statement.
>
> Also, it improves the readability if you rename the local variable
> 'api_set' to 'api_bit', because it's not really a set. It's just one
> bit.
>

I'll incorporate both changes.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20151022/a68d5a5e/attachment-0001.html>


More information about the mesa-dev mailing list