[Mesa-dev] [PATCH] glsl: reuse main extension table to appropriate restrict extensions

Nanley Chery nanleychery at gmail.com
Mon Jun 13 16:39:39 UTC 2016


On Mon, Jun 13, 2016 at 9:16 AM, Ilia Mirkin <imirkin at alum.mit.edu> wrote:

> On Mon, Jun 13, 2016 at 12:11 PM, Emil Velikov <emil.l.velikov at gmail.com>
> wrote:
> > Hi Ilia,
> >
> > On 13 June 2016 at 00:23, Ilia Mirkin <imirkin at alum.mit.edu> wrote:
> >
> >> @@ -81,6 +81,7 @@ MAIN_FILES = \
> >>         main/execmem.c \
> >>         main/extensions.c \
> >>         main/extensions.h \
> >> +       main/extensions_table.c \
> > From a build perspective everything looks amazing. Thank you !
>
> Thanks for checking.
>
> >
> >
> >> --- a/src/mesa/main/extensions.c
> >> +++ b/src/mesa/main/extensions.c
> >> @@ -49,25 +49,15 @@ static char *extra_extensions = NULL;
> >>  #define o(x) offsetof(struct gl_extensions, x)
> >>
> >>
> >> -/**
> >> - * \brief Table of supported OpenGL extensions for all API's.
> >> - */
> >> -const struct mesa_extension _mesa_extension_table[] = {
> >> +static bool extension_table_size[] = {
> >>  #define EXT(name_str, driver_cap, gll_ver, glc_ver, gles_ver,
> gles2_ver, yyyy) \
> >> -        { .name = "GL_" #name_str, .offset = o(driver_cap), \
> >> -          .version = { \
> >> -            [API_OPENGL_COMPAT] = gll_ver, \
> >> -            [API_OPENGL_CORE]   = glc_ver, \
> >> -            [API_OPENGLES]      = gles_ver, \
> >> -            [API_OPENGLES2]     = gles2_ver, \
> >> -           }, \
> >> -           .year = yyyy \
> >> -        },
> >> +   0,
> >> +
> >>  #include "extensions_table.h"
> >>  #undef EXT
> >>  };
> >>
> > An alternative idea to the one proposed by Eric:
> > Explicitly set the array size (ideally as a macro in the relevant
> > header) and use that instead of having a dummy array, only to know the
> > array size.
>
> I couldn't come up with a non-horrible way of doing that. Are you
> basically suggesting I add a
>
> #define EXTENSIONS_COUNT 10000
>
> in extensions_table.h, and expect someone to increment it every time
> an extension was being added?
>
> I guess it could be enforced via a STATIC_ASSERT in the new
> extensions_table.c, but it feels really dirty. I guess a cleverer
> thing would be to count by doing something horrible for the compiler,
> e.g.
>
> static const int foo = 0 +1+1+1+1+1+1......
>
> Probably nicer than my array of 0's though. Open to other ideas.
>
>
You can add an entry to the end of the enum defined in extensions.h called
"MESA_EXTENSION_COUNT"  or similar.

- Nanley


>   -ilia
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160613/bd79fbeb/attachment.html>


More information about the mesa-dev mailing list